@vc-shell/create-vc-app 2.0.0-alpha.15 → 2.0.0-alpha.17
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/CHANGELOG.md +22 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.test.d.ts +2 -0
- package/dist/commands/init.test.d.ts.map +1 -0
- package/dist/engine/codegen.d.ts.map +1 -1
- package/dist/engine/helpers.d.ts +1 -1
- package/dist/engine/helpers.d.ts.map +1 -1
- package/dist/engine/helpers.test.d.ts +2 -0
- package/dist/engine/helpers.test.d.ts.map +1 -0
- package/dist/engine/template.d.ts.map +1 -1
- package/dist/engine/template.test.d.ts +2 -0
- package/dist/engine/template.test.d.ts.map +1 -0
- package/dist/index.js +169 -165
- package/dist/output.d.ts.map +1 -1
- package/dist/templates/dynamic-module/_package.json.ejs +6 -6
- package/dist/templates/dynamic-module/src/modules/index.ts.ejs +8 -5
- package/dist/templates/dynamic-module/tsconfig.json +1 -1
- package/dist/templates/host-app/_package.json.ejs +7 -9
- package/dist/templates/host-app/src/main.ts.ejs +17 -15
- package/dist/templates/host-app/tsconfig.json +1 -0
- package/dist/templates/module/composables/useDetails.ts.ejs +41 -38
- package/dist/templates/module/index.ts.ejs +11 -8
- package/dist/templates/module/locales/en.json.ejs +33 -22
- package/dist/templates/module/pages/details.vue.ejs +10 -12
- package/dist/templates/module/pages/list.vue.ejs +11 -13
- package/dist/templates/sample-module/index.ts +11 -8
- package/dist/templates/sample-module/pages/details.vue +8 -4
- package/dist/templates/sample-module/pages/list.vue +103 -119
- package/dist/templates/standalone/_package.json.ejs +7 -9
- package/dist/templates/standalone/src/bootstrap.ts.ejs +5 -5
- package/dist/templates/standalone/src/main.ts.ejs +29 -23
- package/dist/templates/standalone/tsconfig.json +1 -0
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
- package/dist/templates/host-app/src/shims-vue.d.ts +0 -27
- package/dist/templates/host-app/src/vue-i18n.d.ts +0 -10
- package/dist/templates/standalone/src/shims-vue.d.ts +0 -27
- package/dist/templates/standalone/src/vue-i18n.d.ts +0 -10
package/dist/index.js
CHANGED
|
@@ -1,52 +1,53 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import z from "mri";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import t from "picocolors";
|
|
4
|
+
import c from "node:path";
|
|
5
5
|
import { exit as U, argv as L } from "node:process";
|
|
6
6
|
import { fileURLToPath as B } from "node:url";
|
|
7
7
|
import A from "prompts";
|
|
8
8
|
import r from "node:fs";
|
|
9
9
|
import T from "ejs";
|
|
10
|
-
const F = "2.0.0-alpha.
|
|
10
|
+
const F = "2.0.0-alpha.17", O = {
|
|
11
11
|
version: F
|
|
12
12
|
};
|
|
13
|
-
function
|
|
13
|
+
function h(e) {
|
|
14
14
|
return e.trim().replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase().replace(/[^a-z0-9-]/g, "");
|
|
15
15
|
}
|
|
16
16
|
function x(e) {
|
|
17
|
-
return e.replace(/[-_\s]+(.)?/g, (n,
|
|
17
|
+
return e.replace(/[-_\s]+(.)?/g, (n, a) => a ? a.toUpperCase() : "").replace(/^(.)/, (n, a) => a.toUpperCase());
|
|
18
18
|
}
|
|
19
19
|
function V(e) {
|
|
20
20
|
const n = x(e);
|
|
21
21
|
return n.charAt(0).toLowerCase() + n.slice(1);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function E(e) {
|
|
24
24
|
return e.replace(/[-\s]+/g, "_").replace(/([a-z])([A-Z])/g, "$1_$2").toUpperCase();
|
|
25
25
|
}
|
|
26
|
-
function
|
|
26
|
+
function S(e) {
|
|
27
27
|
return e.replace(/[-_]+/g, " ").replace(/\b\w/g, (n) => n.toUpperCase());
|
|
28
28
|
}
|
|
29
29
|
function k(e) {
|
|
30
30
|
return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(e);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
32
|
+
function C(e) {
|
|
33
33
|
return e.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function _(e) {
|
|
36
36
|
return e.trim().toLowerCase().replace(/\/+/g, "/").replace(/[^a-z0-9/-]+/g, "/").replace(/\/?$/, "/");
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
const n = e.moduleName,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
function D(e) {
|
|
39
|
+
const n = e.moduleName || "", a = n ? h(n) : "", s = {
|
|
40
|
+
hasModule: !!e.moduleName,
|
|
41
|
+
ModuleName: a,
|
|
42
|
+
ModuleNamePascalCase: n ? x(n) : "",
|
|
43
|
+
ModuleNameCamelCase: n ? V(n) : "",
|
|
44
|
+
ModuleNameUppercase: a.toUpperCase(),
|
|
45
|
+
ModuleNameScreamingSnake: n ? E(n) : "",
|
|
46
|
+
ModuleNameSentenceCase: n ? S(n) : ""
|
|
46
47
|
};
|
|
47
|
-
return e.projectName && (s.AppName =
|
|
48
|
+
return e.projectName && (s.AppName = h(e.projectName), s.AppNameSentenceCase = S(e.projectName)), e.packageName !== void 0 && (s.PackageName = e.packageName || "", s.BasePath = e.basePath || "", s.tenantRoutes = e.tenantRoutes || !1, s.aiAgent = e.aiAgent || !1, s.dashboard = e.dashboard || !1, s.mocks = e.mocks || !1), s;
|
|
48
49
|
}
|
|
49
|
-
const Z = /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico", ".pdf", ".zip"]),
|
|
50
|
+
const Z = /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico", ".pdf", ".zip"]), J = {
|
|
50
51
|
_gitignore: ".gitignore",
|
|
51
52
|
"_yarnrc.yml": ".yarnrc.yml",
|
|
52
53
|
_browserslistrc: ".browserslistrc",
|
|
@@ -63,99 +64,97 @@ const Z = /* @__PURE__ */ new Set([".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ic
|
|
|
63
64
|
_yarn: ".yarn",
|
|
64
65
|
"_package.json": "package.json"
|
|
65
66
|
};
|
|
66
|
-
function
|
|
67
|
+
function K(e, n, a) {
|
|
67
68
|
n.endsWith(".ejs") && (n = n.slice(0, -4));
|
|
68
|
-
const s =
|
|
69
|
+
const s = c.dirname(n);
|
|
69
70
|
r.existsSync(s) || r.mkdirSync(s, { recursive: !0 });
|
|
70
|
-
const o =
|
|
71
|
+
const o = c.extname(e.replace(/\.ejs$/, "")).toLowerCase();
|
|
71
72
|
if (Z.has(o))
|
|
72
73
|
r.copyFileSync(e, n);
|
|
73
74
|
else {
|
|
74
|
-
const d = r.readFileSync(e, "utf-8"), p = T.render(d,
|
|
75
|
+
const d = r.readFileSync(e, "utf-8"), p = T.render(d, a, { filename: e });
|
|
75
76
|
r.writeFileSync(n, p);
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
+
function b(e, n, a) {
|
|
79
80
|
if (!r.existsSync(e)) return;
|
|
80
81
|
const s = r.readdirSync(e);
|
|
81
82
|
for (const o of s) {
|
|
82
|
-
const d =
|
|
83
|
-
let
|
|
83
|
+
const d = c.join(e, o), p = o.endsWith(".ejs") ? o.slice(0, -4) : o;
|
|
84
|
+
let m = J[p] ?? p;
|
|
84
85
|
try {
|
|
85
|
-
m = T.render(m,
|
|
86
|
+
m = T.render(m, a);
|
|
86
87
|
} catch {
|
|
87
88
|
}
|
|
88
|
-
const
|
|
89
|
-
r.statSync(d).isDirectory() ? (r.existsSync(
|
|
89
|
+
const l = c.join(n, m);
|
|
90
|
+
r.statSync(d).isDirectory() ? (r.existsSync(l) || r.mkdirSync(l, { recursive: !0 }), b(d, l, a)) : K(d, l, a);
|
|
90
91
|
}
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
+
function Y(e) {
|
|
93
94
|
if (r.existsSync(e))
|
|
94
95
|
for (const n of r.readdirSync(e)) {
|
|
95
96
|
if (n === ".git") continue;
|
|
96
|
-
const
|
|
97
|
-
r.statSync(
|
|
97
|
+
const a = c.join(e, n);
|
|
98
|
+
r.statSync(a).isDirectory() ? r.rmSync(a, { recursive: !0, force: !0 }) : r.unlinkSync(a);
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
+
function I(e) {
|
|
101
102
|
if (!r.existsSync(e)) return !0;
|
|
102
103
|
const n = r.readdirSync(e);
|
|
103
104
|
return n.length === 0 || n.length === 1 && n[0] === ".git";
|
|
104
105
|
}
|
|
105
|
-
const
|
|
106
|
+
const q = {
|
|
106
107
|
standalone: "Standalone App",
|
|
107
|
-
"dynamic-module": "Dynamic Module"
|
|
108
|
-
"host-app": "Host App"
|
|
108
|
+
"dynamic-module": "Dynamic Module"
|
|
109
109
|
};
|
|
110
|
-
function
|
|
111
|
-
const n =
|
|
110
|
+
function W(e) {
|
|
111
|
+
const n = q[e.projectType], a = !!e.moduleName;
|
|
112
112
|
console.log(`
|
|
113
|
-
${
|
|
114
|
-
${
|
|
115
|
-
${
|
|
116
|
-
${
|
|
117
|
-
${
|
|
118
|
-
${
|
|
119
|
-
${
|
|
120
|
-
` : ""} ${
|
|
121
|
-
${
|
|
113
|
+
${t.green("╭─────────────────────────────────────────╮")}
|
|
114
|
+
${t.green("│")} ${t.green("│")}
|
|
115
|
+
${t.green("│")} ${t.bold("VC Shell App created successfully!")} ${t.green("│")}
|
|
116
|
+
${t.green("│")} ${t.green("│")}
|
|
117
|
+
${t.green("│")} Project: ${t.cyan(e.projectName.padEnd(28))}${t.green("│")}
|
|
118
|
+
${t.green("│")} Type: ${t.cyan(n.padEnd(28))}${t.green("│")}
|
|
119
|
+
${a && e.moduleName ? ` ${t.green("│")} Module: ${t.cyan(e.moduleName.padEnd(28))}${t.green("│")}
|
|
120
|
+
` : ""} ${t.green("│")} ${t.green("│")}
|
|
121
|
+
${t.green("╰─────────────────────────────────────────╯")}
|
|
122
122
|
|
|
123
|
-
${
|
|
123
|
+
${t.bold("Next steps:")}
|
|
124
124
|
|
|
125
125
|
1. cd ${e.projectName}
|
|
126
126
|
2. yarn install
|
|
127
127
|
3. yarn serve
|
|
128
|
-
${
|
|
128
|
+
${a && e.moduleName ? `
|
|
129
129
|
Module is ready at:
|
|
130
|
-
src/modules/${
|
|
130
|
+
src/modules/${H(e.moduleName)}/
|
|
131
131
|
` : ""}
|
|
132
|
-
${
|
|
132
|
+
${t.dim("Docs: https://docs.virtocommerce.org/platform/developer-guide/latest/custom-apps-development/vc-shell/vc-shell-overview/")}
|
|
133
133
|
`);
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function H(e) {
|
|
136
136
|
return e.trim().replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").toLowerCase().replace(/[^a-z0-9-]/g, "");
|
|
137
137
|
}
|
|
138
138
|
const X = [
|
|
139
139
|
{ title: "Standalone App — full application with bundled modules", value: "standalone" },
|
|
140
|
-
{ title: "Dynamic Module — remote module loaded by host via Module Federation", value: "dynamic-module" }
|
|
141
|
-
{ title: "Host App — shell application that loads dynamic modules", value: "host-app" }
|
|
140
|
+
{ title: "Dynamic Module — remote module loaded by host via Module Federation", value: "dynamic-module" }
|
|
142
141
|
];
|
|
143
142
|
async function G(e, n) {
|
|
144
|
-
const
|
|
143
|
+
const a = process.cwd();
|
|
145
144
|
let o = e._?.[0] || e.name || e["app-name"];
|
|
146
|
-
const d = o || "vc-app", p = () => o === "." ?
|
|
147
|
-
let
|
|
145
|
+
const d = o || "vc-app", p = () => o === "." ? c.basename(c.resolve()) : o, m = !!(o && e.type);
|
|
146
|
+
let l;
|
|
148
147
|
if (m) {
|
|
149
148
|
o = o || d;
|
|
150
|
-
const g =
|
|
151
|
-
r.existsSync(g) && !
|
|
152
|
-
const u = p(),
|
|
153
|
-
|
|
154
|
-
projectName:
|
|
155
|
-
packageName: e["package-name"] || (k(u) ? u :
|
|
156
|
-
projectType:
|
|
157
|
-
moduleName:
|
|
158
|
-
basePath: e["base-path"] ||
|
|
149
|
+
const g = c.resolve(a, o);
|
|
150
|
+
r.existsSync(g) && !I(g) && !e.overwrite && (console.error(t.red(`Target directory "${o}" is not empty. Use --overwrite to overwrite.`)), process.exit(1));
|
|
151
|
+
const u = p(), y = e.type, f = e["module-name"], N = y === "dynamic-module" ? f || S(u) : f || void 0;
|
|
152
|
+
l = {
|
|
153
|
+
projectName: h(u),
|
|
154
|
+
packageName: e["package-name"] || (k(u) ? u : C(u)),
|
|
155
|
+
projectType: y,
|
|
156
|
+
moduleName: N,
|
|
157
|
+
basePath: e["base-path"] || _(`/apps/${h(u)}/`),
|
|
159
158
|
tenantRoutes: e["tenant-routes"] || !1,
|
|
160
159
|
aiAgent: e["ai-agent"] || !1,
|
|
161
160
|
dashboard: e.dashboard || !1,
|
|
@@ -163,7 +162,7 @@ async function G(e, n) {
|
|
|
163
162
|
};
|
|
164
163
|
} else {
|
|
165
164
|
const g = () => {
|
|
166
|
-
throw new Error(
|
|
165
|
+
throw new Error(t.red("✖") + " Creation cancelled");
|
|
167
166
|
};
|
|
168
167
|
try {
|
|
169
168
|
const u = await A(
|
|
@@ -171,22 +170,22 @@ async function G(e, n) {
|
|
|
171
170
|
{
|
|
172
171
|
name: "projectName",
|
|
173
172
|
type: o ? null : "text",
|
|
174
|
-
message:
|
|
173
|
+
message: t.reset("Project name:"),
|
|
175
174
|
initial: d,
|
|
176
175
|
onState: (w) => {
|
|
177
|
-
o =
|
|
176
|
+
o = h(String(w.value).trim()) || d;
|
|
178
177
|
},
|
|
179
|
-
format: (w) =>
|
|
178
|
+
format: (w) => h(String(w).trim())
|
|
180
179
|
},
|
|
181
180
|
{
|
|
182
|
-
type: () => !r.existsSync(
|
|
181
|
+
type: () => !r.existsSync(c.resolve(a, o)) || I(c.resolve(a, o)) ? null : "confirm",
|
|
183
182
|
name: "overwrite",
|
|
184
183
|
message: () => (o === "." ? "Current directory" : `Target directory "${o}"`) + " is not empty. Remove existing files and continue?"
|
|
185
184
|
},
|
|
186
185
|
{
|
|
187
|
-
type: (w, { overwrite:
|
|
188
|
-
if (
|
|
189
|
-
throw new Error(
|
|
186
|
+
type: (w, { overwrite: M }) => {
|
|
187
|
+
if (M === !1)
|
|
188
|
+
throw new Error(t.red("✖") + " Operation cancelled");
|
|
190
189
|
return null;
|
|
191
190
|
},
|
|
192
191
|
name: "overwriteChecker"
|
|
@@ -194,91 +193,97 @@ async function G(e, n) {
|
|
|
194
193
|
{
|
|
195
194
|
name: "packageName",
|
|
196
195
|
type: () => k(p()) ? null : "text",
|
|
197
|
-
message:
|
|
198
|
-
initial: () =>
|
|
196
|
+
message: t.reset("Package name:"),
|
|
197
|
+
initial: () => C(p()),
|
|
199
198
|
validate: (w) => k(w) || "Invalid package.json name"
|
|
200
199
|
},
|
|
201
200
|
{
|
|
202
201
|
type: "select",
|
|
203
202
|
name: "projectType",
|
|
204
|
-
message:
|
|
203
|
+
message: t.reset("Project type:"),
|
|
205
204
|
choices: X
|
|
206
205
|
}
|
|
207
206
|
],
|
|
208
207
|
{ onCancel: g }
|
|
209
|
-
),
|
|
208
|
+
), y = o ? h(o) : u.projectName, f = u.projectType || "standalone", N = S(y), j = "/apps/" + h(y) + "/", $ = await A(
|
|
210
209
|
[
|
|
210
|
+
{
|
|
211
|
+
name: "includeModule",
|
|
212
|
+
type: f === "standalone" ? "confirm" : null,
|
|
213
|
+
message: "Include starter module?",
|
|
214
|
+
initial: !0
|
|
215
|
+
},
|
|
211
216
|
{
|
|
212
217
|
name: "moduleName",
|
|
213
|
-
type:
|
|
214
|
-
message:
|
|
215
|
-
initial:
|
|
218
|
+
type: (w, M) => f === "standalone" && !M.includeModule ? null : "text",
|
|
219
|
+
message: t.reset("Module name:"),
|
|
220
|
+
initial: N,
|
|
216
221
|
format: (w) => String(w).trim()
|
|
217
222
|
},
|
|
218
223
|
{
|
|
219
224
|
name: "basePath",
|
|
220
|
-
type:
|
|
221
|
-
message:
|
|
222
|
-
initial:
|
|
223
|
-
format: (w) =>
|
|
225
|
+
type: f === "dynamic-module" ? null : "text",
|
|
226
|
+
message: t.reset("Base path:"),
|
|
227
|
+
initial: j,
|
|
228
|
+
format: (w) => _(String(w).trim())
|
|
224
229
|
},
|
|
225
230
|
{
|
|
226
|
-
type:
|
|
231
|
+
type: f === "dynamic-module" ? null : "confirm",
|
|
227
232
|
name: "tenantRoutes",
|
|
228
233
|
message: "Include tenant routing (/:tenantId prefix)?",
|
|
229
234
|
initial: !1
|
|
230
235
|
},
|
|
231
236
|
{
|
|
232
|
-
type:
|
|
237
|
+
type: f === "dynamic-module" ? null : "confirm",
|
|
233
238
|
name: "aiAgent",
|
|
234
239
|
message: "Include AI Agent configuration?",
|
|
235
240
|
initial: !1
|
|
236
241
|
},
|
|
237
242
|
{
|
|
238
|
-
type:
|
|
243
|
+
type: f === "dynamic-module" ? null : "confirm",
|
|
239
244
|
name: "dashboard",
|
|
240
245
|
message: "Include Dashboard with widgets?",
|
|
241
246
|
initial: !0
|
|
242
247
|
},
|
|
243
248
|
{
|
|
244
249
|
name: "mocks",
|
|
245
|
-
type:
|
|
250
|
+
type: "confirm",
|
|
246
251
|
message: "Include sample module with mock data?",
|
|
247
252
|
initial: !1
|
|
248
253
|
}
|
|
249
254
|
],
|
|
250
255
|
{ onCancel: g }
|
|
251
256
|
);
|
|
252
|
-
|
|
253
|
-
projectName:
|
|
254
|
-
packageName: u.packageName || (k(
|
|
255
|
-
projectType:
|
|
256
|
-
moduleName:
|
|
257
|
-
basePath:
|
|
258
|
-
tenantRoutes:
|
|
259
|
-
aiAgent:
|
|
260
|
-
dashboard:
|
|
261
|
-
mocks:
|
|
257
|
+
l = {
|
|
258
|
+
projectName: y,
|
|
259
|
+
packageName: u.packageName || (k(y) ? y : C(y)),
|
|
260
|
+
projectType: f,
|
|
261
|
+
moduleName: $.moduleName || ($.includeModule !== !1 ? N : void 0),
|
|
262
|
+
basePath: $.basePath || _(j),
|
|
263
|
+
tenantRoutes: $.tenantRoutes || !1,
|
|
264
|
+
aiAgent: $.aiAgent || !1,
|
|
265
|
+
dashboard: $.dashboard ?? !0,
|
|
266
|
+
mocks: $.mocks || !1
|
|
262
267
|
};
|
|
263
268
|
} catch (u) {
|
|
264
269
|
console.log(u.message), process.exit(1);
|
|
265
270
|
}
|
|
266
271
|
}
|
|
267
|
-
const i =
|
|
268
|
-
r.existsSync(i) && !
|
|
269
|
-
Scaffolding ${
|
|
272
|
+
const i = c.resolve(a, o);
|
|
273
|
+
r.existsSync(i) && !I(i) ? Y(i) : r.existsSync(i) || r.mkdirSync(i, { recursive: !0 }), console.log(`
|
|
274
|
+
Scaffolding ${t.cyan(l.projectType)} in ${t.green(i)}...
|
|
270
275
|
`);
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
273
|
-
const g =
|
|
274
|
-
|
|
276
|
+
const v = D(l);
|
|
277
|
+
if (b(c.join(n, l.projectType), i, v), l.moduleName) {
|
|
278
|
+
const g = h(l.moduleName), u = l.projectType === "dynamic-module" ? c.join(i, "src/modules") : c.join(i, "src/modules", g);
|
|
279
|
+
b(c.join(n, "module"), u, v);
|
|
275
280
|
}
|
|
276
|
-
|
|
281
|
+
l.mocks && b(c.join(n, "sample-module"), c.join(i, "src/modules/sample"), v), W(l);
|
|
277
282
|
}
|
|
278
|
-
function
|
|
279
|
-
const
|
|
283
|
+
function R(e, n) {
|
|
284
|
+
const a = /^import\s.+$/gm;
|
|
280
285
|
let s = null, o;
|
|
281
|
-
for (; (o =
|
|
286
|
+
for (; (o = a.exec(e)) !== null; )
|
|
282
287
|
s = o;
|
|
283
288
|
if (s) {
|
|
284
289
|
const d = s.index + s[0].length;
|
|
@@ -289,36 +294,36 @@ function D(e, n) {
|
|
|
289
294
|
` + e;
|
|
290
295
|
}
|
|
291
296
|
function Q(e, n) {
|
|
292
|
-
let
|
|
293
|
-
const s = x(n), o =
|
|
294
|
-
|
|
297
|
+
let a = r.readFileSync(e, "utf-8");
|
|
298
|
+
const s = x(n), o = h(n);
|
|
299
|
+
a = R(a, `import ${s} from "./modules/${o}";`);
|
|
295
300
|
const d = /\.use\([A-Z]\w+,\s*\{\s*router\s*\}\)/g;
|
|
296
301
|
let p = null, m;
|
|
297
|
-
for (; (m = d.exec(
|
|
302
|
+
for (; (m = d.exec(a)) !== null; )
|
|
298
303
|
p = m;
|
|
299
304
|
if (p) {
|
|
300
|
-
const
|
|
305
|
+
const l = p.index + p[0].length, i = `
|
|
301
306
|
.use(${s}, { router })`;
|
|
302
|
-
|
|
307
|
+
a = a.slice(0, l) + i + a.slice(l);
|
|
303
308
|
}
|
|
304
|
-
r.writeFileSync(e,
|
|
309
|
+
r.writeFileSync(e, a);
|
|
305
310
|
}
|
|
306
311
|
function ee(e, n) {
|
|
307
|
-
let
|
|
308
|
-
const s =
|
|
309
|
-
if (!
|
|
310
|
-
const
|
|
311
|
-
if (
|
|
312
|
-
const g =
|
|
313
|
-
|
|
312
|
+
let a = r.readFileSync(e, "utf-8");
|
|
313
|
+
const s = h(n), o = E(n);
|
|
314
|
+
if (!a.includes("addMenuItem")) {
|
|
315
|
+
const v = /import\s*\{([^}]+)\}\s*from\s*["']@vc-shell\/framework["']/.exec(a);
|
|
316
|
+
if (v) {
|
|
317
|
+
const g = v[1].trim() + ", addMenuItem";
|
|
318
|
+
a = a.replace(v[0], `import { ${g} } from "@vc-shell/framework"`);
|
|
314
319
|
} else
|
|
315
|
-
|
|
320
|
+
a = R(a, 'import { addMenuItem } from "@vc-shell/framework";');
|
|
316
321
|
}
|
|
317
322
|
const d = /addMenuItem\(\{[\s\S]*?\}\);/g;
|
|
318
323
|
let p = null, m;
|
|
319
|
-
for (; (m = d.exec(
|
|
324
|
+
for (; (m = d.exec(a)) !== null; )
|
|
320
325
|
p = m;
|
|
321
|
-
const
|
|
326
|
+
const l = `
|
|
322
327
|
addMenuItem({
|
|
323
328
|
title: "${o}.MENU.TITLE",
|
|
324
329
|
icon: "lucide-box",
|
|
@@ -327,63 +332,63 @@ function ee(e, n) {
|
|
|
327
332
|
});`;
|
|
328
333
|
if (p) {
|
|
329
334
|
const i = p.index + p[0].length;
|
|
330
|
-
|
|
331
|
-
` +
|
|
335
|
+
a = a.slice(0, i) + `
|
|
336
|
+
` + l + a.slice(i);
|
|
332
337
|
} else {
|
|
333
|
-
const i =
|
|
334
|
-
i !== -1 && (
|
|
335
|
-
` +
|
|
338
|
+
const i = a.lastIndexOf("}");
|
|
339
|
+
i !== -1 && (a = a.slice(0, i) + l + `
|
|
340
|
+
` + a.slice(i));
|
|
336
341
|
}
|
|
337
|
-
r.writeFileSync(e,
|
|
342
|
+
r.writeFileSync(e, a);
|
|
338
343
|
}
|
|
339
|
-
async function
|
|
340
|
-
const
|
|
341
|
-
r.existsSync(o) || (console.error(
|
|
344
|
+
async function ae(e, n) {
|
|
345
|
+
const a = process.cwd(), s = e._?.[1], o = c.join(a, "package.json");
|
|
346
|
+
r.existsSync(o) || (console.error(t.red("Error: No package.json found. Run this command from a vc-shell project root.")), process.exit(1));
|
|
342
347
|
const d = JSON.parse(r.readFileSync(o, "utf-8"));
|
|
343
|
-
({ ...d.dependencies, ...d.devDependencies })["@vc-shell/framework"] || (console.error(
|
|
348
|
+
({ ...d.dependencies, ...d.devDependencies })["@vc-shell/framework"] || (console.error(t.red("Error: Not a vc-shell project (@vc-shell/framework not found in dependencies).")), process.exit(1));
|
|
344
349
|
let m = s;
|
|
345
350
|
m || (m = (await A({
|
|
346
351
|
type: "text",
|
|
347
352
|
name: "moduleName",
|
|
348
353
|
message: "Module name:",
|
|
349
|
-
validate: (
|
|
350
|
-
})).moduleName), m || (console.error(
|
|
351
|
-
const
|
|
352
|
-
r.existsSync(
|
|
353
|
-
const u =
|
|
354
|
-
|
|
355
|
-
const
|
|
356
|
-
if (r.existsSync(
|
|
354
|
+
validate: (j) => j.trim().length > 0 || "Module name is required"
|
|
355
|
+
})).moduleName), m || (console.error(t.red("Module name is required.")), process.exit(1));
|
|
356
|
+
const l = h(m), i = x(m), v = c.join(a, "src/modules"), g = c.join(v, l);
|
|
357
|
+
r.existsSync(v) || r.mkdirSync(v, { recursive: !0 }), r.existsSync(g) && (console.error(t.red(`Error: Module "${l}" already exists at ${c.relative(a, g)}`)), process.exit(1));
|
|
358
|
+
const u = D({ moduleName: m, projectName: c.basename(a) });
|
|
359
|
+
b(c.join(n, "module"), g, u), console.log(t.green(` ✔ Created ${c.relative(a, g)}/`));
|
|
360
|
+
const y = c.join(a, "src/main.ts");
|
|
361
|
+
if (r.existsSync(y))
|
|
357
362
|
try {
|
|
358
|
-
Q(
|
|
363
|
+
Q(y, m), console.log(t.green(` ✔ Updated src/main.ts — added import & app.use(${i})`));
|
|
359
364
|
} catch {
|
|
360
|
-
console.warn(
|
|
365
|
+
console.warn(t.yellow(" ⚠ Could not auto-update src/main.ts. Add manually:")), console.warn(t.yellow(` import ${i} from "./modules/${l}";`)), console.warn(t.yellow(` app.use(${i}, { router });`));
|
|
361
366
|
}
|
|
362
|
-
const
|
|
363
|
-
if (r.existsSync(
|
|
367
|
+
const f = c.join(a, "src/bootstrap.ts");
|
|
368
|
+
if (r.existsSync(f))
|
|
364
369
|
try {
|
|
365
|
-
ee(
|
|
370
|
+
ee(f, m), console.log(t.green(` ✔ Updated src/bootstrap.ts — added menu item "${S(m)}"`));
|
|
366
371
|
} catch {
|
|
367
|
-
console.warn(
|
|
372
|
+
console.warn(t.yellow(" ⚠ Could not auto-update src/bootstrap.ts. Add addMenuItem() manually."));
|
|
368
373
|
}
|
|
369
374
|
console.log(`
|
|
370
|
-
Module "${
|
|
375
|
+
Module "${l}" is ready! Run ${t.bold(t.green("yarn serve"))} to see it.
|
|
371
376
|
`);
|
|
372
377
|
}
|
|
373
|
-
const
|
|
374
|
-
function
|
|
378
|
+
const P = c.resolve(B(import.meta.url), "..", "templates");
|
|
379
|
+
function te() {
|
|
375
380
|
console.log(`
|
|
376
|
-
${
|
|
381
|
+
${t.bold(t.green("create-vc-app"))} — Create VC Shell applications and modules
|
|
377
382
|
|
|
378
|
-
${
|
|
383
|
+
${t.bold("Usage:")}
|
|
379
384
|
create-vc-app [project-name] [options] Create a new project
|
|
380
385
|
create-vc-app add-module <module-name> Add a module to existing project
|
|
381
386
|
|
|
382
|
-
${
|
|
383
|
-
--type <type> Project type: standalone | dynamic-module
|
|
387
|
+
${t.bold("Options (create):")}
|
|
388
|
+
--type <type> Project type: standalone | dynamic-module
|
|
384
389
|
--name, --app-name <name> Application name
|
|
385
390
|
--package-name <name> npm package name
|
|
386
|
-
--module-name <name> Initial module name
|
|
391
|
+
--module-name <name> Initial module name (opt-in for standalone)
|
|
387
392
|
--base-path <path> Base path [default: /apps/<name>/]
|
|
388
393
|
--tenant-routes Include tenant routing (/:tenantId prefix)
|
|
389
394
|
--ai-agent Include AI Agent configuration
|
|
@@ -393,14 +398,13 @@ ${a.bold("Options (create):")}
|
|
|
393
398
|
--help, -h Show this help
|
|
394
399
|
--version, -v Show version
|
|
395
400
|
|
|
396
|
-
${
|
|
401
|
+
${t.bold("Examples:")}
|
|
397
402
|
create-vc-app my-app
|
|
398
403
|
create-vc-app my-app --type standalone --dashboard --mocks
|
|
399
404
|
create-vc-app my-module --type dynamic-module --module-name "Reviews"
|
|
400
|
-
create-vc-app my-shell --type host-app --dashboard --tenant-routes
|
|
401
405
|
create-vc-app add-module orders
|
|
402
406
|
|
|
403
|
-
${
|
|
407
|
+
${t.bold("Docs:")} https://docs.virtocommerce.org/platform/developer-guide/latest/custom-apps-development/vc-shell/vc-shell-overview/
|
|
404
408
|
`);
|
|
405
409
|
}
|
|
406
410
|
async function ne() {
|
|
@@ -410,15 +414,15 @@ async function ne() {
|
|
|
410
414
|
string: ["type", "name", "app-name", "package-name", "module-name", "base-path"]
|
|
411
415
|
});
|
|
412
416
|
if (e.help) {
|
|
413
|
-
|
|
417
|
+
te();
|
|
414
418
|
return;
|
|
415
419
|
}
|
|
416
420
|
if (e.version) {
|
|
417
421
|
console.log(`create-vc-app v${O.version}`);
|
|
418
422
|
return;
|
|
419
423
|
}
|
|
420
|
-
e._[0] === "add-module" ? await
|
|
424
|
+
e._[0] === "add-module" ? await ae(e, P) : await G(e, P);
|
|
421
425
|
}
|
|
422
426
|
ne().catch((e) => {
|
|
423
|
-
console.error(
|
|
427
|
+
console.error(t.red(e.message || String(e))), U(1);
|
|
424
428
|
});
|
package/dist/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAOjD,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAsB1D"}
|
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@types/node": "^20.10.5",
|
|
13
|
-
"@vc-shell/ts-config": "^2.0.0-alpha.
|
|
13
|
+
"@vc-shell/ts-config": "^2.0.0-alpha.17",
|
|
14
14
|
"cross-env": "^7.0.3",
|
|
15
15
|
"sass": "^1.87.0",
|
|
16
16
|
"typescript": "^5.8.3",
|
|
17
17
|
"vite": "^6.3.3",
|
|
18
|
-
"vue-tsc": "^
|
|
18
|
+
"vue-tsc": "^3.2.5"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@vc-shell/config-generator": "^2.0.0-alpha.
|
|
22
|
-
"@vc-shell/framework": "^2.0.0-alpha.
|
|
23
|
-
"vue": "^3.5.
|
|
24
|
-
"vue-router": "^
|
|
21
|
+
"@vc-shell/config-generator": "^2.0.0-alpha.17",
|
|
22
|
+
"@vc-shell/framework": "^2.0.0-alpha.17",
|
|
23
|
+
"vue": "^3.5.30",
|
|
24
|
+
"vue-router": "^5.0.3"
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as locales from "./locales";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export default
|
|
1
|
+
import * as blades from "./pages";
|
|
2
|
+
import * as locales from "./locales";
|
|
3
|
+
import { defineAppModule } from "@vc-shell/framework";
|
|
4
|
+
|
|
5
|
+
export default defineAppModule({
|
|
6
|
+
blades,
|
|
7
|
+
locales,
|
|
8
|
+
});
|