forked from silverbulletmd/silverbullet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_plugs_libraries.ts
More file actions
71 lines (60 loc) · 2.11 KB
/
build_plugs_libraries.ts
File metadata and controls
71 lines (60 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import * as path from "@std/path";
import * as esbuild from "esbuild";
import { compileManifests } from "./client/plugos/plug_compile.ts";
import { builtinPlugNames } from "./plugs/builtin_plugs.ts";
import { parseArgs } from "@std/cli/parse-args";
import { fileURLToPath } from "node:url";
import { copy } from "@std/fs";
import { version } from "./version.ts";
// This builds all built-in plugs and libraries and puts them into client_bundle/base_fs
if (import.meta.main) {
await updateVersionFile();
const args = parseArgs(Deno.args, {
boolean: ["debug", "reload", "info"],
alias: { w: "watch" },
});
const manifests = builtinPlugNames.map((name) =>
`./plugs/${name}/${name}.plug.yaml`
);
const plugBundlePath = "client_bundle/base_fs";
const targetDir = path.join(plugBundlePath, "Library", "Std", "Plugs");
Deno.mkdirSync(targetDir, { recursive: true });
Deno.mkdirSync("dist", { recursive: true });
// Copy Library files
await copy("libraries/Library", `${plugBundlePath}/Library`, {
overwrite: true,
});
await copy("libraries/Repositories", `${plugBundlePath}/Repositories`, {
overwrite: true,
});
// Build the plugs
await compileManifests(
manifests,
targetDir,
{
debug: args.debug,
info: args.info,
configPath: fileURLToPath(new URL("deno.json", import.meta.url)),
},
);
esbuild.stop();
}
export async function updateVersionFile() {
const command = new Deno.Command("git", {
args: ["describe", "--tags", "--long"],
stdout: "piped",
stderr: "piped",
});
const { stdout } = await command.output();
let commitVersion = new TextDecoder().decode(stdout).trim();
if (!commitVersion) {
// Probably no valid .git repo, fallback to GITHUB_SHA env var (used in CI)
commitVersion = `${version}-${Deno.env.get("GITHUB_SHA") || "unknown"}`;
}
const versionFilePath = "./public_version.ts";
const versionContent = `export const publicVersion = "${commitVersion}";`;
await Deno.writeTextFile(versionFilePath, versionContent);
console.log(
`Updated public_version.ts with version information: ${commitVersion}`,
);
}