Skip to content

Commit 09453a4

Browse files
authored
Initial commit
0 parents  commit 09453a4

28 files changed

+9263
-0
lines changed

.eslintignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
*.sh
2+
node_modules
3+
*.md
4+
*.woff
5+
*.ttf
6+
.vscode
7+
.idea
8+
dist
9+
/public
10+
/docs
11+
.husky
12+
.local
13+
/bin
14+
.eslintrc.js
15+
prettier.config.js
16+
/src/mock/*
17+
coverage
18+
docs-html
19+
.github

.eslintrc.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
module.exports = {
2+
/* 优先级低于parse的语法解析配置 */
3+
parserOptions: {
4+
parser: '@typescript-eslint/parser',
5+
},
6+
extends: [
7+
'eslint:recommended',
8+
'plugin:@typescript-eslint/recommended', // typescript-eslint推荐规则
9+
'prettier',
10+
'plugin:prettier/recommended',
11+
],
12+
env: {
13+
browser: true,
14+
node: true,
15+
es6: true,
16+
},
17+
rules: {
18+
// 禁止使用 var
19+
'no-var': 'error',
20+
// 不使用结尾分号
21+
semi: 'off',
22+
'no-case-declarations': 'off',
23+
// 优先使用 interface 而不是 type
24+
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
25+
'@typescript-eslint/no-explicit-any': 'off',
26+
'@typescript-eslint/explicit-module-boundary-types': 'off',
27+
'@typescript-eslint/ban-types': 'off',
28+
'@typescript-eslint/no-unused-vars': 'error',
29+
'@typescript-eslint/no-this-alias': 'off',
30+
},
31+
overrides: [
32+
{
33+
files: ['**/__test__/**'],
34+
rules: {
35+
'@typescript-eslint/no-empty-function': 'off',
36+
},
37+
},
38+
{
39+
files: ['**/scripts/**.[jt]s', 'rollup.config.js'],
40+
rules: {
41+
'@typescript-eslint/no-var-requires': 'off',
42+
},
43+
},
44+
],
45+
};

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "npm" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "monthly"

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
pull_request:
8+
branches:
9+
- main
10+
permissions:
11+
contents: read # to fetch code (actions/checkout)
12+
jobs:
13+
linter:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Install pnpm
19+
uses: pnpm/action-setup@v2
20+
21+
- name: Set node version to 18
22+
uses: actions/setup-node@v3
23+
with:
24+
node-version: 18
25+
cache: 'pnpm'
26+
- run: pnpm install
27+
- run: npm run lint-check
28+
tests:
29+
needs: linter
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v3
33+
34+
- name: Install pnpm
35+
uses: pnpm/action-setup@v2
36+
37+
- name: Set node version to 18
38+
uses: actions/setup-node@v3
39+
with:
40+
node-version: 18
41+
cache: 'pnpm'
42+
- run: pnpm install
43+
- run: npm run test

.gitignore

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# TypeScript v1 declaration files
45+
typings/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
78+
# Next.js build output
79+
.next
80+
81+
# Nuxt.js build / generate output
82+
.nuxt
83+
dist
84+
85+
# Gatsby files
86+
.cache/
87+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88+
# https://nextjs.org/blog/next-9-1#public-directory-support
89+
# public
90+
91+
# vuepress build output
92+
.vuepress/dist
93+
94+
# Serverless directories
95+
.serverless/
96+
97+
# FuseBox cache
98+
.fusebox/
99+
100+
# DynamoDB Local files
101+
.dynamodb/
102+
103+
# TernJS port file
104+
.tern-port
105+
106+
.idea
107+
docs-html
108+
temp

.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

.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 --allow-empty

.prettierignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/dist/*
2+
.local
3+
.output.js
4+
/node_modules/**
5+
6+
**/*.svg
7+
**/*.sh
8+
9+
/public/*
10+
/types/*
11+
coverage
12+
docs-html
13+
.github

.prettierrc.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module.exports = {
2+
// 一行最多 100 字符
3+
printWidth: 100,
4+
// 使用 2 个空格缩进
5+
tabWidth: 2,
6+
// 不使用缩进符使用空格
7+
useTabs: false,
8+
// 行尾需要有分号
9+
semi: true,
10+
// 使用单引号
11+
singleQuote: true,
12+
// 对象的 key 仅在必要时用引号
13+
quoteProps: 'as-needed',
14+
// jsx 不使用单引号,而使用双引号
15+
jsxSingleQuote: false,
16+
// 尾随逗号
17+
trailingComma: 'all',
18+
// 大括号内的首尾需要空格
19+
bracketSpacing: true,
20+
// jsx 标签的反尖括号需要换行
21+
jsxBracketSameLine: false,
22+
// 箭头函数,只有一个参数的时候,也需要括号
23+
arrowParens: 'always',
24+
// 每个文件格式化的范围是文件的全部内容
25+
rangeStart: 0,
26+
rangeEnd: Infinity,
27+
// 不需要写文件开头的 @prettier
28+
requirePragma: false,
29+
// 不需要自动在文件开头插入 @prettier
30+
insertPragma: false,
31+
// 使用默认的折行标准
32+
proseWrap: 'preserve',
33+
// 根据显示样式决定 html 要不要折行
34+
htmlWhitespaceSensitivity: 'css',
35+
// 换行符使用 auto
36+
endOfLine: 'auto',
37+
}

CHANGELOG.md

Whitespace-only changes.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 mengxinssfd
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# lib-starter
2+
3+
npm 库初始启动模板,减少重建项时繁琐的操作
4+
5+
功能集成:
6+
7+
- pnpm
8+
- typescript
9+
- jest
10+
- eslint,prettier
11+
- commit lint
12+
- d.ts 打包
13+
- changelog
14+
- rollup
15+
- typedoc
16+
- monorepo
17+
- 添加子包脚本
18+
- 依据提示生成项目初始 package
19+
- 自动添加 src,**tests**目录
20+
- 自动添加到 typedoc
21+
- multirepo
22+
- github action
23+
- 合并、pr 检测
24+
- 依赖更新检测
25+
- 自动打包发布脚本
26+
- gh-pages 手动发布脚本
27+
28+
## 使用步骤
29+
30+
### 1.安装依赖
31+
32+
项目使用的 `pnpm` 作为包管理工具,如未安装 `pnpm` 的话需要安装 `pnpm`
33+
34+
```shell
35+
npm install -g pnpm
36+
```
37+
38+
然后
39+
40+
```shell
41+
pnpm install
42+
```
43+
44+
### 2.初始化项目
45+
46+
依赖安装完后会自动运行仓库初始化脚本,此时只要跟着提示填写或选择选项即可完成初始化仓库。
47+
48+
也可以中断初始化,在需要时使用
49+
50+
```shell
51+
npm run pkg:init
52+
```
53+
54+
命令初始化项目
55+
56+
monorepo 添加 child package
57+
58+
```shell
59+
npm run pkg:new
60+
```
61+
62+
### 3.更新`README.md`
63+
64+
### 4.清空[`CHANGELOG.md`](CHANGELOG.md)
65+
66+
### 5.更新[`LICENSE`](LICENSE)
67+
68+
[`package.json`](package.json)里面有`license`, 根目录下也有个文件[`LICENSE`](LICENSE)需要更新。

0 commit comments

Comments
 (0)