Skip to content

Commit f01a0ef

Browse files
authored
Merge pull request #40 from cloudcome/feat/v0.x
Feat/v0.x
2 parents 5479ceb + c2441b3 commit f01a0ef

File tree

14 files changed

+239
-60
lines changed

14 files changed

+239
-60
lines changed

.eslintrc.cjs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,19 @@ module.exports = defineConfig({
99
es2022: true,
1010
},
1111

12-
parser: '@typescript-eslint/parser',
13-
14-
extends: [
15-
//
16-
'eslint:recommended',
17-
'plugin:@typescript-eslint/recommended',
18-
'plugin:prettier/recommended',
12+
overrides: [
13+
{
14+
files: ['*.ts'],
15+
parser: '@typescript-eslint/parser',
16+
extends: [
17+
//
18+
'eslint:recommended',
19+
'plugin:@typescript-eslint/recommended',
20+
'plugin:prettier/recommended',
21+
],
22+
rules: {
23+
'prettier/prettier': 'error',
24+
},
25+
},
1926
],
20-
21-
rules: {
22-
'prettier/prettier': 'error',
23-
},
2427
});

bin/index.cjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env node
2+
3+
const { start } = require('../dist-cjs/index.cjs');
4+
5+
start().then();

bin/index.mjs

Lines changed: 0 additions & 5 deletions
This file was deleted.

package-lock.json

Lines changed: 112 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,38 @@
66
"prepare": "husky install",
77
"lint": "eslint src/**/*.ts",
88
"test": "echo 'no test'",
9-
"build": "tsc -p tsconfig.build.json"
9+
"build:types": "rm -rf dist-dts && tsc --project tsconfig.types.json",
10+
"build:files": "rm -rf dist-cjs dist-mjs && rollup --config",
11+
"build": "npm run build:types && npm run build:files"
1012
},
1113
"engines": {
1214
"node": ">=16"
1315
},
1416
"engineStrict": true,
1517
"type": "module",
16-
"module": "./dist/index.js",
18+
"module": "dist-mjs/index.mjs",
19+
"main": "dist-cjs/index.cjs",
20+
"types": "dist-dts/index.d.ts",
1721
"exports": {
1822
".": {
19-
"import": "./dist/index.js",
20-
"types": "./dist/index.d.ts"
23+
"import": "./dist-mjs/index.mjs",
24+
"require": "./dist-cjs/index.cjs",
25+
"types": "./dist-dts/index.d.ts"
2126
},
22-
"./helper": {
23-
"import": "./dist/helper.js",
24-
"types": "./dist/helper.d.ts"
27+
"./helpers": {
28+
"import": "./dist-mjs/helpers.mjs",
29+
"require": "./dist-cjs/helpers.cjs",
30+
"types": "./dist-dts/helpers.d.ts"
2531
},
2632
"./package.json": "./package.json"
2733
},
2834
"bin": {
29-
"oas-gen-ts": "bin/index.mjs"
35+
"oas-gen-ts": "bin/index.cjs"
3036
},
3137
"files": [
32-
"dist",
38+
"dist-cjs",
39+
"dist-dts",
40+
"dist-mjs",
3341
"templates"
3442
],
3543
"keywords": [
@@ -41,16 +49,18 @@
4149
"axios"
4250
],
4351
"author": "云淡然 <hi@ydr.me>",
44-
"homepage": "https://github.com/cloudcome/oas_ts",
45-
"repository": "https://github.com/cloudcome/oas_ts",
52+
"homepage": "https://github.com/cloudcome/oas-gen-ts",
53+
"repository": "https://github.com/cloudcome/oas-gen-ts",
4654
"license": "MIT",
4755
"dependencies": {
56+
"chalk": "^5.2.0",
4857
"cosmiconfig": "^8.1.0",
4958
"swagger-typescript-api": "^12.0.3"
5059
},
5160
"devDependencies": {
5261
"@commitlint/cli": "^17.4.4",
5362
"@commitlint/config-conventional": "^17.4.4",
63+
"@rollup/plugin-typescript": "^11.0.0",
5464
"@types/node": "^18.15.3",
5565
"@types/prettier": "^2.7.2",
5666
"@typescript-eslint/eslint-plugin": "^5.55.0",
@@ -62,6 +72,7 @@
6272
"husky": "^8.0.3",
6373
"lint-staged": "^13.2.0",
6474
"prettier": "^2.8.4",
75+
"rollup": "^3.19.1",
6576
"typescript": "^4.9.5"
6677
}
6778
}

rollup.config.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import typescript from '@rollup/plugin-typescript';
2+
3+
export default {
4+
input: ['src/index.ts', 'src/helpers.ts'],
5+
output: [
6+
{
7+
format: 'esm',
8+
dir: 'dist-mjs',
9+
entryFileNames: '[name].mjs',
10+
},
11+
{
12+
format: 'cjs',
13+
dir: 'dist-cjs',
14+
entryFileNames: '[name].cjs',
15+
},
16+
],
17+
plugins: [
18+
typescript({
19+
tsconfig: 'tsconfig.json',
20+
}),
21+
],
22+
};

src/configure.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const defaults: Config = {
55
cwd: process.cwd(),
66
dest: 'src/apis',
77
axiosImport: axiosImportDefault,
8+
unwrapResponseData: false,
89
list: [],
910
};
1011

src/const.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import path from 'node:path';
1+
import path from 'path';
22

3-
export const templatesDir = path.join(__dirname, '../templates');
3+
const dirname = __dirname;
4+
5+
export const templatesDir = path.join(dirname, '../templates');
46
export const axiosImportDefault = `import { Axios } from 'axios';
57
const axios = new Axios();`;
68
export const helpersImport = `import { formatHeaders, formatBody } from 'oas-gen-ts/helpers';`;

0 commit comments

Comments
 (0)