@vc-shell/create-vc-app 2.0.3-pr222.ba0d3c5 → 2.0.3-pr223.4c0ddd9

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.
Files changed (59) hide show
  1. package/README.md +23 -19
  2. package/dist/commands/add-module.d.ts +1 -3
  3. package/dist/commands/add-module.d.ts.map +1 -1
  4. package/dist/commands/init.d.ts +1 -3
  5. package/dist/commands/init.d.ts.map +1 -1
  6. package/dist/index.js +138 -145
  7. package/dist/templates/host-app/LICENSE +12 -0
  8. package/dist/templates/host-app/README.md +54 -0
  9. package/dist/templates/host-app/_browserslistrc +3 -0
  10. package/dist/templates/host-app/_commitlintrc.json +3 -0
  11. package/dist/templates/host-app/_editorconfig +22 -0
  12. package/dist/templates/host-app/_env.ejs +3 -0
  13. package/dist/templates/host-app/_env.local.ejs +1 -0
  14. package/dist/templates/host-app/_eslintignore +3 -0
  15. package/dist/templates/host-app/_eslintrc.js +41 -0
  16. package/dist/templates/host-app/_github/COMMIT_CONVENTION.md +91 -0
  17. package/dist/templates/host-app/_github/PULL_REQUEST_TEMPLATE.md +8 -0
  18. package/dist/templates/host-app/_gitignore +71 -0
  19. package/dist/templates/host-app/_package.json.ejs +67 -0
  20. package/dist/templates/host-app/_prettierignore +4 -0
  21. package/dist/templates/host-app/_prettierrc +4 -0
  22. package/dist/templates/host-app/_vscode/extensions.json +14 -0
  23. package/dist/templates/host-app/_vscode/settings.json +14 -0
  24. package/dist/templates/host-app/_yarn/releases/yarn-4.9.1.cjs +948 -0
  25. package/dist/templates/host-app/_yarnrc.yml +7 -0
  26. package/dist/templates/host-app/index.html.ejs +26 -0
  27. package/dist/templates/host-app/postcss.config.cjs +6 -0
  28. package/dist/templates/host-app/public/assets/background.jpg +0 -0
  29. package/dist/templates/host-app/public/assets/logo-white.svg +21 -0
  30. package/dist/templates/host-app/public/assets/logo.svg +8 -0
  31. package/dist/templates/host-app/public/assets/welcome.png +0 -0
  32. package/dist/templates/host-app/public/img/icons/apple-touch-icon.png +0 -0
  33. package/dist/templates/host-app/public/img/icons/favicon-16x16.png +0 -0
  34. package/dist/templates/host-app/public/img/icons/favicon-32x32.png +0 -0
  35. package/dist/templates/host-app/public/img/icons/favicon.ico +0 -0
  36. package/dist/templates/host-app/public/img/icons/mstile-150x150.png +0 -0
  37. package/dist/templates/host-app/public/img/icons/safari-pinned-tab.svg +32 -0
  38. package/dist/templates/host-app/src/api_client/README.md +199 -0
  39. package/dist/templates/host-app/src/bootstrap.ts.ejs +26 -0
  40. package/dist/templates/host-app/src/components/dashboard-widgets/Welcome.vue +51 -0
  41. package/dist/templates/host-app/src/composables/index.ts +1 -0
  42. package/dist/templates/host-app/src/env.d.ts +9 -0
  43. package/dist/templates/host-app/src/locales/en.json +16 -0
  44. package/dist/templates/host-app/src/locales/index.ts +2 -0
  45. package/dist/templates/host-app/src/main.ts.ejs +59 -0
  46. package/dist/templates/host-app/src/pages/App.vue.ejs +41 -0
  47. package/dist/templates/host-app/src/pages/Dashboard.vue.ejs +7 -0
  48. package/dist/templates/host-app/src/pages/Platform.vue +19 -0
  49. package/dist/templates/host-app/src/router/index.ts +10 -0
  50. package/dist/templates/host-app/src/router/routes.ts.ejs +98 -0
  51. package/dist/templates/host-app/src/styles/custom.scss +116 -0
  52. package/dist/templates/host-app/src/styles/index.scss +8 -0
  53. package/dist/templates/host-app/tailwind.config.ts +7 -0
  54. package/dist/templates/host-app/tsconfig.json +17 -0
  55. package/dist/templates/host-app/vite.config.mts.ejs +4 -0
  56. package/dist/templates/host-app/yarn.lock +0 -0
  57. package/dist/types.d.ts +0 -16
  58. package/dist/types.d.ts.map +1 -1
  59. package/package.json +2 -2
package/README.md CHANGED
@@ -5,15 +5,16 @@ Scaffolding tool for VC Shell applications and modules.
5
5
  ## Create a New Project
6
6
 
7
7
  ```bash
8
- npx @vc-shell/create-vc-app [project-name]
8
+ npx create-vc-app [project-name]
9
9
  ```
