From cf7bf3f344e482a03fd7519e54b1bfaab157099e Mon Sep 17 00:00:00 2001 From: aleidk Date: Fri, 11 Apr 2025 19:33:42 -0400 Subject: [PATCH 1/7] fix: remove unecesary dependency --- package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/package.json b/package.json index a589498..40ed893 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "bin": "./index.ts", "dependencies": { "@alecodes/bun-plugin-sass": "^0.1.3", - "@alecodes/bun-static-builder": "^0.1.0", }, "devDependencies": { "@types/bun": "latest" From e43815f2a6d8324ac4f1da59215c79b299c00f31 Mon Sep 17 00:00:00 2001 From: aleidk Date: Fri, 11 Apr 2025 19:33:47 -0400 Subject: [PATCH 2/7] chore(version): v0.1.1 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa99c3b..24611ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines. - - - +## v0.1.1 - 2025-04-11 +#### Bug Fixes +- remove unecesary dependency - (cf7bf3f) - aleidk + +- - - + ## v0.1.0 - 2025-04-11 #### Features - first release - (154eca7) - aleidk diff --git a/package.json b/package.json index 40ed893..5555037 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.1.0", + "version": "0.1.1", "name": "@alecodes/tmpl-build-and-load", "module": "index.ts", "type": "module", From b4a551489c1173ab2560519f820c5b66d77e9b92 Mon Sep 17 00:00:00 2001 From: aleidk Date: Fri, 11 Apr 2025 19:40:59 -0400 Subject: [PATCH 3/7] fix: add shebang to entrypoint --- index.ts | 84 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/index.ts b/index.ts index a664a4d..76cfd13 100644 --- a/index.ts +++ b/index.ts @@ -1,30 +1,32 @@ +#!/usr/bin/env bun + import sassPlugin from "@alecodes/bun-plugin-sass"; import { parseArgs } from "node:util"; import path from "node:path"; const { values } = parseArgs({ - args: Bun.argv, - options: { - globs: { - type: "string", - short: "g", - }, - outdir: { - type: "string", - short: "o", - }, - bundle_name: { - type: "string", - short: "n", - default: "main", - }, - }, - strict: true, - allowPositionals: true, + args: Bun.argv, + options: { + globs: { + type: "string", + short: "g", + }, + outdir: { + type: "string", + short: "o", + }, + bundle_name: { + type: "string", + short: "n", + default: "main", + }, + }, + strict: true, + allowPositionals: true, }); if (values.globs === undefined || values.outdir === undefined) { - throw new Error("Error in the arguments provided."); + throw new Error("Error in the arguments provided."); } console.log(`Building glob "${values.globs}" to "${values.outdir}"`); @@ -33,39 +35,39 @@ console.log(`Building glob "${values.globs}" to "${values.outdir}"`); const entrypoints = Array.from(new Bun.Glob(values.globs).scanSync(".")); const result = await Bun.build({ - entrypoints, - publicPath: "/", - // splitting: true, - plugins: [sassPlugin], - minify: { - whitespace: true, - identifiers: true, - syntax: true, - }, - naming: { - entry: "[dir]/[name].[ext]", - chunk: "assets/[name]-[hash].[ext]", - asset: "assets/[name]-[hash].[ext]", - }, + entrypoints, + publicPath: "/", + // splitting: true, + plugins: [sassPlugin], + minify: { + whitespace: true, + identifiers: true, + syntax: true, + }, + naming: { + entry: "[dir]/[name].[ext]", + chunk: "assets/[name]-[hash].[ext]", + asset: "assets/[name]-[hash].[ext]", + }, }); let out = ""; out += "|env: &mut minijinja::Environment| {\n"; for (const res of result.outputs) { - // Can be consumed as blobs - let asset_text = await res.text(); - asset_text = asset_text.replaceAll(/\n/g, "\\n"); - asset_text = asset_text.replaceAll(/"/g, `\\"`); - const asset_path = path.normalize(res.path); - out += `env.add_template("${asset_path}", "${asset_text}").expect("Embedded an invalid template");\n`; + // Can be consumed as blobs + let asset_text = await res.text(); + asset_text = asset_text.replaceAll(/\n/g, "\\n"); + asset_text = asset_text.replaceAll(/"/g, `\\"`); + const asset_path = path.normalize(res.path); + out += `env.add_template("${asset_path}", "${asset_text}").expect("Embedded an invalid template");\n`; } out += "}"; Bun.write( - path.join(values.outdir, `minijinja_templates_${values.bundle_name}.rs`), - out, + path.join(values.outdir, `minijinja_templates_${values.bundle_name}.rs`), + out, ); console.log("Assets compiled!"); From 5786338063a3a4c87d5269576b9e7cd28371abff Mon Sep 17 00:00:00 2001 From: aleidk Date: Fri, 11 Apr 2025 19:41:08 -0400 Subject: [PATCH 4/7] chore(version): v0.1.2 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24611ad..b9cc8c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines. - - - +## v0.1.2 - 2025-04-11 +#### Bug Fixes +- add shebang to entrypoint - (b4a5514) - aleidk + +- - - + ## v0.1.1 - 2025-04-11 #### Bug Fixes - remove unecesary dependency - (cf7bf3f) - aleidk diff --git a/package.json b/package.json index 5555037..e02c0f4 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.1.1", + "version": "0.1.2", "name": "@alecodes/tmpl-build-and-load", "module": "index.ts", "type": "module", From f6077d4a1d9e146e8fa298cbeab0a04e35809e5f Mon Sep 17 00:00:00 2001 From: aleidk Date: Fri, 11 Apr 2025 19:42:35 -0400 Subject: [PATCH 5/7] docs: fix example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6be599e..dd2d336 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ fn main() { let output = Command::new("bun") .args([ "run", - "scripts/build.ts", + "tmpl-build-and-load", "--outdir", out_dir.as_str(), "--globs", From a1b480fc4748e73b1ecd640f25675c4f9b82b184 Mon Sep 17 00:00:00 2001 From: aleidk Date: Mon, 14 Apr 2025 11:31:59 -0400 Subject: [PATCH 6/7] fix: use raw string to prevent quote issues --- index.ts | 81 +++++++++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/index.ts b/index.ts index 76cfd13..d65cc97 100644 --- a/index.ts +++ b/index.ts @@ -5,28 +5,28 @@ import { parseArgs } from "node:util"; import path from "node:path"; const { values } = parseArgs({ - args: Bun.argv, - options: { - globs: { - type: "string", - short: "g", - }, - outdir: { - type: "string", - short: "o", - }, - bundle_name: { - type: "string", - short: "n", - default: "main", - }, - }, - strict: true, - allowPositionals: true, + args: Bun.argv, + options: { + globs: { + type: "string", + short: "g", + }, + outdir: { + type: "string", + short: "o", + }, + bundle_name: { + type: "string", + short: "n", + default: "main", + }, + }, + strict: true, + allowPositionals: true, }); if (values.globs === undefined || values.outdir === undefined) { - throw new Error("Error in the arguments provided."); + throw new Error("Error in the arguments provided."); } console.log(`Building glob "${values.globs}" to "${values.outdir}"`); @@ -35,40 +35,37 @@ console.log(`Building glob "${values.globs}" to "${values.outdir}"`); const entrypoints = Array.from(new Bun.Glob(values.globs).scanSync(".")); const result = await Bun.build({ - entrypoints, - publicPath: "/", - // splitting: true, - plugins: [sassPlugin], - minify: { - whitespace: true, - identifiers: true, - syntax: true, - }, - naming: { - entry: "[dir]/[name].[ext]", - chunk: "assets/[name]-[hash].[ext]", - asset: "assets/[name]-[hash].[ext]", - }, + entrypoints, + publicPath: "/", + // splitting: true, + plugins: [sassPlugin], + minify: { + whitespace: true, + identifiers: true, + syntax: true, + }, + naming: { + entry: "[dir]/[name].[ext]", + chunk: "assets/[name]-[hash].[ext]", + asset: "assets/[name]-[hash].[ext]", + }, }); let out = ""; out += "|env: &mut minijinja::Environment| {\n"; for (const res of result.outputs) { - // Can be consumed as blobs - let asset_text = await res.text(); - asset_text = asset_text.replaceAll(/\n/g, "\\n"); - asset_text = asset_text.replaceAll(/"/g, `\\"`); - const asset_path = path.normalize(res.path); - out += `env.add_template("${asset_path}", "${asset_text}").expect("Embedded an invalid template");\n`; + // Can be consumed as blobs + const asset_text = await res.text(); + const asset_path = path.normalize(res.path); + out += `env.add_template("${asset_path}", r##"${asset_text}"##).expect("Embedded an invalid template");\n`; } out += "}"; Bun.write( - path.join(values.outdir, `minijinja_templates_${values.bundle_name}.rs`), - out, + path.join(values.outdir, `minijinja_templates_${values.bundle_name}.rs`), + out, ); console.log("Assets compiled!"); - From 76b8d3b34298f970138fb05d531dfc1304804156 Mon Sep 17 00:00:00 2001 From: aleidk Date: Mon, 14 Apr 2025 11:32:52 -0400 Subject: [PATCH 7/7] chore(version): v0.1.3 --- CHANGELOG.md | 8 ++++++++ package.json | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9cc8c1..a561dfe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines. - - - +## v0.1.3 - 2025-04-14 +#### Bug Fixes +- use raw string to prevent quote issues - (a1b480f) - aleidk +#### Documentation +- fix example - (f6077d4) - aleidk + +- - - + ## v0.1.2 - 2025-04-11 #### Bug Fixes - add shebang to entrypoint - (b4a5514) - aleidk diff --git a/package.json b/package.json index e02c0f4..a3afe23 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "version": "0.1.2", + "version": "0.1.3", "name": "@alecodes/tmpl-build-and-load", "module": "index.ts", "type": "module",