@vc-shell/api-client-generator 1.0.336 → 1.0.338

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.0.338](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.337...v1.0.338) (2025-02-05)
2
+
3
+
4
+
5
+ ## [1.0.337](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.336...v1.0.337) (2025-01-29)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **api-client:** correct type export path generation ([40464e9](https://github.com/VirtoCommerce/vc-shell/commit/40464e9d94be6409c8224cc8e90b1a39794b2328))
11
+
12
+
13
+
1
14
  ## [1.0.336](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.335...v1.0.336) (2025-01-29)
2
15
 
3
16
 
@@ -5,15 +5,15 @@ import { existsSync as D, readFileSync as C, writeFileSync as T } from "node:fs"
5
5
  import A, { dirname as b, resolve as L, join as m, relative as _ } from "node:path";
6
6
  import { fileURLToPath as R } from "node:url";
7
7
  import { cwd as S } from "node:process";
8
- const k = R(import.meta.url), j = b(k);
9
- class E {
8
+ const k = R(import.meta.url), E = b(k);
9
+ class j {
10
10
  workingDirectory;
11
11
  generatorDirectory;
12
12
  assetsDirectory;
13
13
  apiClientDirectory;
14
14
  nswagPaths;
15
15
  constructor(e) {
16
- this.workingDirectory = S(), this.generatorDirectory = L(j, ".."), this.assetsDirectory = m(this.generatorDirectory, "public", "assets"), this.apiClientDirectory = L(this.workingDirectory, e), this.nswagPaths = {
16
+ this.workingDirectory = S(), this.generatorDirectory = L(E, ".."), this.assetsDirectory = m(this.generatorDirectory, "public", "assets"), this.apiClientDirectory = L(this.workingDirectory, e), this.nswagPaths = {
17
17
  configuration: m(_(this.workingDirectory, this.assetsDirectory), "config.nswag"),
18
18
  authApiBase: "authApiBase.ts",
19
19
  templates: "templates"
@@ -28,35 +28,35 @@ class E {
28
28
  };
29
29
  }
30
30
  }
31
- function y(n) {
32
- return n == null ? [] : Array.isArray(n) ? n : [n];
31
+ function y(t) {
32
+ return t == null ? [] : Array.isArray(t) ? t : [t];
33
33
  }
34
- function $(n, e, i, t) {
35
- var c, s = n[e], u = ~t.string.indexOf(e) ? i == null || i === !0 ? "" : String(i) : typeof i == "boolean" ? i : ~t.boolean.indexOf(e) ? i === "false" ? !1 : i === "true" || (n._.push((c = +i, c * 0 === 0 ? c : i)), !!i) : (c = +i, c * 0 === 0 ? c : i);
36
- n[e] = s == null ? u : Array.isArray(s) ? s.concat(u) : [s, u];
34
+ function $(t, e, i, n) {
35
+ var c, s = t[e], u = ~n.string.indexOf(e) ? i == null || i === !0 ? "" : String(i) : typeof i == "boolean" ? i : ~n.boolean.indexOf(e) ? i === "false" ? !1 : i === "true" || (t._.push((c = +i, c * 0 === 0 ? c : i)), !!i) : (c = +i, c * 0 === 0 ? c : i);
36
+ t[e] = s == null ? u : Array.isArray(s) ? s.concat(u) : [s, u];
37
37
  }
38
- function B(n, e) {
39
- n = n || [], e = e || {};
40
- var i, t, c, s, u, o = { _: [] }, r = 0, a = 0, l = 0, f = n.length;
38
+ function B(t, e) {
39
+ t = t || [], e = e || {};
40
+ var i, n, c, s, u, o = { _: [] }, r = 0, a = 0, l = 0, f = t.length;
41
41
  const P = e.alias !== void 0, h = e.unknown !== void 0, p = e.default !== void 0;
42
42
  if (e.alias = e.alias || {}, e.string = y(e.string), e.boolean = y(e.boolean), P)
43
43
  for (i in e.alias)
44
- for (t = e.alias[i] = y(e.alias[i]), r = 0; r < t.length; r++)
45
- (e.alias[t[r]] = t.concat(i)).splice(r, 1);
44
+ for (n = e.alias[i] = y(e.alias[i]), r = 0; r < n.length; r++)
45
+ (e.alias[n[r]] = n.concat(i)).splice(r, 1);
46
46
  for (r = e.boolean.length; r-- > 0; )
47
- for (t = e.alias[e.boolean[r]] || [], a = t.length; a-- > 0; ) e.boolean.push(t[a]);
47
+ for (n = e.alias[e.boolean[r]] || [], a = n.length; a-- > 0; ) e.boolean.push(n[a]);
48
48
  for (r = e.string.length; r-- > 0; )
49
- for (t = e.alias[e.string[r]] || [], a = t.length; a-- > 0; ) e.string.push(t[a]);
49
+ for (n = e.alias[e.string[r]] || [], a = n.length; a-- > 0; ) e.string.push(n[a]);
50
50
  if (p) {
51
51
  for (i in e.default)
52
- if (s = typeof e.default[i], t = e.alias[i] = e.alias[i] || [], e[s] !== void 0)
53
- for (e[s].push(i), r = 0; r < t.length; r++)
54
- e[s].push(t[r]);
52
+ if (s = typeof e.default[i], n = e.alias[i] = e.alias[i] || [], e[s] !== void 0)
53
+ for (e[s].push(i), r = 0; r < n.length; r++)
54
+ e[s].push(n[r]);
55
55
  }
56
56
  const d = h ? Object.keys(e.alias) : [];
57
57
  for (r = 0; r < f; r++) {
58
- if (c = n[r], c === "--") {
59
- o._ = o._.concat(n.slice(++r));
58
+ if (c = t[r], c === "--") {
59
+ o._ = o._.concat(t.slice(++r));
60
60
  break;
61
61
  }
62
62
  for (a = 0; a < c.length && c.charCodeAt(a) === 45; a++)
@@ -70,9 +70,9 @@ function B(n, e) {
70
70
  } else {
71
71
  for (l = a + 1; l < c.length && c.charCodeAt(l) !== 61; l++)
72
72
  ;
73
- for (s = c.substring(a, l), u = c.substring(++l) || r + 1 === f || ("" + n[r + 1]).charCodeAt(0) === 45 || n[++r], t = a === 2 ? [s] : s, l = 0; l < t.length; l++) {
74
- if (s = t[l], h && !~d.indexOf(s)) return e.unknown("-".repeat(a) + s);
75
- $(o, s, l + 1 < t.length || u, e);
73
+ for (s = c.substring(a, l), u = c.substring(++l) || r + 1 === f || ("" + t[r + 1]).charCodeAt(0) === 45 || t[++r], n = a === 2 ? [s] : s, l = 0; l < n.length; l++) {
74
+ if (s = n[l], h && !~d.indexOf(s)) return e.unknown("-".repeat(a) + s);
75
+ $(o, s, l + 1 < n.length || u, e);
76
76
  }
77
77
  }
78
78
  }
@@ -81,25 +81,25 @@ function B(n, e) {
81
81
  o[i] === void 0 && (o[i] = e.default[i]);
82
82
  if (P)
83
83
  for (i in o)
84
- for (t = e.alias[i] || []; t.length > 0; )
85
- o[t.shift()] = o[i];
84
+ for (n = e.alias[i] || []; n.length > 0; )
85
+ o[n.shift()] = o[i];
86
86
  return o;
87
87
  }
88
88
  async function M() {
89
89
  await I({}, "build");
90
- const n = B(process.argv.slice(2)), e = process.env.APP_PLATFORM_URL ?? n.APP_PLATFORM_URL;
90
+ const t = B(process.argv.slice(2)), e = process.env.APP_PLATFORM_URL ?? t.APP_PLATFORM_URL;
91
91
  if (!e)
92
92
  return console.log(
93
93
  g.red("error"),
94
94
  "api-client-generator APP_PLATFORM_URL is required in .env config or as api-client-generator argument"
95
95
  );
96
- if (!n.APP_PLATFORM_MODULES)
96
+ if (!t.APP_PLATFORM_MODULES)
97
97
  return console.log(g.red("error"), "api-client-generator modules command is required");
98
- if (!n.APP_API_CLIENT_DIRECTORY)
98
+ if (!t.APP_API_CLIENT_DIRECTORY)
99
99
  return console.log(g.red("error"), "api-client-generator outDir command is required");
100
- const i = n.APP_OUT_DIR ?? "./", t = new E(n.APP_API_CLIENT_DIRECTORY), c = n.APP_PLATFORM_MODULES.replace(/[[\]]/g, "").split(","), s = {};
100
+ const i = t.APP_OUT_DIR ?? "./", n = new j(t.APP_API_CLIENT_DIRECTORY), c = t.APP_PLATFORM_MODULES.replace(/[[\]]/g, "").split(","), s = {};
101
101
  let u, o;
102
- if (!n.SKIP_BUILD && (u = A.join(n.APP_API_CLIENT_DIRECTORY, "tsconfig.json"), o = {
102
+ if (!t.SKIP_BUILD && (u = A.join(t.APP_API_CLIENT_DIRECTORY, "tsconfig.json"), o = {
103
103
  extends: "@vc-shell/ts-config/tsconfig.json",
104
104
  compilerOptions: {
105
105
  baseUrl: ".",
@@ -114,7 +114,7 @@ async function M() {
114
114
  o = { ...o, ...r }, o && (o.compilerOptions = { ...o.compilerOptions, ...r.compilerOptions }, o.files = Array.from(new Set(o.files.concat(r.files || []))), o.include = Array.from(new Set(o.include.concat(r.include || [])))), console.log("api-client-generator %s Generated tsconfig.json", g.greenBright("success"));
115
115
  }
116
116
  for (const r of c) {
117
- const a = t.resolveApiClientPaths(r);
117
+ const a = n.resolveApiClientPaths(r);
118
118
  console.log(
119
119
  "api-client-generator %s Generating API client for %s module on %s environment",
120
120
  g.green("info"),
@@ -125,8 +125,8 @@ async function M() {
125
125
  "npx nswag",
126
126
  [
127
127
  "run",
128
- t.nswagPaths.configuration,
129
- `/variables:APP_PLATFORM_URL=${e},APP_PLATFORM_MODULE=${r},APP_AUTH_API_BASE_PATH=${t.nswagPaths.authApiBase},APP_TEMPLATE_DIRECTORY=${t.nswagPaths.templates},APP_API_CLIENT_PATH=${a.nswag}`,
128
+ n.nswagPaths.configuration,
129
+ `/variables:APP_PLATFORM_URL=${e},APP_PLATFORM_MODULE=${r},APP_AUTH_API_BASE_PATH=${n.nswagPaths.authApiBase},APP_TEMPLATE_DIRECTORY=${n.nswagPaths.templates},APP_API_CLIENT_PATH=${a.nswag}`,
130
130
  "/runtime:Net60"
131
131
  ],
132
132
  {
@@ -139,12 +139,12 @@ async function M() {
139
139
  "api-client-generator %s Successfully generated %s",
140
140
  g.greenBright("success"),
141
141
  g.whiteBright(a.console)
142
- ), !n.SKIP_BUILD && o) {
142
+ ), !t.SKIP_BUILD && o) {
143
143
  const f = r.toLowerCase();
144
144
  o.files.includes(`${f}.ts`) || o.files.push(`${f}.ts`);
145
145
  const P = {
146
146
  import: i !== "./" ? `./${i}/${f}.js` : `./${f}.js`,
147
- types: i !== "./" ? `./${i}/types/${f}.d.ts` : `./types/${f}.js`
147
+ types: i !== "./" ? `./${i}/types/${f}.d.ts` : `./types/${f}.d.ts`
148
148
  }, h = Object.keys(s).find(
149
149
  (p) => s[p].import.includes(`${f}.js`)
150
150
  );
@@ -158,15 +158,15 @@ async function M() {
158
158
  l
159
159
  );
160
160
  }
161
- if (!n.SKIP_BUILD && u && o) {
161
+ if (!t.SKIP_BUILD && u && o) {
162
162
  T(u, JSON.stringify(o, null, 2)), console.log("api-client-generator %s Compiling TypeScript files to JavaScript", g.green("info")), O("npx tsc", ["--project", u], {
163
163
  stdio: ["ignore", "inherit", "ignore"],
164
164
  shell: !0
165
165
  }).status === 0 ? console.log("api-client-generator %s Successfully compiled TypeScript files", g.greenBright("success")) : console.error("api-client-generator %s Failed to compile TypeScript files", g.red("error"));
166
- const a = A.join(n.APP_API_CLIENT_DIRECTORY, "package.json");
166
+ const a = A.join(t.APP_API_CLIENT_DIRECTORY, "package.json");
167
167
  let l = {
168
- name: n.APP_PACKAGE_NAME || "api-client",
169
- version: n.APP_PACKAGE_VERSION || "1.0.0",
168
+ name: t.APP_PACKAGE_NAME || "api-client",
169
+ version: t.APP_PACKAGE_VERSION || "1.0.0",
170
170
  files: i !== "./" ? [i, "package.json"] : ["package.json"],
171
171
  exports: s
172
172
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vc-shell/api-client-generator",
3
3
  "description": "Tool for API clients generation",
4
- "version": "1.0.336",
4
+ "version": "1.0.338",
5
5
  "type": "module",
6
6
  "bin": "./dist/api-client-generator.js",
7
7
  "files": [
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/cross-spawn": "^6.0.6",
16
- "@vc-shell/ts-config": "^1.0.336",
16
+ "@vc-shell/ts-config": "^1.0.338",
17
17
  "typescript": "~5.3.3"
18
18
  },
19
19
  "dependencies": {