Skip to content

Commit

Permalink
Merge pull request #129 from qld-gov-au/QOLOE-122-handlebars-helper-fix
Browse files Browse the repository at this point in the history
QOLOE-122 correct handlebars loading by having an init function to wrap it
  • Loading branch information
stvp-qld authored May 17, 2024
2 parents d2c4d7e + 95d8cb0 commit 1da57b5
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 45 deletions.
12 changes: 6 additions & 6 deletions .esbuild/plugins/qgds-plugin-clean-output-folders.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function cleanFoldersPlugin() {
setup(build) {
build.onStart(() => {
//Console feedback
log("cyan", `\u{1F4C2} Cleaning /dist and /docs folders\n\n`);
log("cyan", `\u{1F4C2} Cleaning /dist folders\n\n`);

// Clean the output folders
const { outdir, outfile } = build.initialOptions;
Expand All @@ -20,11 +20,11 @@ export default function cleanFoldersPlugin() {
fs.rmSync(outfile);
}

// Clean the docs folder
const docsdir = "./docs/";
if (fs.existsSync(docsdir)) {
fs.rmSync(docsdir, { recursive: true });
}
// // Clean the docs folder
// const docsdir = "./docs/";
// if (fs.existsSync(docsdir)) {
// fs.rmSync(docsdir, { recursive: true });
// }
});
},
};
Expand Down
8 changes: 5 additions & 3 deletions .esbuild/plugins/qgds-plugin-copy-assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ export default function copyPlugin() {
to: ["./dist/sample-data/"],
},
{
from: ["./src/js/handlebars.helpers.js"],
from: ["./src/js/handlebars*"],
to: ["./dist/assets/js"],
},
{
from: ["./src/js/handlebars*"],
to: ["./dist/components/"],
},
{ from: ["./src/assets/img/*"], to: ["./dist/assets/img"] },
{ from: ["./dist/**/*"], to: ["./docs/"] },
{ from: ["./storybook-static/**/*"], to: ["./docs/storybook-static/"] },
],
});

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Storybook-library-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down
14 changes: 2 additions & 12 deletions .github/workflows/compile.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down Expand Up @@ -74,21 +74,11 @@ jobs:
- name: Build 🔧
run: | # build the files
npm run build
# - name: Build storybook 🔧
# run: | # build the Storybook files
# npm run build-storybook

- name: setup Package
run: |
ls -ltr
mkdir -p ./target/docs
cp -r ./docs ./target/docs
cp -r ./dist ./target/dist
- uses: actions/[email protected]
with:
name: Package
path: ./target
path: ./dist


- name: Extract branch name
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/githubPackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npmjsPackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/storybook-deploy.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ docs/
dist/
.idea
*.iml
docs/storybook-static

13 changes: 0 additions & 13 deletions .npmgnore

This file was deleted.

9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ git clone https://github.com/qld-gov-au/qgds-qol-mvp

### Prerequisites

- Node 18.17.1
- NPM 10.2.5
- Node 18.17.1+
- NPM 10.2.5+

### Install dependencies

Expand Down Expand Up @@ -59,7 +59,10 @@ npm run serve

### Next steps

- HTML templating using drop in components
- HTML templating using drop in components

If you wish to use the includes handle bars, please ensure
"handlebars": "4.7.8" + is loaded prior to running handlebars.helpers.bundle.js
- Dev build and testing branching

## Documentation
Expand Down
6 changes: 5 additions & 1 deletion esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ const buildConfig = {
out: "./assets/css/qld.bootstrap",
},
{
in: "./src/js/handlebars.helpers.js",
in: "./src/js/handlebars.init.js",
out: "./assets/js/handlebars.helpers.bundle",
},
{
in: "./src/js/handlebars.init.js",
out: "./components/handlebars.helpers.bundle",
},
],

loader: {
Expand Down
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,25 @@
"license": "ISC",
"type": "module",
"files": [
".esbuild",
".storybook",
".vscode",
"dist",
"docs"
"src",
".eslintrc.cjs",
"esbuild.js",
"jsconfig.json",
"pom.xml",
"README.md",
"vite.config.js"
],
"dependencies": {
"@fortawesome/fontawesome-free": "^6.5.2",
"bootstrap": "^5.3.1",
"material-symbols": "^0.17.4"
},
"devDependencies": {
"handlebars": "4.7.8",
"@chromatic-com/storybook": "^1.3.5",
"@storybook/addon-essentials": "^8.1.0",
"@storybook/addon-interactions": "^8.1.0",
Expand Down Expand Up @@ -75,6 +85,8 @@
"exports": {
"qld.bootstrap.min.js": "./dist/assets/js/qld.bootstrap.min.js",
"qld.bootstrap.css": "./dist/assets/css/qld.bootstrap.css",
"handlebars.helpers.bundle.js": "./dist/components/handlebars.helpers.bundle.js",
"handlebars.init.js": "./dist/components/handlebars.init.js",
"bootstrap.min.js": "./dist/assets/js/boostrap.min.js"
}
}
6 changes: 6 additions & 0 deletions src/js/handlebars.init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import handlebarsHelpers from "./handlebars.helpers.js";
import Handlebars from "handlebars";
export * from "./handlebars.helpers.js";

export const init = () => handlebarsHelpers(Handlebars);

0 comments on commit 1da57b5

Please sign in to comment.