@ruan-cat/utils 4.21.0 → 4.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/chunk-46BA5ZMG.js +2788 -0
- package/dist/cli/chunk-46BA5ZMG.js.map +1 -0
- package/dist/cli/index.js +65 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/move-vercel-output-to-root.js +14 -0
- package/dist/cli/move-vercel-output-to-root.js.map +1 -0
- package/dist/node-esm/index.js +1 -1
- package/dist/node-esm/index.js.map +1 -1
- package/package.json +5 -2
- package/src/cli/index.ts +87 -0
- package/src/cli/move-vercel-output-to-root.ts +17 -0
- package/src/node-esm/scripts/move-vercel-output-to-root/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ruan-cat/utils",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.22.0",
|
|
4
4
|
"description": "阮喵喵工具集合。默认提供js文件,也直接提供ts文件。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
7
7
|
"types": "./src/index.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"ruan-cat-utils": "./dist/cli/index.js",
|
|
10
|
+
"move-vercel-output-to-root": "./dist/cli/move-vercel-output-to-root.js"
|
|
11
|
+
},
|
|
8
12
|
"homepage": "https://utils.ruancat6312.top",
|
|
9
13
|
"bugs": {
|
|
10
14
|
"url": "https://github.com/ruan-cat/monorepo/issues"
|
|
@@ -30,7 +34,6 @@
|
|
|
30
34
|
"import": "./dist/node-esm/index.js"
|
|
31
35
|
},
|
|
32
36
|
"./monorepo": "./src/monorepo/index.ts",
|
|
33
|
-
"./move-vercel-output-to-root": "./src/node-esm/scripts/move-vercel-output-to-root/index.ts",
|
|
34
37
|
"./unplugin-vue-router": "./src/unplugin-vue-router/index.ts",
|
|
35
38
|
"./vite-plugin-autogeneration-import-file": "./src/vite-plugin-autogeneration-import-file/index.ts",
|
|
36
39
|
"./vueuse": "./src/vueuse/index.ts",
|
package/src/cli/index.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ruan-cat/utils CLI 入口
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* 本文件是 @ruan-cat/utils 包的统一 CLI 入口。
|
|
6
|
+
* 通过 package.json 的 bin 字段暴露为 `ruan-cat-utils` 命令。
|
|
7
|
+
*
|
|
8
|
+
* 用法:
|
|
9
|
+
* npx ruan-cat-utils <command> [options]
|
|
10
|
+
*
|
|
11
|
+
* 支持的子命令:
|
|
12
|
+
* move-vercel-output-to-root 将子包的 .vercel/output 搬运到 monorepo 根目录
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import consola from "consola";
|
|
16
|
+
import {
|
|
17
|
+
getMoveVercelOutputToRootHelpText,
|
|
18
|
+
runMoveVercelOutputToRootCli,
|
|
19
|
+
} from "../node-esm/scripts/move-vercel-output-to-root/index";
|
|
20
|
+
|
|
21
|
+
const CLI_NAME = "ruan-cat-utils";
|
|
22
|
+
|
|
23
|
+
function printMainHelp() {
|
|
24
|
+
const helpText = [
|
|
25
|
+
`${CLI_NAME} - @ruan-cat/utils 命令行工具`,
|
|
26
|
+
"",
|
|
27
|
+
"用法:",
|
|
28
|
+
` ${CLI_NAME} <command> [options]`,
|
|
29
|
+
"",
|
|
30
|
+
"可用命令:",
|
|
31
|
+
" move-vercel-output-to-root 将子包的 .vercel/output 搬运到 monorepo 根目录",
|
|
32
|
+
"",
|
|
33
|
+
"全局选项:",
|
|
34
|
+
" -h, --help 查看帮助信息",
|
|
35
|
+
" -v, --version 查看版本号",
|
|
36
|
+
"",
|
|
37
|
+
"示例:",
|
|
38
|
+
` ${CLI_NAME} move-vercel-output-to-root`,
|
|
39
|
+
` ${CLI_NAME} move-vercel-output-to-root --dry-run`,
|
|
40
|
+
` ${CLI_NAME} move-vercel-output-to-root --root-dir ../../..`,
|
|
41
|
+
].join("\n");
|
|
42
|
+
|
|
43
|
+
console.log(helpText);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function printVersion() {
|
|
47
|
+
// 动态读取版本号会引入额外复杂度,这里直接输出包名提示用户查看
|
|
48
|
+
console.log(`${CLI_NAME} (from @ruan-cat/utils)`);
|
|
49
|
+
console.log("运行 'npm list @ruan-cat/utils' 查看当前安装的版本。");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function main() {
|
|
53
|
+
const args = process.argv.slice(2);
|
|
54
|
+
const command = args[0];
|
|
55
|
+
|
|
56
|
+
if (!command || command === "--help" || command === "-h") {
|
|
57
|
+
printMainHelp();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (command === "--version" || command === "-v") {
|
|
62
|
+
printVersion();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
switch (command) {
|
|
67
|
+
case "move-vercel-output-to-root": {
|
|
68
|
+
const subArgs = args.slice(1);
|
|
69
|
+
try {
|
|
70
|
+
runMoveVercelOutputToRootCli(subArgs);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
consola.error(error instanceof Error ? error.message : String(error));
|
|
73
|
+
process.exitCode = 1;
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
default: {
|
|
79
|
+
consola.error(`未知命令:${command}`);
|
|
80
|
+
console.log("");
|
|
81
|
+
printMainHelp();
|
|
82
|
+
process.exitCode = 1;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
main();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* move-vercel-output-to-root 快捷命令入口
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* 本文件是 `move-vercel-output-to-root` bin 命令的直接入口。
|
|
6
|
+
* 安装 @ruan-cat/utils 后,可以直接通过 `npx move-vercel-output-to-root` 调用。
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import consola from "consola";
|
|
10
|
+
import { runMoveVercelOutputToRootCli } from "../node-esm/scripts/move-vercel-output-to-root/index";
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
runMoveVercelOutputToRootCli();
|
|
14
|
+
} catch (error) {
|
|
15
|
+
consola.error(error instanceof Error ? error.message : String(error));
|
|
16
|
+
process.exitCode = 1;
|
|
17
|
+
}
|
|
@@ -239,7 +239,7 @@ export function parseMoveVercelOutputToRootCliArgs(args: string[]): MoveVercelOu
|
|
|
239
239
|
*/
|
|
240
240
|
export function getMoveVercelOutputToRootHelpText() {
|
|
241
241
|
return [
|
|
242
|
-
"
|
|
242
|
+
"move-vercel-output-to-root [options]",
|
|
243
243
|
"",
|
|
244
244
|
"选项:",
|
|
245
245
|
" --root-dir <path> 显式指定 monorepo 根目录",
|