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.
Files changed (2) hide show
  1. package/index.js +41 -21
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,18 +1,31 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // 开源版默认配置(只在环境变量未设置时才设置)
4
- if (!process.env.ROCKCLI_BASE_URL) {
5
- process.env.ROCKCLI_BASE_URL = 'http://127.0.0.1:8080';
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
- yargs(hideBin(process.argv))
27
- .scriptName('rockcli')
28
- .usage(LOGO + '\n\nUsage: $0 <command> [options]')
29
- .command(logCommand)
30
- .command(sandboxCommand)
31
- .demandCommand(1)
32
- .strict()
33
- .alias('h', 'help')
34
- .alias('v', 'version')
35
- .version('0.1.0')
36
- .help()
37
- .wrap(null)
38
- .parse();
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
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rl-rockcli",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Open-source ROCK CLI - Sandbox and Log management tool",
5
5
  "bin": {
6
6
  "rockcli": "./index.js"