@vc-shell/api-client-generator 1.1.52 → 1.1.53

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,12 @@
1
+ ## [1.1.53](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.52...v1.1.53) (2025-07-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **api-client:** validate APP_TYPE_STYLE parameter and enhance error handling in API client generation ([506228d](https://github.com/VirtoCommerce/vc-shell/commit/506228d19deb14ba3d4f17e3180130395d001278))
7
+
8
+
9
+
1
10
  ## [1.1.52](https://github.com/VirtoCommerce/vc-shell/compare/v1.1.51...v1.1.52) (2025-07-02)
2
11
 
3
12
 
package/README.md CHANGED
@@ -68,6 +68,12 @@ Add the dependencies to your project's **package.json**:
68
68
  | `--SKIP_BUILD` | Skip build step. <br>{==boolean==} | `--SKIP_BUILD=true` |
69
69
  | `--VERBOSE` | Enable verbose logging. <br>{==boolean==} | `--VERBOSE=true` |
70
70
 
71
+ !!! note
72
+ For the `--APP_TYPE_STYLE` parameter, use **exactly** `"Class"` or `"Interface"` (case-sensitive). Any other value will cause an error.
73
+
74
+ !!! tip
75
+ Use `--APP_TYPE_STYLE=Interface` for better TypeScript integration and smaller bundle sizes. Use `--APP_TYPE_STYLE=Class` when you need runtime type checking or class-specific features.
76
+
71
77
  3. Configure Platform URL to ensure your project can access the platform's API configurations. Add the platform URL to your project's **.env** file:
72
78
 
