Skip to content

Commit

Permalink
feat(项目初始化架构): 初次创建工程,使用lerna yarn workspace eslint prettierrc ink gi…
Browse files Browse the repository at this point in the history
…t 构建 @muniz/cli 脚手架。

affects: @muniz/cli, @muniz/muniz-plugin-i18n

lerna 采用整体发布模式
结合 yarn workspace, 把公用module 抽离到顶层(yarn 工程目录)
eslint校验代码,由于使用了ink 开启了react 校验, 继承
airbnb 规范
ink react 开发命令行UI工具
  • Loading branch information
1160007652 committed Sep 19, 2020
1 parent feab716 commit f460faf
Show file tree
Hide file tree
Showing 23 changed files with 371 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# http://editorconfig.org
# editorconfig 可以让编辑器格式化的风格一致
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
Empty file added .eslintignore
Empty file.
37 changes: 37 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const path = require('path');

module.exports = {
env: {
browser: true,
es2020: true,
node: true,
},
extends: ['plugin:react/recommended', 'airbnb', 'airbnb/hooks', 'prettier', 'prettier/react'],
parser: 'babel-eslint',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 11,
sourceType: 'module',
},
plugins: ['react'],
rules: {
'react/button-has-type': 'never',
'react/prop-types': 'never',
'react/sort-comp': 'never',
'import/extensions': 'never',
'react/jsx-filename-extension': [1, { extensions: ['.js'] }],
// 取消 .d.ts 声明文件中使用了 constructor 报错 问题
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
},
overrides: [
{
files: ['**/*.d.ts'],
rules: {
'import/no-duplicates': 0,
},
},
],
};
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
yarn.lock
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 特定npm库的映射
# SASS_BINARY_SITE=http://npm.taobao.org/mirrors/node-sass
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v13.6.0
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"jsxSingleQuote": false,
"trailingComma": "all",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "always"
}
9 changes: 9 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"recommendations": [
"editorconfig.editorconfig",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"dsznajder.es7-react-js-snippets"
],
"unwantedRecommendations": ["hookyqr.beautify", "dbaeumer.jshint"]
}
76 changes: 76 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
// stylelint 扩展自身的校验就够了
"css.validate": false,
"less.validate": false,
"scss.validate": false,
"json.schemas": [],
// eslint 保存自动格式化
"eslint.format.enable": true,
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
// 格式化css
"source.fixAll.stylelint": true
},
"eslint.codeAction.showDocumentation": {
"enable": true
},
"eslint.codeAction.disableRuleComment": {
"enable": true
},
// 指定哪些文件不参与搜索
"search.exclude": {
"**/node_modules": true,
"dist": true,
"out": true,
"next-build": true,
"yarn.lock": true,
"package-lock": true
},
// 指定哪些文件不被 VSCode 监听,预防启动 VSCode 时扫描的文件太多,导致 CPU 占用过高
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true,
"**/dist/**": true,
"**/next-build/**": true,
"**/out/**": true,
"**/.next/**": true
},
// 配置 VScode 使用 prettier 的 formatter
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[less]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
## @muniz/cli

Muniz 脚手架, 是一个基于插件机制模型设计的, 由多个插件组合而成。

### 项目框架

#### Lerna

- 采用 workspace 模型
- 结合 yarn - workspace 管理 node_modules

#### Eslint

- 使用 Eslint 进行代码规范校验
- 继承 于 airbnb 规范

#### Prettierrc

- 使用 Prettierrc 进行代码本地、提交时的格式校验
- 与 Eslint 冲突的解决

#### Commitlint

- 进行 Github 代码提交 Commit 校验
- husky 、 lint-staged

#### ink

- React 开发命令行库

#### meow

- 命令行解释器

### 发布

### 提交

### 测试

### 文档
3 changes: 3 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
};
8 changes: 8 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"allowSyntheticDefaultImports": false,
"baseUrl": "./"
},
"exclude": ["node_modules"]
}
14 changes: 14 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "0.0.0",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": ["packages/@muniz/cli*", "packages/@muniz/muniz-plugin*"],
"command": {
"publish": {
"ignoreChanges": ["ignored-file", "*.md"]
},
"bootstrap": {
"hoist": true
}
}
}
52 changes: 52 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "root",
"private": true,
"workspaces": [
"packages/@muniz/cli*",
"packages/@muniz/muniz-plugin*"
],
"scripts": {
"commit": "git-cz"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-lerna-changelog"
}
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"lint-staged": {
"*.{js}": [
"eslint -c .eslintrc.js"
],
"*.{js,json,yml,md}": [
"prettier --write"
]
},
"devDependencies": {
"@commitlint/cli": "^11.0.0",
"@commitlint/config-conventional": "^11.0.0",
"commitizen": "^4.2.1",
"cz-lerna-changelog": "^2.0.3",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.20.5",
"eslint-plugin-react-hooks": "^4.0.8",
"husky": "^4.3.0",
"lerna": "^3.22.1",
"lint-staged": "^10.4.0",
"prettier": "^2.1.2",
"standard": "^14.3.4"
},
"publishConfig": {
"access": "public"
}
}
11 changes: 11 additions & 0 deletions packages/@muniz/cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `@muniz/cli`

> TODO: description
## Usage

```
const cli = require('@muniz/cli');
// TODO: DEMONSTRATE API
```
7 changes: 7 additions & 0 deletions packages/@muniz/cli/__tests__/cli.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

const cli = require('..');

describe('@muniz/cli', () => {
it('needs tests');
});
1 change: 1 addition & 0 deletions packages/@muniz/cli/bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('cli - new cli');
8 changes: 8 additions & 0 deletions packages/@muniz/cli/lib/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

module.exports = cli;

function cli() {
// TODO
console.log('sss');
}
26 changes: 26 additions & 0 deletions packages/@muniz/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "@muniz/cli",
"version": "0.0.0",
"description": "muniz脚手架,核心插件,命令行工具,可扩展插件模型",
"bin": "./bin/cli.js",
"keywords": [
"@muniz/cli"
],
"author": "1160007652 <[email protected]>",
"homepage": "",
"license": "ISC",
"main": "lib/cli.js",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1"
}
}
11 changes: 11 additions & 0 deletions packages/@muniz/muniz-plugin-i18n/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# `@muniz/muniz-plugin-i18n`

> TODO: description
## Usage

```
const munizPluginI18N = require('@muniz/muniz-plugin-i18n');
// TODO: DEMONSTRATE API
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

const munizPluginI18N = require('..');

describe('@muniz/muniz-plugin-i18n', () => {
it('needs tests');
});
7 changes: 7 additions & 0 deletions packages/@muniz/muniz-plugin-i18n/lib/muniz-plugin-i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = munizPluginI18N;

function munizPluginI18N() {
// TODO
}
22 changes: 22 additions & 0 deletions packages/@muniz/muniz-plugin-i18n/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@muniz/muniz-plugin-i18n",
"version": "0.0.0",
"description": "@muniz/cli 多语言模块",
"author": "1160007652 <[email protected]>",
"homepage": "",
"license": "ISC",
"main": "lib/muniz-plugin-i18n.js",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1"
}
}

0 comments on commit f460faf

Please sign in to comment.