Skip to content

Commit 9c8cd3f

Browse files
committed
feat: 增加发布
1 parent f54a261 commit 9c8cd3f

12 files changed

+7514
-3720
lines changed

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
dist/**
22
build/**
33
node_modules
4+
coverage
5+
config
6+
47
*.test.{js,jsx,ts,tsx}
58
*.spec.{js,jsx,ts,tsx}
69
**/config-overrides.js

.eslintrc.js

+16-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ module.exports = {
88
'airbnb',
99
],
1010
plugins: ['prettier'],
11+
settings: {
12+
'import/resolver': {
13+
node: {
14+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
15+
},
16+
},
17+
},
1118
parserOptions: {
1219
ecmaFeatures: {
1320
jsx: true,
@@ -16,6 +23,15 @@ module.exports = {
1623
sourceType: 'module',
1724
},
1825
ignorePatterns: ['**/*/*.test.js'],
26+
overrides: [
27+
{
28+
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
29+
extends: ['plugin:testing-library/react'],
30+
env: {
31+
jest: true,
32+
},
33+
},
34+
],
1935
rules: {
2036
'import/extensions': 0,
2137
'react/jsx-filename-extension': [1, { extensions: ['.tsx', '.ts'] }],
@@ -37,11 +53,4 @@ module.exports = {
3753
'import/prefer-default-export': [0],
3854
'react/jsx-props-no-spreading': 0,
3955
},
40-
settings: {
41-
'import/resolver': {
42-
node: {
43-
extensions: ['.js', '.jsx', '.ts', '.tsx'],
44-
},
45-
},
46-
},
4756
};

.husky/commit-msg

+4
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 --no-install commitlint --edit "$1"

.release-it.json

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"hooks": {
3+
"after:git:release": "git push origin HEAD"
4+
},
5+
"git": {
6+
"commitMessage": "chore: release ${version}",
7+
"requireCommits": true
8+
},
9+
"plugins": {
10+
"@release-it/conventional-changelog": {
11+
"infile": "CHANGELOG.md",
12+
"preset": {
13+
"name": "conventionalcommits",
14+
"types": [
15+
{
16+
"type": "feat",
17+
"section": "Features"
18+
},
19+
{
20+
"type": "fix",
21+
"section": "Bug Fixes"
22+
},
23+
{
24+
"type": "docs",
25+
"section": "Docs"
26+
},
27+
{
28+
"type": "refactor",
29+
"section": "Refactors"
30+
},
31+
{
32+
"type": "style",
33+
"section": "Refactors"
34+
},
35+
{
36+
"type": "perf",
37+
"section": "Performances"
38+
},
39+
{
40+
"type": "chore",
41+
"section": "Miscellaneous"
42+
},
43+
{
44+
"type": "build",
45+
"section": "Miscellaneous"
46+
},
47+
{
48+
"type": "test",
49+
"section": "Miscellaneous"
50+
}
51+
]
52+
}
53+
}
54+
}
55+
}

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"editor.codeActionsOnSave": {
44
"source.fixAll.eslint": true,
55
"source.fixAll": true
6-
}
6+
},
7+
"typescript.tsdk": "node_modules\\typescript\\lib"
78
}

README.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
# Lerna-TS-React
1+
# Typescript-React-Template
22

33
`master` branch integrate `TypeScript`, `ESlint`, `React`, `Redux` features.
44

