Skip to content

Commit 8f39839

Browse files
committed
init
0 parents  commit 8f39839

File tree

13 files changed

+1790
-0
lines changed

13 files changed

+1790
-0
lines changed

.github/workflows/build.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: build
2+
on:
3+
push:
4+
tags:
5+
- '[0-9]+.[0-9]+.[0-9]+'
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
env:
12+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
13+
NPM_TOKEN: ${{secrets.NPM_YZ_TOKEN}}
14+
CI_FE_TOKEN: ${{secrets.CI_FE_TOKEN}}
15+
16+
strategy:
17+
matrix:
18+
node-version: [14.x]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v1
24+
with:
25+
always-auth: true
26+
node-version: ${{ matrix.node-version }}
27+
- run: npm config set always-auth=true
28+
- run: npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
29+
- run: npm config set //npm.yzops.net/:_authToken $NPM_TOKEN
30+
- run: yarn
31+
- run: yarn build
32+
- run: npm --no-git-tag-version version ${GITHUB_REF#refs/tags/}
33+
- run: npm publish
34+
# - run: CI_TOKEN=$CI_FE_TOKEN yarn docs:build

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
logs
3+
run
4+
dist
5+
dtpl.error.log

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## ts-jsonschema-sync
2+
3+
监测 ts 的 interface 定义,一有改动,同步生成 json schema。
4+
5+
Monitor the interface definition of ts and generate JSON schema synchronously once there is any modification.
6+
7+
## install
8+
9+
```
10+
yarn add @yzfe/ts-jsonschema-sync
11+
```
12+
13+
## use
14+
15+
```ts
16+
import { getTypeNames, getSchemaObject } from '@yzfe/ts-jsonschema-sync'
17+
import * as path from 'path'
18+
19+
const rootPath = path.join(__dirname, 'typings')
20+
21+
const types = getTypeNames({
22+
rootPath
23+
})
24+
25+
console.log(types)
26+
27+
console.log(JSON.stringify(getSchemaObject(types[0], {
28+
rootPath
29+
}), null, 2))
30+
```

package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "@yzfe/ts-jsonschema-sync",
3+
"version": "0.0.0",
4+
"description": "Monitor the interface definition of ts and generate JSON schema synchronously once there is any modification",
5+
"main": "./dist/index.js",
6+
"module": "./dist/esm/index.js",
7+
"types": "./dist/index.d.ts",
8+
"author": "[email protected]",
9+
"license": "MIT",
10+
"publishConfig": {
11+
"access": "public",
12+
"registry": "https://registry.npmjs.org"
13+
},
14+
"files": [
15+
"dist",
16+
"package.json",
17+
"README.md"
18+
],
19+
"scripts": {
20+
"dev": "npm run build -- --watch",
21+
"build": "tsup",
22+
"docs": "npm run cpHome && vuepress dev docs",
23+
"docs:build": "npm run cpHome && NODE_ENV=production vuepress build docs",
24+
"test": "ts-node --transpile-only --skip-project test"
25+
},
26+
"dependencies": {
27+
"glob": "^9.3.2",
28+
"typescript-json-schema": "^0.55.0"
29+
},
30+
"devDependencies": {
31+
"@types/node": "^18.15.11",
32+
"ts-node": "^10.9.1",
33+
"tsup": "^6.7.0",
34+
"typescript": "^5.0.3"
35+
}
36+
}

src/.prettierrc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"singleQuote": true,
3+
"semi": false,
4+
"tabWidth": 4,
5+
"overrides": [
6+
{
7+
"files": ["src/**/*.tsx", "test/**/*.ts"],
8+
"options": {
9+
"parser": "typescript"
10+
}
11+
}
12+
]
13+
}

0 commit comments

Comments
 (0)