From 3f47b3e59a95b35a85a7b8347ba9eac39f5482e6 Mon Sep 17 00:00:00 2001 From: arvinxx Date: Sun, 21 May 2023 14:41:17 +0800 Subject: [PATCH] :tada: chore: init project --- .changelogrc.js | 5 ++ .commitlintrc.js | 3 + .dumirc.ts | 9 +++ .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/workflows/release.yml | 60 ++++++++++++++ .github/workflows/test.yml | 30 +++++++ .gitignore | 42 ++++++++++ .gitpod.yml | 3 + .husky/commit-msg | 4 + .husky/pre-commit | 4 + .idea/.gitignore | 5 ++ .npmrc | 2 + .prettierignore | 18 +++++ .prettierrc.js | 19 +++++ .releaserc.js | 3 + .stylelintrc.js | 10 +++ LICENSE | 21 +++++ README.md | 44 +++++++++++ docs/changelog.md | 8 ++ docs/index.md | 12 +++ package.json | 96 +++++++++++++++++++++++ src/index.ts | 3 + tests/index.test.ts | 5 ++ tests/test-setup.ts | 0 tsconfig-check.json | 6 ++ tsconfig.json | 19 +++++ vitest.config.ts | 14 ++++ 33 files changed, 576 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/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 .idea/.gitignore 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 LICENSE create mode 100644 README.md create mode 100644 docs/changelog.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 0000000..38b5c12 --- /dev/null +++ b/.changelogrc.js @@ -0,0 +1,5 @@ +// 详情配置查看 https://github.com/arvinxx/gitmoji-commit-workflow/tree/master/packages/changelog#readme +module.exports = { + displayTypes: ['feat', 'fix', 'styles', 'pref', 'build'], + titleLanguage: 'zh-CN', +}; diff --git a/.commitlintrc.js b/.commitlintrc.js new file mode 100644 index 0000000..ddd2139 --- /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 0000000..396ed85 --- /dev/null +++ b/.dumirc.ts @@ -0,0 +1,9 @@ +import { defineConfig } from 'dumi'; +import { homepage } from './package.json'; + +export default defineConfig({ + themeConfig: { + name: 'lobe-ui', + github: homepage, + }, +}); diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7e3649a --- /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 0000000..3bf41a8 --- /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 0000000..2109370 --- /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 0000000..5b4b50d --- /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 0000000..b1a768e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,46 @@ +--- +name: '报告Bug 🐛' +about: 报告 lobe-ui 的 bug +title: '🐛[BUG]' +labels: '🐛 BUG' +assignees: '' +--- + +### 🐛 bug 描述 + + + +### 📷 复现步骤 + + + +### 🏞 期望结果 + + + +### 💻 复现代码 + + + +[可复现 demo](https://codesandbox.io/s/html2ksetch-demo-m53be?file=/src/Demo.tsx) + +### © 版本信息 + +- lobe-ui 版本: [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 0000000..5be5065 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,25 @@ +--- +name: '功能需求 ✨' +about: 对 lobe-ui 的需求或建议 +title: '👑 [需求]' +labels: '👑 Feature' +assignees: '' +--- + +### 🥰 需求描述 + + + +### 🧐 解决方案 + + + +### 🚑 其他信息 + + diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..2653df8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,25 @@ +--- +name: '疑问或需要帮助 ❓' +about: 对 lobe-ui 使用的疑问或需要帮助 +title: '🧐[问题]' +labels: '🧐 Question' +assignees: '' +--- + +### 🧐 问题描述 + + + +### 💻 示例代码 + + + +### 🚑 其他信息 + + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bd3dab5 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,60 @@ +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: build + run: pnpm run build + + - 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 0000000..3edee65 --- /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 0000000..064cd73 --- /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 0000000..e605228 --- /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 0000000..c160a77 --- /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 0000000..cf0c46b --- /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/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..10b731c --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..89cfc9f --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +lockfile=false +resolution-mode=highest diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..b86a5bb --- /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 0000000..b70ecec --- /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 0000000..495d29b --- /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 0000000..bbd3844 --- /dev/null +++ b/.stylelintrc.js @@ -0,0 +1,10 @@ +module.exports = { + extends: ['stylelint-config-recommended', 'stylelint-config-clean-order'], + files: ['*.js', '*.jsx', '*.ts', '*.tsx'], + plugins: ['stylelint-order'], + customSyntax: 'postcss-styled-syntax', + rules: { + 'no-empty-source': null, + 'no-invalid-double-slash-comments': null, + }, +}; diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1dd53d2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 LobeHub + +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 0000000..be21e78 --- /dev/null +++ b/README.md @@ -0,0 +1,44 @@ +# lobe-ui + +[![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] + +[![ docs by dumi][dumi-url]](https://d.umijs.org/) [![Build With father][father-url]](https://github.com/umijs/father/) + + + +[gitpod-badge]: https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod +[gitpod-url]: https://gitpod.io/#https://github.com/ant-design/lobe-ui + + + +[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/lobe-ui.svg?style=flat-square&color=deepgreen&label=latest +[npm-url]: http://npmjs.org/package/lobe-ui +[npm-size]: https://img.shields.io/bundlephobia/minzip/lobe-ui?color=deepgreen&label=gizpped%20size&style=flat-square +[npm-size-url]: https://packagephobia.com/result?p=lobe-ui + + + +[coverage]: https://codecov.io/gh/lobehub/lobe-ui/branch/master/graph/badge.svg +[codecov-url]: https://codecov.io/gh/lobehub/lobe-ui/branch/master + + + +[test-ci]: https://github.com/lobehub/lobe-ui/workflows/Test%20CI/badge.svg +[release-ci]: https://github.com/lobehub/lobe-ui/workflows/Release%20CI/badge.svg +[test-ci-url]: https://github.com/lobehub/lobe-ui/actions?query=workflow%3ATest%20CI +[release-ci-url]: https://github.com/lobehub/lobe-ui/actions?query=workflow%3ARelease%20CI +[download-image]: https://img.shields.io/npm/dm/lobe-ui.svg?style=flat-square +[download-url]: https://npmjs.org/package/lobe-ui + +## 简介 + +## License + +[MIT](./LICENSE) diff --git a/docs/changelog.md b/docs/changelog.md new file mode 100644 index 0000000..05e5f1a --- /dev/null +++ b/docs/changelog.md @@ -0,0 +1,8 @@ +--- +title: 更新日志 +nav: + title: 更新日志 + order: 999 +--- + + diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000..376fe3d --- /dev/null +++ b/docs/index.md @@ -0,0 +1,12 @@ +--- +hero: + title: lobe-ui + description: a npm develop template + actions: + - text: 快速上手 + link: /guide + - text: 完全指南 + link: /usage +--- + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..d59cf05 --- /dev/null +++ b/package.json @@ -0,0 +1,96 @@ +{ + "name": "lobe-ui", + "version": "0.0.0", + "description": "ui kit for lobehub", + "keywords": [ + "npm", + "template" + ], + "homepage": "https://github.com/lobehub/lobe-ui", + "bugs": { + "url": "https://github.com/lobehub/lobe-ui/issues/new" + }, + "repository": { + "type": "git", + "url": "https://github.com/lobehub/lobe-ui.git" + }, + "license": "MIT", + "author": "LobeHubƒ", + "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", + "ci": "npm run lint && npm run type-check", + "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": "father doctor && npm run build", + "prettier": "prettier -c --write \"**/**\"", + "release": "semantic-release", + "setup": "dumi setup", + "start": "dumi dev", + "test": "vitest", + "test:coverage": "vitest run --coverage", + "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": "^13", + "@types/react": "^18", + "@types/react-dom": "^18", + "@umijs/lint": "^4", + "@vitest/coverage-c8": "latest", + "antd": "^5", + "commitlint": "^17", + "commitlint-config-gitmoji": "^2", + "concurrently": "^7", + "cross-env": "^7", + "dumi": "^2", + "dumi-theme-antd-style": "latest", + "eslint": "^8", + "eslint-import-resolver-alias": "^1", + "eslint-import-resolver-typescript": "^2", + "father": "^4", + "husky": "^8", + "jsdom": "^21.1.1", + "lint-staged": "^13", + "prettier": "^2", + "prettier-plugin-organize-imports": "^3", + "prettier-plugin-packagejson": "^2", + "react": "^18", + "react-dom": "^18", + "semantic-release": "^20", + "semantic-release-config-gitmoji": "^1", + "stylelint": "^14", + "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 0000000..6a7a2cb --- /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 0000000..a6924f6 --- /dev/null +++ b/tests/index.test.ts @@ -0,0 +1,5 @@ +import { hello } from 'lobe-ui'; + +test('hello', () => { + expect(hello()).toBe('world'); +}); diff --git a/tests/test-setup.ts b/tests/test-setup.ts new file mode 100644 index 0000000..e69de29 diff --git a/tsconfig-check.json b/tsconfig-check.json new file mode 100644 index 0000000..9f910a2 --- /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 0000000..28bb204 --- /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"], + "lobe-ui": ["src"], + "lobe-ui/*": ["src/*", "*"] + } + } +} diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..542f524 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,14 @@ +import { defineConfig } from 'vitest/config'; +import { name } from './package.json'; + +export default defineConfig({ + test: { + setupFiles: './tests/test-setup.ts', + environment: 'jsdom', + globals: true, + alias: { + '@': './src', + [name]: './src', + }, + }, +});