@weotro/dx 0.1.21 → 0.2.1

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.
Files changed (75) hide show
  1. package/README.md +78 -766
  2. package/bin/dx.js +100 -182
  3. package/example/.env.development +1 -0
  4. package/example/README.md +24 -0
  5. package/example/dx/scripts/build +2 -0
  6. package/example/dx/scripts/db +2 -0
  7. package/example/dx/scripts/deploy +2 -0
  8. package/example/dx/scripts/setup +2 -0
  9. package/example/dx/scripts/start +12 -0
  10. package/example/dx/scripts/test +2 -0
  11. package/lib/env.js +40 -257
  12. package/lib/logger.js +5 -238
  13. package/lib/setup.js +72 -0
  14. package/package.json +27 -13
  15. package/skills/ask_3th/SKILL.md +2 -0
  16. package/skills/delegate_3th/SKILL.md +4 -2
  17. package/skills/delegate_3th/scripts/delegate_3th.py +37 -41
  18. package/skills/delegate_3th/scripts/test_delegate_3th.py +43 -17
  19. package/skills/dx-adopt/SKILL.md +88 -0
  20. package/skills/dx-adopt/agents/openai.yaml +2 -0
  21. package/skills/dx-adopt/references/dx-0.2-contract.md +95 -0
  22. package/skills/dx-adopt/references/migrate-0.1.md +48 -0
  23. package/bin/dx-with-version-env.js +0 -8
  24. package/lib/artifact-deploy/artifact-builder.js +0 -144
  25. package/lib/artifact-deploy/config.js +0 -180
  26. package/lib/artifact-deploy/remote-script.js +0 -301
  27. package/lib/artifact-deploy/remote-transport.js +0 -86
  28. package/lib/artifact-deploy.js +0 -70
  29. package/lib/backend-artifact-deploy/artifact-builder.js +0 -267
  30. package/lib/backend-artifact-deploy/config.js +0 -218
  31. package/lib/backend-artifact-deploy/path-utils.js +0 -18
  32. package/lib/backend-artifact-deploy/remote-phases.js +0 -14
  33. package/lib/backend-artifact-deploy/remote-result.js +0 -44
  34. package/lib/backend-artifact-deploy/remote-script.js +0 -507
  35. package/lib/backend-artifact-deploy/remote-transport.js +0 -123
  36. package/lib/backend-artifact-deploy/rollback.js +0 -5
  37. package/lib/backend-artifact-deploy/runtime-package.js +0 -46
  38. package/lib/backend-artifact-deploy.js +0 -91
  39. package/lib/backend-package.js +0 -674
  40. package/lib/cli/args.js +0 -38
  41. package/lib/cli/command-result.js +0 -1
  42. package/lib/cli/commands/contracts.js +0 -60
  43. package/lib/cli/commands/core.js +0 -533
  44. package/lib/cli/commands/db.js +0 -231
  45. package/lib/cli/commands/deploy.js +0 -175
  46. package/lib/cli/commands/env.js +0 -120
  47. package/lib/cli/commands/export.js +0 -39
  48. package/lib/cli/commands/package.js +0 -22
  49. package/lib/cli/commands/release.js +0 -55
  50. package/lib/cli/commands/stack.js +0 -427
  51. package/lib/cli/commands/start.js +0 -58
  52. package/lib/cli/commands/worktree.js +0 -145
  53. package/lib/cli/dx-cli.js +0 -1098
  54. package/lib/cli/flags.js +0 -123
  55. package/lib/cli/help-model.js +0 -234
  56. package/lib/cli/help-renderer.js +0 -137
  57. package/lib/cli/help-schema.js +0 -552
  58. package/lib/cli/help.js +0 -141
  59. package/lib/cli/index.js +0 -4
  60. package/lib/cli/nx-command.js +0 -13
  61. package/lib/confirm.js +0 -213
  62. package/lib/env-policy.js +0 -134
  63. package/lib/env-profile.js +0 -531
  64. package/lib/exec.js +0 -698
  65. package/lib/nx-ignore.js +0 -45
  66. package/lib/run-with-version-env.js +0 -163
  67. package/lib/sdk-build.js +0 -424
  68. package/lib/start-dev.js +0 -401
  69. package/lib/telegram-webhook.js +0 -431
  70. package/lib/validate-env.js +0 -317
  71. package/lib/vercel-deploy.js +0 -549
  72. package/lib/worktree.js +0 -1052
  73. package/skills/delegate_3th/scripts/__pycache__/delegate_3th.cpython-314.pyc +0 -0
  74. package/skills/delegate_3th/scripts/__pycache__/delegate_cc.cpython-314.pyc +0 -0
  75. package/skills/delegate_3th/scripts/__pycache__/test_delegate_cc.cpython-314.pyc +0 -0
@@ -1,91 +0,0 @@
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
- }