@vc-shell/create-vc-app 1.1.53 → 1.1.55
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 +13 -0
- package/README.md +106 -30
- package/dist/index.js +306 -237
- package/dist/templates/base/_package.json +5 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
## [1.1.55](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.54...v1.1.55) (2025-07-07)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## [1.1.54](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.53...v1.1.54) (2025-07-07)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **cli:** enhance CLI argument parsing and validation, add help and version options ([f8508cc](https://github.com/VirtoCommerce/vc-shell/commit/f8508ccac11bce142a03839e44b893520e9546ce))
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
1
14
|
## [1.1.53](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.52...v1.1.53) (2025-07-04)
|
|
2
15
|
|
|
3
16
|
|
package/README.md
CHANGED
|
@@ -1,30 +1,106 @@
|
|
|
1
|
-
# Creating your first application
|
|
2
|
-
|
|
3
|
-
Make sure you have executed `yarn` command and your current working directory is the one where you intend to create a project.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
✔
|
|
16
|
-
✔
|
|
17
|
-
✔
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
# Creating your first application
|
|
2
|
+
|
|
3
|
+
Make sure you have executed `yarn` command and your current working directory is the one where you intend to create a project.
|
|
4
|
+
|
|
5
|
+
## Interactive Mode (Default)
|
|
6
|
+
|
|
7
|
+
Run following command:
|
|
8
|
+
```bash
|
|
9
|
+
$ npx create-vc-app
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
This command will execute application scaffolding tool. You will be presented with prompts:
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
✔ Project name: … <your-app-name>
|
|
16
|
+
✔ Package name: … <your-package-name>
|
|
17
|
+
✔ Base path: … /apps/<your-app-name>/
|
|
18
|
+
✔ Select module variant: › Classic view modules boilerplate
|
|
19
|
+
✔ Module name: … <your-first-module-name>
|
|
20
|
+
✔ Do you want to include additional module with sample data? … No / Yes
|
|
21
|
+
|
|
22
|
+
Scaffolding app in ./<your-app-name>...
|
|
23
|
+
|
|
24
|
+
Done.
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Non-Interactive Mode
|
|
28
|
+
|
|
29
|
+
For automation, CI/CD, or when you want to skip prompts, you can use command line arguments:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
$ npx create-vc-app my-app --variant classic --module-name "My Module" --mocks
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Available Options
|
|
36
|
+
|
|
37
|
+
| Option | Description | Default |
|
|
38
|
+
|--------|-------------|---------|
|
|
39
|
+
| `--name`, `--app-name` | Name of the application | Directory name |
|
|
40
|
+
| `--package-name` | Package name | App name (validated) |
|
|
41
|
+
| `--variant` | Module variant (classic\|dynamic) | `classic` |
|
|
42
|
+
| `--module-name` | Module name | App name in title case |
|
|
43
|
+
| `--base-path` | Base path for the application | `/apps/<app-name>/` |
|
|
44
|
+
| `--mocks` | Include additional module with sample data | `false` |
|
|
45
|
+
| `--overwrite` | Overwrite existing files without confirmation | `false` |
|
|
46
|
+
| `--help`, `-h` | Show help message | - |
|
|
47
|
+
| `--version`, `-v` | Show version | - |
|
|
48
|
+
|
|
49
|
+
### Examples
|
|
50
|
+
|
|
51
|
+
**Basic usage:**
|
|
52
|
+
```bash
|
|
53
|
+
npx create-vc-app my-app
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**With custom options:**
|
|
57
|
+
```bash
|
|
58
|
+
npx create-vc-app my-app --variant classic --module-name "My Module" --mocks
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**With custom paths:**
|
|
62
|
+
```bash
|
|
63
|
+
npx create-vc-app my-app --base-path "/custom/path/" --package-name "@my-org/my-app"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Overwrite existing directory:**
|
|
67
|
+
```bash
|
|
68
|
+
npx create-vc-app existing-dir --overwrite
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Create in current directory:**
|
|
72
|
+
```bash
|
|
73
|
+
npx create-vc-app . --name my-existing-project --overwrite
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
**Full non-interactive example:**
|
|
77
|
+
```bash
|
|
78
|
+
npx create-vc-app my-ecommerce-app \
|
|
79
|
+
--variant classic \
|
|
80
|
+
--module-name "Product Catalog" \
|
|
81
|
+
--base-path "/apps/ecommerce/" \
|
|
82
|
+
--package-name "@mycompany/ecommerce-app" \
|
|
83
|
+
--mocks \
|
|
84
|
+
--overwrite
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## After Creation
|
|
88
|
+
|
|
89
|
+
Once app is created, follow the instructions to install dependencies and start dev server:
|
|
90
|
+
```bash
|
|
91
|
+
$ cd <your-app-name>
|
|
92
|
+
$ yarn
|
|
93
|
+
$ yarn serve
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Available Variants
|
|
97
|
+
|
|
98
|
+
- **classic** - Classic view modules boilerplate (default)
|
|
99
|
+
- **dynamic** - Dynamic view modules boilerplate (coming soon)
|
|
100
|
+
|
|
101
|
+
## Notes
|
|
102
|
+
|
|
103
|
+
- If you provide a project name as the first argument, it will be used as the app name
|
|
104
|
+
- The `--variant` option is required for non-interactive mode
|
|
105
|
+
- Use `--overwrite` to automatically overwrite existing files without confirmation
|
|
106
|
+
- Package names are automatically validated and converted to valid npm package names
|
package/dist/index.js
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
2
|
+
import Ae from "prompts";
|
|
3
|
+
import Ne from "mri";
|
|
4
|
+
import t from "chalk";
|
|
5
|
+
import c from "node:path";
|
|
6
6
|
import s from "node:fs";
|
|
7
|
-
import { fileURLToPath as
|
|
8
|
-
import { cwd as
|
|
9
|
-
const
|
|
10
|
-
version:
|
|
7
|
+
import { fileURLToPath as Oe } from "node:url";
|
|
8
|
+
import { cwd as Me, exit as Ee, argv as Te } from "node:process";
|
|
9
|
+
const Ue = "1.1.55", I = {
|
|
10
|
+
version: Ue
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
function
|
|
14
|
-
var r =
|
|
12
|
+
var Pe = typeof global == "object" && global && global.Object === Object && global, Le = typeof self == "object" && self && self.Object === Object && self, _e = Pe || Le || Function("return this")(), b = _e.Symbol, K = Object.prototype, ze = K.hasOwnProperty, De = K.toString, $ = b ? b.toStringTag : void 0;
|
|
13
|
+
function Ie(e) {
|
|
14
|
+
var r = ze.call(e, $), a = e[$];
|
|
15
15
|
try {
|
|
16
|
-
e[
|
|
17
|
-
var
|
|
16
|
+
e[$] = void 0;
|
|
17
|
+
var o = !0;
|
|
18
18
|
} catch {
|
|
19
19
|
}
|
|
20
|
-
var
|
|
21
|
-
return
|
|
20
|
+
var i = De.call(e);
|
|
21
|
+
return o && (r ? e[$] = a : delete e[$]), i;
|
|
22
22
|
}
|
|
23
|
-
var
|
|
24
|
-
function
|
|
25
|
-
return
|
|
23
|
+
var Ze = Object.prototype, Fe = Ze.toString;
|
|
24
|
+
function Ve(e) {
|
|
25
|
+
return Fe.call(e);
|
|
26
26
|
}
|
|
27
|
-
var
|
|
28
|
-
function
|
|
29
|
-
return e == null ? e === void 0 ?
|
|
27
|
+
var He = "[object Null]", We = "[object Undefined]", Z = b ? b.toStringTag : void 0;
|
|
28
|
+
function Be(e) {
|
|
29
|
+
return e == null ? e === void 0 ? We : He : Z && Z in Object(e) ? Ie(e) : Ve(e);
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function Je(e) {
|
|
32
32
|
return e != null && typeof e == "object";
|
|
33
33
|
}
|
|
34
|
-
var
|
|
35
|
-
function
|
|
36
|
-
return typeof e == "symbol" ||
|
|
34
|
+
var Ge = "[object Symbol]";
|
|
35
|
+
function Ye(e) {
|
|
36
|
+
return typeof e == "symbol" || Je(e) && Be(e) == Ge;
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
for (var
|
|
40
|
-
a
|
|
41
|
-
return
|
|
38
|
+
function qe(e, r) {
|
|
39
|
+
for (var a = -1, o = e == null ? 0 : e.length, i = Array(o); ++a < o; )
|
|
40
|
+
i[a] = r(e[a], a, e);
|
|
41
|
+
return i;
|
|
42
42
|
}
|
|
43
|
-
var
|
|
44
|
-
function
|
|
43
|
+
var Ke = Array.isArray, F = b ? b.prototype : void 0, V = F ? F.toString : void 0;
|
|
44
|
+
function Q(e) {
|
|
45
45
|
if (typeof e == "string")
|
|
46
46
|
return e;
|
|
47
|
-
if (
|
|
48
|
-
return
|
|
49
|
-
if (
|
|
50
|
-
return
|
|
47
|
+
if (Ke(e))
|
|
48
|
+
return qe(e, Q) + "";
|
|
49
|
+
if (Ye(e))
|
|
50
|
+
return V ? V.call(e) : "";
|
|
51
51
|
var r = e + "";
|
|
52
52
|
return r == "0" && 1 / e == -1 / 0 ? "-0" : r;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
return e == null ? "" :
|
|
54
|
+
function R(e) {
|
|
55
|
+
return e == null ? "" : Q(e);
|
|
56
56
|
}
|
|
57
|
-
function
|
|
58
|
-
var
|
|
59
|
-
r < 0 && (r = -r >
|
|
60
|
-
for (var
|
|
61
|
-
|
|
62
|
-
return
|
|
57
|
+
function Qe(e, r, a) {
|
|
58
|
+
var o = -1, i = e.length;
|
|
59
|
+
r < 0 && (r = -r > i ? 0 : i + r), a = a > i ? i : a, a < 0 && (a += i), i = r > a ? 0 : a - r >>> 0, r >>>= 0;
|
|
60
|
+
for (var u = Array(i); ++o < i; )
|
|
61
|
+
u[o] = e[o + r];
|
|
62
|
+
return u;
|
|
63
63
|
}
|
|
64
|
-
function
|
|
65
|
-
var
|
|
66
|
-
return
|
|
64
|
+
function Xe(e, r, a) {
|
|
65
|
+
var o = e.length;
|
|
66
|
+
return a = a === void 0 ? o : a, !r && a >= o ? e : Qe(e, r, a);
|
|
67
67
|
}
|
|
68
|
-
var
|
|
69
|
-
function
|
|
70
|
-
return
|
|
68
|
+
var er = "\\ud800-\\udfff", rr = "\\u0300-\\u036f", ar = "\\ufe20-\\ufe2f", nr = "\\u20d0-\\u20ff", or = rr + ar + nr, tr = "\\ufe0e\\ufe0f", ir = "\\u200d", sr = RegExp("[" + ir + er + or + tr + "]");
|
|
69
|
+
function X(e) {
|
|
70
|
+
return sr.test(e);
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function ur(e) {
|
|
73
73
|
return e.split("");
|
|
74
74
|
}
|
|
75
|
-
var
|
|
76
|
-
function
|
|
77
|
-
return e.match(
|
|
75
|
+
var ee = "\\ud800-\\udfff", cr = "\\u0300-\\u036f", lr = "\\ufe20-\\ufe2f", fr = "\\u20d0-\\u20ff", pr = cr + lr + fr, mr = "\\ufe0e\\ufe0f", dr = "[" + ee + "]", U = "[" + pr + "]", P = "\\ud83c[\\udffb-\\udfff]", gr = "(?:" + U + "|" + P + ")", re = "[^" + ee + "]", ae = "(?:\\ud83c[\\udde6-\\uddff]){2}", ne = "[\\ud800-\\udbff][\\udc00-\\udfff]", xr = "\\u200d", oe = gr + "?", te = "[" + mr + "]?", br = "(?:" + xr + "(?:" + [re, ae, ne].join("|") + ")" + te + oe + ")*", vr = te + oe + br, yr = "(?:" + [re + U + "?", U, ae, ne, dr].join("|") + ")", hr = RegExp(P + "(?=" + P + ")|" + yr + vr, "g");
|
|
76
|
+
function $r(e) {
|
|
77
|
+
return e.match(hr) || [];
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
return
|
|
79
|
+
function Sr(e) {
|
|
80
|
+
return X(e) ? $r(e) : ur(e);
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function ie(e) {
|
|
83
83
|
return function(r) {
|
|
84
|
-
r =
|
|
85
|
-
var
|
|
86
|
-
return
|
|
84
|
+
r = R(r);
|
|
85
|
+
var a = X(r) ? Sr(r) : void 0, o = a ? a[0] : r.charAt(0), i = a ? Xe(a, 1).join("") : r.slice(1);
|
|
86
|
+
return o[e]() + i;
|
|
87
87
|
};
|
|
88
88
|
}
|
|
89
|
-
var
|
|
90
|
-
function
|
|
91
|
-
return
|
|
89
|
+
var L = ie("toUpperCase");
|
|
90
|
+
function kr(e) {
|
|
91
|
+
return L(R(e).toLowerCase());
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
for (var
|
|
95
|
-
|
|
96
|
-
return
|
|
93
|
+
function Cr(e, r, a, o) {
|
|
94
|
+
for (var i = -1, u = e == null ? 0 : e.length; ++i < u; )
|
|
95
|
+
a = r(a, e[i], i, e);
|
|
96
|
+
return a;
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function wr(e) {
|
|
99
99
|
return function(r) {
|
|
100
100
|
return e?.[r];
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
|
-
var
|
|
103
|
+
var jr = {
|
|
104
104
|
// Latin-1 Supplement block.
|
|
105
105
|
À: "A",
|
|
106
106
|
Á: "A",
|
|
@@ -293,48 +293,48 @@ var hr = {
|
|
|
293
293
|
œ: "oe",
|
|
294
294
|
ʼn: "'n",
|
|
295
295
|
ſ: "s"
|
|
296
|
-
},
|
|
297
|
-
function
|
|
298
|
-
return e =
|
|
299
|
-
}
|
|
300
|
-
var
|
|
301
|
-
function
|
|
302
|
-
return e.match(
|
|
303
|
-
}
|
|
304
|
-
var
|
|
305
|
-
function
|
|
306
|
-
return
|
|
307
|
-
}
|
|
308
|
-
var
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
296
|
+
}, Rr = wr(jr), Ar = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, Nr = "\\u0300-\\u036f", Or = "\\ufe20-\\ufe2f", Mr = "\\u20d0-\\u20ff", Er = Nr + Or + Mr, Tr = "[" + Er + "]", Ur = RegExp(Tr, "g");
|
|
297
|
+
function Pr(e) {
|
|
298
|
+
return e = R(e), e && e.replace(Ar, Rr).replace(Ur, "");
|
|
299
|
+
}
|
|
300
|
+
var Lr = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
|
|
301
|
+
function _r(e) {
|
|
302
|
+
return e.match(Lr) || [];
|
|
303
|
+
}
|
|
304
|
+
var zr = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
|
|
305
|
+
function Dr(e) {
|
|
306
|
+
return zr.test(e);
|
|
307
|
+
}
|
|
308
|
+
var se = "\\ud800-\\udfff", Ir = "\\u0300-\\u036f", Zr = "\\ufe20-\\ufe2f", Fr = "\\u20d0-\\u20ff", Vr = Ir + Zr + Fr, ue = "\\u2700-\\u27bf", ce = "a-z\\xdf-\\xf6\\xf8-\\xff", Hr = "\\xac\\xb1\\xd7\\xf7", Wr = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", Br = "\\u2000-\\u206f", Jr = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", le = "A-Z\\xc0-\\xd6\\xd8-\\xde", Gr = "\\ufe0e\\ufe0f", fe = Hr + Wr + Br + Jr, pe = "['’]", H = "[" + fe + "]", Yr = "[" + Vr + "]", me = "\\d+", qr = "[" + ue + "]", de = "[" + ce + "]", ge = "[^" + se + fe + me + ue + ce + le + "]", Kr = "\\ud83c[\\udffb-\\udfff]", Qr = "(?:" + Yr + "|" + Kr + ")", Xr = "[^" + se + "]", xe = "(?:\\ud83c[\\udde6-\\uddff]){2}", be = "[\\ud800-\\udbff][\\udc00-\\udfff]", x = "[" + le + "]", ea = "\\u200d", W = "(?:" + de + "|" + ge + ")", ra = "(?:" + x + "|" + ge + ")", B = "(?:" + pe + "(?:d|ll|m|re|s|t|ve))?", J = "(?:" + pe + "(?:D|LL|M|RE|S|T|VE))?", ve = Qr + "?", ye = "[" + Gr + "]?", aa = "(?:" + ea + "(?:" + [Xr, xe, be].join("|") + ")" + ye + ve + ")*", na = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", oa = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", ta = ye + ve + aa, ia = "(?:" + [qr, xe, be].join("|") + ")" + ta, sa = RegExp([
|
|
309
|
+
x + "?" + de + "+" + B + "(?=" + [H, x, "$"].join("|") + ")",
|
|
310
|
+
ra + "+" + J + "(?=" + [H, x + W, "$"].join("|") + ")",
|
|
311
|
+
x + "?" + W + "+" + B,
|
|
312
|
+
x + "+" + J,
|
|
313
|
+
oa,
|
|
314
|
+
na,
|
|
315
|
+
me,
|
|
316
|
+
ia
|
|
317
317
|
].join("|"), "g");
|
|
318
|
-
function
|
|
319
|
-
return e.match(
|
|
318
|
+
function ua(e) {
|
|
319
|
+
return e.match(sa) || [];
|
|
320
320
|
}
|
|
321
|
-
function
|
|
322
|
-
return e =
|
|
321
|
+
function ca(e, r, a) {
|
|
322
|
+
return e = R(e), r = r, r === void 0 ? Dr(e) ? ua(e) : _r(e) : e.match(r) || [];
|
|
323
323
|
}
|
|
324
|
-
var
|
|
325
|
-
function
|
|
324
|
+
var la = "['’]", fa = RegExp(la, "g");
|
|
325
|
+
function _(e) {
|
|
326
326
|
return function(r) {
|
|
327
|
-
return
|
|
327
|
+
return Cr(ca(Pr(r).replace(fa, "")), e, "");
|
|
328
328
|
};
|
|
329
329
|
}
|
|
330
|
-
var
|
|
331
|
-
return r = r.toLowerCase(), e + (
|
|
332
|
-
}),
|
|
333
|
-
return e + (
|
|
334
|
-
}),
|
|
335
|
-
return e + (
|
|
330
|
+
var G = _(function(e, r, a) {
|
|
331
|
+
return r = r.toLowerCase(), e + (a ? kr(r) : r);
|
|
332
|
+
}), pa = ie("toLowerCase"), ma = _(function(e, r, a) {
|
|
333
|
+
return e + (a ? "_" : "") + r.toLowerCase();
|
|
334
|
+
}), C = _(function(e, r, a) {
|
|
335
|
+
return e + (a ? " " : "") + L(r);
|
|
336
336
|
});
|
|
337
|
-
const
|
|
337
|
+
const da = {
|
|
338
338
|
_gitignore: ".gitignore",
|
|
339
339
|
"_yarnrc.yml": ".yarnrc.yml",
|
|
340
340
|
_browserslistrc: ".browserslistrc",
|
|
@@ -351,177 +351,246 @@ const fn = {
|
|
|
351
351
|
_vscode: ".vscode",
|
|
352
352
|
_yarn: ".yarn",
|
|
353
353
|
"_package.json": "package.json"
|
|
354
|
+
}, j = [
|
|
355
|
+
// {
|
|
356
|
+
// name: "dynamic",
|
|
357
|
+
// display: "Dynamic view modules boilerplate",
|
|
358
|
+
// },
|
|
359
|
+
{
|
|
360
|
+
name: "classic",
|
|
361
|
+
display: "Classic view modules boilerplate"
|
|
362
|
+
}
|
|
363
|
+
], T = {
|
|
364
|
+
classic: ["classic-module"],
|
|
365
|
+
dynamic: ["dynamic-module"]
|
|
354
366
|
};
|
|
355
|
-
function
|
|
367
|
+
function ga() {
|
|
368
|
+
console.log(`
|
|
369
|
+
${t.bold(t.green("create-vc-app"))} - Create a new VC Shell application
|
|
370
|
+
|
|
371
|
+
${t.bold("Usage:")}
|
|
372
|
+
create-vc-app [project-name] [options]
|
|
373
|
+
|
|
374
|
+
${t.bold("Options:")}
|
|
375
|
+
--name, --app-name <name> Name of the application
|
|
376
|
+
--package-name <name> Package name (defaults to app name)
|
|
377
|
+
--variant <variant> Module variant (classic|dynamic) [default: classic]
|
|
378
|
+
--module-name <name> Module name (defaults to app name in title case)
|
|
379
|
+
--base-path <path> Base path for the application [default: /apps/<app-name>/]
|
|
380
|
+
--mocks Include additional module with sample data
|
|
381
|
+
--overwrite Overwrite existing files without confirmation
|
|
382
|
+
--help, -h Show this help message
|
|
383
|
+
--version, -v Show version
|
|
384
|
+
|
|
385
|
+
${t.bold("Examples:")}
|
|
386
|
+
create-vc-app my-app
|
|
387
|
+
create-vc-app my-app --variant classic --mocks
|
|
388
|
+
create-vc-app my-app --module-name "My Module" --base-path "/custom/path/"
|
|
389
|
+
create-vc-app . --name existing-project --overwrite
|
|
390
|
+
|
|
391
|
+
${t.bold("Non-interactive mode:")}
|
|
392
|
+
create-vc-app my-app --variant classic --module-name "My Module" --mocks --overwrite
|
|
393
|
+
|
|
394
|
+
${t.bold("Available variants:")}
|
|
395
|
+
${j.map((e) => ` ${e.name.padEnd(10)} - ${e.display}`).join(`
|
|
396
|
+
`)}
|
|
397
|
+
`);
|
|
398
|
+
}
|
|
399
|
+
function w(e) {
|
|
356
400
|
return /^(?:@[a-z0-9-*~][a-z0-9-*._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(e);
|
|
357
401
|
}
|
|
358
|
-
function
|
|
402
|
+
function p(e) {
|
|
359
403
|
return e.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
|
|
360
404
|
}
|
|
361
|
-
function
|
|
405
|
+
function Y(e) {
|
|
362
406
|
return e.trim().toLowerCase().replace(/\/+/g, "/").replace(/[^a-z0-9/-]+/g, "/").replace(/\/?$/, "/");
|
|
363
407
|
}
|
|
364
|
-
function
|
|
408
|
+
function he(e) {
|
|
365
409
|
if (s.existsSync(e))
|
|
366
410
|
s.readdirSync(e).forEach((r) => {
|
|
367
|
-
const
|
|
368
|
-
s.lstatSync(
|
|
411
|
+
const a = c.join(e, r);
|
|
412
|
+
s.lstatSync(a).isDirectory() ? he(a) : s.unlinkSync(a);
|
|
369
413
|
});
|
|
370
414
|
else
|
|
371
415
|
return;
|
|
372
416
|
}
|
|
373
|
-
function
|
|
417
|
+
function q(e) {
|
|
374
418
|
const r = s.readdirSync(e);
|
|
375
419
|
return r.length === 0 || r.length === 1 && r[0] === ".git";
|
|
376
420
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
{
|
|
383
|
-
|
|
384
|
-
|
|
421
|
+
function xa(e) {
|
|
422
|
+
const r = [];
|
|
423
|
+
return e.variant && !j.some((a) => a.name === e.variant) && r.push(`Invalid variant: ${e.variant}. Available variants: ${j.map((a) => a.name).join(", ")}`), e["package-name"] && !w(e["package-name"]) && r.push(`Invalid package name: ${e["package-name"]}`), { valid: r.length === 0, errors: r };
|
|
424
|
+
}
|
|
425
|
+
function ba() {
|
|
426
|
+
return Ne(Te.slice(2), {
|
|
427
|
+
alias: {
|
|
428
|
+
h: "help",
|
|
429
|
+
v: "version"
|
|
430
|
+
},
|
|
431
|
+
boolean: ["help", "version", "mocks", "overwrite"],
|
|
432
|
+
string: ["name", "app-name", "package-name", "variant", "module-name", "base-path"]
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
async function va() {
|
|
436
|
+
const e = ba();
|
|
437
|
+
if (e.help) {
|
|
438
|
+
ga();
|
|
439
|
+
return;
|
|
385
440
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
console.log(` ${
|
|
392
|
-
create-vc-app version: ${
|
|
441
|
+
if (e.version) {
|
|
442
|
+
console.log(`create-vc-app version ${I.version}`);
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
const r = xa(e);
|
|
446
|
+
r.valid || (console.error(t.red("Error:")), r.errors.forEach((n) => console.error(t.red(` ${n}`))), process.exit(1)), console.log(` ${t.bold(t.green(`
|
|
447
|
+
create-vc-app version: ${I.version}
|
|
393
448
|
`))}`);
|
|
394
|
-
const
|
|
395
|
-
let
|
|
396
|
-
const
|
|
397
|
-
let
|
|
449
|
+
const a = Me();
|
|
450
|
+
let o = e._[0] || e.name || e["app-name"];
|
|
451
|
+
const i = o || "vc-app", u = () => o === "." ? c.basename(c.resolve()) : o, $e = !!(o || e.name || e["app-name"]);
|
|
452
|
+
let l;
|
|
398
453
|
try {
|
|
399
|
-
|
|
400
|
-
[
|
|
401
|
-
{
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
454
|
+
if ($e && e.variant) {
|
|
455
|
+
o = o || e.name || e["app-name"] || i, o || (console.error(t.red("Project name is required")), process.exit(1)), s.existsSync(o) && !q(o) && !e.overwrite && (console.error(
|
|
456
|
+
t.red(`Target directory "${o}" is not empty. Use --overwrite to overwrite existing files.`)
|
|
457
|
+
), process.exit(1));
|
|
458
|
+
const n = u(), g = e["package-name"] || (w(n) ? n : p(n)), S = e["module-name"] || C(n), N = e["base-path"] || Y(`/apps/${p(n)}/`);
|
|
459
|
+
l = {
|
|
460
|
+
appName: p(o),
|
|
461
|
+
packageName: g,
|
|
462
|
+
variant: e.variant,
|
|
463
|
+
moduleName: S,
|
|
464
|
+
basePath: N,
|
|
465
|
+
mocks: e.mocks || !1
|
|
466
|
+
}, console.log(t.cyan("Creating app with the following configuration:")), console.log(t.cyan(` App name: ${l.appName}`)), console.log(t.cyan(` Package name: ${l.packageName}`)), console.log(t.cyan(` Variant: ${l.variant}`)), console.log(t.cyan(` Module name: ${l.moduleName}`)), console.log(t.cyan(` Base path: ${l.basePath}`)), console.log(t.cyan(` Mocks: ${l.mocks ? "Yes" : "No"}`)), console.log();
|
|
467
|
+
} else
|
|
468
|
+
l = await Ae(
|
|
469
|
+
[
|
|
470
|
+
{
|
|
471
|
+
name: "appName",
|
|
472
|
+
type: o ? null : "text",
|
|
473
|
+
message: t.reset("Project name:"),
|
|
474
|
+
initial: i,
|
|
475
|
+
onState: (n) => o = p(String(n.value).trim()) || i,
|
|
476
|
+
format: (n) => p(String(n).trim())
|
|
419
477
|
},
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
478
|
+
{
|
|
479
|
+
type: () => !s.existsSync(o) || q(o) ? null : "confirm",
|
|
480
|
+
name: "overwrite",
|
|
481
|
+
message: () => (o === "." ? "Current directory" : `Target directory "${o}"`) + " is not empty. Remove existing files and continue?"
|
|
482
|
+
},
|
|
483
|
+
{
|
|
484
|
+
type: (n, { overwrite: g }) => {
|
|
485
|
+
if (g === !1)
|
|
486
|
+
throw new Error(t.red("✖") + " Operation cancelled");
|
|
487
|
+
return null;
|
|
488
|
+
},
|
|
489
|
+
name: "overwriteChecker"
|
|
490
|
+
},
|
|
491
|
+
{
|
|
492
|
+
name: "packageName",
|
|
493
|
+
type: () => w(u()) ? null : "text",
|
|
494
|
+
message: t.reset("Package name:"),
|
|
495
|
+
initial: () => p(u()),
|
|
496
|
+
validate: (n) => w(n) || "Invalid package.json name"
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
name: "basePath",
|
|
500
|
+
type: "text",
|
|
501
|
+
message: t.reset("Base path:"),
|
|
502
|
+
initial: () => "/apps/" + p(u()) + "/",
|
|
503
|
+
format: (n) => Y(String(n).trim())
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
type: "select",
|
|
507
|
+
name: "variant",
|
|
508
|
+
message: t.reset("Select module variant:"),
|
|
509
|
+
choices: j.map((n) => ({
|
|
510
|
+
title: n.display,
|
|
511
|
+
value: n.name
|
|
512
|
+
}))
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
name: "moduleName",
|
|
516
|
+
type: "text",
|
|
517
|
+
message: t.reset("Module name:"),
|
|
518
|
+
initial: () => C(u()),
|
|
519
|
+
format: (n) => String(n).trim()
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
name: "mocks",
|
|
523
|
+
type: "confirm",
|
|
524
|
+
message: "Do you want to include additional module with sample data?",
|
|
525
|
+
initial: !1
|
|
526
|
+
}
|
|
527
|
+
],
|
|
452
528
|
{
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
initial: !1
|
|
529
|
+
onCancel: () => {
|
|
530
|
+
throw new Error(t.red("✖") + " Creation cancelled");
|
|
531
|
+
}
|
|
457
532
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
throw new Error(u.red("✖") + " Creation cancelled");
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
);
|
|
465
|
-
} catch (o) {
|
|
466
|
-
console.log(o.message), we(1);
|
|
533
|
+
);
|
|
534
|
+
} catch (n) {
|
|
535
|
+
console.log(n.message), Ee(1);
|
|
467
536
|
}
|
|
468
|
-
const { packageName:
|
|
469
|
-
["{{ModuleName}}",
|
|
470
|
-
["{{ModuleNamePascalCase}}",
|
|
537
|
+
const { packageName: Se, variant: v, moduleName: d, appName: z, basePath: ke, mocks: Ce } = l, A = /* @__PURE__ */ new Map([
|
|
538
|
+
["{{ModuleName}}", p(d)],
|
|
539
|
+
["{{ModuleNamePascalCase}}", L(G(d))],
|
|
471
540
|
["{{ModuleNameUppercase}}", d.toUpperCase()],
|
|
472
|
-
["{{ModuleNameUppercaseSnakeCase}}",
|
|
473
|
-
["{{ModuleNameExports}}",
|
|
474
|
-
["{{ModuleNameSentenceCase}}",
|
|
475
|
-
["{{AppName}}",
|
|
476
|
-
["{{AppNameSentenceCase}}",
|
|
477
|
-
["{{BasePath}}",
|
|
478
|
-
["{{PackageName}}",
|
|
479
|
-
]), f =
|
|
480
|
-
s.existsSync(f) ?
|
|
541
|
+
["{{ModuleNameUppercaseSnakeCase}}", ma(d).toUpperCase()],
|
|
542
|
+
["{{ModuleNameExports}}", pa(G(d))],
|
|
543
|
+
["{{ModuleNameSentenceCase}}", C(d)],
|
|
544
|
+
["{{AppName}}", z],
|
|
545
|
+
["{{AppNameSentenceCase}}", C(z)],
|
|
546
|
+
["{{BasePath}}", ke],
|
|
547
|
+
["{{PackageName}}", Se || u()]
|
|
548
|
+
]), f = c.join(a, o);
|
|
549
|
+
s.existsSync(f) ? he(f) : s.existsSync(f) || s.mkdirSync(f), console.log(`
|
|
481
550
|
Scaffolding app in ${f}...`);
|
|
482
|
-
const
|
|
483
|
-
function
|
|
484
|
-
const
|
|
485
|
-
for (const
|
|
486
|
-
const
|
|
487
|
-
let
|
|
488
|
-
for (const [
|
|
489
|
-
const
|
|
490
|
-
|
|
551
|
+
const we = c.resolve(Oe(import.meta.url), "..", "templates");
|
|
552
|
+
function m(n, g = "") {
|
|
553
|
+
const S = c.resolve(we, n), N = s.readdirSync(S);
|
|
554
|
+
for (const y of N) {
|
|
555
|
+
const O = c.join(S, y);
|
|
556
|
+
let k = da[y] ?? y;
|
|
557
|
+
for (const [D, h] of A.entries()) {
|
|
558
|
+
const E = new RegExp(D, "g");
|
|
559
|
+
k = k.replace(E, h);
|
|
491
560
|
}
|
|
492
|
-
const
|
|
493
|
-
if (s.statSync(
|
|
494
|
-
s.mkdirSync(
|
|
561
|
+
const M = c.join(f, g, k);
|
|
562
|
+
if (s.statSync(O).isDirectory())
|
|
563
|
+
s.mkdirSync(M, { recursive: !0 }), m(c.join(n, y), c.join(g, k));
|
|
495
564
|
else if ([".png", ".jpg", ".jpeg", ".gif", ".bmp", ".ico", ".pdf", ".zip"].includes(
|
|
496
|
-
|
|
565
|
+
c.extname(y).toLowerCase()
|
|
497
566
|
))
|
|
498
|
-
s.copyFileSync(
|
|
567
|
+
s.copyFileSync(O, M);
|
|
499
568
|
else {
|
|
500
|
-
let
|
|
501
|
-
for (const [
|
|
502
|
-
const
|
|
503
|
-
|
|
569
|
+
let h = s.readFileSync(O, "utf-8");
|
|
570
|
+
for (const [E, je] of A.entries()) {
|
|
571
|
+
const Re = new RegExp(E, "g");
|
|
572
|
+
h = h.replace(Re, je);
|
|
504
573
|
}
|
|
505
|
-
s.writeFileSync(
|
|
574
|
+
s.writeFileSync(M, h);
|
|
506
575
|
}
|
|
507
576
|
}
|
|
508
577
|
}
|
|
509
|
-
if (
|
|
510
|
-
|
|
511
|
-
}),
|
|
512
|
-
|
|
513
|
-
}),
|
|
514
|
-
|
|
515
|
-
}),
|
|
578
|
+
if (m("base"), T[v].forEach((n) => {
|
|
579
|
+
m(`modules/${n}`, "src/modules/" + A.get("{{ModuleName}}"));
|
|
580
|
+
}), Ce && (v === "dynamic" && T[v].forEach((n) => {
|
|
581
|
+
m(`sample/${n}`, "src/modules/sample");
|
|
582
|
+
}), v === "classic" && T[v].forEach((n) => {
|
|
583
|
+
m(`sample/${n}`, "src/modules/sample");
|
|
584
|
+
}), m("mocks", "src/modules/sample"), m("sample/overrides", "src")), console.log(`
|
|
516
585
|
Done. You can now run application:
|
|
517
|
-
`), f !==
|
|
518
|
-
const
|
|
586
|
+
`), f !== a) {
|
|
587
|
+
const n = c.relative(a, f);
|
|
519
588
|
console.log(
|
|
520
|
-
` ${
|
|
589
|
+
` ${t.bold(t.green(`cd ${n.includes(" ") ? `"${n}"` : n}`))}`
|
|
521
590
|
);
|
|
522
591
|
}
|
|
523
|
-
console.log(` ${
|
|
592
|
+
console.log(` ${t.bold(t.green("yarn"))}`), console.log(` ${t.bold(t.green("yarn serve"))}`);
|
|
524
593
|
}
|
|
525
|
-
|
|
594
|
+
va().catch((e) => {
|
|
526
595
|
console.error(e);
|
|
527
596
|
});
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"@types/node": "^20.10.5",
|
|
24
24
|
"@typescript-eslint/eslint-plugin": "^6.16.0",
|
|
25
25
|
"@typescript-eslint/parser": "^6.16.0",
|
|
26
|
-
"@vc-shell/api-client-generator": "^1.1.
|
|
27
|
-
"@vc-shell/release-config": "^1.1.
|
|
28
|
-
"@vc-shell/ts-config": "^1.1.
|
|
26
|
+
"@vc-shell/api-client-generator": "^1.1.55",
|
|
27
|
+
"@vc-shell/release-config": "^1.1.55",
|
|
28
|
+
"@vc-shell/ts-config": "^1.1.55",
|
|
29
29
|
"@vitejs/plugin-vue": "^5.2.3",
|
|
30
30
|
"@vue/eslint-config-prettier": "^9.0.0",
|
|
31
31
|
"@vue/eslint-config-typescript": "^12.0.0",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"vue-tsc": "^2.2.10"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@vc-shell/config-generator": "^1.1.
|
|
57
|
-
"@vc-shell/framework": "^1.1.
|
|
56
|
+
"@vc-shell/config-generator": "^1.1.55",
|
|
57
|
+
"@vc-shell/framework": "^1.1.55",
|
|
58
58
|
"@vueuse/core": "^10.7.1",
|
|
59
59
|
"@vueuse/integrations": "^10.7.1",
|
|
60
60
|
"cross-spawn": "^7.0.3",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vc-shell/create-vc-app",
|
|
3
3
|
"description": "Application scaffolding",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.55",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./dist/index.js",
|
|
7
7
|
"files": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/prompts": "^2.4.4",
|
|
16
|
-
"@vc-shell/ts-config": "^1.1.
|
|
16
|
+
"@vc-shell/ts-config": "^1.1.55",
|
|
17
17
|
"copyfiles": "^2.4.1",
|
|
18
18
|
"cross-env": "^7.0.3",
|
|
19
19
|
"shx": "^0.3.4",
|