🤖
command-plugin


Translations: 🇨🇳 汉语
// 红色
console.log("\x1B[91m --本地ts-build中-- ");
console.log("\x1B[0m")
// 绿色
console.log(\x1B[92m --本地ts-build中-- \x1B[0m);
// 黄色
console.log(\x1B[93m --本地ts-build中-- \x1B[0m);
// 蓝色
console.log(\x1B[94m --本地ts-build中-- \x1B[0m);
npm uninstall -g chalk commander inquirer
Quickstart
begin
npm install command-plugin -g
# 第一种方法,推荐:
npm run engineer
# 第二种方法:不推荐 项目根目录的package.json中输入
command-plugin install prettier husky env eslint npm
# 第三种方法:命令行下面 输入
command-plugin gui
Quesion
- 如果你遇到Error [ERR_REQUIRE_ESM]: require() of ES Module 的报错。在你的package.json中加入
"type": "module",
- This file is being treated as an ES module because it has a '.js' file extension and 'D:\cicd-test\package.json' contains "type": "module"
删掉 "type": "module", 加入 "type": "commonjs"
- 暂时没有适配pnpm的自动script写入,如果你是用这个你需要
# 项目根目录的package.json中添加
{
"engineer":"command-plugin gui "
}
# 然后运行 npm run engineer
Contain
husky
限制了只能用如下参数进行提交
- feat: 新功能 (feature)
- fix:修补bug
- docs:文档 (documentation)
- style:格式(不影响代码运行的变动)
- refactor: 重构(即不是新增功能,也不是修改bug的代码变动)
- chore:构建过程或辅助工具的变动revert: 撤销,版本回退
- perf:性能优化
- test:测试
- improvement:改进
- update:
- build: 打包
- ci: 持续集成
prettier
module.exports = {
printWidth: 80,
singleQuote: true,
tabWidth: 2,
proseWrap: 'never',
Semicolons: true,
overrides: [{ files: '.prettierrc', options: { parser: 'json' } }],
};
more refer:https://www.prettier.cn/
env
cross-env ENV=production max dev
var proEnv = require('./config/production.env');
var testEnv = require('./config/test.env');
var devEnv = require('./config/development.env');
const env = process.env.ENV;
let URL_COMMON = '';
let URL_RESOURCE = '';
if (env === 'production') {
console.log("----------生产环境----------");
URL_COMMON = proEnv.URL_COMMON;
URL_RESOURCE = proEnv.URL_RESOURCE
} else if (env === 'test') {
console.log("----------测试环境----------");
URL_COMMON = testEnv.URL_COMMON;
URL_RESOURCE = testEnv.URL_RESOURCE
} else if( env ==='development') {
console.log("----------开发环境----------");
URL_COMMON = devEnv.URL_COMMON;
URL_RESOURCE = devEnv.URL_RESOURCE
}
eslint
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
extends: [
],
parserOptions: {
ecmaVersion: 8,
sourceType: 'module',
},
settings: {},
rules: {
'no-unused-vars': 2,
'consistent-return': 0,
'no-underscore-dangle': 0,
'no-plusplus': 1,
'no-eval': 0,
'linebreak-style': [0, 'error', 'window'],
camelcase: 'warn',
},
overrides: [
{
files: ['*.js'],
rules: {
'no-unused-vars': 0,
},
},
],
};
more refer:http://eslint.cn/
npm
指定.npmrc
cicd
目前这个文件夹是放置一些脚本的。
包括部署和项目结构优化的脚本
test
里面分成两个文件夹.主要使用jest做的
主要是有工具类js ,ts 的测试。
以及web-component之类的测试
node_proxy
集成了三种方法来做跨域。一般如果你做脚本的话,可以下载下来做插件的端口转发
standard_readme
帮助你生成标准 README.md 的 东西。
注意。提前要填写好你package.json 的name version homepage 三个字段
然后注意 如果项目中有 README.md 需要先删掉
默认会生成 author 和 packageName 的label(就是一开始下面并列的牌子)
如果你想要添加自己的label 可以在package.json中添加 如下格式字段
"label": [
{
"frontName": "Gitee",
"behindName": "Electrolux",
"src": "https://gitee.com/Electrolux",
"color": "red"
},
{
"frontName": "Bili",
"behindName": "Electrolux",
"src": "https://space.bilibili.com/286773126",
"color": "Pink"
}
],
Developer
一开始安装的时候会通过package.json的bin字段执行 install.js
如果你想添加你自己工程化的东西
--1.首先将你的文件放进file 文件夹
--2.修改project.js的 guiFn 方法和 增加 util/handleEvent.js导出的方法
--3.接下来的测试阶段请输入npm link
然后 npm run engineer
Example
COMMIT and CHANGELOG
# first
npm install command-plugin -g
npm run engineer
# THEN
select CICD and husky
# THEN
GO to dir .husky/commit-msg
然后把 os.system("node CICD/CHANGELOG/changeLogAdd.js " + line) 前面的判断符号改成 true
# THEN
GO to dir CICD/CHANGELOG/changeLogAdd
然后 把 isAutoUpDate 改成 true
COMMIT and Update Readme.md
if you allow my readme.md script ,then you can
# first
npm install command-plugin -g
npm run engineer
# THEN
select CICD
# THEN
GO to dir .husky/commit-msg
然后把 os.system("node CICD/readmeUpdate/readmeUpdate.js") 前面的判断符号改成 true
# THEN
GO to dir CICD/readmeUpdate/readmeUpdate.js
然后 把 line 和 resText 进行 替换
Badge

[](https://gitee.com/Electrolux)
Support
command-plugin is developed by me. Please use command-plugin, star it on gitee or even become a sponsor to support us!