@gopowerteam/request-generate 0.2.1 → 0.2.2

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/index.d.ts CHANGED
@@ -137,7 +137,7 @@ declare class Generate {
137
137
  * @returns Promise<void>
138
138
  */
139
139
  static startup(options: GenerateOptions): Promise<void>;
140
- static getApiDocument(url: string, retry?: number): Promise<UnkownVersionDocument>;
140
+ static getApiDocument(input: string): Promise<UnkownVersionDocument>;
141
141
  /**
142
142
  * 生成应用
143
143
  */
package/dist/index.js CHANGED
@@ -994,6 +994,10 @@ function updateOptionsFromLocalConfig(options, output) {
994
994
  return false;
995
995
  }
996
996
  });
997
+ options.forEach((item) => {
998
+ const file = path2.default.resolve(".request", `${item.name}.json`);
999
+ item.input = file;
1000
+ });
997
1001
  writeLocalConfig(toUpdateOptions, config);
998
1002
  return options;
999
1003
  }
@@ -1133,17 +1137,15 @@ var _Generate = class {
1133
1137
  _Generate.writeClient(application.client, application.options);
1134
1138
  });
1135
1139
  }
1136
- static async getApiDocument(url, retry = 0) {
1137
- if (retry >= 3) {
1138
- console.error(`\u8BF7\u6C42[${url}]\u5931\u8D25,\u8BF7\u7A0D\u540E\u91CD\u8BD5.`);
1139
- _process2.default.exit(0);
1140
- }
1140
+ static async getApiDocument(input) {
1141
1141
  try {
1142
- return await getOpenApiDocument(
1143
- url
1142
+ const document = await getOpenApiDocument(
1143
+ input
1144
1144
  );
1145
+ return document;
1145
1146
  } catch (e) {
1146
- return _Generate.getApiDocument(url, retry + 1);
1147
+ console.error(`\u8BF7\u6C42\u6587\u4EF6[${input}]\u5931\u8D25,\u8BF7\u7A0D\u540E\u91CD\u8BD5.`);
1148
+ _process2.default.exit(0);
1147
1149
  }
1148
1150
  }
1149
1151
  /**
package/dist/index.mjs CHANGED
@@ -995,6 +995,10 @@ function updateOptionsFromLocalConfig(options, output) {
995
995
  return false;
996
996
  }
997
997
  });
998
+ options.forEach((item) => {
999
+ const file = path4.resolve(".request", `${item.name}.json`);
1000
+ item.input = file;
1001
+ });
998
1002
  writeLocalConfig(toUpdateOptions, config);
999
1003
  return options;
1000
1004
  }
@@ -1134,17 +1138,15 @@ var _Generate = class {
1134
1138
  _Generate.writeClient(application.client, application.options);
1135
1139
  });
1136
1140
  }
1137
- static async getApiDocument(url, retry = 0) {
1138
- if (retry >= 3) {
1139
- console.error(`\u8BF7\u6C42[${url}]\u5931\u8D25,\u8BF7\u7A0D\u540E\u91CD\u8BD5.`);
1140
- process.exit(0);
1141
- }
1141
+ static async getApiDocument(input) {
1142
1142
  try {
1143
- return await getOpenApiDocument(
1144
- url
1143
+ const document = await getOpenApiDocument(
1144
+ input
1145
1145
  );
1146
+ return document;
1146
1147
  } catch {
1147
- return _Generate.getApiDocument(url, retry + 1);
1148
+ console.error(`\u8BF7\u6C42\u6587\u4EF6[${input}]\u5931\u8D25,\u8BF7\u7A0D\u540E\u91CD\u8BD5.`);
1149
+ process.exit(0);
1148
1150
  }
1149
1151
  }
1150
1152
  /**
@@ -4,6 +4,7 @@
4
4
  var _child_process = require('child_process');
5
5
  var _fs = require('fs'); var fs = _interopRequireWildcard(_fs);
6
6
  var _path = require('path'); var path = _interopRequireWildcard(_path);
7
+ var _process = require('process'); var _process2 = _interopRequireDefault(_process);
7
8
  var _handlebars = require('handlebars'); var _handlebars2 = _interopRequireDefault(_handlebars);
8
9
 
9
10
  // src/vite-plugin/templates.ts
@@ -125,7 +126,12 @@ function genretateDeclareAndCode(options) {
125
126
  }
126
127
  function generateRequestCode() {
127
128
  const generateScript = path.resolve(viteConfig.root, "node_modules", ".bin", "request-generate");
128
- _child_process.execSync.call(void 0, `${generateScript}`);
129
+ _child_process.execSync.call(void 0, `${generateScript}`, {
130
+ env: {
131
+ ..._process2.default.env,
132
+ FORCE_COLOR: "1"
133
+ }
134
+ });
129
135
  }
130
136
  var vite_plugin_default = (options) => {
131
137
  return {
@@ -4,6 +4,7 @@ import "../chunk-WF3XBEPN.mjs";
4
4
  import { execSync } from "node:child_process";
5
5
  import * as fs from "node:fs";
6
6
  import * as path from "node:path";
7
+ import process from "node:process";
7
8
  import Handlebars from "handlebars";
8
9
 
9
10
  // src/vite-plugin/templates.ts
@@ -125,7 +126,12 @@ function genretateDeclareAndCode(options) {
125
126
  }
126
127
  function generateRequestCode() {
127
128
  const generateScript = path.resolve(viteConfig.root, "node_modules", ".bin", "request-generate");
128
- execSync(`${generateScript}`);
129
+ execSync(`${generateScript}`, {
130
+ env: {
131
+ ...process.env,
132
+ FORCE_COLOR: "1"
133
+ }
134
+ });
129
135
  }
130
136
  var vite_plugin_default = (options) => {
131
137
  return {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gopowerteam/request-generate",
3
3
  "type": "commonjs",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "private": false,
6
6
  "keywords": [
7
7
  "gopowerteam",