@asiainfo-sdd/multica-cli 0.1.0 → 0.2.1

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.
@@ -1,4 +1,4 @@
1
1
  {
2
- "server_url": "http://10.19.198.57:8080",
3
- "app_url": "http://10.19.198.57:8080"
2
+ "server_url": "https://aido.asiainfo.com/runtime-svc",
3
+ "app_url": "https://aido.asiainfo.com/runtime-svc"
4
4
  }
package/lib/install.js CHANGED
@@ -16,7 +16,7 @@ const http = require('./http');
16
16
  const pkg = require('../package.json');
17
17
 
18
18
  // 下载源基址,可被环境变量覆盖。指向 Nexus raw 仓库或 Jenkins 产物目录。
19
- const DEFAULT_DOWNLOAD_BASE = 'http://10.15.32.126:9090/aird-api/business/api/v1/external/daemon-download';
19
+ const DEFAULT_DOWNLOAD_BASE = 'https://aido.asiainfo.com/aird-api/business/api/v1/external/daemon-download';
20
20
  const LOCK_STALE_MS = 5 * 60 * 1000;
21
21
 
22
22
  function log(msg) {
@@ -151,7 +151,7 @@ function hintRunRebuild() {
151
151
  log(' 修复方式:稍后执行 npm rebuild @asiainfo-sdd/multica-cli');
152
152
  }
153
153
 
154
- // 把部署级配置(server_url/app_url)合并进 ~/.multica/config.json。
154
+ // 把部署级配置(server_url/app_url)写入 ~/.multica/config.json(覆盖式)。
155
155
  // manifest 失败时传 null,退回 env > 包内置默认值。
156
156
  function applyServerConfigSafe(manifest) {
157
157
  let result;
@@ -165,8 +165,8 @@ function applyServerConfigSafe(manifest) {
165
165
  for (const { key, value } of result.written) {
166
166
  log(`✓ 已写入 ${key} = ${value}(${require('./server-config').multicaConfigPath()})`);
167
167
  }
168
- for (const { key, existing } of result.kept) {
169
- log(`ℹ ${key} 已有配置 ${existing},保持不变(如需更改:aido config set ${key} <新地址>)`);
168
+ for (const { key, from, to } of result.updated) {
169
+ log(`✓ 已更新 ${key}:${from} → ${to}(环境切换;token 需重新登录生成)`);
170
170
  }
171
171
  }
172
172
 
@@ -1,10 +1,13 @@
1
1
  'use strict';
2
2
 
3
- // 安装时把部署级配置(server_url/app_url)合并写入 ~/.multica/config.json,
3
+ // 安装时把部署级配置(server_url/app_url)写入 ~/.multica/config.json,
4
4
  // 免去用户手工 multica config set。规则:
5
5
  // - 取值优先级: MULTICA_SERVER_URL/MULTICA_APP_URL env > manifest 顶层
6
6
  // server_url/app_url(运维可不重发 npm 包直接改) > lib/dist-config.json
7
- // - 只填空: 用户已有值(如指向测试服)绝不覆盖,只提示
7
+ // - server_url/app_url 两个部署级 URL【覆盖式】更新: 与本次安装源不一致时
8
+ // 直接覆盖并打印 新值 ← 旧值(升级环境后旧地址上的 token 验证/daemon 连接
9
+ // 必然失败,覆盖是唯一正确动作;自定义地址用户可从日志看到旧值并改回)
10
+ // - 其余字段(token/workspace_id/各超时/backends 等)一律不动
8
11
  // - 目标文件是 multica CLI 的标准配置(daemon 只认这里的 token),
9
12
  // 多 profile 场景(--profile)不在此处理,留给用户手动 config set
10
13
  // token 属于个人凭据,始终由用户自行 multica login --token 写入。
@@ -51,8 +54,9 @@ function resolveDesired(manifest) {
51
54
  return desired;
52
55
  }
53
56
 
54
- // 返回 {written: [{key, value}], kept: [{key, existing}]} 供上层打印;
57
+ // 返回 {written: [{key, value}], updated: [{key, from, to}]} 供上层打印;
55
58
  // 无可写内容或文件损坏时返回 null(不产生任何变更)。
59
+ // written = 原来为空、本次填入;updated = 原有不同值、本次覆盖。
56
60
  function applyServerConfig(manifest) {
57
61
  const desired = resolveDesired(manifest);
58
62
  if (!desired.server_url && !desired.app_url) return null;
@@ -67,24 +71,28 @@ function applyServerConfig(manifest) {
67
71
  }
68
72
 
69
73
  const written = [];
70
- const kept = [];
74
+ const updated = [];
75
+ let changed = false;
71
76
  for (const key of CONFIG_KEYS) {
72
77
  if (!desired[key]) continue;
73
- if (userConfig[key] && userConfig[key] !== desired[key]) {
74
- kept.push({ key, existing: userConfig[key] });
75
- } else if (!userConfig[key]) {
78
+ if (!userConfig[key]) {
76
79
  userConfig[key] = desired[key];
77
80
  written.push({ key, value: desired[key] });
81
+ changed = true;
82
+ } else if (userConfig[key] !== desired[key]) {
83
+ updated.push({ key, from: userConfig[key], to: desired[key] });
84
+ userConfig[key] = desired[key];
85
+ changed = true;
78
86
  }
79
87
  }
80
88
 
81
- if (written.length === 0) return { written, kept };
89
+ if (!changed) return { written, updated };
82
90
 
83
91
  const file = multicaConfigPath();
84
92
  fs.mkdirSync(path.dirname(file), { recursive: true });
85
- // 保留用户已有其余字段,仅追加部署级键;不写 token。
93
+ // 保留用户已有其余字段,仅更新部署级键;不写 token。
86
94
  fs.writeFileSync(file, JSON.stringify(userConfig, null, 2) + '\n');
87
- return { written, kept };
95
+ return { written, updated };
88
96
  }
89
97
 
90
98
  function logWarn(msg) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asiainfo-sdd/multica-cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "数字工厂 daemon 客户端安装帮助包:npm install 时按平台下载二进制并校验并写入部署级配置,不参与 daemon 的使用与管理",
5
5
  "bin": {
6
6
  "aido": "bin/aido.js",