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