-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.mjs
More file actions
59 lines (52 loc) · 1.49 KB
/
build.mjs
File metadata and controls
59 lines (52 loc) · 1.49 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
import * as esbuild from "esbuild";
import { mkdirSync, writeFileSync, chmodSync, copyFileSync } from "node:fs";
const sharedConfig = {
bundle: true,
platform: "node",
format: "cjs",
target: "node18",
minify: false,
sourcemap: false,
};
const entries = [
{ in: "src/cli.ts", out: "dist/cli.js" },
...["recall", "flush"].map((n) => ({
in: `src/hooks/${n}.ts`,
out: `dist/hooks/${n}.js`,
})),
...["search-memory", "save-memory", "forget-memory", "login"].map((n) => ({
in: `src/skills/${n}.ts`,
out: `dist/skills/${n}.js`,
})),
];
await Promise.all(
entries.map((e) =>
esbuild.build({
...sharedConfig,
entryPoints: [e.in],
outfile: e.out,
banner: { js: "#!/usr/bin/env node" },
})
)
);
// Copy SKILL.md files to dist
for (const skillName of ["supermemory-search", "supermemory-save", "supermemory-forget", "supermemory-login"]) {
mkdirSync(`dist/skills/${skillName}`, { recursive: true });
copyFileSync(
`src/skills/${skillName}/SKILL.md`,
`dist/skills/${skillName}/SKILL.md`
);
}
// The root package.json declares `"type": "module"`, but esbuild emits CommonJS.
// Drop a CJS marker into dist/ so Node loads the bundles correctly.
mkdirSync("dist", { recursive: true });
writeFileSync("dist/package.json", JSON.stringify({ type: "commonjs" }, null, 2));
// Make the executables actually executable.
for (const e of entries) {
try {
chmodSync(e.out, 0o755);
} catch {
// ignore
}
}
console.log("Build complete!");