@forinda/kickjs-cli 1.2.1 → 1.2.3

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/index.d.ts CHANGED
@@ -77,6 +77,7 @@ interface GenerateModuleOptions {
77
77
  minimal?: boolean;
78
78
  force?: boolean;
79
79
  pattern?: ProjectPattern;
80
+ dryRun?: boolean;
80
81
  }
81
82
  /**
82
83
  * Generate a module — structure depends on the project pattern.
package/dist/index.js CHANGED
@@ -8,7 +8,9 @@ import { createInterface } from "readline";
8
8
  // src/utils/fs.ts
9
9
  import { writeFile, mkdir, access, readFile } from "fs/promises";
10
10
  import { dirname } from "path";
11
+ var _dryRun = false;
11
12
  async function writeFileSafe(filePath, content) {
13
+ if (_dryRun) return;
12
14
  await mkdir(dirname(filePath), {
13
15
  recursive: true
14
16
  });
@@ -1394,7 +1396,7 @@ function promptUser(question) {
1394
1396
  }
1395
1397
  __name(promptUser, "promptUser");
1396
1398
  async function generateModule(options) {
1397
- const { name, modulesDir, noEntity, noTests, repo = "inmemory", force } = options;
1399
+ const { name, modulesDir, noEntity, noTests, repo = "inmemory", force, dryRun } = options;
1398
1400
  let pattern = options.pattern ?? "ddd";
1399
1401
  if (options.minimal) pattern = "minimal";
1400
1402
  const kebab = toKebabCase(name);
@@ -1406,6 +1408,10 @@ async function generateModule(options) {
1406
1408
  let overwriteAll = force ?? false;
1407
1409
  const write = /* @__PURE__ */ __name(async (relativePath, content) => {
1408
1410
  const fullPath = join(moduleDir, relativePath);
1411
+ if (dryRun) {
1412
+ files.push(fullPath);
1413
+ return;
1414
+ }
1409
1415
  if (!overwriteAll && await fileExists(fullPath)) {
1410
1416
  const answer = await promptUser(` File already exists: ${relativePath}
1411
1417
  Overwrite? (y/n/a = yes/no/all) `);
@@ -1447,7 +1453,9 @@ async function generateModule(options) {
1447
1453
  await generateDddFiles(ctx);
1448
1454
  break;
1449
1455
  }
1450
- await autoRegisterModule(modulesDir, pascal, plural);
1456
+ if (!dryRun) {
1457
+ await autoRegisterModule(modulesDir, pascal, plural);
1458
+ }
1451
1459
  return files;
1452
1460
  }
1453
1461
  __name(generateModule, "generateModule");
@@ -2181,6 +2189,7 @@ export default defineConfig({
2181
2189
  },
2182
2190
  })
2183
2191
  `);
2192
+ await writeFileSafe(join9(dir, "README.md"), generateReadme(name, template, packageManager));
2184
2193
  if (options.initGit) {
2185
2194
  try {
2186
2195
  execSync("git init", {
@@ -2338,6 +2347,91 @@ bootstrap({
2338
2347
  }
2339
2348
  }
2340
2349
  __name(getEntryFile, "getEntryFile");
2350
+ function generateReadme(name, template, pm) {
2351
+ const templateLabels = {
2352
+ rest: "REST API",
2353
+ graphql: "GraphQL API",
2354
+ ddd: "Domain-Driven Design",
2355
+ cqrs: "CQRS + Event-Driven",
2356
+ minimal: "Minimal"
2357
+ };
2358
+ const packages = [
2359
+ "@forinda/kickjs-core",
2360
+ "@forinda/kickjs-http",
2361
+ "@forinda/kickjs-config"
2362
+ ];
2363
+ if (template !== "minimal") {
2364
+ packages.push("@forinda/kickjs-swagger", "@forinda/kickjs-devtools");
2365
+ }
2366
+ if (template === "graphql") packages.push("@forinda/kickjs-graphql");
2367
+ if (template === "cqrs") {
2368
+ packages.push("@forinda/kickjs-queue", "@forinda/kickjs-ws", "@forinda/kickjs-otel");
2369
+ }
2370
+ return `# ${name}
2371
+
2372
+ A **${templateLabels[template] ?? "REST API"}** built with [KickJS](https://forinda.github.io/kick-js/) \u2014 a decorator-driven Node.js framework on Express 5 and TypeScript.
2373
+
2374
+ ## Getting Started
2375
+
2376
+ \`\`\`bash
2377
+ ${pm} install
2378
+ kick dev
2379
+ \`\`\`
2380
+
2381
+ ## Scripts
2382
+
2383
+ | Command | Description |
2384
+ |---|---|
2385
+ | \`kick dev\` | Start dev server with Vite HMR |
2386
+ | \`kick build\` | Production build |
2387
+ | \`kick start\` | Run production build |
2388
+ | \`${pm} run test\` | Run tests with Vitest |
2389
+ | \`kick g module <name>\` | Generate a DDD module |
2390
+ | \`kick g scaffold <name> <fields...>\` | Generate CRUD from field definitions |
2391
+ | \`kick add <package>\` | Add a KickJS package |
2392
+
2393
+ ## Project Structure
2394
+
2395
+ \`\`\`
2396
+ src/
2397
+ \u251C\u2500\u2500 index.ts # Application entry point
2398
+ \u251C\u2500\u2500 modules/ # Feature modules (controllers, services, repos)
2399
+ \u2502 \u2514\u2500\u2500 index.ts # Module registry
2400
+ \u2514\u2500\u2500 ...
2401
+ \`\`\`
2402
+
2403
+ ## Packages
2404
+
2405
+ ${packages.map((p) => `- \`${p}\``).join("\n")}
2406
+
2407
+ ## Adding Features
2408
+
2409
+ \`\`\`bash
2410
+ kick add auth # Authentication (JWT, API key, OAuth)
2411
+ kick add swagger # OpenAPI documentation
2412
+ kick add ws # WebSocket support
2413
+ kick add queue # Background job processing
2414
+ kick add mailer # Email sending
2415
+ kick add cron # Scheduled tasks
2416
+ kick add --list # Show all available packages
2417
+ \`\`\`
2418
+
2419
+ ## Environment Variables
2420
+
2421
+ Copy \`.env.example\` to \`.env\` and configure:
2422
+
2423
+ | Variable | Default | Description |
2424
+ |---|---|---|
2425
+ | \`PORT\` | \`3000\` | Server port |
2426
+ | \`NODE_ENV\` | \`development\` | Environment |
2427
+
2428
+ ## Learn More
2429
+
2430
+ - [KickJS Documentation](https://forinda.github.io/kick-js/)
2431
+ - [CLI Reference](https://forinda.github.io/kick-js/api/cli.html)
2432
+ `;
2433
+ }
2434
+ __name(generateReadme, "generateReadme");
2341
2435
 
2342
2436
  // src/config.ts
2343
2437
  import { readFile as readFile3, access as access2 } from "fs/promises";