@gopowerteam/request-generate 0.1.22 → 0.1.23
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/bin/{index.cjs → index.mts} +18 -12
- package/package.json +5 -5
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
'use strict'
|
|
3
|
-
require('ts-node').register()
|
|
1
|
+
#!/usr/bin/env tsx
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import fs from 'node:fs'
|
|
5
|
+
import { program } from 'commander'
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
8
7
|
|
|
9
|
-
const
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
const RequestGenerate = await import(path.resolve(
|
|
10
11
|
__dirname,
|
|
11
12
|
'..',
|
|
12
13
|
'dist',
|
|
13
|
-
'index.
|
|
14
|
+
'index.mjs'
|
|
14
15
|
))
|
|
15
16
|
|
|
16
17
|
const params = program
|
|
@@ -31,7 +32,7 @@ const configFilePaths = [
|
|
|
31
32
|
* @param {*} filePath
|
|
32
33
|
* @returns
|
|
33
34
|
*/
|
|
34
|
-
function loadConfigFile(filePath) {
|
|
35
|
+
async function loadConfigFile(filePath) {
|
|
35
36
|
if (filePath) {
|
|
36
37
|
configFilePaths.unshift(filePath)
|
|
37
38
|
}
|
|
@@ -40,17 +41,22 @@ function loadConfigFile(filePath) {
|
|
|
40
41
|
fs.existsSync(path.resolve(process.cwd(), file))
|
|
41
42
|
)
|
|
42
43
|
|
|
44
|
+
if(!configFilePath){
|
|
45
|
+
throw new Error("Not Find Config File.")
|
|
46
|
+
}
|
|
47
|
+
|
|
43
48
|
if (configFilePath.endsWith('js')) {
|
|
44
|
-
return
|
|
49
|
+
return import(path.resolve(process.cwd(), configFilePath))
|
|
45
50
|
} else if (configFilePath.endsWith('ts')) {
|
|
46
|
-
return
|
|
51
|
+
return import(path.resolve(process.cwd(), configFilePath))
|
|
47
52
|
} else {
|
|
48
53
|
throw new Error('无法找到RequestGenerate配置文件')
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
|
|
52
57
|
if (RequestGenerate) {
|
|
53
|
-
const config = loadConfigFile(params.config)
|
|
58
|
+
const { default: config } = await loadConfigFile(params.config)
|
|
59
|
+
|
|
54
60
|
RequestGenerate.default(config)
|
|
55
61
|
.then(() => {
|
|
56
62
|
console.log('接口文件生成完成')
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gopowerteam/request-generate",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.23",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"README.md"
|
|
11
11
|
],
|
|
12
12
|
"bin": {
|
|
13
|
-
"request-generate": "bin/index.
|
|
13
|
+
"request-generate": "bin/index.mts"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"gopowerteam",
|
|
@@ -44,19 +44,19 @@
|
|
|
44
44
|
"jest": "^29.4.3",
|
|
45
45
|
"openapi-types": "^12.1.0",
|
|
46
46
|
"ts-jest": "^29.0.5",
|
|
47
|
-
"ts-node": "^10.9.1",
|
|
48
47
|
"tsup": "^6.6.3",
|
|
49
48
|
"typescript": "^4.9.5",
|
|
50
49
|
"vite": "^4.1.4",
|
|
51
|
-
"@gopowerteam/request": "0.1.
|
|
50
|
+
"@gopowerteam/request": "0.1.19"
|
|
52
51
|
},
|
|
53
52
|
"dependencies": {
|
|
54
53
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
54
|
+
"commander": "^10.0.0",
|
|
55
55
|
"handlebars": "^4.7.8",
|
|
56
56
|
"qs": "^6.11.0",
|
|
57
57
|
"rimraf": "^4.1.2",
|
|
58
58
|
"rxjs": "^7.8.0",
|
|
59
|
-
"
|
|
59
|
+
"tsx": "^4.7.0"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"build": "tsup"
|