73
79
  ```title="vc-app-extend/.env"
@@ -197,3 +203,32 @@ If you encounter issues during API client generation:
197
203
  5. If you encounter JSON parsing errors in tsconfig.json or package.json, try using the `--VERBOSE=true` flag to see detailed error messages
198
204
  6. Check for duplicate exports in your package.json which might cause conflicts
199
205
  7. If you manually modified exports in package.json, ensure they follow the correct format
206
+
207
+ ### Common Issues
208
+
209
+ #### APP_TYPE_STYLE Error
210
+
211
+ If you see an error like:
212
+ ```
213
+ Error converting value "$(APP_TYPE_STYLE)" to type 'NJsonSchema.CodeGeneration.TypeScript.TypeScriptTypeStyle'
214
+ ```
215
+
216
+ This means the `APP_TYPE_STYLE` parameter was not properly validated or passed to NSwag:
217
+
218
+ **Solution:**
219
+ 1. Ensure you're using exactly `"Class"` or `"Interface"` (case-sensitive)
220
+ 2. Check that you're passing the parameter correctly: `--APP_TYPE_STYLE=Interface`
221
+ 3. Enable verbose logging to see what value is being passed: `--VERBOSE=true`
222
+
223
+ **Example of correct usage:**
224
+ ```bash
225
+ yarn generate-api-client --APP_TYPE_STYLE=Interface --VERBOSE=true
226
+ ```
227
+
228
+ #### NSwag Command Failed
229
+
230
+ If NSwag fails with exit code, check:
231
+ 1. .NET Core 6.0 or later is installed
232
+ 2. The platform URL is accessible
233
+ 3. The specified modules exist on the platform
234
+ 4. Enable verbose logging to see the full error output
@@ -1,212 +1,212 @@
1
- import t from "chalk";
2
- import { sync as E } from "cross-spawn";
1
+ import e from "chalk";
2
+ import { sync as x } from "cross-spawn";
3
3
  import { resolveConfig as j } from "vite";
4
- import { existsSync as _, mkdirSync as B, writeFileSync as I, readFileSync as R } from "node:fs";
5
- import m, { dirname as O, resolve as T, join as w, relative as x } from "node:path";
6
- import { fileURLToPath as S } from "node:url";
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
7
  import { cwd as L } from "node:process";
8
- import k from "mri";
9
- const b = S(import.meta.url), $ = O(b);
8
+ import b from "mri";
9
+ const k = O(import.meta.url), $ = S(k);
10
10
  class v {
11
11
  workingDirectory;
12
12
  generatorDirectory;
13
13
  assetsDirectory;
14
14
  apiClientDirectory;
15
15
  nswagPaths;
16
- constructor(e) {
17
- this.workingDirectory = L(), this.generatorDirectory = T($, ".."), this.assetsDirectory = w(this.generatorDirectory, "public", "assets"), this.apiClientDirectory = T(this.workingDirectory, e), this.nswagPaths = {
18
- configuration: w(x(this.workingDirectory, this.assetsDirectory), "config.nswag"),
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 = {
18
+ configuration: w(E(this.workingDirectory, this.assetsDirectory), "config.nswag"),
19
19
  authApiBase: "authApiBase.ts",
20
20
  templates: "templates"
21
21
  };
22
22
  }
23
- resolveApiClientPaths(e) {
24
- const g = `${e.toLowerCase()}.ts`;
23
+ resolveApiClientPaths(t) {
24
+ const a = `${t.toLowerCase()}.ts`;
25
25
  return {
26
- fileName: g,
27
- nswag: w(x(this.assetsDirectory, this.apiClientDirectory), g),
28
- console: w(x(this.workingDirectory, this.apiClientDirectory), g)
26
+ fileName: a,
27
+ nswag: w(E(this.assetsDirectory, this.apiClientDirectory), a),
28
+ console: w(E(this.workingDirectory, this.apiClientDirectory), a)
29
29
  };
30
30
  }
31
31
  }
32
- function D(o, e, g = []) {
32
+ function D(o, t, a = []) {
33
33
  const r = { ...o };
34
- for (const s of g)
35
- s in e && (r[s] = e[s]);
36
- for (const [s, a] of Object.entries(e)) {
37
- const c = s;
38
- s in r && typeof r[c] == "object" && !Array.isArray(r[c]) && typeof a == "object" && !Array.isArray(a) && a !== null ? r[c] = { ...r[c], ...a } : g.includes(s) || (r[c] = a);
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);
39
39
  }
40
40
  return r;
41
41
  }
42
- function F(o, e, g, r) {
43
- const s = {
42
+ function F(o, t, a, r) {
43
+ const l = {
44
44
  extends: "@vc-shell/ts-config/tsconfig.json",
45
45
  compilerOptions: {
46
46
  baseUrl: ".",
47
- declarationDir: m.join(g, "types"),
47
+ declarationDir: m.join(a, "types"),
48
48
  outDir: r,
49
49
  rootDir: "./"
50
50
  },
51
51
  files: [],
52
52
  include: ["*.ts"]
53
53
  };
54
- let a = { ...s };
54
+ let c = { ...l };
55
55
  if (_(o))
56
56
  try {
57
- const c = R(o, "utf-8");
57
+ const p = R(o, "utf-8");
58
58
  try {
59
- const n = JSON.parse(c);
60
- a = D(s, n), n.compilerOptions && typeof n.compilerOptions == "object" && (a.compilerOptions = {
61
- ...s.compilerOptions,
59
+ const n = JSON.parse(p);
60
+ c = D(l, n), n.compilerOptions && typeof n.compilerOptions == "object" && (c.compilerOptions = {
61
+ ...l.compilerOptions,
62
62
  ...n.compilerOptions
63
- }, a.compilerOptions.outDir = r, a.compilerOptions.declarationDir = m.join(r, "types"));
63
+ }, c.compilerOptions.outDir = r, c.compilerOptions.declarationDir = m.join(r, "types"));
64
64
  const y = Array.isArray(n.files) ? n.files : [];
65
- a.files = Array.from(/* @__PURE__ */ new Set([...e, ...y])), console.log("api-client-generator %s Updated existing tsconfig.json", t.greenBright("success"));
65
+ c.files = Array.from(/* @__PURE__ */ new Set([...t, ...y])), console.log("api-client-generator %s Updated existing tsconfig.json", e.greenBright("success"));
66
66
  } catch (n) {
67
67
  console.error(
68
68
  "api-client-generator %s Failed to parse existing tsconfig.json, creating new one",
69
- t.yellow("warning"),
69
+ e.yellow("warning"),
70
70
  n
71
- ), a = { ...s }, a.files = e;
71
+ ), c = { ...l }, c.files = t;
72
72
  }
73
- } catch (c) {
74
- console.error("api-client-generator %s Failed to read existing tsconfig.json", t.red("error"), c);
73
+ } catch (p) {
74
+ console.error("api-client-generator %s Failed to read existing tsconfig.json", e.red("error"), p);
75
75
  }
76
76
  else
77
- a.files = e, console.log("api-client-generator %s Created new tsconfig.json", t.greenBright("success"));
78
- return a;
77
+ c.files = t, console.log("api-client-generator %s Created new tsconfig.json", e.greenBright("success"));
78
+ return c;
79
79
  }
80
80
  function A(o) {
81
- let e = o;
82
- const g = [".d.ts", ".ts", ".js"];
81
+ let t = o;
82
+ const a = [".d.ts", ".ts", ".js"];
83
83
  let r;
84
84
  do {
85
85
  r = !1;
86
- for (const s of g)
87
- if (e.toLowerCase().endsWith(s.toLowerCase())) {
88
- e = e.substring(0, e.length - s.length), r = !0;
86
+ for (const l of a)
87
+ if (t.toLowerCase().endsWith(l.toLowerCase())) {
88
+ t = t.substring(0, t.length - l.length), r = !0;
89
89
  break;
90
90
  }
91
91
  } while (r);
92
- return e = e.replace(/\/\.\//g, "/"), e = e.replace(/\/+/g, "/"), e = e.replace(/\.\.\//g, ""), e !== "." && !e.startsWith("./") && !e.startsWith("/") && !m.isAbsolute(e) && (e = "./" + e), e.startsWith("//") && (e = "./" + e.substring(2)), e !== "." && e.startsWith("/") && !e.startsWith("./") && !m.isAbsolute(e) && (e = "." + e), e !== "." && e.startsWith("././") && (e = "./" + e.substring(3)), e;
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;
93
93
  }
94
94
  function P(o) {
95
- let e = A(o);
96
- return e = m.basename(e), e = e.replace(/^virtocommerce\./i, ""), e.toLowerCase();
95
+ let t = A(o);
96
+ return t = m.basename(t), t = t.replace(/^virtocommerce\./i, ""), t.toLowerCase();
97
97
  }
98
98
  function M(o) {
99
99
  return o ? [`./${o}`, `./virtocommerce.${o}`] : [];
100
100
  }
101
- function N(o, e, g, r) {
102
- const s = {}, a = /* @__PURE__ */ new Set();
101
+ function N(o, t, a, r) {
102
+ const l = {}, c = /* @__PURE__ */ new Set();
103
103
  for (const d of o) {
104
104
  const i = P(d);
105
105
  if (!i) continue;
106
- const l = `virtocommerce.${i}`, f = `./${m.join(e, `${l}.js`)}`, h = `./${m.join(e, "types", `${l}.d.ts`)}`, p = { import: f, types: h }, u = M(i);
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
107
  for (const C of u)
108
- s[C] = p, r && console.log(
108
+ l[C] = s, r && console.log(
109
109
  "api-client-generator %s Generated standard export: %s -> { import: %s, types: %s }",
110
- t.blue("debug"),
111
- t.whiteBright(C),
112
- t.whiteBright(f),
113
- t.whiteBright(h)
110
+ e.blue("debug"),
111
+ e.whiteBright(C),
112
+ e.whiteBright(f),
113
+ e.whiteBright(h)
114
114
  );
115
- a.add(i);
115
+ c.add(i);
116
116
  }
117
- const c = { ...s };
118
- if (g)
119
- for (const [d, i] of Object.entries(g)) {
117
+ const p = { ...l };
118
+ if (a)
119
+ for (const [d, i] of Object.entries(a)) {
120
120
  if (d === ".")
121
121
  continue;
122
122
  if (typeof i != "object" || i === null) {
123
123
  r && console.log(
124
124
  "api-client-generator %s Skipping malformed existing export value for key: %s",
125
- t.yellow("warning"),
125
+ e.yellow("warning"),
126
126
  d
127
127
  );
128
128
  continue;
129
129
  }
130
- const l = i;
131
- if (!l.import || !l.types) {
130
+ const g = i;
131
+ if (!g.import || !g.types) {
132
132
  r && console.log(
133
133
  "api-client-generator %s Skipping existing export with missing import/types for key: %s",
134
- t.yellow("warning"),
134
+ e.yellow("warning"),
135
135
  d
136
136
  );
137
137
  continue;
138
138
  }
139
139
  const f = A(d);
140
140
  if (!(!f || f === "."))
141
- if (P(f), f in s)
141
+ if (P(f), f in l)
142
142
  r && console.log(
143
143
  "api-client-generator %s Existing export key '%s' was handled by new generation.",
144
- t.blue("debug"),
145
- t.whiteBright(f)
144
+ e.blue("debug"),
145
+ e.whiteBright(f)
146
146
  );
147
147
  else {
148
- const h = A(l.import), p = A(l.types);
149
- c[f] = {
148
+ const h = A(g.import), s = A(g.types);
149
+ p[f] = {
150
150
  import: `${h}.js`,
151
- types: `${p}.d.ts`
151
+ types: `${s}.d.ts`
152
152
  }, r && console.log(
153
153
  "api-client-generator %s Preserved existing export: %s -> { import: %s, types: %s }",
154
- t.blue("debug"),
155
- t.whiteBright(f),
156
- t.whiteBright(`${h}.js`),
157
- t.whiteBright(`${p}.d.ts`)
154
+ e.blue("debug"),
155
+ e.whiteBright(f),
156
+ e.whiteBright(`${h}.js`),
157
+ e.whiteBright(`${s}.d.ts`)
158
158
  );
159
159
  }
160
160
  }
161
161
  const n = /* @__PURE__ */ new Set();
162
- for (const d in c) {
162
+ for (const d in p) {
163
163
  if (d === ".") continue;
164
164
  const i = P(d);
165
165
  i && n.add(i);
166
166
  }
167
167
  const y = Array.from(n);
168
168
  if (y.length === 1) {
169
- const d = y[0], i = `virtocommerce.${d}`, l = `./${m.join(e, `${i}.js`)}`, f = `./${m.join(e, "types", `${i}.d.ts`)}`;
170
- c["."] = {
171
- import: l,
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
172
  types: f
173
173
  }, r && console.log(
174
174
  "api-client-generator %s Set root export for single module '%s': { import: %s, types: %s }",
175
- t.blue("debug"),
176
- t.whiteBright(d),
177
- t.whiteBright(l),
178
- t.whiteBright(f)
175
+ e.blue("debug"),
176
+ e.whiteBright(d),
177
+ e.whiteBright(g),
178
+ e.whiteBright(f)
179
179
  );
180
- } else if (g && "." in g) {
181
- const d = g["."];
180
+ } else if (a && "." in a) {
181
+ const d = a["."];
182
182
  if (typeof d == "object" && d !== null) {
183
183
  const i = d;
184
184
  if (i.import && i.types) {
185
- const l = P(i.import);
186
- if (l && y.includes(l)) {
187
- const f = `virtocommerce.${l}`, h = `./${m.join(e, `${f}.js`)}`, p = `./${m.join(e, "types", `${f}.d.ts`)}`;
188
- c["."] = { import: h, types: p }, r && console.log(
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(
189
189
  "api-client-generator %s Preserved and standardized existing root export pointing to module '%s'",
190
- t.blue("debug"),
191
- t.whiteBright(l)
190
+ e.blue("debug"),
191
+ e.whiteBright(g)
192
192
  );
193
193
  } else r && console.log(
194
194
  "api-client-generator %s Removed existing root export as it pointed to an unknown or unhandled module '%s'",
195
- t.yellow("warning"),
196
- l || "unknown"
195
+ e.yellow("warning"),
196
+ g || "unknown"
197
197
  );
198
- } else r && console.log("api-client-generator %s Removed malformed existing root export.", t.yellow("warning"));
198
+ } else r && console.log("api-client-generator %s Removed malformed existing root export.", e.yellow("warning"));
199
199
  }
200
200
  }
201
- return c;
201
+ return p;
202
202
  }
203
- function U(o, e, g) {
204
- const r = g.VERBOSE ?? !1, s = g.APP_BUILD_DIR ?? "dist", a = [];
205
- s && a.push(s), a.push("package.json");
206
- const c = {
207
- name: g.APP_PACKAGE_NAME || "api-client",
208
- version: g.APP_PACKAGE_VERSION || "1.0.0",
209
- files: a,
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,
210
210
  exports: {},
211
211
  // Add metadata to track generated content
212
212
  apiClientGenerator: {
@@ -214,13 +214,13 @@ function U(o, e, g) {
214
214
  generatedAt: (/* @__PURE__ */ new Date()).toISOString()
215
215
  }
216
216
  };
217
- let n = { ...c }, y, d, i;
217
+ let n = { ...p }, y, d, i;
218
218
  if (_(o))
219
219
  try {
220
- const p = R(o, "utf-8");
220
+ const s = R(o, "utf-8");
221
221
  try {
222
- const u = JSON.parse(p);
223
- typeof u.module == "string" && (d = u.module), typeof u.types == "string" && (i = u.types), n = D(c, u, [
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, [
224
224
  "name",
225
225
  "version",
226
226
  "description",
@@ -231,122 +231,138 @@ function U(o, e, g) {
231
231
  "scripts",
232
232
  "devDependencies",
233
233
  "dependencies"
234
- ]), n.apiClientGenerator = c.apiClientGenerator, u.files && Array.isArray(u.files) && (n.files = Array.from(/* @__PURE__ */ new Set([...a, ...u.files]))), y = u.exports, console.log("api-client-generator %s Updated existing package.json", t.greenBright("success"));
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
235
  } catch (u) {
236
236
  console.error(
237
237
  "api-client-generator %s Failed to parse existing package.json, creating new one",
238
- t.yellow("warning"),
238
+ e.yellow("warning"),
239
239
  u
240
240
  );
241
241
  }
242
- } catch (p) {
243
- console.error("api-client-generator %s Failed to read existing package.json", t.red("error"), p);
242
+ } catch (s) {
243
+ console.error("api-client-generator %s Failed to read existing package.json", e.red("error"), s);
244
244
  }
245
245
  else
246
- console.log("api-client-generator %s Creating new package.json", t.greenBright("success"));
247
- n.exports = N(e, s, y, r);
248
- const l = Object.keys(n.exports), f = /* @__PURE__ */ new Set();
249
- for (const p of l) {
250
- if (p === ".") continue;
251
- const u = P(p);
246
+ 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
252
  u && f.add(u);
253
253
  }
254
254
  if (Array.from(f).length, n.exports && "." in n.exports) {
255
- const p = n.exports["."];
256
- p && p.import && (n.module = p.import, r && console.log(
255
+ const s = n.exports["."];
256
+ s && s.import && (n.module = s.import, r && console.log(
257
257
  "api-client-generator %s Set 'module' field from root export: %s",
258
- t.blue("debug"),
259
- t.whiteBright(p.import)
260
- )), p && p.types && (n.types = p.types, r && console.log(
258
+ e.blue("debug"),
259
+ e.whiteBright(s.import)
260
+ )), s && s.types && (n.types = s.types, r && console.log(
261
261
  "api-client-generator %s Set 'types' field from root export: %s",
262
- t.blue("debug"),
263
- t.whiteBright(p.types)
262
+ e.blue("debug"),
263
+ e.whiteBright(s.types)
264
264
  ));
265
265
  } else
266
- "module" in n && (delete n.module, r && console.log("api-client-generator %s Removed 'module' field (no clear root export).", t.blue("debug"))), "types" in n && (delete n.types, r && console.log("api-client-generator %s Removed 'types' field (no clear root export).", t.blue("debug")));
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
267
  return n;
268
268
  }
269
269
  async function Y() {
270
270
  await j({}, "build");
271
- const o = k(process.argv.slice(2)), e = process.env.APP_PLATFORM_URL ?? o.APP_PLATFORM_URL, g = o.VERBOSE ?? !1, r = o.APP_TYPE_STYLE ?? "Class";
272
- if (!e)
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";
272
+ if (r !== "Class" && r !== "Interface") {
273
+ console.error(
274
+ "api-client-generator %s Invalid APP_TYPE_STYLE value: %s. Must be either 'Class' or 'Interface'",
275
+ e.red("error"),
276
+ e.whiteBright(r)
277
+ );
278
+ return;
279
+ }
280
+ if (a && console.log("api-client-generator %s Using APP_TYPE_STYLE: %s", e.blue("debug"), e.whiteBright(r)), !t)
273
281
  return console.log(
274
- t.red("error"),
282
+ e.red("error"),
275
283
  "api-client-generator APP_PLATFORM_URL is required in .env config or as api-client-generator argument"
276
284
  );
277
285
  if (!o.APP_PLATFORM_MODULES)
278
- return console.log(t.red("error"), "api-client-generator modules command is required");
286
+ return console.log(e.red("error"), "api-client-generator modules command is required");
279
287
  if (!o.APP_API_CLIENT_DIRECTORY)
280
- return console.log(t.red("error"), "api-client-generator outDir command is required");
281
- const s = o.APP_OUT_DIR ?? "./", a = o.APP_BUILD_DIR ?? "dist", c = new v(o.APP_API_CLIENT_DIRECTORY);
288
+ 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);
282
290
  if (!_(o.APP_API_CLIENT_DIRECTORY))
283
291
  try {
284
- B(o.APP_API_CLIENT_DIRECTORY, { recursive: !0 }), console.log(
292
+ I(o.APP_API_CLIENT_DIRECTORY, { recursive: !0 }), console.log(
285
293
  "api-client-generator %s Created directory %s",
286
- t.greenBright("success"),
287
- t.whiteBright(o.APP_API_CLIENT_DIRECTORY)
294
+ e.greenBright("success"),
295
+ e.whiteBright(o.APP_API_CLIENT_DIRECTORY)
288
296
  );
289
297
  } catch (i) {
290
298
  console.error(
291
299
  "api-client-generator %s Failed to create directory %s",
292
- t.red("error"),
293
- t.whiteBright(o.APP_API_CLIENT_DIRECTORY),
300
+ e.red("error"),
301
+ e.whiteBright(o.APP_API_CLIENT_DIRECTORY),
294
302
  i
295
303
  );
296
304
  return;
297
305
  }
298
- const n = m.join(o.APP_API_CLIENT_DIRECTORY, a);
306
+ const n = m.join(o.APP_API_CLIENT_DIRECTORY, c);
299
307
  if (!_(n))
300
308
  try {
301
- B(n, { recursive: !0 }), console.log(
309
+ I(n, { recursive: !0 }), console.log(
302
310
  "api-client-generator %s Created build directory %s",
303
- t.greenBright("success"),
304
- t.whiteBright(n)
311
+ e.greenBright("success"),
312
+ e.whiteBright(n)
305
313
  );
306
314
  } catch (i) {
307
315
  console.error(
308
316
  "api-client-generator %s Failed to create build directory %s",
309
- t.red("error"),
310
- t.whiteBright(n),
317
+ e.red("error"),
318
+ e.whiteBright(n),
311
319
  i
312
320
  );
313
321
  }
314
322
  const y = o.APP_PLATFORM_MODULES.replace(/[[\]]/g, "").split(","), d = [];
315
323
  for (const i of y) {
316
- const l = c.resolveApiClientPaths(i);
324
+ const g = p.resolveApiClientPaths(i);
317
325
  console.log(
318
326
  "api-client-generator %s Generating API client for %s module on %s environment",
319
- t.green("info"),
320
- t.whiteBright(i),
321
- t.whiteBright(e)
327
+ e.green("info"),
328
+ e.whiteBright(i),
329
+ e.whiteBright(t)
322
330
  );
323
331
  const f = [
324
- "run",
325
- c.nswagPaths.configuration,
326
- `/variables:APP_PLATFORM_URL=${e},APP_PLATFORM_MODULE=${i},APP_AUTH_API_BASE_PATH=${c.nswagPaths.authApiBase},APP_TEMPLATE_DIRECTORY=${c.nswagPaths.templates},APP_API_CLIENT_PATH=${l.nswag},APP_TYPE_STYLE=${r}`,
327
- "/runtime:Net60"
328
- ];
329
- g && console.log("api-client-generator %s Running command: npx nswag %s", t.blue("debug"), f.join(" ")), E("npx nswag", f, {
330
- stdio: ["ignore", "inherit", "ignore"],
332
+ `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}`,
337
+ `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"],
331
342
  shell: !0
