@gbits-jszx/dg-cli 0.0.0-regress-1777570061
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 +61 -0
- package/bin/dg-cli.js +58 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @gbits-jszx/dg-cli
|
|
2
|
+
|
|
3
|
+
DataGateway CLI — 部署 / 运维 / 配置一站式工具,Go 二进制经由 npx 分发。
|
|
4
|
+
|
|
5
|
+
## 安装与使用
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 一次性运行(推荐)
|
|
9
|
+
npx -y @gbits-jszx/dg-cli@latest doctor
|
|
10
|
+
|
|
11
|
+
# 全局安装
|
|
12
|
+
npm i -g @gbits-jszx/dg-cli
|
|
13
|
+
dg-cli doctor
|
|
14
|
+
|
|
15
|
+
# 项目本地依赖
|
|
16
|
+
npm i -D @gbits-jszx/dg-cli
|
|
17
|
+
npx dg-cli doctor
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 平台支持
|
|
21
|
+
|
|
22
|
+
| OS | Arch |
|
|
23
|
+
|---|---|
|
|
24
|
+
| Linux | x64 / arm64 |
|
|
25
|
+
| macOS | Intel / Apple Silicon |
|
|
26
|
+
| Windows | x64 |
|
|
27
|
+
|
|
28
|
+
> npm 装包时根据 `process.platform/arch` 自动只下载当前平台的二进制(约 8MB),其它子包跳过。
|
|
29
|
+
|
|
30
|
+
## 主要命令
|
|
31
|
+
|
|
32
|
+
- `dg-cli doctor`:环境自检
|
|
33
|
+
- `dg-cli config init|validate|path`:配置文件管理(schema 驱动)
|
|
34
|
+
- `dg-cli deploy install|upgrade|rollback`:VM 部署
|
|
35
|
+
- `dg-cli image build|push`:镜像构建发布
|
|
36
|
+
- `dg-cli system rotate-secret`:业务系统密钥轮换
|
|
37
|
+
|
|
38
|
+
完整文档:[DataGateway 项目仓库](https://m68gitlab.g-bits.com/jszx-infra/datagateway)。
|
|
39
|
+
|
|
40
|
+
## 常见问题
|
|
41
|
+
|
|
42
|
+
**Q1:装完执行报「不支持的平台」**
|
|
43
|
+
当前平台未被收录(仅支持 linux x64/arm64、macOS Intel/Apple Silicon、Windows x64)。请联系维护者补齐 `@gbits-jszx/dg-cli-<platform>-<arch>` 子包,或通过仓库内 GitLab 渠道安装本地构建版本。
|
|
44
|
+
|
|
45
|
+
**Q2:`npx` 报错「需要登录 https://registry.npmjs.org」**
|
|
46
|
+
本机 `~/.npmrc` 把 registry 切到了私有镜像(如 npmmirror)。临时切回:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm config set registry https://registry.npmjs.org/
|
|
50
|
+
npx -y @gbits-jszx/dg-cli@latest doctor
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Q3:与 `configs/config.yaml`、`.env` 文件的优先级**
|
|
54
|
+
bootstrap 把所有环境变量与当前工作目录原样透传给 Go 二进制,配置加载链与直接跑 `dg-cli` 完全一致:CLI flag > env (`DG_*`) > `configs/config.yaml` > 默认值。
|
|
55
|
+
|
|
56
|
+
**Q4:内网 / 无公网出口怎么办**
|
|
57
|
+
走 GitLab Generic Package 渠道(详见 `docs/dev-guide/OPS-部署指南.md` 第 4 步「离线兜底」)。
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT
|
package/bin/dg-cli.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// dg-cli npm bootstrap: 按 process.platform/arch 解析对应平台子包二进制并透传调用。
|
|
3
|
+
// 设计原则:stdio inherit + 默认 cwd + 默认 env,确保子进程感知到的运行环境与直接跑二进制完全一致。
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
const { execFileSync } = require("child_process");
|
|
7
|
+
|
|
8
|
+
const platform = process.platform; // 'linux' / 'darwin' / 'win32'
|
|
9
|
+
const arch = process.arch; // 'x64' / 'arm64'
|
|
10
|
+
const pkg = `@gbits-jszx/dg-cli-${platform}-${arch}`;
|
|
11
|
+
const exe = platform === "win32" ? "dg-cli.exe" : "dg-cli";
|
|
12
|
+
|
|
13
|
+
let binPath;
|
|
14
|
+
try {
|
|
15
|
+
binPath = require.resolve(`${pkg}/bin/${exe}`);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
// optionalDependencies 在装包时遇到任何瞬时错误(网络/权限/registry 镜像不同步)都会被
|
|
18
|
+
// npm 静默跳过、只记 lock,于是这里 require.resolve 找不到。绝大多数情况是缓存或安装
|
|
19
|
+
// 失败而不是平台真的不支持,按"清缓存 → 强装子包"的顺序给可执行排障步骤。
|
|
20
|
+
const supported = new Set([
|
|
21
|
+
"linux-x64", "linux-arm64",
|
|
22
|
+
"darwin-x64", "darwin-arm64",
|
|
23
|
+
"win32-x64",
|
|
24
|
+
]);
|
|
25
|
+
const tag = `${platform}-${arch}`;
|
|
26
|
+
console.error(`[dg-cli] 未能解析平台子包:${pkg}`);
|
|
27
|
+
if (!supported.has(tag)) {
|
|
28
|
+
console.error(`[dg-cli] 当前平台 ${tag} 不在支持矩阵内,请联系维护者补齐。`);
|
|
29
|
+
process.exit(2);
|
|
30
|
+
}
|
|
31
|
+
console.error(`[dg-cli] 平台 ${tag} 在支持矩阵内,子包很可能因 npm optionalDependencies 静默跳过未装到。`);
|
|
32
|
+
console.error(`[dg-cli] 排障步骤(依次尝试,命中即止):`);
|
|
33
|
+
console.error(` 1) 清缓存重试:`);
|
|
34
|
+
console.error(` rm -rf ~/.npm/_npx ~/.npm/_cacache && npx -y --prefer-online @gbits-jszx/dg-cli@latest --version`);
|
|
35
|
+
console.error(` 2) 强装当前平台子包:`);
|
|
36
|
+
console.error(` npm i -g @gbits-jszx/dg-cli ${pkg}`);
|
|
37
|
+
console.error(` 3) 内网镜像 registry 同步滞后?换 npmjs 试一次:`);
|
|
38
|
+
console.error(` npm --registry=https://registry.npmjs.org/ i -g @gbits-jszx/dg-cli ${pkg}`);
|
|
39
|
+
process.exit(2);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
execFileSync(binPath, process.argv.slice(2), {
|
|
44
|
+
stdio: "inherit",
|
|
45
|
+
env: process.env,
|
|
46
|
+
});
|
|
47
|
+
} catch (err) {
|
|
48
|
+
// 若子进程根本没起来(EACCES / ENOENT 等),stdio:inherit 也拿不到任何输出,
|
|
49
|
+
// 必须自己打印才能让用户看到根因;正常退出码非 0 时不打扰。
|
|
50
|
+
if (err && err.code && err.code !== 0 && typeof err.status !== "number") {
|
|
51
|
+
console.error(`[dg-cli] 启动失败: ${err.code} ${err.message}`);
|
|
52
|
+
console.error(`[dg-cli] 二进制: ${binPath}`);
|
|
53
|
+
if (err.code === "EACCES") {
|
|
54
|
+
console.error(`[dg-cli] 提示: 缺可执行位,尝试 chmod +x "${binPath}" 后重试`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
process.exit(typeof err.status === "number" ? err.status : 1);
|
|
58
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@gbits-jszx/dg-cli",
|
|
3
|
+
"version": "0.0.0-regress-1777570061",
|
|
4
|
+
"description": "DataGateway CLI — 部署/运维/配置一站式(Go binary,npx 分发)",
|
|
5
|
+
"bin": {
|
|
6
|
+
"dg-cli": "bin/dg-cli.js"
|
|
7
|
+
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=14"
|
|
14
|
+
},
|
|
15
|
+
"optionalDependencies": {
|
|
16
|
+
"@gbits-jszx/dg-cli-linux-x64": "0.0.0-regress-1777570061",
|
|
17
|
+
"@gbits-jszx/dg-cli-linux-arm64": "0.0.0-regress-1777570061",
|
|
18
|
+
"@gbits-jszx/dg-cli-darwin-x64": "0.0.0-regress-1777570061",
|
|
19
|
+
"@gbits-jszx/dg-cli-darwin-arm64": "0.0.0-regress-1777570061",
|
|
20
|
+
"@gbits-jszx/dg-cli-win32-x64": "0.0.0-regress-1777570061"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://m68gitlab.g-bits.com/jszx-infra/datagateway.git"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"datagateway",
|
|
29
|
+
"cli",
|
|
30
|
+
"mcp",
|
|
31
|
+
"gateway"
|
|
32
|
+
]
|
|
33
|
+
}
|