rl-rockcli 0.0.5 → 0.0.7
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/index.js +41 -21
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* rl-rockcli - Open Source ROCK CLI Entry Point
|
|
5
|
+
*
|
|
6
|
+
* 这是开源版本的入口文件,它会:
|
|
7
|
+
* 1. 设置 ROCKCLI_MODE=opensource 环境变量
|
|
8
|
+
* 2. **只引用 Core 命令**(不引用 Internal)
|
|
9
|
+
* 3. 过滤掉内网专有功能
|
|
10
|
+
*/
|
|
7
11
|
|
|
8
|
-
//
|
|
12
|
+
// 强制设置开源模式(在任何 require 之前)
|
|
9
13
|
process.env.ROCKCLI_MODE = 'opensource';
|
|
10
14
|
|
|
15
|
+
// 开源版默认配置
|
|
16
|
+
if (!process.env.ROCKCLI_BASE_URL) {
|
|
17
|
+
process.env.ROCKCLI_BASE_URL = 'http://127.0.0.1:8080'; // 本地开发环境
|
|
18
|
+
}
|
|
19
|
+
|
|
11
20
|
const yargs = require('yargs/yargs');
|
|
12
21
|
const { hideBin } = require('yargs/helpers');
|
|
13
|
-
const logCommand = require('./commands/log');
|
|
14
|
-
const sandboxCommand = require('./commands/sandbox');
|
|
15
22
|
|
|
23
|
+
// ⚠️ 关键:只引用 Core 命令,不引用 Internal
|
|
24
|
+
// 这确保打包时不会包含内网代码
|
|
25
|
+
const logCommand = require('./commands/log'); // 已支持 ROCKCLI_MODE 过滤
|
|
26
|
+
const sandboxCommand = require('./commands/sandbox'); // 已支持 ROCKCLI_MODE 过滤
|
|
27
|
+
|
|
28
|
+
// ASCII Art Logo
|
|
16
29
|
const LOGO = `
|
|
17
30
|
██████╗ ██████╗ ██████╗██╗ ██╗ ██████╗██╗ ██╗
|
|
18
31
|
██╔══██╗██╔═══██╗██╔════╝██║ ██╔╝██╔════╝██║ ██║
|
|
@@ -20,19 +33,26 @@ const LOGO = `
|
|
|
20
33
|
██╔══██╗██║ ██║██║ ██╔═██╗ ██║ ██║ ██║
|
|
21
34
|
██║ ██║╚██████╔╝╚██████╗██║ ██╗╚██████╗███████╗██║
|
|
22
35
|
╚═╝ ╚═╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝ ╚═════╝╚══════╝╚═╝
|
|
23
|
-
Open Source
|
|
24
36
|
`;
|
|
25
37
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
function run() {
|
|
39
|
+
const cli = yargs(hideBin(process.argv));
|
|
40
|
+
|
|
41
|
+
cli
|
|
42
|
+
.scriptName('rockcli')
|
|
43
|
+
.usage(LOGO + '\n\nUsage: $0 <command> [options]')
|
|
44
|
+
.command(logCommand)
|
|
45
|
+
.command(sandboxCommand)
|
|
46
|
+
.demandCommand(1, '请提供一个有效的命令。使用 --help 查看可用命令。')
|
|
47
|
+
.strict()
|
|
48
|
+
.alias('h', 'help')
|
|
49
|
+
.alias('v', 'version')
|
|
50
|
+
.version(require('./package.json').version)
|
|
51
|
+
.help()
|
|
52
|
+
.wrap(null);
|
|
53
|
+
|
|
54
|
+
cli.parse();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
run();
|
|
58
|
+
|