Skip to content

Commit 4433542

Browse files
authored
Merge pull request #38 from cloudcome/feat/v0.x
Feat/v0.x
2 parents b278db1 + 34c49a1 commit 4433542

24 files changed

+4562
-203
lines changed

.commitlintrc.cjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* @type {import('@commitlint/types').UserConfig}
3+
*/
4+
module.exports = {
5+
extends: ['@commitlint/config-conventional'],
6+
};

.eslintignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Macos
2+
.DS_Store
3+
4+
# Node
5+
node_modules
6+
package-lock.json
7+
pnpm-lock.yaml
8+
yarn.lock
9+
10+
# local env files
11+
.env.local
12+
.env.*.local
13+
14+
# Log files
15+
*.log
16+
npm-debug.log*
17+
yarn-debug.log*
18+
yarn-error.log*
19+
pnpm-debug.log*
20+
21+
# Editor directories and files
22+
.idea
23+
.vscode
24+
!.vscode/extensions.json
25+
26+
# dist and cache
27+
/dist
28+
/dist-*
29+
/dist_*
30+
.cache
31+
32+
# testing
33+
/coverage
34+
35+
# next.js
36+
.next
37+
/out
38+
/build
39+
40+
# nuxt.js
41+
.nuxt
42+
.nitro
43+
.output

.eslintrc.cjs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const { defineConfig } = require('eslint-define-config');
2+
3+
module.exports = defineConfig({
4+
root: true,
5+
6+
env: {
7+
browser: true,
8+
node: true,
9+
es2022: true,
10+
},
11+
12+
parser: '@typescript-eslint/parser',
13+
14+
extends: [
15+
//
16+
'eslint:recommended',
17+
'plugin:@typescript-eslint/recommended',
18+
'plugin:prettier/recommended',
19+
],
20+
21+
rules: {
22+
'prettier/prettier': 'error',
23+
},
24+
});

.husky/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
```shell
2+
chmod +x commit-msg
3+
chmod +x pre-commit
4+
```

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx commitlint --edit "$1"

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx lint-staged

.lintstagedrc.cjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
'*.ts': 'eslint --fix',
3+
'*': 'prettier --ignore-unknown --write',
4+
};

.prettierignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Macos
2+
.DS_Store
3+
4+
# Node
5+
node_modules
6+
package-lock.json
7+
pnpm-lock.yaml
8+
yarn.lock
9+
10+
# local env files
11+
.env.local
12+
.env.*.local
13+
14+
# Log files
15+
*.log
16+
npm-debug.log*
17+
yarn-debug.log*
18+
yarn-error.log*
19+
pnpm-debug.log*
20+
21+
# Editor directories and files
22+
.idea
23+
.vscode
24+
!.vscode/extensions.json
25+
26+
# dist and cache
27+
/dist
28+
/dist-*
29+
/dist_*
30+
.cache
31+
32+
# testing
33+
/coverage
34+
35+
# next.js
36+
.next
37+
/out
38+
/build
39+
40+
# nuxt.js
41+
.nuxt
42+
.nitro
43+
.output

.prettierrc.cjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* @type {import('prettier').Config}
3+
*/
4+
module.exports = {
5+
tabWidth: 2,
6+
singleQuote: true,
7+
};

README.md

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,44 @@
22

33
OpenAPI Specification ➡️ TypeScript
44

5-
# 安装
5+
# Install
66

77
```shell
88
npm i -D oas-gen-ts
99
```
1010

11-
# 使用
11+
# Usage
1212

13-
## 命令行
13+
## CLI
14+
15+
Create oas.config.js or oas.json in the root directory of the project, and refer to [cosmiconfig](https://www.npmjs.com/package/cosmiconfig) for the file name specification.
16+
17+
```ts
18+
// oas.config.mjs
19+
export default defineConfig({
20+
axiosImport: `import { axios } from '@/util/axios';`,
21+
list: [
22+
{
23+
name: 'pet',
24+
url: 'https://petstore3.swagger.io/api/v3/openapi.json',
25+
},
26+
],
27+
});
28+
```
29+
30+
```shell
31+
# Generate typescript files based on configuration files
32+
npx oas-gen-ts
33+
34+
# The `src/apis/pet.ts` file will be generated
35+
```
1436

1537
## API
1638

17-
[](https://)
39+
```ts
40+
import { generate } from 'oas-gen-ts';
41+
42+
generate({
43+
// ...
44+
});
45+
```

0 commit comments

Comments
 (0)