gen-api-types 1.0.3 → 1.0.4
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/README.md +1 -1
- package/bin/index.js +33 -0
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ export class TestApi {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
@gen_type_m()
|
|
41
|
-
static getWeather(): Promise<
|
|
41
|
+
static getWeather(): Promise<Response__TestApi_getWeather> {
|
|
42
42
|
return fetch('http://t.weather.sojson.com/api/weather/city/101030100').then(r => r.json())
|
|
43
43
|
}
|
|
44
44
|
}
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// 强制使用 tsx 执行当前目录下的 TypeScript 文件
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
const { exec,execFile,spawn } = require('child_process');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { promisify } = require('util')
|
|
8
|
+
const p_exec = promisify(exec);
|
|
9
|
+
const args = process.argv.slice(2);
|
|
10
|
+
; (async function () {
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
await p_exec('tsx -v')
|
|
14
|
+
try {
|
|
15
|
+
const cli_path = path.resolve(__dirname,'../src/cli/index.ts')
|
|
16
|
+
// const cli_path = path.resolve(__dirname,'../dist/gen_api_types.cli.min.js')
|
|
17
|
+
|
|
18
|
+
const cp = spawn('tsx',[cli_path,...args],{ stdio: 'inherit',shell: true })
|
|
19
|
+
cp.on('error',err => console.error('执行 tsx 命令失败',err))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
} catch (error) {
|
|
24
|
+
// console.error('执行 tsx 命令失败',error)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('请安装 tsx',error)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
})();
|
|
33
|
+
|
package/package.json
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gen-api-types",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"bin": {
|
|
7
|
-
"gen-api-types": "src/cli/index.ts"
|
|
7
|
+
"gen-api-types": "src/cli/index.ts",
|
|
8
|
+
"gat": "bin/index.js"
|
|
8
9
|
},
|
|
9
10
|
"scripts": {
|
|
10
11
|
"test": "vitest",
|
|
11
12
|
"build": "webpack",
|
|
12
13
|
"publish:patch": "npm version patch && npm publish"
|
|
13
14
|
},
|
|
14
|
-
"keywords": [
|
|
15
|
+
"keywords": [
|
|
16
|
+
"generate types",
|
|
17
|
+
"TypeScript",
|
|
18
|
+
"Cli",
|
|
19
|
+
"API"
|
|
20
|
+
],
|
|
15
21
|
"files": [
|
|
16
22
|
"src",
|
|
17
23
|
"tsconfig.json",
|