Skip to content

Commit

Permalink
chore(cli): initialization cli project
Browse files Browse the repository at this point in the history
link #37
  • Loading branch information
Zhengqbbb committed Jun 18, 2022
1 parent b30be8d commit 2947e38
Show file tree
Hide file tree
Showing 10 changed files with 326 additions and 144 deletions.
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,25 @@
"@commitlint/config-conventional": "^17.0.2",
"@cz-git/inquirer": "workspace:*",
"@types/inquirer": "8.2.0",
"@types/node": "^17.0.43",
"@types/node": "^18.0.0",
"@types/rimraf": "^3.0.2",
"@typescript-eslint/eslint-plugin": "^5.28.0",
"@typescript-eslint/parser": "^5.28.0",
"bumpp": "^7.1.1",
"bumpp": "^7.2.0",
"concurrently": "^7.2.2",
"conventional-changelog-cli": "^2.2.2",
"cz-git": "workspace:*",
"czg": "workspace:*",
"eslint": "^8.17.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"esno": "^0.16.3",
"fast-glob": "^3.2.11",
"husky": "^8.0.1",
"lint-staged": "^13.0.1",
"lint-staged": "^13.0.2",
"ora": "^6.1.0",
"pathe": "^0.3.0",
"prettier": "^2.7.0",
"prettier": "^2.7.1",
"rimraf": "^3.0.2",
"sort-package-json": "^1.57.0",
"tsup": "6.1.2",
Expand Down
Empty file added packages/cli/CHANGELOG.md
Empty file.
21 changes: 21 additions & 0 deletions packages/cli/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2022-present Qiubin Zheng (@Zhengqbbb zhengqbbb@gmail.com)

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.
40 changes: 40 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "czg",
"version": "0.0.1",
"description": "Interactive Commitizen CLI that generate standardized commit messages",
"keywords": [
"commit",
"commit message",
"commitizen-cli",
"commitizen",
"cli",
"cz-git",
"cz-customizable"
],
"homepage": "https://cz-git.qbenben.com/cli",
"bugs": {
"url": "https://github.com/Zhengqbbb/cz-git/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/Zhengqbbb/cz-git",
"directory": "packages/cli"
},
"license": "MIT",
"author": "Zhengqbbb <zhengqbbb@gmail.com> (https://github.com/Zhengqbbb)",
"bin": {
"czg": "lib/index.js"
},
"scripts": {
"build": "pnpm clean && tsup",
"clean": "rimraf *.tsbuildinfo lib dist",
"release:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
},
"devDependencies": {
"@cz-git/inquirer": "workspace:*",
"@cz-git/loader": "workspace:*",
"cz-git": "workspace:*",
"inquirer": "8.2.0",
"rimraf": "3.0.2"
}
}
75 changes: 75 additions & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env node
import { SearchCheckbox, style, fuzzyFilter } from "@cz-git/inquirer";
import inquirer from "inquirer";
console.log(style.gray("Hello, world!"));

const testArr1 = [
{ name: "test1", value: "test1" },
{ name: "test2", value: "test2" },
{ name: "test3", value: "test3" },
{ name: "test4", value: "test4" },
{ name: "test5", value: "test5" },
{ name: "test6", value: "test6" },
{ name: "test7", value: "test7" },
{ name: "test8", value: "test8" },
{ name: "test9", value: "test9" }
];

const testArr2 = [
{ name: "test1", value: "test1" },
new inquirer.Separator(),
{ name: "test2", value: "test2" },
{ name: "test3", value: "test3" },
{ name: "test4", value: "test4" },
{ name: "test5", value: "test5" },
{ name: "test6", value: "test6" },
{ name: "test7", value: "test7" },
{ name: "test8", value: "test8" },
{ name: "test9", value: "test9" }
];

const testArr3 = [
{ value: false, name: "empty" },
{ value: "___CUSTOM___", name: "custom" },
new inquirer.Separator(),
{ value: "cz-git", name: "cz-git" },
{ value: "docs", name: "docs: cz-git document" },
{ value: "plugin-inquirer", name: "plugin-inquirer: provide cz-git inquirer" },
{ value: "plugin-loader", name: "plugin-loader: options loader" }
];

inquirer.registerPrompt("search-checkbox", SearchCheckbox);
inquirer
.prompt([
{
type: "search-checkbox",
name: "testOne",
themeColorCode: "",
message: "Select checkbox test:",
source: function (_: unknown, input: string) {
return fuzzyFilter(input, testArr1);
}
},
{
type: "search-checkbox",
name: "testTwo",
themeColorCode: "38;5;043",
message: "Select checkbox test:",
source: function (_: unknown, input: string) {
return fuzzyFilter(input, testArr2);
}
},
{
type: "search-checkbox",
name: "cz",
themeColorCode: "38;5;042",
message: "Select scope:",
source: function (_: unknown, input: string) {
return fuzzyFilter(input, testArr3);
}
}
])
.then(function (answers) {
console.log(JSON.stringify(answers, null, " "));
})
.catch((e) => console.log(e));
11 changes: 11 additions & 0 deletions packages/cli/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./lib",
"noUnusedLocals": false,
"noUnusedParameters": false,
},
"exclude": ["node_modules", "./dist", "./lib"],
"include": ["./src"]
}
13 changes: 13 additions & 0 deletions packages/cli/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from "tsup";
import baseConfig from "../../tsup.config";

export default defineConfig(() => {
return {
...baseConfig,

minify: true,
entry: ["./src/index.ts"],
tsconfig: "./tsconfig.json",
dts: false
};
});

0 comments on commit 2947e38

Please sign in to comment.