🎉 init: 小龙的工作空间
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Build script — builds both web and api.
|
||||
* Usage: node scripts/build.mjs
|
||||
*/
|
||||
|
||||
import { execSync } from "node:child_process";
|
||||
|
||||
const ROOT = new URL("..", import.meta.url).pathname;
|
||||
|
||||
function run(cmd, cwd) {
|
||||
console.log(`\n🔨 ${cmd} (in ${cwd})`);
|
||||
execSync(cmd, { cwd, stdio: "inherit" });
|
||||
}
|
||||
|
||||
console.log("🏗️ Building fullstack project...\n");
|
||||
|
||||
try {
|
||||
run("npm run build", `${ROOT}/apps/api`);
|
||||
run("npm run build", `${ROOT}/apps/web`);
|
||||
console.log("\n✅ Build complete!");
|
||||
} catch (e) {
|
||||
console.error("\n❌ Build failed:", e.message);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Dev script — starts both web and api in parallel.
|
||||
* Usage: node scripts/dev.mjs
|
||||
*/
|
||||
|
||||
import { spawn } from "node:child_process";
|
||||
|
||||
function start(name, command, args, cwd) {
|
||||
const child = spawn(command, args, {
|
||||
cwd,
|
||||
stdio: "inherit",
|
||||
shell: true,
|
||||
env: { ...process.env, FORCE_COLOR: "1" },
|
||||
});
|
||||
child.on("error", (err) => console.error(`[${name}] Failed: ${err.message}`));
|
||||
child.on("exit", (code) => {
|
||||
if (code !== 0 && code !== null) console.error(`[${name}] Exited with code ${code}`);
|
||||
});
|
||||
return child;
|
||||
}
|
||||
|
||||
const ROOT = new URL("..", import.meta.url).pathname;
|
||||
|
||||
console.log("🚀 Starting fullstack dev servers...\n");
|
||||
|
||||
const api = start("api", "npm", ["run", "dev"], `${ROOT}/apps/api`);
|
||||
const web = start("web", "npm", ["run", "dev"], `${ROOT}/apps/web`);
|
||||
|
||||
process.on("SIGINT", () => { api.kill(); web.kill(); process.exit(0); });
|
||||
process.on("SIGTERM", () => { api.kill(); web.kill(); process.exit(0); });
|
||||
Reference in New Issue
Block a user