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