init: 初始化: ⏳ 初始化BunnyCli
This commit is contained in:
commit
da3cafc257
|
@ -0,0 +1,23 @@
|
|||
module.exports = {
|
||||
env: {
|
||||
browser: true,
|
||||
commonjs: true,
|
||||
es2021: true,
|
||||
},
|
||||
extends: "eslint:recommended",
|
||||
overrides: [
|
||||
{
|
||||
env: {
|
||||
node: true,
|
||||
},
|
||||
files: [".eslintrc.{js,cjs}"],
|
||||
parserOptions: {
|
||||
sourceType: "script",
|
||||
},
|
||||
},
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaVersion: "latest",
|
||||
},
|
||||
rules: { "no-undef": "off" },
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
node_modules
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
npx --no-install commitlint --edit $1
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env sh
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
npm run lint:lint-staged
|
|
@ -0,0 +1,5 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JavaScriptLibraryMappings">
|
||||
<includedPredefinedLibrary name="Node.js Core" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/bunny-cli.iml" filepath="$PROJECT_DIR$/.idea/bunny-cli.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,97 @@
|
|||
#!/usr/bin/env node
|
||||
const { program } = require("commander"); // 命令行提示工具
|
||||
const chalk = require("chalk"); // 终端输出颜色变化
|
||||
const inquirer = require("inquirer"); // 交互选项
|
||||
const ora = require("ora"); // loading效果
|
||||
const spinner = ora("Loading unicorns").start(); // 注意要使用x几版本因为不支持
|
||||
const figlet = require("figlet"); // 生成艺术字
|
||||
|
||||
figlet("Hello World!!", function (err, data) {
|
||||
if (err) {
|
||||
console.log("Something went wrong...");
|
||||
console.dir(err);
|
||||
return;
|
||||
}
|
||||
console.log(data);
|
||||
});
|
||||
|
||||
figlet.text(
|
||||
"Boo!",
|
||||
{
|
||||
font: "Ghost",
|
||||
horizontalLayout: "default",
|
||||
verticalLayout: "default",
|
||||
width: 80,
|
||||
whitespaceBreak: true,
|
||||
},
|
||||
function (err, data) {
|
||||
if (err) {
|
||||
console.log("Something went wrong...");
|
||||
console.dir(err);
|
||||
return;
|
||||
}
|
||||
console.log(data);
|
||||
},
|
||||
);
|
||||
|
||||
console.log(
|
||||
figlet.textSync("Boo!", {
|
||||
font: "Ghost",
|
||||
horizontalLayout: "default",
|
||||
verticalLayout: "default",
|
||||
width: 80,
|
||||
whitespaceBreak: true,
|
||||
}),
|
||||
);
|
||||
|
||||
setTimeout(() => {
|
||||
spinner.color = "red";
|
||||
spinner.text = "网络较慢,请稍后...";
|
||||
}, 1000);
|
||||
|
||||
setTimeout(() => {
|
||||
spinner.succeed("下载成功!!!");
|
||||
}, 2000);
|
||||
|
||||
setTimeout(() => {
|
||||
spinner.fail("下载失败!!!");
|
||||
}, 3000);
|
||||
|
||||
inquirer
|
||||
.prompt([
|
||||
/* Pass your questions in here */
|
||||
{ type: "input", name: "food", message: "你吃什么", default: "包子" },
|
||||
{ type: "input", name: "food", message: "吃辣吗?", default: "微辣" },
|
||||
])
|
||||
.then((answers) => {
|
||||
// Use user feedback for... whatever!!
|
||||
console.log(answers);
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.isTtyError) {
|
||||
// Prompt couldn't be rendered in the current environment
|
||||
} else {
|
||||
// Something else went wrong
|
||||
}
|
||||
});
|
||||
|
||||
console.log(chalk.red("文字颜色"));
|
||||
|
||||
program.name("bunny-cli").usage("<command> [options]");
|
||||
|
||||
program
|
||||
.option("-d, --debug", "output extra debugging")
|
||||
.option("-s, --small", "small pizza size")
|
||||
.option("-p, --pizza-type <type>", "flavour of pizza");
|
||||
|
||||
program
|
||||
.command("clone <source> [destination]")
|
||||
.description("clone a repository into a newly created directory")
|
||||
.action((source, destination) => {
|
||||
console.log(source, destination);
|
||||
});
|
||||
|
||||
program.parse(process.argv);
|
||||
|
||||
const options = program.opts();
|
||||
console.log(options);
|
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/env node
|
||||
const { program } = require("commander"); // 命令行提示工具
|
||||
const chalk = require("chalk"); // 终端输出颜色变化
|
||||
const inquirer = require("inquirer"); // 交互选项
|
||||
const ora = require("ora"); // loading效果
|
||||
const spinner = ora("Loading unicorns").start(); // 注意要使用x几版本因为不支持
|
||||
const figlet = require("figlet"); // 生成艺术字
|
||||
|
||||
console.log(program);
|
||||
console.log(chalk);
|
||||
console.log(inquirer);
|
||||
console.log(ora);
|
||||
console.log(spinner);
|
||||
console.log(figlet);
|
|
@ -0,0 +1,126 @@
|
|||
// @see: https://cz-git.qbenben.com/zh/guide
|
||||
/** @type {import('cz-git').UserConfig} */
|
||||
|
||||
module.exports = {
|
||||
ignores: [(commit) => commit === "init"],
|
||||
extends: ["@commitlint/config-conventional"],
|
||||
rules: {
|
||||
// @see: https://commitlint.js.org/#/reference-rules
|
||||
"body-leading-blank": [2, "always"],
|
||||
"footer-leading-blank": [1, "always"],
|
||||
"header-max-length": [2, "always", 108],
|
||||
"subject-empty": [2, "never"],
|
||||
"type-empty": [2, "never"],
|
||||
"subject-case": [0],
|
||||
"type-enum": [
|
||||
2,
|
||||
"always",
|
||||
[
|
||||
"init",
|
||||
"feat",
|
||||
"page",
|
||||
"completepage",
|
||||
"fix",
|
||||
"fixbug",
|
||||
"docs",
|
||||
"style",
|
||||
"refactor",
|
||||
"perf",
|
||||
"test",
|
||||
"build",
|
||||
"ci",
|
||||
"change",
|
||||
"revert",
|
||||
"wip",
|
||||
"workflow",
|
||||
"types",
|
||||
"release",
|
||||
],
|
||||
],
|
||||
},
|
||||
prompt: {
|
||||
messages: {
|
||||
type: "选择你要提交的类型 :",
|
||||
scope: "选择一个提交范围(可选):",
|
||||
customScope: "请输入自定义的提交范围 :",
|
||||
subject: "填写简短精炼的变更描述 :\n",
|
||||
body: '填写更加详细的变更描述(可选)。使用 "|" 换行 :\n',
|
||||
breaking: '列举非兼容性重大的变更(可选)。使用 "|" 换行 :\n',
|
||||
footerPrefixsSelect: "选择关联issue前缀(可选):",
|
||||
customFooterPrefixs: "输入自定义issue前缀 :",
|
||||
footer: "列举关联issue (可选) 例如: #31, #I3244 :\n",
|
||||
confirmCommit: "是否提交或修改commit ?",
|
||||
},
|
||||
types: [
|
||||
{ value: "init: 初始化", name: "初始化: ⏳ 初始化项目", emoji: "⏳" },
|
||||
{ value: "feat: 新增功能", name: "新增: 🚀 新增功能", emoji: "🚀" },
|
||||
{ value: "page: 新增页面", name: "页面: 📄 新增页面", emoji: "📄" },
|
||||
{
|
||||
value: "completepage: 完成页面",
|
||||
name: "完成页面: 🍻 完成页面",
|
||||
emoji: "🍻",
|
||||
},
|
||||
{ value: "fixbug: 修改bug", name: "bug: 🐛 修改bug", emoji: "🐛" },
|
||||
{ value: "fix: 修复", name: "修复: 🧩 修复缺陷", emoji: "🧩" },
|
||||
{ value: "docs: 文档", name: "文档: 📚 文档变更", emoji: "📚" },
|
||||
{
|
||||
value: "style: 格式",
|
||||
name: "格式: 🎨 代码格式(不影响功能,例如空格、分号等格式修正)",
|
||||
emoji: "🎨",
|
||||
},
|
||||
{
|
||||
value: "refactor: 重构",
|
||||
name: "重构: ♻️ 代码重构(不包括 bug 修复、功能新增)",
|
||||
emoji: "♻️",
|
||||
},
|
||||
{ value: "perf: 性能", name: "性能: ⚡️ 性能优化", emoji: "⚡️" },
|
||||
{
|
||||
value: "test: 测试",
|
||||
name: "测试: ✅ 添加疏漏测试或已有测试改动",
|
||||
emoji: "✅",
|
||||
},
|
||||
{
|
||||
value: "change: 修改包版本",
|
||||
name: "修改包: 📦️ 修改版本、外部依赖变更(如升级 npm 包、修改 webpack 配置等)",
|
||||
emoji: "📦️",
|
||||
},
|
||||
{
|
||||
value: "ci: 集成",
|
||||
name: "集成: 🎡 修改 CI 配置、脚本",
|
||||
emoji: "🎡",
|
||||
},
|
||||
{ value: "revert: 回退", name: "回退: ⏪️ 回滚 commit", emoji: "⏪️" },
|
||||
{ value: "build: 打包", name: "打包: 🔨 项目打包发布", emoji: "🔨" },
|
||||
],
|
||||
useEmoji: true,
|
||||
themeColorCode: "",
|
||||
scopes: [],
|
||||
allowCustomScopes: true,
|
||||
allowEmptyScopes: true,
|
||||
customScopesAlign: "bottom",
|
||||
customScopesAlias: "custom",
|
||||
emptyScopesAlias: "empty",
|
||||
upperCaseSubject: false,
|
||||
allowBreakingChanges: ["feat", "fix"],
|
||||
breaklineNumber: 100,
|
||||
breaklineChar: "|",
|
||||
skipQuestions: [],
|
||||
issuePrefixs: [
|
||||
{ value: "closed", name: "closed: ISSUES has been processed" },
|
||||
],
|
||||
customIssuePrefixsAlign: "top",
|
||||
emptyIssuePrefixsAlias: "skip",
|
||||
customIssuePrefixsAlias: "custom",
|
||||
allowCustomIssuePrefixs: true,
|
||||
allowEmptyIssuePrefixs: true,
|
||||
confirmColorize: true,
|
||||
maxHeaderLength: Infinity,
|
||||
maxSubjectLength: Infinity,
|
||||
minSubjectLength: 0,
|
||||
scopeOverrides: undefined,
|
||||
defaultBody: "",
|
||||
defaultIssues: "",
|
||||
defaultScope: "",
|
||||
defaultSubject: "",
|
||||
},
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
module.exports = {
|
||||
"*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"],
|
||||
"{!(package)*.json,*.code-snippets,.!(browserslist)*rc}": [
|
||||
"prettier --write--parser json",
|
||||
],
|
||||
"package.json": ["prettier --write"],
|
||||
"*.vue": ["eslint --fix", "prettier --write"],
|
||||
"*.{scss,less,styl,html}": ["prettier --write"],
|
||||
"*.md": ["prettier --write"],
|
||||
};
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "bunny-cli",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"bunny-cli": "./bin/index.js"
|
||||
},
|
||||
"scripts": {
|
||||
"lint:eslint": "eslint --fix --ext .js,.ts,.vue ./src",
|
||||
"lint:prettier": "prettier --write --loglevel warn \"bin/**/*.{js,ts,json,tsx,css,less,scss,vue,html,md}\"",
|
||||
"lint:lint-staged": "lint-staged",
|
||||
"prepare": "husky install",
|
||||
"release": "standard-version",
|
||||
"commit": "git status && git add -A && git-cz",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"chalk": "^4.0.0",
|
||||
"commander": "^11.1.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.1.1",
|
||||
"figlet": "^1.7.0",
|
||||
"fs-extra": "^11.2.0",
|
||||
"inquirer": "^8.0.0",
|
||||
"ora": "^5.0.1",
|
||||
"prettier": "^3.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^18.4.3",
|
||||
"@commitlint/config-conventional": "^18.4.3",
|
||||
"commitizen": "^4.3.0",
|
||||
"cz-git": "^1.8.0",
|
||||
"eslint": "^8.56.0",
|
||||
"husky": "^8.0.3",
|
||||
"lint-staged": "^15.2.0"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "node_modules/cz-git"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue