@ranger1/dx 0.1.81 → 0.1.82
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
|
@@ -362,6 +362,49 @@ dx deploy backend --prod --skip-migration
|
|
|
362
362
|
|
|
363
363
|
- 生成的 release `package.json` 默认只保留运行时依赖;如果应用把 `prisma` 放在 `devDependencies`,dx 会自动把它提升进 release 依赖,保证远端 `prisma generate` / `prisma migrate deploy` 可执行。
|
|
364
364
|
- 打包前会递归扫描整个 staged payload;任意层级出现 `.env*` 文件都会直接失败,避免把环境文件误打进制品。
|
|
365
|
+
- 所有本地路径字段都会被解析为相对项目根目录,并且必须留在项目根目录内;例如 `build.distDir`、`runtime.prismaSchemaDir`、`artifact.outputDir` 不能通过 `../` 逃逸到仓库外。
|
|
366
|
+
- `remote.baseDir` 必须是绝对路径,并且只能包含 `/`、字母、数字、`.`、`_`、`-`;不要使用空格或 shell 特殊字符。
|
|
367
|
+
|
|
368
|
+
SSH 认证说明:
|
|
369
|
+
|
|
370
|
+
- `dx deploy backend` 当前直接调用系统 `ssh` / `scp`,不会单独解析 `sshKey`、`identityFile` 之类的 dx 配置项。
|
|
371
|
+
- 因此,发布使用哪把私钥,取决于本机 OpenSSH 的默认认证行为,例如 `ssh-agent`、`~/.ssh/config`、默认私钥文件等。
|
|
372
|
+
- 如果你已经在 `~/.ssh/config` 中配置了主机别名(例如 `Host ai-staging`),推荐直接把 `backendDeploy.remote.host` 写成这个别名,让 OpenSSH 自动匹配对应的 `HostName`、`User`、`Port`、`IdentityFile`。
|
|
373
|
+
|
|
374
|
+
例如本机 `~/.ssh/config`:
|
|
375
|
+
|
|
376
|
+
```sshconfig
|
|
377
|
+
Host ai-staging
|
|
378
|
+
HostName 1.2.3.4
|
|
379
|
+
User deploy
|
|
380
|
+
Port 22
|
|
381
|
+
IdentityFile ~/.ssh/your_staging_key
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
对应的 `dx/config/commands.json`:
|
|
385
|
+
|
|
386
|
+
```json
|
|
387
|
+
{
|
|
388
|
+
"deploy": {
|
|
389
|
+
"backend": {
|
|
390
|
+
"internal": "backend-artifact-deploy",
|
|
391
|
+
"backendDeploy": {
|
|
392
|
+
"remote": {
|
|
393
|
+
"host": "ai-staging",
|
|
394
|
+
"port": 22,
|
|
395
|
+
"user": "deploy",
|
|
396
|
+
"baseDir": "/srv/example-app"
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
注意:
|
|
405
|
+
|
|
406
|
+
- `remote.host` 写成别名后,dx 仍会显式传入 `remote.user` 和 `remote.port`;如果这两个值与 `~/.ssh/config` 中的 `User` / `Port` 不一致,命令行参数会覆盖 SSH config。
|
|
407
|
+
- 最稳妥的做法是让 `remote.user`、`remote.port` 与 `~/.ssh/config` 保持一致,或者都统一以 SSH config 中的值为准后再同步到 dx 配置。
|
|
365
408
|
|
|
366
409
|
## 依赖关系约定
|
|
367
410
|
|
|
@@ -32,12 +32,25 @@ async function defaultReadVersion(versionFile) {
|
|
|
32
32
|
return String(pkg.version || '').trim()
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
export function buildFlagsForEnvironment(environment) {
|
|
36
|
+
switch (environment || 'development') {
|
|
37
|
+
case 'production':
|
|
38
|
+
return { prod: true }
|
|
39
|
+
case 'staging':
|
|
40
|
+
return { staging: true }
|
|
41
|
+
case 'development':
|
|
42
|
+
default:
|
|
43
|
+
return { dev: true }
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function defaultRunBuild(build, environment = 'development') {
|
|
36
48
|
if (!build?.command) {
|
|
37
49
|
throw new Error('缺少构建命令: build.command')
|
|
38
50
|
}
|
|
39
51
|
await execManager.executeCommand(build.command, {
|
|
40
52
|
app: build.app || undefined,
|
|
53
|
+
flags: buildFlagsForEnvironment(environment),
|
|
41
54
|
})
|
|
42
55
|
}
|
|
43
56
|
|
|
@@ -217,7 +230,7 @@ export async function buildBackendArtifact(config, deps = {}) {
|
|
|
217
230
|
const checksumPath = resolveWithinBase(outputDir, names.checksumName, 'checksumPath')
|
|
218
231
|
const bundlePath = resolveWithinBase(outputDir, names.bundleName, 'bundlePath')
|
|
219
232
|
|
|
220
|
-
await runBuild(config.build)
|
|
233
|
+
await runBuild(config.build, config.environment)
|
|
221
234
|
await prepareOutputDir(outputDir)
|
|
222
235
|
await stageFiles({
|
|
223
236
|
config,
|