@vc-shell/api-client-generator 1.0.250 → 1.0.251
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 +4 -0
- package/dist/api-client-generator.js +15 -15
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,18 +2,18 @@ import g from "chalk";
|
|
|
2
2
|
import { spawnSync as C } from "node:child_process";
|
|
3
3
|
import { resolveConfig as L } from "vite";
|
|
4
4
|
import { existsSync as D, readFileSync as T, writeFileSync as x } from "node:fs";
|
|
5
|
-
import
|
|
5
|
+
import A, { dirname as R, resolve as b, join as _, relative as w } from "node:path";
|
|
6
6
|
import { fileURLToPath as S } from "node:url";
|
|
7
7
|
import { cwd as k } from "node:process";
|
|
8
|
-
const E = S(import.meta.url),
|
|
9
|
-
class
|
|
8
|
+
const E = S(import.meta.url), j = R(E);
|
|
9
|
+
class I {
|
|
10
10
|
workingDirectory;
|
|
11
11
|
generatorDirectory;
|
|
12
12
|
assetsDirectory;
|
|
13
13
|
apiClientDirectory;
|
|
14
14
|
nswagPaths;
|
|
15
15
|
constructor(e) {
|
|
16
|
-
this.workingDirectory = k(), this.generatorDirectory = b(
|
|
16
|
+
this.workingDirectory = k(), this.generatorDirectory = b(j, ".."), this.assetsDirectory = _(this.generatorDirectory, "public", "assets"), this.apiClientDirectory = b(this.workingDirectory, e), this.nswagPaths = {
|
|
17
17
|
configuration: _(w(this.workingDirectory, this.assetsDirectory), "config.nswag"),
|
|
18
18
|
authApiBase: "authApiBase.ts",
|
|
19
19
|
templates: "templates"
|
|
@@ -85,7 +85,7 @@ function N(r, e) {
|
|
|
85
85
|
s[n.shift()] = s[i];
|
|
86
86
|
return s;
|
|
87
87
|
}
|
|
88
|
-
async function
|
|
88
|
+
async function v() {
|
|
89
89
|
await L({}, "build");
|
|
90
90
|
const r = N(process.argv.slice(2)), e = process.env.APP_PLATFORM_URL ?? r.APP_PLATFORM_URL;
|
|
91
91
|
if (!e)
|
|
@@ -97,12 +97,12 @@ async function $() {
|
|
|
97
97
|
return console.log(g.red("error"), "api-client-generator modules command is required");
|
|
98
98
|
if (!r.APP_API_CLIENT_DIRECTORY)
|
|
99
99
|
return console.log(g.red("error"), "api-client-generator outDir command is required");
|
|
100
|
-
const i = r.APP_OUT_DIR ?? "dist", n = new
|
|
100
|
+
const i = r.APP_OUT_DIR ?? "dist", n = new I(r.APP_API_CLIENT_DIRECTORY), c = r.APP_PLATFORM_MODULES.replace(/[[\]]/g, "").split(","), t = {}, u = A.join(r.APP_API_CLIENT_DIRECTORY, "tsconfig.json");
|
|
101
101
|
let s = {
|
|
102
102
|
extends: "@vc-shell/ts-config/tsconfig.json",
|
|
103
103
|
compilerOptions: {
|
|
104
104
|
baseUrl: ".",
|
|
105
|
-
declarationDir:
|
|
105
|
+
declarationDir: A.join(i, "types"),
|
|
106
106
|
outDir: i,
|
|
107
107
|
rootDir: "./"
|
|
108
108
|
},
|
|
@@ -142,12 +142,12 @@ async function $() {
|
|
|
142
142
|
const h = f.toLowerCase();
|
|
143
143
|
s.files.includes(`${h}.ts`) || s.files.push(`${h}.ts`);
|
|
144
144
|
const d = {
|
|
145
|
-
import:
|
|
146
|
-
types:
|
|
147
|
-
},
|
|
145
|
+
import: A.join(i, `${h}.js`),
|
|
146
|
+
types: A.join(i, "types", `${h}.d.ts`)
|
|
147
|
+
}, m = Object.keys(t).find(
|
|
148
148
|
(y) => t[y].import.includes(`${h}.js`)
|
|
149
149
|
);
|
|
150
|
-
|
|
150
|
+
m ? t[m] = d : t[`./${h}`] = d;
|
|
151
151
|
} else
|
|
152
152
|
console.error(
|
|
153
153
|
"api-client-generator %s Failed to generate %s",
|
|
@@ -159,7 +159,7 @@ async function $() {
|
|
|
159
159
|
stdio: ["ignore", "inherit", "ignore"],
|
|
160
160
|
shell: !0
|
|
161
161
|
}).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"));
|
|
162
|
-
const l =
|
|
162
|
+
const l = A.join(r.APP_API_CLIENT_DIRECTORY, "package.json");
|
|
163
163
|
let a = {
|
|
164
164
|
name: r.APP_PACKAGE_NAME || "api-client",
|
|
165
165
|
version: r.APP_PACKAGE_VERSION || "1.0.0",
|
|
@@ -170,12 +170,12 @@ async function $() {
|
|
|
170
170
|
const f = JSON.parse(T(l, "utf-8"));
|
|
171
171
|
a = { ...a, ...f }, a.files = Array.from(new Set(a.files.concat(f.files || []))), a.exports = { ...f.exports, ...a.exports };
|
|
172
172
|
for (const [P, p] of Object.entries(t)) {
|
|
173
|
-
const h = p.import, d =
|
|
173
|
+
const h = p.import, d = A.basename(h), m = Object.keys(a.exports).find(
|
|
174
174
|
(y) => a.exports[y].import.includes(d)
|
|
175
175
|
);
|
|
176
|
-
|
|
176
|
+
m ? a.exports[m] = p : a.exports[P] = p;
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
x(l, JSON.stringify(a, null, 2)), console.log("api-client-generator %s Generated package.json", g.greenBright("success"));
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
v();
|
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.251",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./dist/api-client-generator.js",
|
|
7
7
|
"files": [
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"build": "vite build"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@vc-shell/ts-config": "^1.0.
|
|
15
|
+
"@vc-shell/ts-config": "^1.0.251",
|
|
16
16
|
"typescript": "~5.3.3"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|