5-
`blog` branch code from this [blog](https://dev.to/davixyz/writing-your-first-react-ui-library-part-1-lerna-17kc).
6-
75
## Lerna part
86

97
## create component

commitlint.config.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module.exports = {
2+
extends: [
3+
'@commitlint/config-conventional',
4+
],
5+
// rule 由 name 和配置数组组成,如:'name:[0, 'always', 72]',
6+
// 数组第一位:level,可选 0(disable), 1(warning), 2(error)
7+
// 数组第二位:应用与否,可选 always | nerver
8+
// 数组第三位:具体配置值
9+
rules: {
10+
'type-enum': [
11+
2,
12+
'always',
13+
[
14+
'build', // 构建系统或者外部依赖的修改
15+
'update', // 更新某功能(不是 feat,也不是 fix)
16+
'feat', // 新功能(feature)
17+
'fix', // 修复 bug
18+
'refactor', // 重构(不是新增功能,也不是修复 bug)
19+
'docs', // 文档
20+
'chore', // 构建过程或者辅助工具的修改
21+
'style', // 不影响代码含义的修改(空格,格式化,分号等)
22+
'revert', // 代码回退
23+
'ci', // CI 配置文件修改
24+
'perf', // 提升性能导致的修改
25+
'test', // 测试代码修改
26+
],
27+
],
28+
'body-leading-blank': [2, 'always'],
29+
'type-case': [0],
30+
'type-empty': [0],
31+
},
32+
};

package.json

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
{
2-
"name": "phoenix",
2+
"name": "typescript-react-template",
33
"version": "1.0.0",
44
"description": "",
55
"private": true,
66
"workspaces": [
77
"packages/*"
88
],
99
"scripts": {
10-
"build": "lerna run lint && lerna run build",
10+
"build": "lerna run build",
1111
"lint": "lerna run lint --parallel",
12+
"start": "lerna run start --scope app",
1213
"clean": "lerna clean -y && rimraf -rf ./node_modules",
1314
"storybook": "start-storybook -p 6006",
1415
"build-storybook": "build-storybook",
1516
"pkg-init": "node ./scripts/init.js",
16-
"lint-file": "eslint --ignore-path ./.eslintignore --quiet --fix "
17+
"lint-file": "eslint --ignore-path ./.eslintignore --quiet --fix ",
18+
"release": "yarn lint && yarn build && release-it",
19+
"release-dry-run": "lerna run release-dry-run --scope={@cddev/phoenix-button,app}"
1720
},
1821
"devDependencies": {
1922
"@babel/core": "^7.18.6",
23+
"@commitlint/cli": "^17.0.3",
24+
"@commitlint/config-conventional": "^17.0.3",
25+
"@release-it/conventional-changelog": "^5.0.0",
2026
"@storybook/addon-actions": "^6.5.9",
2127
"@storybook/addon-essentials": "^6.5.9",
2228
"@storybook/addon-links": "^6.5.9",
@@ -28,26 +34,32 @@
2834
"eslint": "^8.19.0",
2935
"eslint-config-airbnb": "^19.0.4",
3036
"eslint-config-prettier": "^8.5.0",
37+
"eslint-config-react-app": "^7.0.1",
38+
"eslint-import-resolver-typescript": "^3.2.5",
3139
"eslint-plugin-import": "^2.26.0",
40+
"eslint-plugin-jest": "^26.5.3",
3241
"eslint-plugin-jsx-a11y": "^6.6.0",
3342
"eslint-plugin-prettier": "^4.2.1",
3443
"eslint-plugin-react": "^7.30.1",
3544
"eslint-plugin-react-hooks": "^4.6.0",
45+
"eslint-plugin-testing-library": "^5.5.1",
3646
"husky": "^8.0.1",
3747
"lerna": "^5.1.8",
3848
"lint-staged": "^13.0.3",
3949
"prettier": "^2.7.1",
4050
"react": "^18.2.0",
4151
"react-dom": "^18.2.0",
52+
"release-it": "^15.1.1",
4253
"rimraf": "^3.0.2"
4354
},
4455
"dependencies": {},
4556
"husky": {
4657
"hooks": {
58+
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
4759
"pre-commit": "lint-staged"
4860
}
4961
},
5062
"lint-staged": {
51-
"*.{js,jsx,ts,tsx}": "yarn run lint:fix"
63+
"*.{js,jsx,ts,tsx}": "yarn run lint"
5264
}
53-
}
65+
}

