@vc-shell/create-vc-app 1.1.99-alpha.2 → 1.1.99-alpha.4

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 (32) hide show
  1. package/README.md +41 -5
  2. package/dist/cli/argv.d.ts.map +1 -1
  3. package/dist/cli/help.d.ts.map +1 -1
  4. package/dist/cli/types.d.ts +5 -0
  5. package/dist/cli/types.d.ts.map +1 -1
  6. package/dist/commands/generate-blade.d.ts +5 -0
  7. package/dist/commands/generate-blade.d.ts.map +1 -1
  8. package/dist/index.js +940 -789
  9. package/dist/templates/base/_package.json +5 -5
  10. package/dist/templates/blades/grid/blade.vue +4 -15
  11. package/dist/utils/naming.d.ts +1 -0
  12. package/dist/utils/naming.d.ts.map +1 -1
  13. package/dist/utils/register-module.d.ts +4 -0
  14. package/dist/utils/register-module.d.ts.map +1 -1
  15. package/dist/utils/templates.d.ts +10 -0
  16. package/dist/utils/templates.d.ts.map +1 -0
  17. package/dist/workflows/create-app.d.ts.map +1 -1
  18. package/package.json +3 -3
  19. package/dist/templates/base/ai-guides/.cursorrules-vc-shell +0 -529
  20. package/dist/templates/base/ai-guides/README.md +0 -360
  21. package/dist/templates/base/ai-guides/guides/AI_GUIDE.md +0 -195
  22. package/dist/templates/base/ai-guides/guides/blade-patterns.md +0 -384
  23. package/dist/templates/base/ai-guides/guides/complete-workflow.md +0 -781
  24. package/dist/templates/base/ai-guides/guides/composables-reference.md +0 -338
  25. package/dist/templates/base/ai-guides/guides/troubleshooting.md +0 -529
  26. package/dist/templates/base/ai-guides/guides/ui-components-reference.md +0 -903
  27. package/dist/templates/base/ai-guides/prompts/adapt-existing-module.md +0 -1026
  28. package/dist/templates/base/ai-guides/prompts/advanced-scenarios.md +0 -852
  29. package/dist/templates/base/ai-guides/prompts/api-client-generation.md +0 -877
  30. package/dist/templates/base/ai-guides/prompts/cli-usage.md +0 -640
  31. package/dist/templates/base/ai-guides/prompts/quick-start-scenarios.md +0 -773
  32. package/dist/templates/base/ai-guides/prompts/simple-modifications.md +0 -987
package/dist/index.js CHANGED
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env node
2
2
  import o from "chalk";
3
3
  import m from "node:path";
4
- import { argv as me, cwd as _ } from "node:process";
4
+ import { argv as me, cwd as G } from "node:process";
5
5
  import ue from "mri";
6
6
  import x from "prompts";
7
- import r from "node:fs";
8
- import { fileURLToPath as X } from "node:url";
7
+ import l from "node:fs";
9
8
  import Y from "prettier";
10
- import { camelCase as F, snakeCase as v, upperFirst as T, kebabCase as N } from "lodash-es";
9
+ import { camelCase as F, snakeCase as v, upperFirst as T, kebabCase as C } from "lodash-es";
11
10
  import pe from "pluralize";