10
10
 
11
- Interactive prompts guide you through project setup. Two project types are available:
11
+ Interactive prompts guide you through project setup. Three project types are available:
12
12
 
13
13
  | Type | Description |
14
14
  | ------------------ | -------------------------------------------------- |
15
15
  | **Standalone App** | Full application with bundled modules |
16
16
  | **Dynamic Module** | Remote module loaded by host via Module Federation |
17
+ | **Host App** | Shell that loads dynamic modules at runtime |
17
18
 
18
19
  ### Non-Interactive Mode
19
20
 
@@ -21,35 +22,38 @@ Pass flags to skip prompts:
21
22
 
22
23
  ```bash
23
24
  # Standalone app with dashboard and sample data
24
- npx @vc-shell/create-vc-app my-app --type standalone --module-name "Products" --dashboard --mocks
25
+ npx create-vc-app my-app --type standalone --module-name "Products" --dashboard --mocks
25
26
 
26
27
  # Dynamic module
27
- npx @vc-shell/create-vc-app my-module --type dynamic-module --module-name "Reviews"
28
+ npx create-vc-app my-module --type dynamic-module --module-name "Reviews"
29
+
30
+ # Host app with tenant routing and AI agent
31
+ npx create-vc-app my-shell --type host-app --dashboard --tenant-routes --ai-agent
28
32
  ```
29
33
 
30
34
  ### Options
31
35
 
32
- | Option | Description | Default |
33
- | ---------------------- | ------------------------------------------------ | ---------------------- |
34
- | `--type <type>` | Project type: `standalone` \| `dynamic-module` ` | _(prompted)_ |
35
- | `--name`, `--app-name` | Application name | Directory name |
36
- | `--package-name` | npm package name | App name (validated) |
37
- | `--module-name` | Initial module name | App name in title case |
38
- | `--base-path` | Base path for the application | `/apps/<name>/` |
39
- | `--tenant-routes` | Include tenant routing (`/:tenantId` prefix) | `false` |
40
- | `--ai-agent` | Include AI Agent configuration | `false` |
41
- | `--dashboard` | Include Dashboard with widgets | `false` |
42
- | `--mocks` | Include sample module with mock data | `false` |
43
- | `--overwrite` | Overwrite existing files without confirmation | `false` |
44
- | `--help`, `-h` | Show help | — |
45
- | `--version`, `-v` | Show version | — |
36
+ | Option | Description | Default |
37
+ | ---------------------- | ------------------------------------------------------------ | ---------------------- |
38
+ | `--type <type>` | Project type: `standalone` \| `dynamic-module` \| `host-app` | _(prompted)_ |
39
+ | `--name`, `--app-name` | Application name | Directory name |
40
+ | `--package-name` | npm package name | App name (validated) |
41
+ | `--module-name` | Initial module name | App name in title case |
42
+ | `--base-path` | Base path for the application | `/apps/<name>/` |
43
+ | `--tenant-routes` | Include tenant routing (`/:tenantId` prefix) | `false` |
44
+ | `--ai-agent` | Include AI Agent configuration | `false` |
45
+ | `--dashboard` | Include Dashboard with widgets | `false` |
46
+ | `--mocks` | Include sample module with mock data | `false` |
47
+ | `--overwrite` | Overwrite existing files without confirmation | `false` |
48
+ | `--help`, `-h` | Show help | — |
49
+ | `--version`, `-v` | Show version | — |
46
50
 
47
51
  ## Add a Module to Existing Project
48
52
 
49
53
  From your project root:
50
54
 
51
55
  ```bash
