express-file-cluster 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.cjs +98 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +16 -0
- package/dist/auth/index.d.ts +16 -0
- package/dist/auth/index.js +59 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/cli/index.cjs +380 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +1 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +357 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.cjs +541 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +498 -0
- package/dist/index.js.map +1 -0
- package/dist/tasks/index.cjs +70 -0
- package/dist/tasks/index.cjs.map +1 -0
- package/dist/tasks/index.d.cts +16 -0
- package/dist/tasks/index.d.ts +16 -0
- package/dist/tasks/index.js +41 -0
- package/dist/tasks/index.js.map +1 -0
- package/dist/types-DNdkDUPX.d.cts +70 -0
- package/dist/types-DNdkDUPX.d.ts +70 -0
- package/package.json +69 -0
- package/src/auth/index.ts +71 -0
- package/src/cli/commands/build.ts +43 -0
- package/src/cli/commands/diagnostics.ts +124 -0
- package/src/cli/commands/generate.ts +91 -0
- package/src/cli/commands/run.ts +28 -0
- package/src/cli/commands/start.ts +74 -0
- package/src/cli/index.ts +22 -0
- package/src/cluster/index.ts +31 -0
- package/src/compose.ts +26 -0
- package/src/db/index.ts +31 -0
- package/src/db/model.ts +95 -0
- package/src/db/mongo.ts +22 -0
- package/src/errors.ts +10 -0
- package/src/index.ts +127 -0
- package/src/router/mount.test.ts +75 -0
- package/src/router/mount.ts +49 -0
- package/src/router/scan.test.ts +23 -0
- package/src/router/scan.ts +55 -0
- package/src/tasks/bullmq-backend.ts +76 -0
- package/src/tasks/index.ts +51 -0
- package/src/tasks/scanner.test.ts +58 -0
- package/src/tasks/scanner.ts +30 -0
- package/src/tasks/thread-runner.ts +40 -0
- package/src/types.ts +68 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +26 -0
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli/index.ts
|
|
4
|
+
import { Command as Command6 } from "commander";
|
|
5
|
+
|
|
6
|
+
// src/cli/commands/start.ts
|
|
7
|
+
import { Command } from "commander";
|
|
8
|
+
import { spawn } from "child_process";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import fs from "fs";
|
|
11
|
+
import chalk from "chalk";
|
|
12
|
+
function startCommand() {
|
|
13
|
+
const cmd = new Command("start");
|
|
14
|
+
cmd.argument("<mode>", "dev | prod").description("Start the EFC server").action((mode) => {
|
|
15
|
+
if (mode === "dev") {
|
|
16
|
+
startDev();
|
|
17
|
+
} else if (mode === "prod") {
|
|
18
|
+
startProd();
|
|
19
|
+
} else {
|
|
20
|
+
console.error(chalk.red(`Unknown mode: ${mode}. Use 'dev' or 'prod'.`));
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return cmd;
|
|
25
|
+
}
|
|
26
|
+
function startDev() {
|
|
27
|
+
const entry = resolveEntry();
|
|
28
|
+
if (!entry) {
|
|
29
|
+
console.error(chalk.red("[EFC] Could not find entry point. Expected src/index.ts or index.ts"));
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
console.log(chalk.cyan("[EFC] Starting development server\u2026"));
|
|
33
|
+
console.log(chalk.dim(` Entry: ${entry}`));
|
|
34
|
+
const child = spawn(
|
|
35
|
+
"node",
|
|
36
|
+
["--import", "tsx/esm", "--watch", entry],
|
|
37
|
+
{ stdio: "inherit", env: { ...process.env, NODE_ENV: "development" } }
|
|
38
|
+
);
|
|
39
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
40
|
+
}
|
|
41
|
+
function startProd() {
|
|
42
|
+
const cwd = process.cwd();
|
|
43
|
+
const distEntry = path.join(cwd, "dist", "index.js");
|
|
44
|
+
if (!fs.existsSync(distEntry)) {
|
|
45
|
+
console.error(chalk.red("[EFC] dist/index.js not found. Run `efc build prod` first."));
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
console.log(chalk.cyan("[EFC] Starting production server\u2026"));
|
|
49
|
+
const child = spawn("node", [distEntry], {
|
|
50
|
+
stdio: "inherit",
|
|
51
|
+
env: { ...process.env, NODE_ENV: "production" }
|
|
52
|
+
});
|
|
53
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
54
|
+
}
|
|
55
|
+
function resolveEntry() {
|
|
56
|
+
const cwd = process.cwd();
|
|
57
|
+
const candidates = [
|
|
58
|
+
path.join(cwd, "src", "index.ts"),
|
|
59
|
+
path.join(cwd, "index.ts"),
|
|
60
|
+
path.join(cwd, "src", "index.js"),
|
|
61
|
+
path.join(cwd, "index.js")
|
|
62
|
+
];
|
|
63
|
+
return candidates.find((f) => fs.existsSync(f)) ?? null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/cli/commands/build.ts
|
|
67
|
+
import { Command as Command2 } from "commander";
|
|
68
|
+
import { spawn as spawn2 } from "child_process";
|
|
69
|
+
import chalk2 from "chalk";
|
|
70
|
+
function buildCommand() {
|
|
71
|
+
const cmd = new Command2("build");
|
|
72
|
+
cmd.argument("<mode>", "prod").description("Build the application for production").action((mode) => {
|
|
73
|
+
if (mode !== "prod") {
|
|
74
|
+
console.error(chalk2.red(`Unknown build mode: ${mode}. Use 'prod'.`));
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
buildProd();
|
|
78
|
+
});
|
|
79
|
+
return cmd;
|
|
80
|
+
}
|
|
81
|
+
function buildProd() {
|
|
82
|
+
console.log(chalk2.cyan("[EFC] Building for production\u2026"));
|
|
83
|
+
const tsc = spawn2("npx", ["tsc", "--noEmit"], { stdio: "inherit" });
|
|
84
|
+
tsc.on("exit", (code) => {
|
|
85
|
+
if (code !== 0) {
|
|
86
|
+
console.error(chalk2.red("[EFC] TypeScript errors found. Fix them before building."));
|
|
87
|
+
process.exit(1);
|
|
88
|
+
}
|
|
89
|
+
const tsup = spawn2("npx", ["tsup"], { stdio: "inherit" });
|
|
90
|
+
tsup.on("exit", (tsupCode) => {
|
|
91
|
+
if (tsupCode === 0) {
|
|
92
|
+
console.log(chalk2.green("[EFC] Build complete \u2192 dist/"));
|
|
93
|
+
} else {
|
|
94
|
+
process.exit(tsupCode ?? 1);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// src/cli/commands/run.ts
|
|
101
|
+
import { Command as Command3 } from "commander";
|
|
102
|
+
import { spawn as spawn3 } from "child_process";
|
|
103
|
+
import chalk3 from "chalk";
|
|
104
|
+
function runCommand() {
|
|
105
|
+
const cmd = new Command3("run");
|
|
106
|
+
cmd.argument("<runner>", "tests").description("Run EFC sub-commands (tests)").allowUnknownOption().action((runner) => {
|
|
107
|
+
if (runner === "tests") {
|
|
108
|
+
runTests(cmd.args.slice(1));
|
|
109
|
+
} else {
|
|
110
|
+
console.error(chalk3.red(`Unknown runner: ${runner}. Use 'tests'.`));
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return cmd;
|
|
115
|
+
}
|
|
116
|
+
function runTests(extraArgs) {
|
|
117
|
+
console.log(chalk3.cyan("[EFC] Running tests via Vitest\u2026"));
|
|
118
|
+
const child = spawn3("npx", ["vitest", "run", ...extraArgs], { stdio: "inherit" });
|
|
119
|
+
child.on("exit", (code) => process.exit(code ?? 0));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/cli/commands/generate.ts
|
|
123
|
+
import { Command as Command4 } from "commander";
|
|
124
|
+
import fs2 from "fs";
|
|
125
|
+
import path2 from "path";
|
|
126
|
+
import chalk4 from "chalk";
|
|
127
|
+
function generateCommand() {
|
|
128
|
+
const cmd = new Command4("generate").alias("g").description("Scaffold EFC modules");
|
|
129
|
+
cmd.command("route <routePath>").description("Scaffold a route module, e.g. users/[id]").action((routePath) => generateRoute(routePath));
|
|
130
|
+
cmd.command("task <name>").description("Scaffold a background task module").action((name) => generateTask(name));
|
|
131
|
+
cmd.command("middleware <name>").description("Scaffold a middleware module").action((name) => generateMiddleware(name));
|
|
132
|
+
return cmd;
|
|
133
|
+
}
|
|
134
|
+
function writeFile(filePath, content) {
|
|
135
|
+
const dir = path2.dirname(filePath);
|
|
136
|
+
fs2.mkdirSync(dir, { recursive: true });
|
|
137
|
+
if (fs2.existsSync(filePath)) {
|
|
138
|
+
console.error(chalk4.red(`File already exists: ${filePath}`));
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
fs2.writeFileSync(filePath, content, "utf8");
|
|
142
|
+
console.log(chalk4.green(` created ${path2.relative(process.cwd(), filePath)}`));
|
|
143
|
+
}
|
|
144
|
+
function generateRoute(routePath) {
|
|
145
|
+
const cwd = process.cwd();
|
|
146
|
+
const filePath = path2.join(cwd, "src", "api", `${routePath}.ts`);
|
|
147
|
+
const content = `import type { Request, Response } from 'express';
|
|
148
|
+
|
|
149
|
+
export const GET = async (req: Request, res: Response) => {
|
|
150
|
+
res.json({ message: 'OK' });
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const POST = async (req: Request, res: Response) => {
|
|
154
|
+
res.status(201).json({ message: 'Created' });
|
|
155
|
+
};
|
|
156
|
+
`;
|
|
157
|
+
writeFile(filePath, content);
|
|
158
|
+
console.log(chalk4.cyan(`[EFC] Route scaffolded`));
|
|
159
|
+
}
|
|
160
|
+
function generateTask(name) {
|
|
161
|
+
const cwd = process.cwd();
|
|
162
|
+
const filePath = path2.join(cwd, "src", "tasks", `${name}.ts`);
|
|
163
|
+
const content = `import { defineTask } from 'express-file-cluster/tasks';
|
|
164
|
+
|
|
165
|
+
interface ${name}Payload {
|
|
166
|
+
// TODO: define payload fields
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export default defineTask<${name}Payload>(async (payload) => {
|
|
170
|
+
// TODO: implement task logic
|
|
171
|
+
console.log('[Task:${name}]', payload);
|
|
172
|
+
});
|
|
173
|
+
`;
|
|
174
|
+
writeFile(filePath, content);
|
|
175
|
+
console.log(chalk4.cyan(`[EFC] Task scaffolded`));
|
|
176
|
+
}
|
|
177
|
+
function generateMiddleware(name) {
|
|
178
|
+
const cwd = process.cwd();
|
|
179
|
+
const filePath = path2.join(cwd, "src", "middlewares", `${name}.ts`);
|
|
180
|
+
const content = `import type { Request, Response, NextFunction } from 'express';
|
|
181
|
+
|
|
182
|
+
export function ${name}(req: Request, res: Response, next: NextFunction): void {
|
|
183
|
+
// TODO: implement middleware logic
|
|
184
|
+
next();
|
|
185
|
+
}
|
|
186
|
+
`;
|
|
187
|
+
writeFile(filePath, content);
|
|
188
|
+
console.log(chalk4.cyan(`[EFC] Middleware scaffolded`));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// src/cli/commands/diagnostics.ts
|
|
192
|
+
import { Command as Command5 } from "commander";
|
|
193
|
+
|
|
194
|
+
// src/router/scan.ts
|
|
195
|
+
import fs3 from "fs";
|
|
196
|
+
import path3 from "path";
|
|
197
|
+
var ROUTE_FILE_RE = /\.(ts|js|mts|mjs|cts|cjs)$/;
|
|
198
|
+
var DYNAMIC_SEGMENT_RE = /\[([^\]]+)\]/g;
|
|
199
|
+
function filePathToUrlPath(relativePath) {
|
|
200
|
+
let p = relativePath.replace(ROUTE_FILE_RE, "");
|
|
201
|
+
p = p.replace(/\/index$/, "");
|
|
202
|
+
p = p.replace(DYNAMIC_SEGMENT_RE, ":$1");
|
|
203
|
+
return p === "" ? "/" : p.startsWith("/") ? p : `/${p}`;
|
|
204
|
+
}
|
|
205
|
+
function extractParams(relativePath) {
|
|
206
|
+
const params = [];
|
|
207
|
+
let match;
|
|
208
|
+
const re = new RegExp(DYNAMIC_SEGMENT_RE.source, "g");
|
|
209
|
+
while ((match = re.exec(relativePath)) !== null) {
|
|
210
|
+
if (match[1]) params.push(match[1]);
|
|
211
|
+
}
|
|
212
|
+
return params;
|
|
213
|
+
}
|
|
214
|
+
function scanDir(dir, base = dir) {
|
|
215
|
+
if (!fs3.existsSync(dir)) return [];
|
|
216
|
+
const entries = [];
|
|
217
|
+
const items = fs3.readdirSync(dir, { withFileTypes: true });
|
|
218
|
+
for (const item of items) {
|
|
219
|
+
const fullPath = path3.join(dir, item.name);
|
|
220
|
+
if (item.isDirectory()) {
|
|
221
|
+
entries.push(...scanDir(fullPath, base));
|
|
222
|
+
} else if (ROUTE_FILE_RE.test(item.name)) {
|
|
223
|
+
const relative = "/" + path3.relative(base, fullPath).replace(/\\/g, "/");
|
|
224
|
+
entries.push({
|
|
225
|
+
urlPath: filePathToUrlPath(relative),
|
|
226
|
+
filePath: fullPath,
|
|
227
|
+
params: extractParams(relative)
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return entries.sort((a, b) => {
|
|
232
|
+
const aDynamic = a.urlPath.includes(":") ? 1 : 0;
|
|
233
|
+
const bDynamic = b.urlPath.includes(":") ? 1 : 0;
|
|
234
|
+
return aDynamic - bDynamic || a.urlPath.localeCompare(b.urlPath);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// src/cli/commands/diagnostics.ts
|
|
239
|
+
import path4 from "path";
|
|
240
|
+
import fs4 from "fs";
|
|
241
|
+
import chalk5 from "chalk";
|
|
242
|
+
function diagnosticsCommands() {
|
|
243
|
+
return [routesCommand(), tasksCommand(), doctorCommand()];
|
|
244
|
+
}
|
|
245
|
+
function routesCommand() {
|
|
246
|
+
return new Command5("routes").description("Print the resolved route table").action(() => {
|
|
247
|
+
const apiDir = resolveApiDir();
|
|
248
|
+
if (!apiDir) {
|
|
249
|
+
console.error(chalk5.red("[EFC] Could not find apiDir (expected src/api)"));
|
|
250
|
+
process.exit(1);
|
|
251
|
+
}
|
|
252
|
+
const routes = scanDir(apiDir);
|
|
253
|
+
if (routes.length === 0) {
|
|
254
|
+
console.log(chalk5.yellow("No routes found."));
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
console.log(chalk5.bold("\n Route Table\n"));
|
|
258
|
+
console.log(chalk5.dim(" " + "\u2500".repeat(60)));
|
|
259
|
+
for (const route of routes) {
|
|
260
|
+
const rel = path4.relative(process.cwd(), route.filePath);
|
|
261
|
+
console.log(` ${chalk5.cyan(route.urlPath.padEnd(35))} ${chalk5.dim(rel)}`);
|
|
262
|
+
}
|
|
263
|
+
console.log(chalk5.dim(" " + "\u2500".repeat(60)));
|
|
264
|
+
console.log(chalk5.dim(`
|
|
265
|
+
${routes.length} route(s) found
|
|
266
|
+
`));
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function tasksCommand() {
|
|
270
|
+
return new Command5("tasks").description("List registered background tasks").action(() => {
|
|
271
|
+
const tasksDir = resolveTasksDir();
|
|
272
|
+
if (!tasksDir || !fs4.existsSync(tasksDir)) {
|
|
273
|
+
console.log(chalk5.yellow("No tasks directory found."));
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
const files = fs4.readdirSync(tasksDir).filter((f) => /\.(ts|js)$/.test(f));
|
|
277
|
+
if (files.length === 0) {
|
|
278
|
+
console.log(chalk5.yellow("No tasks found."));
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
console.log(chalk5.bold("\n Background Tasks\n"));
|
|
282
|
+
for (const file of files) {
|
|
283
|
+
console.log(` ${chalk5.cyan(path4.basename(file, path4.extname(file)))}`);
|
|
284
|
+
}
|
|
285
|
+
console.log();
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
function doctorCommand() {
|
|
289
|
+
return new Command5("doctor").description("Validate config, env vars, and project setup").action(() => {
|
|
290
|
+
const cwd = process.cwd();
|
|
291
|
+
const checks = [
|
|
292
|
+
{
|
|
293
|
+
label: "package.json exists",
|
|
294
|
+
ok: fs4.existsSync(path4.join(cwd, "package.json"))
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
label: "tsconfig.json exists",
|
|
298
|
+
ok: fs4.existsSync(path4.join(cwd, "tsconfig.json")),
|
|
299
|
+
hint: "Run `tsc --init` to create one"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
label: "src/api directory exists",
|
|
303
|
+
ok: fs4.existsSync(path4.join(cwd, "src", "api")),
|
|
304
|
+
hint: "Create src/api/ and add route files"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
label: "DATABASE_URL set",
|
|
308
|
+
ok: Boolean(process.env["DATABASE_URL"]),
|
|
309
|
+
hint: "Add DATABASE_URL to .env"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
label: "JWT_SECRET set",
|
|
313
|
+
ok: Boolean(process.env["JWT_SECRET"]),
|
|
314
|
+
hint: "Add JWT_SECRET to .env (generate: openssl rand -hex 64)"
|
|
315
|
+
}
|
|
316
|
+
];
|
|
317
|
+
console.log(chalk5.bold("\n EFC Doctor\n"));
|
|
318
|
+
let allOk = true;
|
|
319
|
+
for (const check of checks) {
|
|
320
|
+
const icon = check.ok ? chalk5.green("\u2713") : chalk5.red("\u2717");
|
|
321
|
+
console.log(` ${icon} ${check.label}`);
|
|
322
|
+
if (!check.ok) {
|
|
323
|
+
allOk = false;
|
|
324
|
+
if (check.hint) console.log(chalk5.dim(` \u2192 ${check.hint}`));
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
console.log();
|
|
328
|
+
if (allOk) {
|
|
329
|
+
console.log(chalk5.green(" All checks passed!\n"));
|
|
330
|
+
} else {
|
|
331
|
+
console.log(chalk5.yellow(" Some checks failed. Fix the issues above.\n"));
|
|
332
|
+
process.exit(1);
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
function resolveApiDir() {
|
|
337
|
+
const cwd = process.cwd();
|
|
338
|
+
const candidates = [path4.join(cwd, "src", "api"), path4.join(cwd, "api")];
|
|
339
|
+
return candidates.find((d) => fs4.existsSync(d)) ?? null;
|
|
340
|
+
}
|
|
341
|
+
function resolveTasksDir() {
|
|
342
|
+
const cwd = process.cwd();
|
|
343
|
+
const candidates = [path4.join(cwd, "src", "tasks"), path4.join(cwd, "tasks")];
|
|
344
|
+
return candidates.find((d) => fs4.existsSync(d)) ?? null;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// src/cli/index.ts
|
|
348
|
+
var program = new Command6("efc").description("Express File Cluster CLI").version("0.1.0");
|
|
349
|
+
program.addCommand(startCommand());
|
|
350
|
+
program.addCommand(buildCommand());
|
|
351
|
+
program.addCommand(runCommand());
|
|
352
|
+
program.addCommand(generateCommand());
|
|
353
|
+
for (const cmd of diagnosticsCommands()) {
|
|
354
|
+
program.addCommand(cmd);
|
|
355
|
+
}
|
|
356
|
+
program.parse(process.argv);
|
|
357
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/cli/index.ts","../../src/cli/commands/start.ts","../../src/cli/commands/build.ts","../../src/cli/commands/run.ts","../../src/cli/commands/generate.ts","../../src/cli/commands/diagnostics.ts","../../src/router/scan.ts"],"sourcesContent":["#!/usr/bin/env node\nimport { Command } from 'commander';\nimport { startCommand } from './commands/start.js';\nimport { buildCommand } from './commands/build.js';\nimport { runCommand } from './commands/run.js';\nimport { generateCommand } from './commands/generate.js';\nimport { diagnosticsCommands } from './commands/diagnostics.js';\n\nconst program = new Command('efc')\n .description('Express File Cluster CLI')\n .version('0.1.0');\n\nprogram.addCommand(startCommand());\nprogram.addCommand(buildCommand());\nprogram.addCommand(runCommand());\nprogram.addCommand(generateCommand());\n\nfor (const cmd of diagnosticsCommands()) {\n program.addCommand(cmd);\n}\n\nprogram.parse(process.argv);\n","import { Command } from 'commander';\nimport { spawn } from 'node:child_process';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport chalk from 'chalk';\n\nexport function startCommand(): Command {\n const cmd = new Command('start');\n\n cmd\n .argument('<mode>', 'dev | prod')\n .description('Start the EFC server')\n .action((mode: string) => {\n if (mode === 'dev') {\n startDev();\n } else if (mode === 'prod') {\n startProd();\n } else {\n console.error(chalk.red(`Unknown mode: ${mode}. Use 'dev' or 'prod'.`));\n process.exit(1);\n }\n });\n\n return cmd;\n}\n\nfunction startDev(): void {\n const entry = resolveEntry();\n if (!entry) {\n console.error(chalk.red('[EFC] Could not find entry point. Expected src/index.ts or index.ts'));\n process.exit(1);\n }\n\n console.log(chalk.cyan('[EFC] Starting development server…'));\n console.log(chalk.dim(` Entry: ${entry}`));\n\n const child = spawn(\n 'node',\n ['--import', 'tsx/esm', '--watch', entry],\n { stdio: 'inherit', env: { ...process.env, NODE_ENV: 'development' } },\n );\n\n child.on('exit', (code) => process.exit(code ?? 0));\n}\n\nfunction startProd(): void {\n const cwd = process.cwd();\n const distEntry = path.join(cwd, 'dist', 'index.js');\n\n if (!fs.existsSync(distEntry)) {\n console.error(chalk.red('[EFC] dist/index.js not found. Run `efc build prod` first.'));\n process.exit(1);\n }\n\n console.log(chalk.cyan('[EFC] Starting production server…'));\n\n const child = spawn('node', [distEntry], {\n stdio: 'inherit',\n env: { ...process.env, NODE_ENV: 'production' },\n });\n\n child.on('exit', (code) => process.exit(code ?? 0));\n}\n\nfunction resolveEntry(): string | null {\n const cwd = process.cwd();\n const candidates = [\n path.join(cwd, 'src', 'index.ts'),\n path.join(cwd, 'index.ts'),\n path.join(cwd, 'src', 'index.js'),\n path.join(cwd, 'index.js'),\n ];\n return candidates.find((f) => fs.existsSync(f)) ?? null;\n}\n","import { Command } from 'commander';\nimport { spawn } from 'node:child_process';\nimport chalk from 'chalk';\n\nexport function buildCommand(): Command {\n const cmd = new Command('build');\n\n cmd\n .argument('<mode>', 'prod')\n .description('Build the application for production')\n .action((mode: string) => {\n if (mode !== 'prod') {\n console.error(chalk.red(`Unknown build mode: ${mode}. Use 'prod'.`));\n process.exit(1);\n }\n buildProd();\n });\n\n return cmd;\n}\n\nfunction buildProd(): void {\n console.log(chalk.cyan('[EFC] Building for production…'));\n\n // Type-check first\n const tsc = spawn('npx', ['tsc', '--noEmit'], { stdio: 'inherit' });\n\n tsc.on('exit', (code) => {\n if (code !== 0) {\n console.error(chalk.red('[EFC] TypeScript errors found. Fix them before building.'));\n process.exit(1);\n }\n\n const tsup = spawn('npx', ['tsup'], { stdio: 'inherit' });\n tsup.on('exit', (tsupCode) => {\n if (tsupCode === 0) {\n console.log(chalk.green('[EFC] Build complete → dist/'));\n } else {\n process.exit(tsupCode ?? 1);\n }\n });\n });\n}\n","import { Command } from 'commander';\nimport { spawn } from 'node:child_process';\nimport chalk from 'chalk';\n\nexport function runCommand(): Command {\n const cmd = new Command('run');\n\n cmd\n .argument('<runner>', 'tests')\n .description('Run EFC sub-commands (tests)')\n .allowUnknownOption()\n .action((runner: string) => {\n if (runner === 'tests') {\n runTests(cmd.args.slice(1));\n } else {\n console.error(chalk.red(`Unknown runner: ${runner}. Use 'tests'.`));\n process.exit(1);\n }\n });\n\n return cmd;\n}\n\nfunction runTests(extraArgs: string[]): void {\n console.log(chalk.cyan('[EFC] Running tests via Vitest…'));\n const child = spawn('npx', ['vitest', 'run', ...extraArgs], { stdio: 'inherit' });\n child.on('exit', (code) => process.exit(code ?? 0));\n}\n","import { Command } from 'commander';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport chalk from 'chalk';\n\nexport function generateCommand(): Command {\n const cmd = new Command('generate').alias('g').description('Scaffold EFC modules');\n\n cmd\n .command('route <routePath>')\n .description('Scaffold a route module, e.g. users/[id]')\n .action((routePath: string) => generateRoute(routePath));\n\n cmd\n .command('task <name>')\n .description('Scaffold a background task module')\n .action((name: string) => generateTask(name));\n\n cmd\n .command('middleware <name>')\n .description('Scaffold a middleware module')\n .action((name: string) => generateMiddleware(name));\n\n return cmd;\n}\n\nfunction writeFile(filePath: string, content: string): void {\n const dir = path.dirname(filePath);\n fs.mkdirSync(dir, { recursive: true });\n if (fs.existsSync(filePath)) {\n console.error(chalk.red(`File already exists: ${filePath}`));\n process.exit(1);\n }\n fs.writeFileSync(filePath, content, 'utf8');\n console.log(chalk.green(` created ${path.relative(process.cwd(), filePath)}`));\n}\n\nfunction generateRoute(routePath: string): void {\n const cwd = process.cwd();\n const filePath = path.join(cwd, 'src', 'api', `${routePath}.ts`);\n\n const content = `import type { Request, Response } from 'express';\n\nexport const GET = async (req: Request, res: Response) => {\n res.json({ message: 'OK' });\n};\n\nexport const POST = async (req: Request, res: Response) => {\n res.status(201).json({ message: 'Created' });\n};\n`;\n\n writeFile(filePath, content);\n console.log(chalk.cyan(`[EFC] Route scaffolded`));\n}\n\nfunction generateTask(name: string): void {\n const cwd = process.cwd();\n const filePath = path.join(cwd, 'src', 'tasks', `${name}.ts`);\n\n const content = `import { defineTask } from 'express-file-cluster/tasks';\n\ninterface ${name}Payload {\n // TODO: define payload fields\n}\n\nexport default defineTask<${name}Payload>(async (payload) => {\n // TODO: implement task logic\n console.log('[Task:${name}]', payload);\n});\n`;\n\n writeFile(filePath, content);\n console.log(chalk.cyan(`[EFC] Task scaffolded`));\n}\n\nfunction generateMiddleware(name: string): void {\n const cwd = process.cwd();\n const filePath = path.join(cwd, 'src', 'middlewares', `${name}.ts`);\n\n const content = `import type { Request, Response, NextFunction } from 'express';\n\nexport function ${name}(req: Request, res: Response, next: NextFunction): void {\n // TODO: implement middleware logic\n next();\n}\n`;\n\n writeFile(filePath, content);\n console.log(chalk.cyan(`[EFC] Middleware scaffolded`));\n}\n","import { Command } from 'commander';\nimport { scanDir } from '../../router/scan.js';\nimport path from 'node:path';\nimport fs from 'node:fs';\nimport chalk from 'chalk';\n\nexport function diagnosticsCommands(): Command[] {\n return [routesCommand(), tasksCommand(), doctorCommand()];\n}\n\nfunction routesCommand(): Command {\n return new Command('routes')\n .description('Print the resolved route table')\n .action(() => {\n const apiDir = resolveApiDir();\n if (!apiDir) {\n console.error(chalk.red('[EFC] Could not find apiDir (expected src/api)'));\n process.exit(1);\n }\n\n const routes = scanDir(apiDir);\n if (routes.length === 0) {\n console.log(chalk.yellow('No routes found.'));\n return;\n }\n\n console.log(chalk.bold('\\n Route Table\\n'));\n console.log(chalk.dim(' ' + '─'.repeat(60)));\n for (const route of routes) {\n const rel = path.relative(process.cwd(), route.filePath);\n console.log(` ${chalk.cyan(route.urlPath.padEnd(35))} ${chalk.dim(rel)}`);\n }\n console.log(chalk.dim(' ' + '─'.repeat(60)));\n console.log(chalk.dim(`\\n ${routes.length} route(s) found\\n`));\n });\n}\n\nfunction tasksCommand(): Command {\n return new Command('tasks')\n .description('List registered background tasks')\n .action(() => {\n const tasksDir = resolveTasksDir();\n if (!tasksDir || !fs.existsSync(tasksDir)) {\n console.log(chalk.yellow('No tasks directory found.'));\n return;\n }\n\n const files = fs.readdirSync(tasksDir).filter((f) => /\\.(ts|js)$/.test(f));\n if (files.length === 0) {\n console.log(chalk.yellow('No tasks found.'));\n return;\n }\n\n console.log(chalk.bold('\\n Background Tasks\\n'));\n for (const file of files) {\n console.log(` ${chalk.cyan(path.basename(file, path.extname(file)))}`);\n }\n console.log();\n });\n}\n\nfunction doctorCommand(): Command {\n return new Command('doctor')\n .description('Validate config, env vars, and project setup')\n .action(() => {\n const cwd = process.cwd();\n const checks: { label: string; ok: boolean; hint?: string }[] = [\n {\n label: 'package.json exists',\n ok: fs.existsSync(path.join(cwd, 'package.json')),\n },\n {\n label: 'tsconfig.json exists',\n ok: fs.existsSync(path.join(cwd, 'tsconfig.json')),\n hint: 'Run `tsc --init` to create one',\n },\n {\n label: 'src/api directory exists',\n ok: fs.existsSync(path.join(cwd, 'src', 'api')),\n hint: 'Create src/api/ and add route files',\n },\n {\n label: 'DATABASE_URL set',\n ok: Boolean(process.env['DATABASE_URL']),\n hint: 'Add DATABASE_URL to .env',\n },\n {\n label: 'JWT_SECRET set',\n ok: Boolean(process.env['JWT_SECRET']),\n hint: 'Add JWT_SECRET to .env (generate: openssl rand -hex 64)',\n },\n ];\n\n console.log(chalk.bold('\\n EFC Doctor\\n'));\n let allOk = true;\n for (const check of checks) {\n const icon = check.ok ? chalk.green('✓') : chalk.red('✗');\n console.log(` ${icon} ${check.label}`);\n if (!check.ok) {\n allOk = false;\n if (check.hint) console.log(chalk.dim(` → ${check.hint}`));\n }\n }\n console.log();\n if (allOk) {\n console.log(chalk.green(' All checks passed!\\n'));\n } else {\n console.log(chalk.yellow(' Some checks failed. Fix the issues above.\\n'));\n process.exit(1);\n }\n });\n}\n\nfunction resolveApiDir(): string | null {\n const cwd = process.cwd();\n const candidates = [path.join(cwd, 'src', 'api'), path.join(cwd, 'api')];\n return candidates.find((d) => fs.existsSync(d)) ?? null;\n}\n\nfunction resolveTasksDir(): string | null {\n const cwd = process.cwd();\n const candidates = [path.join(cwd, 'src', 'tasks'), path.join(cwd, 'tasks')];\n return candidates.find((d) => fs.existsSync(d)) ?? null;\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\nimport type { RouteEntry } from '../types.js';\n\nconst ROUTE_FILE_RE = /\\.(ts|js|mts|mjs|cts|cjs)$/;\nconst DYNAMIC_SEGMENT_RE = /\\[([^\\]]+)\\]/g;\n\nfunction filePathToUrlPath(relativePath: string): string {\n let p = relativePath.replace(ROUTE_FILE_RE, '');\n // index files map to parent path\n p = p.replace(/\\/index$/, '');\n // [param] → :param\n p = p.replace(DYNAMIC_SEGMENT_RE, ':$1');\n return p === '' ? '/' : p.startsWith('/') ? p : `/${p}`;\n}\n\nfunction extractParams(relativePath: string): string[] {\n const params: string[] = [];\n let match: RegExpExecArray | null;\n const re = new RegExp(DYNAMIC_SEGMENT_RE.source, 'g');\n while ((match = re.exec(relativePath)) !== null) {\n if (match[1]) params.push(match[1]);\n }\n return params;\n}\n\nexport function scanDir(dir: string, base: string = dir): RouteEntry[] {\n if (!fs.existsSync(dir)) return [];\n\n const entries: RouteEntry[] = [];\n const items = fs.readdirSync(dir, { withFileTypes: true });\n\n for (const item of items) {\n const fullPath = path.join(dir, item.name);\n if (item.isDirectory()) {\n entries.push(...scanDir(fullPath, base));\n } else if (ROUTE_FILE_RE.test(item.name)) {\n const relative = '/' + path.relative(base, fullPath).replace(/\\\\/g, '/');\n entries.push({\n urlPath: filePathToUrlPath(relative),\n filePath: fullPath,\n params: extractParams(relative),\n });\n }\n }\n\n // Sort: static routes before dynamic ones at each segment level\n return entries.sort((a, b) => {\n const aDynamic = a.urlPath.includes(':') ? 1 : 0;\n const bDynamic = b.urlPath.includes(':') ? 1 : 0;\n return aDynamic - bDynamic || a.urlPath.localeCompare(b.urlPath);\n });\n}\n\nexport { filePathToUrlPath };\n"],"mappings":";;;AACA,SAAS,WAAAA,gBAAe;;;ACDxB,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,OAAO,UAAU;AACjB,OAAO,QAAQ;AACf,OAAO,WAAW;AAEX,SAAS,eAAwB;AACtC,QAAM,MAAM,IAAI,QAAQ,OAAO;AAE/B,MACG,SAAS,UAAU,YAAY,EAC/B,YAAY,sBAAsB,EAClC,OAAO,CAAC,SAAiB;AACxB,QAAI,SAAS,OAAO;AAClB,eAAS;AAAA,IACX,WAAW,SAAS,QAAQ;AAC1B,gBAAU;AAAA,IACZ,OAAO;AACL,cAAQ,MAAM,MAAM,IAAI,iBAAiB,IAAI,wBAAwB,CAAC;AACtE,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AAEH,SAAO;AACT;AAEA,SAAS,WAAiB;AACxB,QAAM,QAAQ,aAAa;AAC3B,MAAI,CAAC,OAAO;AACV,YAAQ,MAAM,MAAM,IAAI,qEAAqE,CAAC;AAC9F,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,UAAQ,IAAI,MAAM,KAAK,yCAAoC,CAAC;AAC5D,UAAQ,IAAI,MAAM,IAAI,YAAY,KAAK,EAAE,CAAC;AAE1C,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA,CAAC,YAAY,WAAW,WAAW,KAAK;AAAA,IACxC,EAA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AQ,IAAIA,OAAM,OAAO,+CAA+C,CAAC;AACzE,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AACL;AAEA,SAAS,gBAA+B;AACtC,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,aAAa,CAACF,MAAK,KAAK,KAAK,OAAO,KAAK,GAAGA,MAAK,KAAK,KAAK,KAAK,CAAC;AACvE,SAAO,WAAW,KAAK,CAAC,MAAMC,IAAG,WAAW,CAAC,CAAC,KAAK;AACrD;AAEA,SAAS,kBAAiC;AACxC,QAAM,MAAM,QAAQ,IAAI;AACxB,QAAM,aAAa,CAACD,MAAK,KAAK,KAAK,OAAO,OAAO,GAAGA,MAAK,KAAK,KAAK,OAAO,CAAC;AAC3E,SAAO,WAAW,KAAK,CAAC,MAAMC,IAAG,WAAW,CAAC,CAAC,KAAK;AACrD;;;ALnHA,IAAM,UAAU,IAAIG,SAAQ,KAAK,EAC9B,YAAY,0BAA0B,EACtC,QAAQ,OAAO;AAElB,QAAQ,WAAW,aAAa,CAAC;AACjC,QAAQ,WAAW,aAAa,CAAC;AACjC,QAAQ,WAAW,WAAW,CAAC;AAC/B,QAAQ,WAAW,gBAAgB,CAAC;AAEpC,WAAW,OAAO,oBAAoB,GAAG;AACvC,UAAQ,WAAW,GAAG;AACxB;AAEA,QAAQ,MAAM,QAAQ,IAAI;","names":["Command","Command","spawn","chalk","Command","spawn","chalk","Command","fs","path","chalk","Command","fs","path","path","fs","chalk","Command","Command"]}
|