packages/phoenix-button/CHANGELOG.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
3+
## 0.1.0 (2022-07-13)
4+
5+
6+
### Features
7+
8+
* 新增 react app ([79a92cb](http://192.168.25.212:82/pingqixing/typescript-react-template/commit/79a92cb0ba8f5e584b44666a505ab1a751dd443f))
9+
10+
11+
### Bug Fixes
12+
13+
* 修改 lint ([41e5046](http://192.168.25.212:82/pingqixing/typescript-react-template/commit/41e5046b4a9eca8d49d15d18da2569fae4897150))
14+
* scripts ([104d376](http://192.168.25.212:82/pingqixing/typescript-react-template/commit/104d376e8b9dcd981260c91d8cc3485344650e8c))
15+
16+
17+
### Miscellaneous
18+
19+
* 发布增加 scope ([36bfb83](http://192.168.25.212:82/pingqixing/typescript-react-template/commit/36bfb837aed4b42860822c07f3b1c0088896ed47))
20+
* 发布增加 scope ([b30eb53](http://192.168.25.212:82/pingqixing/typescript-react-template/commit/b30eb53e7b4853dd5f81d30d5584dddd19b9fa5e))
21+
* 发布增加 scope ([568fd4b](http://192.168.25.212:82/pingqixing/typescript-react-template/commit/568fd4b96c9712e3c55f5cc78e11a737ff3ac353))
22+
* 删除顶层 release 的 publishPath ([30bb48d](http://192.168.25.212:82/pingqixing/typescript-react-template/commit/30bb48d0b88814315870b8a6c3b27870b19da711))
23+
* 设置 ts 为本地版本 ([1881fbf](http://192.168.25.212:82/pingqixing/typescript-react-template/commit/1881fbfdfb5f771e8c68df1456081421cc0d7d72))
24+
* 修改名字 ([a33b74c](http://192.168.25.212:82/pingqixing/typescript-react-template/commit/a33b74c4c1f82c939e3cb00f01c4ba706a3eeb3c))
25+
* 增加 release 配置 ([2973a8c](http://192.168.25.212:82/pingqixing/typescript-react-template/commit/2973a8c4049d9b841c8624d93057123afbe6623d))
26+
* app 依赖升级 ([f74d99c](http://192.168.25.212:82/pingqixing/typescript-react-template/commit/f74d99c651d9b4257f7446034c698b0c85c253da))
27+
* husky ([fc89357](http://192.168.25.212:82/pingqixing/typescript-react-template/commit/fc89357e97f6bfa9b9831881894327e33d9b809a))
28+
* release 脚本 ([a07f07d](http://192.168.25.212:82/pingqixing/typescript-react-template/commit/a07f07db00071d94b5fccddf71e2d492dc1fbc5a))

packages/phoenix-button/package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cddev/phoenix-button",
3-
"version": "0.0.0",
3+
"version": "0.1.0",
44
"description": "Now I’m the model of a modern major general / The venerated Virginian veteran whose men are all / Lining up, to put me up on a pedestal / Writin’ letters to relatives / Embellishin’ my elegance and eloquence / But the elephant is in the room / The truth is in ya face when ya hear the British cannons go / BOOM",
55
"keywords": [],
66
"author": "navono <[email protected]>",
@@ -17,11 +17,13 @@
1717
],
1818
"publishConfig": {
1919
"access": "public",
20+
"registry": "http://192.168.25.57:8081/repository/npm-private/",
2021
"directory": "."
2122
},
2223
"scripts": {
2324
"build": "rimraf dist && phoenix-builder",
24-
"lint": "eslint --ignore-path ../../.eslintignore --quiet --fix ./src/**/*"
25+
"lint": "eslint --ignore-path ../../.eslintignore --quiet --fix ./src/**/*",
26+
"release-dry-run": "release-it --dry-run --ci"
2527
},
2628
"devDependencies": {
2729
"@cddev/phoenix-builder": "^0.0.0",
@@ -34,4 +36,4 @@
3436
"dependencies": {
3537
"clsx": "^1.2.1"
3638
}
37-
}
39+
}
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export interface ButtonProps {
2-
children: any;
3-
className: any;
4-
variant: any;
2+
children?: any;
3+
className?: any;
4+
variant?: any;
55
[x: string]: any;
66
}

0 commit comments

Comments
 (0)