12
- function ge(t = me.slice(2)) {
13
- return ue(t, {
11
+ import { fileURLToPath as ge } from "node:url";
12
+ function fe(e = me.slice(2)) {
13
+ return ue(e, {
14
14
  alias: {
15
15
  h: "help",
16
16
  v: "version"
@@ -26,29 +26,44 @@ function ge(t = me.slice(2)) {
26
26
  "skip-form-editor",
27
27
  "skip-module-gen"
28
28
  ],
29
- string: ["name", "app-name", "package-name", "module-name", "base-path", "type", "module", "path", "form-fields"]
29
+ string: [
30
+ "name",
31
+ "app-name",
32
+ "package-name",
33
+ "module-name",
34
+ "base-path",
35
+ "type",
36
+ "module",
37
+ "path",
38
+ "form-fields",
39
+ "widget-module",
40
+ "widget-blade",
41
+ "widget-name",
42
+ "widget-entity",
43
+ "widget-icon"
44
+ ]
30
45
  });
31
46
  }
32
- function L(t) {
33
- return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(t);
47
+ function R(e) {
48
+ return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(e);
34
49
  }
35
- function A(t) {
36
- return t.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
50
+ function O(e) {
51
+ return e.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
37
52
  }
38
- function ee(t) {
39
- return t.trim().toLowerCase().replace(/\/+/g, "/").replace(/[^a-z0-9/-]+/g, "/").replace(/\/?$/, "/");
53
+ function X(e) {
54
+ return e.trim().toLowerCase().replace(/\/+/g, "/").replace(/[^a-z0-9/-]+/g, "/").replace(/\/?$/, "/");
40
55
  }
41
- function fe(t) {
42
- return t.startsWith("/") && t.endsWith("/");
56
+ function ye(e) {
57
+ return e.startsWith("/") && e.endsWith("/");
43
58
  }
44
- function ye(t) {
45
- const e = [];
46
- return t["package-name"] && !L(t["package-name"]) && e.push(`Invalid package name: ${t["package-name"]}`), t["base-path"] && !fe(t["base-path"]) && e.push(`Invalid base path: ${t["base-path"]}. Must start and end with "/"`), e;
59
+ function he(e) {
60
+ const t = [];
61
+ return e["package-name"] && !R(e["package-name"]) && t.push(`Invalid package name: ${e["package-name"]}`), e["base-path"] && !ye(e["base-path"]) && t.push(`Invalid base path: ${e["base-path"]}. Must start and end with "/"`), t;
47
62
  }
48
- const he = "1.1.99-alpha.2", U = {
49
- version: he
63
+ const we = "1.1.99-alpha.4", U = {
64
+ version: we
50
65
  };
51
- function we() {
66
+ function be() {
52
67
  console.log(`
53
68
  ${o.bold(o.green("create-vc-app"))} - Create a new VC Shell application or generate modules/blades
54
69
 
@@ -73,6 +88,11 @@ ${o.bold("Blade Generator Options:")}
73
88
  --name <name> Blade name
74
89
  --is-workspace Mark blade as workspace (main module blade)
75
90
  --widget Generate widget instead of blade
91
+ --widget-module <name> Module name for widget (non-interactive)
92
+ --widget-blade <name> Blade name for widget (non-interactive)
93
+ --widget-name <name> Widget name (non-interactive)
94
+ --widget-entity <name> Related entity name (non-interactive)
95
+ --widget-icon <icon> Widget icon (non-interactive, default: material-list)
76
96
  --composable Generate composable
77
97
  --locales Generate locales
78
98
  --path <path> Target path
@@ -111,9 +131,13 @@ ${o.bold("Examples:")}
111
131
 
112
132
  ${o.gray("# Generate widget interactively")}
113
133
  create-vc-app blade --widget
134
+
135
+ ${o.gray("# Generate widget non-interactively")}
136
+ create-vc-app blade --widget --widget-module products --widget-blade products-list \\
137
+ --widget-name Stats --widget-entity Product --widget-icon material-sell
114
138
  `);
115
139
  }
116
- function be() {
140
+ function Ee() {
117
141
  console.log(`create-vc-app version ${U.version}`);
118
142
  }
119
143
  const Se = {
@@ -134,97 +158,99 @@ const Se = {
134
158
  _yarn: ".yarn",
135
159
  "_package.json": "package.json"
136
160
  }, $e = [".ts", ".vue", ".js", ".json", ".md"], Z = "18.0.0";
137
- function Ee() {
138
- const t = process.version.slice(1), [e] = t.split(".").map(Number), [n] = Z.split(".").map(Number);
161
+ function ve() {
162
+ const e = process.version.slice(1), [t] = e.split(".").map(Number), [n] = Z.split(".").map(Number);
139
163
  return {
140
- compatible: e >= n,
141
- currentVersion: t,
164
+ compatible: t >= n,
165
+ currentVersion: e,
142
166
  minVersion: Z
143
167
  };
144
168
  }
145
- async function P(t) {
169
+ async function P(e) {
146
170
  try {
147
- const e = r.readFileSync(t, "utf-8"), n = m.extname(t);
171
+ const t = l.readFileSync(e, "utf-8"), n = m.extname(e);
148
172
  let a = "typescript";
149
173
  n === ".vue" ? a = "vue" : n === ".json" ? a = "json" : n === ".md" ? a = "markdown" : n === ".css" || n === ".scss" ? a = "css" : n === ".html" ? a = "html" : n === ".js" || n === ".mjs" || n === ".cjs" ? a = "babel" : (n === ".ts" || n === ".mts" || n === ".cts") && (a = "typescript");
150
- let s = null;
174
+ let i = null;
151
175
  try {
152
- s = await Y.resolveConfig(t, {
176
+ i = await Y.resolveConfig(e, {
153
177
  editorconfig: !0
154
178
  });
155
179
  } catch {
156
180
  }
157
- const l = {
181
+ const s = {
158
182
  ...{
159
183
  endOfLine: "auto",
160
184
  // Changed from "lf" to "auto"
161
185
  singleAttributePerLine: !0
162
186
  // Added for Vue files
163
187
  },
164
- ...s,
188
+ ...i,
165
189
  parser: a
166
190
  // Always use detected parser
167
- }, d = await Y.format(e, l);
168
- r.writeFileSync(t, d, "utf-8");
169
- } catch (e) {
170
- console.warn(o.yellow(`⚠️ Warning: Could not format ${t}`)), console.warn(o.yellow(` ${e.message}`));
191
+ }, d = await Y.format(t, s);
192
+ l.writeFileSync(e, d, "utf-8");
193
+ } catch (t) {
194
+ console.warn(o.yellow(`⚠️ Warning: Could not format ${e}`)), console.warn(o.yellow(` ${t.message}`));
171
195
  }
172
196
  }
173
- async function te(t, e = [".ts", ".vue", ".js", ".json"]) {
174
- const n = r.readdirSync(t);
197
+ async function ee(e, t = [".ts", ".vue", ".js", ".json"]) {
198
+ const n = l.readdirSync(e);
175
199
  for (const a of n) {
176
- const s = m.join(t, a);
177
- r.statSync(s).isDirectory() ? await te(s, e) : e.some((l) => a.endsWith(l)) && await P(s);
200
+ const i = m.join(e, a);
201
+ l.statSync(i).isDirectory() ? await ee(i, t) : t.some((s) => a.endsWith(s)) && await P(i);
178
202
  }
179
203
  }
180
- function W(t, e) {
181
- const n = F(t), a = pe(t), s = F(a);
204
+ function W(e, t) {
205
+ const n = F(e), a = pe(e), i = F(a);
182
206
  return {
183
- entitySingular: t,
207
+ entitySingular: e,
184
208
  entityPlural: a,
185
- moduleName: e,
209
+ moduleName: t,
186
210
  entitySingularPascal: T(n),
187
211
  entitySingularCamel: n,
188
- entitySingularKebab: N(t),
189
- entityPluralPascal: T(s),
190
- entityPluralCamel: s,
191
- entityPluralKebab: N(a),
192
- moduleNamePascal: T(F(e)),
193
- moduleNameUpperSnake: v(e).toUpperCase()
212
+ entitySingularKebab: C(e),
213
+ entityPluralPascal: T(i),
214
+ entityPluralCamel: i,
215
+ entityPluralKebab: C(a),
216
+ entityListKebab: `${C(e)}-list`,
217
+ moduleNamePascal: T(F(t)),
218
+ moduleNameUpperSnake: v(t).toUpperCase()
194
219
  };
195
220
  }
196
- function z(t) {
221
+ function z(e) {
197
222
  return {
198
- "{{EntityName}}": t.entitySingularPascal,
199
- "{{EntityNamePlural}}": t.entityPluralPascal,
200
- "{{entityName}}": t.entitySingularCamel,
201
- "{{entityNamePlural}}": t.entityPluralCamel,
202
- "{{entity-name}}": t.entitySingularKebab,
203
- "{{entity-name-plural}}": t.entityPluralKebab,
204
- "{{entity_name}}": v(t.entitySingular),
205
- "{{entity_name_plural}}": v(t.entityPlural),
206
- "{{ModuleName}}": t.moduleNamePascal,
207
- "{{moduleName}}": F(t.moduleName),
208
- "{{module-name}}": N(t.moduleName),
209
- "{{MODULE_NAME}}": t.moduleNameUpperSnake,
210
- "{{MODULE_NAME_UPPERCASE}}": t.moduleNameUpperSnake
223
+ "{{EntityName}}": e.entitySingularPascal,
224
+ "{{EntityNamePlural}}": e.entityPluralPascal,
225
+ "{{entityName}}": e.entitySingularCamel,
226
+ "{{entityNamePlural}}": e.entityPluralCamel,
227
+ "{{entity-name}}": e.entitySingularKebab,
228
+ "{{entity-name-plural}}": e.entityPluralKebab,
229
+ "{{entity-name-list}}": e.entityListKebab,
230
+ "{{entity_name}}": v(e.entitySingular),
231
+ "{{entity_name_plural}}": v(e.entityPlural),
232
+ "{{ModuleName}}": e.moduleNamePascal,
233
+ "{{moduleName}}": F(e.moduleName),
234
+ "{{module-name}}": C(e.moduleName),
235
+ "{{MODULE_NAME}}": e.moduleNameUpperSnake,
236
+ "{{MODULE_NAME_UPPERCASE}}": e.moduleNameUpperSnake
211
237
  };
212
238
  }
213
- function H(t, e) {
214
- let n = t;
215
- for (const [a, s] of Object.entries(e))
216
- n = n.replace(new RegExp(a, "g"), s);
239
+ function H(e, t) {
240
+ let n = e;
241
+ for (const [a, i] of Object.entries(t))
242
+ n = n.replace(new RegExp(a, "g"), i);
217
243
  return n;
218
244
  }
219
- function ae(t) {
220
- return t.replace(/'/g, "\\'").replace(/"/g, '\\"');
245
+ function te(e) {
246
+ return e.replace(/'/g, "\\'").replace(/"/g, '\\"');
221
247
  }
222
- async function ne() {
223
- const t = [];
224
- let e = !0;
248
+ async function ae() {
249
+ const e = [];
250
+ let t = !0;
225
251
  for (console.log(`
226
252
  📝 Configure form fields (press Ctrl+C to skip):
227
- `); e; )
253
+ `); t; )
228
254
  try {
229
255
  const n = await x(
230
256
  [
@@ -338,45 +364,45 @@ async function ne() {
338
364
  ],
339
365
  {
340
366
  onCancel: () => {
341
- throw e = !1, new Error("cancelled");
367
+ throw t = !1, new Error("cancelled");
342
368
  }
343
369
  }
344
370
  );
345
371
  if (!n.name) {
346
- e = !1;
372
+ t = !1;
347
373
  break;
348
374
  }
349
- t.push({
375
+ e.push({
350
376
  name: n.name,
351
377
  type: n.type,
352
378
  label: n.label || T(n.name),
353
379
  required: n.required,
354
380
  options: n.options
355
- }), e = n.addAnother;
381
+ }), t = n.addAnother;
356
382
  } catch (n) {
357
383
  if (n.message === "cancelled")
358
384
  break;
359
385
  throw n;
360
386
  }
361
- return t;
387
+ return e;
362
388
  }
363
- function q(t, e) {
364
- const n = v(t.name).toUpperCase(), a = t.required ? 'rules="required"' : "";
365
- let s = "";
366
- return t.type === "number" ? s = 'type="number"' : t.type === "date" && (s = 'type="date"'), ` <Field
389
+ function q(e, t) {
390
+ const n = v(e.name).toUpperCase(), a = e.required ? 'rules="required"' : "";
391
+ let i = "";
392
+ return e.type === "number" ? i = 'type="number"' : e.type === "date" && (i = 'type="date"'), ` <Field
367
393
  v-slot="{ field, errorMessage, handleChange, errors }"
368
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
369
- :model-value="item.${t.name}"
370
- name="${t.name}"
394
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
395
+ :model-value="item.${e.name}"
396
+ name="${e.name}"
371
397
  ${a}
372
398
  >
373
399
  <VcInput
374
400
  v-bind="field"
375
- v-model="item.${t.name}"
376
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
377
- :placeholder="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}_PLACEHOLDER')"
378
- ${s}
379
- ${t.required ? "required" : ""}
401
+ v-model="item.${e.name}"
402
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
403
+ :placeholder="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}_PLACEHOLDER')"
404
+ ${i}
405
+ ${e.required ? "required" : ""}
380
406
  clearable
381
407
  :error="!!errors.length"
382
408
  :error-message="errorMessage"
@@ -384,37 +410,37 @@ function q(t, e) {
384
410
  />
385
411
  </Field>`;
386
412
  }
387
- function ve(t, e) {
388
- const n = v(t.name).toUpperCase();
413
+ function Ie(e, t) {
414
+ const n = v(e.name).toUpperCase();
389
415
  return ` <VcTextarea
390
- v-model="item.${t.name}"
391
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
392
- :placeholder="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}_PLACEHOLDER')"
393
- ${t.required ? "required" : ""}
416
+ v-model="item.${e.name}"
417
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
418
+ :placeholder="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}_PLACEHOLDER')"
419
+ ${e.required ? "required" : ""}
394
420
  clearable
395
421
  />`;
396
422
  }
397
- function Ie(t, e) {
398
- const n = v(t.name).toUpperCase(), a = t.required ? 'rules="required"' : "", s = t.options?.map((c) => {
399
- const l = ae(c);
400
- return `{ value: '${l}', label: '${l}' }`;
423
+ function Ae(e, t) {
424
+ const n = v(e.name).toUpperCase(), a = e.required ? 'rules="required"' : "", i = e.options?.map((r) => {
425
+ const s = te(r);
426
+ return `{ value: '${s}', label: '${s}' }`;
401
427
  }).join(", ") || "";
402
428
  return ` <Field
403
429
  v-slot="{ errorMessage, handleChange, errors }"
404
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
405
- :model-value="item.${t.name}"
406
- name="${t.name}"
430
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
431
+ :model-value="item.${e.name}"
432
+ name="${e.name}"
407
433
  ${a}
408
434
  >
409
435
  <VcSelect
410
- v-model="item.${t.name}"
411
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
412
- :placeholder="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}_PLACEHOLDER')"
413
- :options="[${s}]"
436
+ v-model="item.${e.name}"
437
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
438
+ :placeholder="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}_PLACEHOLDER')"
439
+ :options="[${i}]"
414
440
  option-value="value"
415
441
  option-label="label"
416
442
  searchable
417
- ${t.required ? "required" : ""}
443
+ ${e.required ? "required" : ""}
418
444
  :clearable="false"
419
445
  :error="!!errors.length"
420
446
  :error-message="errorMessage"
@@ -422,41 +448,41 @@ function Ie(t, e) {
422
448
  />
423
449
  </Field>`;
424
450
  }
425
- function Ce(t, e) {
426
- const n = v(t.name).toUpperCase(), a = t.required ? 'rules="required"' : "";
451
+ function Ne(e, t) {
452
+ const n = v(e.name).toUpperCase(), a = e.required ? 'rules="required"' : "";
427
453
  return ` <Field
428
454
  v-slot="{ errorMessage, handleChange, errors }"
429
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
430
- :model-value="item.${t.name}"
431
- name="${t.name}"
455
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
456
+ :model-value="item.${e.name}"
457
+ name="${e.name}"
432
458
  ${a}
433
459
  >
434
460
  <VcEditor
435
- v-model="item.${t.name}"
436
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
437
- :placeholder="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}_PLACEHOLDER')"
438
- ${t.required ? "required" : ""}
461
+ v-model="item.${e.name}"
462
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
463
+ :placeholder="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}_PLACEHOLDER')"
464
+ ${e.required ? "required" : ""}
439
465
  :error="!!errors.length"
440
466
  :error-message="errorMessage"
441
467
  @update:model-value="handleChange"
442
468
  />
443
469
  </Field>`;
444
470
  }
445
- function xe(t, e) {
446
- const n = v(t.name).toUpperCase();
471
+ function xe(e, t) {
472
+ const n = v(e.name).toUpperCase();
447
473
  return ` <VcSwitch
448
- v-model="item.${t.name}"
449
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
450
- :tooltip="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}_TOOLTIP')"
474
+ v-model="item.${e.name}"
475
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
476
+ :tooltip="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}_TOOLTIP')"
451
477
  :true-value="true"
452
478
  :false-value="false"
453
479
  />`;
454
480
  }
455
- function Ae(t, e) {
456
- const n = v(t.name).toUpperCase();
457
- return ` <VcCard :header="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')">
481
+ function Ce(e, t) {
482
+ const n = v(e.name).toUpperCase();
483
+ return ` <VcCard :header="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')">
458
484
  <VcGallery
459
- :images="item.${t.name}"
485
+ :images="item.${e.name}"
460
486
  multiple
461
487
  @upload="assetsHandler.upload"
462
488
  @sort="assetsHandler.edit"
@@ -465,7 +491,7 @@ function Ae(t, e) {
465
491
  />
466
492
  </VcCard>`;
467
493
  }
468
- function Ne(t) {
494
+ function Oe(e) {
469
495
  return `
470
496
  // VcGallery Assets Handler Setup
471
497
  // TODO: Import Image type from your API client (e.g., import { Image, IImage } from "@your-app/api/client")
@@ -473,13 +499,13 @@ const { upload, remove, edit, loading: assetsLoading } = useAssets();
473
499
 
474
500
  /**
475
501
  * Handles asset operations for VcGallery
476
- * TODO: Update the path '${t}s/\${item.value?.id}' to match your entity structure
502
+ * TODO: Update the path '${e}s/\${item.value?.id}' to match your entity structure
477
503
  */
478
504
  const assetsHandler = {
479
505
  loading: assetsLoading,
480
506
  async upload(files: FileList, startingSortOrder?: number) {
481
507
  // TODO: Update path to match your entity (e.g., 'products/\${item.value?.id}')
482
- const uploaded = await upload(files, \`${t}s/\${item.value?.id}\`, startingSortOrder);
508
+ const uploaded = await upload(files, \`${e}s/\${item.value?.id}\`, startingSortOrder);
483
509
  // TODO: If using typed Image class, map: uploaded.map((x) => new Image(x))
484
510
  item.value.images = [...(item.value?.images ?? []), ...uploaded];
485
511
  },
@@ -514,30 +540,30 @@ const onGalleryItemEdit = (asset: ICommonAsset) => {
514
540
  };
515
541
  `;
516
542
  }
517
- function Pe(t, e) {
518
- const n = v(t.name).toUpperCase();
543
+ function Pe(e, t) {
544
+ const n = v(e.name).toUpperCase();
519
545
  return ` <VcField
520
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
521
- :model-value="item.${t.name}"
546
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
547
+ :model-value="item.${e.name}"
522
548
  orientation="horizontal"
523
549
  :aspect-ratio="[1, 2]"
524
550
  type="text"
525
551
  />`;
526
552
  }
527
- function Oe(t, e) {
528
- const n = v(t.name).toUpperCase(), a = t.required ? 'rules="required"' : "";
553
+ function Te(e, t) {
554
+ const n = v(e.name).toUpperCase(), a = e.required ? 'rules="required"' : "";
529
555
  return ` <Field
530
556
  v-slot="{ field, errorMessage, handleChange, errors }"
531
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
532
- :model-value="item.${t.name}"
533
- name="${t.name}"
557
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
558
+ :model-value="item.${e.name}"
559
+ name="${e.name}"
534
560
  ${a}
535
561
  >
536
562
  <VcInputCurrency
537
563
  v-bind="field"
538
- v-model="item.${t.name}"
539
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
540
- ${t.required ? "required" : ""}
564
+ v-model="item.${e.name}"
565
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
566
+ ${e.required ? "required" : ""}
541
567
  clearable
542
568
  :error="!!errors.length"
543
569
  :error-message="errorMessage"
@@ -545,116 +571,116 @@ function Oe(t, e) {
545
571
  />
546
572
  </Field>`;
547
573
  }
548
- function Te(t, e) {
549
- const n = v(t.name).toUpperCase(), a = t.required ? 'rules="required"' : "", s = t.options?.map((c) => {
550
- const l = ae(c);
574
+ function Fe(e, t) {
575
+ const n = v(e.name).toUpperCase(), a = e.required ? 'rules="required"' : "", i = e.options?.map((r) => {
576
+ const s = te(r);
551
577
  return ` <VcRadioButton
552
- :model-value="item.${t.name}"
553
- value="${l}"
554
- :label="'${l}'"
578
+ :model-value="item.${e.name}"
579
+ value="${s}"
580
+ :label="'${s}'"
555
581
  @update:model-value="handleChange"
556
582
  />`;
557
583
  }).join(`
558
584
  `) || "";
559
585
  return ` <Field
560
586
  v-slot="{ field, errorMessage, handleChange, errors }"
561
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
562
- :model-value="item.${t.name}"
563
- name="${t.name}"
587
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
588
+ :model-value="item.${e.name}"
589
+ name="${e.name}"
564
590
  ${a}
565
591
  >
566
592
  <div class="tw-space-y-2">
567
- ${s}
593
+ ${i}
568
594
  </div>
569
595
  <div v-if="errors.length" class="tw-text-red-500 tw-text-sm">{{ errorMessage }}</div>
570
596
  </Field>`;
571
597
  }
572
- function Fe(t, e) {
573
- const n = v(t.name).toUpperCase();
598
+ function De(e, t) {
599
+ const n = v(e.name).toUpperCase();
574
600
  return ` <VcCheckbox
575
- v-model="item.${t.name}"
576
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
601
+ v-model="item.${e.name}"
602
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
577
603
  />`;
578
604
  }
579
- function De(t, e) {
580
- const n = v(t.name).toUpperCase(), a = t.required ? 'rules="required"' : "";
605
+ function Me(e, t) {
606
+ const n = v(e.name).toUpperCase(), a = e.required ? 'rules="required"' : "";
581
607
  return ` <!-- TODO: Configure VcMultivalue dictionary and placeholder -->
582
608
  <Field
583
609
  v-slot="{ errorMessage, handleChange, errors }"
584
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
585
- :model-value="item.${t.name}"
586
- name="${t.name}"
610
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
611
+ :model-value="item.${e.name}"
612
+ name="${e.name}"
587
613
  ${a}
588
614
  >
589
615
  <VcMultivalue
590
- v-model="item.${t.name}"
591
- :label="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}')"
592
- :placeholder="$t('${e}.PAGES.DETAILS.FORM.INFO.${n}_PLACEHOLDER')"
593
- ${t.required ? "required" : ""}
616
+ v-model="item.${e.name}"
617
+ :label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
618
+ :placeholder="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}_PLACEHOLDER')"
619
+ ${e.required ? "required" : ""}
594
620
  :error="!!errors.length"
595
621
  :error-message="errorMessage"
596
622
  @update:model-value="handleChange"
597
623
  />
598
624
  </Field>`;
599
625
  }
600
- function Me(t) {
601
- return t.some(
602
- (e) => e.type === "gallery"
626
+ function Le(e) {
627
+ return e.some(
628
+ (t) => t.type === "gallery"
603
629
  /* Gallery */
604
630
  );
605
631
  }
606
- function R(t, e) {
607
- return t.length === 0 ? oe(e) : t.map((n) => {
632
+ function k(e, t) {
633
+ return e.length === 0 ? ne(t) : e.map((n) => {
608
634
  switch (n.type) {
609
635
  case "text":
610
636
  case "number":
611
637
  case "date":
612
- return q(n, e);
638
+ return q(n, t);
613
639
  case "textarea":
614
- return ve(n, e);
640
+ return Ie(n, t);
615
641
  case "select":
616
- return Ie(n, e);
642
+ return Ae(n, t);
617
643
  case "editor":
618
- return Ce(n, e);
644
+ return Ne(n, t);
619
645
  case "switch":
620
- return xe(n, e);
646
+ return xe(n, t);
621
647
  case "gallery":
622
- return Ae(n, e);
648
+ return Ce(n, t);
623
649
  case "data-field":
624
- return Pe(n, e);
650
+ return Pe(n, t);
625
651
  case "currency":
626
- return Oe(n, e);
652
+ return Te(n, t);
627
653
  case "radio":
628
- return Te(n, e);
654
+ return Fe(n, t);
629
655
  case "checkbox":
630
- return Fe(n, e);
656
+ return De(n, t);
631
657
  case "multivalue":
632
- return De(n, e);
658
+ return Me(n, t);
633
659
  case "image":
634
660
  return q({
635
661
  ...n,
636
662
  type: "text"
637
663
  /* Text */
638
- }, e);
664
+ }, t);
639
665
  default:
640
- return q(n, e);
666
+ return q(n, t);
641
667
  }
642
668
  }).join(`
643
669
 
644
670
  `);
645
671
  }
646
- function k(t) {
647
- const e = {};
648
- for (const n of t) {
672
+ function j(e) {
673
+ const t = {};
674
+ for (const n of e) {
649
675
  const a = v(n.name).toUpperCase();
650
- e[a] = n.label || T(n.name);
676
+ t[a] = n.label || T(n.name);
651
677
  }
652
- return e;
678
+ return t;
653
679
  }
654
- function oe(t) {
680
+ function ne(e) {
655
681
  return ` <Field
656
682
  v-slot="{ field, errorMessage, handleChange, errors }"
657
- :label="$t('${t}.PAGES.DETAILS.FORM.INFO.NAME')"
683
+ :label="$t('${e}.PAGES.DETAILS.FORM.INFO.NAME')"
658
684
  :model-value="item.name"
659
685
  name="name"
660
686
  rules="required"
@@ -662,8 +688,8 @@ function oe(t) {
662
688
  <VcInput
663
689
  v-bind="field"
664
690
  v-model="item.name"
665
- :label="$t('${t}.PAGES.DETAILS.FORM.INFO.NAME')"
666
- :placeholder="$t('${t}.PAGES.DETAILS.FORM.INFO.NAME_PLACEHOLDER')"
691
+ :label="$t('${e}.PAGES.DETAILS.FORM.INFO.NAME')"
692
+ :placeholder="$t('${e}.PAGES.DETAILS.FORM.INFO.NAME_PLACEHOLDER')"
667
693
  required
668
694
  clearable
669
695
  :error="!!errors.length"
@@ -673,122 +699,180 @@ function oe(t) {
673
699
  </Field>
674
700
 
675
701
  <VcField
676
- :label="$t('${t}.PAGES.DETAILS.FORM.INFO.CREATED_DATE')"
702
+ :label="$t('${e}.PAGES.DETAILS.FORM.INFO.CREATED_DATE')"
677
703
  :model-value="createdDate"
678
704
  orientation="horizontal"
679
705
  :aspect-ratio="[1, 2]"
680
706
  type="text"
681
707
  />`;
682
708
  }
683
- async function Le(t, e, n) {
684
- const a = m.join(t, "src", "main.ts");
685
- if (!r.existsSync(a))
709
+ async function Re(e, t, n) {
710
+ const a = m.join(e, "src", "main.ts");
711
+ if (!l.existsSync(a))
686
712
  return console.log(o.yellow(`⚠️ main.ts not found at ${a}`)), console.log(o.yellow(" Please register the module manually.")), !1;
687
713
  try {
688
- let s = r.readFileSync(a, "utf-8");
689
- const c = `import ${n}Module from "./modules/${e}";`, l = `.use(${n}Module, { router })`;
690
- if (s.includes(c) || s.includes(`from "./modules/${e}"`))
691
- return console.log(o.yellow(` Module ${e} is already registered in main.ts`)), !0;
692
- const d = /^import\s+.+\s+from\s+['"]\.\/.+['"];?\s*$/gm, w = s.match(d);
693
- if (w && w.length > 0) {
694
- const p = w[w.length - 1], i = s.lastIndexOf(p);
695
- s = s.slice(0, i + p.length) + `
696
- ${c}` + s.slice(i + p.length);
714
+ let i = l.readFileSync(a, "utf-8");
715
+ const r = `import ${n}Module from "./modules/${t}";`;
716
+ if (i.includes(r) || i.includes(`from "./modules/${t}"`))
717
+ return console.log(o.yellow(` Module ${t} is already registered in main.ts`)), !0;
718
+ const s = /^import\s+.+\s+from\s+['"]\.\/.+['"];?\s*$/gm, d = i.match(s);
719
+ if (d && d.length > 0) {
720
+ const c = d[d.length - 1], g = i.lastIndexOf(c);
721
+ i = i.slice(0, g + c.length) + `
722
+ ${r}` + i.slice(g + c.length);
697
723
  } else {
698
- const p = s.search(/^import/m);
699
- p !== -1 && (s = s.slice(0, p) + `${c}
700
- ` + s.slice(p));
724
+ const c = i.search(/^import/m);
725
+ c !== -1 && (i = i.slice(0, c) + `${r}
726
+ ` + i.slice(c));
701
727
  }
702
- const u = /(app\.use|\.use)\(router\)/, g = s.match(u);
703
- if (g) {
704
- const p = s.indexOf(g[0]);
705
- let i = p;
706
- for (; i > 0 && s[i - 1] !== `
728
+ const h = i.match(/const\s+app\s*=\s*createApp\([^)]*\)([;\s]*\n)/);
729
+ let p = !1;
730
+ if (h) {
731
+ const c = i.slice(i.indexOf(h[0]) + h[0].length, i.indexOf(h[0]) + h[0].length + 50);
732
+ p = /^\s*\.use\(/.test(c);
733
+ }
734
+ const u = /(app\.use|\.use)\(router\)/, f = i.match(u);
735
+ if (f) {
736
+ const c = i.indexOf(f[0]);
737
+ let g = c;
738
+ for (; g > 0 && i[g - 1] !== `
707
739
  `; )
708
- i--;
709
- const f = s.slice(i, p).match(/^\s*/)?.[0] || " ";
710
- s = s.slice(0, i) + `${f}${l}
711
- ` + s.slice(i);
740
+ g--;
741
+ const y = i.slice(g, c).match(/^\s*/)?.[0] || " ";
742
+ let b;
743
+ p ? b = `${y}.use(${n}Module, { router })` : b = `${y}app.use(${n}Module, { router });`, i = i.slice(0, g) + `${b}
744
+ ` + i.slice(g);
712
745
  } else {
713
- const p = /(app\.use|\.use)\([^)]+\)/g, i = [...s.matchAll(p)];
714
- if (i.length > 0) {
715
- const f = i[i.length - 1], y = f.index + f[0].length;
716
- s = s.slice(0, y) + `
717
- ${l}` + s.slice(y);
746
+ const c = /(app\.use|\.use)\([^)]+\)/g, g = [...i.matchAll(c)];
747
+ if (g.length > 0) {
748
+ const y = g[g.length - 1], b = y.index + y[0].length;
749
+ let E;
750
+ p ? E = `
751
+ .use(${n}Module, { router })` : E = `
752
+ app.use(${n}Module, { router });`, i = i.slice(0, b) + E + i.slice(b);
718
753
  }
719
754
  }
720
- return r.writeFileSync(a, s, "utf-8"), console.log(o.green("✓ Registered module in main.ts")), !0;
721
- } catch (s) {
722
- return console.log(o.yellow(`⚠️ Failed to auto-register module: ${s.message}`)), console.log(o.yellow(" Please register manually.")), !1;
755
+ return l.writeFileSync(a, i, "utf-8"), console.log(o.green("✓ Registered module in main.ts")), !0;
756
+ } catch (i) {
757
+ return console.log(o.yellow(`⚠️ Failed to auto-register module: ${i.message}`)), console.log(o.yellow(" Please register manually.")), !1;
723
758
  }
724
759
  }
725
- async function K(t, e) {
726
- const n = m.join(t, "pages"), a = m.join(n, "index.ts");
760
+ async function K(e, t) {
761
+ const n = m.join(e, "pages"), a = m.join(n, "index.ts");
727
762
  try {
728
- let s = "";
729
- r.existsSync(a) && (s = r.readFileSync(a, "utf-8"));
730
- for (const c of e) {
731
- const l = `export { default as ${c.exportName} } from "./${c.fileName}.vue";`;
732
- !s.includes(l) && !s.includes(`from "./${c.fileName}.vue"`) && (s += l + `
763
+ let i = "";
764
+ l.existsSync(a) && (i = l.readFileSync(a, "utf-8"));
765
+ for (const r of t) {
766
+ const s = `export { default as ${r.exportName} } from "./${r.fileName}.vue";`;
767
+ !i.includes(s) && !i.includes(`from "./${r.fileName}.vue"`) && (i += s + `
733
768
  `);
734
769
  }
735
- return r.writeFileSync(a, s, "utf-8"), await P(a), console.log(o.green("✓ Updated pages/index.ts")), !0;
736
- } catch (s) {
737
- return console.log(o.yellow(`⚠️ Failed to update pages/index.ts: ${s.message}`)), !1;
770
+ return l.writeFileSync(a, i, "utf-8"), await P(a), console.log(o.green("✓ Updated pages/index.ts")), !0;
771
+ } catch (i) {
772
+ return console.log(o.yellow(`⚠️ Failed to update pages/index.ts: ${i.message}`)), !1;
738
773
  }
739
774
  }
740
- class O extends Error {
775
+ class I extends Error {
741
776
  exitCode;
742
- constructor(e, n = 1) {
743
- super(e), this.name = "CLIError", this.exitCode = n;
777
+ constructor(t, n = 1) {
778
+ super(t), this.name = "CLIError", this.exitCode = n;
744
779
  }
745
780
  }
746
- class B extends O {
781
+ class V extends I {
747
782
  issues;
748
- constructor(e) {
749
- super("Validation failed", 1), this.name = "ValidationError", this.issues = e;
783
+ constructor(t) {
784
+ super("Validation failed", 1), this.name = "ValidationError", this.issues = t;
750
785
  }
751
786
  }
752
- class E extends O {
787
+ class $ extends I {
753
788
  constructor() {
754
789
  super("Operation cancelled by user", 0), this.name = "UserCancelledError";
755
790
  }
756
791
  }
757
- function se(t) {
758
- if (!r.existsSync(t))
792
+ function L(e) {
793
+ const t = m.dirname(ge(e)), n = [
794
+ m.resolve(t, "..", "..", "templates"),
795
+ // From src/commands, src/workflows, dist/commands, dist/workflows
796
+ m.resolve(t, "..", "templates"),
797
+ // From src/, dist/ (fallback)
798
+ m.resolve(t, "templates")
799
+ // From root (fallback)
800
+ ];
801
+ for (const a of n)
802
+ if (l.existsSync(a))
803
+ return a;
804
+ throw new Error(
805
+ `Templates directory not found. Searched in:
806
+ ${n.map((a) => ` - ${a}`).join(`
807
+ `)}`
808
+ );
809
+ }
810
+ function oe(e) {
811
+ if (!l.existsSync(e))
759
812
  return;
760
- const e = m.relative(_(), t) || t;
761
- throw new O(`File already exists: ${e}. Remove it or rename before regenerating.`);
813
+ const t = m.relative(G(), e) || e;
814
+ throw new I(`File already exists: ${t}. Remove it or rename before regenerating.`);
762
815
  }
763
- async function le(t = {}) {
816
+ async function ie(e = {}) {
764
817
  console.log(`
765
818
  ${o.bold(o.green("@vc-shell/create-vc-app Generator"))}
766
819
  `);
767
- const e = t.path || _(), n = m.join(e, "package.json");
768
- if (!r.existsSync(n))
769
- throw new O("❌ No package.json found. Are you in a project directory?");
820
+ const t = e.path || G(), n = m.join(t, "package.json");
821
+ if (!l.existsSync(n))
822
+ throw new I("❌ No package.json found. Are you in a project directory?");
770
823
  try {
771
- if (t.module && t.type && t.name) {
824
+ const a = e.module || e.type || e.name, i = e.module && e.type && e.name;
825
+ if (a && !i) {
826
+ const s = [];
827
+ throw e.module || s.push("--module"), e.type || s.push("--type"), e.name || s.push("--name"), new I(
828
+ `❌ Non-interactive mode requires all flags: --module, --type, and --name.
829
+ Missing: ${s.join(", ")}
830
+
831
+ Run without flags for interactive mode, or provide all required flags.`
832
+ );
833
+ }
834
+ if (i) {
772
835
  console.log(o.cyan(`📝 Running in non-interactive mode
773
- `)), await Re(e, {
774
- moduleName: N(t.module),
775
- // Normalize to kebab-case
776
- bladeType: t.type,
777
- entityName: t.name,
778
- isWorkspace: t.isWorkspace ?? !1,
779
- includeComposable: t.composable ?? !0,
780
- includeLocales: t.locales ?? !0,
781
- formFields: t.formFields,
782
- skipFormEditor: t.skipFormEditor
836
+ `)), await ke(t, {
837
+ moduleName: C(e.module),
838
+ // Normalize to kebab-case (! is safe due to hasAllBladeFlags check)
839
+ bladeType: e.type,
840
+ entityName: e.name,
841
+ isWorkspace: e.isWorkspace ?? !1,
842
+ includeComposable: e.composable ?? !0,
843
+ includeLocales: e.locales ?? !0,
844
+ formFields: e.formFields,
845
+ skipFormEditor: e.skipFormEditor
783
846
  });
784
847
  return;
785
848
  }
786
- if (t.widget) {
787
- await Q(e);
849
+ if (e.widget) {
850
+ const s = e.widgetModule || e.widgetBlade || e.widgetName || e.widgetEntity || e.widgetIcon, d = e.widgetModule && e.widgetBlade && e.widgetName && e.widgetEntity;
851
+ if (s && !d) {
852
+ const h = [];
853
+ throw e.widgetModule || h.push("--widget-module"), e.widgetBlade || h.push("--widget-blade"), e.widgetName || h.push("--widget-name"), e.widgetEntity || h.push("--widget-entity"), new I(
854
+ `❌ Non-interactive widget mode requires all flags: --widget-module, --widget-blade, --widget-name, and --widget-entity.
855
+ Missing: ${h.join(", ")}
856
+
857
+ Run with only --widget flag for interactive mode, or provide all required flags.`
858
+ );
859
+ }
860
+ if (d) {
861
+ console.log(o.cyan(`📝 Running widget generation in non-interactive mode
862
+ `)), await Be(t, {
863
+ moduleName: C(e.widgetModule),
864
+ bladeName: e.widgetBlade.replace(".vue", ""),
865
+ widgetName: e.widgetName,
866
+ entityName: e.widgetEntity,
867
+ icon: e.widgetIcon || "material-list"
868
+ });
869
+ return;
870
+ }
871
+ await Q(t);
788
872
  return;
789
873
  }
790
- let a;
791
- t._skipActionPrompt ? a = "module" : a = (await x(
874
+ let r;
875
+ e._skipActionPrompt ? r = "module" : r = (await x(
792
876
  {
793
877
  type: "select",
794
878
  name: "action",
@@ -801,79 +885,79 @@ ${o.bold(o.green("@vc-shell/create-vc-app Generator"))}
801
885
  },
802
886
  {
803
887
  onCancel: () => {
804
- throw new E();
888
+ throw new $();
805
889
  }
806
890
  }
807
- )).action, a === "module" ? await ke(e) : a === "blade" ? await je(e) : a === "widget" && await Q(e);
891
+ )).action, r === "module" ? await je(t) : r === "blade" ? await _e(t) : r === "widget" && await Q(t);
808
892
  } catch (a) {
809
- if (a instanceof E)
810
- throw new E();
811
- if (a instanceof O)
893
+ if (a instanceof $)
894
+ throw new $();
895
+ if (a instanceof I)
812
896
  throw a;
813
- const s = a instanceof Error ? a.message : String(a), c = a instanceof Error && a.stack ? `
897
+ const i = a instanceof Error ? a.message : String(a), r = a instanceof Error && a.stack ? `
814
898
  ${a.stack}` : "";
815
- throw new O(`
816
- ❌ Generation failed: ${s}${c ? `
817
- ${c}` : ""}`);
899
+ throw new I(`
900
+ ❌ Generation failed: ${i}${r ? `
901
+ ${r}` : ""}`);
818
902
  }
819
903
  }
820
- async function Re(t, e) {
821
- const n = m.join(t, "src", "modules"), a = m.join(n, e.moduleName);
822
- if (!r.existsSync(a)) {
823
- console.log(o.cyan(`📦 Module "${e.moduleName}" not found. Creating new module...
904
+ async function ke(e, t) {
905
+ const n = m.join(e, "src", "modules"), a = m.join(n, t.moduleName);
906
+ if (!l.existsSync(a)) {
907
+ console.log(o.cyan(`📦 Module "${t.moduleName}" not found. Creating new module...
824
908
  `));
825
909
  const y = {
826
- moduleName: e.moduleName,
827
- entitySingular: e.moduleName,
910
+ moduleName: t.moduleName,
911
+ entitySingular: t.moduleName,
828
912
  createBothBlades: !1,
829
- createGridBlade: e.bladeType === "grid",
830
- createDetailsBlade: e.bladeType === "details",
831
- gridIsWorkspace: e.isWorkspace && e.bladeType === "grid",
832
- detailsIsWorkspace: e.isWorkspace && e.bladeType === "details",
833
- includeComposables: e.includeComposable,
834
- includeLocales: e.includeLocales,
913
+ createGridBlade: t.bladeType === "grid",
914
+ createDetailsBlade: t.bladeType === "details",
915
+ gridIsWorkspace: t.isWorkspace && t.bladeType === "grid",
916
+ detailsIsWorkspace: t.isWorkspace && t.bladeType === "details",
917
+ includeComposables: t.includeComposable,
918
+ includeLocales: t.includeLocales,
835
919
  customizeForm: !1
836
920
  };
837
- await re(t, y, e.formFields, e.skipFormEditor), console.log(o.green(`✅ Module "${e.moduleName}" with ${e.bladeType} blade created successfully
921
+ await se(e, y, t.formFields, t.skipFormEditor), console.log(o.green(`✅ Module "${t.moduleName}" with ${t.bladeType} blade created successfully
838
922
  `));
839
923
  return;
840
924
  }
841
- const s = W(e.entityName, e.moduleName), c = z(s), l = V(), d = [];
842
- let w = "", u = {}, g = [];
843
- if (e.bladeType === "details" && e.formFields)
925
+ const i = W(t.entityName, t.moduleName), r = z(i), s = L(import.meta.url), d = [];
926
+ let h = "", p = {}, u = [];
927
+ if (t.bladeType === "details" && t.formFields)
844
928
  try {
845
- g = JSON.parse(e.formFields), g.length > 0 && (w = R(g, s.moduleNameUpperSnake), u = k(g));
929
+ u = JSON.parse(t.formFields), u.length > 0 && (h = k(u, i.moduleNameUpperSnake), p = j(u));
846
930
  } catch (y) {
847
931
  throw console.error(o.red("❌ Invalid form-fields JSON")), y;
848
932
  }
849
- const p = await j(
850
- l,
933
+ const f = await _(
934
+ s,
851
935
  a,
852
- e.bladeType,
853
- c,
854
- e.isWorkspace,
855
- w,
856
- g
936
+ t.bladeType,
937
+ r,
938
+ t.isWorkspace,
939
+ h,
940
+ u
857
941
  );
858
- if (d.push(p), e.includeComposable) {
859
- const y = await G(
860
- l,
861
- a,
862
- e.bladeType,
942
+ if (d.push(f), t.includeComposable) {
943
+ const y = await B(
863
944
  s,
864
- c
945
+ a,
946
+ t.bladeType,
947
+ i,
948
+ r
865
949
  );
866
950
  d.push(y);
867
- const b = m.join(a, "composables", "index.ts"), h = `export * from "./${e.bladeType === "grid" ? `use${s.entitySingularPascal}List` : `use${s.entitySingularPascal}Details`}";
951
+ const b = m.join(a, "composables", "index.ts"), w = `export * from "./${t.bladeType === "grid" ? `use${i.entitySingularPascal}List` : `use${i.entitySingularPascal}Details`}";
868
952
  `;
869
- r.existsSync(b) ? r.readFileSync(b, "utf-8").includes(h) || r.appendFileSync(b, h) : r.writeFileSync(b, h);
953
+ l.existsSync(b) ? l.readFileSync(b, "utf-8").includes(w) || l.appendFileSync(b, w) : l.writeFileSync(b, w);
870
954
  }
871
- const i = e.bladeType === "grid" ? `${s.entitySingularPascal}List` : `${s.entitySingularPascal}Details`, f = e.bladeType === "grid" ? c["{{entity-name-plural}}"] : `${c["{{entity-name}}"]}-details`;
872
- if (await K(a, [{ exportName: i, fileName: f }]), e.includeLocales && Object.keys(u).length > 0) {
955
+ const c = t.bladeType === "grid" ? `${i.entitySingularPascal}List` : `${i.entitySingularPascal}Details`, g = t.bladeType === "grid" ? r["{{entity-name-list}}"] : `${r["{{entity-name}}"]}-details`;
956
+ if (await K(a, [{ exportName: c, fileName: g }]), t.includeLocales && Object.keys(p).length > 0) {
873
957
  const y = m.join(a, "locales", "en.json");
874
- if (r.existsSync(y)) {
875
- const b = JSON.parse(r.readFileSync(y, "utf-8"));
876
- b.PAGES || (b.PAGES = {}), b.PAGES.DETAILS || (b.PAGES.DETAILS = {}), b.PAGES.DETAILS.FORM || (b.PAGES.DETAILS.FORM = {}), b.PAGES.DETAILS.FORM.INFO || (b.PAGES.DETAILS.FORM.INFO = {}), Object.assign(b.PAGES.DETAILS.FORM.INFO, u), r.writeFileSync(y, JSON.stringify(b, null, 2), "utf-8"), d.push(y);
958
+ if (l.existsSync(y)) {
959
+ const b = JSON.parse(l.readFileSync(y, "utf-8"));
960
+ b.PAGES || (b.PAGES = {}), b.PAGES.DETAILS || (b.PAGES.DETAILS = {}), b.PAGES.DETAILS.FORM || (b.PAGES.DETAILS.FORM = {}), b.PAGES.DETAILS.FORM.INFO || (b.PAGES.DETAILS.FORM.INFO = {}), Object.assign(b.PAGES.DETAILS.FORM.INFO, p), l.writeFileSync(y, JSON.stringify(b, null, 2), "utf-8"), d.push(y);
877
961
  }
878
962
  }
879
963
  console.log(o.cyan(`
@@ -885,13 +969,13 @@ async function Re(t, e) {
885
969
  ✅ Blade generated successfully!
886
970
  `));
887
971
  }
888
- async function ke(t, e, n, a) {
972
+ async function je(e, t, n, a) {
889
973
  console.log(o.cyan(`
890
974
  📦 Creating new module
891
975
  `));
892
- let s;
976
+ let i;
893
977
  {
894
- let l = {
978
+ let s = {
895
979
  ...await x(
896
980
  [
897
981
  {
@@ -899,7 +983,7 @@ async function ke(t, e, n, a) {
899
983
  name: "moduleName",
900
984
  message: "Module name (e.g., products, orders):",
901
985
  validate: (d) => d.length > 0 ? !0 : "Module name is required",
902
- format: (d) => N(d)
986
+ format: (d) => C(d)
903
987
  // Normalize to kebab-case
904
988
  },
905
989
  {
@@ -917,7 +1001,7 @@ async function ke(t, e, n, a) {
917
1001
  ],
918
1002
  {
919
1003
  onCancel: () => {
920
- throw new E();
1004
+ throw new $();
921
1005
  }
922
1006
  }
923
1007
  ),
@@ -929,7 +1013,7 @@ async function ke(t, e, n, a) {
929
1013
  includeLocales: !0,
930
1014
  customizeForm: !1
931
1015
  };
932
- if (l.createBothBlades) {
1016
+ if (s.createBothBlades) {
933
1017
  const d = await x(
934
1018
  {
935
1019
  type: "select",
@@ -943,11 +1027,11 @@ async function ke(t, e, n, a) {
943
1027
  },
944
1028
  {
945
1029
  onCancel: () => {
946
- throw new E();
1030
+ throw new $();
947
1031
  }
948
1032
  }
949
1033
  );
950
- l.createGridBlade = !0, l.createDetailsBlade = !0, l.gridIsWorkspace = d.workspace === "grid", l.detailsIsWorkspace = d.workspace === "details";
1034
+ s.createGridBlade = !0, s.createDetailsBlade = !0, s.gridIsWorkspace = d.workspace === "grid", s.detailsIsWorkspace = d.workspace === "details";
951
1035
  } else {
952
1036
  const d = await x(
953
1037
  [
@@ -969,13 +1053,13 @@ async function ke(t, e, n, a) {
969
1053
  ],
970
1054
  {
971
1055
  onCancel: () => {
972
- throw new E();
1056
+ throw new $();
973
1057
  }
974
1058
  }
975
1059
  );
976
- l.createGridBlade = d.bladeType === "grid", l.createDetailsBlade = d.bladeType === "details", l.gridIsWorkspace = l.createGridBlade && d.isWorkspace, l.detailsIsWorkspace = l.createDetailsBlade && d.isWorkspace;
1060
+ s.createGridBlade = d.bladeType === "grid", s.createDetailsBlade = d.bladeType === "details", s.gridIsWorkspace = s.createGridBlade && d.isWorkspace, s.detailsIsWorkspace = s.createDetailsBlade && d.isWorkspace;
977
1061
  }
978
- if (l.createDetailsBlade) {
1062
+ if (s.createDetailsBlade) {
979
1063
  const d = await x(
980
1064
  {
981
1065
  type: "confirm",
@@ -985,137 +1069,137 @@ async function ke(t, e, n, a) {
985
1069
  },
986
1070
  {
987
1071
  onCancel: () => {
988
- throw new E();
1072
+ throw new $();
989
1073
  }
990
1074
  }
991
1075
  );
992
- l.customizeForm = d.customizeForm;
1076
+ s.customizeForm = d.customizeForm;
993
1077
  }
994
- s = l;
1078
+ i = s;
995
1079
  }
996
- await re(t, s, n, a);
1080
+ await se(e, i, n, a);
997
1081
  }
998
- async function re(t, e, n, a) {
1082
+ async function se(e, t, n, a) {
999
1083
  try {
1000
- const s = W(e.entitySingular, e.moduleName), c = z(s), l = m.join(t, "src", "modules", e.moduleName);
1001
- if (r.existsSync(l) && !We(l))
1002
- throw new O(
1003
- `Module "${e.moduleName}" already exists and is not empty. Use the blade generator to extend it instead of recreating.`
1084
+ const i = W(t.entitySingular, t.moduleName), r = z(i), s = m.join(e, "src", "modules", t.moduleName);
1085
+ if (l.existsSync(s) && !We(s))
1086
+ throw new I(
1087
+ `Module "${t.moduleName}" already exists and is not empty. Use the blade generator to extend it instead of recreating.`
1004
1088
  );
1005
1089
  console.log(o.cyan(`
1006
1090
  📁 Creating module structure...
1007
1091
  `));
1008
1092
  const d = [
1009
- l,
1010
- m.join(l, "pages"),
1011
- m.join(l, "composables"),
1012
- m.join(l, "locales"),
1013
- m.join(l, "components"),
1014
- m.join(l, "components", "widgets")
1093
+ s,
1094
+ m.join(s, "pages"),
1095
+ m.join(s, "composables"),
1096
+ m.join(s, "locales"),
1097
+ m.join(s, "components"),
1098
+ m.join(s, "components", "widgets")
1015
1099
  ];
1016
- for (const h of d)
1017
- if (!r.existsSync(h))
1100
+ for (const w of d)
1101
+ if (!l.existsSync(w))
1018
1102
  try {
1019
- r.mkdirSync(h, { recursive: !0 }), console.log(o.green(`✓ Created directory: ${m.relative(t, h)}`));
1020
- } catch ($) {
1021
- throw new Error(`Failed to create directory ${h}: ${$.message}`);
1103
+ l.mkdirSync(w, { recursive: !0 }), console.log(o.green(`✓ Created directory: ${m.relative(e, w)}`));
1104
+ } catch (S) {
1105
+ throw new Error(`Failed to create directory ${w}: ${S.message}`);
1022
1106
  }
1023
- const w = V(), u = [];
1024
- let g = "", p = {};
1025
- if (e.createGridBlade) {
1026
- const h = await j(w, l, "grid", c, e.gridIsWorkspace);
1027
- u.push(h);
1107
+ const h = L(import.meta.url), p = [];
1108
+ let u = "", f = {};
1109
+ if (t.createGridBlade) {
1110
+ const w = await _(h, s, "grid", r, t.gridIsWorkspace);
1111
+ p.push(w);
1028
1112
  }
1029
- let i = [];
1030
- if (e.createDetailsBlade) {
1113
+ let c = [];
1114
+ if (t.createDetailsBlade) {
1031
1115
  if (n)
1032
1116
  try {
1033
- i = JSON.parse(n), i.length > 0 && (g = R(i, s.moduleNameUpperSnake), p = k(i));
1034
- } catch ($) {
1035
- throw console.error(o.red("❌ Invalid form-fields JSON")), $;
1117
+ c = JSON.parse(n), c.length > 0 && (u = k(c, i.moduleNameUpperSnake), f = j(c));
1118
+ } catch (S) {
1119
+ throw console.error(o.red("❌ Invalid form-fields JSON")), S;
1036
1120
  }
1037
- else e.customizeForm && !a && (i = await ne(), i.length > 0 && (g = R(i, s.moduleNameUpperSnake), p = k(i)));
1038
- const h = await j(
1039
- w,
1040
- l,
1121
+ else t.customizeForm && !a && (c = await ae(), c.length > 0 && (u = k(c, i.moduleNameUpperSnake), f = j(c)));
1122
+ const w = await _(
1123
+ h,
1124
+ s,
1041
1125
  "details",
1042
- c,
1043
- e.detailsIsWorkspace,
1044
- g,
1045
- i
1126
+ r,
1127
+ t.detailsIsWorkspace,
1128
+ u,
1129
+ c
1046
1130
  );
1047
- u.push(h);
1131
+ p.push(w);
1048
1132
  }
1049
- if (e.includeComposables) {
1050
- if (e.createGridBlade) {
1051
- const $ = await G(w, l, "grid", s, c);
1052
- u.push($);
1133
+ if (t.includeComposables) {
1134
+ if (t.createGridBlade) {
1135
+ const S = await B(h, s, "grid", i, r);
1136
+ p.push(S);
1053
1137
  }
1054
- if (e.createDetailsBlade) {
1055
- const $ = await G(
1056
- w,
1057
- l,
1058
- "details",
1138
+ if (t.createDetailsBlade) {
1139
+ const S = await B(
1140
+ h,
1059
1141
  s,
1060
- c
1142
+ "details",
1143
+ i,
1144
+ r
1061
1145
  );
1062
- u.push($);
1146
+ p.push(S);
1063
1147
  }
1064
- const h = await Be(l, e, s);
1065
- u.push(h);
1148
+ const w = await Ve(s, t, i);
1149
+ p.push(w);
1066
1150
  }
1067
- if (e.includeLocales) {
1068
- const h = await Ve(l, s, c, p);
1069
- u.push(h);
1070
- const $ = m.join(l, "locales", "index.ts");
1071
- r.writeFileSync($, `import en from "./en.json";
1151
+ if (t.includeLocales) {
1152
+ const w = await qe(s, i, r, f);
1153
+ p.push(w);
1154
+ const S = m.join(s, "locales", "index.ts");
1155
+ l.writeFileSync(S, `import en from "./en.json";
1072
1156
  export { en };
1073
- `), u.push($);
1157
+ `), p.push(S);
1074
1158
  }
1075
- const f = m.join(l, "index.ts");
1076
- r.writeFileSync(f, `import * as pages from "./pages";
1159
+ const g = m.join(s, "index.ts");
1160
+ l.writeFileSync(g, `import * as pages from "./pages";
1077
1161
  import * as locales from "./locales";
1078
1162
  import { createAppModule } from "@vc-shell/framework";
1079
1163
 
1080
1164
  export default createAppModule(pages, locales);
1081
1165
 
1082
1166
  export * from "./composables";
1083
- `), u.push(f);
1167
+ `), p.push(g);
1084
1168
  const b = [];
1085
- e.createGridBlade && b.push({
1086
- exportName: `${s.entitySingularPascal}List`,
1087
- fileName: s.entityPluralKebab
1088
- }), e.createDetailsBlade && b.push({
1089
- exportName: `${s.entitySingularPascal}Details`,
1090
- fileName: `${s.entitySingularKebab}-details`
1091
- }), b.length > 0 && await K(l, b), console.log(o.cyan(`
1169
+ t.createGridBlade && b.push({
1170
+ exportName: `${i.entitySingularPascal}List`,
1171
+ fileName: i.entityListKebab
1172
+ }), t.createDetailsBlade && b.push({
1173
+ exportName: `${i.entitySingularPascal}Details`,
1174
+ fileName: `${i.entitySingularKebab}-details`
1175
+ }), b.length > 0 && await K(s, b), console.log(o.cyan(`
1092
1176
  ✨ Formatting files with Prettier...
1093
1177
  `));
1094
- for (const h of u)
1095
- await P(h);
1178
+ for (const w of p)
1179
+ await P(w);
1096
1180
  console.log(o.green(`
1097
1181
  ✅ Module generated successfully!`)), console.log(o.cyan(`
1098
1182
  📦 Registering module in main.ts...
1099
1183
  `));
1100
- const S = await Le(t, e.moduleName, s.moduleNamePascal);
1184
+ const E = await Re(e, t.moduleName, i.moduleNamePascal);
1101
1185
  console.log(o.cyan(`
1102
- 📝 Next steps:`)), S ? (console.log(o.cyan(" 1. Update API client imports in the generated composables")), console.log(o.cyan(` 2. Customize the table columns and form fields as needed
1103
- `))) : (console.log(o.cyan(" 1. Import the module in your main.ts:")), console.log(o.gray(` import ${s.moduleNamePascal}Module from "./modules/${e.moduleName}";`)), console.log(o.gray(` app.use(${s.moduleNamePascal}Module, { router });`)), console.log(o.cyan(" 2. Update API client imports in the generated composables")), console.log(o.cyan(` 3. Customize the table columns and form fields as needed
1186
+ 📝 Next steps:`)), E ? (console.log(o.cyan(" 1. Update API client imports in the generated composables")), console.log(o.cyan(` 2. Customize the table columns and form fields as needed
1187
+ `))) : (console.log(o.cyan(" 1. Import the module in your main.ts:")), console.log(o.gray(` import ${i.moduleNamePascal}Module from "./modules/${t.moduleName}";`)), console.log(o.gray(` app.use(${i.moduleNamePascal}Module, { router });`)), console.log(o.cyan(" 2. Update API client imports in the generated composables")), console.log(o.cyan(` 3. Customize the table columns and form fields as needed
1104
1188
  `)));
1105
- } catch (s) {
1189
+ } catch (i) {
1106
1190
  throw console.error(o.red(`
1107
- ❌ Module generation failed:`), s.message), s;
1191
+ ❌ Module generation failed:`), i.message), i;
1108
1192
  }
1109
1193
  }
1110
- async function je(t) {
1194
+ async function _e(e) {
1111
1195
  try {
1112
1196
  console.log(o.cyan(`
1113
1197
  📄 Adding blade to existing module
1114
1198
  `));
1115
- const e = m.join(t, "src", "modules");
1116
- if (!r.existsSync(e))
1199
+ const t = m.join(e, "src", "modules");
1200
+ if (!l.existsSync(t))
1117
1201
  throw console.error(o.red("❌ No modules directory found at src/modules")), new Error("Modules directory not found");
1118
- const n = r.readdirSync(e).filter((S) => r.statSync(m.join(e, S)).isDirectory());
1202
+ const n = l.readdirSync(t).filter((E) => l.statSync(m.join(t, E)).isDirectory());
1119
1203
  if (n.length === 0)
1120
1204
  throw console.error(o.red("❌ No existing modules found")), new Error("No existing modules found");
1121
1205
  const a = await x(
@@ -1124,13 +1208,13 @@ async function je(t) {
1124
1208
  type: "autocomplete",
1125
1209
  name: "moduleName",
1126
1210
  message: "Select existing module:",
1127
- choices: n.map((S) => ({ title: S, value: S }))
1211
+ choices: n.map((E) => ({ title: E, value: E }))
1128
1212
  },
1129
1213
  {
1130
1214
  type: "text",
1131
1215
  name: "entitySingular",
1132
1216
  message: "Entity name (e.g., Product, Order):",
1133
- validate: (S) => S.length > 0 ? !0 : "Entity name is required"
1217
+ validate: (E) => E.length > 0 ? !0 : "Entity name is required"
1134
1218
  },
1135
1219
  {
1136
1220
  type: "select",
@@ -1156,12 +1240,12 @@ async function je(t) {
1156
1240
  ],
1157
1241
  {
1158
1242
  onCancel: () => {
1159
- throw new E();
1243
+ throw new $();
1160
1244
  }
1161
1245
  }
1162
1246
  );
1163
- let s = !1;
1164
- a.bladeType === "details" && (s = (await x(
1247
+ let i = !1;
1248
+ a.bladeType === "details" && (i = (await x(
1165
1249
  {
1166
1250
  type: "confirm",
1167
1251
  name: "customizeForm",
@@ -1170,68 +1254,100 @@ async function je(t) {
1170
1254
  },
1171
1255
  {
1172
1256
  onCancel: () => {
1173
- throw new E();
1257
+ throw new $();
1174
1258
  }
1175
1259
  }
1176
1260
  )).customizeForm);
1177
- const c = W(a.entitySingular, a.moduleName), l = z(c), d = m.join(e, a.moduleName), w = V(), u = [];
1178
- let g = "", p = {}, i = [];
1179
- s && a.bladeType === "details" && (i = await ne(), i.length > 0 && (g = R(i, c.moduleNameUpperSnake), p = k(i)));
1180
- const f = await j(
1181
- w,
1261
+ const r = W(a.entitySingular, a.moduleName), s = z(r), d = m.join(t, a.moduleName), h = L(import.meta.url), p = [];
1262
+ let u = "", f = {}, c = [];
1263
+ i && a.bladeType === "details" && (c = await ae(), c.length > 0 && (u = k(c, r.moduleNameUpperSnake), f = j(c)));
1264
+ const g = await _(
1265
+ h,
1182
1266
  d,
1183
1267
  a.bladeType,
1184
- l,
1268
+ s,
1185
1269
  a.isWorkspace,
1186
- g,
1187
- i
1270
+ u,
1271
+ c
1188
1272
  );
1189
- if (u.push(f), a.includeComposable) {
1190
- const S = await G(
1191
- w,
1273
+ if (p.push(g), a.includeComposable) {
1274
+ const E = await B(
1275
+ h,
1192
1276
  d,
1193
1277
  a.bladeType,
1194
- c,
1195
- l
1278
+ r,
1279
+ s
1196
1280
  );
1197
- u.push(S);
1198
- const h = m.join(d, "composables", "index.ts"), I = `export * from "./${a.bladeType === "grid" ? `use${c.entitySingularPascal}List` : `use${c.entitySingularPascal}Details`}";
1281
+ p.push(E);
1282
+ const w = m.join(d, "composables", "index.ts"), A = `export * from "./${a.bladeType === "grid" ? `use${r.entitySingularPascal}List` : `use${r.entitySingularPascal}Details`}";
1199
1283
  `;
1200
- r.existsSync(h) ? r.readFileSync(h, "utf-8").includes(I) || r.appendFileSync(h, I) : r.writeFileSync(h, I);
1284
+ l.existsSync(w) ? l.readFileSync(w, "utf-8").includes(A) || l.appendFileSync(w, A) : l.writeFileSync(w, A);
1201
1285
  }
1202
- if (Object.keys(p).length > 0) {
1203
- const S = m.join(d, "locales", "en.json");
1204
- if (r.existsSync(S)) {
1205
- const h = JSON.parse(r.readFileSync(S, "utf-8")), $ = Object.keys(h)[0];
1206
- $ && h[$]?.PAGES?.DETAILS?.FORM?.INFO && (h[$].PAGES.DETAILS.FORM.INFO = {
1207
- ...h[$].PAGES.DETAILS.FORM.INFO,
1208
- ...p
1209
- }, r.writeFileSync(S, JSON.stringify(h, null, 2)), console.log(o.green("✓ Updated locales with custom fields")));
1286
+ if (Object.keys(f).length > 0) {
1287
+ const E = m.join(d, "locales", "en.json");
1288
+ if (l.existsSync(E)) {
1289
+ const w = JSON.parse(l.readFileSync(E, "utf-8")), S = Object.keys(w)[0];
1290
+ S && w[S]?.PAGES?.DETAILS?.FORM?.INFO && (w[S].PAGES.DETAILS.FORM.INFO = {
1291
+ ...w[S].PAGES.DETAILS.FORM.INFO,
1292
+ ...f
1293
+ }, l.writeFileSync(E, JSON.stringify(w, null, 2)), console.log(o.green("✓ Updated locales with custom fields")));
1210
1294
  }
1211
1295
  }
1212
- const y = a.bladeType === "grid" ? `${c.entitySingularPascal}List` : `${c.entitySingularPascal}Details`, b = a.bladeType === "grid" ? l["{{entity-name-plural}}"] : `${l["{{entity-name}}"]}-details`;
1296
+ const y = a.bladeType === "grid" ? `${r.entitySingularPascal}List` : `${r.entitySingularPascal}Details`, b = a.bladeType === "grid" ? s["{{entity-name-list}}"] : `${s["{{entity-name}}"]}-details`;
1213
1297
  await K(d, [{ exportName: y, fileName: b }]), console.log(o.cyan(`
1214
1298
  ✨ Formatting files with Prettier...
1215
1299
  `));
1216
- for (const S of u)
1217
- await P(S);
1300
+ for (const E of p)
1301
+ await P(E);
1218
1302
  console.log(o.green(`
1219
1303
  ✅ Blade generated successfully!
1220
1304
  `));
1221
- } catch (e) {
1305
+ } catch (t) {
1222
1306
  throw console.error(o.red(`
1223
- ❌ Blade generation failed:`), e.message), e;
1307
+ ❌ Blade generation failed:`), t.message), t;
1308
+ }
1309
+ }
1310
+ async function Be(e, t) {
1311
+ try {
1312
+ console.log(o.cyan(`
1313
+ 🧩 Creating widget (non-interactive mode)
1314
+ `));
1315
+ const n = m.join(e, "src", "modules");
1316
+ if (!l.existsSync(n))
1317
+ throw new I("❌ No modules directory found");
1318
+ const a = m.join(n, t.moduleName);
1319
+ if (!l.existsSync(a))
1320
+ throw new I(`❌ Module "${t.moduleName}" not found`);
1321
+ const i = m.join(a, "pages");
1322
+ if (!l.existsSync(i))
1323
+ throw new I("❌ No pages directory found in this module");
1324
+ const r = m.join(i, `${t.bladeName}.vue`);
1325
+ if (!l.existsSync(r))
1326
+ throw new I(`❌ Blade "${t.bladeName}.vue" not found in module "${t.moduleName}"`);
1327
+ await le(
1328
+ a,
1329
+ {
1330
+ bladeName: t.bladeName,
1331
+ widgetName: t.widgetName,
1332
+ entityName: t.entityName
1333
+ },
1334
+ t.icon,
1335
+ t.moduleName
1336
+ );
1337
+ } catch (n) {
1338
+ throw n instanceof I || console.error(o.red(`
1339
+ ❌ Widget generation failed:`), n.message), n;
1224
1340
  }
1225
1341
  }
1226
- async function Q(t) {
1342
+ async function Q(e) {
1227
1343
  try {
1228
1344
  console.log(o.cyan(`
1229
1345
  🧩 Creating widget
1230
1346
  `));
1231
- const e = m.join(t, "src", "modules");
1232
- if (!r.existsSync(e))
1347
+ const t = m.join(e, "src", "modules");
1348
+ if (!l.existsSync(t))
1233
1349
  throw console.error(o.red("❌ No modules directory found")), new Error("Modules directory not found");
1234
- const n = r.readdirSync(e).filter((u) => r.statSync(m.join(e, u)).isDirectory());
1350
+ const n = l.readdirSync(t).filter((p) => l.statSync(m.join(t, p)).isDirectory());
1235
1351
  if (n.length === 0)
1236
1352
  throw console.error(o.red("❌ No existing modules found")), new Error("No existing modules found");
1237
1353
  const a = await x(
@@ -1239,18 +1355,18 @@ async function Q(t) {
1239
1355
  type: "autocomplete",
1240
1356
  name: "moduleName",
1241
1357
  message: "Select module:",
1242
- choices: n.map((u) => ({ title: u, value: u }))
1358
+ choices: n.map((p) => ({ title: p, value: p }))
1243
1359
  },
1244
1360
  {
1245
1361
  onCancel: () => {
1246
- throw new E();
1362
+ throw new $();
1247
1363
  }
1248
1364
  }
1249
- ), s = m.join(e, a.moduleName), c = m.join(s, "pages");
1250
- if (!r.existsSync(c))
1365
+ ), i = m.join(t, a.moduleName), r = m.join(i, "pages");
1366
+ if (!l.existsSync(r))
1251
1367
  throw console.error(o.red("❌ No pages directory found in this module")), new Error("Pages directory not found");
1252
- const l = r.readdirSync(c).filter((u) => u.endsWith(".vue"));
1253
- if (l.length === 0)
1368
+ const s = l.readdirSync(r).filter((p) => p.endsWith(".vue"));
1369
+ if (s.length === 0)
1254
1370
  throw console.error(o.red("❌ No blades found in this module")), new Error("No blades found in module");
1255
1371
  const d = await x(
1256
1372
  [
@@ -1258,19 +1374,19 @@ async function Q(t) {
1258
1374
  type: "autocomplete",
1259
1375
  name: "bladeName",
1260
1376
  message: "Select blade to register widget in:",
1261
- choices: l.map((u) => ({ title: u, value: u.replace(".vue", "") }))
1377
+ choices: s.map((p) => ({ title: p, value: p.replace(".vue", "") }))
1262
1378
  },
1263
1379
  {
1264
1380
  type: "text",
1265
1381
  name: "widgetName",
1266
1382
  message: "Widget name (e.g., Stats, Chart, Items):",
1267
- validate: (u) => u.length > 0 ? !0 : "Widget name is required"
1383
+ validate: (p) => p.length > 0 ? !0 : "Widget name is required"
1268
1384
  },
1269
1385
  {
1270
1386
  type: "text",
1271
1387
  name: "entityName",
1272
1388
  message: "Related entity name (e.g., Offer, Item, Review):",
1273
- validate: (u) => u.length > 0 ? !0 : "Entity name is required"
1389
+ validate: (p) => p.length > 0 ? !0 : "Entity name is required"
1274
1390
  },
1275
1391
  {
1276
1392
  type: "select",
@@ -1289,121 +1405,121 @@ async function Q(t) {
1289
1405
  ],
1290
1406
  {
1291
1407
  onCancel: () => {
1292
- throw new E();
1408
+ throw new $();
1293
1409
  }
1294
1410
  }
1295
1411
  );
1296
- let w = d.icon;
1297
- w === "custom" && (w = (await x(
1412
+ let h = d.icon;
1413
+ h === "custom" && (h = (await x(
1298
1414
  {
1299
1415
  type: "text",
1300
1416
  name: "customIcon",
1301
1417
  message: "Enter custom icon name (e.g., material-dashboard):",
1302
- validate: (g) => g.length > 0 ? !0 : "Icon is required"
1418
+ validate: (u) => u.length > 0 ? !0 : "Icon is required"
1303
1419
  },
1304
1420
  {
1305
1421
  onCancel: () => {
1306
- throw new E();
1422
+ throw new $();
1307
1423
  }
1308
1424
  }
1309
- )).customIcon), await Ge(s, d, w, a.moduleName);
1310
- } catch (e) {
1425
+ )).customIcon), await le(i, d, h, a.moduleName);
1426
+ } catch (t) {
1311
1427
  throw console.error(o.red(`
1312
- ❌ Widget generation failed:`), e.message), e;
1428
+ ❌ Widget generation failed:`), t.message), t;
1313
1429
  }
1314
1430
  }
1315
- async function Ge(t, e, n, a) {
1431
+ async function le(e, t, n, a) {
1316
1432
  try {
1317
- const s = W(e.entityName, a), c = V(), l = m.join(c, "widgets", "widget.vue");
1318
- if (!r.existsSync(l))
1319
- throw new Error(`Widget template not found at ${l}`);
1320
- const d = e.bladeName.match(/^(.+?)(-list|-details)?$/), w = d ? d[1] : e.bladeName, u = m.join(t, "components", "widgets"), g = m.join(u, N(e.widgetName)), p = m.join(g, `${N(e.widgetName)}-widget.vue`), i = m.join(g, "index.ts");
1321
- if (!r.existsSync(g))
1433
+ const i = W(t.entityName, a), r = L(import.meta.url), s = m.join(r, "widgets", "widget.vue");
1434
+ if (!l.existsSync(s))
1435
+ throw new Error(`Widget template not found at ${s}`);
1436
+ const d = t.bladeName.match(/^(.+?)(-list|-details)?$/), h = d ? d[1] : t.bladeName, p = m.join(e, "components", "widgets"), u = m.join(p, C(t.widgetName)), f = m.join(u, `${C(t.widgetName)}-widget.vue`), c = m.join(u, "index.ts");
1437
+ if (!l.existsSync(u))
1322
1438
  try {
1323
- r.mkdirSync(g, { recursive: !0 });
1324
- } catch (C) {
1325
- throw new Error(`Failed to create widget directory: ${C.message}`);
1439
+ l.mkdirSync(u, { recursive: !0 });
1440
+ } catch (N) {
1441
+ throw new Error(`Failed to create widget directory: ${N.message}`);
1326
1442
  }
1327
- let f = r.readFileSync(l, "utf-8");
1443
+ let g = l.readFileSync(s, "utf-8");
1328
1444
  const y = {
1329
1445
  "{{MODULE_NAME_UPPERCASE}}": v(a).toUpperCase(),
1330
- "{{WIDGET_NAME_UPPERCASE}}": v(e.widgetName).toUpperCase(),
1446
+ "{{WIDGET_NAME_UPPERCASE}}": v(t.widgetName).toUpperCase(),
1331
1447
  "{{WIDGET_ICON}}": n,
1332
- "{{EntityName}}": s.entitySingularPascal,
1333
- "{{entityName}}": s.entitySingularCamel,
1334
- "{{ParentEntity}}": T(F(w)),
1335
- "{{parentEntityCamel}}": F(w),
1336
- "{{BladeName}}": `${s.entitySingularPascal}List`
1448
+ "{{EntityName}}": i.entitySingularPascal,
1449
+ "{{entityName}}": i.entitySingularCamel,
1450
+ "{{ParentEntity}}": T(F(h)),
1451
+ "{{parentEntityCamel}}": F(h),
1452
+ "{{BladeName}}": `${i.entitySingularPascal}List`
1337
1453
  };
1338
- f = H(f, y), r.writeFileSync(p, f), console.log(o.green(`✓ Created widget: ${m.relative(process.cwd(), p)}`));
1339
- const b = `${T(F(e.widgetName))}Widget`, S = `export { default as ${b} } from "./${N(e.widgetName)}-widget.vue";
1454
+ g = H(g, y), l.writeFileSync(f, g), console.log(o.green(`✓ Created widget: ${m.relative(process.cwd(), f)}`));
1455
+ const b = `${T(F(t.widgetName))}Widget`, E = `export { default as ${b} } from "./${C(t.widgetName)}-widget.vue";
1340
1456
  `;
1341
- r.writeFileSync(i, S);
1342
- const h = m.join(u, "index.ts"), $ = `export * from "./${N(e.widgetName)}";
1457
+ l.writeFileSync(c, E);
1458
+ const w = m.join(p, "index.ts"), S = `export * from "./${C(t.widgetName)}";
1343
1459
  `;
1344
- r.existsSync(h) ? r.readFileSync(h, "utf-8").includes($) || r.appendFileSync(h, $) : r.writeFileSync(h, $);
1345
- const I = m.join(t, "locales", "en.json");
1346
- if (r.existsSync(I))
1460
+ l.existsSync(w) ? l.readFileSync(w, "utf-8").includes(S) || l.appendFileSync(w, S) : l.writeFileSync(w, S);
1461
+ const A = m.join(e, "locales", "en.json");
1462
+ if (l.existsSync(A))
1347
1463
  try {
1348
- const C = JSON.parse(r.readFileSync(I, "utf-8")), M = Object.keys(C)[0];
1464
+ const N = JSON.parse(l.readFileSync(A, "utf-8")), M = Object.keys(N)[0];
1349
1465
  if (M) {
1350
- C[M].WIDGETS || (C[M].WIDGETS = {});
1351
- const J = v(e.widgetName).toUpperCase();
1352
- C[M].WIDGETS[J] || (C[M].WIDGETS[J] = {
1353
- TITLE: T(e.widgetName)
1354
- }), r.writeFileSync(I, JSON.stringify(C, null, 2)), await P(I), console.log(o.green("✓ Updated locales with widget translations"));
1466
+ N[M].WIDGETS || (N[M].WIDGETS = {});
1467
+ const J = v(t.widgetName).toUpperCase();
1468
+ N[M].WIDGETS[J] || (N[M].WIDGETS[J] = {
1469
+ TITLE: T(t.widgetName)
1470
+ }), l.writeFileSync(A, JSON.stringify(N, null, 2)), await P(A), console.log(o.green("✓ Updated locales with widget translations"));
1355
1471
  }
1356
- } catch (C) {
1357
- console.warn(o.yellow(`⚠️ Could not update locales: ${C.message}`));
1472
+ } catch (N) {
1473
+ console.warn(o.yellow(`⚠️ Could not update locales: ${N.message}`));
1358
1474
  }
1359
- const D = m.join(t, "pages", `${e.bladeName}.vue`);
1360
- if (r.existsSync(D))
1475
+ const D = m.join(e, "pages", `${t.bladeName}.vue`);
1476
+ if (l.existsSync(D))
1361
1477
  try {
1362
- await _e(D, b, s.entitySingularCamel), console.log(o.green(`✓ Registered widget in ${e.bladeName}.vue`));
1363
- } catch (C) {
1364
- console.warn(o.yellow(`⚠️ Could not auto-register widget in blade: ${C.message}`)), console.warn(o.yellow(" Please add the widget registration manually."));
1478
+ await Ge(D, b, i.entitySingularCamel), console.log(o.green(`✓ Registered widget in ${t.bladeName}.vue`));
1479
+ } catch (N) {
1480
+ console.warn(o.yellow(`⚠️ Could not auto-register widget in blade: ${N.message}`)), console.warn(o.yellow(" Please add the widget registration manually."));
1365
1481
  }
1366
- await P(p), await P(i), r.existsSync(D) && await P(D), console.log(o.green(`
1482
+ await P(f), await P(c), l.existsSync(D) && await P(D), console.log(o.green(`
1367
1483
  ✅ Widget generated successfully!`)), console.log(o.cyan(`
1368
1484
  📝 Widget is automatically registered in the blade!`)), console.log(o.cyan(` See TODO comments in widget file for API integration.
1369
1485
  `));
1370
- } catch (s) {
1486
+ } catch (i) {
1371
1487
  throw console.error(o.red(`
1372
- ❌ Widget file creation failed:`), s.message), s;
1488
+ ❌ Widget file creation failed:`), i.message), i;
1373
1489
  }
1374
1490
  }
1375
- async function _e(t, e, n) {
1376
- let a = r.readFileSync(t, "utf-8");
1491
+ async function Ge(e, t, n) {
1492
+ let a = l.readFileSync(e, "utf-8");
1377
1493
  if (!new RegExp(
1378
- `import\\s*\\{[^}]*\\b${e}\\b[^}]*\\}\\s*from\\s*["']\\.\\./components/widgets["']`
1494
+ `import\\s*\\{[^}]*\\b${t}\\b[^}]*\\}\\s*from\\s*["']\\.\\./components/widgets["']`
1379
1495
  ).test(a)) {
1380
- const p = a.match(/import\s*\{([^}]+)\}\s*from\s*["']\.\.\/components\/widgets["']/);
1381
- if (p) {
1382
- const f = p[1].split(",").map((y) => y.trim()).filter(Boolean);
1383
- if (!f.includes(e)) {
1384
- f.push(e);
1385
- const y = f.join(", ");
1386
- a = a.replace(p[0], `import { ${y} } from "../components/widgets"`);
1496
+ const f = a.match(/import\s*\{([^}]+)\}\s*from\s*["']\.\.\/components\/widgets["']/);
1497
+ if (f) {
1498
+ const g = f[1].split(",").map((y) => y.trim()).filter(Boolean);
1499
+ if (!g.includes(t)) {
1500
+ g.push(t);
1501
+ const y = g.join(", ");
1502
+ a = a.replace(f[0], `import { ${y} } from "../components/widgets"`);
1387
1503
  }
1388
1504
  } else {
1389
- const i = a.match(/<script\s+(?:setup\s+lang="ts"|lang="ts"\s+setup|setup)>/);
1390
- if (i) {
1391
- const f = a.indexOf(i[0]) + i[0].length, y = [...a.slice(f).matchAll(/import\s+[\s\S]+?;/g)];
1505
+ const c = a.match(/<script\s+(?:setup\s+lang="ts"|lang="ts"\s+setup|setup)>/);
1506
+ if (c) {
1507
+ const g = a.indexOf(c[0]) + c[0].length, y = [...a.slice(g).matchAll(/import\s+[\s\S]+?;/g)];
1392
1508
  if (y.length > 0) {
1393
- const b = y[y.length - 1], S = f + b.index + b[0].length;
1394
- a = a.slice(0, S) + `
1395
- import { ${e} } from "../components/widgets";` + a.slice(S);
1509
+ const b = y[y.length - 1], E = g + b.index + b[0].length;
1510
+ a = a.slice(0, E) + `
1511
+ import { ${t} } from "../components/widgets";` + a.slice(E);
1396
1512
  } else
1397
- a = a.slice(0, f) + `
1398
- import { ${e} } from "../components/widgets";
1399
- ` + a.slice(f);
1513
+ a = a.slice(0, g) + `
1514
+ import { ${t} } from "../components/widgets";
1515
+ ` + a.slice(g);
1400
1516
  }
1401
1517
  }
1402
1518
  }
1403
- const c = `${e}`, l = ` registerWidget(
1519
+ const r = `${t}`, s = ` registerWidget(
1404
1520
  {
1405
- id: "${c}",
1406
- component: ${e},
1521
+ id: "${r}",
1522
+ component: ${t},
1407
1523
  props: { item },
1408
1524
  updateFunctionName: "updateActiveWidgetCount",
1409
1525
  // isVisible: computed(() => !!props.param), // Uncomment to show widget only when blade has param
@@ -1411,117 +1527,114 @@ import { ${e} } from "../components/widgets";
1411
1527
  blade?.value.id ?? "",
1412
1528
  );`, d = a.match(/function\s+registerWidgets\s*\(\s*\)\s*\{/);
1413
1529
  if (d) {
1414
- const p = a.indexOf(d[0]) + d[0].length;
1415
- let i = 1, f = p;
1416
- for (let y = p; y < a.length && i > 0; y++)
1417
- a[y] === "{" && i++, a[y] === "}" && i--, i === 1 && (f = y);
1418
- a = a.slice(0, f) + `
1419
- ` + l + `
1420
- ` + a.slice(f);
1530
+ const f = a.indexOf(d[0]) + d[0].length;
1531
+ let c = 1, g = f;
1532
+ for (let y = f; y < a.length && c > 0; y++)
1533
+ a[y] === "{" && c++, a[y] === "}" && c--, c === 1 && (g = y);
1534
+ a = a.slice(0, g) + `
1535
+ ` + s + `
1536
+ ` + a.slice(g);
1421
1537
  } else {
1422
- const p = a.match(/defineExpose\s*\(/);
1423
- if (p) {
1424
- const i = a.indexOf(p[0]), f = `
1538
+ const f = a.match(/defineExpose\s*\(/);
1539
+ if (f) {
1540
+ const c = a.indexOf(f[0]), g = `
1425
1541
  function registerWidgets() {
1426
- ${l}
1542
+ ${s}
1427
1543
  }
1428
1544
 
1429
1545
  registerWidgets();
1430
1546
 
1431
1547
  `;
1432
- a = a.slice(0, i) + f + a.slice(i);
1548
+ a = a.slice(0, c) + g + a.slice(c);
1433
1549
  } else {
1434
- const i = a.match(/<\/script>/);
1435
- if (i) {
1436
- const f = a.indexOf(i[0]), y = `
1550
+ const c = a.match(/<\/script>/);
1551
+ if (c) {
1552
+ const g = a.indexOf(c[0]), y = `
1437
1553
  function registerWidgets() {
1438
- ${l}
1554
+ ${s}
1439
1555
  }
1440
1556
 
1441
1557
  registerWidgets();
1442
1558
 
1443
1559
  `;
1444
- a = a.slice(0, f) + y + a.slice(f);
1560
+ a = a.slice(0, g) + y + a.slice(g);
1445
1561
  }
1446
1562
  }
1447
1563
  }
1448
- const w = ` unregisterWidget("${c}", blade?.value.id);`, u = a.match(/onBeforeUnmount\s*\(\s*\(\s*\)\s*=>\s*\{/);
1449
- if (u) {
1450
- const p = a.indexOf(u[0]) + u[0].length;
1451
- a = a.slice(0, p) + `
1452
- ` + w + `
1453
- ` + a.slice(p);
1564
+ const h = ` unregisterWidget("${r}", blade?.value.id);`, p = a.match(/onBeforeUnmount\s*\(\s*\(\s*\)\s*=>\s*\{/);
1565
+ if (p) {
1566
+ const f = a.indexOf(p[0]) + p[0].length;
1567
+ a = a.slice(0, f) + `
1568
+ ` + h + `
1569
+ ` + a.slice(f);
1454
1570
  } else {
1455
- const p = a.match(/defineExpose\s*\(/);
1456
- if (p) {
1457
- const i = a.indexOf(p[0]), f = `
1571
+ const f = a.match(/defineExpose\s*\(/);
1572
+ if (f) {
1573
+ const c = a.indexOf(f[0]), g = `
1458
1574
  onBeforeUnmount(() => {
1459
- ${w}
1575
+ ${h}
1460
1576
  });
1461
1577
 
1462
1578
  `;
1463
- a = a.slice(0, i) + f + a.slice(i);
1579
+ a = a.slice(0, c) + g + a.slice(c);
1464
1580
  }
1465
1581
  }
1466
- const g = [
1582
+ const u = [
1467
1583
  // registerWidget and unregisterWidget come from useWidgets(), not direct imports
1468
1584
  { name: "useWidgets", from: "@vc-shell/framework" },
1469
1585
  { name: "useBlade", from: "@vc-shell/framework" },
1470
1586
  { name: "onBeforeUnmount", from: "vue" }
1471
1587
  // { name: "computed", from: "vue" }, // Not needed if isVisible is commented
1472
1588
  ];
1473
- for (const { name: p, from: i } of g) {
1474
- const f = i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), y = new RegExp(`import\\s*\\{([^}]+)\\}\\s*from\\s*["']${f}["']`, "g"), b = [...a.matchAll(y)];
1589
+ for (const { name: f, from: c } of u) {
1590
+ const g = c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), y = new RegExp(`import\\s*\\{([^}]+)\\}\\s*from\\s*["']${g}["']`, "g"), b = [...a.matchAll(y)];
1475
1591
  if (b.length > 0) {
1476
- const S = b[0], $ = S[1].split(",").map((I) => I.trim()).filter(Boolean);
1477
- if (!$.includes(p)) {
1478
- $.push(p);
1479
- const I = $.join(", ");
1480
- a = a.replace(S[0], `import { ${I} } from "${i}"`);
1592
+ const E = b[0], S = E[1].split(",").map((A) => A.trim()).filter(Boolean);
1593
+ if (!S.includes(f)) {
1594
+ S.push(f);
1595
+ const A = S.join(", ");
1596
+ a = a.replace(E[0], `import { ${A} } from "${c}"`);
1481
1597
  }
1482
1598
  } else {
1483
- const S = a.match(/<script\s+(?:setup\s+lang="ts"|lang="ts"\s+setup|setup)>/);
1484
- if (S) {
1485
- const h = a.indexOf(S[0]) + S[0].length, $ = a.slice(h).match(/^[\s\n]*import/m);
1486
- if ($) {
1487
- const I = h + a.slice(h).indexOf($[0]);
1488
- a = a.slice(0, I) + `import { ${p} } from "${i}";
1489
- ` + a.slice(I);
1599
+ const E = a.match(/<script\s+(?:setup\s+lang="ts"|lang="ts"\s+setup|setup)>/);
1600
+ if (E) {
1601
+ const w = a.indexOf(E[0]) + E[0].length, S = a.slice(w).match(/^[\s\n]*import/m);
1602
+ if (S) {
1603
+ const A = w + a.slice(w).indexOf(S[0]);
1604
+ a = a.slice(0, A) + `import { ${f} } from "${c}";
1605
+ ` + a.slice(A);
1490
1606
  } else
1491
- a = a.slice(0, h) + `
1492
- import { ${p} } from "${i}";
1493
- ` + a.slice(h);
1607
+ a = a.slice(0, w) + `
1608
+ import { ${f} } from "${c}";
1609
+ ` + a.slice(w);
1494
1610
  }
1495
1611
  }
1496
1612
  }
1497
1613
  if (!a.includes("const blade = useBlade()")) {
1498
- const p = `
1614
+ const f = `
1499
1615
  const blade = useBlade();
1500
- `, i = a.match(/const\s+\w+\s*=\s*[^;]+;(?=[^;]*const)/g);
1501
- if (i && i.length > 0) {
1502
- const f = i[i.length - 1], y = a.lastIndexOf(f) + f.length;
1503
- a = a.slice(0, y) + p + a.slice(y);
1616
+ `, c = a.match(/const\s+\w+\s*=\s*[^;]+;(?=[^;]*const)/g);
1617
+ if (c && c.length > 0) {
1618
+ const g = c[c.length - 1], y = a.lastIndexOf(g) + g.length;
1619
+ a = a.slice(0, y) + f + a.slice(y);
1504
1620
  }
1505
1621
  }
1506
1622
  if (!a.includes("const { registerWidget, unregisterWidget } = useWidgets()")) {
1507
- const p = `
1623
+ const f = `
1508
1624
  const { registerWidget, unregisterWidget } = useWidgets();
1509
- `, i = a.match(/const blade = useBlade\(\);/);
1510
- if (i) {
1511
- const f = a.indexOf(i[0]) + i[0].length;
1512
- a = a.slice(0, f) + p + a.slice(f);
1625
+ `, c = a.match(/const blade = useBlade\(\);/);
1626
+ if (c) {
1627
+ const g = a.indexOf(c[0]) + c[0].length;
1628
+ a = a.slice(0, g) + f + a.slice(g);
1513
1629
  }
1514
1630
  }
1515
- r.writeFileSync(t, a);
1631
+ l.writeFileSync(e, a);
1516
1632
  }
1517
- function V() {
1518
- return m.resolve(X(import.meta.url), "..", "templates");
1519
- }
1520
- async function j(t, e, n, a, s, c, l) {
1521
- const d = m.join(t, "blades", n, "blade.vue"), w = n === "grid" ? `${a["{{entity-name-plural}}"]}.vue` : `${a["{{entity-name}}"]}-details.vue`, u = m.join(e, "pages", w);
1522
- se(u);
1523
- let g = r.readFileSync(d, "utf-8");
1524
- if (s ? (g = g.replace(/{{isWorkspace}}/g, "true"), g = g.replace(
1633
+ async function _(e, t, n, a, i, r, s) {
1634
+ const d = m.join(e, "blades", n, "blade.vue"), h = n === "grid" ? `${a["{{entity-name-list}}"]}.vue` : `${a["{{entity-name}}"]}-details.vue`, p = m.join(t, "pages", h);
1635
+ oe(p);
1636
+ let u = l.readFileSync(d, "utf-8");
1637
+ if (i ? (u = u.replace(/{{isWorkspace}}/g, "true"), u = u.replace(
1525
1638
  /{{menuItem}}/g,
1526
1639
  `{
1527
1640
  id: "${a["{{entityName}}"]}",
@@ -1529,61 +1642,94 @@ async function j(t, e, n, a, s, c, l) {
1529
1642
  icon: "material-list",
1530
1643
  priority: 1,
1531
1644
  }`
1532
- )) : (g = g.replace(/{{isWorkspace}}/g, "false"), g = g.replace(/{{menuItem}}/g, "undefined")), n === "details") {
1533
- if (c)
1534
- g = g.replace(/\{\{FORM_FIELDS\}\}/g, c);
1645
+ )) : (u = u.replace(/{{isWorkspace}}/g, "false"), u = u.replace(/{{menuItem}}/g, "undefined")), n === "grid") {
1646
+ const f = `${a["{{entity-name}}"]}-details.vue`;
1647
+ l.existsSync(m.join(t, "pages", f)) ? (u = u.replace(
1648
+ /\{\{DETAILS_BLADE_IMPORT\}\}/g,
1649
+ `import ${a["{{EntityName}}"]}Details from "./{{entity-name}}-details.vue";
1650
+ `
1651
+ ), u = u.replace(
1652
+ /\{\{DETAILS_BLADE_OPEN_ITEM\}\}/g,
1653
+ `openBlade({
1654
+ blade: markRaw(${a["{{EntityName}}"]}Details),
1655
+ param: item.id,
1656
+ onOpen() {
1657
+ selectedItemId.value = item.id;
1658
+ },
1659
+ onClose() {
1660
+ selectedItemId.value = undefined;
1661
+ },
1662
+ });`
1663
+ ), u = u.replace(
1664
+ /\{\{DETAILS_BLADE_OPEN_NEW\}\}/g,
1665
+ `openBlade({
1666
+ blade: markRaw(${a["{{EntityName}}"]}Details),
1667
+ });`
1668
+ )) : (u = u.replace(/\{\{DETAILS_BLADE_IMPORT\}\}/g, ""), u = u.replace(
1669
+ /\{\{DETAILS_BLADE_OPEN_ITEM\}\}/g,
1670
+ `// TODO: Implement item click handler
1671
+ console.log("Item clicked:", item);`
1672
+ ), u = u.replace(
1673
+ /\{\{DETAILS_BLADE_OPEN_NEW\}\}/g,
1674
+ `// TODO: Implement add handler
1675
+ console.log("Add new item");`
1676
+ ));
1677
+ }
1678
+ if (n === "details") {
1679
+ if (r)
1680
+ u = u.replace(/\{\{FORM_FIELDS\}\}/g, r);
1535
1681
  else {
1536
- const i = oe(a["{{MODULE_NAME_UPPERCASE}}"]);
1537
- g = g.replace(/\{\{FORM_FIELDS\}\}/g, i);
1682
+ const c = ne(a["{{MODULE_NAME_UPPERCASE}}"]);
1683
+ u = u.replace(/\{\{FORM_FIELDS\}\}/g, c);
1538
1684
  }
1539
- if (l && Me(l)) {
1540
- g = g.replace(/\{\{GALLERY_IMPORTS\}\}/g, `
1685
+ if (s && Le(s)) {
1686
+ u = u.replace(/\{\{GALLERY_IMPORTS\}\}/g, `
1541
1687
  useAssets,
1542
1688
  ICommonAsset,`);
1543
- const i = Ne(a["{{entityName}}"]);
1544
- g = g.replace(/\{\{GALLERY_SCRIPT_ADDITIONS\}\}/g, i);
1689
+ const c = Oe(a["{{entityName}}"]);
1690
+ u = u.replace(/\{\{GALLERY_SCRIPT_ADDITIONS\}\}/g, c);
1545
1691
  } else
1546
- g = g.replace(/\{\{GALLERY_IMPORTS\}\}/g, ""), g = g.replace(/\{\{GALLERY_SCRIPT_ADDITIONS\}\}/g, "");
1692
+ u = u.replace(/\{\{GALLERY_IMPORTS\}\}/g, ""), u = u.replace(/\{\{GALLERY_SCRIPT_ADDITIONS\}\}/g, "");
1547
1693
  }
1548
- return g = H(g, a), r.writeFileSync(u, g), console.log(o.green(`✓ Created ${n} blade: ${m.relative(process.cwd(), u)}`)), u;
1549
- }
1550
- async function G(t, e, n, a, s) {
1551
- const c = n === "grid" ? "grid-composable.ts" : "details-composable.ts", l = m.join(t, "composables", c), d = n === "grid" ? `use${a.entitySingularPascal}List.ts` : `use${a.entitySingularPascal}Details.ts`, w = m.join(e, "composables", d);
1552
- se(w);
1553
- let u = r.readFileSync(l, "utf-8");
1554
- return u = H(u, s), r.writeFileSync(w, u), console.log(o.green(`✓ Created composable: ${m.relative(process.cwd(), w)}`)), w;
1555
- }
1556
- function We(t) {
1557
- const e = r.readdirSync(t);
1558
- return e.length === 0 || e.length === 1 && e[0] === ".git";
1559
- }
1560
- async function Be(t, e, n) {
1561
- const a = m.join(t, "composables", "index.ts");
1562
- let s = "";
1563
- return e.createGridBlade && (s += `export * from "./use${n.entitySingularPascal}List";
1564
- `), e.createDetailsBlade && (s += `export * from "./use${n.entitySingularPascal}Details";
1565
- `), r.writeFileSync(a, s), console.log(o.green("✓ Created composables index")), a;
1566
- }
1567
- async function Ve(t, e, n, a) {
1568
- const s = m.join(t, "locales", "en.json"), c = {
1694
+ return u = H(u, a), l.writeFileSync(p, u), console.log(o.green(`✓ Created ${n} blade: ${m.relative(process.cwd(), p)}`)), p;
1695
+ }
1696
+ async function B(e, t, n, a, i) {
1697
+ const r = n === "grid" ? "grid-composable.ts" : "details-composable.ts", s = m.join(e, "composables", r), d = n === "grid" ? `use${a.entitySingularPascal}List.ts` : `use${a.entitySingularPascal}Details.ts`, h = m.join(t, "composables", d);
1698
+ oe(h);
1699
+ let p = l.readFileSync(s, "utf-8");
1700
+ return p = H(p, i), l.writeFileSync(h, p), console.log(o.green(`✓ Created composable: ${m.relative(process.cwd(), h)}`)), h;
1701
+ }
1702
+ function We(e) {
1703
+ const t = l.readdirSync(e);
1704
+ return t.length === 0 || t.length === 1 && t[0] === ".git";
1705
+ }
1706
+ async function Ve(e, t, n) {
1707
+ const a = m.join(e, "composables", "index.ts");
1708
+ let i = "";
1709
+ return t.createGridBlade && (i += `export * from "./use${n.entitySingularPascal}List";
1710
+ `), t.createDetailsBlade && (i += `export * from "./use${n.entitySingularPascal}Details";
1711
+ `), l.writeFileSync(a, i), console.log(o.green("✓ Created composables index")), a;
1712
+ }
1713
+ async function qe(e, t, n, a) {
1714
+ const i = m.join(e, "locales", "en.json"), r = {
1569
1715
  TITLE: "Information",
1570
1716
  NAME: "Name",
1571
- NAME_PLACEHOLDER: `Enter ${e.entitySingularCamel} name`,
1717
+ NAME_PLACEHOLDER: `Enter ${t.entitySingularCamel} name`,
1572
1718
  CREATED_DATE: "Created Date"
1573
- }, l = a && Object.keys(a).length > 0 ? { TITLE: "Information", ...a } : c, d = {
1574
- [e.moduleNameUpperSnake]: {
1719
+ }, s = a && Object.keys(a).length > 0 ? { TITLE: "Information", ...a } : r, d = {
1720
+ [t.moduleNameUpperSnake]: {
1575
1721
  MENU: {
1576
- TITLE: e.entityPluralPascal
1722
+ TITLE: t.entityPluralPascal
1577
1723
  },
1578
1724
  PAGES: {
1579
1725
  LIST: {
1580
- TITLE: e.entityPluralPascal,
1726
+ TITLE: t.entityPluralPascal,
1581
1727
  SEARCH: {
1582
- PLACEHOLDER: `Search ${e.entityPluralCamel}...`
1728
+ PLACEHOLDER: `Search ${t.entityPluralCamel}...`
1583
1729
  },
1584
1730
  TOOLBAR: {
1585
1731
  REFRESH: "Refresh",
1586
- ADD: `Add ${e.entitySingularPascal}`,
1732
+ ADD: `Add ${t.entitySingularPascal}`,
1587
1733
  DELETE: "Delete selected"
1588
1734
  },
1589
1735
  TABLE: {
@@ -1591,7 +1737,7 @@ async function Ve(t, e, n, a) {
1591
1737
  NAME: "Name",
1592
1738
  CREATED_DATE: "Created"
1593
1739
  },
1594
- TOTALS: `{count} ${e.entityPluralCamel}`,
1740
+ TOTALS: `{count} ${t.entityPluralCamel}`,
1595
1741
  FILTER: {
1596
1742
  STATUS: {
1597
1743
  TITLE: "Status",
@@ -1609,28 +1755,28 @@ async function Ve(t, e, n, a) {
1609
1755
  }
1610
1756
  },
1611
1757
  EMPTY: {
1612
- NO_ITEMS: `No ${e.entityPluralCamel} yet`,
1613
- ADD: `Add ${e.entitySingularPascal}`
1758
+ NO_ITEMS: `No ${t.entityPluralCamel} yet`,
1759
+ ADD: `Add ${t.entitySingularPascal}`
1614
1760
  },
1615
1761
  NOT_FOUND: {
1616
- EMPTY: `No ${e.entityPluralCamel} found`,
1762
+ EMPTY: `No ${t.entityPluralCamel} found`,
1617
1763
  RESET: "Reset search"
1618
1764
  }
1619
1765
  },
1620
1766
  DETAILS: {
1621
- TITLE: `New ${e.entitySingularPascal}`,
1767
+ TITLE: `New ${t.entitySingularPascal}`,
1622
1768
  TOOLBAR: {
1623
1769
  SAVE: "Save",
1624
1770
  DELETE: "Delete"
1625
1771
  },
1626
1772
  FORM: {
1627
- INFO: l
1773
+ INFO: s
1628
1774
  }
1629
1775
  },
1630
1776
  ALERTS: {
1631
- DELETE: `Are you sure you want to delete this ${e.entitySingularCamel}?`,
1777
+ DELETE: `Are you sure you want to delete this ${t.entitySingularCamel}?`,
1632
1778
  DELETE_SELECTED_CONFIRMATION: {
1633
- MESSAGE: `Are you sure you want to delete {count} ${e.entityPluralCamel}?`,
1779
+ MESSAGE: `Are you sure you want to delete {count} ${t.entityPluralCamel}?`,
1634
1780
  ALL: "all {totalCount}"
1635
1781
  },
1636
1782
  CLOSE_CONFIRMATION: "You have unsaved changes. Are you sure you want to close?",
@@ -1639,48 +1785,48 @@ async function Ve(t, e, n, a) {
1639
1785
  }
1640
1786
  }
1641
1787
  };
1642
- return r.writeFileSync(s, JSON.stringify(d, null, 2)), console.log(o.green("✓ Created locales file")), s;
1788
+ return l.writeFileSync(i, JSON.stringify(d, null, 2)), console.log(o.green("✓ Created locales file")), i;
1643
1789
  }
1644
- async function qe(t) {
1645
- const { args: e, cwd: n } = t, a = e._[0] || e.name || e["app-name"], l = await Ue({
1646
- args: e,
1790
+ async function Ue(e) {
1791
+ const { args: t, cwd: n } = e, a = t._[0] || t.name || t["app-name"], s = await ze({
1792
+ args: t,
1647
1793
  defaultAppName: a || "vc-app",
1648
1794
  hasAllArgs: !!a
1649
1795
  });
1650
1796
  console.log(o.cyan(`
1651
- 📋 Creating app with the following configuration:`)), console.log(o.cyan(` App name: ${l.appName}`)), console.log(o.cyan(` Package name: ${l.packageName}`)), console.log(o.cyan(` Base path: ${l.basePath}`)), console.log();
1652
- const d = a === "." ? n : m.join(n, l.appName);
1653
- He(d, {
1654
- overwrite: !!e.overwrite
1797
+ 📋 Creating app with the following configuration:`)), console.log(o.cyan(` App name: ${s.appName}`)), console.log(o.cyan(` Package name: ${s.packageName}`)), console.log(o.cyan(` Base path: ${s.basePath}`)), console.log();
1798
+ const d = a === "." ? n : m.join(n, s.appName);
1799
+ Ke(d, {
1800
+ overwrite: !!t.overwrite
1655
1801
  }), console.log(o.cyan(`
1656
1802
  📦 Scaffolding app in ${o.bold(d)}...`));
1657
- const w = Ke(l), u = Je({
1803
+ const h = Je(s), p = Ye({
1658
1804
  templateName: "base",
1659
1805
  targetDirectory: d,
1660
- replacements: w
1806
+ replacements: h
1661
1807
  });
1662
- return console.log(o.green(`✅ Created ${u} files`)), console.log(o.cyan(`
1663
- 🎨 Formatting files with Prettier...`)), await Xe(d), e["skip-module-gen"] || await et(d, e), {
1808
+ return console.log(o.green(`✅ Created ${p} files`)), console.log(o.cyan(`
1809
+ 🎨 Formatting files with Prettier...`)), await et(d), t["skip-module-gen"] || await tt(d, t), {
1664
1810
  root: d,
1665
- filesCreated: u,
1666
- config: l
1811
+ filesCreated: p,
1812
+ config: s
1667
1813
  };
1668
1814
  }
1669
- async function Ue(t) {
1670
- const { args: e, defaultAppName: n, hasAllArgs: a } = t;
1815
+ async function ze(e) {
1816
+ const { args: t, defaultAppName: n, hasAllArgs: a } = e;
1671
1817
  if (a) {
1672
- const s = A(e._[0] || e.name || e["app-name"] || n), c = e._[0] || e.name || e["app-name"] || s, l = e["package-name"] || (L(c) ? c : A(c)), d = ee(e["base-path"] || `/apps/${A(c)}/`);
1818
+ const i = O(t._[0] || t.name || t["app-name"] || n), r = t._[0] || t.name || t["app-name"] || i, s = t["package-name"] || (R(r) ? r : O(r)), d = X(t["base-path"] || `/apps/${O(r)}/`);
1673
1819
  return {
1674
- appName: s,
1675
- packageName: l,
1820
+ appName: i,
1821
+ packageName: s,
1676
1822
  moduleName: "",
1677
1823
  basePath: d
1678
1824
  };
1679
1825
  }
1680
- return ze(n);
1826
+ return He(n);
1681
1827
  }
1682
- async function ze(t) {
1683
- let e = t;
1828
+ async function He(e) {
1829
+ let t = e;
1684
1830
  try {
1685
1831
  const n = await x(
1686
1832
  [
@@ -1688,147 +1834,147 @@ async function ze(t) {
1688
1834
  name: "appName",
1689
1835
  type: "text",
1690
1836
  message: o.reset("Project name:"),
1691
- initial: t,
1692
- onState: (l) => {
1693
- e = A(String(l.value).trim()) || t;
1837
+ initial: e,
1838
+ onState: (s) => {
1839
+ t = O(String(s.value).trim()) || e;
1694
1840
  },
1695
- format: (l) => A(String(l).trim())
1841
+ format: (s) => O(String(s).trim())
1696
1842
  },
1697
1843
  {
1698
- type: () => !r.existsSync(e) || de(e) ? null : "confirm",
1844
+ type: () => !l.existsSync(t) || de(t) ? null : "confirm",
1699
1845
  name: "overwrite",
1700
- message: () => (e === "." ? "Current directory" : `Target directory "${e}"`) + " is not empty. Remove existing files and continue?"
1846
+ message: () => (t === "." ? "Current directory" : `Target directory "${t}"`) + " is not empty. Remove existing files and continue?"
1701
1847
  },
1702
1848
  {
1703
- type: (l, { overwrite: d }) => {
1849
+ type: (s, { overwrite: d }) => {
1704
1850
  if (d === !1)
1705
- throw new E();
1851
+ throw new $();
1706
1852
  return null;
1707
1853
  },
1708
1854
  name: "overwriteChecker"
1709
1855
  },
1710
1856
  {
1711
1857
  name: "packageName",
1712
- type: () => L(e) ? null : "text",
1858
+ type: () => R(t) ? null : "text",
1713
1859
  message: o.reset("Package name:"),
1714
- initial: () => A(e),
1715
- validate: (l) => L(l) || "Invalid package.json name"
1860
+ initial: () => O(t),
1861
+ validate: (s) => R(s) || "Invalid package.json name"
1716
1862
  },
1717
1863
  {
1718
1864
  name: "basePath",
1719
1865
  type: "text",
1720
1866
  message: o.reset("Base path:"),
1721
- initial: () => `/apps/${A(e)}/`,
1722
- format: (l) => ee(String(l).trim())
1867
+ initial: () => `/apps/${O(t)}/`,
1868
+ format: (s) => X(String(s).trim())
1723
1869
  }
1724
1870
  ],
1725
1871
  {
1726
1872
  onCancel: () => {
1727
- throw new E();
1873
+ throw new $();
1728
1874
  }
1729
1875
  }
1730
- ), a = n.appName || A(t), s = n.packageName || A(a), c = n.basePath || `/apps/${a}/`;
1876
+ ), a = n.appName || O(e), i = n.packageName || O(a), r = n.basePath || `/apps/${a}/`;
1731
1877
  return {
1732
1878
  appName: a,
1733
- packageName: s,
1879
+ packageName: i,
1734
1880
  moduleName: "",
1735
- basePath: c
1881
+ basePath: r
1736
1882
  };
1737
1883
  } catch (n) {
1738
- if (n instanceof E)
1884
+ if (n instanceof $)
1739
1885
  throw n;
1740
1886
  const a = n;
1741
- throw new B([a.message]);
1887
+ throw new V([a.message]);
1742
1888
  }
1743
1889
  }
1744
- function He(t, e) {
1745
- if (r.existsSync(t)) {
1746
- if (!de(t) && !e.overwrite)
1747
- throw new B([
1748
- `Target directory "${t}" is not empty. Use --overwrite to overwrite existing files.`
1890
+ function Ke(e, t) {
1891
+ if (l.existsSync(e)) {
1892
+ if (!de(e) && !t.overwrite)
1893
+ throw new V([
1894
+ `Target directory "${e}" is not empty. Use --overwrite to overwrite existing files.`
1749
1895
  ]);
1750
- ce(t);
1896
+ ce(e);
1751
1897
  } else
1752
- r.mkdirSync(t, { recursive: !0 });
1898
+ l.mkdirSync(e, { recursive: !0 });
1753
1899
  }
1754
- function Ke(t) {
1900
+ function Je(e) {
1755
1901
  return /* @__PURE__ */ new Map([
1756
- ["{{AppName}}", t.appName],
1757
- ["{{AppNameSentenceCase}}", tt(t.appName)],
1758
- ["{{BasePath}}", t.basePath],
1759
- ["{{PackageName}}", t.packageName]
1902
+ ["{{AppName}}", e.appName],
1903
+ ["{{AppNameSentenceCase}}", at(e.appName)],
1904
+ ["{{BasePath}}", e.basePath],
1905
+ ["{{PackageName}}", e.packageName]
1760
1906
  ]);
1761
1907
  }
1762
- function Je(t) {
1763
- const e = m.resolve(X(import.meta.url), "..", "templates"), n = m.join(e, t.templateName);
1908
+ function Ye(e) {
1909
+ const t = L(import.meta.url), n = m.join(t, e.templateName);
1764
1910
  let a = 0;
1765
- return ie(n, (s, c) => {
1766
- const l = m.join(t.targetDirectory, c), d = Ye(l, t.replacements);
1767
- if (r.statSync(s).isDirectory()) {
1768
- r.mkdirSync(d, { recursive: !0 });
1911
+ return re(n, (i, r) => {
1912
+ const s = m.join(e.targetDirectory, r), d = Ze(s, e.replacements);
1913
+ if (l.statSync(i).isDirectory()) {
1914
+ l.mkdirSync(d, { recursive: !0 });
1769
1915
  return;
1770
1916
  }
1771
- const u = m.dirname(d);
1772
- if (r.existsSync(u) || r.mkdirSync(u, { recursive: !0 }), Qe(s))
1773
- r.copyFileSync(s, d);
1917
+ const p = m.dirname(d);
1918
+ if (l.existsSync(p) || l.mkdirSync(p, { recursive: !0 }), Xe(i))
1919
+ l.copyFileSync(i, d);
1774
1920
  else {
1775
- const g = r.readFileSync(s, "utf-8"), p = Ze(g, t.replacements);
1776
- r.writeFileSync(d, p);
1921
+ const u = l.readFileSync(i, "utf-8"), f = Qe(u, e.replacements);
1922
+ l.writeFileSync(d, f);
1777
1923
  }
1778
1924
  a += 1;
1779
1925
  }), a;
1780
1926
  }
1781
- function ie(t, e, n = "") {
1782
- const a = r.readdirSync(t);
1783
- for (const s of a) {
1784
- const c = m.join(t, s), l = m.join(n, Se[s] ?? s);
1785
- r.statSync(c).isDirectory() ? ie(c, e, l) : e(c, l);
1927
+ function re(e, t, n = "") {
1928
+ const a = l.readdirSync(e);
1929
+ for (const i of a) {
1930
+ const r = m.join(e, i), s = m.join(n, Se[i] ?? i);
1931
+ l.statSync(r).isDirectory() ? re(r, t, s) : t(r, s);
1786
1932
  }
1787
1933
  }
1788
- function Ye(t, e) {
1789
- let n = t;
1790
- for (const [a, s] of e) {
1791
- const c = new RegExp(a, "g");
1792
- n = n.replace(c, s);
1934
+ function Ze(e, t) {
1935
+ let n = e;
1936
+ for (const [a, i] of t) {
1937
+ const r = new RegExp(a, "g");
1938
+ n = n.replace(r, i);
1793
1939
  }
1794
1940
  return n;
1795
1941
  }
1796
- function Ze(t, e) {
1797
- let n = t;
1798
- for (const [a, s] of e) {
1799
- const c = new RegExp(a, "g");
1800
- n = n.replace(c, s);
1942
+ function Qe(e, t) {
1943
+ let n = e;
1944
+ for (const [a, i] of t) {
1945
+ const r = new RegExp(a, "g");
1946
+ n = n.replace(r, i);
1801
1947
  }
1802
1948
  return n;
1803
1949
  }
1804
- function Qe(t) {
1805
- const e = m.extname(t).toLowerCase();
1806
- return [".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico", ".pdf", ".zip"].includes(e);
1950
+ function Xe(e) {
1951
+ const t = m.extname(e).toLowerCase();
1952
+ return [".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico", ".pdf", ".zip"].includes(t);
1807
1953
  }
1808
- function ce(t) {
1809
- if (r.existsSync(t))
1810
- for (const e of r.readdirSync(t)) {
1811
- const n = m.join(t, e);
1812
- r.lstatSync(n).isDirectory() ? ce(n) : r.unlinkSync(n);
1954
+ function ce(e) {
1955
+ if (l.existsSync(e))
1956
+ for (const t of l.readdirSync(e)) {
1957
+ const n = m.join(e, t);
1958
+ l.lstatSync(n).isDirectory() ? ce(n) : l.unlinkSync(n);
1813
1959
  }
1814
1960
  }
1815
- function de(t) {
1816
- const e = r.readdirSync(t);
1817
- return e.length === 0 || e.length === 1 && e[0] === ".git";
1961
+ function de(e) {
1962
+ const t = l.readdirSync(e);
1963
+ return t.length === 0 || t.length === 1 && t[0] === ".git";
1818
1964
  }
1819
- async function Xe(t) {
1965
+ async function et(e) {
1820
1966
  try {
1821
- await te(t, $e), console.log(o.green("✅ All files formatted"));
1822
- } catch (e) {
1823
- console.log(o.yellow(`⚠️ Some files could not be formatted: ${e.message}`));
1967
+ await ee(e, $e), console.log(o.green("✅ All files formatted"));
1968
+ } catch (t) {
1969
+ console.log(o.yellow(`⚠️ Some files could not be formatted: ${t.message}`));
1824
1970
  }
1825
1971
  }
1826
- async function et(t, e) {
1972
+ async function tt(e, t) {
1827
1973
  console.log(o.cyan(`
1828
1974
  🏗️ Creating module with blade generator...
1829
1975
  `));
1830
1976
  try {
1831
- await le({
1977
+ await ie({
1832
1978
  name: void 0,
1833
1979
  type: void 0,
1834
1980
  module: void 0,
@@ -1836,13 +1982,13 @@ async function et(t, e) {
1836
1982
  locales: !0,
1837
1983
  widget: !1,
1838
1984
  isWorkspace: !0,
1839
- path: t,
1840
- formFields: e["form-fields"],
1841
- skipFormEditor: e["skip-form-editor"],
1985
+ path: e,
1986
+ formFields: t["form-fields"],
1987
+ skipFormEditor: t["skip-form-editor"],
1842
1988
  _skipActionPrompt: !0
1843
1989
  });
1844
1990
  } catch (n) {
1845
- if (n instanceof E) {
1991
+ if (n instanceof $) {
1846
1992
  console.log(o.yellow(`
1847
1993
  ⚠️ Module generation cancelled`)), console.log(o.yellow(" You can add modules later using: create-vc-app blade"));
1848
1994
  return;
@@ -1851,116 +1997,121 @@ async function et(t, e) {
1851
1997
  ⚠️ Module generation failed: ${n.message}`)), console.log(o.yellow(" You can add modules later using: create-vc-app blade"));
1852
1998
  }
1853
1999
  }
1854
- function tt(t) {
1855
- return t.split("-").map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
2000
+ function at(e) {
2001
+ return e.split("-").map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(" ");
1856
2002
  }
1857
- async function at(t) {
1858
- const e = ge(t);
1859
- if (e.help)
1860
- return we(), 0;
1861
- if (e.version)
2003
+ async function nt(e) {
2004
+ const t = fe(e);
2005
+ if (t.help)
1862
2006
  return be(), 0;
1863
- nt();
1864
- const n = e._[0];
2007
+ if (t.version)
2008
+ return Ee(), 0;
2009
+ ot();
2010
+ const n = t._[0];
1865
2011
  if (n === "blade" || n === "generate")
1866
- return await ot(e), 0;
1867
- const a = ye(e);
2012
+ return await it(t), 0;
2013
+ const a = he(t);
1868
2014
  if (a.length > 0)
1869
- throw new B(a);
1870
- return lt(), await st(e), 0;
2015
+ throw new V(a);
2016
+ return lt(), await st(t), 0;
1871
2017
  }
1872
- function nt() {
1873
- const t = Ee();
1874
- if (!t.compatible)
1875
- throw new O(
2018
+ function ot() {
2019
+ const e = ve();
2020
+ if (!e.compatible)
2021
+ throw new I(
1876
2022
  [
1877
- o.red(`❌ Node.js ${t.minVersion} or higher is required.`),
1878
- o.red(` Current version: ${t.currentVersion}`),
2023
+ o.red(`❌ Node.js ${e.minVersion} or higher is required.`),
2024
+ o.red(` Current version: ${e.currentVersion}`),
1879
2025
  o.yellow(`
1880
2026
  Please upgrade Node.js to continue.`)
1881
2027
  ].join(`
1882
2028
  `)
1883
2029
  );
1884
2030
  }
1885
- async function ot(t) {
1886
- const [, e] = t._;
1887
- await le({
1888
- name: e || t.name,
1889
- type: t.type,
1890
- module: t.module,
1891
- composable: t.composable,
1892
- locales: t.locales,
1893
- widget: t.widget,
1894
- isWorkspace: t["is-workspace"],
1895
- path: t.path,
1896
- formFields: t["form-fields"],
1897
- skipFormEditor: t["skip-form-editor"]
2031
+ async function it(e) {
2032
+ const [, t] = e._;
2033
+ await ie({
2034
+ name: t || e.name,
2035
+ type: e.type,
2036
+ module: e.module,
2037
+ composable: e.composable,
2038
+ locales: e.locales,
2039
+ widget: e.widget,
2040
+ isWorkspace: e["is-workspace"],
2041
+ path: e.path,
2042
+ formFields: e["form-fields"],
2043
+ skipFormEditor: e["skip-form-editor"],
2044
+ widgetModule: e["widget-module"],
2045
+ widgetBlade: e["widget-blade"],
2046
+ widgetName: e["widget-name"],
2047
+ widgetEntity: e["widget-entity"],
2048
+ widgetIcon: e["widget-icon"]
1898
2049
  });
1899
2050
  }
1900
- async function st(t) {
2051
+ async function st(e) {
1901
2052
  try {
1902
- const e = await qe({ args: t, cwd: _() });
1903
- rt(e.root, e.config.packageName, e.config.basePath, e.filesCreated), it(e.root);
1904
- } catch (e) {
1905
- if (e instanceof E) {
2053
+ const t = await Ue({ args: e, cwd: G() });
2054
+ rt(t.root, t.config.packageName, t.config.basePath, t.filesCreated), ct(t.root);
2055
+ } catch (t) {
2056
+ if (t instanceof $) {
1906
2057
  console.log(o.yellow(`
1907
2058
  ⚠️ Operation cancelled by user`)), console.log(o.gray(` No changes were made.
1908
2059
  `));
1909
2060
  return;
1910
2061
  }
1911
- throw e;
2062
+ throw t;
1912
2063
  }
1913
2064
  }
1914
2065
  function lt() {
1915
- const t = "═".repeat(50);
2066
+ const e = "═".repeat(50);
1916
2067
  console.log(o.bold(o.green(`
1917
- ╔${t}╗`))), console.log(o.bold(o.green(`║ create-vc-app v${U.version}${" ".repeat(33 - String(U.version).length)}║`))), console.log(o.bold(o.green(`╚${t}╝
2068
+ ╔${e}╗`))), console.log(o.bold(o.green(`║ create-vc-app v${U.version}${" ".repeat(33 - String(U.version).length)}║`))), console.log(o.bold(o.green(`╚${e}╝
1918
2069
  `)));
1919
2070
  }
1920
- function rt(t, e, n, a) {
2071
+ function rt(e, t, n, a) {
1921
2072
  console.log(o.green(`
1922
2073
  ${"=".repeat(50)}`)), console.log(o.green(o.bold("✨ Application created successfully!"))), console.log(o.green(`${"=".repeat(50)}
1923
- `)), console.log(o.cyan("📊 Summary:")), console.log(o.cyan(` Location: ${o.bold(t)}`)), console.log(o.cyan(` Package: ${o.bold(e)}`)), console.log(o.cyan(` Base path: ${o.bold(n)}`)), console.log(o.cyan(` Files created: ${o.bold(a.toString())}`));
2074
+ `)), console.log(o.cyan("📊 Summary:")), console.log(o.cyan(` Location: ${o.bold(e)}`)), console.log(o.cyan(` Package: ${o.bold(t)}`)), console.log(o.cyan(` Base path: ${o.bold(n)}`)), console.log(o.cyan(` Files created: ${o.bold(a.toString())}`));
1924
2075
  }
1925
- function it(t) {
2076
+ function ct(e) {
1926
2077
  console.log(o.cyan(`
1927
2078
  🚀 Next steps:
1928
2079
  `));
1929
- const e = _();
1930
- if (t !== e) {
1931
- const n = m.relative(e, t) || t, a = n.includes(" ") ? `"${n}"` : n;
2080
+ const t = G();
2081
+ if (e !== t) {
2082
+ const n = m.relative(t, e) || e, a = n.includes(" ") ? `"${n}"` : n;
1932
2083
  console.log(o.white(` 1. ${o.bold(o.cyan(`cd ${a}`))}`)), console.log(o.white(` 2. ${o.bold(o.cyan("yarn"))}`)), console.log(o.white(` 3. ${o.bold(o.cyan("yarn serve"))}`));
1933
2084
  } else
1934
2085
  console.log(o.white(` 1. ${o.bold(o.cyan("yarn"))}`)), console.log(o.white(` 2. ${o.bold(o.cyan("yarn serve"))}`));
1935
2086
  console.log(o.gray(`
1936
2087
  You can also run:`)), console.log(o.gray(" yarn build - Build for production")), console.log(o.gray(" yarn lint - Run linter")), console.log(o.gray(" create-vc-app blade - Generate modules/blades/widgets")), console.log();
1937
2088
  }
1938
- async function ct() {
2089
+ async function dt() {
1939
2090
  try {
1940
- await at(process.argv.slice(2));
1941
- } catch (t) {
1942
- dt(t);
2091
+ await nt(process.argv.slice(2));
2092
+ } catch (e) {
2093
+ mt(e);
1943
2094
  }
1944
2095
  }
1945
- function dt(t) {
1946
- if (t instanceof E && (console.log(o.yellow(`
2096
+ function mt(e) {
2097
+ if (e instanceof $ && (console.log(o.yellow(`
1947
2098
  ⚠️ Operation cancelled by user
1948
- `)), process.exit(0)), t instanceof B) {
1949
- if (t.issues?.length) {
2099
+ `)), process.exit(0)), e instanceof V) {
2100
+ if (e.issues?.length) {
1950
2101
  console.error(o.red(`
1951
2102
  ❌ Validation errors:
1952
2103
  `));
1953
- for (const n of t.issues)
2104
+ for (const n of e.issues)
1954
2105
  console.error(o.red(` • ${n}`));
1955
2106
  console.log(o.gray(`
1956
2107
  Run ${o.cyan("create-vc-app --help")} for usage information.
1957
2108
  `));
1958
2109
  }
1959
- process.exit(t.exitCode);
2110
+ process.exit(e.exitCode);
1960
2111
  }
1961
- t instanceof O && (console.error(t.message), process.exit(t.exitCode));
1962
- const e = t instanceof Error ? t.message : String(t);
2112
+ e instanceof I && (console.error(e.message), process.exit(e.exitCode));
2113
+ const t = e instanceof Error ? e.message : String(e);
1963
2114
  console.error(o.red(`
1964
- ❌ Unexpected error: ${e}`)), t instanceof Error && t.stack && console.error(o.gray(t.stack)), process.exit(1);
2115
+ ❌ Unexpected error: ${t}`)), e instanceof Error && e.stack && console.error(o.gray(e.stack)), process.exit(1);
1965
2116
  }
1966
- ct();
2117
+ dt();