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