52
- npx @vc-shell/create-vc-app add-module <module-name>
56
+ npx create-vc-app add-module <module-name>
53
57
  ```
54
58
 
55
59
  This will:
@@ -1,4 +1,2 @@
1
- import { CLIArgs } from '../types.js';
2
-
3
- export declare function addModuleCommand(args: CLIArgs, templateRoot: string): Promise<void>;
1
+ export declare function addModuleCommand(args: Record<string, unknown>, templateRoot: string): Promise<void>;
4
2
  //# sourceMappingURL=add-module.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"add-module.d.ts","sourceRoot":"","sources":["../../src/commands/add-module.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgFzF"}
1
+ {"version":3,"file":"add-module.d.ts","sourceRoot":"","sources":["../../src/commands/add-module.ts"],"names":[],"mappings":"AAQA,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAgFzG"}
@@ -1,4 +1,2 @@
1
- import { CLIArgs } from '../types.js';
2
-
3
- export declare function initCommand(args: CLIArgs, templateRoot: string): Promise<void>;
1
+ export declare function initCommand(args: Record<string, unknown>, templateRoot: string): Promise<void>;
4
2
  //# sourceMappingURL=init.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAA+B,MAAM,aAAa,CAAC;AAqBxE,wBAAsB,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuNpF"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAqBA,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkNpG"}
package/dist/index.js CHANGED
@@ -1,30 +1,30 @@
1
1
  #!/usr/bin/env node
2
2
  import z from "mri";
3
- import n from "picocolors";
3
+ import t from "picocolors";
4
4
  import c from "node:path";
5
- import { exit as L, argv as B } from "node:process";
6
- import { fileURLToPath as F } from "node:url";
5
+ import { exit as U, argv as L } from "node:process";
6
+ import { fileURLToPath as B } from "node:url";
7
7
  import A from "prompts";
8
8
  import r from "node:fs";
9
- import E from "ejs";
10
- const O = "2.0.3", V = {
11
- version: O
9
+ import T from "ejs";
10
+ const F = "2.0.3", O = {
11
+ version: F
12
12
  };
13
13
  function h(e) {
14
14
  return e.trim().replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase().replace(/[^a-z0-9-]/g, "");
15
15
  }
16
16
  function x(e) {
17
- return e.replace(/[-_\s]+(.)?/g, (a, t) => t ? t.toUpperCase() : "").replace(/^(.)/, (a, t) => t.toUpperCase());
17
+ return e.replace(/[-_\s]+(.)?/g, (n, a) => a ? a.toUpperCase() : "").replace(/^(.)/, (n, a) => a.toUpperCase());
18
18
  }
19
- function Z(e) {
20
- const a = x(e);
21
- return a.charAt(0).toLowerCase() + a.slice(1);
19
+ function V(e) {
20
+ const n = x(e);
21
+ return n.charAt(0).toLowerCase() + n.slice(1);
22
22
  }
23
- function D(e) {
23
+ function E(e) {
24
24
  return e.replace(/[-\s]+/g, "_").replace(/([a-z])([A-Z])/g, "$1_$2").toUpperCase();
25
25
  }
26
26
  function S(e) {
27
- return e.replace(/[-_]+/g, " ").replace(/\b\w/g, (a) => a.toUpperCase());
27
+ return e.replace(/[-_]+/g, " ").replace(/\b\w/g, (n) => n.toUpperCase());
28
28
  }
29
29
  function k(e) {
30
30
  return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(e);
@@ -35,19 +35,19 @@ function C(e) {
35
35
  function _(e) {
36
36
  return e.trim().toLowerCase().replace(/\/+/g, "/").replace(/[^a-z0-9/-]+/g, "/").replace(/\/?$/, "/");
37
37
  }
38
- function R(e) {
39
- const a = e.moduleName || "", t = a ? h(a) : "", s = {
38
+ function D(e) {
39
+ const n = e.moduleName || "", a = n ? h(n) : "", s = {
40
40
  hasModule: !!e.moduleName,
41
- ModuleName: t,
42
- ModuleNamePascalCase: a ? x(a) : "",
43
- ModuleNameCamelCase: a ? Z(a) : "",
44
- ModuleNameUppercase: t.toUpperCase(),
45
- ModuleNameScreamingSnake: a ? D(a) : "",
46
- ModuleNameSentenceCase: a ? S(a) : ""
41
+ ModuleName: a,
42
+ ModuleNamePascalCase: n ? x(n) : "",
43
+ ModuleNameCamelCase: n ? V(n) : "",
44
+ ModuleNameUppercase: a.toUpperCase(),
45
+ ModuleNameScreamingSnake: n ? E(n) : "",
46
+ ModuleNameSentenceCase: n ? S(n) : ""
47
47
  };
48
48
  return e.projectName && (s.AppName = h(e.projectName), s.AppNameSentenceCase = S(e.projectName)), e.packageName !== void 0 && (s.PackageName = e.packageName || "", s.BasePath = e.basePath || "", s.tenantRoutes = e.tenantRoutes || !1, s.aiAgent = e.aiAgent || !1, s.dashboard = e.dashboard || !1, s.mocks = e.mocks || !1), s;
49
49
  }
50
- const J = /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico", ".pdf", ".zip"]), K = {
50
+ const Z = /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico", ".pdf", ".zip"]), J = {
51
51
  _gitignore: ".gitignore",
52
52
  "_yarnrc.yml": ".yarnrc.yml",
53
53
  _browserslistrc: ".browserslistrc",
@@ -62,97 +62,90 @@ const J = /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ic
62
62
  _yarn: ".yarn",
63
63
  "_package.json": "package.json"
64
64
  };
65
- function Y(e, a, t) {
66
- a.endsWith(".ejs") && (a = a.slice(0, -4));
67
- const s = c.dirname(a);
65
+ function K(e, n, a) {
66
+ n.endsWith(".ejs") && (n = n.slice(0, -4));
67
+ const s = c.dirname(n);
68
68
  r.existsSync(s) || r.mkdirSync(s, { recursive: !0 });
69
69
  const o = c.extname(e.replace(/\.ejs$/, "")).toLowerCase();
70
- if (J.has(o))
71
- r.copyFileSync(e, a);
70
+ if (Z.has(o))
71
+ r.copyFileSync(e, n);
72
72
  else {
73
- const d = r.readFileSync(e, "utf-8"), p = E.render(d, t, { filename: e });
74
- r.writeFileSync(a, p);
73
+ const d = r.readFileSync(e, "utf-8"), p = T.render(d, a, { filename: e });
74
+ r.writeFileSync(n, p);
75
75
  }
76
76
  }
77
- function j(e, a, t) {
77
+ function b(e, n, a) {
78
78
  if (!r.existsSync(e)) return;
79
79
  const s = r.readdirSync(e);
80
80
  for (const o of s) {
81
81
  const d = c.join(e, o), p = o.endsWith(".ejs") ? o.slice(0, -4) : o;
82
- let m = K[p] ?? p;
82
+ let m = J[p] ?? p;
83
83
  try {
84
- m = E.render(m, t);
84
+ m = T.render(m, a);
85
85
  } catch {
86
86
  }
87
- const l = c.join(a, m);
88
- r.statSync(d).isDirectory() ? (r.existsSync(l) || r.mkdirSync(l, { recursive: !0 }), j(d, l, t)) : Y(d, l, t);
87
+ const l = c.join(n, m);
88
+ r.statSync(d).isDirectory() ? (r.existsSync(l) || r.mkdirSync(l, { recursive: !0 }), b(d, l, a)) : K(d, l, a);
89
89
  }
90
90
  }
91
- function q(e) {
91
+ function Y(e) {
92
92
  if (r.existsSync(e))
93
- for (const a of r.readdirSync(e)) {
94
- if (a === ".git") continue;
95
- const t = c.join(e, a);
96
- r.statSync(t).isDirectory() ? r.rmSync(t, { recursive: !0, force: !0 }) : r.unlinkSync(t);
93
+ for (const n of r.readdirSync(e)) {
94
+ if (n === ".git") continue;
95
+ const a = c.join(e, n);
96
+ r.statSync(a).isDirectory() ? r.rmSync(a, { recursive: !0, force: !0 }) : r.unlinkSync(a);
97
97
  }
98
98
  }
99
99
  function I(e) {
100
100
  if (!r.existsSync(e)) return !0;
101
- const a = r.readdirSync(e);
102
- return a.length === 0 || a.length === 1 && a[0] === ".git";
101
+ const n = r.readdirSync(e);
102
+ return n.length === 0 || n.length === 1 && n[0] === ".git";
103
103
  }
104
- const W = {
104
+ const q = {
105
105
  standalone: "Standalone App",
106
106
  "dynamic-module": "Dynamic Module"
107
107
  };
108
- function H(e) {
109
- const a = W[e.projectType] ?? e.projectType, t = !!e.moduleName;
108
+ function W(e) {
109
+ const n = q[e.projectType], a = !!e.moduleName;
110
110
  console.log(`
