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