mirror of
https://github.com/wanghuan9/obsidian-feishu-lark-cli-sync.git
synced 2026-07-22 07:47:44 +00:00
50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
import { readFile, writeFile } from "fs/promises";
|
|
import { builtinModules } from "node:module";
|
|
import esbuild from "esbuild";
|
|
|
|
await esbuild.build({
|
|
bundle: true,
|
|
entryPoints: ["src/lark-sync-core.ts"],
|
|
format: "esm",
|
|
logLevel: "silent",
|
|
minify: true,
|
|
outfile: "lark-sync-core.mjs",
|
|
platform: "node",
|
|
target: "node20",
|
|
treeShaking: true,
|
|
external: [
|
|
...builtinModules
|
|
]
|
|
});
|
|
|
|
await esbuild.build({
|
|
bundle: true,
|
|
entryPoints: ["src/lark-cli-command.ts"],
|
|
format: "esm",
|
|
logLevel: "silent",
|
|
minify: true,
|
|
outfile: "lark-cli-command.mjs",
|
|
platform: "node",
|
|
target: "node20",
|
|
treeShaking: true,
|
|
external: [
|
|
...builtinModules
|
|
]
|
|
});
|
|
|
|
const files = [
|
|
["sync-pre-push.mjs", "EMBEDDED_PRE_PUSH_SCRIPT"],
|
|
["lark-sync-core.mjs", "EMBEDDED_PRE_PUSH_CORE_SCRIPT"],
|
|
["lark-cli-command.mjs", "EMBEDDED_LARK_CLI_COMMAND_SCRIPT"]
|
|
];
|
|
|
|
const lines = [
|
|
"// Generated by scripts/generate-embedded-helpers.mjs. Do not edit manually."
|
|
];
|
|
|
|
for (const [file, exportName] of files) {
|
|
const content = await readFile(file, "utf8");
|
|
lines.push(`export const ${exportName} = ${JSON.stringify(content)};`);
|
|
}
|
|
|
|
await writeFile("src/embedded-helpers.ts", `${lines.join("\n")}\n`);
|