@kosdev-code/kos-ui-cli 2.1.14 → 2.1.16

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.14",
3
+ "version": "2.1.16",
4
4
  "bin": {
5
5
  "kosui": "./src/lib/cli.mjs"
6
6
  },
@@ -21,7 +21,7 @@
21
21
  "main": "./src/index.js",
22
22
  "kos": {
23
23
  "build": {
24
- "gitHash": "56100d85ce92867188ff952f1697e0347e78e080"
24
+ "gitHash": "e45c510bf843db80b68a1feb15cf6ddc3c58e0cd"
25
25
  }
26
26
  },
27
27
  "publishConfig": {
@@ -0,0 +1,82 @@
1
+ // generators/kab/index.mjs
2
+ import { execSync } from "child_process";
3
+ import inquirer from "inquirer";
4
+ import { detectWorkspace } from "../../utils/nx-context.mjs";
5
+
6
+ export const metadata = {
7
+ key: "kab",
8
+ name: "Run Kab Target",
9
+ namedArguments: {
10
+ project: "project",
11
+ interactive: "interactive"
12
+ },
13
+ };
14
+
15
+ async function getProjectsWithTarget(target) {
16
+ try {
17
+ const output = execSync(`npx nx show projects --with-target ${target} --json`, {
18
+ encoding: "utf-8",
19
+ stdio: ["pipe", "pipe", "ignore"]
20
+ });
21
+ return JSON.parse(output);
22
+ } catch (error) {
23
+ return [];
24
+ }
25
+ }
26
+
27
+ export default async function (plop) {
28
+ const projects = await getProjectsWithTarget("kab");
29
+
30
+ if (projects.length === 0) {
31
+ console.warn("[kos-cli] No projects found with kab target");
32
+ // Still register the generator but it will fail gracefully
33
+ }
34
+
35
+ plop.setActionType("runKab", async function (answers) {
36
+ const isWorkspace = await detectWorkspace();
37
+
38
+ if (!isWorkspace) {
39
+ console.warn(
40
+ "[kos-cli] Not inside an Nx workspace. Cannot run kab target."
41
+ );
42
+ return "Skipped: Not a workspace";
43
+ }
44
+
45
+ const { project } = answers;
46
+
47
+ if (project === "all") {
48
+ console.log("[kos-cli] Running kab on all projects with kab target...");
49
+ try {
50
+ execSync("npx nx run-many --target=kab", {
51
+ stdio: "inherit",
52
+ });
53
+ return "Successfully ran kab on all projects";
54
+ } catch (error) {
55
+ throw new Error(`Failed to run kab on all projects: ${error.message}`);
56
+ }
57
+ } else {
58
+ console.log(`[kos-cli] Running kab on ${project}...`);
59
+ try {
60
+ execSync(`npx nx run ${project}:kab`, {
61
+ stdio: "inherit",
62
+ });
63
+ return `Successfully ran kab on ${project}`;
64
+ } catch (error) {
65
+ throw new Error(`Failed to run kab on ${project}: ${error.message}`);
66
+ }
67
+ }
68
+ });
69
+
70
+ plop.setGenerator("kab", {
71
+ description: "Run the kab target on a project",
72
+ prompts: [
73
+ {
74
+ type: "list",
75
+ name: "project",
76
+ message: "Select a project to run kab:",
77
+ choices: [...projects, new inquirer.Separator(), { name: "Run on all projects", value: "all" }],
78
+ },
79
+ ],
80
+ actions: () => [{ type: "runKab" }],
81
+ });
82
+ }
@@ -0,0 +1,74 @@
1
+ // generators/serve/index.mjs
2
+ import { execSync } from "child_process";
3
+ import { detectWorkspace } from "../../utils/nx-context.mjs";
4
+
5
+ export const metadata = {
6
+ key: "serve",
7
+ name: "Run Serve Target",
8
+ namedArguments: {
9
+ project: "project",
10
+ interactive: "interactive"
11
+ },
12
+ };
13
+
14
+ async function getProjectsWithTarget(target) {
15
+ try {
16
+ const output = execSync(`npx nx show projects --with-target ${target} --json`, {
17
+ encoding: "utf-8",
18
+ stdio: ["pipe", "pipe", "ignore"]
19
+ });
20
+ return JSON.parse(output);
21
+ } catch (error) {
22
+ return [];
23
+ }
24
+ }
25
+
26
+ export default async function (plop) {
27
+ const projects = await getProjectsWithTarget("serve");
28
+
29
+ if (projects.length === 0) {
30
+ console.warn("[kos-cli] No projects found with serve target");
31
+ // Still register the generator but it will fail gracefully
32
+ }
33
+
34
+ plop.setActionType("runServe", async function (answers) {
35
+ const isWorkspace = await detectWorkspace();
36
+
37
+ if (!isWorkspace) {
38
+ console.warn(
39
+ "[kos-cli] Not inside an Nx workspace. Cannot run serve target."
40
+ );
41
+ return "Skipped: Not a workspace";
42
+ }
43
+
44
+ const { project } = answers;
45
+
46
+ console.log(`[kos-cli] Running serve on ${project}...`);
47
+ try {
48
+ // Run serve in foreground with stdio inherited so it stays alive
49
+ execSync(`npx nx run ${project}:serve`, {
50
+ stdio: "inherit",
51
+ });
52
+ return `Serve completed for ${project}`;
53
+ } catch (error) {
54
+ // Don't throw error for Ctrl+C or normal termination
55
+ if (error.signal === "SIGINT") {
56
+ return `Serve terminated for ${project}`;
57
+ }
58
+ throw new Error(`Failed to run serve on ${project}: ${error.message}`);
59
+ }
60
+ });
61
+
62
+ plop.setGenerator("serve", {
63
+ description: "Run the serve target on a project",
64
+ prompts: [
65
+ {
66
+ type: "list",
67
+ name: "project",
68
+ message: "Select a project to serve:",
69
+ choices: projects,
70
+ },
71
+ ],
72
+ actions: () => [{ type: "runServe" }],
73
+ });
74
+ }
@@ -14,6 +14,8 @@ import registerPluginComponent from "./generators/plugin/index.mjs";
14
14
 
15
15
  import registerCacheGenerators from "./generators/cache/index.mjs";
16
16
  import registerEnv from "./generators/env/index.mjs";
17
+ import registerKab from "./generators/kab/index.mjs";
18
+ import registerServe from "./generators/serve/index.mjs";
17
19
  import registerVersion from "./generators/version/index.mjs";
18
20
  import registerI18nNamespace from "./generators/i18n/namespace.mjs";
19
21
  import registerUiProject from "./generators/project/app.mjs";
@@ -58,6 +60,8 @@ export default async function (plop) {
58
60
  await registerI18n(plop);
59
61
  await registerI18nNamespace(plop);
60
62
  await registerEnv(plop);
63
+ await registerKab(plop);
64
+ await registerServe(plop);
61
65
  await registerVersion(plop);
62
66
  await registerCacheGenerators(plop);
63
67
  }