diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..80c4a8d --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,21 @@ +name: publish to npm + +on: + release: + types: [ created ] + +jobs: + build-and-publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '16.x' + registry-url: 'https://registry.npmjs.org' + - run: yarn + - run: yarn build + - run: yarn publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.gitignore b/.gitignore index 2074f5b..2460e46 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ yarn-debug.log* yarn-error.log* yarn.lock package-lock.json +pnpm-lock.yaml # Editor directories and files .idea diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..36af219 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +npx lint-staged diff --git a/.lintstagedrc b/.lintstagedrc deleted file mode 100644 index bf36132..0000000 --- a/.lintstagedrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "*.{ts,js}": ["eslint --fix", "prettier --write"] -} diff --git a/CHANGELOG.md b/CHANGELOG.md index 68d508d..93a2591 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +### 1.0.5 + +feat + +- export all types + +fix + +- support windows path + ### 1.0.4 feat diff --git a/README.md b/README.md index 1837e0b..9ad60e2 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,10 @@ then in package.json ## Options +
+TOC +
+ - [entry (required)](#entry) - [outDir (required)](#outdir) - [name (required)](#name) @@ -78,6 +82,9 @@ then in package.json - [tableRegExp](#tableregexp) - [fileNameRegExp](#filenameregexp) +
+
+ ### entry - Required: `true` diff --git a/package.json b/package.json index ce22f98..f69356b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "components-helper", - "version": "1.0.4", + "version": "1.0.5", "description": "Based on the docs to provide code prompt files for vue component library", "main": "lib/index.js", "module": "lib/index.es.js", @@ -16,7 +16,8 @@ "build": "rollup -c rollup.config.js", "test": "node test/index.js", "lint": "eslint . --fix --ext .ts,.js --ignore-pattern \"/lib/\"", - "prettier": "prettier --write \"src/*.ts\" --ignore-unknown" + "prettier": "prettier --write \"src/*.ts\" --ignore-unknown", + "prepare": "husky install" }, "files": [ "lib" @@ -46,24 +47,22 @@ "node": ">10.0.0" }, "dependencies": { - "fast-glob": "^3.2.5" + "fast-glob": "^3.2.7" }, "devDependencies": { - "@types/node": "^14.14.35", - "@typescript-eslint/eslint-plugin": "^4.19.0", - "@typescript-eslint/parser": "^4.19.0", - "eslint": "^7.22.0", - "eslint-plugin-prettier": "^3.3.1", - "husky": "^4.3.6", - "lint-staged": "^10.5.4", - "prettier": "^2.2.1", - "rollup": "^2.42.3", + "@types/node": "^16.11.12", + "@typescript-eslint/eslint-plugin": "^5.6.0", + "@typescript-eslint/parser": "^5.6.0", + "eslint": "^8.4.1", + "eslint-plugin-prettier": "^4.0.0", + "husky": "^7.0.4", + "lint-staged": "^12.1.2", + "prettier": "^2.5.1", + "rollup": "^2.61.0", "rollup-plugin-typescript2": "^0.30.0", - "typescript": "^4.2.3" + "typescript": "^4.5.2" }, - "husky": { - "hooks": { - "pre-commit": "lint-staged" - } + "lint-staged": { + "*.{ts,js}": ["eslint --fix", "prettier --write"] } } diff --git a/rollup.config.js b/rollup.config.js index 89c9f7d..84a25af 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -2,13 +2,13 @@ import ts from 'rollup-plugin-typescript2' const commonConf = { input: './src/index.ts', - external: ['fast-glob'], - plugins:[ + external: ['fast-glob', 'fs', 'path'], + plugins: [ ts({ extensions: ['.ts'], tsconfig: './tsconfig.json', }), - ] + ], } const list = [ @@ -16,16 +16,16 @@ const list = [ file: 'lib/index.es.js', format: 'es', exports: 'named', + compact: true, }, { file: 'lib/index.js', - format: 'umd', + format: 'cjs', exports: 'named', - name: 'ComponentsHelper', compact: true, }, ] -const buildConf = options => Object.assign({}, commonConf, options) +const buildConf = (options) => Object.assign({}, commonConf, options) -export default list.map(output => buildConf({ output })) +export default list.map((output) => buildConf({ output })) diff --git a/src/index.ts b/src/index.ts index 5dc5f0d..8f42e48 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ -// eslint-disable-next-line @typescript-eslint/no-var-requires -const fg = require('fast-glob') +import fg from 'fast-glob' import config from './config' import read from './read' import parse from './parse' @@ -32,5 +31,6 @@ const main = (options = {} as InstallOptions): void => { write(_options, 'webTypes', webTypesData) } +export * from './type' export default main module.exports = main diff --git a/src/type.ts b/src/type.ts index 2b26d93..00f4d62 100644 --- a/src/type.ts +++ b/src/type.ts @@ -1,31 +1,35 @@ -type ReComponentName = (title: string, fileName: string, path: string) => string +export type ReComponentName = ( + title: string, + fileName: string, + path: string, +) => string -type ReDocUrl = ( +export type ReDocUrl = ( fileName: string, header?: string, path?: string, ) => string | undefined -type ReAttribute = ( +export type ReAttribute = ( value: string, key: string, columns: string[], title: string, ) => string | undefined -type ReVeturDescription = ( +export type ReVeturDescription = ( description?: string, defaultValue?: string, docUrl?: string, ) => string | undefined -type ReWebTypesSource = ( +export type ReWebTypesSource = ( title: string, fileName: string, path: string, ) => Source -interface OptionsConfig { +export interface OptionsConfig { entry: string outDir: string name: string diff --git a/tsconfig.json b/tsconfig.json index 215195f..08d8434 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,8 +4,9 @@ "module":"esnext", "lib": ["ESNext"], "outDir": "lib", + "moduleResolution": "Node", "strict": true, "declaration": true, - "removeComments": true + "allowSyntheticDefaultImports": true } }