@vc-shell/api-client-generator 1.1.86 → 1.1.88

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.88](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.87...v1.1.88) (2025-10-07)
2
+
3
+
4
+
5
+ ## [1.1.87](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.86...v1.1.87) (2025-10-06)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **api-client:** enhance module name parsing and export generation for improved flexibility and compatibility ([37d3e20](https://github.com/VirtoCommerce/vc-shell/commit/37d3e20831e6931d4fcc93c7127a53b7af2d7540))
11
+
12
+
13
+
1
14
  ## [1.1.86](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.85...v1.1.86) (2025-10-06)
2
15
 
3
16
 
@@ -1,212 +1,235 @@
1
1
  import e from "chalk";
2
- import { sync as x } from "cross-spawn";
3
- import { resolveConfig as j } from "vite";
4
- import { existsSync as _, mkdirSync as I, writeFileSync as T, readFileSync as R } from "node:fs";
5
- import m, { dirname as S, resolve as B, join as w, relative as E } from "node:path";
6
- import { fileURLToPath as O } from "node:url";
7
- import { cwd as L } from "node:process";
8
- import b from "mri";
9
- const k = O(import.meta.url), $ = S(k);
10
- class v {
2
+ import { sync as I } from "cross-spawn";
3
+ import { resolveConfig as S } from "vite";
4
+ import { existsSync as C, mkdirSync as T, writeFileSync as B, readFileSync as O } from "node:fs";
5
+ import h, { dirname as b, resolve as R, join as w, relative as E } from "node:path";
6
+ import { fileURLToPath as L } from "node:url";
7
+ import { cwd as k } from "node:process";
8
+ import N from "mri";
9
+ const M = L(import.meta.url), $ = b(M);
10
+ class F {
11
11
  workingDirectory;
12
12
  generatorDirectory;
13
13
  assetsDirectory;
14
14
  apiClientDirectory;
15
15
  nswagPaths;
16
16
  constructor(t) {
17
- this.workingDirectory = L(), this.generatorDirectory = B($, ".."), this.assetsDirectory = w(this.generatorDirectory, "public", "assets"), this.apiClientDirectory = B(this.workingDirectory, t), this.nswagPaths = {
17
+ this.workingDirectory = k(), this.generatorDirectory = R($, ".."), this.assetsDirectory = w(this.generatorDirectory, "public", "assets"), this.apiClientDirectory = R(this.workingDirectory, t), this.nswagPaths = {
18
18
  configuration: w(E(this.workingDirectory, this.assetsDirectory), "config.nswag"),
19
19
  authApiBase: "authApiBase.ts",
20
20
  templates: "templates"
21
21
  };
22
22
  }
23
23
  resolveApiClientPaths(t) {
24
- const a = `${t.toLowerCase()}.ts`;
24
+ const i = `${t.toLowerCase()}.ts`;
25
25
  return {
26
- fileName: a,
27
- nswag: w(E(this.assetsDirectory, this.apiClientDirectory), a),
28
- console: w(E(this.workingDirectory, this.apiClientDirectory), a)
26
+ fileName: i,
27
+ nswag: w(E(this.assetsDirectory, this.apiClientDirectory), i),
28
+ console: w(E(this.workingDirectory, this.apiClientDirectory), i)
29
29
  };
30
30
  }
31
31
  }
32
- function D(o, t, a = []) {
32
+ function D(o, t, i = []) {
33
33
  const r = { ...o };
34
- for (const l of a)
35
- l in t && (r[l] = t[l]);
36
- for (const [l, c] of Object.entries(t)) {
37
- const p = l;
38
- l in r && typeof r[p] == "object" && !Array.isArray(r[p]) && typeof c == "object" && !Array.isArray(c) && c !== null ? r[p] = { ...r[p], ...c } : a.includes(l) || (r[p] = c);
34
+ for (const a of i)
35
+ a in t && (r[a] = t[a]);
36
+ for (const [a, l] of Object.entries(t)) {
37
+ const g = a;
38
+ a in r && typeof r[g] == "object" && !Array.isArray(r[g]) && typeof l == "object" && !Array.isArray(l) && l !== null ? r[g] = { ...r[g], ...l } : i.includes(a) || (r[g] = l);
39
39
  }
40
40
  return r;
41
41
  }
42
- function F(o, t, a, r) {
43
- const l = {
42
+ function v(o, t, i, r) {
43
+ const a = {
44
44
  extends: "@vc-shell/ts-config/tsconfig.json",
45
45
  compilerOptions: {
46
46
  baseUrl: ".",
47
- declarationDir: m.join(a, "types"),
47
+ declarationDir: h.join(i, "types"),
48
48
  outDir: r,
49
49
  rootDir: "./"
50
50
  },
51
51
  files: [],
52
52
  include: ["*.ts"]
53
53
  };
54
- let c = { ...l };
55
- if (_(o))
54
+ let l = { ...a };
55
+ if (C(o))
56
56
  try {
57
- const p = R(o, "utf-8");
57
+ const g = O(o, "utf-8");
58
58
  try {
59
- const n = JSON.parse(p);
60
- c = D(l, n), n.compilerOptions && typeof n.compilerOptions == "object" && (c.compilerOptions = {
61
- ...l.compilerOptions,
62
- ...n.compilerOptions
63
- }, c.compilerOptions.outDir = r, c.compilerOptions.declarationDir = m.join(r, "types"));
64
- const y = Array.isArray(n.files) ? n.files : [];
65
- c.files = Array.from(/* @__PURE__ */ new Set([...t, ...y])), console.log("api-client-generator %s Updated existing tsconfig.json", e.greenBright("success"));
66
- } catch (n) {
59
+ const s = JSON.parse(g);
60
+ l = D(a, s), s.compilerOptions && typeof s.compilerOptions == "object" && (l.compilerOptions = {
61
+ ...a.compilerOptions,
62
+ ...s.compilerOptions
63
+ }, l.compilerOptions.outDir = r, l.compilerOptions.declarationDir = h.join(r, "types"));
64
+ const y = Array.isArray(s.files) ? s.files : [];
65
+ l.files = Array.from(/* @__PURE__ */ new Set([...t, ...y])), console.log("api-client-generator %s Updated existing tsconfig.json", e.greenBright("success"));
66
+ } catch (s) {
67
67
  console.error(
68
68
  "api-client-generator %s Failed to parse existing tsconfig.json, creating new one",
69
69
  e.yellow("warning"),
70
- n
71
- ), c = { ...l }, c.files = t;
70
+ s
71
+ ), l = { ...a }, l.files = t;
72
72
  }
73
- } catch (p) {
74
- console.error("api-client-generator %s Failed to read existing tsconfig.json", e.red("error"), p);
73
+ } catch (g) {
74
+ console.error("api-client-generator %s Failed to read existing tsconfig.json", e.red("error"), g);
75
75
  }
76
76
  else
77
- c.files = t, console.log("api-client-generator %s Created new tsconfig.json", e.greenBright("success"));
78
- return c;
77
+ l.files = t, console.log("api-client-generator %s Created new tsconfig.json", e.greenBright("success"));
78
+ return l;
79
79
  }
80
80
  function A(o) {
81
81
  let t = o;
82
- const a = [".d.ts", ".ts", ".js"];
82
+ const i = [".d.ts", ".ts", ".js"];
83
83
  let r;
84
84
  do {
85
85
  r = !1;
86
- for (const l of a)
87
- if (t.toLowerCase().endsWith(l.toLowerCase())) {
88
- t = t.substring(0, t.length - l.length), r = !0;
86
+ for (const a of i)
87
+ if (t.toLowerCase().endsWith(a.toLowerCase())) {
88
+ t = t.substring(0, t.length - a.length), r = !0;
89
89
  break;
90
90
  }
91
91
  } while (r);
92
- return t = t.replace(/\/\.\//g, "/"), t = t.replace(/\/+/g, "/"), t = t.replace(/\.\.\//g, ""), t !== "." && !t.startsWith("./") && !t.startsWith("/") && !m.isAbsolute(t) && (t = "./" + t), t.startsWith("//") && (t = "./" + t.substring(2)), t !== "." && t.startsWith("/") && !t.startsWith("./") && !m.isAbsolute(t) && (t = "." + t), t !== "." && t.startsWith("././") && (t = "./" + t.substring(3)), t;
92
+ return t = t.replace(/\/\.\//g, "/"), t = t.replace(/\/+/g, "/"), t = t.replace(/\.\.\//g, ""), t !== "." && !t.startsWith("./") && !t.startsWith("/") && !h.isAbsolute(t) && (t = "./" + t), t.startsWith("//") && (t = "./" + t.substring(2)), t !== "." && t.startsWith("/") && !t.startsWith("./") && !h.isAbsolute(t) && (t = "." + t), t !== "." && t.startsWith("././") && (t = "./" + t.substring(3)), t;
93
93
  }
94
- function P(o) {
94
+ function _(o) {
95
95
  let t = A(o);
96
- return t = m.basename(t), t = t.replace(/^virtocommerce\./i, ""), t.toLowerCase();
96
+ t = h.basename(t);
97
+ const i = t.toLowerCase(), r = i.indexOf(".");
98
+ if (r > 0) {
99
+ const a = i.substring(0, r), l = i.substring(r + 1);
100
+ return {
101
+ prefix: a,
102
+ coreName: l,
103
+ fullName: i
104
+ };
105
+ }
106
+ return {
107
+ prefix: void 0,
108
+ coreName: i,
109
+ fullName: i
110
+ };
111
+ }
112
+ function j(o) {
113
+ return _(o).coreName;
97
114
  }
98
- function M(o) {
99
- return o ? [`./${o}`, `./virtocommerce.${o}`] : [];
115
+ function U(o, t) {
116
+ if (!o)
117
+ return [];
118
+ const i = [`./${o}`];
119
+ return t && i.push(`./${t}.${o}`), i;
100
120
  }
101
- function N(o, t, a, r) {
102
- const l = {}, c = /* @__PURE__ */ new Set();
103
- for (const d of o) {
104
- const i = P(d);
105
- if (!i) continue;
106
- const g = `virtocommerce.${i}`, f = `./${m.join(t, `${g}.js`)}`, h = `./${m.join(t, "types", `${g}.d.ts`)}`, s = { import: f, types: h }, u = M(i);
107
- for (const C of u)
108
- l[C] = s, r && console.log(
121
+ function P(o) {
122
+ return o.replace(/\\/g, "/");
123
+ }
124
+ function Y(o, t, i, r) {
125
+ const a = {}, l = /* @__PURE__ */ new Set();
126
+ for (const f of o) {
127
+ const n = _(f);
128
+ if (!n.coreName) continue;
129
+ const u = n.fullName, p = P(`./${h.join(t, `${u}.js`)}`), m = P(`./${h.join(t, "types", `${u}.d.ts`)}`), c = { import: p, types: m }, d = U(n.coreName, n.prefix);
130
+ for (const x of d)
131
+ a[x] = c, r && console.log(
109
132
  "api-client-generator %s Generated standard export: %s -> { import: %s, types: %s }",
110
133
  e.blue("debug"),
111
- e.whiteBright(C),
112
- e.whiteBright(f),
113
- e.whiteBright(h)
134
+ e.whiteBright(x),
135
+ e.whiteBright(p),
136
+ e.whiteBright(m)
114
137
  );
115
- c.add(i);
138
+ l.add(n.coreName);
116
139
  }
117
- const p = { ...l };
118
- if (a)
119
- for (const [d, i] of Object.entries(a)) {
120
- if (d === ".")
140
+ const g = { ...a };
141
+ if (i)
142
+ for (const [f, n] of Object.entries(i)) {
143
+ if (f === ".")
121
144
  continue;
122
- if (typeof i != "object" || i === null) {
145
+ if (typeof n != "object" || n === null) {
123
146
  r && console.log(
124
147
  "api-client-generator %s Skipping malformed existing export value for key: %s",
125
148
  e.yellow("warning"),
126
- d
149
+ f
127
150
  );
128
151
  continue;
129
152
  }
130
- const g = i;
131
- if (!g.import || !g.types) {
153
+ const u = n;
154
+ if (!u.import || !u.types) {
132
155
  r && console.log(
133
156
  "api-client-generator %s Skipping existing export with missing import/types for key: %s",
134
157
  e.yellow("warning"),
135
- d
158
+ f
136
159
  );
137
160
  continue;
138
161
  }
139
- const f = A(d);
140
- if (!(!f || f === "."))
141
- if (P(f), f in l)
162
+ const p = A(f);
163
+ if (!(!p || p === "."))
164
+ if (j(p), p in a)
142
165
  r && console.log(
143
166
  "api-client-generator %s Existing export key '%s' was handled by new generation.",
144
167
  e.blue("debug"),
145
- e.whiteBright(f)
168
+ e.whiteBright(p)
146
169
  );
147
170
  else {
148
- const h = A(g.import), s = A(g.types);
149
- p[f] = {
150
- import: `${h}.js`,
151
- types: `${s}.d.ts`
171
+ const m = A(u.import), c = A(u.types);
172
+ g[p] = {
173
+ import: P(`${m}.js`),
174
+ types: P(`${c}.d.ts`)
152
175
  }, r && console.log(
153
176
  "api-client-generator %s Preserved existing export: %s -> { import: %s, types: %s }",
154
177
  e.blue("debug"),
155
- e.whiteBright(f),
156
- e.whiteBright(`${h}.js`),
157
- e.whiteBright(`${s}.d.ts`)
178
+ e.whiteBright(p),
179
+ e.whiteBright(`${m}.js`),
180
+ e.whiteBright(`${c}.d.ts`)
158
181
  );
159
182
  }
160
183
  }
161
- const n = /* @__PURE__ */ new Set();
162
- for (const d in p) {
163
- if (d === ".") continue;
164
- const i = P(d);
165
- i && n.add(i);
184
+ const s = /* @__PURE__ */ new Map();
185
+ for (const f in g) {
186
+ if (f === ".") continue;
187
+ const n = _(f);
188
+ n.coreName && s.set(n.coreName, n.fullName);
166
189
  }
167
- const y = Array.from(n);
190
+ const y = Array.from(s.keys());
168
191
  if (y.length === 1) {
169
- const d = y[0], i = `virtocommerce.${d}`, g = `./${m.join(t, `${i}.js`)}`, f = `./${m.join(t, "types", `${i}.d.ts`)}`;
170
- p["."] = {
171
- import: g,
172
- types: f
192
+ const f = y[0], n = s.get(f), u = P(`./${h.join(t, `${n}.js`)}`), p = P(`./${h.join(t, "types", `${n}.d.ts`)}`);
193
+ g["."] = {
194
+ import: u,
195
+ types: p
173
196
  }, r && console.log(
174
197
  "api-client-generator %s Set root export for single module '%s': { import: %s, types: %s }",
175
198
  e.blue("debug"),
176
- e.whiteBright(d),
177
- e.whiteBright(g),
178
- e.whiteBright(f)
199
+ e.whiteBright(n),
200
+ e.whiteBright(u),
201
+ e.whiteBright(p)
179
202
  );
180
- } else if (a && "." in a) {
181
- const d = a["."];
182
- if (typeof d == "object" && d !== null) {
183
- const i = d;
184
- if (i.import && i.types) {
185
- const g = P(i.import);
186
- if (g && y.includes(g)) {
187
- const f = `virtocommerce.${g}`, h = `./${m.join(t, `${f}.js`)}`, s = `./${m.join(t, "types", `${f}.d.ts`)}`;
188
- p["."] = { import: h, types: s }, r && console.log(
203
+ } else if (i && "." in i) {
204
+ const f = i["."];
205
+ if (typeof f == "object" && f !== null) {
206
+ const n = f;
207
+ if (n.import && n.types) {
208
+ const p = _(n.import).coreName;
209
+ if (p && y.includes(p)) {
210
+ const m = s.get(p), c = P(`./${h.join(t, `${m}.js`)}`), d = P(`./${h.join(t, "types", `${m}.d.ts`)}`);
211
+ g["."] = { import: c, types: d }, r && console.log(
189
212
  "api-client-generator %s Preserved and standardized existing root export pointing to module '%s'",
190
213
  e.blue("debug"),
191
- e.whiteBright(g)
214
+ e.whiteBright(m)
192
215
  );
193
216
  } else r && console.log(
194
217
  "api-client-generator %s Removed existing root export as it pointed to an unknown or unhandled module '%s'",
195
218
  e.yellow("warning"),
196
- g || "unknown"
219
+ p || "unknown"
197
220
  );
198
221
  } else r && console.log("api-client-generator %s Removed malformed existing root export.", e.yellow("warning"));
199
222
  }
200
223
  }
201
- return p;
224
+ return g;
202
225
  }
203
- function U(o, t, a) {
204
- const r = a.VERBOSE ?? !1, l = a.APP_BUILD_DIR ?? "dist", c = [];
205
- l && c.push(l), c.push("package.json");
206
- const p = {
207
- name: a.APP_PACKAGE_NAME || "api-client",
208
- version: a.APP_PACKAGE_VERSION || "1.0.0",
209
- files: c,
226
+ function J(o, t, i) {
227
+ const r = i.VERBOSE ?? !1, a = i.APP_BUILD_DIR ?? "dist", l = [];
228
+ a && l.push(a), l.push("package.json");
229
+ const g = {
230
+ name: i.APP_PACKAGE_NAME || "api-client",
231
+ version: i.APP_PACKAGE_VERSION || "1.0.0",
232
+ files: l,
210
233
  exports: {},
211
234
  // Add metadata to track generated content
212
235
  apiClientGenerator: {
@@ -214,13 +237,13 @@ function U(o, t, a) {
214
237
  generatedAt: (/* @__PURE__ */ new Date()).toISOString()
215
238
  }
216
239
  };
217
- let n = { ...p }, y, d, i;
218
- if (_(o))
240
+ let s = { ...g }, y, f, n;
241
+ if (C(o))
219
242
  try {
220
- const s = R(o, "utf-8");
243
+ const c = O(o, "utf-8");
221
244
  try {
222
- const u = JSON.parse(s);
223
- typeof u.module == "string" && (d = u.module), typeof u.types == "string" && (i = u.types), n = D(p, u, [
245
+ const d = JSON.parse(c);
246
+ typeof d.module == "string" && (f = d.module), typeof d.types == "string" && (n = d.types), s = D(g, d, [
224
247
  "name",
225
248
  "version",
226
249
  "description",
@@ -231,44 +254,44 @@ function U(o, t, a) {
231
254
  "scripts",
232
255
  "devDependencies",
233
256
  "dependencies"
234
- ]), n.apiClientGenerator = p.apiClientGenerator, u.files && Array.isArray(u.files) && (n.files = Array.from(/* @__PURE__ */ new Set([...c, ...u.files]))), y = u.exports, console.log("api-client-generator %s Updated existing package.json", e.greenBright("success"));
235
- } catch (u) {
257
+ ]), s.apiClientGenerator = g.apiClientGenerator, d.files && Array.isArray(d.files) && (s.files = Array.from(/* @__PURE__ */ new Set([...l, ...d.files]))), y = d.exports, console.log("api-client-generator %s Updated existing package.json", e.greenBright("success"));
258
+ } catch (d) {
236
259
  console.error(
237
260
  "api-client-generator %s Failed to parse existing package.json, creating new one",
238
261
  e.yellow("warning"),
239
- u
262
+ d
240
263
  );
241
264
  }
242
- } catch (s) {
243
- console.error("api-client-generator %s Failed to read existing package.json", e.red("error"), s);
265
+ } catch (c) {
266
+ console.error("api-client-generator %s Failed to read existing package.json", e.red("error"), c);
244
267
  }
245
268
  else
246
269
  console.log("api-client-generator %s Creating new package.json", e.greenBright("success"));
247
- n.exports = N(t, l, y, r);
248
- const g = Object.keys(n.exports), f = /* @__PURE__ */ new Set();
249
- for (const s of g) {
250
- if (s === ".") continue;
251
- const u = P(s);
252
- u && f.add(u);
270
+ s.exports = Y(t, a, y, r);
271
+ const u = Object.keys(s.exports), p = /* @__PURE__ */ new Set();
272
+ for (const c of u) {
273
+ if (c === ".") continue;
274
+ const d = j(c);
275
+ d && p.add(d);
253
276
  }
254
- if (Array.from(f).length, n.exports && "." in n.exports) {
255
- const s = n.exports["."];
256
- s && s.import && (n.module = s.import, r && console.log(
277
+ if (Array.from(p).length, s.exports && "." in s.exports) {
278
+ const c = s.exports["."];
279
+ c && c.import && (s.module = c.import, r && console.log(
257
280
  "api-client-generator %s Set 'module' field from root export: %s",
258
281
  e.blue("debug"),
259
- e.whiteBright(s.import)
260
- )), s && s.types && (n.types = s.types, r && console.log(
282
+ e.whiteBright(c.import)
283
+ )), c && c.types && (s.types = c.types, r && console.log(
261
284
  "api-client-generator %s Set 'types' field from root export: %s",
262
285
  e.blue("debug"),
263
- e.whiteBright(s.types)
286
+ e.whiteBright(c.types)
264
287
  ));
265
288
  } else
266
- "module" in n && (delete n.module, r && console.log("api-client-generator %s Removed 'module' field (no clear root export).", e.blue("debug"))), "types" in n && (delete n.types, r && console.log("api-client-generator %s Removed 'types' field (no clear root export).", e.blue("debug")));
267
- return n;
289
+ "module" in s && (delete s.module, r && console.log("api-client-generator %s Removed 'module' field (no clear root export).", e.blue("debug"))), "types" in s && (delete s.types, r && console.log("api-client-generator %s Removed 'types' field (no clear root export).", e.blue("debug")));
290
+ return s;
268
291
  }
269
- async function Y() {
270
- await j({}, "build");
271
- const o = b(process.argv.slice(2)), t = process.env.APP_PLATFORM_URL ?? o.APP_PLATFORM_URL, a = o.VERBOSE ?? !1, r = o.APP_TYPE_STYLE ?? "Class";
292
+ async function K() {
293
+ await S({}, "build");
294
+ const o = N(process.argv.slice(2)), t = process.env.APP_PLATFORM_URL ?? o.APP_PLATFORM_URL, i = o.VERBOSE ?? !1, r = o.APP_TYPE_STYLE ?? "Class";
272
295
  if (r !== "Class" && r !== "Interface") {
273
296
  console.error(
274
297
  "api-client-generator %s Invalid APP_TYPE_STYLE value: %s. Must be either 'Class' or 'Interface'",
@@ -277,7 +300,7 @@ async function Y() {
277
300
  );
278
301
  return;
279
302
  }
280
- if (a && console.log("api-client-generator %s Using APP_TYPE_STYLE: %s", e.blue("debug"), e.whiteBright(r)), !t)
303
+ if (i && console.log("api-client-generator %s Using APP_TYPE_STYLE: %s", e.blue("debug"), e.whiteBright(r)), !t)
281
304
  return console.log(
282
305
  e.red("error"),
283
306
  "api-client-generator APP_PLATFORM_URL is required in .env config or as api-client-generator argument"
@@ -286,83 +309,83 @@ async function Y() {
286
309
  return console.log(e.red("error"), "api-client-generator modules command is required");
287
310
  if (!o.APP_API_CLIENT_DIRECTORY)
288
311
  return console.log(e.red("error"), "api-client-generator outDir command is required");
289
- const l = o.APP_OUT_DIR ?? "./", c = o.APP_BUILD_DIR ?? "dist", p = new v(o.APP_API_CLIENT_DIRECTORY);
290
- if (!_(o.APP_API_CLIENT_DIRECTORY))
312
+ const a = o.APP_OUT_DIR ?? "./", l = o.APP_BUILD_DIR ?? "dist", g = new F(o.APP_API_CLIENT_DIRECTORY);
313
+ if (!C(o.APP_API_CLIENT_DIRECTORY))
291
314
  try {
292
- I(o.APP_API_CLIENT_DIRECTORY, { recursive: !0 }), console.log(
315
+ T(o.APP_API_CLIENT_DIRECTORY, { recursive: !0 }), console.log(
293
316
  "api-client-generator %s Created directory %s",
294
317
  e.greenBright("success"),
295
318
  e.whiteBright(o.APP_API_CLIENT_DIRECTORY)
296
319
  );
297
- } catch (i) {
320
+ } catch (n) {
298
321
  console.error(
299
322
  "api-client-generator %s Failed to create directory %s",
300
323
  e.red("error"),
301
324
  e.whiteBright(o.APP_API_CLIENT_DIRECTORY),
302
- i
325
+ n
303
326
  );
304
327
  return;
305
328
  }
306
- const n = m.join(o.APP_API_CLIENT_DIRECTORY, c);
307
- if (!_(n))
329
+ const s = h.join(o.APP_API_CLIENT_DIRECTORY, l);
330
+ if (!C(s))
308
331
  try {
309
- I(n, { recursive: !0 }), console.log(
332
+ T(s, { recursive: !0 }), console.log(
310
333
  "api-client-generator %s Created build directory %s",
311
334
  e.greenBright("success"),
312
- e.whiteBright(n)
335
+ e.whiteBright(s)
313
336
  );
314
- } catch (i) {
337
+ } catch (n) {
315
338
  console.error(
316
339
  "api-client-generator %s Failed to create build directory %s",
317
340
  e.red("error"),
318
- e.whiteBright(n),
319
- i
341
+ e.whiteBright(s),
342
+ n
320
343
  );
321
344
  }
322
- const y = o.APP_PLATFORM_MODULES.replace(/[[\]]/g, "").split(","), d = [];
323
- for (const i of y) {
324
- const g = p.resolveApiClientPaths(i);
345
+ const y = o.APP_PLATFORM_MODULES.replace(/[[\]]/g, "").split(","), f = [];
346
+ for (const n of y) {
347
+ const u = g.resolveApiClientPaths(n);
325
348
  console.log(
326
349
  "api-client-generator %s Generating API client for %s module on %s environment",
327
350
  e.green("info"),
328
- e.whiteBright(i),
351
+ e.whiteBright(n),
329
352
  e.whiteBright(t)
330
353
  );
331
- const f = [
354
+ const p = [
332
355
  `APP_PLATFORM_URL=${t}`,
333
- `APP_PLATFORM_MODULE=${i}`,
334
- `APP_AUTH_API_BASE_PATH=${p.nswagPaths.authApiBase}`,
335
- `APP_TEMPLATE_DIRECTORY=${p.nswagPaths.templates}`,
336
- `APP_API_CLIENT_PATH=${g.nswag}`,
356
+ `APP_PLATFORM_MODULE=${n}`,
357
+ `APP_AUTH_API_BASE_PATH=${g.nswagPaths.authApiBase}`,
358
+ `APP_TEMPLATE_DIRECTORY=${g.nswagPaths.templates}`,
359
+ `APP_API_CLIENT_PATH=${u.nswag}`,
337
360
  `APP_TYPE_STYLE=${r}`
338
- ].join(","), h = ["run", p.nswagPaths.configuration, `/variables:${f}`, "/runtime:Net60"];
339
- a && (console.log("api-client-generator %s Running command: npx nswag %s", e.blue("debug"), h.join(" ")), console.log("api-client-generator %s Variables: %s", e.blue("debug"), f));
340
- const s = x("npx nswag", h, {
341
- stdio: ["ignore", a ? "inherit" : "pipe", "inherit"],
361
+ ].join(","), m = ["run", g.nswagPaths.configuration, `/variables:${p}`, "/runtime:Net60"];
362
+ i && (console.log("api-client-generator %s Running command: npx nswag %s", e.blue("debug"), m.join(" ")), console.log("api-client-generator %s Variables: %s", e.blue("debug"), p));
363
+ const c = I("npx nswag", m, {
364
+ stdio: ["ignore", i ? "inherit" : "pipe", "inherit"],
342
365
  shell: !0
343
366
  });
344
- s.status === 0 ? (console.log(
367
+ c.status === 0 ? (console.log(
345
368
  "api-client-generator %s Successfully generated %s",
346
369
  e.greenBright("success"),
347
- e.whiteBright(g.console)
348
- ), o.SKIP_BUILD || d.push(`${i.toLowerCase()}.ts`)) : (console.error(
370
+ e.whiteBright(u.console)
371
+ ), o.SKIP_BUILD || f.push(`${n.toLowerCase()}.ts`)) : (console.error(
349
372
  "api-client-generator %s Failed to generate %s",
350
373
  e.red("error"),
351
- e.whiteBright(g.console)
352
- ), a && console.error(
374
+ e.whiteBright(u.console)
375
+ ), i && console.error(
353
376
  "api-client-generator %s NSwag command failed with exit code: %s",
354
377
  e.red("error"),
355
- s.status
378
+ c.status
356
379
  ));
357
380
  }
358
381
  if (!o.SKIP_BUILD) {
359
- const i = m.join(o.APP_API_CLIENT_DIRECTORY, "tsconfig.json"), g = F(i, d, l, c);
360
- T(i, JSON.stringify(g, null, 2)), console.log("api-client-generator %s Compiling TypeScript files to JavaScript", e.green("info")), x("npx tsc", ["--project", i], {
382
+ const n = h.join(o.APP_API_CLIENT_DIRECTORY, "tsconfig.json"), u = v(n, f, a, l);
383
+ B(n, JSON.stringify(u, null, 2)), console.log("api-client-generator %s Compiling TypeScript files to JavaScript", e.green("info")), I("npx tsc", ["--project", n], {
361
384
  stdio: ["ignore", "inherit", "ignore"],
362
385
  shell: !0
363
386
  }).status === 0 ? console.log("api-client-generator %s Successfully compiled TypeScript files", e.greenBright("success")) : console.error("api-client-generator %s Failed to compile TypeScript files", e.red("error"));
364
- const h = m.join(o.APP_API_CLIENT_DIRECTORY, "package.json"), s = U(h, d, o);
365
- T(h, JSON.stringify(s, null, 2)), console.log("api-client-generator %s Generated package.json", e.greenBright("success"));
387
+ const m = h.join(o.APP_API_CLIENT_DIRECTORY, "package.json"), c = J(m, f, o);
388
+ B(m, JSON.stringify(c, null, 2)), console.log("api-client-generator %s Generated package.json", e.greenBright("success"));
366
389
  }
367
390
  }
368
- Y();
391
+ K();
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.1.86",
4
+ "version": "1.1.88",
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.1.86",
16
+ "@vc-shell/ts-config": "^1.1.88",
17
17
  "typescript": "^5.8.3"
18
18
  },
19
19
  "dependencies": {