From dbd553640f434771df7cf4afb85b7fd31a00e1e2 Mon Sep 17 00:00:00 2001
From: Vic
Date: Sat, 13 Jul 2024 01:40:31 -0500
Subject: [PATCH] add postcommit
---
.husky/post-commit | 6 ++++++
.husky/postcommit.sh | 8 ++++++++
.husky/pre-commit | 3 +--
.husky/precommit.sh | 1 +
client/assets/Notes.md | 1 +
client/assets/pages.js | 24 ------------------------
client/assets/partials.js | 20 --------------------
client/src/utils/hbsAsyncHelper.js | 2 +-
client/src/views/pages/body.hbs | 2 +-
client/wrangler.toml | 6 +++++-
10 files changed, 24 insertions(+), 49 deletions(-)
create mode 100644 .husky/post-commit
create mode 100644 .husky/postcommit.sh
create mode 100644 client/assets/Notes.md
delete mode 100644 client/assets/pages.js
delete mode 100644 client/assets/partials.js
diff --git a/.husky/post-commit b/.husky/post-commit
new file mode 100644
index 0000000..7e63942
--- /dev/null
+++ b/.husky/post-commit
@@ -0,0 +1,6 @@
+# .husky/post-commit
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+sh ./.husky/postcommit.sh
+
diff --git a/.husky/postcommit.sh b/.husky/postcommit.sh
new file mode 100644
index 0000000..24607e8
--- /dev/null
+++ b/.husky/postcommit.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+FILE="./client/wrangler.toml"
+if [ -f "$FILE" ]; then
+ mv ~/tmp.wrangler.toml $FILE
+else
+ echo "$FILE does not exist."
+fi
+
diff --git a/.husky/pre-commit b/.husky/pre-commit
index 1ca15f0..edd2f85 100644
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -2,5 +2,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
-sh ./.husky/precommit.sh
-
+sh ./.husky/precommit.sh
\ No newline at end of file
diff --git a/.husky/precommit.sh b/.husky/precommit.sh
index 6eb3dce..996cf3e 100644
--- a/.husky/precommit.sh
+++ b/.husky/precommit.sh
@@ -1,6 +1,7 @@
#!/bin/sh
FILE="./client/wrangler.toml"
if [ -f "$FILE" ]; then
+ cp $FILE ~/tmp.wrangler.toml
sed -i -e 's/account_id = ".*"/account_id = "**********"/' $FILE
echo "$FILE updated"
git add -A
diff --git a/client/assets/Notes.md b/client/assets/Notes.md
new file mode 100644
index 0000000..3f95fc9
--- /dev/null
+++ b/client/assets/Notes.md
@@ -0,0 +1 @@
+This folder hosts asset files that are built from handlebars.
\ No newline at end of file
diff --git a/client/assets/pages.js b/client/assets/pages.js
deleted file mode 100644
index 0b7e2d3..0000000
--- a/client/assets/pages.js
+++ /dev/null
@@ -1,24 +0,0 @@
-import Handlebars from 'handlebars/runtime.js';
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
-templates['body'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
- var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) {
- if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
- return parent[propertyName];
- }
- return undefined
- };
-
- return "\r\n\r\n"
- + ((stack1 = container.invokePartial(lookupProperty(partials,"structure/htmlhead"),depth0,{"name":"structure/htmlhead","data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
- + "\r\n Cloudflare Workers with Handlebars \r\n\r\n\r\n\r\n"
- + ((stack1 = container.invokePartial(lookupProperty(partials,"structure/header"),depth0,{"name":"structure/header","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
- + "\r\n\r\n
\r\n
\r\n\r\n
\r\n
\r\n"
- + ((stack1 = container.invokePartial(lookupProperty(partials,"logos/cloudflare"),depth0,{"name":"logos/cloudflare","data":data,"indent":" ","helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
- + "
\r\n
\r\n\r\n
This template is rendered by Handlebars in a Cloudflare Worker! \r\n\r\n
\r\n Your name: "
- + alias3(((helper = (helper = lookupProperty(helpers,"name") || (depth0 != null ? lookupProperty(depth0,"name") : depth0)) != null ? helper : alias2),(typeof helper === "function" ? helper.call(alias1,{"name":"name","hash":{},"data":data,"loc":{"start":{"line":24,"column":44},"end":{"line":24,"column":52}}}) : helper)))
- + "\r\n
\r\n\r\n
"
- + alias3((lookupProperty(helpers,"asyncTest")||(depth0 && lookupProperty(depth0,"asyncTest"))||alias2).call(alias1,{"name":"asyncTest","hash":{"age":38,"name":"Vic Tester"},"data":data,"loc":{"start":{"line":27,"column":17},"end":{"line":27,"column":55}}}))
- + " \r\n\r\n
\r\n
\r\n
\r\n\r\n"
- + ((stack1 = container.invokePartial(lookupProperty(partials,"structure/footer"),depth0,{"name":"structure/footer","data":data,"helpers":helpers,"partials":partials,"decorators":container.decorators})) != null ? stack1 : "")
- + "\r\n";
-},"usePartial":true,"useData":true});
diff --git a/client/assets/partials.js b/client/assets/partials.js
deleted file mode 100644
index 16b8393..0000000
--- a/client/assets/partials.js
+++ /dev/null
@@ -1,20 +0,0 @@
-import Handlebars from 'handlebars/runtime.js';
- var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
-Handlebars.partials['logos/cloudflare'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
- return "\r\n\r\n \r\n \r\n \r\n Cloudflare logo \r\n \r\n \r\n \r\n \r\n ";
-},"useData":true});
-Handlebars.partials['logos/handlebars'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
- return "";
-},"useData":true});
-Handlebars.partials['structure/footer'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
- return "\r\n Footer component.\r\n ";
-},"useData":true});
-Handlebars.partials['structure/footerlibs'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
- return "";
-},"useData":true});
-Handlebars.partials['structure/header'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
- return "\r\n \r\n Cloudflare Handlebars Worker \r\n
\r\n \r\n ";
-},"useData":true});
-Handlebars.partials['structure/htmlhead'] = template({"compiler":[8,">= 4.3.0"],"main":function(container,depth0,helpers,partials,data) {
- return " ";
-},"useData":true});
diff --git a/client/src/utils/hbsAsyncHelper.js b/client/src/utils/hbsAsyncHelper.js
index 716d52e..8b2d577 100644
--- a/client/src/utils/hbsAsyncHelper.js
+++ b/client/src/utils/hbsAsyncHelper.js
@@ -11,7 +11,7 @@ export const registerHBHelper = () => registerAsyncHelper(Handlebars,'asyncTest'
return new Promise((resolve, reject) => {
setTimeout(
function() {
- resolve(`Async render with params: ${options.hash.name} || ${options.hash.age}`)
+ resolve(`Async render with params: ${options.hash.name}`)
},
200
);
diff --git a/client/src/views/pages/body.hbs b/client/src/views/pages/body.hbs
index ce5e4dc..7b80430 100644
--- a/client/src/views/pages/body.hbs
+++ b/client/src/views/pages/body.hbs
@@ -24,7 +24,7 @@
Your name: {{name}}
- {{asyncTest name='Vic Tester' age=38}}
+ {{asyncTest name='Vic Tester'}}
diff --git a/client/wrangler.toml b/client/wrangler.toml
index 17672b3..1724e7e 100644
--- a/client/wrangler.toml
+++ b/client/wrangler.toml
@@ -1,4 +1,8 @@
name = "tech"
account_id = "**********"
workers_dev = true
-compatibility_date = "2024-07-11"
\ No newline at end of file
+compatibility_date = "2024-07-11"
+
+[build]
+command="npm run build"
+watch_dir="views/"
\ No newline at end of file