refactor: extract seed provision scripts to dedicated directory

Move bootstrap, default, and inform scripts from inline template
strings in lib/init.ts to standalone files under seed/, loaded via
an esbuild text-loader plugin. Add type-checking (provisions.d.ts,
tsconfig.json) and ESLint config for the seed scripts. Set tsconfig
module to Preserve to support import attributes.
This commit is contained in:
Zaid Humaimidi committed 2026-03-13 13:48:45 -07:00
1 parent f39e2ce7cf
commit d445aa03cf
10 files changed
+236 -56

No files matched your search

+14 -1
View File
@@ -92,6 +92,19 @@ const assetsPlugin = {
},
} as esbuild.Plugin;
const seedPlugin = {
name: "seed",
setup(build) {
build.onLoad({ filter: /\/seed\// }, (args) => {
if (args.with?.["type"] !== "text") return undefined;
let contents = fs.readFileSync(args.path, "utf8");
// Strip TypeScript directives that are only needed for type-checking
contents = contents.replace(/^\s*\/\/\s*@ts-.*\n/gm, "");
return { contents, loader: "text" };
});
},
} as esbuild.Plugin;
const packageDotJsonPlugin = {
name: "packageDotJson",
setup(build) {
@@ -295,7 +308,7 @@ async function generateBackendJs(): Promise<void> {
banner: { js: "#!/usr/bin/env node" },
entryPoints: services.map((s) => `bin/${s}.ts`),
outdir: path.join(OUTPUT_DIR, "bin"),
plugins: [packageDotJsonPlugin, assetsPlugin],
plugins: [packageDotJsonPlugin, assetsPlugin, seedPlugin],
});
for (const bin of services) {
+2 -2
View File
@@ -5,7 +5,7 @@ const execPromise = promisify(exec);
async function runEslint(): Promise<string> {
const CMD =
"eslint 'bin/*.ts' 'lib/**/*.ts' 'ui/**/*.ts' 'test/**/*.ts' 'build/**/*.ts'";
"eslint 'bin/*.ts' 'lib/**/*.ts' 'ui/**/*.ts' 'test/**/*.ts' 'build/**/*.ts' 'seed/*'";
const env = {
...(process.stdout.isTTY && { FORCE_COLOR: "1" }),
...process.env,
@@ -21,7 +21,7 @@ async function runEslint(): Promise<string> {
}
async function runTsc(): Promise<string> {
const CMD = "tsc --noEmit";
const CMD = "tsc --noEmit && tsc -p seed/tsconfig.json";
const env = {
...(process.stdout.isTTY && { FORCE_COLOR: "1" }),
...process.env,