@ranger1/dx 0.1.8 → 0.1.9
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 +7 -0
- package/lib/vercel-deploy.js +3 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -152,6 +152,13 @@ dx lint
|
|
|
152
152
|
dx test e2e backend
|
|
153
153
|
```
|
|
154
154
|
|
|
155
|
+
## deploy 行为说明
|
|
156
|
+
|
|
157
|
+
从 `0.1.9` 起,`dx deploy <target>` 不再在 dx 内部硬编码执行任何 `nx build`/`sdk build` 等前置步骤。
|
|
158
|
+
|
|
159
|
+
- 需要的前置构建(例如 `shared`、`api-contracts`、OpenAPI 导出、后端构建等)应由项目自己的 Nx 依赖图(`dependsOn`/项目依赖)或 Vercel 的 `buildCommand` 负责。
|
|
160
|
+
- 这样 dx deploy 不会强依赖 `apps/sdk` 等目录结构,更容易适配不同 monorepo。
|
|
161
|
+
|
|
155
162
|
## 给 Nx target 注入版本信息(可选)
|
|
156
163
|
|
|
157
164
|
本包提供 `dx-with-version-env`,用于在 `nx:run-commands` 中注入版本/sha/构建时间等环境变量:
|
package/lib/vercel-deploy.js
CHANGED
|
@@ -79,35 +79,9 @@ export async function deployToVercel(target, options = {}) {
|
|
|
79
79
|
return
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
logger.step('编译 backend...')
|
|
86
|
-
const backendConfig = environment === 'production' || environment === 'staging'
|
|
87
|
-
? 'production'
|
|
88
|
-
: 'development'
|
|
89
|
-
await execManager.executeCommand(`npx nx build backend --configuration=${backendConfig}`, {
|
|
90
|
-
app: 'backend',
|
|
91
|
-
flags: {
|
|
92
|
-
...(environment === 'production' ? { prod: true } : {}),
|
|
93
|
-
...(environment === 'staging' ? { staging: true } : {}),
|
|
94
|
-
...(environment === 'development' ? { dev: true } : {}),
|
|
95
|
-
},
|
|
96
|
-
})
|
|
97
|
-
logger.success('backend 编译成功')
|
|
98
|
-
|
|
99
|
-
logger.step('编译 sdk...')
|
|
100
|
-
const { runSdkBuild } = await import('./sdk-build.js')
|
|
101
|
-
const sdkArgs = environment === 'production' ? [] : ['dev']
|
|
102
|
-
await runSdkBuild(sdkArgs)
|
|
103
|
-
logger.success('sdk 编译成功')
|
|
104
|
-
} catch (error) {
|
|
105
|
-
const message = error?.message || String(error)
|
|
106
|
-
logger.error(`编译失败: ${message}`)
|
|
107
|
-
logger.error('部署已终止,请先修复编译错误')
|
|
108
|
-
process.exitCode = 1
|
|
109
|
-
return
|
|
110
|
-
}
|
|
82
|
+
// deploy 不再硬编码任何 Nx 构建步骤。
|
|
83
|
+
// - 前置构建/生成(shared/contracts/backend 等)应由项目自己的 Nx 依赖图或 Vercel buildCommand 负责。
|
|
84
|
+
// - 这样 dx deploy 能兼容不同 monorepo 布局(不强依赖 apps/sdk 等目录)。
|
|
111
85
|
|
|
112
86
|
// 映射环境标识:development -> dev, staging -> staging, production -> prod
|
|
113
87
|
const envMap = {
|