From d4b8d323e8686745c54fd4982c7fa9ddb72abe64 Mon Sep 17 00:00:00 2001 From: Arvin Xu Date: Fri, 20 Oct 2023 11:39:49 +0800 Subject: [PATCH] Initial commit --- .changelogrc.js | 11 + .commitlintrc.js | 3 + .dumirc.ts | 10 + .editorconfig | 16 + .eslintignore | 12 + .eslintrc.js | 1 + .fatherrc.ts | 6 + .github/ISSUE_TEMPLATE/bug_report.md | 46 ++ .github/ISSUE_TEMPLATE/feature_request.md | 25 + .github/ISSUE_TEMPLATE/question.md | 25 + .github/PULL_REQUEST_TEMPLATE.md | 17 + .github/workflows/contributor-help.yml | 28 ++ .github/workflows/release.yml | 57 +++ .github/workflows/test.yml | 30 ++ .gitignore | 42 ++ .gitpod.yml | 3 + .husky/commit-msg | 4 + .husky/pre-commit | 4 + .npmrc | 2 + .prettierignore | 18 + .prettierrc.js | 19 + .releaserc.js | 3 + .stylelintrc.js | 1 + CHANGELOG.md | 578 ++++++++++++++++++++++ LICENSE | 21 + README.md | 141 ++++++ docs/changelog.md | 8 + docs/guide.md | 13 + docs/index.md | 21 + package.json | 95 ++++ src/index.ts | 3 + tests/index.test.ts | 5 + tests/test-setup.ts | 0 tsconfig-check.json | 6 + tsconfig.json | 19 + vitest.config.ts | 20 + 36 files changed, 1313 insertions(+) create mode 100644 .changelogrc.js create mode 100644 .commitlintrc.js create mode 100644 .dumirc.ts create mode 100644 .editorconfig create mode 100644 .eslintignore create mode 100644 .eslintrc.js create mode 100644 .fatherrc.ts create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/question.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/contributor-help.yml create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore create mode 100644 .gitpod.yml create mode 100755 .husky/commit-msg create mode 100755 .husky/pre-commit create mode 100644 .npmrc create mode 100644 .prettierignore create mode 100644 .prettierrc.js create mode 100644 .releaserc.js create mode 100644 .stylelintrc.js create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 docs/changelog.md create mode 100644 docs/guide.md create mode 100644 docs/index.md create mode 100644 package.json create mode 100644 src/index.ts create mode 100644 tests/index.test.ts create mode 100644 tests/test-setup.ts create mode 100644 tsconfig-check.json create mode 100644 tsconfig.json create mode 100644 vitest.config.ts diff --git a/.changelogrc.js b/.changelogrc.js new file mode 100644 index 00000000..b4645b77 --- /dev/null +++ b/.changelogrc.js @@ -0,0 +1,11 @@ +// 详情配置查看 https://github.com/arvinxx/gitmoji-commit-workflow/tree/master/packages/changelog#readme +module.exports = { + displayTypes: ['feat', 'fix', 'styles', 'pref', 'build'], + titleLanguage: 'zh-CN', + showAuthor: true, + showAuthorAvatar: true, + showSummary: true, + reduceHeadingLevel: true, + newlineTimestamp: true, + addBackToTop: true, +}; diff --git a/.commitlintrc.js b/.commitlintrc.js new file mode 100644 index 00000000..ddd2139c --- /dev/null +++ b/.commitlintrc.js @@ -0,0 +1,3 @@ +module.exports = { + extends: ['gitmoji'], +}; diff --git a/.dumirc.ts b/.dumirc.ts new file mode 100644 index 00000000..bc3991d9 --- /dev/null +++ b/.dumirc.ts @@ -0,0 +1,10 @@ +import { defineConfig } from 'dumi'; +import { homepage } from './package.json'; + +export default defineConfig({ + themeConfig: { + name: '@arvinxu/npm-template', + github: homepage, + }, + html2sketch: {}, +}); diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..7e3649ac --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# http://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false + +[Makefile] +indent_style = tab diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000..3bf41a80 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,12 @@ +/lambda/mock/** +/scripts +/config +/example +_test_ +__test__ + +/node_modules +jest* +/es +/lib +/docs diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..21093703 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1 @@ +module.exports = require('@umijs/lint/dist/config/eslint'); diff --git a/.fatherrc.ts b/.fatherrc.ts new file mode 100644 index 00000000..5b4b50db --- /dev/null +++ b/.fatherrc.ts @@ -0,0 +1,6 @@ +import { defineConfig } from 'father'; + +export default defineConfig({ + cjs: { output: 'lib' }, + esm: { output: 'es' }, +}); diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..81607460 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,46 @@ +--- +name: '报告Bug 🐛' +about: 报告 @arvinxu/npm-template 的 bug +title: '🐛[BUG]' +labels: '🐛 BUG' +assignees: '' +--- + +### 🐛 bug 描述 + + + +### 📷 复现步骤 + + + +### 🏞 期望结果 + + + +### 💻 复现代码 + + + +[可复现 demo](https://codesandbox.io/s/html2ksetch-demo-m53be?file=/src/Demo.tsx) + +### © 版本信息 + +- @arvinxu/npm-template 版本: [e.g. 1.0.0] +- 浏览器环境 +- 开发环境 [e.g. mac OS] + +### 🚑 其他信息 + + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..2a7d46d1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,25 @@ +--- +name: '功能需求 ✨' +about: 对 @arvinxu/npm-template 的需求或建议 +title: '👑 [需求]' +labels: '👑 Feature' +assignees: '' +--- + +### 🥰 需求描述 + + + +### 🧐 解决方案 + + + +### 🚑 其他信息 + + diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 00000000..d68d805b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,25 @@ +--- +name: '疑问或需要帮助 ❓' +about: 对 @arvinxu/npm-template 使用的疑问或需要帮助 +title: '🧐[问题]' +labels: '🧐 Question' +assignees: '' +--- + +### 🧐 问题描述 + + + +### 💻 示例代码 + + + +### 🚑 其他信息 + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..a73b6cf8 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,17 @@ +#### 💻 变更类型 | Change Type + + + +- \[ ] ✨ feat +- \[ ] 🐛 fix +- \[ ] 💄 style +- \[ ] 🔨 chore +- \[ ] 📝 docs + +#### 🔀 变更说明 | Description of Change + + + +#### 📝 补充信息 | Additional Information + + diff --git a/.github/workflows/contributor-help.yml b/.github/workflows/contributor-help.yml new file mode 100644 index 00000000..a5d7f119 --- /dev/null +++ b/.github/workflows/contributor-help.yml @@ -0,0 +1,28 @@ +name: Contributor Helper + +on: + schedule: + - cron: '0 0 * * *' + +jobs: + contributor: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + + - uses: actions-cool/contributor-helper@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + style: 'simple' + update-files: 'README.md' + update-places: '/' + + - name: Commit and push if changed + run: |- + git diff + git config --global user.email "actions@github.com" + git config --global user.name "github-actions" + git pull + git add -A + git commit -m "🤖 docs: Auto update contributors" || exit 0 + git push diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..91abe2c5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,57 @@ +name: Release CI +on: + push: + branches: + - master + - alpha + - beta + - rc + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Install deps + run: pnpm install + + - name: Test + run: pnpm run test + + release: + needs: test + name: Release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Install deps + run: pnpm install + + - name: release + run: pnpm run release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..3edee65b --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,30 @@ +name: Test CI +on: [push, pull_request] +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Setup Node.js environment + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Install deps + run: pnpm install + + - name: lint + run: pnpm run ci + + - name: Test and coverage + run: pnpm run test:coverage + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..064cd739 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +**/node_modules +# roadhog-api-doc ignore +/src/utils/request-temp.js +_roadhog-api-doc + +# production +**/dist +/.vscode +/es +/lib + +# misc +.DS_Store +storybook-static +npm-debug.log* +yarn-error.log + +/coverage +.idea +package-lock.json +*bak +.vscode + +# visual studio code +.history +*.log +functions/* +lambda/mock/index.js +.temp/** + +# umi +.dumi/tmp* + +# screenshot +screenshot +.firebase +example/.temp/* +.eslintcache +techUI* diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 00000000..e6052280 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,3 @@ +tasks: + - init: pnpm install + command: pnpm run start diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 00000000..c160a771 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx --no -- commitlint --edit ${1} diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 00000000..cf0c46b9 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx --no-install lint-staged diff --git a/.npmrc b/.npmrc new file mode 100644 index 00000000..89cfc9f9 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +lockfile=false +resolution-mode=highest diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..b86a5bbc --- /dev/null +++ b/.prettierignore @@ -0,0 +1,18 @@ +**/*.svg +.umi +.umi-production +/dist +.dockerignore +.DS_Store +.eslintignore +*.png +*.toml +docker +.editorconfig +Dockerfile* +.gitignore +.prettierignore +LICENSE +.eslintcache +*.lock +yarn-error.log diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 00000000..b70ecec9 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1,19 @@ +module.exports = { + pluginSearchDirs: false, + plugins: [ + require.resolve('prettier-plugin-organize-imports'), + require.resolve('prettier-plugin-packagejson'), + ], + printWidth: 100, + proseWrap: 'never', + singleQuote: true, + trailingComma: 'all', + overrides: [ + { + files: '*.md', + options: { + proseWrap: 'preserve', + }, + }, + ], +}; diff --git a/.releaserc.js b/.releaserc.js new file mode 100644 index 00000000..495d29bb --- /dev/null +++ b/.releaserc.js @@ -0,0 +1,3 @@ +module.exports = { + extends: ['semantic-release-config-gitmoji'], +}; diff --git a/.stylelintrc.js b/.stylelintrc.js new file mode 100644 index 00000000..0e38f7cd --- /dev/null +++ b/.stylelintrc.js @@ -0,0 +1 @@ +module.exports = require('@umijs/lint/dist/config/stylelint'); diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..1c907cc2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,578 @@ +# Changelog + +### [Version 1.11.1](https://github.com/arvinxx/npm-template/compare/v1.11.0...v1.11.1) + +Released on **2023-06-12** + +#### 🐛 修复 + +- 更新 CHANGELOG 格式到最新. + +
+ +
+Improvements and Fixes + +#### What's fixed + +- 更新 CHANGELOG 格式到最新 ([050dc64](https://github.com/arvinxx/npm-template/commit/050dc64)) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +## Version 1.11.0 + +Released on **2023-06-12** + +#### ✨ 新特性 + +- Upgrade changelog configuration. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's improved + +- Upgrade changelog configuration ([cac6de6](https://github.com/arvinxx/npm-template/commit/cac6de6)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +## Version 1.10.0 + +Released on **2023-06-10** + +#### ✨ 新特性 + +- **readme**: Update README formatting and content. +- Add contributor-helper workflow and PR template. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's improved + +- **readme**: Update README formatting and content ([de92198](https://github.com/arvinxx/npm-template/commit/de92198)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) +- Add contributor-helper workflow and PR template ([15ac439](https://github.com/arvinxx/npm-template/commit/15ac439)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +### Version 1.9.1 + +Released on **2023-06-10** + +#### 🐛 修复 + +- Update release workflow. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's fixed + +- Update release workflow ([41d342d](https://github.com/arvinxx/npm-template/commit/41d342d)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +## Version 1.9.0 + +Released on **2023-06-10** + +#### ✨ 新特性 + +- 升级 changelog 配置. + +#### 🐛 修复 + +- 兼容最新的 vitest v8 provider. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's improved + +- 升级 changelog 配置 ([37562fa](https://github.com/arvinxx/npm-template/commit/37562fa)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +#### What's fixed + +- 兼容最新的 vitest v8 provider ([e29309e](https://github.com/arvinxx/npm-template/commit/e29309e)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +## Version 1.8.0 + +Released on **2023-05-23** + +#### ✨ 新特性 + +- 升级基础依赖,并开启, 默认开启 html2sketch 配置. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's improved + +- 升级基础依赖,并开启 ([63bad90](https://github.com/arvinxx/npm-template/commit/63bad90)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) +- 默认开启 html2sketch 配置 ([10fb123](https://github.com/arvinxx/npm-template/commit/10fb123)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +## Version 1.7.0 + +Released on **2023-04-09** + +#### ✨ 新特性 + +- 迁移测试框架到 vitest. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's improved + +- 迁移测试框架到 vitest ([5a0e7f7](https://github.com/arvinxx/npm-template/commit/5a0e7f7)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +## Version 1.6.0 + +Released on **2023-02-15** + +#### ✨ 新特性 + +- 内置 dumi-theme-antd-style 主题包. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's improved + +- 内置 dumi-theme-antd-style 主题包 ([de4b5a0](https://github.com/arvinxx/npm-template/commit/de4b5a0)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +## Version 1.5.0 + +Released on **2023-02-09** + +#### ✨ 新特性 + +- 升级 semantic-release 版本. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's improved + +- 升级 semantic-release 版本 ([31e1495](https://github.com/arvinxx/npm-template/commit/31e1495)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +## Version 1.4.0 + +Released on **2023-01-06** + +#### ✨ 新特性 + +- 优化默认配置. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's improved + +- 优化默认配置 ([16b8275](https://github.com/arvinxx/npm-template/commit/16b8275)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +### Version 1.3.1 + +Released on **2023-01-06** + +
+ +
+Improvements and Fixes + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +## Version 1.3.0 + +Released on **2023-01-06** + +#### ✨ 新特性 + +- 支持 alpha beta rc 频道的发版. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's improved + +- 支持 alpha beta rc 频道的发版 ([0cfe840](https://github.com/arvinxx/npm-template/commit/0cfe840)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +### Version 1.2.4 + +Released on **2023-01-01** + +#### 🐛 修复 + +- 修正 jest 测试配置问题. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's fixed + +- 修正 jest 测试配置问题 ([ed8a6e4](https://github.com/arvinxx/npm-template/commit/ed8a6e4)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +### Version 1.2.3 + +Released on **2023-01-01** + +#### 🐛 修复 + +- 修正 ISSUE TEMPLATE 中的包名问题. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's fixed + +- 修正 ISSUE TEMPLATE 中的包名问题 ([e64da9a](https://github.com/arvinxx/npm-template/commit/e64da9a)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +### Version 1.2.2 + +Released on **2023-01-01** + +#### 🐛 修复 + +- 修正 commitlint 指令. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's fixed + +- 修正 commitlint 指令 ([f2b380b](https://github.com/arvinxx/npm-template/commit/f2b380b)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +### Version 1.2.1 + +Released on **2022-12-17** + +#### 🐛 修复 + +- 补充 react 类型依赖. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's fixed + +- 补充 react 类型依赖 ([c8723ad](https://github.com/arvinxx/npm-template/commit/c8723ad)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +## Version 1.2.0 + +Released on **2022-12-17** + +#### ✨ 新特性 + +- 补充测试与文档. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's improved + +- 补充测试与文档 ([15068b4](https://github.com/arvinxx/npm-template/commit/15068b4)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +### Version 1.1.2 + +Released on **2022-12-17** + +#### 🐛 修复 + +- 修正无法上传到 npm 的问题. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's fixed + +- 修正无法上传到 npm 的问题 ([e2c609d](https://github.com/arvinxx/npm-template/commit/e2c609d)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +### Version 1.1.1 + +Released on **2022-12-17** + +#### 👷 构建系统 + +- 构建. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### Build system + +- 构建 ([cc9dbb5](https://github.com/arvinxx/npm-template/commit/cc9dbb5)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +## Version 1.1.0 + +Released on **2022-12-17** + +#### ✨ 新特性 + +- 使用 Vercel 部署预览. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's improved + +- 使用 Vercel 部署预览 ([f423074](https://github.com/arvinxx/npm-template/commit/f423074)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
+ +## Version 1.0.0 + +Released on **2022-12-17** + +#### ✨ 新特性 + +- Add ci release workflow, add release ci, update test config, 优化 lint 的执行范围. + +#### 🐛 修复 + +- Fix test ci. + +
+ +[](https://api.github.com/users/arvinxx) + +
+Improvements and Fixes + +#### What's improved + +- Add ci release workflow ([0e7600e](https://github.com/arvinxx/npm-template/commit/0e7600e)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) +- Add release ci ([31f950a](https://github.com/arvinxx/npm-template/commit/31f950a)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) +- Update test config ([c11a3d9](https://github.com/arvinxx/npm-template/commit/c11a3d9)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) +- 优化 lint 的执行范围 ([c1dc5d3](https://github.com/arvinxx/npm-template/commit/c1dc5d3)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +#### What's fixed + +- Fix test ci ([78f4e92](https://github.com/arvinxx/npm-template/commit/78f4e92)) - by [ **arvinxx**](https://api.github.com/users/arvinxx) + +
+ +
+ +[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top) + +
diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..f4a1f161 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 Arvin Xu + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 00000000..177b1612 --- /dev/null +++ b/README.md @@ -0,0 +1,141 @@ + + +
+ +[//]: # '' + +

@arvinxu/npm-template

+ +一个开发 npm 项目的模板 + +[Changelog](./CHANGELOG.md) · [Report Bug][issues-url] · [Request Feature][issues-url] + + + +[![NPM version][npm-image]][npm-url] [![NPM downloads][download-image]][download-url] [![install size][npm-size]][npm-size-url] + +[![Test CI status][test-ci]][test-ci-url] [![Deploy CI][release-ci]][release-ci-url] [![Coverage][coverage]][codecov-url] + +[![contributors][contributors-shield]][contributors-url] [![forks][forks-shield]][forks-url] [![stargazers][stargazers-shield]][stargazers-url] [![issues][issues-shield]][issues-url] + +[![ docs by dumi][dumi-url]](https://d.umijs.org/) [![Build With father][father-url]](https://github.com/umijs/father/) + +![](https://github.com/othneildrew/Best-README-Template/raw/master/images/screenshot.png) + + + +[gitpod-badge]: https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod +[gitpod-url]: https://gitpod.io/#https://github.com/ant-design/@arvinxu/npm-template + + + +[dumi-url]: https://img.shields.io/badge/docs%20by-dumi-blue +[father-url]: https://img.shields.io/badge/build%20with-father-028fe4.svg + + + +[npm-image]: http://img.shields.io/npm/v/@arvinxu/npm-template.svg?style=flat-square&color=deepgreen&label=latest +[npm-url]: http://npmjs.org/package/@arvinxu/npm-template +[npm-size]: https://img.shields.io/bundlephobia/minzip/@arvinxu/npm-template?color=deepgreen&label=gizpped%20size&style=flat-square +[npm-size-url]: https://packagephobia.com/result?p=@arvinxu/npm-template + + + +[coverage]: https://codecov.io/gh/arvinxx/npm-template/branch/master/graph/badge.svg +[codecov-url]: https://codecov.io/gh/arvinxx/npm-template/branch/master + + + +[test-ci]: https://github.com/arvinxx/npm-template/workflows/Test%20CI/badge.svg +[release-ci]: https://github.com/arvinxx/npm-template/workflows/Release%20CI/badge.svg +[test-ci-url]: https://github.com/arvinxx/npm-template/actions?query=workflow%3ATest%20CI +[release-ci-url]: https://github.com/arvinxx/npm-template/actions?query=workflow%3ARelease%20CI +[download-image]: https://img.shields.io/npm/dm/@arvinxu/npm-template.svg?style=flat-square +[download-url]: https://npmjs.org/package/@arvinxu/npm-template + +
+ +## 简介 + +这是一个开发 npm 项目的模板,具有以下特点: + +- 🏗️ **基于 father4 的构建工具**:本项目采用了基于 father4 的构建工具,可以更高效地构建项目,提高开发效率; +- 📖 **基于 dumi2 的文档工具**:本项目采用了基于 dumi2 的文档工具,可以更方便地编写和管理文档,提高文档的可读性和可维护性; +- 🚀 **基于 vercel 自动化触发文档站构建**:本项目使用 vercel 自动化触发文档站构建,可以更快地更新文档站,提高用户的使用体验; +- 📦 **基于 semantic-release 实现 npm 包的自动化发布**:本项目使用 semantic-release 实现 npm 包的自动化发布,可以更方便地管理和发布 npm 包,提高开发效率。 + +## 快速上手 + +### 安装 + +推荐使用 `pnpm` 安装 + +```bash +pnpm i @arvinxu/npm-template -S +``` + +### 使用 + +基于该仓库模板可以快速创建一个 npm 包的工程化脚手架。 + +## 迭代记录 + +2023.06.12 - 完善文档与 README 框架 + +2022.12.17 - 基于蚂蚁研发技术栈配置完成最新的 npm 研发脚手架 + +详情:[CHANGELOG](./CHANGELOG.md) + +## 🤝 Contributing + + + +> 📊 Total: **2** + + + + + + + + + + +
+ +[![][back-to-top]](#readme-top) + +##
+ +#### 📝 License + +Copyright © 2020 - present [Arvin Xu][profile-url].
+This project is [MIT](./LICENSE) licensed. + + + +[profile-url]: https://github.com/arvinxx + + + +[back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square + + + +[contributors-shield]: https://img.shields.io/github/contributors/arvinxx/npm-template.svg?style=flat +[contributors-url]: https://github.com/arvinxx/npm-template/graphs/contributors + + + +[forks-shield]: https://img.shields.io/github/forks/arvinxx/npm-template.svg?style=flat +[forks-url]: https://github.com/arvinxx/npm-template/network/members + + + +[stargazers-shield]: https://img.shields.io/github/stars/arvinxx/npm-template.svg?style=flat +[stargazers-url]: https://github.com/arvinxx/npm-template/stargazers + + + +[issues-shield]: https://img.shields.io/github/issues/arvinxx/npm-template.svg?style=flat +[issues-url]: https://github.com/arvinxx/npm-template/issues/new/choose diff --git a/docs/changelog.md b/docs/changelog.md new file mode 100644 index 00000000..05e5f1a3 --- /dev/null +++ b/docs/changelog.md @@ -0,0 +1,8 @@ +--- +title: 更新日志 +nav: + title: 更新日志 + order: 999 +--- + + diff --git a/docs/guide.md b/docs/guide.md new file mode 100644 index 00000000..f9d85893 --- /dev/null +++ b/docs/guide.md @@ -0,0 +1,13 @@ +--- +title: 使用介绍 +--- + +## Step1. 使用该模板创建一个新的仓库 + +点击右上角 `use this template` -> `create a new reposity` 按钮,创建一个新的仓库。 + +## Step2. 初始化项目信息 + +使用编辑器全局替换 `@arvinxu/npm-template` 为你的包名(例如 `antd-style`),执行 `pnpm i` 安装依赖。 + +## Step3. 开始开发 diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..97fbe3ec --- /dev/null +++ b/docs/index.md @@ -0,0 +1,21 @@ +--- +hero: + title: @arvinxu/npm-template + description: a npm develop template + actions: + - text: 快速上手 + link: /guide + - text: Github + link: /usage +--- + + + +工程框架选型如下: + +- 构建: father4 +- 文档: dumi2 +- CI: Github Action +- CD: + - 文档发布: 使用 vercel 自动化触发文档站构建; + - npm 发布: 使用 `semantic-release` 实现 npm 包的自动化发布; diff --git a/package.json b/package.json new file mode 100644 index 00000000..e505ebf3 --- /dev/null +++ b/package.json @@ -0,0 +1,95 @@ +{ + "name": "@arvinxu/npm-template", + "version": "1.11.1", + "description": "a npm develop template", + "keywords": [ + "npm", + "template" + ], + "homepage": "https://github.com/arvinxx/npm-template", + "bugs": { + "url": "https://github.com/arvinxx/npm-template/issues/new" + }, + "repository": { + "type": "git", + "url": "https://github.com/arvinxx/npm-template.git" + }, + "license": "MIT", + "author": "arvinxx(arvinx@foxmail.com)", + "sideEffects": false, + "main": "lib/index.js", + "module": "es/index.js", + "types": "lib/index.d.ts", + "files": [ + "lib", + "es" + ], + "scripts": { + "build": "father build", + "build:watch": "father dev", + "changelog": "conventional-changelog -n node_modules/conventional-changelog-gitmoji-config -i CHANGELOG.md -s -r 0", + "ci": "npm run lint && npm run type-check && npm run doctor && npm run build", + "clean": "rm -rf es lib dist coverage .dumi/tmp .eslintcache", + "dev": "dumi dev", + "docs:build": "dumi build", + "doctor": "father doctor", + "lint": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"", + "prepare": "husky install && npm run setup", + "prepublishOnly": "npm run doctor && npm run build", + "prettier": "prettier -c --write \"**/**\"", + "release": "semantic-release", + "setup": "dumi setup", + "start": "dumi dev", + "test": "vitest --passWithNoTests", + "test:coverage": "vitest run --coverage --passWithNoTests", + "test:update": "vitest -u", + "type-check": "tsc -p tsconfig-check.json" + }, + "lint-staged": { + "*.{md,json}": [ + "prettier --write --no-error-on-unmatched-pattern" + ], + "*.{js,jsx}": [ + "eslint --fix", + "prettier --write" + ], + "*.{ts,tsx}": [ + "eslint --fix", + "prettier --parser=typescript --write" + ] + }, + "devDependencies": { + "@commitlint/cli": "^17", + "@testing-library/react": "^14", + "@types/react": "^18", + "@types/react-dom": "^18", + "@umijs/lint": "^4", + "@vitest/coverage-v8": "latest", + "commitlint": "^17", + "commitlint-config-gitmoji": "^2", + "concurrently": "^7", + "conventional-changelog-gitmoji-config": "^1", + "cross-env": "^7", + "dumi": "^2", + "dumi-theme-antd-style": "latest", + "eslint": "^8", + "father": "^4", + "husky": "^8", + "jsdom": "^22", + "lint-staged": "^13", + "prettier": "^2", + "prettier-plugin-organize-imports": "^3", + "prettier-plugin-packagejson": "^2", + "react": "^18", + "react-dom": "^18", + "semantic-release": "^21", + "semantic-release-config-gitmoji": "^1", + "stylelint": "^15", + "typescript": "^5", + "vitest": "latest" + }, + "publishConfig": { + "access": "public", + "registry": "https://registry.npmjs.org" + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 00000000..6a7a2cb5 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,3 @@ +export const hello = () => { + return 'world'; +}; diff --git a/tests/index.test.ts b/tests/index.test.ts new file mode 100644 index 00000000..16b4e8bb --- /dev/null +++ b/tests/index.test.ts @@ -0,0 +1,5 @@ +import { hello } from '@arvinxu/npm-template'; + +test('hello', () => { + expect(hello()).toBe('world'); +}); diff --git a/tests/test-setup.ts b/tests/test-setup.ts new file mode 100644 index 00000000..e69de29b diff --git a/tsconfig-check.json b/tsconfig-check.json new file mode 100644 index 00000000..9f910a24 --- /dev/null +++ b/tsconfig-check.json @@ -0,0 +1,6 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "noEmit": true + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..6660a2f7 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,19 @@ +{ + "include": ["src", "tests", ".dumi/**/*", ".dumirc.ts", "*.ts"], + "compilerOptions": { + "strict": true, + "declaration": true, + "skipLibCheck": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "jsx": "react-jsx", + "baseUrl": ".", + "types": ["vitest/globals"], + "paths": { + "@@/*": [".dumi/tmp/*"], + "@/*": ["src"], + "@arvinxu/npm-template": ["src"], + "@arvinxu/npm-template/*": ["src/*", "*"] + } + } +} diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 00000000..4be08583 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,20 @@ +import { defineConfig } from 'vitest/config'; +import { name } from './package.json'; + +export default defineConfig({ + esbuild: { + jsxInject: "import React from 'react'", + }, + test: { + setupFiles: './tests/test-setup.ts', + environment: 'jsdom', + globals: true, + alias: { + '@': './src', + [name]: './src', + }, + coverage: { + reporter: ['text', 'text-summary', 'json', 'lcov'], + }, + }, +});