diff --git a/.github/workflows/edge.yml b/.github/workflows/edge.yml index 27b695be..c7b9ade0 100644 --- a/.github/workflows/edge.yml +++ b/.github/workflows/edge.yml @@ -33,4 +33,5 @@ jobs: prerelease: true files: | website/CHANGELOG.md + dist/plug-compile.js silverbullet-*.zip diff --git a/build_bundle.ts b/build_bundle.ts index 202099c5..06efc9b0 100644 --- a/build_bundle.ts +++ b/build_bundle.ts @@ -8,6 +8,7 @@ await Deno.mkdir("dist", { recursive: true }); await esbuild.build({ entryPoints: { silverbullet: "silverbullet.ts", + "plug-compile": "plug-compile.ts", }, outdir: "dist", format: "esm", @@ -22,11 +23,11 @@ await esbuild.build({ configPath: new URL("./deno.json", import.meta.url).pathname, }), }); -const bundleJs = await Deno.readTextFile("dist/silverbullet.js"); +const plugBundleJS = await Deno.readTextFile("dist/plug-compile.js"); // Patch output JS with import.meta.main override to avoid ESBuild CLI handling await Deno.writeTextFile( - "dist/silverbullet.js", - "import.meta.main = false;\n" + bundleJs, + "dist/plug-compile.js", + "import.meta.main = false;\n" + plugBundleJS, ); -console.log("Output in dist/silverbullet.js"); +console.log("Output in dist"); esbuild.stop(); diff --git a/plug-compile.ts b/plug-compile.ts new file mode 100755 index 00000000..5e7bef25 --- /dev/null +++ b/plug-compile.ts @@ -0,0 +1,38 @@ +import.meta.main = false; +import { Command } from "@cliffy/command"; + +import { version } from "./version.ts"; + +import { versionCommand } from "./cmd/version.ts"; +import { plugCompileCommand } from "./cmd/plug_compile.ts"; + +await new Command() + .name("plug-compile") + .description("Bundle (compile) one or more plug manifests") + .version(version) + .helpOption(false) + .usage(" | (see below)") + .arguments("<...name.plug.yaml:string>") + .option("--debug", "Do not minifiy code", { default: false }) + .option("--info", "Print out size info per function", { + default: false, + }) + .option("--watch, -w [type:boolean]", "Watch for changes and rebuild", { + default: false, + }) + .option( + "--dist ", + "Folder to put the resulting .plug.json file into", + { default: "." }, + ) + .option("--importmap ", "Path to import map file to use") + .option("-c, --config ", "Path to deno.json file to use") + .option("--runtimeUrl ", "URL to worker_runtime.ts to use") + .action(plugCompileCommand) + // version + .command("version") + .description("Get current version") + .action(versionCommand) + .parse(Deno.args); + +Deno.exit(0); diff --git a/silverbullet.ts b/silverbullet.ts index 96feacd2..6de80f21 100755 --- a/silverbullet.ts +++ b/silverbullet.ts @@ -1,4 +1,3 @@ -import.meta.main = false; import { Command } from "@cliffy/command"; import { version } from "./version.ts"; @@ -6,7 +5,6 @@ import { version } from "./version.ts"; import { upgradeCommand, upgradeEdgeCommand } from "./cmd/upgrade.ts"; import { versionCommand } from "./cmd/version.ts"; import { serveCommand } from "./cmd/server.ts"; -import { plugCompileCommand } from "./cmd/plug_compile.ts"; import { syncCommand } from "./cmd/sync.ts"; // Unhandled rejection, let's not crash @@ -33,26 +31,6 @@ await new Command() "'username:password' combo for authentication", ) .action(serveCommand) - // plug:compile - .command("plug:compile") - .description("Bundle (compile) one or more plug manifests") - .arguments("<...name.plug.yaml:string>") - .option("--debug", "Do not minifiy code", { default: false }) - .option("--info", "Print out size info per function", { - default: false, - }) - .option("--watch, -w [type:boolean]", "Watch for changes and rebuild", { - default: false, - }) - .option( - "--dist ", - "Folder to put the resulting .plug.json file into", - { default: "." }, - ) - .option("--importmap ", "Path to import map file to use") - .option("-c, --config ", "Path to deno.json file to use") - .option("--runtimeUrl ", "URL to worker_runtime.ts to use") - .action(plugCompileCommand) // upgrade .command("upgrade") .description("Upgrade SilverBullet") @@ -79,5 +57,3 @@ await new Command() .description("Get current version") .action(versionCommand) .parse(Deno.args); - -Deno.exit(0);