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