@vc-shell/create-vc-app 1.1.99-alpha.1 → 1.1.99-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -5
- package/dist/cli/argv.d.ts.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/types.d.ts +5 -0
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/commands/generate-blade.d.ts +5 -0
- package/dist/commands/generate-blade.d.ts.map +1 -1
- package/dist/index.js +940 -789
- package/dist/templates/base/_package.json +5 -5
- package/dist/templates/blades/grid/blade.vue +329 -340
- package/dist/templates/composables/details-composable.ts +2 -0
- package/dist/templates/composables/grid-composable.ts +3 -1
- package/dist/utils/naming.d.ts +1 -0
- package/dist/utils/naming.d.ts.map +1 -1
- package/dist/utils/register-module.d.ts +4 -0
- package/dist/utils/register-module.d.ts.map +1 -1
- package/dist/utils/templates.d.ts +10 -0
- package/dist/utils/templates.d.ts.map +1 -0
- package/dist/workflows/create-app.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/templates/base/ai-guides/.cursorrules-vc-shell +0 -529
- package/dist/templates/base/ai-guides/README.md +0 -360
- package/dist/templates/base/ai-guides/guides/AI_GUIDE.md +0 -195
- package/dist/templates/base/ai-guides/guides/blade-patterns.md +0 -384
- package/dist/templates/base/ai-guides/guides/complete-workflow.md +0 -781
- package/dist/templates/base/ai-guides/guides/composables-reference.md +0 -338
- package/dist/templates/base/ai-guides/guides/troubleshooting.md +0 -529
- package/dist/templates/base/ai-guides/guides/ui-components-reference.md +0 -903
- package/dist/templates/base/ai-guides/prompts/adapt-existing-module.md +0 -1026
- package/dist/templates/base/ai-guides/prompts/advanced-scenarios.md +0 -852
- package/dist/templates/base/ai-guides/prompts/api-client-generation.md +0 -877
- package/dist/templates/base/ai-guides/prompts/cli-usage.md +0 -640
- package/dist/templates/base/ai-guides/prompts/quick-start-scenarios.md +0 -773
- 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
|
|
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
|
|
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
|
|
9
|
+
import { camelCase as F, snakeCase as v, upperFirst as T, kebabCase as C } from "lodash-es";
|
|
11
10
|
import pe from "pluralize";
|
|
12
|
-
|
|
13
|
-
|
|
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: [
|
|
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
|
|
33
|
-
return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(
|
|
47
|
+
function R(e) {
|
|
48
|
+
return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(e);
|
|
34
49
|
}
|
|
35
|
-
function
|
|
36
|
-
return
|
|
50
|
+
function O(e) {
|
|
51
|
+
return e.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
|
|
37
52
|
}
|
|
38
|
-
function
|
|
39
|
-
return
|
|
53
|
+
function X(e) {
|
|
54
|
+
return e.trim().toLowerCase().replace(/\/+/g, "/").replace(/[^a-z0-9/-]+/g, "/").replace(/\/?$/, "/");
|
|
40
55
|
}
|
|
41
|
-
function
|
|
42
|
-
return
|
|
56
|
+
function ye(e) {
|
|
57
|
+
return e.startsWith("/") && e.endsWith("/");
|
|
43
58
|
}
|
|
44
|
-
function
|
|
45
|
-
const
|
|
46
|
-
return
|
|
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
|
|
49
|
-
version:
|
|
63
|
+
const we = "1.1.99-alpha.10", U = {
|
|
64
|
+
version: we
|
|
50
65
|
};
|
|
51
|
-
function
|
|
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
|
|
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
|
|
138
|
-
const
|
|
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:
|
|
141
|
-
currentVersion:
|
|
164
|
+
compatible: t >= n,
|
|
165
|
+
currentVersion: e,
|
|
142
166
|
minVersion: Z
|
|
143
167
|
};
|
|
144
168
|
}
|
|
145
|
-
async function P(
|
|
169
|
+
async function P(e) {
|
|
146
170
|
try {
|
|
147
|
-
const
|
|
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
|
|
174
|
+
let i = null;
|
|
151
175
|
try {
|
|
152
|
-
|
|
176
|
+
i = await Y.resolveConfig(e, {
|
|
153
177
|
editorconfig: !0
|
|
154
178
|
});
|
|
155
179
|
} catch {
|
|
156
180
|
}
|
|
157
|
-
const
|
|
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
|
-
...
|
|
188
|
+
...i,
|
|
165
189
|
parser: a
|
|
166
190
|
// Always use detected parser
|
|
167
|
-
}, d = await Y.format(
|
|
168
|
-
|
|
169
|
-
} catch (
|
|
170
|
-
console.warn(o.yellow(`⚠️ Warning: Could not format ${
|
|
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
|
|
174
|
-
const n =
|
|
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
|
|
177
|
-
|
|
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(
|
|
181
|
-
const n = F(
|
|
204
|
+
function W(e, t) {
|
|
205
|
+
const n = F(e), a = pe(e), i = F(a);
|
|
182
206
|
return {
|
|
183
|
-
entitySingular:
|
|
207
|
+
entitySingular: e,
|
|
184
208
|
entityPlural: a,
|
|
185
|
-
moduleName:
|
|
209
|
+
moduleName: t,
|
|
186
210
|
entitySingularPascal: T(n),
|
|
187
211
|
entitySingularCamel: n,
|
|
188
|
-
entitySingularKebab:
|
|
189
|
-
entityPluralPascal: T(
|
|
190
|
-
entityPluralCamel:
|
|
191
|
-
entityPluralKebab:
|
|
192
|
-
|
|
193
|
-
|
|
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(
|
|
221
|
+
function z(e) {
|
|
197
222
|
return {
|
|
198
|
-
"{{EntityName}}":
|
|
199
|
-
"{{EntityNamePlural}}":
|
|
200
|
-
"{{entityName}}":
|
|
201
|
-
"{{entityNamePlural}}":
|
|
202
|
-
"{{entity-name}}":
|
|
203
|
-
"{{entity-name-plural}}":
|
|
204
|
-
"{{
|
|
205
|
-
"{{
|
|
206
|
-
"{{
|
|
207
|
-
"{{
|
|
208
|
-
"{{
|
|
209
|
-
"{{
|
|
210
|
-
"{{
|
|
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(
|
|
214
|
-
let n =
|
|
215
|
-
for (const [a,
|
|
216
|
-
n = n.replace(new RegExp(a, "g"),
|
|
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
|
|
220
|
-
return
|
|
245
|
+
function te(e) {
|
|
246
|
+
return e.replace(/'/g, "\\'").replace(/"/g, '\\"');
|
|
221
247
|
}
|
|
222
|
-
async function
|
|
223
|
-
const
|
|
224
|
-
let
|
|
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
|
-
`);
|
|
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
|
|
367
|
+
throw t = !1, new Error("cancelled");
|
|
342
368
|
}
|
|
343
369
|
}
|
|
344
370
|
);
|
|
345
371
|
if (!n.name) {
|
|
346
|
-
|
|
372
|
+
t = !1;
|
|
347
373
|
break;
|
|
348
374
|
}
|
|
349
|
-
|
|
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
|
-
}),
|
|
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
|
|
387
|
+
return e;
|
|
362
388
|
}
|
|
363
|
-
function q(
|
|
364
|
-
const n = v(
|
|
365
|
-
let
|
|
366
|
-
return
|
|
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('${
|
|
369
|
-
:model-value="item.${
|
|
370
|
-
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.${
|
|
376
|
-
:label="$t('${
|
|
377
|
-
:placeholder="$t('${
|
|
378
|
-
${
|
|
379
|
-
${
|
|
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
|
|
388
|
-
const n = v(
|
|
413
|
+
function Ie(e, t) {
|
|
414
|
+
const n = v(e.name).toUpperCase();
|
|
389
415
|
return ` <VcTextarea
|
|
390
|
-
v-model="item.${
|
|
391
|
-
:label="$t('${
|
|
392
|
-
:placeholder="$t('${
|
|
393
|
-
${
|
|
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
|
|
398
|
-
const n = v(
|
|
399
|
-
const
|
|
400
|
-
return `{ value: '${
|
|
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('${
|
|
405
|
-
:model-value="item.${
|
|
406
|
-
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.${
|
|
411
|
-
:label="$t('${
|
|
412
|
-
:placeholder="$t('${
|
|
413
|
-
:options="[${
|
|
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
|
-
${
|
|
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
|
|
426
|
-
const n = v(
|
|
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('${
|
|
430
|
-
:model-value="item.${
|
|
431
|
-
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.${
|
|
436
|
-
:label="$t('${
|
|
437
|
-
:placeholder="$t('${
|
|
438
|
-
${
|
|
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(
|
|
446
|
-
const n = v(
|
|
471
|
+
function xe(e, t) {
|
|
472
|
+
const n = v(e.name).toUpperCase();
|
|
447
473
|
return ` <VcSwitch
|
|
448
|
-
v-model="item.${
|
|
449
|
-
:label="$t('${
|
|
450
|
-
:tooltip="$t('${
|
|
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
|
|
456
|
-
const n = v(
|
|
457
|
-
return ` <VcCard :header="$t('${
|
|
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.${
|
|
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
|
|
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 '${
|
|
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, \`${
|
|
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(
|
|
518
|
-
const n = v(
|
|
543
|
+
function Pe(e, t) {
|
|
544
|
+
const n = v(e.name).toUpperCase();
|
|
519
545
|
return ` <VcField
|
|
520
|
-
:label="$t('${
|
|
521
|
-
:model-value="item.${
|
|
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
|
|
528
|
-
const n = v(
|
|
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('${
|
|
532
|
-
:model-value="item.${
|
|
533
|
-
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.${
|
|
539
|
-
:label="$t('${
|
|
540
|
-
${
|
|
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
|
|
549
|
-
const n = v(
|
|
550
|
-
const
|
|
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.${
|
|
553
|
-
value="${
|
|
554
|
-
:label="'${
|
|
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('${
|
|
562
|
-
:model-value="item.${
|
|
563
|
-
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
|
-
${
|
|
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
|
|
573
|
-
const n = v(
|
|
598
|
+
function De(e, t) {
|
|
599
|
+
const n = v(e.name).toUpperCase();
|
|
574
600
|
return ` <VcCheckbox
|
|
575
|
-
v-model="item.${
|
|
576
|
-
:label="$t('${
|
|
601
|
+
v-model="item.${e.name}"
|
|
602
|
+
:label="$t('${t}.PAGES.DETAILS.FORM.INFO.${n}')"
|
|
577
603
|
/>`;
|
|
578
604
|
}
|
|
579
|
-
function
|
|
580
|
-
const n = v(
|
|
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('${
|
|
585
|
-
:model-value="item.${
|
|
586
|
-
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.${
|
|
591
|
-
:label="$t('${
|
|
592
|
-
:placeholder="$t('${
|
|
593
|
-
${
|
|
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
|
|
601
|
-
return
|
|
602
|
-
(
|
|
626
|
+
function Le(e) {
|
|
627
|
+
return e.some(
|
|
628
|
+
(t) => t.type === "gallery"
|
|
603
629
|
/* Gallery */
|
|
604
630
|
);
|
|
605
631
|
}
|
|
606
|
-
function
|
|
607
|
-
return
|
|
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,
|
|
638
|
+
return q(n, t);
|
|
613
639
|
case "textarea":
|
|
614
|
-
return
|
|
640
|
+
return Ie(n, t);
|
|
615
641
|
case "select":
|
|
616
|
-
return
|
|
642
|
+
return Ae(n, t);
|
|
617
643
|
case "editor":
|
|
618
|
-
return
|
|
644
|
+
return Ne(n, t);
|
|
619
645
|
case "switch":
|
|
620
|
-
return xe(n,
|
|
646
|
+
return xe(n, t);
|
|
621
647
|
case "gallery":
|
|
622
|
-
return
|
|
648
|
+
return Ce(n, t);
|
|
623
649
|
case "data-field":
|
|
624
|
-
return Pe(n,
|
|
650
|
+
return Pe(n, t);
|
|
625
651
|
case "currency":
|
|
626
|
-
return
|
|
652
|
+
return Te(n, t);
|
|
627
653
|
case "radio":
|
|
628
|
-
return
|
|
654
|
+
return Fe(n, t);
|
|
629
655
|
case "checkbox":
|
|
630
|
-
return
|
|
656
|
+
return De(n, t);
|
|
631
657
|
case "multivalue":
|
|
632
|
-
return
|
|
658
|
+
return Me(n, t);
|
|
633
659
|
case "image":
|
|
634
660
|
return q({
|
|
635
661
|
...n,
|
|
636
662
|
type: "text"
|
|
637
663
|
/* Text */
|
|
638
|
-
},
|
|
664
|
+
}, t);
|
|
639
665
|
default:
|
|
640
|
-
return q(n,
|
|
666
|
+
return q(n, t);
|
|
641
667
|
}
|
|
642
668
|
}).join(`
|
|
643
669
|
|
|
644
670
|
`);
|
|
645
671
|
}
|
|
646
|
-
function
|
|
647
|
-
const
|
|
648
|
-
for (const n of
|
|
672
|
+
function j(e) {
|
|
673
|
+
const t = {};
|
|
674
|
+
for (const n of e) {
|
|
649
675
|
const a = v(n.name).toUpperCase();
|
|
650
|
-
|
|
676
|
+
t[a] = n.label || T(n.name);
|
|
651
677
|
}
|
|
652
|
-
return
|
|
678
|
+
return t;
|
|
653
679
|
}
|
|
654
|
-
function
|
|
680
|
+
function ne(e) {
|
|
655
681
|
return ` <Field
|
|
656
682
|
v-slot="{ field, errorMessage, handleChange, errors }"
|
|
657
|
-
:label="$t('${
|
|
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('${
|
|
666
|
-
:placeholder="$t('${
|
|
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('${
|
|
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
|
|
684
|
-
const a = m.join(
|
|
685
|
-
if (!
|
|
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
|
|
689
|
-
const
|
|
690
|
-
if (
|
|
691
|
-
return console.log(o.yellow(` Module ${
|
|
692
|
-
const
|
|
693
|
-
if (
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
${
|
|
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
|
|
699
|
-
|
|
700
|
-
` +
|
|
724
|
+
const c = i.search(/^import/m);
|
|
725
|
+
c !== -1 && (i = i.slice(0, c) + `${r}
|
|
726
|
+
` + i.slice(c));
|
|
701
727
|
}
|
|
702
|
-
const
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
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
|
-
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
`
|
|
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
|
|
714
|
-
if (
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
|
|
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
|
|
721
|
-
} catch (
|
|
722
|
-
return console.log(o.yellow(`⚠️ Failed to auto-register module: ${
|
|
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(
|
|
726
|
-
const n = m.join(
|
|
760
|
+
async function K(e, t) {
|
|
761
|
+
const n = m.join(e, "pages"), a = m.join(n, "index.ts");
|
|
727
762
|
try {
|
|
728
|
-
let
|
|
729
|
-
|
|
730
|
-
for (const
|
|
731
|
-
const
|
|
732
|
-
!
|
|
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
|
|
736
|
-
} catch (
|
|
737
|
-
return console.log(o.yellow(`⚠️ Failed to update pages/index.ts: ${
|
|
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
|
|
775
|
+
class I extends Error {
|
|
741
776
|
exitCode;
|
|
742
|
-
constructor(
|
|
743
|
-
super(
|
|
777
|
+
constructor(t, n = 1) {
|
|
778
|
+
super(t), this.name = "CLIError", this.exitCode = n;
|
|
744
779
|
}
|
|
745
780
|
}
|
|
746
|
-
class
|
|
781
|
+
class V extends I {
|
|
747
782
|
issues;
|
|
748
|
-
constructor(
|
|
749
|
-
super("Validation failed", 1), this.name = "ValidationError", this.issues =
|
|
783
|
+
constructor(t) {
|
|
784
|
+
super("Validation failed", 1), this.name = "ValidationError", this.issues = t;
|
|
750
785
|
}
|
|
751
786
|
}
|
|
752
|
-
class
|
|
787
|
+
class $ extends I {
|
|
753
788
|
constructor() {
|
|
754
789
|
super("Operation cancelled by user", 0), this.name = "UserCancelledError";
|
|
755
790
|
}
|
|
756
791
|
}
|
|
757
|
-
function
|
|
758
|
-
|
|
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
|
|
761
|
-
throw new
|
|
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
|
|
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
|
|
768
|
-
if (!
|
|
769
|
-
throw new
|
|
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
|
-
|
|
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
|
|
774
|
-
moduleName:
|
|
775
|
-
// Normalize to kebab-case
|
|
776
|
-
bladeType:
|
|
777
|
-
entityName:
|
|
778
|
-
isWorkspace:
|
|
779
|
-
includeComposable:
|
|
780
|
-
includeLocales:
|
|
781
|
-
formFields:
|
|
782
|
-
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 (
|
|
787
|
-
|
|
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
|
|
791
|
-
|
|
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
|
|
888
|
+
throw new $();
|
|
805
889
|
}
|
|
806
890
|
}
|
|
807
|
-
)).action,
|
|
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
|
|
810
|
-
throw new
|
|
811
|
-
if (a instanceof
|
|
893
|
+
if (a instanceof $)
|
|
894
|
+
throw new $();
|
|
895
|
+
if (a instanceof I)
|
|
812
896
|
throw a;
|
|
813
|
-
const
|
|
897
|
+
const i = a instanceof Error ? a.message : String(a), r = a instanceof Error && a.stack ? `
|
|
814
898
|
${a.stack}` : "";
|
|
815
|
-
throw new
|
|
816
|
-
❌ Generation failed: ${
|
|
817
|
-
${
|
|
899
|
+
throw new I(`
|
|
900
|
+
❌ Generation failed: ${i}${r ? `
|
|
901
|
+
${r}` : ""}`);
|
|
818
902
|
}
|
|
819
903
|
}
|
|
820
|
-
async function
|
|
821
|
-
const n = m.join(
|
|
822
|
-
if (!
|
|
823
|
-
console.log(o.cyan(`📦 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:
|
|
827
|
-
entitySingular:
|
|
910
|
+
moduleName: t.moduleName,
|
|
911
|
+
entitySingular: t.moduleName,
|
|
828
912
|
createBothBlades: !1,
|
|
829
|
-
createGridBlade:
|
|
830
|
-
createDetailsBlade:
|
|
831
|
-
gridIsWorkspace:
|
|
832
|
-
detailsIsWorkspace:
|
|
833
|
-
includeComposables:
|
|
834
|
-
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
|
|
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
|
|
842
|
-
let
|
|
843
|
-
if (
|
|
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
|
-
|
|
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
|
|
850
|
-
|
|
933
|
+
const f = await _(
|
|
934
|
+
s,
|
|
851
935
|
a,
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
936
|
+
t.bladeType,
|
|
937
|
+
r,
|
|
938
|
+
t.isWorkspace,
|
|
939
|
+
h,
|
|
940
|
+
u
|
|
857
941
|
);
|
|
858
|
-
if (d.push(
|
|
859
|
-
const y = await
|
|
860
|
-
l,
|
|
861
|
-
a,
|
|
862
|
-
e.bladeType,
|
|
942
|
+
if (d.push(f), t.includeComposable) {
|
|
943
|
+
const y = await B(
|
|
863
944
|
s,
|
|
864
|
-
|
|
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"),
|
|
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
|
-
|
|
953
|
+
l.existsSync(b) ? l.readFileSync(b, "utf-8").includes(w) || l.appendFileSync(b, w) : l.writeFileSync(b, w);
|
|
870
954
|
}
|
|
871
|
-
const
|
|
872
|
-
if (await K(a, [{ exportName:
|
|
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 (
|
|
875
|
-
const b = JSON.parse(
|
|
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,
|
|
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
|
|
972
|
+
async function je(e, t, n, a) {
|
|
889
973
|
console.log(o.cyan(`
|
|
890
974
|
📦 Creating new module
|
|
891
975
|
`));
|
|
892
|
-
let
|
|
976
|
+
let i;
|
|
893
977
|
{
|
|
894
|
-
let
|
|
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) =>
|
|
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
|
|
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 (
|
|
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
|
|
1030
|
+
throw new $();
|
|
947
1031
|
}
|
|
948
1032
|
}
|
|
949
1033
|
);
|
|
950
|
-
|
|
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
|
|
1056
|
+
throw new $();
|
|
973
1057
|
}
|
|
974
1058
|
}
|
|
975
1059
|
);
|
|
976
|
-
|
|
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 (
|
|
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
|
|
1072
|
+
throw new $();
|
|
989
1073
|
}
|
|
990
1074
|
}
|
|
991
1075
|
);
|
|
992
|
-
|
|
1076
|
+
s.customizeForm = d.customizeForm;
|
|
993
1077
|
}
|
|
994
|
-
|
|
1078
|
+
i = s;
|
|
995
1079
|
}
|
|
996
|
-
await
|
|
1080
|
+
await se(e, i, n, a);
|
|
997
1081
|
}
|
|
998
|
-
async function
|
|
1082
|
+
async function se(e, t, n, a) {
|
|
999
1083
|
try {
|
|
1000
|
-
const
|
|
1001
|
-
if (
|
|
1002
|
-
throw new
|
|
1003
|
-
`Module "${
|
|
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
|
-
|
|
1010
|
-
m.join(
|
|
1011
|
-
m.join(
|
|
1012
|
-
m.join(
|
|
1013
|
-
m.join(
|
|
1014
|
-
m.join(
|
|
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
|
|
1017
|
-
if (!
|
|
1100
|
+
for (const w of d)
|
|
1101
|
+
if (!l.existsSync(w))
|
|
1018
1102
|
try {
|
|
1019
|
-
|
|
1020
|
-
} catch (
|
|
1021
|
-
throw new Error(`Failed to create directory ${
|
|
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
|
|
1024
|
-
let
|
|
1025
|
-
if (
|
|
1026
|
-
const
|
|
1027
|
-
|
|
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
|
|
1030
|
-
if (
|
|
1113
|
+
let c = [];
|
|
1114
|
+
if (t.createDetailsBlade) {
|
|
1031
1115
|
if (n)
|
|
1032
1116
|
try {
|
|
1033
|
-
|
|
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
|
|
1038
|
-
const
|
|
1039
|
-
|
|
1040
|
-
|
|
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
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1126
|
+
r,
|
|
1127
|
+
t.detailsIsWorkspace,
|
|
1128
|
+
u,
|
|
1129
|
+
c
|
|
1046
1130
|
);
|
|
1047
|
-
|
|
1131
|
+
p.push(w);
|
|
1048
1132
|
}
|
|
1049
|
-
if (
|
|
1050
|
-
if (
|
|
1051
|
-
const
|
|
1052
|
-
|
|
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 (
|
|
1055
|
-
const
|
|
1056
|
-
|
|
1057
|
-
l,
|
|
1058
|
-
"details",
|
|
1138
|
+
if (t.createDetailsBlade) {
|
|
1139
|
+
const S = await B(
|
|
1140
|
+
h,
|
|
1059
1141
|
s,
|
|
1060
|
-
|
|
1142
|
+
"details",
|
|
1143
|
+
i,
|
|
1144
|
+
r
|
|
1061
1145
|
);
|
|
1062
|
-
|
|
1146
|
+
p.push(S);
|
|
1063
1147
|
}
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1148
|
+
const w = await Ve(s, t, i);
|
|
1149
|
+
p.push(w);
|
|
1066
1150
|
}
|
|
1067
|
-
if (
|
|
1068
|
-
const
|
|
1069
|
-
|
|
1070
|
-
const
|
|
1071
|
-
|
|
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
|
-
`),
|
|
1157
|
+
`), p.push(S);
|
|
1074
1158
|
}
|
|
1075
|
-
const
|
|
1076
|
-
|
|
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
|
-
`),
|
|
1167
|
+
`), p.push(g);
|
|
1084
1168
|
const b = [];
|
|
1085
|
-
|
|
1086
|
-
exportName: `${
|
|
1087
|
-
fileName:
|
|
1088
|
-
}),
|
|
1089
|
-
exportName: `${
|
|
1090
|
-
fileName: `${
|
|
1091
|
-
}), b.length > 0 && await K(
|
|
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
|
|
1095
|
-
await P(
|
|
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
|
|
1184
|
+
const E = await Re(e, t.moduleName, i.moduleNamePascal);
|
|
1101
1185
|
console.log(o.cyan(`
|
|
1102
|
-
📝 Next steps:`)),
|
|
1103
|
-
`))) : (console.log(o.cyan(" 1. Import the module in your main.ts:")), console.log(o.gray(` import ${
|
|
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 (
|
|
1189
|
+
} catch (i) {
|
|
1106
1190
|
throw console.error(o.red(`
|
|
1107
|
-
❌ Module generation failed:`),
|
|
1191
|
+
❌ Module generation failed:`), i.message), i;
|
|
1108
1192
|
}
|
|
1109
1193
|
}
|
|
1110
|
-
async function
|
|
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
|
|
1116
|
-
if (!
|
|
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 =
|
|
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((
|
|
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: (
|
|
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
|
|
1243
|
+
throw new $();
|
|
1160
1244
|
}
|
|
1161
1245
|
}
|
|
1162
1246
|
);
|
|
1163
|
-
let
|
|
1164
|
-
a.bladeType === "details" && (
|
|
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
|
|
1257
|
+
throw new $();
|
|
1174
1258
|
}
|
|
1175
1259
|
}
|
|
1176
1260
|
)).customizeForm);
|
|
1177
|
-
const
|
|
1178
|
-
let
|
|
1179
|
-
|
|
1180
|
-
const
|
|
1181
|
-
|
|
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
|
-
|
|
1268
|
+
s,
|
|
1185
1269
|
a.isWorkspace,
|
|
1186
|
-
|
|
1187
|
-
|
|
1270
|
+
u,
|
|
1271
|
+
c
|
|
1188
1272
|
);
|
|
1189
|
-
if (
|
|
1190
|
-
const
|
|
1191
|
-
|
|
1273
|
+
if (p.push(g), a.includeComposable) {
|
|
1274
|
+
const E = await B(
|
|
1275
|
+
h,
|
|
1192
1276
|
d,
|
|
1193
1277
|
a.bladeType,
|
|
1194
|
-
|
|
1195
|
-
|
|
1278
|
+
r,
|
|
1279
|
+
s
|
|
1196
1280
|
);
|
|
1197
|
-
|
|
1198
|
-
const
|
|
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
|
-
|
|
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(
|
|
1203
|
-
const
|
|
1204
|
-
if (
|
|
1205
|
-
const
|
|
1206
|
-
|
|
1207
|
-
...
|
|
1208
|
-
...
|
|
1209
|
-
},
|
|
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" ? `${
|
|
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
|
|
1217
|
-
await P(
|
|
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 (
|
|
1305
|
+
} catch (t) {
|
|
1222
1306
|
throw console.error(o.red(`
|
|
1223
|
-
❌ Blade generation failed:`),
|
|
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(
|
|
1342
|
+
async function Q(e) {
|
|
1227
1343
|
try {
|
|
1228
1344
|
console.log(o.cyan(`
|
|
1229
1345
|
🧩 Creating widget
|
|
1230
1346
|
`));
|
|
1231
|
-
const
|
|
1232
|
-
if (!
|
|
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 =
|
|
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((
|
|
1358
|
+
choices: n.map((p) => ({ title: p, value: p }))
|
|
1243
1359
|
},
|
|
1244
1360
|
{
|
|
1245
1361
|
onCancel: () => {
|
|
1246
|
-
throw new
|
|
1362
|
+
throw new $();
|
|
1247
1363
|
}
|
|
1248
1364
|
}
|
|
1249
|
-
),
|
|
1250
|
-
if (!
|
|
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
|
|
1253
|
-
if (
|
|
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:
|
|
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: (
|
|
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: (
|
|
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
|
|
1408
|
+
throw new $();
|
|
1293
1409
|
}
|
|
1294
1410
|
}
|
|
1295
1411
|
);
|
|
1296
|
-
let
|
|
1297
|
-
|
|
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: (
|
|
1418
|
+
validate: (u) => u.length > 0 ? !0 : "Icon is required"
|
|
1303
1419
|
},
|
|
1304
1420
|
{
|
|
1305
1421
|
onCancel: () => {
|
|
1306
|
-
throw new
|
|
1422
|
+
throw new $();
|
|
1307
1423
|
}
|
|
1308
1424
|
}
|
|
1309
|
-
)).customIcon), await
|
|
1310
|
-
} catch (
|
|
1425
|
+
)).customIcon), await le(i, d, h, a.moduleName);
|
|
1426
|
+
} catch (t) {
|
|
1311
1427
|
throw console.error(o.red(`
|
|
1312
|
-
❌ Widget generation failed:`),
|
|
1428
|
+
❌ Widget generation failed:`), t.message), t;
|
|
1313
1429
|
}
|
|
1314
1430
|
}
|
|
1315
|
-
async function
|
|
1431
|
+
async function le(e, t, n, a) {
|
|
1316
1432
|
try {
|
|
1317
|
-
const
|
|
1318
|
-
if (!
|
|
1319
|
-
throw new Error(`Widget template not found at ${
|
|
1320
|
-
const d =
|
|
1321
|
-
if (!
|
|
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
|
-
|
|
1324
|
-
} catch (
|
|
1325
|
-
throw new Error(`Failed to create widget directory: ${
|
|
1439
|
+
l.mkdirSync(u, { recursive: !0 });
|
|
1440
|
+
} catch (N) {
|
|
1441
|
+
throw new Error(`Failed to create widget directory: ${N.message}`);
|
|
1326
1442
|
}
|
|
1327
|
-
let
|
|
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(
|
|
1446
|
+
"{{WIDGET_NAME_UPPERCASE}}": v(t.widgetName).toUpperCase(),
|
|
1331
1447
|
"{{WIDGET_ICON}}": n,
|
|
1332
|
-
"{{EntityName}}":
|
|
1333
|
-
"{{entityName}}":
|
|
1334
|
-
"{{ParentEntity}}": T(F(
|
|
1335
|
-
"{{parentEntityCamel}}": F(
|
|
1336
|
-
"{{BladeName}}": `${
|
|
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
|
-
|
|
1339
|
-
const b = `${T(F(
|
|
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
|
-
|
|
1342
|
-
const
|
|
1457
|
+
l.writeFileSync(c, E);
|
|
1458
|
+
const w = m.join(p, "index.ts"), S = `export * from "./${C(t.widgetName)}";
|
|
1343
1459
|
`;
|
|
1344
|
-
|
|
1345
|
-
const
|
|
1346
|
-
if (
|
|
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
|
|
1464
|
+
const N = JSON.parse(l.readFileSync(A, "utf-8")), M = Object.keys(N)[0];
|
|
1349
1465
|
if (M) {
|
|
1350
|
-
|
|
1351
|
-
const J = v(
|
|
1352
|
-
|
|
1353
|
-
TITLE: T(
|
|
1354
|
-
}),
|
|
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 (
|
|
1357
|
-
console.warn(o.yellow(`⚠️ Could not update locales: ${
|
|
1472
|
+
} catch (N) {
|
|
1473
|
+
console.warn(o.yellow(`⚠️ Could not update locales: ${N.message}`));
|
|
1358
1474
|
}
|
|
1359
|
-
const D = m.join(
|
|
1360
|
-
if (
|
|
1475
|
+
const D = m.join(e, "pages", `${t.bladeName}.vue`);
|
|
1476
|
+
if (l.existsSync(D))
|
|
1361
1477
|
try {
|
|
1362
|
-
await
|
|
1363
|
-
} catch (
|
|
1364
|
-
console.warn(o.yellow(`⚠️ Could not auto-register widget in blade: ${
|
|
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(
|
|
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 (
|
|
1486
|
+
} catch (i) {
|
|
1371
1487
|
throw console.error(o.red(`
|
|
1372
|
-
❌ Widget file creation failed:`),
|
|
1488
|
+
❌ Widget file creation failed:`), i.message), i;
|
|
1373
1489
|
}
|
|
1374
1490
|
}
|
|
1375
|
-
async function
|
|
1376
|
-
let a =
|
|
1491
|
+
async function Ge(e, t, n) {
|
|
1492
|
+
let a = l.readFileSync(e, "utf-8");
|
|
1377
1493
|
if (!new RegExp(
|
|
1378
|
-
`import\\s*\\{[^}]*\\b${
|
|
1494
|
+
`import\\s*\\{[^}]*\\b${t}\\b[^}]*\\}\\s*from\\s*["']\\.\\./components/widgets["']`
|
|
1379
1495
|
).test(a)) {
|
|
1380
|
-
const
|
|
1381
|
-
if (
|
|
1382
|
-
const
|
|
1383
|
-
if (!
|
|
1384
|
-
|
|
1385
|
-
const y =
|
|
1386
|
-
a = a.replace(
|
|
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
|
|
1390
|
-
if (
|
|
1391
|
-
const
|
|
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],
|
|
1394
|
-
a = a.slice(0,
|
|
1395
|
-
import { ${
|
|
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,
|
|
1398
|
-
import { ${
|
|
1399
|
-
` + a.slice(
|
|
1513
|
+
a = a.slice(0, g) + `
|
|
1514
|
+
import { ${t} } from "../components/widgets";
|
|
1515
|
+
` + a.slice(g);
|
|
1400
1516
|
}
|
|
1401
1517
|
}
|
|
1402
1518
|
}
|
|
1403
|
-
const
|
|
1519
|
+
const r = `${t}`, s = ` registerWidget(
|
|
1404
1520
|
{
|
|
1405
|
-
id: "${
|
|
1406
|
-
component: ${
|
|
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
|
|
1415
|
-
let
|
|
1416
|
-
for (let y =
|
|
1417
|
-
a[y] === "{" &&
|
|
1418
|
-
a = a.slice(0,
|
|
1419
|
-
` +
|
|
1420
|
-
` + a.slice(
|
|
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
|
|
1423
|
-
if (
|
|
1424
|
-
const
|
|
1538
|
+
const f = a.match(/defineExpose\s*\(/);
|
|
1539
|
+
if (f) {
|
|
1540
|
+
const c = a.indexOf(f[0]), g = `
|
|
1425
1541
|
function registerWidgets() {
|
|
1426
|
-
${
|
|
1542
|
+
${s}
|
|
1427
1543
|
}
|
|
1428
1544
|
|
|
1429
1545
|
registerWidgets();
|
|
1430
1546
|
|
|
1431
1547
|
`;
|
|
1432
|
-
a = a.slice(0,
|
|
1548
|
+
a = a.slice(0, c) + g + a.slice(c);
|
|
1433
1549
|
} else {
|
|
1434
|
-
const
|
|
1435
|
-
if (
|
|
1436
|
-
const
|
|
1550
|
+
const c = a.match(/<\/script>/);
|
|
1551
|
+
if (c) {
|
|
1552
|
+
const g = a.indexOf(c[0]), y = `
|
|
1437
1553
|
function registerWidgets() {
|
|
1438
|
-
${
|
|
1554
|
+
${s}
|
|
1439
1555
|
}
|
|
1440
1556
|
|
|
1441
1557
|
registerWidgets();
|
|
1442
1558
|
|
|
1443
1559
|
`;
|
|
1444
|
-
a = a.slice(0,
|
|
1560
|
+
a = a.slice(0, g) + y + a.slice(g);
|
|
1445
1561
|
}
|
|
1446
1562
|
}
|
|
1447
1563
|
}
|
|
1448
|
-
const
|
|
1449
|
-
if (
|
|
1450
|
-
const
|
|
1451
|
-
a = a.slice(0,
|
|
1452
|
-
` +
|
|
1453
|
-
` + a.slice(
|
|
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
|
|
1456
|
-
if (
|
|
1457
|
-
const
|
|
1571
|
+
const f = a.match(/defineExpose\s*\(/);
|
|
1572
|
+
if (f) {
|
|
1573
|
+
const c = a.indexOf(f[0]), g = `
|
|
1458
1574
|
onBeforeUnmount(() => {
|
|
1459
|
-
${
|
|
1575
|
+
${h}
|
|
1460
1576
|
});
|
|
1461
1577
|
|
|
1462
1578
|
`;
|
|
1463
|
-
a = a.slice(0,
|
|
1579
|
+
a = a.slice(0, c) + g + a.slice(c);
|
|
1464
1580
|
}
|
|
1465
1581
|
}
|
|
1466
|
-
const
|
|
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:
|
|
1474
|
-
const
|
|
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
|
|
1477
|
-
if (
|
|
1478
|
-
|
|
1479
|
-
const
|
|
1480
|
-
a = a.replace(
|
|
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
|
|
1484
|
-
if (
|
|
1485
|
-
const
|
|
1486
|
-
if (
|
|
1487
|
-
const
|
|
1488
|
-
a = a.slice(0,
|
|
1489
|
-
` + a.slice(
|
|
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,
|
|
1492
|
-
import { ${
|
|
1493
|
-
` + a.slice(
|
|
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
|
|
1614
|
+
const f = `
|
|
1499
1615
|
const blade = useBlade();
|
|
1500
|
-
`,
|
|
1501
|
-
if (
|
|
1502
|
-
const
|
|
1503
|
-
a = a.slice(0, 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
|
|
1623
|
+
const f = `
|
|
1508
1624
|
const { registerWidget, unregisterWidget } = useWidgets();
|
|
1509
|
-
`,
|
|
1510
|
-
if (
|
|
1511
|
-
const
|
|
1512
|
-
a = a.slice(0,
|
|
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
|
-
|
|
1631
|
+
l.writeFileSync(e, a);
|
|
1516
1632
|
}
|
|
1517
|
-
function
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
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
|
-
)) : (
|
|
1533
|
-
|
|
1534
|
-
|
|
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
|
|
1537
|
-
|
|
1682
|
+
const c = ne(a["{{MODULE_NAME_UPPERCASE}}"]);
|
|
1683
|
+
u = u.replace(/\{\{FORM_FIELDS\}\}/g, c);
|
|
1538
1684
|
}
|
|
1539
|
-
if (
|
|
1540
|
-
|
|
1685
|
+
if (s && Le(s)) {
|
|
1686
|
+
u = u.replace(/\{\{GALLERY_IMPORTS\}\}/g, `
|
|
1541
1687
|
useAssets,
|
|
1542
1688
|
ICommonAsset,`);
|
|
1543
|
-
const
|
|
1544
|
-
|
|
1689
|
+
const c = Oe(a["{{entityName}}"]);
|
|
1690
|
+
u = u.replace(/\{\{GALLERY_SCRIPT_ADDITIONS\}\}/g, c);
|
|
1545
1691
|
} else
|
|
1546
|
-
|
|
1692
|
+
u = u.replace(/\{\{GALLERY_IMPORTS\}\}/g, ""), u = u.replace(/\{\{GALLERY_SCRIPT_ADDITIONS\}\}/g, "");
|
|
1547
1693
|
}
|
|
1548
|
-
return
|
|
1549
|
-
}
|
|
1550
|
-
async function
|
|
1551
|
-
const
|
|
1552
|
-
|
|
1553
|
-
let
|
|
1554
|
-
return
|
|
1555
|
-
}
|
|
1556
|
-
function We(
|
|
1557
|
-
const
|
|
1558
|
-
return
|
|
1559
|
-
}
|
|
1560
|
-
async function
|
|
1561
|
-
const a = m.join(
|
|
1562
|
-
let
|
|
1563
|
-
return
|
|
1564
|
-
`),
|
|
1565
|
-
`),
|
|
1566
|
-
}
|
|
1567
|
-
async function
|
|
1568
|
-
const
|
|
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 ${
|
|
1717
|
+
NAME_PLACEHOLDER: `Enter ${t.entitySingularCamel} name`,
|
|
1572
1718
|
CREATED_DATE: "Created Date"
|
|
1573
|
-
},
|
|
1574
|
-
[
|
|
1719
|
+
}, s = a && Object.keys(a).length > 0 ? { TITLE: "Information", ...a } : r, d = {
|
|
1720
|
+
[t.moduleNameUpperSnake]: {
|
|
1575
1721
|
MENU: {
|
|
1576
|
-
TITLE:
|
|
1722
|
+
TITLE: t.entityPluralPascal
|
|
1577
1723
|
},
|
|
1578
1724
|
PAGES: {
|
|
1579
1725
|
LIST: {
|
|
1580
|
-
TITLE:
|
|
1726
|
+
TITLE: t.entityPluralPascal,
|
|
1581
1727
|
SEARCH: {
|
|
1582
|
-
PLACEHOLDER: `Search ${
|
|
1728
|
+
PLACEHOLDER: `Search ${t.entityPluralCamel}...`
|
|
1583
1729
|
},
|
|
1584
1730
|
TOOLBAR: {
|
|
1585
1731
|
REFRESH: "Refresh",
|
|
1586
|
-
ADD: `Add ${
|
|
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} ${
|
|
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 ${
|
|
1613
|
-
ADD: `Add ${
|
|
1758
|
+
NO_ITEMS: `No ${t.entityPluralCamel} yet`,
|
|
1759
|
+
ADD: `Add ${t.entitySingularPascal}`
|
|
1614
1760
|
},
|
|
1615
1761
|
NOT_FOUND: {
|
|
1616
|
-
EMPTY: `No ${
|
|
1762
|
+
EMPTY: `No ${t.entityPluralCamel} found`,
|
|
1617
1763
|
RESET: "Reset search"
|
|
1618
1764
|
}
|
|
1619
1765
|
},
|
|
1620
1766
|
DETAILS: {
|
|
1621
|
-
TITLE: `New ${
|
|
1767
|
+
TITLE: `New ${t.entitySingularPascal}`,
|
|
1622
1768
|
TOOLBAR: {
|
|
1623
1769
|
SAVE: "Save",
|
|
1624
1770
|
DELETE: "Delete"
|
|
1625
1771
|
},
|
|
1626
1772
|
FORM: {
|
|
1627
|
-
INFO:
|
|
1773
|
+
INFO: s
|
|
1628
1774
|
}
|
|
1629
1775
|
},
|
|
1630
1776
|
ALERTS: {
|
|
1631
|
-
DELETE: `Are you sure you want to delete this ${
|
|
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} ${
|
|
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
|
|
1788
|
+
return l.writeFileSync(i, JSON.stringify(d, null, 2)), console.log(o.green("✓ Created locales file")), i;
|
|
1643
1789
|
}
|
|
1644
|
-
async function
|
|
1645
|
-
const { args:
|
|
1646
|
-
args:
|
|
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: ${
|
|
1652
|
-
const d = a === "." ? n : m.join(n,
|
|
1653
|
-
|
|
1654
|
-
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
|
|
1803
|
+
const h = Je(s), p = Ye({
|
|
1658
1804
|
templateName: "base",
|
|
1659
1805
|
targetDirectory: d,
|
|
1660
|
-
replacements:
|
|
1806
|
+
replacements: h
|
|
1661
1807
|
});
|
|
1662
|
-
return console.log(o.green(`✅ Created ${
|
|
1663
|
-
🎨 Formatting files with Prettier...`)), await
|
|
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:
|
|
1666
|
-
config:
|
|
1811
|
+
filesCreated: p,
|
|
1812
|
+
config: s
|
|
1667
1813
|
};
|
|
1668
1814
|
}
|
|
1669
|
-
async function
|
|
1670
|
-
const { args:
|
|
1815
|
+
async function ze(e) {
|
|
1816
|
+
const { args: t, defaultAppName: n, hasAllArgs: a } = e;
|
|
1671
1817
|
if (a) {
|
|
1672
|
-
const
|
|
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:
|
|
1675
|
-
packageName:
|
|
1820
|
+
appName: i,
|
|
1821
|
+
packageName: s,
|
|
1676
1822
|
moduleName: "",
|
|
1677
1823
|
basePath: d
|
|
1678
1824
|
};
|
|
1679
1825
|
}
|
|
1680
|
-
return
|
|
1826
|
+
return He(n);
|
|
1681
1827
|
}
|
|
1682
|
-
async function
|
|
1683
|
-
let
|
|
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:
|
|
1692
|
-
onState: (
|
|
1693
|
-
|
|
1837
|
+
initial: e,
|
|
1838
|
+
onState: (s) => {
|
|
1839
|
+
t = O(String(s.value).trim()) || e;
|
|
1694
1840
|
},
|
|
1695
|
-
format: (
|
|
1841
|
+
format: (s) => O(String(s).trim())
|
|
1696
1842
|
},
|
|
1697
1843
|
{
|
|
1698
|
-
type: () => !
|
|
1844
|
+
type: () => !l.existsSync(t) || de(t) ? null : "confirm",
|
|
1699
1845
|
name: "overwrite",
|
|
1700
|
-
message: () => (
|
|
1846
|
+
message: () => (t === "." ? "Current directory" : `Target directory "${t}"`) + " is not empty. Remove existing files and continue?"
|
|
1701
1847
|
},
|
|
1702
1848
|
{
|
|
1703
|
-
type: (
|
|
1849
|
+
type: (s, { overwrite: d }) => {
|
|
1704
1850
|
if (d === !1)
|
|
1705
|
-
throw new
|
|
1851
|
+
throw new $();
|
|
1706
1852
|
return null;
|
|
1707
1853
|
},
|
|
1708
1854
|
name: "overwriteChecker"
|
|
1709
1855
|
},
|
|
1710
1856
|
{
|
|
1711
1857
|
name: "packageName",
|
|
1712
|
-
type: () =>
|
|
1858
|
+
type: () => R(t) ? null : "text",
|
|
1713
1859
|
message: o.reset("Package name:"),
|
|
1714
|
-
initial: () =>
|
|
1715
|
-
validate: (
|
|
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/${
|
|
1722
|
-
format: (
|
|
1867
|
+
initial: () => `/apps/${O(t)}/`,
|
|
1868
|
+
format: (s) => X(String(s).trim())
|
|
1723
1869
|
}
|
|
1724
1870
|
],
|
|
1725
1871
|
{
|
|
1726
1872
|
onCancel: () => {
|
|
1727
|
-
throw new
|
|
1873
|
+
throw new $();
|
|
1728
1874
|
}
|
|
1729
1875
|
}
|
|
1730
|
-
), a = n.appName ||
|
|
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:
|
|
1879
|
+
packageName: i,
|
|
1734
1880
|
moduleName: "",
|
|
1735
|
-
basePath:
|
|
1881
|
+
basePath: r
|
|
1736
1882
|
};
|
|
1737
1883
|
} catch (n) {
|
|
1738
|
-
if (n instanceof
|
|
1884
|
+
if (n instanceof $)
|
|
1739
1885
|
throw n;
|
|
1740
1886
|
const a = n;
|
|
1741
|
-
throw new
|
|
1887
|
+
throw new V([a.message]);
|
|
1742
1888
|
}
|
|
1743
1889
|
}
|
|
1744
|
-
function
|
|
1745
|
-
if (
|
|
1746
|
-
if (!de(
|
|
1747
|
-
throw new
|
|
1748
|
-
`Target directory "${
|
|
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(
|
|
1896
|
+
ce(e);
|
|
1751
1897
|
} else
|
|
1752
|
-
|
|
1898
|
+
l.mkdirSync(e, { recursive: !0 });
|
|
1753
1899
|
}
|
|
1754
|
-
function
|
|
1900
|
+
function Je(e) {
|
|
1755
1901
|
return /* @__PURE__ */ new Map([
|
|
1756
|
-
["{{AppName}}",
|
|
1757
|
-
["{{AppNameSentenceCase}}",
|
|
1758
|
-
["{{BasePath}}",
|
|
1759
|
-
["{{PackageName}}",
|
|
1902
|
+
["{{AppName}}", e.appName],
|
|
1903
|
+
["{{AppNameSentenceCase}}", at(e.appName)],
|
|
1904
|
+
["{{BasePath}}", e.basePath],
|
|
1905
|
+
["{{PackageName}}", e.packageName]
|
|
1760
1906
|
]);
|
|
1761
1907
|
}
|
|
1762
|
-
function
|
|
1763
|
-
const
|
|
1908
|
+
function Ye(e) {
|
|
1909
|
+
const t = L(import.meta.url), n = m.join(t, e.templateName);
|
|
1764
1910
|
let a = 0;
|
|
1765
|
-
return
|
|
1766
|
-
const
|
|
1767
|
-
if (
|
|
1768
|
-
|
|
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
|
|
1772
|
-
if (
|
|
1773
|
-
|
|
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
|
|
1776
|
-
|
|
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
|
|
1782
|
-
const a =
|
|
1783
|
-
for (const
|
|
1784
|
-
const
|
|
1785
|
-
|
|
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
|
|
1789
|
-
let n =
|
|
1790
|
-
for (const [a,
|
|
1791
|
-
const
|
|
1792
|
-
n = n.replace(
|
|
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
|
|
1797
|
-
let n =
|
|
1798
|
-
for (const [a,
|
|
1799
|
-
const
|
|
1800
|
-
n = n.replace(
|
|
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
|
|
1805
|
-
const
|
|
1806
|
-
return [".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico", ".pdf", ".zip"].includes(
|
|
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(
|
|
1809
|
-
if (
|
|
1810
|
-
for (const
|
|
1811
|
-
const n = m.join(
|
|
1812
|
-
|
|
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(
|
|
1816
|
-
const
|
|
1817
|
-
return
|
|
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
|
|
1965
|
+
async function et(e) {
|
|
1820
1966
|
try {
|
|
1821
|
-
await
|
|
1822
|
-
} catch (
|
|
1823
|
-
console.log(o.yellow(`⚠️ Some files could not be formatted: ${
|
|
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
|
|
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
|
|
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:
|
|
1840
|
-
formFields:
|
|
1841
|
-
skipFormEditor:
|
|
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
|
|
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
|
|
1855
|
-
return
|
|
2000
|
+
function at(e) {
|
|
2001
|
+
return e.split("-").map((t) => t.charAt(0).toUpperCase() + t.slice(1)).join(" ");
|
|
1856
2002
|
}
|
|
1857
|
-
async function
|
|
1858
|
-
const
|
|
1859
|
-
if (
|
|
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
|
-
|
|
1864
|
-
|
|
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
|
|
1867
|
-
const a =
|
|
2012
|
+
return await it(t), 0;
|
|
2013
|
+
const a = he(t);
|
|
1868
2014
|
if (a.length > 0)
|
|
1869
|
-
throw new
|
|
1870
|
-
return lt(), await st(
|
|
2015
|
+
throw new V(a);
|
|
2016
|
+
return lt(), await st(t), 0;
|
|
1871
2017
|
}
|
|
1872
|
-
function
|
|
1873
|
-
const
|
|
1874
|
-
if (!
|
|
1875
|
-
throw new
|
|
2018
|
+
function ot() {
|
|
2019
|
+
const e = ve();
|
|
2020
|
+
if (!e.compatible)
|
|
2021
|
+
throw new I(
|
|
1876
2022
|
[
|
|
1877
|
-
o.red(`❌ Node.js ${
|
|
1878
|
-
o.red(` Current version: ${
|
|
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
|
|
1886
|
-
const [,
|
|
1887
|
-
await
|
|
1888
|
-
name:
|
|
1889
|
-
type:
|
|
1890
|
-
module:
|
|
1891
|
-
composable:
|
|
1892
|
-
locales:
|
|
1893
|
-
widget:
|
|
1894
|
-
isWorkspace:
|
|
1895
|
-
path:
|
|
1896
|
-
formFields:
|
|
1897
|
-
skipFormEditor:
|
|
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(
|
|
2051
|
+
async function st(e) {
|
|
1901
2052
|
try {
|
|
1902
|
-
const
|
|
1903
|
-
rt(
|
|
1904
|
-
} catch (
|
|
1905
|
-
if (
|
|
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
|
|
2062
|
+
throw t;
|
|
1912
2063
|
}
|
|
1913
2064
|
}
|
|
1914
2065
|
function lt() {
|
|
1915
|
-
const
|
|
2066
|
+
const e = "═".repeat(50);
|
|
1916
2067
|
console.log(o.bold(o.green(`
|
|
1917
|
-
╔${
|
|
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(
|
|
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(
|
|
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
|
|
2076
|
+
function ct(e) {
|
|
1926
2077
|
console.log(o.cyan(`
|
|
1927
2078
|
🚀 Next steps:
|
|
1928
2079
|
`));
|
|
1929
|
-
const
|
|
1930
|
-
if (
|
|
1931
|
-
const n = m.relative(
|
|
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
|
|
2089
|
+
async function dt() {
|
|
1939
2090
|
try {
|
|
1940
|
-
await
|
|
1941
|
-
} catch (
|
|
1942
|
-
|
|
2091
|
+
await nt(process.argv.slice(2));
|
|
2092
|
+
} catch (e) {
|
|
2093
|
+
mt(e);
|
|
1943
2094
|
}
|
|
1944
2095
|
}
|
|
1945
|
-
function
|
|
1946
|
-
if (
|
|
2096
|
+
function mt(e) {
|
|
2097
|
+
if (e instanceof $ && (console.log(o.yellow(`
|
|
1947
2098
|
⚠️ Operation cancelled by user
|
|
1948
|
-
`)), process.exit(0)),
|
|
1949
|
-
if (
|
|
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
|
|
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(
|
|
2110
|
+
process.exit(e.exitCode);
|
|
1960
2111
|
}
|
|
1961
|
-
|
|
1962
|
-
const
|
|
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: ${
|
|
2115
|
+
❌ Unexpected error: ${t}`)), e instanceof Error && e.stack && console.error(o.gray(e.stack)), process.exit(1);
|
|
1965
2116
|
}
|
|
1966
|
-
|
|
2117
|
+
dt();
|