@kosdev-code/kos-ui-cli 2.1.38 → 3.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosdev-code/kos-ui-cli",
3
- "version": "2.1.38",
3
+ "version": "3.0.0",
4
4
  "bin": {
5
5
  "kosui": "./src/lib/cli.mjs"
6
6
  },
@@ -15,14 +15,13 @@
15
15
  "plop": "^3.1.2",
16
16
  "inquirer-directory": "^2.2.0",
17
17
  "figlet": "^1.6.0",
18
- "create-nx-workspace": "18.0.3",
19
- "openapi-typescript": "^7.6.1"
18
+ "create-nx-workspace": "21.6.10",
19
+ "openapi-typescript": "^7.6.1",
20
+ "@kosdev-code/kos-codegen-core": "~3.0.0"
20
21
  },
21
- "module": "./src/index.js",
22
- "main": "./src/index.js",
23
22
  "kos": {
24
23
  "build": {
25
- "gitHash": "424ce681eaa2f82db88daaaa810780ec0bde0952"
24
+ "gitHash": "681d3ed1315f7d905a8749f448fcc230639ed4a5"
26
25
  }
27
26
  },
28
27
  "publishConfig": {
package/src/lib/cli.mjs CHANGED
@@ -6,9 +6,15 @@ import nodePlop from "node-plop";
6
6
  import path, { dirname } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { clearCache } from "./utils/cache.mjs";
9
- import { buildNonInteractiveCommand, isRunningInteractively } from "./utils/command-builder.mjs";
9
+ import {
10
+ displayGeneralHelp,
11
+ displayGeneratorHelp,
12
+ } from "./utils/cli-help-display.mjs";
13
+ import {
14
+ buildNonInteractiveCommand,
15
+ isRunningInteractively,
16
+ } from "./utils/command-builder.mjs";
10
17
  import { getGeneratorMetadata } from "./utils/generator-loader.mjs";
11
- import { displayGeneralHelp, displayGeneratorHelp } from "./utils/cli-help-display.mjs";
12
18
 
13
19
  const originalArgs = process.argv.slice(2);
14
20
  const parsedArgs = minimist(originalArgs);
@@ -22,7 +28,9 @@ const hasQuiet = originalArgs.includes("--quiet");
22
28
  if (hasNoCache || hasRefresh) {
23
29
  process.env.DISABLE_CACHE = "true";
24
30
  if (!hasQuiet) {
25
- console.log("[kos-cli] Cache disabled or refresh forced. Clearing cache...");
31
+ console.log(
32
+ "[kos-cli] Cache disabled or refresh forced. Clearing cache..."
33
+ );
26
34
  }
27
35
  clearCache();
28
36
  }
@@ -35,6 +43,13 @@ if (hasQuiet) {
35
43
  const __dirname = dirname(fileURLToPath(import.meta.url));
36
44
  const configPath = path.join(__dirname, "plopfile.mjs");
37
45
 
46
+ // Point codegen-core's template resolver to the templates bundled with this CLI.
47
+ // Required because template-resolver.ts uses __dirname (a CJS global) which is
48
+ // undefined when its code is bundled into an ESM generator bundle.
49
+ if (!process.env.KOS_TEMPLATE_BASE_DIR) {
50
+ process.env.KOS_TEMPLATE_BASE_DIR = path.resolve(__dirname, "../..");
51
+ }
52
+
38
53
  const showBanner =
39
54
  command !== "help" && process.env.DISABLE_CLI_BANNER !== "true";
40
55
 
@@ -49,7 +64,10 @@ function parseArgumentValue(value) {
49
64
  return true;
50
65
  } else if (value === "false" || value === "n" || value === "no") {
51
66
  return false;
52
- } else if (typeof value === "string" && (value.startsWith("{") || value.startsWith("["))) {
67
+ } else if (
68
+ typeof value === "string" &&
69
+ (value.startsWith("{") || value.startsWith("["))
70
+ ) {
53
71
  // Try to parse JSON for complex arguments like --app-version='{"ice-app":"v2"}'
54
72
  try {
55
73
  return JSON.parse(value);
@@ -61,9 +79,9 @@ function parseArgumentValue(value) {
61
79
  // Handle repeated arguments like --app-version ice-app=v2 --app-version apc=v3
62
80
  // Minimist stores repeated args as arrays
63
81
  const parsedObject = {};
64
- value.forEach(item => {
65
- if (typeof item === 'string' && item.includes('=')) {
66
- const [key, val] = item.split('=');
82
+ value.forEach((item) => {
83
+ if (typeof item === "string" && item.includes("=")) {
84
+ const [key, val] = item.split("=");
67
85
  parsedObject[key.trim()] = val.trim();
68
86
  }
69
87
  });
@@ -71,7 +89,7 @@ function parseArgumentValue(value) {
71
89
  } else if (typeof value === "string" && value.includes("=")) {
72
90
  // Handle single key=value format like --app-version ice-app=v2
73
91
  const parsedObject = {};
74
- const [key, val] = value.split('=');
92
+ const [key, val] = value.split("=");
75
93
  parsedObject[key.trim()] = val.trim();
76
94
  return parsedObject;
77
95
  }
@@ -357,10 +375,16 @@ async function launch() {
357
375
  });
358
376
 
359
377
  // Output equivalent non-interactive command when running interactively
360
- if (isRunningInteractively(parsedArgs, hasAnyAnswers) && results.failures.length === 0 && !hasQuiet) {
378
+ if (
379
+ isRunningInteractively(parsedArgs, hasAnyAnswers) &&
380
+ results.failures.length === 0 &&
381
+ !hasQuiet
382
+ ) {
361
383
  const commandString = buildNonInteractiveCommand(command, answers, meta);
362
384
  if (commandString) {
363
- console.log(chalk.cyan("\n[kos-cli] Equivalent non-interactive command:"));
385
+ console.log(
386
+ chalk.cyan("\n[kos-cli] Equivalent non-interactive command:")
387
+ );
364
388
  console.log(chalk.green(` ${commandString}`));
365
389
  }
366
390
  }