@vc-shell/api-client-generator 1.2.4-beta.4 → 1.2.4-beta.5

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.
@@ -1,21 +1,21 @@
1
1
  import e from "chalk";
2
- import { sync as k } from "cross-spawn";
3
- import { resolveConfig as L } from "vite";
4
- import { existsSync as T, mkdirSync as R, writeFileSync as v, readFileSync as j } from "node:fs";
5
- import y, { dirname as M, resolve as O, join as x, relative as I } from "node:path";
6
- import { fileURLToPath as U } from "node:url";
7
- import { cwd as $ } from "node:process";
8
- import F from "mri";
9
- const V = U(import.meta.url), G = M(V);
10
- class K {
2
+ import { sync as v } from "cross-spawn";
3
+ import { resolveConfig as U } from "vite";
4
+ import { existsSync as T, mkdirSync as O, writeFileSync as j, readFileSync as D } from "node:fs";
5
+ import y, { dirname as $, resolve as N, join as S, relative as R } from "node:path";
6
+ import { fileURLToPath as F } from "node:url";
7
+ import { cwd as V } from "node:process";
8
+ import K from "mri";
9
+ const G = F(import.meta.url), Y = $(G);
10
+ class J {
11
11
  workingDirectory;
12
12
  generatorDirectory;
13
13
  assetsDirectory;
14
14
  apiClientDirectory;
15
15
  nswagPaths;
16
16
  constructor(r) {
17
- this.workingDirectory = $(), this.generatorDirectory = O(G, ".."), this.assetsDirectory = x(this.generatorDirectory, "public", "assets"), this.apiClientDirectory = O(this.workingDirectory, r), this.nswagPaths = {
18
- configuration: x(I(this.workingDirectory, this.assetsDirectory), "config.nswag"),
17
+ this.workingDirectory = V(), this.generatorDirectory = N(Y, ".."), this.assetsDirectory = S(this.generatorDirectory, "public", "assets"), this.apiClientDirectory = N(this.workingDirectory, r), this.nswagPaths = {
18
+ configuration: S(R(this.workingDirectory, this.assetsDirectory), "config.nswag"),
19
19
  authApiBase: "authApiBase.ts",
20
20
  templates: "templates"
21
21
  };
@@ -24,23 +24,23 @@ class K {
24
24
  const i = `${r.toLowerCase()}.ts`;
25
25
  return {
26
26
  fileName: i,
27
- nswag: x(I(this.assetsDirectory, this.apiClientDirectory), i),
28
- console: x(I(this.workingDirectory, this.apiClientDirectory), i)
27
+ nswag: S(R(this.assetsDirectory, this.apiClientDirectory), i),
28
+ console: S(R(this.workingDirectory, this.apiClientDirectory), i)
29
29
  };
30
30
  }
31
31
  }
32
- function D(t, r, i = []) {
32
+ function L(t, r, i = []) {
33
33
  const o = { ...t };
34
- for (const l of i)
35
- l in r && (o[l] = r[l]);
36
- for (const [l, c] of Object.entries(r)) {
37
- const u = l;
38
- l in o && typeof o[u] == "object" && !Array.isArray(o[u]) && typeof c == "object" && !Array.isArray(c) && c !== null ? o[u] = { ...o[u], ...c } : i.includes(l) || (o[u] = c);
34
+ for (const n of i)
35
+ n in r && (o[n] = r[n]);
36
+ for (const [n, a] of Object.entries(r)) {
37
+ const d = n;
38
+ n in o && typeof o[d] == "object" && !Array.isArray(o[d]) && typeof a == "object" && !Array.isArray(a) && a !== null ? o[d] = { ...o[d], ...a } : i.includes(n) || (o[d] = a);
39
39
  }
40
40
  return o;
41
41
  }
42
- function Y(t, r, i, o) {
43
- const l = {
42
+ function q(t, r, i, o) {
43
+ const n = {
44
44
  extends: "@vc-shell/ts-config/tsconfig.json",
45
45
  compilerOptions: {
46
46
  baseUrl: ".",
@@ -51,55 +51,55 @@ function Y(t, r, i, o) {
51
51
  files: [],
52
52
  include: ["*.ts"]
53
53
  };
54
- let c = { ...l };
54
+ let a = { ...n };
55
55
  if (T(t))
56
56
  try {
57
- const u = j(t, "utf-8");
57
+ const d = D(t, "utf-8");
58
58
  try {
59
- const n = JSON.parse(u);
60
- c = D(l, n), n.compilerOptions && typeof n.compilerOptions == "object" && (c.compilerOptions = {
61
- ...l.compilerOptions,
62
- ...n.compilerOptions
63
- }, c.compilerOptions.outDir = o, c.compilerOptions.declarationDir = y.join(o, "types"));
64
- const P = Array.isArray(n.files) ? n.files : [];
65
- c.files = Array.from(/* @__PURE__ */ new Set([...r, ...P])), console.log("api-client-generator %s Updated existing tsconfig.json", e.greenBright("success"));
66
- } catch (n) {
59
+ const s = JSON.parse(d);
60
+ a = L(n, s), s.compilerOptions && typeof s.compilerOptions == "object" && (a.compilerOptions = {
61
+ ...n.compilerOptions,
62
+ ...s.compilerOptions
63
+ }, a.compilerOptions.outDir = o, a.compilerOptions.declarationDir = y.join(o, "types"));
64
+ const P = Array.isArray(s.files) ? s.files : [];
65
+ a.files = Array.from(/* @__PURE__ */ new Set([...r, ...P])), 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 = r;
70
+ s
71
+ ), a = { ...n }, a.files = r;
72
72
  }
73
- } catch (u) {
74
- console.error("api-client-generator %s Failed to read existing tsconfig.json", e.red("error"), u);
73
+ } catch (d) {
74
+ console.error("api-client-generator %s Failed to read existing tsconfig.json", e.red("error"), d);
75
75
  }
76
76
  else
77
- c.files = r, console.log("api-client-generator %s Created new tsconfig.json", e.greenBright("success"));
78
- return c;
77
+ a.files = r, console.log("api-client-generator %s Created new tsconfig.json", e.greenBright("success"));
78
+ return a;
79
79
  }
80
- function S(t) {
80
+ function C(t) {
81
81
  let r = t;
82
82
  const i = [".d.ts", ".ts", ".js"];
83
83
  let o;
84
84
  do {
85
85
  o = !1;
86
- for (const l of i)
87
- if (r.toLowerCase().endsWith(l.toLowerCase())) {
88
- r = r.substring(0, r.length - l.length), o = !0;
86
+ for (const n of i)
87
+ if (r.toLowerCase().endsWith(n.toLowerCase())) {
88
+ r = r.substring(0, r.length - n.length), o = !0;
89
89
  break;
90
90
  }
91
91
  } while (o);
92
92
  return r = r.replace(/\/\.\//g, "/"), r = r.replace(/\/+/g, "/"), r = r.replace(/\.\.\//g, ""), r !== "." && !r.startsWith("./") && !r.startsWith("/") && !y.isAbsolute(r) && (r = "./" + r), r.startsWith("//") && (r = "./" + r.substring(2)), r !== "." && r.startsWith("/") && !r.startsWith("./") && !y.isAbsolute(r) && (r = "." + r), r !== "." && r.startsWith("././") && (r = "./" + r.substring(3)), r;
93
93
  }
94
- function C(t) {
95
- let r = S(t);
94
+ function B(t) {
95
+ let r = C(t);
96
96
  r = y.basename(r);
97
97
  const i = r.toLowerCase(), o = i.indexOf(".");
98
98
  if (o > 0) {
99
- const l = i.substring(0, o), c = i.substring(o + 1);
99
+ const n = i.substring(0, o), a = i.substring(o + 1);
100
100
  return {
101
- prefix: l,
102
- coreName: c,
101
+ prefix: n,
102
+ coreName: a,
103
103
  fullName: i
104
104
  };
105
105
  }
@@ -109,10 +109,10 @@ function C(t) {
109
109
  fullName: i
110
110
  };
111
111
  }
112
- function N(t) {
113
- return C(t).coreName;
112
+ function M(t) {
113
+ return B(t).coreName;
114
114
  }
115
- function J(t, r) {
115
+ function W(t, r) {
116
116
  if (!t)
117
117
  return [];
118
118
  const i = [`./${t}`];
@@ -121,94 +121,94 @@ function J(t, r) {
121
121
  function E(t) {
122
122
  return t.replace(/\\/g, "/");
123
123
  }
124
- function q(t, r, i, o) {
125
- const l = {}, c = /* @__PURE__ */ new Set();
126
- for (const f of t) {
127
- const s = C(f);
128
- if (!s.coreName) continue;
129
- const h = s.fullName, a = E(`./${y.join(r, `${h}.js`)}`), m = E(`./${y.join(r, "types", `${h}.d.ts`)}`), p = { import: a, types: m }, g = J(s.coreName, s.prefix);
130
- for (const d of g)
131
- l[d] = p, o && console.log(
124
+ function z(t, r, i, o) {
125
+ const n = {}, a = /* @__PURE__ */ new Set();
126
+ for (const u of t) {
127
+ const p = B(u);
128
+ if (!p.coreName) continue;
129
+ const h = p.fullName, l = E(`./${y.join(r, `${h}.js`)}`), m = E(`./${y.join(r, "types", `${h}.d.ts`)}`), c = { import: l, types: m }, g = W(p.coreName, p.prefix);
130
+ for (const b of g)
131
+ n[b] = c, o && console.log(
132
132
  "api-client-generator %s Generated standard export: %s -> { import: %s, types: %s }",
133
133
  e.blue("debug"),
134
- e.whiteBright(d),
135
- e.whiteBright(a),
134
+ e.whiteBright(b),
135
+ e.whiteBright(l),
136
136
  e.whiteBright(m)
137
137
  );
138
- c.add(s.coreName);
138
+ a.add(p.coreName);
139
139
  }
140
- const u = { ...l };
140
+ const d = { ...n };
141
141
  if (i)
142
- for (const [f, s] of Object.entries(i)) {
143
- if (f === ".")
142
+ for (const [u, p] of Object.entries(i)) {
143
+ if (u === ".")
144
144
  continue;
145
- if (typeof s != "object" || s === null) {
145
+ if (typeof p != "object" || p === null) {
146
146
  o && console.log(
147
147
  "api-client-generator %s Skipping malformed existing export value for key: %s",
148
148
  e.yellow("warning"),
149
- f
149
+ u
150
150
  );
151
151
  continue;
152
152
  }
153
- const h = s;
153
+ const h = p;
154
154
  if (!h.import || !h.types) {
155
155
  o && console.log(
156
156
  "api-client-generator %s Skipping existing export with missing import/types for key: %s",
157
157
  e.yellow("warning"),
158
- f
158
+ u
159
159
  );
160
160
  continue;
161
161
  }
162
- const a = S(f);
163
- if (!(!a || a === "."))
164
- if (N(a), a in l)
162
+ const l = C(u);
163
+ if (!(!l || l === "."))
164
+ if (M(l), l in n)
165
165
  o && console.log(
166
166
  "api-client-generator %s Existing export key '%s' was handled by new generation.",
167
167
  e.blue("debug"),
168
- e.whiteBright(a)
168
+ e.whiteBright(l)
169
169
  );
170
170
  else {
171
- const m = S(h.import), p = S(h.types);
172
- u[a] = {
171
+ const m = C(h.import), c = C(h.types);
172
+ d[l] = {
173
173
  import: E(`${m}.js`),
174
- types: E(`${p}.d.ts`)
174
+ types: E(`${c}.d.ts`)
175
175
  }, o && console.log(
176
176
  "api-client-generator %s Preserved existing export: %s -> { import: %s, types: %s }",
177
177
  e.blue("debug"),
178
- e.whiteBright(a),
178
+ e.whiteBright(l),
179
179
  e.whiteBright(`${m}.js`),
180
- e.whiteBright(`${p}.d.ts`)
180
+ e.whiteBright(`${c}.d.ts`)
181
181
  );
182
182
  }
183
183
  }
184
- const n = /* @__PURE__ */ new Map();
185
- for (const f in u) {
186
- if (f === ".") continue;
187
- const s = C(f);
188
- s.coreName && n.set(s.coreName, s.fullName);
184
+ const s = /* @__PURE__ */ new Map();
185
+ for (const u in d) {
186
+ if (u === ".") continue;
187
+ const p = B(u);
188
+ p.coreName && s.set(p.coreName, p.fullName);
189
189
  }
190
- const P = Array.from(n.keys());
190
+ const P = Array.from(s.keys());
191
191
  if (P.length === 1) {
192
- const f = P[0], s = n.get(f), h = E(`./${y.join(r, `${s}.js`)}`), a = E(`./${y.join(r, "types", `${s}.d.ts`)}`);
193
- u["."] = {
192
+ const u = P[0], p = s.get(u), h = E(`./${y.join(r, `${p}.js`)}`), l = E(`./${y.join(r, "types", `${p}.d.ts`)}`);
193
+ d["."] = {
194
194
  import: h,
195
- types: a
195
+ types: l
196
196
  }, o && console.log(
197
197
  "api-client-generator %s Set root export for single module '%s': { import: %s, types: %s }",
198
198
  e.blue("debug"),
199
- e.whiteBright(s),
199
+ e.whiteBright(p),
200
200
  e.whiteBright(h),
201
- e.whiteBright(a)
201
+ e.whiteBright(l)
202
202
  );
203
203
  } else if (i && "." in i) {
204
- const f = i["."];
205
- if (typeof f == "object" && f !== null) {
206
- const s = f;
207
- if (s.import && s.types) {
208
- const a = C(s.import).coreName;
209
- if (a && P.includes(a)) {
210
- const m = n.get(a), p = E(`./${y.join(r, `${m}.js`)}`), g = E(`./${y.join(r, "types", `${m}.d.ts`)}`);
211
- u["."] = { import: p, types: g }, o && console.log(
204
+ const u = i["."];
205
+ if (typeof u == "object" && u !== null) {
206
+ const p = u;
207
+ if (p.import && p.types) {
208
+ const l = B(p.import).coreName;
209
+ if (l && P.includes(l)) {
210
+ const m = s.get(l), c = E(`./${y.join(r, `${m}.js`)}`), g = E(`./${y.join(r, "types", `${m}.d.ts`)}`);
211
+ d["."] = { import: c, types: g }, o && console.log(
212
212
  "api-client-generator %s Preserved and standardized existing root export pointing to module '%s'",
213
213
  e.blue("debug"),
214
214
  e.whiteBright(m)
@@ -216,20 +216,20 @@ function q(t, r, i, o) {
216
216
  } else o && console.log(
217
217
  "api-client-generator %s Removed existing root export as it pointed to an unknown or unhandled module '%s'",
218
218
  e.yellow("warning"),
219
- a || "unknown"
219
+ l || "unknown"
220
220
  );
221
221
  } else o && console.log("api-client-generator %s Removed malformed existing root export.", e.yellow("warning"));
222
222
  }
223
223
  }
224
- return u;
224
+ return d;
225
225
  }
226
- function W(t, r, i) {
227
- const o = i.VERBOSE ?? !1, l = i.APP_BUILD_DIR ?? "dist", c = [];
228
- l && c.push(l), c.push("package.json");
229
- const u = {
226
+ function H(t, r, i) {
227
+ const o = i.VERBOSE ?? !1, n = i.APP_BUILD_DIR ?? "dist", a = [];
228
+ n && a.push(n), a.push("package.json");
229
+ const d = {
230
230
  name: i.APP_PACKAGE_NAME || "api-client",
231
231
  version: i.APP_PACKAGE_VERSION || "1.0.0",
232
- files: c,
232
+ files: a,
233
233
  exports: {},
234
234
  // Add metadata to track generated content
235
235
  apiClientGenerator: {
@@ -237,13 +237,13 @@ function W(t, r, i) {
237
237
  generatedAt: (/* @__PURE__ */ new Date()).toISOString()
238
238
  }
239
239
  };
240
- let n = { ...u }, P, f, s;
240
+ let s = { ...d }, P, u, p;
241
241
  if (T(t))
242
242
  try {
243
- const p = j(t, "utf-8");
243
+ const c = D(t, "utf-8");
244
244
  try {
245
- const g = JSON.parse(p);
246
- typeof g.module == "string" && (f = g.module), typeof g.types == "string" && (s = g.types), n = D(u, g, [
245
+ const g = JSON.parse(c);
246
+ typeof g.module == "string" && (u = g.module), typeof g.types == "string" && (p = g.types), s = L(d, g, [
247
247
  "name",
248
248
  "version",
249
249
  "description",
@@ -254,7 +254,7 @@ function W(t, r, i) {
254
254
  "scripts",
255
255
  "devDependencies",
256
256
  "dependencies"
257
- ]), n.apiClientGenerator = u.apiClientGenerator, g.files && Array.isArray(g.files) && (n.files = Array.from(/* @__PURE__ */ new Set([...c, ...g.files]))), P = g.exports, console.log("api-client-generator %s Updated existing package.json", e.greenBright("success"));
257
+ ]), s.apiClientGenerator = d.apiClientGenerator, g.files && Array.isArray(g.files) && (s.files = Array.from(/* @__PURE__ */ new Set([...a, ...g.files]))), P = g.exports, console.log("api-client-generator %s Updated existing package.json", e.greenBright("success"));
258
258
  } catch (g) {
259
259
  console.error(
260
260
  "api-client-generator %s Failed to parse existing package.json, creating new one",
@@ -262,156 +262,163 @@ function W(t, r, i) {
262
262
  g
263
263
  );
264
264
  }
265
- } catch (p) {
266
- console.error("api-client-generator %s Failed to read existing package.json", e.red("error"), p);
265
+ } catch (c) {
266
+ console.error("api-client-generator %s Failed to read existing package.json", e.red("error"), c);
267
267
  }
268
268
  else
269
269
  console.log("api-client-generator %s Creating new package.json", e.greenBright("success"));
270
- n.exports = q(r, l, P, o);
271
- const h = Object.keys(n.exports), a = /* @__PURE__ */ new Set();
272
- for (const p of h) {
273
- if (p === ".") continue;
274
- const g = N(p);
275
- g && a.add(g);
270
+ s.exports = z(r, n, P, o);
271
+ const h = Object.keys(s.exports), l = /* @__PURE__ */ new Set();
272
+ for (const c of h) {
273
+ if (c === ".") continue;
274
+ const g = M(c);
275
+ g && l.add(g);
276
276
  }
277
- if (Array.from(a).length, n.exports && "." in n.exports) {
278
- const p = n.exports["."];
279
- p && p.import && (n.module = p.import, o && console.log(
277
+ if (Array.from(l).length, s.exports && "." in s.exports) {
278
+ const c = s.exports["."];
279
+ c && c.import && (s.module = c.import, o && console.log(
280
280
  "api-client-generator %s Set 'module' field from root export: %s",
281
281
  e.blue("debug"),
282
- e.whiteBright(p.import)
283
- )), p && p.types && (n.types = p.types, o && console.log(
282
+ e.whiteBright(c.import)
283
+ )), c && c.types && (s.types = c.types, o && console.log(
284
284
  "api-client-generator %s Set 'types' field from root export: %s",
285
285
  e.blue("debug"),
286
- e.whiteBright(p.types)
286
+ e.whiteBright(c.types)
287
287
  ));
288
288
  } else
289
- "module" in n && (delete n.module, o && console.log("api-client-generator %s Removed 'module' field (no clear root export).", e.blue("debug"))), "types" in n && (delete n.types, o && console.log("api-client-generator %s Removed 'types' field (no clear root export).", e.blue("debug")));
290
- return n;
289
+ "module" in s && (delete s.module, o && console.log("api-client-generator %s Removed 'module' field (no clear root export).", e.blue("debug"))), "types" in s && (delete s.types, o && console.log("api-client-generator %s Removed 'types' field (no clear root export).", e.blue("debug")));
290
+ return s;
291
291
  }
292
- async function z() {
292
+ async function Q() {
293
293
  try {
294
- await L({}, "build");
295
- const t = F(process.argv.slice(2)), r = process.env.APP_PLATFORM_URL ?? t.APP_PLATFORM_URL, i = process.env.APP_PLATFORM_MODULES ?? t.APP_PLATFORM_MODULES, o = process.env.APP_API_CLIENT_DIRECTORY ?? t.APP_API_CLIENT_DIRECTORY, l = process.env.APP_PACKAGE_NAME ?? t.APP_PACKAGE_NAME, c = process.env.APP_PACKAGE_VERSION ?? t.APP_PACKAGE_VERSION, u = process.env.APP_OUT_DIR ?? t.APP_OUT_DIR ?? "./", n = process.env.APP_BUILD_DIR ?? t.APP_BUILD_DIR ?? "dist", P = process.env.RUNTIME ?? t.RUNTIME ?? "Net80", f = process.env.SKIP_BUILD === "true" || t.SKIP_BUILD === !0, s = process.env.VERBOSE === "true" || t.VERBOSE === !0, h = process.env.APP_TYPE_STYLE ?? t.APP_TYPE_STYLE ?? "Class";
296
- h !== "Class" && h !== "Interface" && (console.error(
294
+ await U({}, "build");
295
+ const t = K(process.argv.slice(2)), r = process.env.APP_PLATFORM_URL ?? t.APP_PLATFORM_URL, i = r?.endsWith("/") ? r : r && `${r}/`, o = process.env.APP_PLATFORM_MODULES ?? t.APP_PLATFORM_MODULES, n = process.env.APP_API_CLIENT_DIRECTORY ?? t.APP_API_CLIENT_DIRECTORY, a = process.env.APP_PACKAGE_NAME ?? t.APP_PACKAGE_NAME, d = process.env.APP_PACKAGE_VERSION ?? t.APP_PACKAGE_VERSION, s = process.env.APP_OUT_DIR ?? t.APP_OUT_DIR ?? "./", P = process.env.APP_BUILD_DIR ?? t.APP_BUILD_DIR ?? "dist", u = process.env.RUNTIME ?? t.RUNTIME ?? "Net80", p = ["Net80", "Net90", "Net100"];
296
+ p.includes(u) || console.warn(
297
+ "api-client-generator %s Unknown RUNTIME value: %s. Known values: %s. Proceeding anyway — NSwag will report an error if the runtime is unsupported.",
298
+ e.yellow("warning"),
299
+ e.whiteBright(u),
300
+ e.whiteBright(p.join(", "))
301
+ );
302
+ const h = process.env.SKIP_BUILD === "true" || t.SKIP_BUILD === !0, l = process.env.VERBOSE === "true" || t.VERBOSE === !0, m = process.env.APP_TYPE_STYLE ?? t.APP_TYPE_STYLE ?? "Class";
303
+ m !== "Class" && m !== "Interface" && (console.error(
297
304
  "api-client-generator %s Invalid APP_TYPE_STYLE value: %s. Must be either 'Class' or 'Interface'",
298
305
  e.red("error"),
299
- e.whiteBright(h)
300
- ), process.exit(1)), s && console.log(
306
+ e.whiteBright(m)
307
+ ), process.exit(1)), l && console.log(
301
308
  "api-client-generator %s Using APP_TYPE_STYLE: %s",
302
309
  e.blue("debug"),
303
- e.whiteBright(h)
304
- ), r || (console.error(
310
+ e.whiteBright(m)
311
+ ), i || (console.error(
305
312
  "api-client-generator %s APP_PLATFORM_URL is required in .env config or as api-client-generator argument",
306
313
  e.red("error")
307
- ), process.exit(1)), i || (console.error(
314
+ ), process.exit(1)), o || (console.error(
308
315
  "api-client-generator %s APP_PLATFORM_MODULES is required in .env config or as api-client-generator argument",
309
316
  e.red("error")
310
- ), process.exit(1)), o || (console.error(
317
+ ), process.exit(1)), n || (console.error(
311
318
  "api-client-generator %s APP_API_CLIENT_DIRECTORY is required in .env config or as api-client-generator argument",
312
319
  e.red("error")
313
320
  ), process.exit(1));
314
- const a = new K(o);
315
- if (!T(o))
321
+ const c = new J(n);
322
+ if (!T(n))
316
323
  try {
317
- R(o, { recursive: !0 }), console.log(
324
+ O(n, { recursive: !0 }), console.log(
318
325
  "api-client-generator %s Created directory %s",
319
326
  e.greenBright("success"),
320
- e.whiteBright(o)
327
+ e.whiteBright(n)
321
328
  );
322
- } catch (d) {
329
+ } catch (f) {
323
330
  console.error(
324
331
  "api-client-generator %s Failed to create directory %s",
325
332
  e.red("error"),
326
- e.whiteBright(o)
327
- ), console.error(e.red("Error details:"), d), console.error("api-client-generator %s Directory creation troubleshooting:", e.blue("info")), console.error(e.blue(" - Check if you have write permissions in the parent directory")), console.error(e.blue(" - Ensure the path is valid and not too long")), console.error(e.blue(" - Try running with elevated permissions if needed")), process.exit(1);
333
+ e.whiteBright(n)
334
+ ), console.error(e.red("Error details:"), f), console.error("api-client-generator %s Directory creation troubleshooting:", e.blue("info")), console.error(e.blue(" - Check if you have write permissions in the parent directory")), console.error(e.blue(" - Ensure the path is valid and not too long")), console.error(e.blue(" - Try running with elevated permissions if needed")), process.exit(1);
328
335
  }
329
- const m = y.join(o, n);
330
- if (!T(m))
336
+ const g = y.join(n, P);
337
+ if (!T(g))
331
338
  try {
332
- R(m, { recursive: !0 }), console.log(
339
+ O(g, { recursive: !0 }), console.log(
333
340
  "api-client-generator %s Created build directory %s",
334
341
  e.greenBright("success"),
335
- e.whiteBright(m)
342
+ e.whiteBright(g)
336
343
  );
337
- } catch (d) {
344
+ } catch (f) {
338
345
  console.error(
339
346
  "api-client-generator %s Failed to create build directory %s",
340
347
  e.red("error"),
341
- e.whiteBright(m)
342
- ), console.error(e.red("Error details:"), d), console.error("api-client-generator %s Build directory creation troubleshooting:", e.blue("info")), console.error(e.blue(" - Check if you have write permissions in the API client directory")), console.error(e.blue(" - Ensure the build directory path is valid")), console.error(
348
+ e.whiteBright(g)
349
+ ), console.error(e.red("Error details:"), f), console.error("api-client-generator %s Build directory creation troubleshooting:", e.blue("info")), console.error(e.blue(" - Check if you have write permissions in the API client directory")), console.error(e.blue(" - Ensure the build directory path is valid")), console.error(
343
350
  e.blue(" - The TypeScript compiler will attempt to create the directory during compilation")
344
351
  );
345
352
  }
346
- const p = i.replace(/[[\]]/g, "").split(",").map((d) => d.trim()).filter((d) => d.length > 0), g = [];
347
- for (const d of p) {
348
- const b = a.resolveApiClientPaths(d);
353
+ const b = o.replace(/[[\]]/g, "").split(",").map((f) => f.trim()).filter((f) => f.length > 0), I = [];
354
+ for (const f of b) {
355
+ const _ = c.resolveApiClientPaths(f);
349
356
  console.log(
350
357
  "api-client-generator %s Generating API client for %s module on %s environment",
351
358
  e.green("info"),
352
- e.whiteBright(d),
353
- e.whiteBright(r)
359
+ e.whiteBright(f),
360
+ e.whiteBright(i)
354
361
  );
355
362
  const w = [
356
- `APP_PLATFORM_URL=${r}`,
357
- `APP_PLATFORM_MODULE=${d}`,
358
- `APP_AUTH_API_BASE_PATH=${a.nswagPaths.authApiBase}`,
359
- `APP_TEMPLATE_DIRECTORY=${a.nswagPaths.templates}`,
360
- `APP_API_CLIENT_PATH=${b.nswag}`,
361
- `APP_TYPE_STYLE=${h}`,
362
- `RUNTIME=${P}`
363
- ].join(","), _ = ["run", a.nswagPaths.configuration, `/variables:${w}`];
364
- s && (console.log(
363
+ `APP_PLATFORM_URL=${i}`,
364
+ `APP_PLATFORM_MODULE=${f}`,
365
+ `APP_AUTH_API_BASE_PATH=${c.nswagPaths.authApiBase}`,
366
+ `APP_TEMPLATE_DIRECTORY=${c.nswagPaths.templates}`,
367
+ `APP_API_CLIENT_PATH=${_.nswag}`,
368
+ `APP_TYPE_STYLE=${m}`,
369
+ `RUNTIME=${u}`
370
+ ].join(","), x = ["run", c.nswagPaths.configuration, `/variables:${w}`];
371
+ l && (console.log(
365
372
  "api-client-generator %s Running command: npx nswag %s",
366
373
  e.blue("debug"),
367
- _.join(" ")
374
+ x.join(" ")
368
375
  ), console.log("api-client-generator %s Variables: %s", e.blue("debug"), w));
369
- const A = k("npx nswag", _, {
370
- stdio: ["ignore", s ? "inherit" : "pipe", "inherit"],
376
+ const A = v("npx nswag", x, {
377
+ stdio: ["ignore", l ? "inherit" : "pipe", "inherit"],
371
378
  shell: !0
372
379
  });
373
380
  A.status === 0 ? (console.log(
374
381
  "api-client-generator %s Successfully generated %s",
375
382
  e.greenBright("success"),
376
- e.whiteBright(b.console)
377
- ), f || g.push(`${d.toLowerCase()}.ts`)) : (console.error(
383
+ e.whiteBright(_.console)
384
+ ), h || I.push(`${f.toLowerCase()}.ts`)) : (console.error(
378
385
  "api-client-generator %s Failed to generate %s",
379
386
  e.red("error"),
380
- e.whiteBright(b.console)
387
+ e.whiteBright(_.console)
381
388
  ), console.error(
382
389
  "api-client-generator %s NSwag command failed with exit code: %s",
383
390
  e.red("error"),
384
391
  A.status
385
- ), A.stderr && A.stderr.toString().trim() && (console.error("api-client-generator %s NSwag error output:", e.red("error")), console.error(e.red(A.stderr.toString()))), A.stdout && A.stdout.toString().trim() && (console.error("api-client-generator %s NSwag output:", e.yellow("warning")), console.error(e.yellow(A.stdout.toString()))), console.error("api-client-generator %s Troubleshooting tips:", e.blue("info")), console.error(e.blue(" - Check if the platform URL is accessible: %s"), r), console.error(e.blue(" - Verify the module name '%s' exists on the platform"), d), console.error(e.blue(` - Ensure .NET Core ${P} is installed`)), console.error(e.blue(" - Try running with --VERBOSE=true for more details")), process.exit(1));
392
+ ), A.stderr && A.stderr.toString().trim() && (console.error("api-client-generator %s NSwag error output:", e.red("error")), console.error(e.red(A.stderr.toString()))), A.stdout && A.stdout.toString().trim() && (console.error("api-client-generator %s NSwag output:", e.yellow("warning")), console.error(e.yellow(A.stdout.toString()))), console.error("api-client-generator %s Troubleshooting tips:", e.blue("info")), console.error(e.blue(" - Check if the platform URL is accessible: %s"), i), console.error(e.blue(" - Verify the module name '%s' exists on the platform"), f), console.error(e.blue(` - Ensure .NET Core ${u} is installed`)), console.error(e.blue(" - Try running with --VERBOSE=true for more details")), process.exit(1));
386
393
  }
387
- if (!f) {
388
- const d = y.join(o, "tsconfig.json"), b = Y(d, g, u, n);
394
+ if (!h) {
395
+ const f = y.join(n, "tsconfig.json"), _ = q(f, I, s, P);
389
396
  try {
390
- v(d, JSON.stringify(b, null, 2)), s && console.log("api-client-generator %s Updated tsconfig.json", e.greenBright("success"));
391
- } catch (B) {
392
- console.error("api-client-generator %s Failed to write tsconfig.json", e.red("error")), console.error(e.red("Error details:"), B), console.error("api-client-generator %s File writing troubleshooting:", e.blue("info")), console.error(e.blue(" - Check if you have write permissions in the API client directory")), console.error(e.blue(" - Ensure the file path is valid and not locked by another process")), console.error(e.blue(" - Try running with elevated permissions if needed")), process.exit(1);
397
+ j(f, JSON.stringify(_, null, 2)), l && console.log("api-client-generator %s Updated tsconfig.json", e.greenBright("success"));
398
+ } catch (k) {
399
+ console.error("api-client-generator %s Failed to write tsconfig.json", e.red("error")), console.error(e.red("Error details:"), k), console.error("api-client-generator %s File writing troubleshooting:", e.blue("info")), console.error(e.blue(" - Check if you have write permissions in the API client directory")), console.error(e.blue(" - Ensure the file path is valid and not locked by another process")), console.error(e.blue(" - Try running with elevated permissions if needed")), process.exit(1);
393
400
  }
394
401
  console.log("api-client-generator %s Compiling TypeScript files to JavaScript", e.green("info"));
395
- const w = k("npx tsc", ["--project", d], {
402
+ const w = v("npx tsc", ["--project", f], {
396
403
  stdio: ["ignore", "pipe", "pipe"],
397
404
  shell: !0
398
405
  });
399
406
  w.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")), w.stderr && w.stderr.toString().trim() && (console.error("api-client-generator %s TypeScript compilation errors:", e.red("error")), console.error(e.red(w.stderr.toString()))), w.stdout && w.stdout.toString().trim() && (console.error("api-client-generator %s TypeScript output:", e.yellow("warning")), console.error(e.yellow(w.stdout.toString()))), console.error("api-client-generator %s TypeScript compilation troubleshooting:", e.blue("info")), console.error(e.blue(" - Check if all required dependencies are installed")), console.error(e.blue(" - Verify TypeScript configuration in tsconfig.json")), console.error(e.blue(" - Ensure generated API files are valid TypeScript")), console.error(e.blue(" - Try running with --VERBOSE=true for more details")), process.exit(1));
400
- const _ = y.join(o, "package.json"), A = W(_, g, {
407
+ const x = y.join(n, "package.json"), A = H(x, I, {
401
408
  ...t,
402
- APP_PACKAGE_NAME: l,
403
- APP_PACKAGE_VERSION: c,
404
- APP_BUILD_DIR: n,
405
- VERBOSE: s
409
+ APP_PACKAGE_NAME: a,
410
+ APP_PACKAGE_VERSION: d,
411
+ APP_BUILD_DIR: P,
412
+ VERBOSE: l
406
413
  });
407
414
  try {
408
- v(_, JSON.stringify(A, null, 2)), console.log("api-client-generator %s Generated package.json", e.greenBright("success"));
409
- } catch (B) {
410
- console.error("api-client-generator %s Failed to write package.json", e.red("error")), console.error(e.red("Error details:"), B), console.error("api-client-generator %s Package.json writing troubleshooting:", e.blue("info")), console.error(e.blue(" - Check if you have write permissions in the API client directory")), console.error(e.blue(" - Ensure the file path is valid and not locked by another process")), console.error(e.blue(" - Try running with elevated permissions if needed")), process.exit(1);
415
+ j(x, JSON.stringify(A, null, 2)), console.log("api-client-generator %s Generated package.json", e.greenBright("success"));
416
+ } catch (k) {
417
+ console.error("api-client-generator %s Failed to write package.json", e.red("error")), console.error(e.red("Error details:"), k), console.error("api-client-generator %s Package.json writing troubleshooting:", e.blue("info")), console.error(e.blue(" - Check if you have write permissions in the API client directory")), console.error(e.blue(" - Ensure the file path is valid and not locked by another process")), console.error(e.blue(" - Try running with elevated permissions if needed")), process.exit(1);
411
418
  }
412
419
  }
413
420
  } catch (t) {
414
421
  console.error("api-client-generator %s Unexpected error occurred during API client generation", e.red("error")), console.error(e.red("Error details:"), t), console.error("api-client-generator %s General troubleshooting:", e.blue("info")), console.error(e.blue(" - Check if all required dependencies are installed")), console.error(e.blue(" - Ensure you have proper permissions")), console.error(e.blue(" - Try running with --VERBOSE=true for more details")), console.error(e.blue(" - Check the platform URL and module names")), process.exit(1);
415
422
  }
416
423
  }
417
- z();
424
+ Q();
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.2.4-beta.4",
4
+ "version": "1.2.4-beta.5",
5
5
  "type": "module",
6
6
  "bin": "./dist/api-client-generator.js",
7
7
  "files": [
@@ -13,14 +13,14 @@
13
13
  },
14
14
  "devDependencies": {
15
15
  "@types/cross-spawn": "^6.0.6",
16
- "@vc-shell/ts-config": "1.2.4-beta.4",
16
+ "@vc-shell/ts-config": "1.2.4-beta.5",
17
17
  "typescript": "^5.8.3"
18
18
  },
19
19
  "dependencies": {
20
20
  "chalk": "^2.4.2",
21
21
  "cross-spawn": "^7.0.3",
22
22
  "mri": "^1.2.0",
23
- "nswag": "^14.5.0",
23
+ "nswag": "^14.6.3",
24
24
  "vite": "^6.3.3",
25
25
  "vite-plugin-dts": "^3.6.4"
26
26
  },
@@ -28,5 +28,5 @@
28
28
  "access": "public",
29
29
  "registry": "https://registry.npmjs.org/"
30
30
  },
31
- "gitHead": "1b590c9e7733b1784b7ac3a992a745dfc666a236"
31
+ "gitHead": "4cc2527f06178114fd3db9f781b1d6fd868a7a61"
32
32
  }