Skip to content

Commit

Permalink
Docs: v1.5.2 补充命令说明
Browse files Browse the repository at this point in the history
  • Loading branch information
pandaoh committed May 13, 2024
1 parent 7b12df3 commit 4949f88
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
32 changes: 31 additions & 1 deletion bin/xcmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @Author: HxB
* @Date: 2022-04-25 16:27:06
* @LastEditors: DoubleAm
* @LastEditTime: 2024-05-11 18:47:15
* @LastEditTime: 2024-05-13 17:11:47
* @Description: 命令处理文件
* @FilePath: \js-xcmd\bin\xcmd.js
*/
Expand Down Expand Up @@ -70,6 +70,7 @@ program.version(pkg.version, '-v, --version');
program
.option('create-react-view [dir]', 'create react-view cli')
.command('create-react-view [dir]')
.description('创建 react-view 模板')
.action((dir) => {
console.log('----------Clone Template----------');
console.log(logLogo(logo));
Expand All @@ -81,6 +82,7 @@ program
program
.option('create-vue-admin [dir]', 'create vue-admin cli')
.command('create-vue-admin [dir]')
.description('创建 vue-admin 模板')
.action((dir) => {
console.log('----------Clone Template----------');
console.log(logLogo(logo));
Expand All @@ -92,6 +94,7 @@ program
program
.option('create-micro-web [dir]', 'create micro-web cli')
.command('create-micro-web [dir]')
.description('创建 react-micro-web 模板')
.action((dir) => {
console.log('----------Clone Template----------');
console.log(logLogo(logo));
Expand All @@ -103,6 +106,7 @@ program
program
.option('create-web-base [dir] [branch]', 'create web-base cli')
.command('create-web-base [dir] [branch]')
.description('获取 web-base 通用开发模板-推荐~')
.action((dir, branch) => {
console.log('----------Clone Template----------');
console.log(logLogo(logo));
Expand All @@ -126,6 +130,7 @@ program
program
.option('copy-file <fileSrc> <fileTarget>', 'copy file')
.command('copy-file <fileSrc> <fileTarget>')
.description('复制文件')
.action((fileSrc, fileTarget) => {
console.log('----------Copying----------');
console.log({ fileSrc, fileTarget });
Expand All @@ -136,6 +141,7 @@ program
program
.option('copy-dir <dirSrc> <dirTarget>', 'copy dir')
.command('copy-dir <dirSrc> <dirTarget>')
.description('复制目录')
.action((dirSrc, dirTarget) => {
console.log('----------Copying----------');
console.log({ dirSrc, dirTarget });
Expand All @@ -146,6 +152,7 @@ program
program
.option('delete-dir <dir>', 'delete dir')
.command('delete-dir <dir>')
.description('删除目录')
.action((dir) => {
console.log('----------Deleting----------');
console.log({ dir });
Expand All @@ -156,6 +163,7 @@ program
program
.option('empty-dir <dir>', 'empty dir')
.command('empty-dir <dir>')
.description('清空目录')
.action((dir) => {
console.log('----------Emptying----------');
console.log({ dir });
Expand All @@ -166,6 +174,7 @@ program
program
.option('rm-rf <path>', 'rm rf')
.command('rm-rf <path>')
.description('彻底删除目录/文件')
// .option('rmrf <path>', 'rmrf')
// .command('rmrf <path>')
.action((path) => {
Expand All @@ -178,6 +187,7 @@ program
program
.option('delete-file <file>', 'delete file')
.command('delete-file <file>')
.description('删除文件')
.action((file) => {
console.log('----------Deleting----------');
console.log({ file });
Expand All @@ -188,6 +198,7 @@ program
program
.option('add-dir <dir>', 'add dir')
.command('add-dir <dir>')
.description('添加目录')
.action((dir) => {
console.log('----------Adding----------');
console.log({ dir });
Expand All @@ -198,6 +209,7 @@ program
program
.option('add-file <file> [content]', 'add file')
.command('add-file <file> [content]')
.description('添加文件')
.action((file, content = '') => {
console.log('----------Adding----------');
console.log({ file, content });
Expand All @@ -208,6 +220,7 @@ program
program
.option('rename-dir <dirSrc> <dirTarget>', 'rename dir')
.command('rename-dir <dirSrc> <dirTarget>')
.description('重命名目录/移动目录')
.action((dirSrc, dirTarget) => {
console.log('----------Renaming----------');
console.log({ dirSrc, dirTarget });
Expand All @@ -218,6 +231,7 @@ program
program
.option('rename-file <fileSrc> <fileTarget>', 'rename file')
.command('rename-file <fileSrc> <fileTarget>')
.description('重命名文件')
.action((fileSrc, fileTarget) => {
console.log('----------Renaming----------');
console.log({ fileSrc, fileTarget });
Expand All @@ -229,6 +243,7 @@ program
program
.option('replace-file-content <fileSrc> <content> <contentTarget>', 'replace file content')
.command('replace-file-content <fileSrc> <content> <contentTarget>')
.description('替换文件内容')
.action((fileSrc, content, contentTarget) => {
contentTarget = contentTarget.replace('[space]', ' ');
contentTarget = contentTarget.replace('[none]', '');
Expand All @@ -250,6 +265,7 @@ program
program
.option('update-time [filePath]', 'update package.json time [filePath]')
.command('update-time [filePath]')
.description('更新 json 中的 time 字段')
// .option('time [filePath]', 'update package.json time [filePath]')
// .command('time [filePath]')
.action((filePath) => {
Expand All @@ -273,6 +289,7 @@ program
program
.option('clean [target]', 'clean node_modules [default: ./node_modules]')
.command('clean [target]')
.description('清理某个目录下的 node_modules 目录')
.action((target = './') => {
console.log('----------Cleaning----------');
let rimrafCmd = `rimraf ${target}/node_modules`;
Expand All @@ -287,6 +304,7 @@ program
program
.option('npm-clean', 'npm-clean')
.command('npm-clean')
.description('清理 npm 缓存')
.action(() => {
console.log('----------Npm-CacheClean-Start----------');
const cmdStr = 'npm cache clean --force';
Expand All @@ -301,6 +319,7 @@ program
program
.option('yarn-clean', 'yarn-clean')
.command('yarn-clean')
.description('清理 yarn 缓存')
.action(() => {
console.log('----------Yarn-CacheClean-Start----------');
const cmdStr = 'yarn cache clean --force';
Expand All @@ -315,6 +334,7 @@ program
program
.option('i', 'npm i --ignore-scripts')
.command('i')
.description('执行 npm i --ignore-scripts')
.action(() => {
console.log('----------Npm-Install-IgnoreScripts-Start----------');
const cmdStr = 'npm i --ignore-scripts';
Expand All @@ -329,6 +349,7 @@ program
program
.option('eslint', 'eslint ./ --fix --ext .ts,.tsx,.js,.jsx,.vue')
.command('eslint')
.description('执行 eslint 修复')
.action(() => {
console.log('----------Eslint-Start----------');
const cmdStr = 'eslint ./ --fix --ext .ts,.tsx,.js,.jsx,.vue';
Expand All @@ -343,6 +364,7 @@ program
program
.option('prettier', 'prettier --write ./**/*.{ts,tsx,js,jsx,vue,html,css,scss,less}')
.command('prettier')
.description('执行 prettier 格式化')
.action(() => {
console.log('----------Prettier-Start----------');
const cmdStr = 'prettier --write ./**/*.{ts,tsx,js,jsx,vue,html,css,scss,less}';
Expand All @@ -357,6 +379,7 @@ program
program
.option('list [global]', 'list [global]')
.command('list [global]')
.description('查看安装的 npm 插件列表')
// .option('ls [global]', 'ls [global]')
// .command('ls [global]')
.action((global) => {
Expand All @@ -379,6 +402,7 @@ program
program
.option('lsn', 'lsn')
.command('lsn')
.description('查看 nvm 可用 node 版本列表')
.action(() => {
let cmdStr = 'nvm list available';
console.log({ cmdStr });
Expand All @@ -392,6 +416,7 @@ program
program
.option('ig [all]', 'ig [all]')
.command('ig [all]')
.description('全局安装必要的 npm 开发插件')
.action((all) => {
let cmdStr = '';
if (!all) {
Expand All @@ -412,6 +437,7 @@ program
program
.option('dev [src]', 'dev [src]')
.command('dev [src]')
.description('帮助执行 pnpm --filter ${src} dev')
.action((src) => {
let cmdStr = '';
if (src) {
Expand All @@ -433,6 +459,7 @@ program
program
.option('start [src]', 'start [src]')
.command('start [src]')
.description('帮助执行 pnpm --filter ${src} start')
.action((src) => {
let cmdStr = '';
if (src) {
Expand All @@ -454,6 +481,7 @@ program
program
.option('build [src]', 'build [src]')
.command('build [src]')
.description('帮助执行 pnpm --filter ${src} build')
.action((src) => {
let cmdStr = '';
if (src) {
Expand All @@ -476,6 +504,7 @@ program
program
.option('run <cmdStr>', 'run cmd')
.command('run <cmdStr>')
.description('执行某个命令')
.action((cmdStr) => {
console.log('----------Executing ----------');
cmd(cmdStr)
Expand Down Expand Up @@ -503,6 +532,7 @@ program
program
.option('sort-json <jsonPath> [outputPath]', 'sort-json <jsonPath> [outputPath]')
.command('sort-json <jsonPath> [outputPath]')
.description('将指定 json 文件排序去重并输出')
.action((jsonPath, outputPath) => {
outputPath = outputPath ? outputPath : jsonPath;
const jsonString = getFileContent(jsonPath);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "js-xcmd",
"version": "1.5.1",
"version": "1.5.2",
"description": "XCmd library for node.js.",
"main": "main.js",
"bin": {
Expand Down

0 comments on commit 4949f88

Please sign in to comment.