feat!: use commander for command management
from this commit npm package commander will be used for command management, making sub-commands possible, due to what commiting from now and on is called through rcz commit
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@resultium/rcz",
|
"name": "@resultium/rcz",
|
||||||
"version": "1.0.0-alpha.1",
|
"version": "1.0.0",
|
||||||
"description": "Resultium commit standardization library, based on commitizen",
|
"description": "Resultium commit standardization library, based on conventional commits",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"rcz": "./dist/index.js"
|
"rcz": "./dist/index.js"
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@clack/prompts": "^0.7.0",
|
"@clack/prompts": "^0.7.0",
|
||||||
|
"commander": "^11.0.0",
|
||||||
"simple-git": "^3.19.1"
|
"simple-git": "^3.19.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@@ -8,6 +8,9 @@ dependencies:
|
|||||||
'@clack/prompts':
|
'@clack/prompts':
|
||||||
specifier: ^0.7.0
|
specifier: ^0.7.0
|
||||||
version: 0.7.0
|
version: 0.7.0
|
||||||
|
commander:
|
||||||
|
specifier: ^11.0.0
|
||||||
|
version: 11.0.0
|
||||||
simple-git:
|
simple-git:
|
||||||
specifier: ^3.19.1
|
specifier: ^3.19.1
|
||||||
version: 3.19.1
|
version: 3.19.1
|
||||||
@@ -55,6 +58,11 @@ packages:
|
|||||||
resolution: {integrity: sha512-4tT2UrL5LBqDwoed9wZ6N3umC4Yhz3W3FloMmiiG4JwmUJWpie0c7lcnUNd4gtMKuDEO4wRVS8B6Xa0uMRsMKg==}
|
resolution: {integrity: sha512-4tT2UrL5LBqDwoed9wZ6N3umC4Yhz3W3FloMmiiG4JwmUJWpie0c7lcnUNd4gtMKuDEO4wRVS8B6Xa0uMRsMKg==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
|
/commander@11.0.0:
|
||||||
|
resolution: {integrity: sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ==}
|
||||||
|
engines: {node: '>=16'}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/debug@4.3.4:
|
/debug@4.3.4:
|
||||||
resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
|
resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
|
||||||
engines: {node: '>=6.0'}
|
engines: {node: '>=6.0'}
|
||||||
|
|||||||
16
src/index.ts
16
src/index.ts
@@ -14,6 +14,7 @@ import fs from "fs";
|
|||||||
import path from "path";
|
import path from "path";
|
||||||
import { Config } from "./types";
|
import { Config } from "./types";
|
||||||
import simpleGit from "simple-git";
|
import simpleGit from "simple-git";
|
||||||
|
import { Command } from "commander";
|
||||||
|
|
||||||
const GetConfig = async () => {
|
const GetConfig = async () => {
|
||||||
if (fs.existsSync(path.join(process.cwd(), ".rczrc"))) {
|
if (fs.existsSync(path.join(process.cwd(), ".rczrc"))) {
|
||||||
@@ -26,8 +27,17 @@ const GetConfig = async () => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const program = new Command();
|
||||||
|
|
||||||
(async () => {
|
program
|
||||||
|
.name("rcz")
|
||||||
|
.description("Resultium commit standardization command-line interface")
|
||||||
|
.version("1.0.0");
|
||||||
|
|
||||||
|
program
|
||||||
|
.command("commit")
|
||||||
|
.description("Create a conventional commit")
|
||||||
|
.action(async () => {
|
||||||
const config = await GetConfig();
|
const config = await GetConfig();
|
||||||
|
|
||||||
intro("Creating a conventional commit");
|
intro("Creating a conventional commit");
|
||||||
@@ -175,4 +185,6 @@ const GetConfig = async () => {
|
|||||||
note(commitMessage);
|
note(commitMessage);
|
||||||
|
|
||||||
outro("Finished creating a conventional commit, feel free to push");
|
outro("Finished creating a conventional commit, feel free to push");
|
||||||
})();
|
});
|
||||||
|
|
||||||
|
program.parse();
|
||||||
|
|||||||
Reference in New Issue
Block a user