@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 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
- Run following command:
6
- ```bash
7
- $ npx create-vc-app
8
- ```
9
-
10
- This command will execute application scaffolding tool. You will be presented with prompts:
11
-
12
- ```text
13
- ✔ App name: … <your-app-name>
14
- ✔ Add Dashboard page? … No / Yes
15
- Add Login/Invite/Reset password pages? No / Yes
16
- Add module starter? No / Yes
17
- Module starter name: … <your-first-module-name>
18
-
19
- Scaffolding app in ./<your-app-name>...
20
-
21
- Done.
22
- ```
23
-
24
-
25
- Once app is created, follow the instructions to install dependencies and start dev server:
26
- ```bash
27
- $ cd <your-app-name>
28
- $ yarn
29
- $ yarn serve
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 Ce from "prompts";
3
- import $e from "mri";
4
- import u from "chalk";
5
- import i from "node:path";
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 Re } from "node:url";
8
- import { cwd as je, argv as Ae, exit as we } from "node:process";
9
- const ke = "1.1.53", Oe = {
10
- version: ke
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 Ne = typeof global == "object" && global && global.Object === Object && global, Me = typeof self == "object" && self && self.Object === Object && self, Te = Ne || Me || Function("return this")(), p = Te.Symbol, H = Object.prototype, Ue = H.hasOwnProperty, Ee = H.toString, y = p ? p.toStringTag : void 0;
13
- function Le(e) {
14
- var r = Ue.call(e, y), n = e[y];
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[y] = void 0;
17
- var t = !0;
16
+ e[$] = void 0;
17
+ var o = !0;
18
18
  } catch {
19
19
  }
20
- var a = Ee.call(e);
21
- return t && (r ? e[y] = n : delete e[y]), a;
20
+ var i = De.call(e);
21
+ return o && (r ? e[$] = a : delete e[$]), i;
22
22
  }
23
- var _e = Object.prototype, Pe = _e.toString;
24
- function ze(e) {
25
- return Pe.call(e);
23
+ var Ze = Object.prototype, Fe = Ze.toString;
24
+ function Ve(e) {
25
+ return Fe.call(e);
26
26
  }
27
- var De = "[object Null]", Ze = "[object Undefined]", _ = p ? p.toStringTag : void 0;
28
- function Fe(e) {
29
- return e == null ? e === void 0 ? Ze : De : _ && _ in Object(e) ? Le(e) : ze(e);
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 Ie(e) {
31
+ function Je(e) {
32
32
  return e != null && typeof e == "object";
33
33
  }
34
- var Ve = "[object Symbol]";
35
- function We(e) {
36
- return typeof e == "symbol" || Ie(e) && Fe(e) == Ve;
34
+ var Ge = "[object Symbol]";
35
+ function Ye(e) {
36
+ return typeof e == "symbol" || Je(e) && Be(e) == Ge;
37
37
  }
38
- function He(e, r) {
39
- for (var n = -1, t = e == null ? 0 : e.length, a = Array(t); ++n < t; )
40
- a[n] = r(e[n], n, e);
41
- return a;
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 Be = Array.isArray, P = p ? p.prototype : void 0, z = P ? P.toString : void 0;
44
- function B(e) {
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 (Be(e))
48
- return He(e, B) + "";
49
- if (We(e))
50
- return z ? z.call(e) : "";
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 C(e) {
55
- return e == null ? "" : B(e);
54
+ function R(e) {
55
+ return e == null ? "" : Q(e);
56
56
  }
57
- function Je(e, r, n) {
58
- var t = -1, a = e.length;
59
- r < 0 && (r = -r > a ? 0 : a + r), n = n > a ? a : n, n < 0 && (n += a), a = r > n ? 0 : n - r >>> 0, r >>>= 0;
60
- for (var c = Array(a); ++t < a; )
61
- c[t] = e[t + r];
62
- return c;
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 Ge(e, r, n) {
65
- var t = e.length;
66
- return n = n === void 0 ? t : n, !r && n >= t ? e : Je(e, r, n);
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 Ye = "\\ud800-\\udfff", qe = "\\u0300-\\u036f", Ke = "\\ufe20-\\ufe2f", Qe = "\\u20d0-\\u20ff", Xe = qe + Ke + Qe, er = "\\ufe0e\\ufe0f", rr = "\\u200d", nr = RegExp("[" + rr + Ye + Xe + er + "]");
69
- function J(e) {
70
- return nr.test(e);
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 or(e) {
72
+ function ur(e) {
73
73
  return e.split("");
74
74
  }
75
- var G = "\\ud800-\\udfff", ar = "\\u0300-\\u036f", tr = "\\ufe20-\\ufe2f", ur = "\\u20d0-\\u20ff", sr = ar + tr + ur, ir = "\\ufe0e\\ufe0f", cr = "[" + G + "]", O = "[" + sr + "]", N = "\\ud83c[\\udffb-\\udfff]", fr = "(?:" + O + "|" + N + ")", Y = "[^" + G + "]", q = "(?:\\ud83c[\\udde6-\\uddff]){2}", K = "[\\ud800-\\udbff][\\udc00-\\udfff]", lr = "\\u200d", Q = fr + "?", X = "[" + ir + "]?", dr = "(?:" + lr + "(?:" + [Y, q, K].join("|") + ")" + X + Q + ")*", mr = X + Q + dr, pr = "(?:" + [Y + O + "?", O, q, K, cr].join("|") + ")", gr = RegExp(N + "(?=" + N + ")|" + pr + mr, "g");
76
- function xr(e) {
77
- return e.match(gr) || [];
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 br(e) {
80
- return J(e) ? xr(e) : or(e);
79
+ function Sr(e) {
80
+ return X(e) ? $r(e) : ur(e);
81
81
  }
82
- function ee(e) {
82
+ function ie(e) {
83
83
  return function(r) {
84
- r = C(r);
85
- var n = J(r) ? br(r) : void 0, t = n ? n[0] : r.charAt(0), a = n ? Ge(n, 1).join("") : r.slice(1);
86
- return t[e]() + a;
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 M = ee("toUpperCase");
90
- function yr(e) {
91
- return M(C(e).toLowerCase());
89
+ var L = ie("toUpperCase");
90
+ function kr(e) {
91
+ return L(R(e).toLowerCase());
92
92
  }
93
- function vr(e, r, n, t) {
94
- for (var a = -1, c = e == null ? 0 : e.length; ++a < c; )
95
- n = r(n, e[a], a, e);
96
- return n;
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 Sr(e) {
98
+ function wr(e) {
99
99
  return function(r) {
100
100
  return e?.[r];
101
101
  };
102
102
  }
103
- var hr = {
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
- }, Cr = Sr(hr), $r = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g, Rr = "\\u0300-\\u036f", jr = "\\ufe20-\\ufe2f", Ar = "\\u20d0-\\u20ff", wr = Rr + jr + Ar, kr = "[" + wr + "]", Or = RegExp(kr, "g");
297
- function Nr(e) {
298
- return e = C(e), e && e.replace($r, Cr).replace(Or, "");
299
- }
300
- var Mr = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
301
- function Tr(e) {
302
- return e.match(Mr) || [];
303
- }
304
- var Ur = /[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 Er(e) {
306
- return Ur.test(e);
307
- }
308
- var re = "\\ud800-\\udfff", Lr = "\\u0300-\\u036f", _r = "\\ufe20-\\ufe2f", Pr = "\\u20d0-\\u20ff", zr = Lr + _r + Pr, ne = "\\u2700-\\u27bf", oe = "a-z\\xdf-\\xf6\\xf8-\\xff", Dr = "\\xac\\xb1\\xd7\\xf7", Zr = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", Fr = "\\u2000-\\u206f", Ir = " \\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", ae = "A-Z\\xc0-\\xd6\\xd8-\\xde", Vr = "\\ufe0e\\ufe0f", te = Dr + Zr + Fr + Ir, ue = "['’]", D = "[" + te + "]", Wr = "[" + zr + "]", se = "\\d+", Hr = "[" + ne + "]", ie = "[" + oe + "]", ce = "[^" + re + te + se + ne + oe + ae + "]", Br = "\\ud83c[\\udffb-\\udfff]", Jr = "(?:" + Wr + "|" + Br + ")", Gr = "[^" + re + "]", fe = "(?:\\ud83c[\\udde6-\\uddff]){2}", le = "[\\ud800-\\udbff][\\udc00-\\udfff]", m = "[" + ae + "]", Yr = "\\u200d", Z = "(?:" + ie + "|" + ce + ")", qr = "(?:" + m + "|" + ce + ")", F = "(?:" + ue + "(?:d|ll|m|re|s|t|ve))?", I = "(?:" + ue + "(?:D|LL|M|RE|S|T|VE))?", de = Jr + "?", me = "[" + Vr + "]?", Kr = "(?:" + Yr + "(?:" + [Gr, fe, le].join("|") + ")" + me + de + ")*", Qr = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", Xr = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", en = me + de + Kr, rn = "(?:" + [Hr, fe, le].join("|") + ")" + en, nn = RegExp([
309
- m + "?" + ie + "+" + F + "(?=" + [D, m, "$"].join("|") + ")",
310
- qr + "+" + I + "(?=" + [D, m + Z, "$"].join("|") + ")",
311
- m + "?" + Z + "+" + F,
312
- m + "+" + I,
313
- Xr,
314
- Qr,
315
- se,
316
- rn
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 on(e) {
319
- return e.match(nn) || [];
318
+ function ua(e) {
319
+ return e.match(sa) || [];
320
320
  }
321
- function an(e, r, n) {
322
- return e = C(e), r = r, r === void 0 ? Er(e) ? on(e) : Tr(e) : e.match(r) || [];
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 tn = "['’]", un = RegExp(tn, "g");
325
- function T(e) {
324
+ var la = "['’]", fa = RegExp(la, "g");
325
+ function _(e) {
326
326
  return function(r) {
327
- return vr(an(Nr(r).replace(un, "")), e, "");
327
+ return Cr(ca(Pr(r).replace(fa, "")), e, "");
328
328
  };
329
329
  }
330
- var V = T(function(e, r, n) {
331
- return r = r.toLowerCase(), e + (n ? yr(r) : r);
332
- }), sn = ee("toLowerCase"), cn = T(function(e, r, n) {
333
- return e + (n ? "_" : "") + r.toLowerCase();
334
- }), w = T(function(e, r, n) {
335
- return e + (n ? " " : "") + M(r);
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 fn = {
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 W(e) {
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 v(e) {
402
+ function p(e) {
359
403
  return e.trim().toLowerCase().replace(/\s+/g, "-").replace(/^[._]/, "").replace(/[^a-z0-9-~]+/g, "-");
360
404
  }
361
- function ln(e) {
405
+ function Y(e) {
362
406
  return e.trim().toLowerCase().replace(/\/+/g, "/").replace(/[^a-z0-9/-]+/g, "/").replace(/\/?$/, "/");
363
407
  }
364
- function pe(e) {
408
+ function he(e) {
365
409
  if (s.existsSync(e))
366
410
  s.readdirSync(e).forEach((r) => {
367
- const n = i.join(e, r);
368
- s.lstatSync(n).isDirectory() ? pe(n) : s.unlinkSync(n);
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 dn(e) {
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
- const mn = [
378
- // {
379
- // name: "dynamic",
380
- // display: "Dynamic view modules boilerplate",
381
- // },
382
- {
383
- name: "classic",
384
- display: "Classic view modules boilerplate"
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
- ], k = {
387
- classic: ["classic-module"],
388
- dynamic: ["dynamic-module"]
389
- };
390
- async function pn() {
391
- console.log(` ${u.bold(u.green(`
392
- create-vc-app version: ${Oe.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 e = je();
395
- let n = $e(Ae.slice(2))._[0];
396
- const t = n || "vc-app", a = () => n === "." ? i.basename(i.resolve()) : n;
397
- let c;
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
- c = await Ce(
400
- [
401
- {
402
- name: "appName",
403
- type: n ? null : "text",
404
- message: u.reset("Project name:"),
405
- initial: t,
406
- onState: (o) => n = v(String(o.value).trim()) || t,
407
- format: (o) => v(String(o).trim())
408
- },
409
- {
410
- type: () => !s.existsSync(n) || dn(n) ? null : "confirm",
411
- name: "overwrite",
412
- message: () => (n === "." ? "Current directory" : `Target directory "${n}"`) + " is not empty. Remove existing files and continue?"
413
- },
414
- {
415
- type: (o, { overwrite: S }) => {
416
- if (S === !1)
417
- throw new Error(u.red("✖") + " Operation cancelled");
418
- return null;
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
- name: "overwriteChecker"
421
- },
422
- {
423
- name: "packageName",
424
- type: () => W(a()) ? null : "text",
425
- message: u.reset("Package name:"),
426
- initial: () => v(a()),
427
- validate: (o) => W(o) || "Invalid package.json name"
428
- },
429
- {
430
- name: "basePath",
431
- type: "text",
432
- message: u.reset("Base path:"),
433
- initial: () => "/apps/" + v(a()) + "/",
434
- format: (o) => ln(String(o).trim())
435
- },
436
- {
437
- type: "select",
438
- name: "variant",
439
- message: u.reset("Select module variant:"),
440
- choices: mn.map((o) => ({
441
- title: o.display,
442
- value: o.name
443
- }))
444
- },
445
- {
446
- name: "moduleName",
447
- type: "text",
448
- message: u.reset("Module name:"),
449
- initial: () => w(a()),
450
- format: (o) => String(o).trim()
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
- name: "mocks",
454
- type: "confirm",
455
- message: "Do you want to include additional module with sample data?",
456
- initial: !1
529
+ onCancel: () => {
530
+ throw new Error(t.red("") + " Creation cancelled");
531
+ }
457
532
  }
458
- ],
459
- {
460
- onCancel: () => {
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: ge, variant: g, moduleName: d, appName: U, basePath: xe, mocks: be } = c, $ = /* @__PURE__ */ new Map([
469
- ["{{ModuleName}}", v(d)],
470
- ["{{ModuleNamePascalCase}}", M(V(d))],
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}}", cn(d).toUpperCase()],
473
- ["{{ModuleNameExports}}", sn(V(d))],
474
- ["{{ModuleNameSentenceCase}}", w(d)],
475
- ["{{AppName}}", U],
476
- ["{{AppNameSentenceCase}}", w(U)],
477
- ["{{BasePath}}", xe],
478
- ["{{PackageName}}", ge || a()]
479
- ]), f = i.join(e, n);
480
- s.existsSync(f) ? pe(f) : s.existsSync(f) || s.mkdirSync(f), console.log(`
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 ye = i.resolve(Re(import.meta.url), "..", "templates");
483
- function l(o, S = "") {
484
- const E = i.resolve(ye, o), ve = s.readdirSync(E);
485
- for (const x of ve) {
486
- const R = i.join(E, x);
487
- let h = fn[x] ?? x;
488
- for (const [L, b] of $.entries()) {
489
- const A = new RegExp(L, "g");
490
- h = h.replace(A, b);
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 j = i.join(f, S, h);
493
- if (s.statSync(R).isDirectory())
494
- s.mkdirSync(j, { recursive: !0 }), l(i.join(o, x), i.join(S, h));
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
- i.extname(x).toLowerCase()
565
+ c.extname(y).toLowerCase()
497
566
  ))
498
- s.copyFileSync(R, j);
567
+ s.copyFileSync(O, M);
499
568
  else {
500
- let b = s.readFileSync(R, "utf-8");
501
- for (const [A, Se] of $.entries()) {
502
- const he = new RegExp(A, "g");
503
- b = b.replace(he, Se);
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(j, b);
574
+ s.writeFileSync(M, h);
506
575
  }
507
576
  }
508
577
  }
509
- if (l("base"), k[g].forEach((o) => {
510
- l(`modules/${o}`, "src/modules/" + $.get("{{ModuleName}}"));
511
- }), be && (g === "dynamic" && k[g].forEach((o) => {
512
- l(`sample/${o}`, "src/modules/sample");
513
- }), g === "classic" && k[g].forEach((o) => {
514
- l(`sample/${o}`, "src/modules/sample");
515
- }), l("mocks", "src/modules/sample"), l("sample/overrides", "src")), console.log(`
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 !== e) {
518
- const o = i.relative(e, f);
586
+ `), f !== a) {
587
+ const n = c.relative(a, f);
519
588
  console.log(
520
- ` ${u.bold(u.green(`cd ${o.includes(" ") ? `"${o}"` : o}`))}`
589
+ ` ${t.bold(t.green(`cd ${n.includes(" ") ? `"${n}"` : n}`))}`
521
590
  );
522
591
  }
523
- console.log(` ${u.bold(u.green("yarn"))}`), console.log(` ${u.bold(u.green("yarn serve"))}`);
592
+ console.log(` ${t.bold(t.green("yarn"))}`), console.log(` ${t.bold(t.green("yarn serve"))}`);
524
593
  }
525
- pn().catch((e) => {
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.53",
27
- "@vc-shell/release-config": "^1.1.53",
28
- "@vc-shell/ts-config": "^1.1.53",
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.53",
57
- "@vc-shell/framework": "^1.1.53",
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.53",
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.53",
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",