@forinda/kickjs-cli 1.2.0 → 1.2.2

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");