@gaiaworks/gaia-cli 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -21,10 +21,10 @@ gaia-cli version
21
21
 
22
22
  ```bash
23
23
  npx @gaiaworks/gaia-cli@latest install
24
- npx @gaiaworks/gaia-cli@latest install --mode external
25
- npx @gaiaworks/gaia-cli@latest install --mode internal
24
+ npx @gaiaworks/gaia-cli@latest install --mode saas
25
+ npx @gaiaworks/gaia-cli@latest install --mode work
26
26
  ```
27
27
 
28
- 未指定 `--mode` 时默认写入 `external`。安装脚本会在全局安装完成后执行 `gaia-cli config set mode <external|internal>`,用于后续区分内部/外部登录流程和 shared skill 规则。
28
+ 未指定 `--mode` 时默认写入 `saas`。安装脚本会在全局安装完成后执行 `gaia-cli config set mode <saas|work>`,用于后续区分内部/外部登录流程和 shared skill 规则。
29
29
 
30
- 安装时会根据 npm 包版本,从 `gaiaworks/gaia-cli-releases` 的同版本 GitHub Release 下载当前平台对应的 `gaia-cli` 二进制。
30
+ 安装时会根据 npm 包版本,从 OSS 的同版本目录下载当前平台对应的 `gaia-cli` 二进制。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaiaworks/gaia-cli",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "JavaScript launcher for gaia-cli.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -11,7 +11,8 @@ const packageSpec = `${packageJson.name}@${packageJson.version}`;
11
11
  const binaryPath = path.join(__dirname, '..', 'bin', binaryName());
12
12
 
13
13
  function parseInstallArgs(args) {
14
- let mode = 'external';
14
+ let mode = 'saas';
15
+ let explicitMode = false;
15
16
  const npmArgs = [];
16
17
 
17
18
  for (let i = 0; i < args.length; i += 1) {
@@ -19,29 +20,31 @@ function parseInstallArgs(args) {
19
20
  if (arg === '--mode') {
20
21
  const value = args[i + 1];
21
22
  if (!value) {
22
- throw new Error('--mode requires a value: internal or external');
23
+ throw new Error('--mode requires a value: work or saas');
23
24
  }
24
25
  mode = value;
26
+ explicitMode = true;
25
27
  i += 1;
26
28
  continue;
27
29
  }
28
30
  if (arg.startsWith('--mode=')) {
29
31
  mode = arg.slice('--mode='.length);
32
+ explicitMode = true;
30
33
  continue;
31
34
  }
32
35
  npmArgs.push(arg);
33
36
  }
34
37
 
35
- if (mode !== 'internal' && mode !== 'external') {
36
- throw new Error(`Unsupported mode: ${mode}. Expected internal or external.`);
38
+ if (mode !== 'work' && mode !== 'saas') {
39
+ throw new Error(`Unsupported mode: ${mode}. Expected work or saas.`);
37
40
  }
38
41
 
39
- return { mode, npmArgs };
42
+ return { explicitMode, mode, npmArgs };
40
43
  }
41
44
 
42
- function run(command, args) {
45
+ function run(command, args, options = {}) {
43
46
  const result = spawnSync(command, args, {
44
- stdio: 'inherit',
47
+ stdio: options.stdio || 'inherit',
45
48
  });
46
49
 
47
50
  if (result.error) {
@@ -60,15 +63,19 @@ function ensureLocalBinary() {
60
63
  }
61
64
 
62
65
  function installWizard(args) {
63
- const { mode, npmArgs } = parseInstallArgs(args);
66
+ const { explicitMode, mode, npmArgs } = parseInstallArgs(args);
64
67
  if (npmArgs.length > 0) {
65
68
  throw new Error(`Unsupported install arguments: ${npmArgs.join(' ')}`);
66
69
  }
67
70
 
68
71
  ensureLocalBinary();
69
72
  run('npm', ['install', '-g', packageSpec]);
70
- run(binaryPath, ['config', 'set', 'mode', mode]);
71
- console.error(`[gaia-cli] Global install completed with mode: ${mode}. You can now run: gaia-cli version`);
73
+ run(binaryPath, ['config', 'set', 'mode', mode], { stdio: 'ignore' });
74
+ if (explicitMode) {
75
+ console.error(`[gaia-cli] 安装完成,当前模式: ${mode}。可以执行: gaia-cli version`);
76
+ } else {
77
+ console.error('[gaia-cli] 安装完成。可以执行: gaia-cli version');
78
+ }
72
79
  }
73
80
 
74
81
  if (require.main === module) {
@@ -9,11 +9,10 @@ const { spawnSync } = require('child_process');
9
9
  const PACKAGE_ROOT = path.resolve(__dirname, '..');
10
10
  const PACKAGE_JSON = path.join(PACKAGE_ROOT, 'package.json');
11
11
  const BIN_DIR = path.join(PACKAGE_ROOT, 'bin');
12
- const RELEASE_REPO = process.env.GAIA_CLI_RELEASE_REPO || 'gaiaworks/gaia-cli-releases';
13
- const DOWNLOAD_BASE = process.env.GAIA_CLI_DOWNLOAD_BASE || `https://github.com/${RELEASE_REPO}/releases/download`;
12
+ const DOWNLOAD_BASE = process.env.GAIA_CLI_DOWNLOAD_BASE || 'https://assets.gaiaworkforce.com/gaia-cli/releases';
14
13
  const ALLOWED_DOWNLOAD_HOSTS = new Set([
15
- 'github.com',
16
- 'objects.githubusercontent.com',
14
+ 'assets.gaiaworkforce.com',
15
+ 'gaiafe.oss-cn-shanghai.aliyuncs.com',
17
16
  ]);
18
17
 
19
18
  function readPackageVersion() {
@@ -158,7 +157,7 @@ if (require.main === module) {
158
157
  install();
159
158
  } catch (error) {
160
159
  console.error(`[gaia-cli] Failed to install binary: ${error.message}`);
161
- console.error('[gaia-cli] Please check network access to GitHub Releases or contact the administrator.');
160
+ console.error('[gaia-cli] Please check network access to OSS assets or contact the administrator.');
162
161
  process.exit(1);
163
162
  }
164
163
  }