Skip to content

Commit cdacf05

Browse files
committed
Moving plug:compile into separate executable step 1
1 parent 32be2f6 commit cdacf05

File tree

4 files changed

+44
-28
lines changed

4 files changed

+44
-28
lines changed

.github/workflows/edge.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ jobs:
3333
prerelease: true
3434
files: |
3535
website/CHANGELOG.md
36+
dist/plug-compile.js
3637
silverbullet-*.zip

build_bundle.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ await Deno.mkdir("dist", { recursive: true });
88
await esbuild.build({
99
entryPoints: {
1010
silverbullet: "silverbullet.ts",
11+
"plug-compile": "plug-compile.ts",
1112
},
1213
outdir: "dist",
1314
format: "esm",
@@ -22,11 +23,11 @@ await esbuild.build({
2223
configPath: new URL("./deno.json", import.meta.url).pathname,
2324
}),
2425
});
25-
const bundleJs = await Deno.readTextFile("dist/silverbullet.js");
26+
const plugBundleJS = await Deno.readTextFile("dist/plug-compile.js");
2627
// Patch output JS with import.meta.main override to avoid ESBuild CLI handling
2728
await Deno.writeTextFile(
28-
"dist/silverbullet.js",
29-
"import.meta.main = false;\n" + bundleJs,
29+
"dist/plug-compile.js",
30+
"import.meta.main = false;\n" + plugBundleJS,
3031
);
31-
console.log("Output in dist/silverbullet.js");
32+
console.log("Output in dist");
3233
esbuild.stop();

plug-compile.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import.meta.main = false;
2+
import { Command } from "@cliffy/command";
3+
4+
import { version } from "./version.ts";
5+
6+
import { versionCommand } from "./cmd/version.ts";
7+
import { plugCompileCommand } from "./cmd/plug_compile.ts";
8+
9+
await new Command()
10+
.name("plug-compile")
11+
.description("Bundle (compile) one or more plug manifests")
12+
.version(version)
13+
.helpOption(false)
14+
.usage("<options> <manifest paths> | <command> (see below)")
15+
.arguments("<...name.plug.yaml:string>")
16+
.option("--debug", "Do not minifiy code", { default: false })
17+
.option("--info", "Print out size info per function", {
18+
default: false,
19+
})
20+
.option("--watch, -w [type:boolean]", "Watch for changes and rebuild", {
21+
default: false,
22+
})
23+
.option(
24+
"--dist <path:string>",
25+
"Folder to put the resulting .plug.json file into",
26+
{ default: "." },
27+
)
28+
.option("--importmap <path:string>", "Path to import map file to use")
29+
.option("-c, --config <path:string>", "Path to deno.json file to use")
30+
.option("--runtimeUrl <url:string>", "URL to worker_runtime.ts to use")
31+
.action(plugCompileCommand)
32+
// version
33+
.command("version")
34+
.description("Get current version")
35+
.action(versionCommand)
36+
.parse(Deno.args);
37+
38+
Deno.exit(0);

silverbullet.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import.meta.main = false;
21
import { Command } from "@cliffy/command";
32

43
import { version } from "./version.ts";
54

65
import { upgradeCommand, upgradeEdgeCommand } from "./cmd/upgrade.ts";
76
import { versionCommand } from "./cmd/version.ts";
87
import { serveCommand } from "./cmd/server.ts";
9-
import { plugCompileCommand } from "./cmd/plug_compile.ts";
108
import { syncCommand } from "./cmd/sync.ts";
119

1210
// Unhandled rejection, let's not crash
@@ -33,26 +31,6 @@ await new Command()
3331
"'username:password' combo for authentication",
3432
)
3533
.action(serveCommand)
36-
// plug:compile
37-
.command("plug:compile")
38-
.description("Bundle (compile) one or more plug manifests")
39-
.arguments("<...name.plug.yaml:string>")
40-
.option("--debug", "Do not minifiy code", { default: false })
41-
.option("--info", "Print out size info per function", {
42-
default: false,
43-
})
44-
.option("--watch, -w [type:boolean]", "Watch for changes and rebuild", {
45-
default: false,
46-
})
47-
.option(
48-
"--dist <path:string>",
49-
"Folder to put the resulting .plug.json file into",
50-
{ default: "." },
51-
)
52-
.option("--importmap <path:string>", "Path to import map file to use")
53-
.option("-c, --config <path:string>", "Path to deno.json file to use")
54-
.option("--runtimeUrl <url:string>", "URL to worker_runtime.ts to use")
55-
.action(plugCompileCommand)
5634
// upgrade
5735
.command("upgrade")
5836
.description("Upgrade SilverBullet")
@@ -79,5 +57,3 @@ await new Command()
7957
.description("Get current version")
8058
.action(versionCommand)
8159
.parse(Deno.args);
82-
83-
Deno.exit(0);

0 commit comments

Comments
 (0)