@weotro/dx 0.1.0
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/LICENSE +21 -0
- package/README.md +755 -0
- package/bin/dx-with-version-env.js +8 -0
- package/bin/dx.js +187 -0
- package/lib/artifact-deploy/artifact-builder.js +144 -0
- package/lib/artifact-deploy/config.js +180 -0
- package/lib/artifact-deploy/remote-script.js +301 -0
- package/lib/artifact-deploy/remote-transport.js +86 -0
- package/lib/artifact-deploy.js +70 -0
- package/lib/backend-artifact-deploy/artifact-builder.js +267 -0
- package/lib/backend-artifact-deploy/config.js +218 -0
- package/lib/backend-artifact-deploy/path-utils.js +18 -0
- package/lib/backend-artifact-deploy/remote-phases.js +14 -0
- package/lib/backend-artifact-deploy/remote-result.js +44 -0
- package/lib/backend-artifact-deploy/remote-script.js +507 -0
- package/lib/backend-artifact-deploy/remote-transport.js +123 -0
- package/lib/backend-artifact-deploy/rollback.js +5 -0
- package/lib/backend-artifact-deploy/runtime-package.js +46 -0
- package/lib/backend-artifact-deploy.js +91 -0
- package/lib/backend-package.js +674 -0
- package/lib/cli/args.js +38 -0
- package/lib/cli/command-result.js +1 -0
- package/lib/cli/commands/contracts.js +60 -0
- package/lib/cli/commands/core.js +533 -0
- package/lib/cli/commands/db.js +231 -0
- package/lib/cli/commands/deploy.js +175 -0
- package/lib/cli/commands/env.js +120 -0
- package/lib/cli/commands/export.js +39 -0
- package/lib/cli/commands/package.js +22 -0
- package/lib/cli/commands/release.js +55 -0
- package/lib/cli/commands/stack.js +427 -0
- package/lib/cli/commands/start.js +58 -0
- package/lib/cli/commands/worktree.js +145 -0
- package/lib/cli/dx-cli.js +1072 -0
- package/lib/cli/flags.js +123 -0
- package/lib/cli/help-model.js +222 -0
- package/lib/cli/help-renderer.js +137 -0
- package/lib/cli/help-schema.js +552 -0
- package/lib/cli/help.js +141 -0
- package/lib/cli/index.js +4 -0
- package/lib/cli/nx-command.js +13 -0
- package/lib/codex-initial.js +271 -0
- package/lib/confirm.js +213 -0
- package/lib/env-policy.js +134 -0
- package/lib/env-profile.js +435 -0
- package/lib/env.js +261 -0
- package/lib/exec.js +692 -0
- package/lib/logger.js +239 -0
- package/lib/nx-ignore.js +45 -0
- package/lib/run-with-version-env.js +163 -0
- package/lib/sdk-build.js +424 -0
- package/lib/start-dev.js +401 -0
- package/lib/telegram-webhook.js +431 -0
- package/lib/validate-env.js +317 -0
- package/lib/vercel-deploy.js +549 -0
- package/lib/version.js +14 -0
- package/lib/worktree.js +1052 -0
- package/package.json +45 -0
- package/skills/create-issue/SKILL.md +90 -0
- package/skills/delivering-design-handoff/SKILL.md +290 -0
- package/skills/doctor/SKILL.md +76 -0
- package/skills/gh-dependabot-cleanup/SKILL.md +54 -0
- package/skills/gh-dependabot-cleanup/agents/openai.yaml +7 -0
- package/skills/git-release/SKILL.md +194 -0
- package/skills/git-release/agents/openai.yaml +7 -0
- package/skills/online-debug-guard/SKILL.md +111 -0
- package/skills/ship-issue-pr/SKILL.md +676 -0
- package/skills/stagewise-ui-debugging/SKILL.md +48 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { buildBackendArtifact } from './backend-artifact-deploy/artifact-builder.js'
|
|
2
|
+
import { resolveBackendDeployConfig } from './backend-artifact-deploy/config.js'
|
|
3
|
+
import { deployBackendArtifactRemotely } from './backend-artifact-deploy/remote-transport.js'
|
|
4
|
+
import { logger as defaultLogger } from './logger.js'
|
|
5
|
+
import { access } from 'node:fs/promises'
|
|
6
|
+
import { basename, resolve } from 'node:path'
|
|
7
|
+
|
|
8
|
+
export async function loadBackendArtifact(config, artifactPath, deps = {}) {
|
|
9
|
+
const ensureReadable = deps.ensureArtifactReadable || access
|
|
10
|
+
const bundlePath = resolve(config.projectRoot, artifactPath)
|
|
11
|
+
await ensureReadable(bundlePath)
|
|
12
|
+
|
|
13
|
+
const bundleFile = basename(bundlePath)
|
|
14
|
+
const prefix = `${config.artifact.bundleName}-v`
|
|
15
|
+
if (!bundleFile.startsWith(prefix) || !bundleFile.endsWith('.tgz')) {
|
|
16
|
+
throw new Error(`制品文件名必须匹配 ${prefix}<version>-<timestamp>.tgz`)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const versionTag = bundleFile.slice(prefix.length, -'.tgz'.length)
|
|
20
|
+
if (!versionTag) throw new Error('无法从制品文件名解析版本')
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
bundlePath,
|
|
24
|
+
versionName: `backend-v${versionTag}`,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function printSuccessfulDeploySummary(result, logger) {
|
|
29
|
+
const summary = result?.summary
|
|
30
|
+
if (!summary) return
|
|
31
|
+
|
|
32
|
+
logger.success(`后端部署成功: ${summary.releaseName || 'unknown-release'}`)
|
|
33
|
+
if (summary.currentRelease) {
|
|
34
|
+
logger.info(`[deploy-summary] current=${summary.currentRelease}`)
|
|
35
|
+
}
|
|
36
|
+
if (summary.serviceName || summary.serviceStatus) {
|
|
37
|
+
logger.info(
|
|
38
|
+
`[deploy-summary] service=${summary.serviceName || 'unknown'} status=${summary.serviceStatus || 'unknown'}`,
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
if (summary.appEnv || summary.nodeEnv) {
|
|
42
|
+
logger.info(
|
|
43
|
+
`[deploy-summary] APP_ENV=${summary.appEnv || '<empty>'} NODE_ENV=${summary.nodeEnv || '<empty>'}`,
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
if (summary.healthUrl) {
|
|
47
|
+
logger.info(`[deploy-summary] health=${summary.healthUrl}`)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function runBackendArtifactDeploy({
|
|
52
|
+
cli,
|
|
53
|
+
target,
|
|
54
|
+
args,
|
|
55
|
+
environment,
|
|
56
|
+
deps = {},
|
|
57
|
+
}) {
|
|
58
|
+
const logger = deps.logger || defaultLogger
|
|
59
|
+
const resolveConfig = deps.resolveConfig || resolveBackendDeployConfig
|
|
60
|
+
const buildArtifact = deps.buildArtifact || buildBackendArtifact
|
|
61
|
+
const deployRemotely =
|
|
62
|
+
deps.deployRemotely || deployBackendArtifactRemotely
|
|
63
|
+
|
|
64
|
+
const targetConfig = cli?.commands?.deploy?.[target]
|
|
65
|
+
const config = resolveConfig({
|
|
66
|
+
cli,
|
|
67
|
+
targetConfig,
|
|
68
|
+
environment,
|
|
69
|
+
flags: cli?.flags || {},
|
|
70
|
+
args,
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
const artifactPath = cli?.flags?.artifact
|
|
74
|
+
if (cli?.flags?.buildOnly && artifactPath) {
|
|
75
|
+
throw new Error('--build-only 与 --artifact 不能同时使用')
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const loadArtifact = deps.loadArtifact || loadBackendArtifact
|
|
79
|
+
const bundle = artifactPath
|
|
80
|
+
? await loadArtifact(config, artifactPath, deps)
|
|
81
|
+
: await buildArtifact(config, deps)
|
|
82
|
+
if (cli?.flags?.buildOnly) {
|
|
83
|
+
return bundle
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const result = await deployRemotely(config, bundle, deps)
|
|
87
|
+
if (result?.ok) {
|
|
88
|
+
printSuccessfulDeploySummary(result, logger)
|
|
89
|
+
}
|
|
90
|
+
return result
|
|
91
|
+
}
|