@vc-shell/api-client-generator 1.0.251 → 1.0.252

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,7 @@
1
+ ## [1.0.252](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.251...v1.0.252) (2024-07-08)
2
+
3
+
4
+
1
5
  ## [1.0.251](https://github.com/VirtoCommerce/vc-shell/compare/v1.0.250...v1.0.251) (2024-07-08)
2
6
 
3
7
 
@@ -2,10 +2,10 @@ 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 A, { dirname as R, resolve as b, join as _, relative as w } from "node:path";
6
- import { fileURLToPath as S } from "node:url";
7
- import { cwd as k } from "node:process";
8
- const E = S(import.meta.url), j = R(E);
5
+ import m, { dirname as R, resolve as b, join as _, relative as w } from "node:path";
6
+ import { fileURLToPath as k } from "node:url";
7
+ import { cwd as S } from "node:process";
8
+ const j = k(import.meta.url), E = R(j);
9
9
  class I {
10
10
  workingDirectory;
11
11
  generatorDirectory;
@@ -13,7 +13,7 @@ class I {
13
13
  apiClientDirectory;
14
14
  nswagPaths;
15
15
  constructor(e) {
16
- this.workingDirectory = k(), this.generatorDirectory = b(j, ".."), this.assetsDirectory = _(this.generatorDirectory, "public", "assets"), this.apiClientDirectory = b(this.workingDirectory, e), this.nswagPaths = {
16
+ this.workingDirectory = S(), this.generatorDirectory = b(E, ".."), 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"
@@ -31,63 +31,63 @@ class I {
31
31
  function O(r) {
32
32
  return r == null ? [] : Array.isArray(r) ? r : [r];
33
33
  }
34
- function M(r, e, i, n) {
35
- var c, t = r[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" || (r._.push((c = +i, c * 0 === 0 ? c : i)), !!i) : (c = +i, c * 0 === 0 ? c : i);
36
- r[e] = t == null ? u : Array.isArray(t) ? t.concat(u) : [t, u];
34
+ function $(r, e, i, n) {
35
+ var c, t = r[e], h = ~n.string.indexOf(e) ? i == null || i === !0 ? "" : String(i) : typeof i == "boolean" ? i : ~n.boolean.indexOf(e) ? i === "false" ? !1 : i === "true" || (r._.push((c = +i, c * 0 === 0 ? c : i)), !!i) : (c = +i, c * 0 === 0 ? c : i);
36
+ r[e] = t == null ? h : Array.isArray(t) ? t.concat(h) : [t, h];
37
37
  }
38
- function N(r, e) {
38
+ function M(r, e) {
39
39
  r = r || [], e = e || {};
40
- var i, n, c, t, u, s = { _: [] }, o = 0, l = 0, a = 0, f = r.length;
41
- const P = e.alias !== void 0, p = e.unknown !== void 0, h = e.default !== void 0;
42
- if (e.alias = e.alias || {}, e.string = O(e.string), e.boolean = O(e.boolean), P)
40
+ var i, n, c, t, h, o = { _: [] }, s = 0, l = 0, a = 0, f = r.length;
41
+ const p = e.alias !== void 0, P = e.unknown !== void 0, u = e.default !== void 0;
42
+ if (e.alias = e.alias || {}, e.string = O(e.string), e.boolean = O(e.boolean), p)
43
43
  for (i in e.alias)
44
- for (n = e.alias[i] = O(e.alias[i]), o = 0; o < n.length; o++)
45
- (e.alias[n[o]] = n.concat(i)).splice(o, 1);
46
- for (o = e.boolean.length; o-- > 0; )
47
- for (n = e.alias[e.boolean[o]] || [], l = n.length; l-- > 0; ) e.boolean.push(n[l]);
48
- for (o = e.string.length; o-- > 0; )
49
- for (n = e.alias[e.string[o]] || [], l = n.length; l-- > 0; ) e.string.push(n[l]);
50
- if (h) {
44
+ for (n = e.alias[i] = O(e.alias[i]), s = 0; s < n.length; s++)
45
+ (e.alias[n[s]] = n.concat(i)).splice(s, 1);
46
+ for (s = e.boolean.length; s-- > 0; )
47
+ for (n = e.alias[e.boolean[s]] || [], l = n.length; l-- > 0; ) e.boolean.push(n[l]);
48
+ for (s = e.string.length; s-- > 0; )
49
+ for (n = e.alias[e.string[s]] || [], l = n.length; l-- > 0; ) e.string.push(n[l]);
50
+ if (u) {
51
51
  for (i in e.default)
52
52
  if (t = typeof e.default[i], n = e.alias[i] = e.alias[i] || [], e[t] !== void 0)
53
- for (e[t].push(i), o = 0; o < n.length; o++)
54
- e[t].push(n[o]);
53
+ for (e[t].push(i), s = 0; s < n.length; s++)
54
+ e[t].push(n[s]);
55
55
  }
56
- const d = p ? Object.keys(e.alias) : [];
57
- for (o = 0; o < f; o++) {
58
- if (c = r[o], c === "--") {
59
- s._ = s._.concat(r.slice(++o));
56
+ const d = P ? Object.keys(e.alias) : [];
57
+ for (s = 0; s < f; s++) {
58
+ if (c = r[s], c === "--") {
59
+ o._ = o._.concat(r.slice(++s));
60
60
  break;
61
61
  }
62
62
  for (l = 0; l < c.length && c.charCodeAt(l) === 45; l++)
63
63
  ;
64
64
  if (l === 0)
65
- s._.push(c);
65
+ o._.push(c);
66
66
  else if (c.substring(l, l + 3) === "no-") {
67
- if (t = c.substring(l + 3), p && !~d.indexOf(t))
67
+ if (t = c.substring(l + 3), P && !~d.indexOf(t))
68
68
  return e.unknown(c);
69
- s[t] = !1;
69
+ o[t] = !1;
70
70
  } else {
71
71
  for (a = l + 1; a < c.length && c.charCodeAt(a) !== 61; a++)
72
72
  ;
73
- for (t = c.substring(l, a), u = c.substring(++a) || o + 1 === f || ("" + r[o + 1]).charCodeAt(0) === 45 || r[++o], n = l === 2 ? [t] : t, a = 0; a < n.length; a++) {
74
- if (t = n[a], p && !~d.indexOf(t)) return e.unknown("-".repeat(l) + t);
75
- M(s, t, a + 1 < n.length || u, e);
73
+ for (t = c.substring(l, a), h = c.substring(++a) || s + 1 === f || ("" + r[s + 1]).charCodeAt(0) === 45 || r[++s], n = l === 2 ? [t] : t, a = 0; a < n.length; a++) {
74
+ if (t = n[a], P && !~d.indexOf(t)) return e.unknown("-".repeat(l) + t);
75
+ $(o, t, a + 1 < n.length || h, e);
76
76
  }
77
77
  }
78
78
  }
79
- if (h)
79
+ if (u)
80
80
  for (i in e.default)
81
- s[i] === void 0 && (s[i] = e.default[i]);
82
- if (P)
83
- for (i in s)
81
+ o[i] === void 0 && (o[i] = e.default[i]);
82
+ if (p)
83
+ for (i in o)
84
84
  for (n = e.alias[i] || []; n.length > 0; )
85
- s[n.shift()] = s[i];
86
- return s;
85
+ o[n.shift()] = o[i];
86
+ return o;
87
87
  }
88
- async function v() {
88
+ async function N() {
89
89
  await L({}, "build");
90
- const r = N(process.argv.slice(2)), e = process.env.APP_PLATFORM_URL ?? r.APP_PLATFORM_URL;
90
+ const r = M(process.argv.slice(2)), e = process.env.APP_PLATFORM_URL ?? r.APP_PLATFORM_URL;
91
91
  if (!e)
92
92
  return console.log(
93
93
  g.red("error"),
@@ -97,25 +97,25 @@ async function v() {
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 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
- let s = {
100
+ const i = r.APP_OUT_DIR ?? "./", n = new I(r.APP_API_CLIENT_DIRECTORY), c = r.APP_PLATFORM_MODULES.replace(/[[\]]/g, "").split(","), t = {}, h = m.join(r.APP_API_CLIENT_DIRECTORY, "tsconfig.json");
101
+ let o = {
102
102
  extends: "@vc-shell/ts-config/tsconfig.json",
103
103
  compilerOptions: {
104
104
  baseUrl: ".",
105
- declarationDir: A.join(i, "types"),
105
+ declarationDir: m.join(i, "types"),
106
106
  outDir: i,
107
107
  rootDir: "./"
108
108
  },
109
109
  files: [],
110
110
  include: ["*.ts"]
111
111
  };
112
- if (D(u)) {
113
- const f = JSON.parse(T(u, "utf-8"));
114
- s = { ...s, ...f }, s.compilerOptions = { ...s.compilerOptions, ...f.compilerOptions }, s.files = Array.from(new Set(s.files.concat(f.files || []))), s.include = Array.from(new Set(s.include.concat(f.include || [])));
112
+ if (D(h)) {
113
+ const f = JSON.parse(T(h, "utf-8"));
114
+ o = { ...o, ...f }, o.compilerOptions = { ...o.compilerOptions, ...f.compilerOptions }, o.files = Array.from(new Set(o.files.concat(f.files || []))), o.include = Array.from(new Set(o.include.concat(f.include || [])));
115
115
  }
116
116
  console.log("api-client-generator %s Generated tsconfig.json", g.greenBright("success"));
117
117
  for (const f of c) {
118
- const P = n.resolveApiClientPaths(f);
118
+ const p = n.resolveApiClientPaths(f);
119
119
  if (console.log(
120
120
  "api-client-generator %s Generating API client for %s module on %s environment",
121
121
  g.green("info"),
@@ -126,7 +126,7 @@ async function v() {
126
126
  [
127
127
  "run",
128
128
  n.nswagPaths.configuration,
129
- `/variables:APP_PLATFORM_URL=${e},APP_PLATFORM_MODULE=${f},APP_AUTH_API_BASE_PATH=${n.nswagPaths.authApiBase},APP_TEMPLATE_DIRECTORY=${n.nswagPaths.templates},APP_API_CLIENT_PATH=${P.nswag}`,
129
+ `/variables:APP_PLATFORM_URL=${e},APP_PLATFORM_MODULE=${f},APP_AUTH_API_BASE_PATH=${n.nswagPaths.authApiBase},APP_TEMPLATE_DIRECTORY=${n.nswagPaths.templates},APP_API_CLIENT_PATH=${p.nswag}`,
130
130
  "/runtime:Net60"
131
131
  ],
132
132
  {
@@ -137,45 +137,45 @@ async function v() {
137
137
  console.log(
138
138
  "api-client-generator %s Successfully generated %s",
139
139
  g.greenBright("success"),
140
- g.whiteBright(P.console)
140
+ g.whiteBright(p.console)
141
141
  );
142
- const h = f.toLowerCase();
143
- s.files.includes(`${h}.ts`) || s.files.push(`${h}.ts`);
142
+ const u = f.toLowerCase();
143
+ o.files.includes(`${u}.ts`) || o.files.push(`${u}.ts`);
144
144
  const d = {
145
- import: A.join(i, `${h}.js`),
146
- types: A.join(i, "types", `${h}.d.ts`)
147
- }, m = Object.keys(t).find(
148
- (y) => t[y].import.includes(`${h}.js`)
145
+ import: i !== "./" ? `./${i}/${u}.js` : `./${u}.js`,
146
+ types: i !== "./" ? `./${i}/types/${u}.d.ts` : `./types/${u}.js`
147
+ }, A = Object.keys(t).find(
148
+ (y) => t[y].import.includes(`${u}.js`)
149
149
  );
150
- m ? t[m] = d : t[`./${h}`] = d;
150
+ A ? t[A] = d : t[`./${u}`] = d;
151
151
  } else
152
152
  console.error(
153
153
  "api-client-generator %s Failed to generate %s",
154
154
  g.red("error"),
155
- g.whiteBright(P.console)
155
+ g.whiteBright(p.console)
156
156
  );
157
157
  }
158
- x(u, JSON.stringify(s, null, 2)), console.log("api-client-generator %s Compiling TypeScript files to JavaScript", g.green("info")), C("npx tsc", ["--project", u], {
158
+ x(h, JSON.stringify(o, null, 2)), console.log("api-client-generator %s Compiling TypeScript files to JavaScript", g.green("info")), C("npx tsc", ["--project", h], {
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 = A.join(r.APP_API_CLIENT_DIRECTORY, "package.json");
162
+ const l = m.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",
166
- files: [i, "package.json"],
166
+ files: i !== "./" ? [i, "package.json"] : ["package.json"],
167
167
  exports: t
168
168
  };
169
169
  if (D(l)) {
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
- for (const [P, p] of Object.entries(t)) {
173
- const h = p.import, d = A.basename(h), m = Object.keys(a.exports).find(
172
+ for (const [p, P] of Object.entries(t)) {
173
+ const u = P.import, d = m.basename(u), A = Object.keys(a.exports).find(
174
174
  (y) => a.exports[y].import.includes(d)
175
175
  );
176
- m ? a.exports[m] = p : a.exports[P] = p;
176
+ A ? a.exports[A] = 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
- v();
181
+ N();
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.251",
4
+ "version": "1.0.252",
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.251",
15
+ "@vc-shell/ts-config": "^1.0.252",
16
16
  "typescript": "~5.3.3"
17
17
  },
18
18
  "dependencies": {