332
- }).status === 0 ? (console.log(
343
+ });
344
+ s.status === 0 ? (console.log(
333
345
  "api-client-generator %s Successfully generated %s",
334
- t.greenBright("success"),
335
- t.whiteBright(l.console)
336
- ), o.SKIP_BUILD || d.push(`${i.toLowerCase()}.ts`)) : console.error(
346
+ e.greenBright("success"),
347
+ e.whiteBright(g.console)
348
+ ), o.SKIP_BUILD || d.push(`${i.toLowerCase()}.ts`)) : (console.error(
337
349
  "api-client-generator %s Failed to generate %s",
338
- t.red("error"),
339
- t.whiteBright(l.console)
340
- );
350
+ e.red("error"),
351
+ e.whiteBright(g.console)
352
+ ), a && console.error(
353
+ "api-client-generator %s NSwag command failed with exit code: %s",
354
+ e.red("error"),
355
+ s.status
356
+ ));
341
357
  }
342
358
  if (!o.SKIP_BUILD) {
343
- const i = m.join(o.APP_API_CLIENT_DIRECTORY, "tsconfig.json"), l = F(i, d, s, a);
344
- I(i, JSON.stringify(l, null, 2)), console.log("api-client-generator %s Compiling TypeScript files to JavaScript", t.green("info")), E("npx tsc", ["--project", i], {
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], {
345
361
  stdio: ["ignore", "inherit", "ignore"],
346
362
  shell: !0
347
- }).status === 0 ? console.log("api-client-generator %s Successfully compiled TypeScript files", t.greenBright("success")) : console.error("api-client-generator %s Failed to compile TypeScript files", t.red("error"));
348
- const h = m.join(o.APP_API_CLIENT_DIRECTORY, "package.json"), p = U(h, d, o);
349
- I(h, JSON.stringify(p, null, 2)), console.log("api-client-generator %s Generated package.json", t.greenBright("success"));
363
+ }).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"));
350
366
  }
351
367
  }
352
368
  Y();
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.52",
4
+ "version": "1.1.53",
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.52",
16
+ "@vc-shell/ts-config": "^1.1.53",
17
17
  "typescript": "^5.8.3"
18
18
  },
19
19
  "dependencies": {