111
- ${n.green("╭─────────────────────────────────────────╮")}
112
- ${n.green("│")} ${n.green("│")}
113
- ${n.green("│")} ${n.bold("VC Shell App created successfully!")} ${n.green("│")}
114
- ${n.green("│")} ${n.green("│")}
115
- ${n.green("│")} Project: ${n.cyan(e.projectName.padEnd(28))}${n.green("│")}
116
- ${n.green("│")} Type: ${n.cyan(a.padEnd(28))}${n.green("│")}
117
- ${t && e.moduleName ? ` ${n.green("│")} Module: ${n.cyan(e.moduleName.padEnd(28))}${n.green("│")}
118
- ` : ""} ${n.green("│")} ${n.green("│")}
119
- ${n.green("╰─────────────────────────────────────────╯")}
111
+ ${t.green("╭─────────────────────────────────────────╮")}
112
+ ${t.green("│")} ${t.green("│")}
113
+ ${t.green("│")} ${t.bold("VC Shell App created successfully!")} ${t.green("│")}
114
+ ${t.green("│")} ${t.green("│")}
115
+ ${t.green("│")} Project: ${t.cyan(e.projectName.padEnd(28))}${t.green("│")}
116
+ ${t.green("│")} Type: ${t.cyan(n.padEnd(28))}${t.green("│")}
117
+ ${a && e.moduleName ? ` ${t.green("│")} Module: ${t.cyan(e.moduleName.padEnd(28))}${t.green("│")}
118
+ ` : ""} ${t.green("│")} ${t.green("│")}
119
+ ${t.green("╰─────────────────────────────────────────╯")}
120
120
 
121
- ${n.bold("Next steps:")}
121
+ ${t.bold("Next steps:")}
122
122
 
123
123
  1. cd ${e.projectName}
124
124
  2. yarn install
125
125
  3. yarn serve
