@1szx1/vite-plugin-swagger2ts 1.3.0 → 1.3.1

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/dist/bin.cjs CHANGED
@@ -6,5 +6,6 @@ require('path');
6
6
  require('swagger2openapi');
7
7
  require('cross-fetch');
8
8
  require('unconfig');
9
+ require('chalk');
9
10
 
10
11
  index.default();
package/dist/bin.mjs CHANGED
@@ -4,5 +4,6 @@ import 'path';
4
4
  import 'swagger2openapi';
5
5
  import 'cross-fetch';
6
6
  import 'unconfig';
7
+ import 'chalk';
7
8
 
8
9
  swagger2TsPlugin();
package/dist/index.cjs CHANGED
@@ -7,10 +7,12 @@ const path = require('path');
7
7
  const swagger2openapi = require('swagger2openapi');
8
8
  const fetch = require('cross-fetch');
9
9
  const unconfig = require('unconfig');
10
+ const chalk = require('chalk');
10
11
 
11
12
  function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
12
13
 
13
14
  const fetch__default = /*#__PURE__*/_interopDefaultCompat(fetch);
15
+ const chalk__default = /*#__PURE__*/_interopDefaultCompat(chalk);
14
16
 
15
17
  function loadConfig() {
16
18
  return unconfig.loadConfig({
@@ -247,7 +249,7 @@ async function loadSwaggerSource(options) {
247
249
  const code2 = await genInterface(docs, name);
248
250
  return code2;
249
251
  } catch (error) {
250
- console.log(`%c[vite-plugin-swagger2ts]: ${name} error`, "color: #ff0000;", error.message);
252
+ console.log(chalk__default.yellow(`[vite-plugin-swagger2ts]: ${name} error;`) + error.message);
251
253
  return "";
252
254
  }
253
255
  }
@@ -255,18 +257,18 @@ async function loadSwaggerSource(options) {
255
257
  let sources2 = void 0;
256
258
  let interfaces2 = [];
257
259
  if (typeof swaggerUrl === "string") {
258
- const resources = await fetchUrl(`${swaggerUrl}/swagger-resources`).catch((error) => error);
260
+ const resources = await fetchUrl(`${swaggerUrl}/swagger-resources;`).catch((error) => error);
259
261
  if (Array.isArray(resources)) {
260
262
  sources2 = resources;
261
263
  interfaces2.push(...await Promise.all(sources2.map(genResourcesCode)));
262
264
  } else {
263
- console.log(`%c[vite-plugin-swagger2ts]: resources error`, "color: #ff0000;", JSON.stringify(resources));
265
+ console.log(chalk__default.yellow(`[vite-plugin-swagger2ts]: resources error`) + JSON.stringify(resources));
264
266
  }
265
267
  }
266
268
  if (typeof jsonUrl === "string") {
267
269
  const swaggerJson = await fetchUrl(jsonUrl);
268
270
  if (!swaggerJson.info)
269
- return console.log(`%c[vite-plugin-swagger2ts]: jsonUrl error`, "color: #ff0000;", JSON.stringify(swaggerJson));
271
+ return console.log(chalk__default.yellow(`[vite-plugin-swagger2ts]: jsonUrl error;`) + JSON.stringify(swaggerJson));
270
272
  interfaces2.push(await genInterface(swaggerJson, getApiName(swaggerJson)));
271
273
  }
272
274
  if (typeof jsonPath === "string") {
package/dist/index.mjs CHANGED
@@ -3,6 +3,7 @@ import { resolve } from 'path';
3
3
  import { convertObj } from 'swagger2openapi';
4
4
  import fetch from 'cross-fetch';
5
5
  import { loadConfig as loadConfig$1 } from 'unconfig';
6
+ import chalk from 'chalk';
6
7
 
7
8
  function loadConfig() {
8
9
  return loadConfig$1({
@@ -239,7 +240,7 @@ async function loadSwaggerSource(options) {
239
240
  const code2 = await genInterface(docs, name);
240
241
  return code2;
241
242
  } catch (error) {
242
- console.log(`%c[vite-plugin-swagger2ts]: ${name} error`, "color: #ff0000;", error.message);
243
+ console.log(chalk.yellow(`[vite-plugin-swagger2ts]: ${name} error;`) + error.message);
243
244
  return "";
244
245
  }
245
246
  }
@@ -247,18 +248,18 @@ async function loadSwaggerSource(options) {
247
248
  let sources2 = void 0;
248
249
  let interfaces2 = [];
249
250
  if (typeof swaggerUrl === "string") {
250
- const resources = await fetchUrl(`${swaggerUrl}/swagger-resources`).catch((error) => error);
251
+ const resources = await fetchUrl(`${swaggerUrl}/swagger-resources;`).catch((error) => error);
251
252
  if (Array.isArray(resources)) {
252
253
  sources2 = resources;
253
254
  interfaces2.push(...await Promise.all(sources2.map(genResourcesCode)));
254
255
  } else {
255
- console.log(`%c[vite-plugin-swagger2ts]: resources error`, "color: #ff0000;", JSON.stringify(resources));
256
+ console.log(chalk.yellow(`[vite-plugin-swagger2ts]: resources error`) + JSON.stringify(resources));
256
257
  }
257
258
  }
258
259
  if (typeof jsonUrl === "string") {
259
260
  const swaggerJson = await fetchUrl(jsonUrl);
260
261
  if (!swaggerJson.info)
261
- return console.log(`%c[vite-plugin-swagger2ts]: jsonUrl error`, "color: #ff0000;", JSON.stringify(swaggerJson));
262
+ return console.log(chalk.yellow(`[vite-plugin-swagger2ts]: jsonUrl error;`) + JSON.stringify(swaggerJson));
262
263
  interfaces2.push(await genInterface(swaggerJson, getApiName(swaggerJson)));
263
264
  }
264
265
  if (typeof jsonPath === "string") {
package/package.json CHANGED
@@ -1,108 +1,109 @@
1
- {
2
- "name": "@1szx1/vite-plugin-swagger2ts",
3
- "description": "forked from https://github.com/morelearn1990/vite-plugin-swagger2ts",
4
- "version": "1.3.0",
5
- "license": "MIT",
6
- "author": "1SZX1 <2414126198@qq.com>",
7
- "repository": {
8
- "type": "git",
9
- "url": "https://github.com/1SZX1/vite-plugin-swagger2ts"
10
- },
11
- "homepage": "https://github.com/1SZX1/vite-plugin-swagger2ts",
12
- "bugs": "https://github.com/1SZX1/vite-plugin-swagger2ts/issues",
13
- "files": [
14
- "dist"
15
- ],
16
- "exports": {
17
- ".": {
18
- "require": "./dist/index.cjs",
19
- "import": "./dist/index.mjs",
20
- "types": "./dist/index.d.ts"
21
- },
22
- "./adapters": {
23
- "require": "./dist/adapters.cjs",
24
- "import": "./dist/adapters.mjs",
25
- "types": "./dist/adapters.d.ts"
26
- }
27
- },
28
- "main": "dist/index.cjs",
29
- "module": "dist/index.mjs",
30
- "types": "dist/index.d.ts",
31
- "typesVersions": {
32
- "*": {
33
- "adapters": [
34
- "./dist/adapters"
35
- ]
36
- }
37
- },
38
- "bin": {
39
- "swagger2ts": "./dist/bin.mjs"
40
- },
41
- "scripts": {
42
- "build": "unbuild",
43
- "stub": "unbuild --stub",
44
- "prepublishOnly": "pnpm run build",
45
- "release": "pnpx git-ensure -a && pnpx bumpp --commit --tag --push",
46
- "demo:dev": "pnpm -C examples/demo run dev",
47
- "demo:build": "pnpm -C examples/demo run build",
48
- "demo:preview": "pnpm -C examples/demo run preview",
49
- "test": "jest",
50
- "lint": "eslint --fix --ext .ts ./",
51
- "version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md",
52
- "preinstall": "npx only-allow pnpm"
53
- },
54
- "dependencies": {
55
- "axios": "^1.4.0",
56
- "cross-fetch": "^3.1.5",
57
- "luch-request": "^3.1.0",
58
- "openapi3-ts": "^2.0.2",
59
- "swagger2openapi": "^7.0.8",
60
- "unconfig": "^0.3.9"
61
- },
62
- "peerDependencies": {
63
- "axios": "^1.4.0",
64
- "luch-request": "^3.1.0",
65
- "vite": "^2.0.0"
66
- },
67
- "devDependencies": {
68
- "@antfu/eslint-config": "^0.6.6",
69
- "@commitlint/cli": "^12.1.4",
70
- "@commitlint/config-conventional": "^12.1.4",
71
- "@dcloudio/types": "^3.3.3",
72
- "@types/eslint": "^8.44.0",
73
- "@types/jest": "^26.0.24",
74
- "@types/node": "^14.18.12",
75
- "@typescript-eslint/eslint-plugin": "^4.33.0",
76
- "@typescript-eslint/parser": "^5.14.0",
77
- "conventional-changelog": "^3.1.25",
78
- "cz-conventional-changelog": "^3.3.0",
79
- "eslint": "^8.44.0",
80
- "husky": "^8.0.3",
81
- "jest": "^26.6.3",
82
- "jest-esbuild": "^0.1.6",
83
- "lint-staged": "^10.5.4",
84
- "typescript": "^4.7.0",
85
- "unbuild": "^2.0.0",
86
- "vite": "^2.8.6"
87
- },
88
- "lint-staged": {
89
- "*.{ts}": "eslint --fix --ext",
90
- "*.{ts,md}": "prettier --write"
91
- },
92
- "husky": {
93
- "hooks": {
94
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
95
- "pre-commit": "lint-staged"
96
- }
97
- },
98
- "commitlint": {
99
- "extends": [
100
- "@commitlint/config-conventional"
101
- ]
102
- },
103
- "config": {
104
- "commitizen": {
105
- "path": "./node_modules/cz-conventional-changelog"
106
- }
107
- }
1
+ {
2
+ "name": "@1szx1/vite-plugin-swagger2ts",
3
+ "description": "forked from https://github.com/morelearn1990/vite-plugin-swagger2ts",
4
+ "version": "1.3.1",
5
+ "license": "MIT",
6
+ "author": "1SZX1 <2414126198@qq.com>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/1SZX1/vite-plugin-swagger2ts"
10
+ },
11
+ "homepage": "https://github.com/1SZX1/vite-plugin-swagger2ts",
12
+ "bugs": "https://github.com/1SZX1/vite-plugin-swagger2ts/issues",
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "exports": {
17
+ ".": {
18
+ "require": "./dist/index.cjs",
19
+ "import": "./dist/index.mjs",
20
+ "types": "./dist/index.d.ts"
21
+ },
22
+ "./adapters": {
23
+ "require": "./dist/adapters.cjs",
24
+ "import": "./dist/adapters.mjs",
25
+ "types": "./dist/adapters.d.ts"
26
+ }
27
+ },
28
+ "main": "dist/index.cjs",
29
+ "module": "dist/index.mjs",
30
+ "types": "dist/index.d.ts",
31
+ "typesVersions": {
32
+ "*": {
33
+ "adapters": [
34
+ "./dist/adapters"
35
+ ]
36
+ }
37
+ },
38
+ "bin": {
39
+ "swagger2ts": "./dist/bin.mjs"
40
+ },
41
+ "scripts": {
42
+ "build": "unbuild",
43
+ "stub": "unbuild --stub",
44
+ "prepublishOnly": "pnpm run build",
45
+ "release": "pnpx git-ensure -a && pnpx bumpp --commit --tag --push",
46
+ "demo:dev": "pnpm -C examples/demo run dev",
47
+ "demo:build": "pnpm -C examples/demo run build",
48
+ "demo:preview": "pnpm -C examples/demo run preview",
49
+ "test": "jest",
50
+ "lint": "eslint --fix --ext .ts ./",
51
+ "version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md",
52
+ "preinstall": "npx only-allow pnpm"
53
+ },
54
+ "dependencies": {
55
+ "axios": "^1.4.0",
56
+ "cross-fetch": "^3.1.5",
57
+ "luch-request": "^3.1.0",
58
+ "openapi3-ts": "^2.0.2",
59
+ "swagger2openapi": "^7.0.8",
60
+ "unconfig": "^0.3.9"
61
+ },
62
+ "peerDependencies": {
63
+ "axios": "^1.4.0",
64
+ "luch-request": "^3.1.0",
65
+ "chalk": "^5.3.0",
66
+ "vite": "^2.0.0"
67
+ },
68
+ "devDependencies": {
69
+ "@antfu/eslint-config": "^0.6.6",
70
+ "@commitlint/cli": "^12.1.4",
71
+ "@commitlint/config-conventional": "^12.1.4",
72
+ "@dcloudio/types": "^3.3.3",
73
+ "@types/eslint": "^8.44.0",
74
+ "@types/jest": "^26.0.24",
75
+ "@types/node": "^14.18.12",
76
+ "@typescript-eslint/eslint-plugin": "^4.33.0",
77
+ "@typescript-eslint/parser": "^5.14.0",
78
+ "conventional-changelog": "^3.1.25",
79
+ "cz-conventional-changelog": "^3.3.0",
80
+ "eslint": "^8.44.0",
81
+ "husky": "^8.0.3",
82
+ "jest": "^26.6.3",
83
+ "jest-esbuild": "^0.1.6",
84
+ "lint-staged": "^10.5.4",
85
+ "typescript": "^4.7.0",
86
+ "unbuild": "^2.0.0",
87
+ "vite": "^2.8.6"
88
+ },
89
+ "lint-staged": {
90
+ "*.{ts}": "eslint --fix --ext",
91
+ "*.{ts,md}": "prettier --write"
92
+ },
93
+ "husky": {
94
+ "hooks": {
95
+ "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
96
+ "pre-commit": "lint-staged"
97
+ }
98
+ },
99
+ "commitlint": {
100
+ "extends": [
101
+ "@commitlint/config-conventional"
102
+ ]
103
+ },
104
+ "config": {
105
+ "commitizen": {
106
+ "path": "./node_modules/cz-conventional-changelog"
107
+ }
108
+ }
108
109
  }