@ranger1/dx 0.1.107 → 0.1.108
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 +29 -0
- package/lib/backend-artifact-deploy/config.js +17 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -463,6 +463,7 @@ SSH 认证说明:
|
|
|
463
463
|
- `dx deploy backend` 当前直接调用系统 `ssh` / `scp`,不会单独解析 `sshKey`、`identityFile` 之类的 dx 配置项。
|
|
464
464
|
- 因此,发布使用哪把私钥,取决于本机 OpenSSH 的默认认证行为,例如 `ssh-agent`、`~/.ssh/config`、默认私钥文件等。
|
|
465
465
|
- 如果你已经在 `~/.ssh/config` 中配置了主机别名(例如 `Host ai-staging`),推荐直接把 `backendDeploy.remote.host` 写成这个别名,让 OpenSSH 自动匹配对应的 `HostName`、`User`、`Port`、`IdentityFile`。
|
|
466
|
+
- `backendDeploy.remote` 可以保持旧的单远端对象;也可以按环境拆成 `remote.staging` / `remote.production`,此时 `dx deploy backend --staging` 与 `dx deploy backend --prod` 会选择对应环境的远端。
|
|
466
467
|
|
|
467
468
|
例如本机 `~/.ssh/config`:
|
|
468
469
|
|
|
@@ -494,6 +495,34 @@ Host ai-staging
|
|
|
494
495
|
}
|
|
495
496
|
```
|
|
496
497
|
|
|
498
|
+
按环境区分远端时:
|
|
499
|
+
|
|
500
|
+
```json
|
|
501
|
+
{
|
|
502
|
+
"deploy": {
|
|
503
|
+
"backend": {
|
|
504
|
+
"internal": "backend-artifact-deploy",
|
|
505
|
+
"backendDeploy": {
|
|
506
|
+
"remote": {
|
|
507
|
+
"staging": {
|
|
508
|
+
"host": "ai-staging",
|
|
509
|
+
"port": 22,
|
|
510
|
+
"user": "deploy",
|
|
511
|
+
"baseDir": "/srv/example-app"
|
|
512
|
+
},
|
|
513
|
+
"production": {
|
|
514
|
+
"host": "ai-ubuntu-prod",
|
|
515
|
+
"port": 22,
|
|
516
|
+
"user": "deploy",
|
|
517
|
+
"baseDir": "/srv/example-app"
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
```
|
|
525
|
+
|
|
497
526
|
注意:
|
|
498
527
|
|
|
499
528
|
- `remote.host` 写成别名后,dx 仍会显式传入 `remote.user` 和 `remote.port`;如果这两个值与 `~/.ssh/config` 中的 `User` / `Port` 不一致,命令行参数会覆盖 SSH config。
|
|
@@ -80,6 +80,22 @@ function requireRemoteBaseDir(value, fieldPath) {
|
|
|
80
80
|
return baseDir.replace(/\/+$/, '') || '/'
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
function resolveRemoteConfig(remoteConfig, environment) {
|
|
84
|
+
if (!remoteConfig || typeof remoteConfig !== 'object') {
|
|
85
|
+
return null
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (typeof remoteConfig.host === 'string') {
|
|
89
|
+
return remoteConfig
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const selected = remoteConfig[environment]
|
|
93
|
+
if (!selected || typeof selected !== 'object') {
|
|
94
|
+
throw new Error(`缺少必填配置: remote.${environment}`)
|
|
95
|
+
}
|
|
96
|
+
return selected
|
|
97
|
+
}
|
|
98
|
+
|
|
83
99
|
export function resolveBackendDeployConfig({ cli, targetConfig, environment, flags = {} }) {
|
|
84
100
|
const deployConfig = targetConfig?.backendDeploy
|
|
85
101
|
if (!deployConfig || typeof deployConfig !== 'object') {
|
|
@@ -89,7 +105,7 @@ export function resolveBackendDeployConfig({ cli, targetConfig, environment, fla
|
|
|
89
105
|
const buildConfig = deployConfig.build || {}
|
|
90
106
|
const runtimeConfig = deployConfig.runtime || {}
|
|
91
107
|
const artifactConfig = deployConfig.artifact || {}
|
|
92
|
-
const remoteConfig = deployConfig.remote
|
|
108
|
+
const remoteConfig = resolveRemoteConfig(deployConfig.remote, environment)
|
|
93
109
|
const startupConfig = deployConfig.startup || {}
|
|
94
110
|
const runConfig = deployConfig.deploy || {}
|
|
95
111
|
const verifyConfig = deployConfig.verify || {}
|