126
- ${t && e.moduleName ? `
126
+ ${a && e.moduleName ? `
127
127
  Module is ready at:
128
- src/modules/${X(e.moduleName)}/
128
+ src/modules/${H(e.moduleName)}/
129
129
  ` : ""}
130
- ${n.dim("Docs: https://docs.virtocommerce.org/platform/developer-guide/latest/custom-apps-development/vc-shell/vc-shell-overview/")}
130
+ ${t.dim("Docs: https://docs.virtocommerce.org/platform/developer-guide/latest/custom-apps-development/vc-shell/vc-shell-overview/")}
131
131
  `);
132
132
  }
133
- function X(e) {
133
+ function H(e) {
134
134
  return e.trim().replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase().replace(/[^a-z0-9-]/g, "");
135
135
  }
136
- const P = [
136
+ const X = [
137
137
  { title: "Standalone App — full application with bundled modules", value: "standalone" },
138
138
  { title: "Dynamic Module — remote module loaded by host via Module Federation", value: "dynamic-module" }
139
139
  ];
140
- function G(e) {
141
- return typeof e == "string" && P.some((a) => a.value === e);
142
- }
143
- async function Q(e, a) {
144
- const t = process.cwd();
140
+ async function G(e, n) {
141
+ const a = process.cwd();
145
142
  let o = e._?.[0] || e.name || e["app-name"];
146
143
  const d = o || "vc-app", p = () => o === "." ? c.basename(c.resolve()) : o, m = !!(o && e.type);
147
144
  let l;
148
145
  if (m) {
149
146
  o = o || d;
150
- const f = c.resolve(t, o);
151
- if (!G(e.type)) {
152
- const b = P.map(($) => $.value).join(", ");
153
- console.error(n.red(`Unknown project type: "${e.type}". Valid types: ${b}`)), process.exit(1);
154
- }
155
- r.existsSync(f) && !I(f) && !e.overwrite && (console.error(n.red(`Target directory "${o}" is not empty. Use --overwrite to overwrite.`)), process.exit(1));
147
+ const f = c.resolve(a, o);
148
+ r.existsSync(f) && !I(f) && !e.overwrite && (console.error(t.red(`Target directory "${o}" is not empty. Use --overwrite to overwrite.`)), process.exit(1));
156
149
  const u = p(), y = e.type, g = e["module-name"], N = y === "dynamic-module" ? g || S(u) : g || void 0;
157
150
  l = {
158
151
  projectName: h(u),
@@ -167,7 +160,7 @@ async function Q(e, a) {
167
160
  };
168
161
  } else {
169
162
  const f = () => {
170
- throw new Error(n.red("✖") + " Creation cancelled");
163
+ throw new Error(t.red("✖") + " Creation cancelled");
171
164
  };
172
165
  try {
173
166
  const u = await A(
@@ -175,7 +168,7 @@ async function Q(e, a) {
175
168
  {
176
169
  name: "projectName",
177
170
  type: o ? null : "text",
178
- message: n.reset("Project name:"),
171
+ message: t.reset("Project name:"),
179
172
  initial: d,
180
173
  onState: (w) => {
181
174
  o = h(String(w.value).trim()) || d;
@@ -183,14 +176,14 @@ async function Q(e, a) {
183
176
  format: (w) => h(String(w).trim())
184
177
  },
185
178
  {
186
- type: () => !r.existsSync(c.resolve(t, o)) || I(c.resolve(t, o)) ? null : "confirm",
179
+ type: () => !r.existsSync(c.resolve(a, o)) || I(c.resolve(a, o)) ? null : "confirm",
187
180
  name: "overwrite",
188
181
  message: () => (o === "." ? "Current directory" : `Target directory "${o}"`) + " is not empty. Remove existing files and continue?"
189
182
  },
190
183
  {
191
184
  type: (w, { overwrite: M }) => {
192
185
  if (M === !1)
193
- throw new Error(n.red("✖") + " Operation cancelled");
186
+ throw new Error(t.red("✖") + " Operation cancelled");
194
187
  return null;
195
188
  },
196
189
  name: "overwriteChecker"
@@ -198,19 +191,19 @@ async function Q(e, a) {
198
191
  {
199
192
  name: "packageName",
200
193
  type: () => k(p()) ? null : "text",
201
- message: n.reset("Package name:"),
194
+ message: t.reset("Package name:"),
202
195
  initial: () => C(p()),
203
196
  validate: (w) => k(w) || "Invalid package.json name"
204
197
  },
205
198
  {
206
199
  type: "select",
207
200
  name: "projectType",
208
- message: n.reset("Project type:"),
209
- choices: P
201
+ message: t.reset("Project type:"),
202
+ choices: X
210
203
  }
211
204
  ],
212
205
  { onCancel: f }
213
- ), y = o ? h(o) : u.projectName, g = u.projectType || "standalone", N = S(y), b = "/apps/" + h(y) + "/", $ = await A(
206
+ ), y = o ? h(o) : u.projectName, g = u.projectType || "standalone", N = S(y), j = "/apps/" + h(y) + "/", $ = await A(
214
207
  [
215
208
  {
216
209
  name: "includeModule",
@@ -221,15 +214,15 @@ async function Q(e, a) {
221
214
  {
222
215
  name: "moduleName",
223
216
  type: (w, M) => g === "standalone" && !M.includeModule ? null : "text",
224
- message: n.reset("Module name:"),
217
+ message: t.reset("Module name:"),
225
218
  initial: N,
226
219
  format: (w) => String(w).trim()
227
220
  },
228
221
  {
229
222
  name: "basePath",
230
223
  type: g === "dynamic-module" ? null : "text",
231
- message: n.reset("Base path:"),
232
- initial: b,
224
+ message: t.reset("Base path:"),
225
+ initial: j,
233
226
  format: (w) => _(String(w).trim())
234
227
  },
235
228
  {
@@ -264,7 +257,7 @@ async function Q(e, a) {
264
257
  packageName: u.packageName || (k(y) ? y : C(y)),
265
258
  projectType: g,
266
259
  moduleName: $.moduleName || ($.includeModule !== !1 ? N : void 0),
267
- basePath: $.basePath || _(b),
260
+ basePath: $.basePath || _(j),
268
261
  tenantRoutes: $.tenantRoutes || !1,
269
262
  aiAgent: $.aiAgent || !1,
270
263
  dashboard: $.dashboard ?? !0,
@@ -274,59 +267,59 @@ async function Q(e, a) {
274
267
  console.log(u.message), process.exit(1);
275
268
  }
276
269
  }
277
- const i = c.resolve(t, o);
278
- r.existsSync(i) && !I(i) ? q(i) : r.existsSync(i) || r.mkdirSync(i, { recursive: !0 }), console.log(`
279
- Scaffolding ${n.cyan(l.projectType)} in ${n.green(i)}...
270
+ const i = c.resolve(a, o);
271
+ r.existsSync(i) && !I(i) ? Y(i) : r.existsSync(i) || r.mkdirSync(i, { recursive: !0 }), console.log(`
272
+ Scaffolding ${t.cyan(l.projectType)} in ${t.green(i)}...
280
273
  `);
281
- const v = R(l);
282
- if (j(c.join(a, l.projectType), i, v), l.moduleName) {
274
+ const v = D(l);
275
+ if (b(c.join(n, l.projectType), i, v), l.moduleName) {
283
276
  const f = h(l.moduleName), u = l.projectType === "dynamic-module" ? c.join(i, "src/modules") : c.join(i, "src/modules", f);
284
- j(c.join(a, "module"), u, v);
277
+ b(c.join(n, "module"), u, v);
285
278
  }
286
- l.mocks && j(c.join(a, "sample-module"), c.join(i, "src/modules/sample"), v), H(l);
279
+ l.mocks && b(c.join(n, "sample-module"), c.join(i, "src/modules/sample"), v), W(l);
287
280
  }
288
- function U(e, a) {
289
- const t = /^import\s.+$/gm;
281
+ function R(e, n) {
282
+ const a = /^import\s.+$/gm;
290
283
  let s = null, o;
291
- for (; (o = t.exec(e)) !== null; )
284
+ for (; (o = a.exec(e)) !== null; )
292
285
  s = o;
293
286
  if (s) {
294
287
  const d = s.index + s[0].length;
295
288
  return e.slice(0, d) + `
296
- ` + a + e.slice(d);
289
+ ` + n + e.slice(d);
297
290
  }
298
- return a + `
291
+ return n + `
299
292
  ` + e;
300
293
  }
301
- function ee(e, a) {
302
- let t = r.readFileSync(e, "utf-8");
303
- const s = x(a), o = h(a);
304
- t = U(t, `import ${s} from "./modules/${o}";`);
294
+ function Q(e, n) {
295
+ let a = r.readFileSync(e, "utf-8");
296
+ const s = x(n), o = h(n);
297
+ a = R(a, `import ${s} from "./modules/${o}";`);
305
298
  const d = /\.use\([A-Z]\w+,\s*\{\s*router\s*\}\)/g;
306
299
  let p = null, m;
307
- for (; (m = d.exec(t)) !== null; )
300
+ for (; (m = d.exec(a)) !== null; )
308
301
  p = m;
309
302
  if (p) {
310
303
  const l = p.index + p[0].length, i = `
311
304
  .use(${s}, { router })`;
312
- t = t.slice(0, l) + i + t.slice(l);
305
+ a = a.slice(0, l) + i + a.slice(l);
313
306
  }
314
- r.writeFileSync(e, t);
307
+ r.writeFileSync(e, a);
315
308
  }
316
- function te(e, a) {
317
- let t = r.readFileSync(e, "utf-8");
318
- const s = h(a), o = D(a);
319
- if (!t.includes("addMenuItem")) {
320
- const v = /import\s*\{([^}]+)\}\s*from\s*["']@vc-shell\/framework["']/.exec(t);
309
+ function ee(e, n) {
310
+ let a = r.readFileSync(e, "utf-8");
311
+ const s = h(n), o = E(n);
312
+ if (!a.includes("addMenuItem")) {
313
+ const v = /import\s*\{([^}]+)\}\s*from\s*["']@vc-shell\/framework["']/.exec(a);
321
314
  if (v) {
322
315
  const f = v[1].trim() + ", addMenuItem";
323
- t = t.replace(v[0], `import { ${f} } from "@vc-shell/framework"`);
316
+ a = a.replace(v[0], `import { ${f} } from "@vc-shell/framework"`);
324
317
  } else
325
- t = U(t, 'import { addMenuItem } from "@vc-shell/framework";');
318
+ a = R(a, 'import { addMenuItem } from "@vc-shell/framework";');
326
319
  }
327
320
  const d = /addMenuItem\(\{[\s\S]*?\}\);/g;
328
321
  let p = null, m;
329
- for (; (m = d.exec(t)) !== null; )
322
+ for (; (m = d.exec(a)) !== null; )
330
323
  p = m;
331
324
  const l = `
332
325
  addMenuItem({
@@ -337,59 +330,59 @@ function te(e, a) {
337
330
  });`;
338
331
  if (p) {
339
332
  const i = p.index + p[0].length;
340
- t = t.slice(0, i) + `
341
- ` + l + t.slice(i);
333
+ a = a.slice(0, i) + `
334
+ ` + l + a.slice(i);
342
335
  } else {
343
- const i = t.lastIndexOf("}");
344
- i !== -1 && (t = t.slice(0, i) + l + `
345
- ` + t.slice(i));
336
+ const i = a.lastIndexOf("}");
337
+ i !== -1 && (a = a.slice(0, i) + l + `
338
+ ` + a.slice(i));
346
339
  }
347
- r.writeFileSync(e, t);
340
+ r.writeFileSync(e, a);
348
341
  }
349
- async function ae(e, a) {
350
- const t = process.cwd(), s = e._?.[1], o = c.join(t, "package.json");
351
- r.existsSync(o) || (console.error(n.red("Error: No package.json found. Run this command from a vc-shell project root.")), process.exit(1));
342
+ async function ae(e, n) {
343
+ const a = process.cwd(), s = e._?.[1], o = c.join(a, "package.json");
344
+ r.existsSync(o) || (console.error(t.red("Error: No package.json found. Run this command from a vc-shell project root.")), process.exit(1));
352
345
  const d = JSON.parse(r.readFileSync(o, "utf-8"));
353
- ({ ...d.dependencies, ...d.devDependencies })["@vc-shell/framework"] || (console.error(n.red("Error: Not a vc-shell project (@vc-shell/framework not found in dependencies).")), process.exit(1));
346
+ ({ ...d.dependencies, ...d.devDependencies })["@vc-shell/framework"] || (console.error(t.red("Error: Not a vc-shell project (@vc-shell/framework not found in dependencies).")), process.exit(1));
354
347
  let m = s;
355
348
  m || (m = (await A({
356
349
  type: "text",
357
350
  name: "moduleName",
358
351
  message: "Module name:",
359
- validate: (b) => b.trim().length > 0 || "Module name is required"
360
- })).moduleName), m || (console.error(n.red("Module name is required.")), process.exit(1));
361
- const l = h(m), i = x(m), v = c.join(t, "src/modules"), f = c.join(v, l);
362
- r.existsSync(v) || r.mkdirSync(v, { recursive: !0 }), r.existsSync(f) && (console.error(n.red(`Error: Module "${l}" already exists at ${c.relative(t, f)}`)), process.exit(1));
363
- const u = R({ moduleName: m, projectName: c.basename(t) });
364
- j(c.join(a, "module"), f, u), console.log(n.green(` ✔ Created ${c.relative(t, f)}/`));
365
- const y = c.join(t, "src/main.ts");
352
+ validate: (j) => j.trim().length > 0 || "Module name is required"
353
+ })).moduleName), m || (console.error(t.red("Module name is required.")), process.exit(1));
354
+ const l = h(m), i = x(m), v = c.join(a, "src/modules"), f = c.join(v, l);
355
+ r.existsSync(v) || r.mkdirSync(v, { recursive: !0 }), r.existsSync(f) && (console.error(t.red(`Error: Module "${l}" already exists at ${c.relative(a, f)}`)), process.exit(1));
356
+ const u = D({ moduleName: m, projectName: c.basename(a) });
357
+ b(c.join(n, "module"), f, u), console.log(t.green(` ✔ Created ${c.relative(a, f)}/`));
358
+ const y = c.join(a, "src/main.ts");
366
359
  if (r.existsSync(y))
367
360
  try {
368
- ee(y, m), console.log(n.green(` ✔ Updated src/main.ts — added import & app.use(${i})`));
361
+ Q(y, m), console.log(t.green(` ✔ Updated src/main.ts — added import & app.use(${i})`));
369
362
  } catch {
370
- console.warn(n.yellow(" ⚠ Could not auto-update src/main.ts. Add manually:")), console.warn(n.yellow(` import ${i} from "./modules/${l}";`)), console.warn(n.yellow(` app.use(${i}, { router });`));
363
+ console.warn(t.yellow(" ⚠ Could not auto-update src/main.ts. Add manually:")), console.warn(t.yellow(` import ${i} from "./modules/${l}";`)), console.warn(t.yellow(` app.use(${i}, { router });`));
371
364
  }
372
- const g = c.join(t, "src/bootstrap.ts");
365
+ const g = c.join(a, "src/bootstrap.ts");
373
366
  if (r.existsSync(g))
374
367
  try {
375
- te(g, m), console.log(n.green(` ✔ Updated src/bootstrap.ts — added menu item "${S(m)}"`));
368
+ ee(g, m), console.log(t.green(` ✔ Updated src/bootstrap.ts — added menu item "${S(m)}"`));
376
369
  } catch {
377
- console.warn(n.yellow(" ⚠ Could not auto-update src/bootstrap.ts. Add addMenuItem() manually."));
370
+ console.warn(t.yellow(" ⚠ Could not auto-update src/bootstrap.ts. Add addMenuItem() manually."));
378
371
  }
379
372
  console.log(`
380
- Module "${l}" is ready! Run ${n.bold(n.green("yarn serve"))} to see it.
373
+ Module "${l}" is ready! Run ${t.bold(t.green("yarn serve"))} to see it.
381
374
  `);
382
375
  }
383
- const T = c.resolve(F(import.meta.url), "..", "templates");
384
- function ne() {
376
+ const P = c.resolve(B(import.meta.url), "..", "templates");
377
+ function te() {
385
378
  console.log(`
386
- ${n.bold(n.green("create-vc-app"))} — Create VC Shell applications and modules
379
+ ${t.bold(t.green("create-vc-app"))} — Create VC Shell applications and modules
387
380
 
388
- ${n.bold("Usage:")}
381
+ ${t.bold("Usage:")}
389
382
  create-vc-app [project-name] [options] Create a new project
390
383
  create-vc-app add-module <module-name> Add a module to existing project
391
384
 
392
- ${n.bold("Options (create):")}
385
+ ${t.bold("Options (create):")}
393
386
  --type <type> Project type: standalone | dynamic-module
394
387
  --name, --app-name <name> Application name
395
388
  --package-name <name> npm package name
@@ -403,31 +396,31 @@ ${n.bold("Options (create):")}
403
396
  --help, -h Show this help
404
397
  --version, -v Show version
405
398
 
406
- ${n.bold("Examples:")}
399
+ ${t.bold("Examples:")}
407
400
  create-vc-app my-app
408
401
  create-vc-app my-app --type standalone --dashboard --mocks
409
402
  create-vc-app my-module --type dynamic-module --module-name "Reviews"
410
403
  create-vc-app add-module orders
411
404
 
412
- ${n.bold("Docs:")} https://docs.virtocommerce.org/platform/developer-guide/latest/custom-apps-development/vc-shell/vc-shell-overview/
405
+ ${t.bold("Docs:")} https://docs.virtocommerce.org/platform/developer-guide/latest/custom-apps-development/vc-shell/vc-shell-overview/
413
406
  `);
414
407
  }
415
- async function oe() {
416
- const e = z(B.slice(2), {
408
+ async function ne() {
409
+ const e = z(L.slice(2), {
417
410
  alias: { h: "help", v: "version" },
418
411
  boolean: ["help", "version", "mocks", "overwrite", "tenant-routes", "ai-agent", "dashboard"],
419
412
  string: ["type", "name", "app-name", "package-name", "module-name", "base-path"]
420
413
  });
421
414
  if (e.help) {
422
- ne();
415
+ te();
423
416
  return;
424
417
  }
425
418
  if (e.version) {
426
- console.log(`create-vc-app v${V.version}`);
419
+ console.log(`create-vc-app v${O.version}`);
427
420
  return;
428
421
  }
429
- e._[0] === "add-module" ? await ae(e, T) : await Q(e, T);
422
+ e._[0] === "add-module" ? await ae(e, P) : await G(e, P);
430
423
  }
431
- oe().catch((e) => {
432
- console.error(n.red(e.message || String(e))), L(1);
424
+ ne().catch((e) => {
425
+ console.error(t.red(e.message || String(e))), U(1);
433
426
  });
@@ -0,0 +1,12 @@
1
+ Copyright (c) Virto Solutions LTD. All rights reserved.
2
+
3
+ Licensed under the Virto Commerce Open Software License (the "License"); you
4
+ may not use this file except in compliance with the License. You may
5
+ obtain a copy of the License at
6
+
7
+ https://virtocommerce.com/open-source-license
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12
+ implied.