@b64hub/sfpm-cli 0.1.0 → 0.3.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.
Files changed (268) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +406 -202
  3. package/dist/commands/add.d.ts +10 -0
  4. package/dist/commands/add.js +50 -0
  5. package/dist/commands/add.js.map +1 -0
  6. package/dist/commands/bootstrap.d.ts +39 -5
  7. package/dist/commands/bootstrap.js +463 -167
  8. package/dist/commands/bootstrap.js.map +1 -1
  9. package/dist/commands/build/index.d.ts +69 -0
  10. package/dist/commands/build/index.js +416 -0
  11. package/dist/commands/build/index.js.map +1 -0
  12. package/dist/commands/build/status.d.ts +3 -4
  13. package/dist/commands/build/status.js +13 -162
  14. package/dist/commands/build/status.js.map +1 -1
  15. package/dist/commands/deploy/artifact.d.ts +15 -13
  16. package/dist/commands/deploy/artifact.js +31 -88
  17. package/dist/commands/deploy/artifact.js.map +1 -1
  18. package/dist/commands/deploy/index.d.ts +50 -0
  19. package/dist/commands/deploy/index.js +150 -0
  20. package/dist/commands/deploy/index.js.map +1 -0
  21. package/dist/commands/dev/pool-list-replay.d.ts +11 -0
  22. package/dist/commands/dev/pool-list-replay.js +19 -0
  23. package/dist/commands/dev/pool-list-replay.js.map +1 -0
  24. package/dist/commands/dev/pool-replay.d.ts +16 -0
  25. package/dist/commands/dev/pool-replay.js +81 -0
  26. package/dist/commands/dev/pool-replay.js.map +1 -0
  27. package/dist/commands/dev/replay.d.ts +21 -0
  28. package/dist/commands/dev/replay.js +103 -0
  29. package/dist/commands/dev/replay.js.map +1 -0
  30. package/dist/commands/install.d.ts +10 -4
  31. package/dist/commands/install.js +60 -71
  32. package/dist/commands/install.js.map +1 -1
  33. package/dist/commands/package/create.d.ts +31 -0
  34. package/dist/commands/package/create.js +270 -0
  35. package/dist/commands/package/create.js.map +1 -0
  36. package/dist/commands/pool/delete.d.ts +4 -5
  37. package/dist/commands/pool/delete.js +64 -52
  38. package/dist/commands/pool/delete.js.map +1 -1
  39. package/dist/commands/pool/fetch.d.ts +5 -4
  40. package/dist/commands/pool/fetch.js +90 -59
  41. package/dist/commands/pool/fetch.js.map +1 -1
  42. package/dist/commands/pool/fill.d.ts +22 -0
  43. package/dist/commands/pool/fill.js +171 -0
  44. package/dist/commands/pool/fill.js.map +1 -0
  45. package/dist/commands/pool/list.d.ts +3 -6
  46. package/dist/commands/pool/list.js +60 -58
  47. package/dist/commands/pool/list.js.map +1 -1
  48. package/dist/commands/{project.d.ts → project/index.d.ts} +1 -1
  49. package/dist/commands/{project.js → project/index.js} +6 -6
  50. package/dist/commands/project/index.js.map +1 -0
  51. package/dist/commands/project/init/turbo.js +3 -11
  52. package/dist/commands/project/init/turbo.js.map +1 -1
  53. package/dist/commands/project/sync.js +2 -10
  54. package/dist/commands/project/sync.js.map +1 -1
  55. package/dist/commands/project/version/bump.js +12 -13
  56. package/dist/commands/project/version/bump.js.map +1 -1
  57. package/dist/commands/publish.d.ts +14 -0
  58. package/dist/commands/publish.js +60 -0
  59. package/dist/commands/publish.js.map +1 -0
  60. package/dist/commands/watch/cancel.d.ts +12 -0
  61. package/dist/commands/watch/cancel.js +44 -0
  62. package/dist/commands/watch/cancel.js.map +1 -0
  63. package/dist/commands/watch/clean.d.ts +10 -0
  64. package/dist/commands/watch/clean.js +29 -0
  65. package/dist/commands/watch/clean.js.map +1 -0
  66. package/dist/commands/watch/status.d.ts +13 -0
  67. package/dist/commands/watch/status.js +137 -0
  68. package/dist/commands/watch/status.js.map +1 -0
  69. package/dist/logger.d.ts +80 -0
  70. package/dist/logger.js +143 -0
  71. package/dist/logger.js.map +1 -0
  72. package/dist/sfpm-command.d.ts +56 -3
  73. package/dist/sfpm-command.js +146 -18
  74. package/dist/sfpm-command.js.map +1 -1
  75. package/dist/types/bootstrap.d.ts +67 -0
  76. package/dist/types/bootstrap.js +78 -0
  77. package/dist/types/bootstrap.js.map +1 -0
  78. package/dist/ui/adapters/build-event-bridge.d.ts +19 -0
  79. package/dist/ui/adapters/build-event-bridge.js +138 -0
  80. package/dist/ui/adapters/build-event-bridge.js.map +1 -0
  81. package/dist/ui/adapters/install-event-bridge.d.ts +9 -0
  82. package/dist/ui/adapters/install-event-bridge.js +91 -0
  83. package/dist/ui/adapters/install-event-bridge.js.map +1 -0
  84. package/dist/ui/adapters/pino-bridge.d.ts +11 -0
  85. package/dist/ui/adapters/pino-bridge.js +24 -0
  86. package/dist/ui/adapters/pino-bridge.js.map +1 -0
  87. package/dist/ui/adapters/pool-delete-event-bridge.d.ts +12 -0
  88. package/dist/ui/adapters/pool-delete-event-bridge.js +18 -0
  89. package/dist/ui/adapters/pool-delete-event-bridge.js.map +1 -0
  90. package/dist/ui/adapters/pool-fill-event-bridge.d.ts +9 -0
  91. package/dist/ui/adapters/pool-fill-event-bridge.js +51 -0
  92. package/dist/ui/adapters/pool-fill-event-bridge.js.map +1 -0
  93. package/dist/ui/apps/BuildApp.d.ts +11 -0
  94. package/dist/ui/apps/BuildApp.js +32 -0
  95. package/dist/ui/apps/BuildApp.js.map +1 -0
  96. package/dist/ui/apps/PoolDeleteApp.d.ts +6 -0
  97. package/dist/ui/apps/PoolDeleteApp.js +77 -0
  98. package/dist/ui/apps/PoolDeleteApp.js.map +1 -0
  99. package/dist/ui/apps/PoolFillApp.d.ts +7 -0
  100. package/dist/ui/apps/PoolFillApp.js +107 -0
  101. package/dist/ui/apps/PoolFillApp.js.map +1 -0
  102. package/dist/ui/apps/PoolListApp.d.ts +14 -0
  103. package/dist/ui/apps/PoolListApp.js +33 -0
  104. package/dist/ui/apps/PoolListApp.js.map +1 -0
  105. package/dist/ui/components/OrchestrationView.d.ts +20 -0
  106. package/dist/ui/components/OrchestrationView.js +59 -0
  107. package/dist/ui/components/OrchestrationView.js.map +1 -0
  108. package/dist/ui/components/PackageRow.d.ts +130 -0
  109. package/dist/ui/components/PackageRow.js +80 -0
  110. package/dist/ui/components/PackageRow.js.map +1 -0
  111. package/dist/ui/components/ValidationView.d.ts +4 -0
  112. package/dist/ui/components/ValidationView.js +9 -0
  113. package/dist/ui/components/ValidationView.js.map +1 -0
  114. package/dist/ui/components/base/Divider.d.ts +4 -0
  115. package/dist/ui/components/base/Divider.js +9 -0
  116. package/dist/ui/components/base/Divider.js.map +1 -0
  117. package/dist/ui/components/base/ElapsedTime.d.ts +14 -0
  118. package/dist/ui/components/base/ElapsedTime.js +19 -0
  119. package/dist/ui/components/base/ElapsedTime.js.map +1 -0
  120. package/dist/ui/components/base/Footer.d.ts +58 -0
  121. package/dist/ui/components/base/Footer.js +59 -0
  122. package/dist/ui/components/base/Footer.js.map +1 -0
  123. package/dist/ui/components/base/GradientBar.d.ts +7 -0
  124. package/dist/ui/components/base/GradientBar.js +19 -0
  125. package/dist/ui/components/base/GradientBar.js.map +1 -0
  126. package/dist/ui/components/base/OrgBadge.d.ts +8 -0
  127. package/dist/ui/components/base/OrgBadge.js +10 -0
  128. package/dist/ui/components/base/OrgBadge.js.map +1 -0
  129. package/dist/ui/components/base/StatusIcon.d.ts +4 -0
  130. package/dist/ui/components/base/StatusIcon.js +22 -0
  131. package/dist/ui/components/base/StatusIcon.js.map +1 -0
  132. package/dist/ui/components/pool/OrgRow.d.ts +17 -0
  133. package/dist/ui/components/pool/OrgRow.js +37 -0
  134. package/dist/ui/components/pool/OrgRow.js.map +1 -0
  135. package/dist/ui/components/pool/PoolOrgRow.d.ts +16 -0
  136. package/dist/ui/components/pool/PoolOrgRow.js +44 -0
  137. package/dist/ui/components/pool/PoolOrgRow.js.map +1 -0
  138. package/dist/ui/connect-devhub.d.ts +41 -0
  139. package/dist/ui/connect-devhub.js +52 -0
  140. package/dist/ui/connect-devhub.js.map +1 -0
  141. package/dist/ui/fixtures/happy-path.d.ts +85 -0
  142. package/dist/ui/fixtures/happy-path.js +62 -0
  143. package/dist/ui/fixtures/happy-path.js.map +1 -0
  144. package/dist/ui/fixtures/large-scale.d.ts +19 -0
  145. package/dist/ui/fixtures/large-scale.js +140 -0
  146. package/dist/ui/fixtures/large-scale.js.map +1 -0
  147. package/dist/ui/fixtures/partial-failure.d.ts +71 -0
  148. package/dist/ui/fixtures/partial-failure.js +21 -0
  149. package/dist/ui/fixtures/partial-failure.js.map +1 -0
  150. package/dist/ui/fixtures/pool-happy-path.d.ts +14 -0
  151. package/dist/ui/fixtures/pool-happy-path.js +74 -0
  152. package/dist/ui/fixtures/pool-happy-path.js.map +1 -0
  153. package/dist/ui/fixtures/pool-list.d.ts +6 -0
  154. package/dist/ui/fixtures/pool-list.js +44 -0
  155. package/dist/ui/fixtures/pool-list.js.map +1 -0
  156. package/dist/ui/fixtures/pool-partial-failure.d.ts +15 -0
  157. package/dist/ui/fixtures/pool-partial-failure.js +86 -0
  158. package/dist/ui/fixtures/pool-partial-failure.js.map +1 -0
  159. package/dist/ui/hooks/use-event-bus-wiring.d.ts +7 -0
  160. package/dist/ui/hooks/use-event-bus-wiring.js +32 -0
  161. package/dist/ui/hooks/use-event-bus-wiring.js.map +1 -0
  162. package/dist/ui/hooks/use-term-width.d.ts +2 -0
  163. package/dist/ui/hooks/use-term-width.js +7 -0
  164. package/dist/ui/hooks/use-term-width.js.map +1 -0
  165. package/dist/ui/renderers/run-orchestrator-plain.d.ts +11 -0
  166. package/dist/ui/renderers/run-orchestrator-plain.js +47 -0
  167. package/dist/ui/renderers/run-orchestrator-plain.js.map +1 -0
  168. package/dist/ui/renderers/run-orchestrator.d.ts +25 -0
  169. package/dist/ui/renderers/run-orchestrator.js +17 -0
  170. package/dist/ui/renderers/run-orchestrator.js.map +1 -0
  171. package/dist/ui/renderers/run-pool-delete-plain.d.ts +12 -0
  172. package/dist/ui/renderers/run-pool-delete-plain.js +31 -0
  173. package/dist/ui/renderers/run-pool-delete-plain.js.map +1 -0
  174. package/dist/ui/renderers/run-pool-delete.d.ts +12 -0
  175. package/dist/ui/renderers/run-pool-delete.js +20 -0
  176. package/dist/ui/renderers/run-pool-delete.js.map +1 -0
  177. package/dist/ui/renderers/run-pool-fill-plain.d.ts +10 -0
  178. package/dist/ui/renderers/run-pool-fill-plain.js +60 -0
  179. package/dist/ui/renderers/run-pool-fill-plain.js.map +1 -0
  180. package/dist/ui/renderers/run-pool-fill.d.ts +16 -0
  181. package/dist/ui/renderers/run-pool-fill.js +24 -0
  182. package/dist/ui/renderers/run-pool-fill.js.map +1 -0
  183. package/dist/ui/renderers/run-pool-list.d.ts +3 -0
  184. package/dist/ui/renderers/run-pool-list.js +7 -0
  185. package/dist/ui/renderers/run-pool-list.js.map +1 -0
  186. package/dist/ui/state/adapters.d.ts +4 -0
  187. package/dist/ui/state/adapters.js +62 -0
  188. package/dist/ui/state/adapters.js.map +1 -0
  189. package/dist/ui/state/orchestration-reducer.d.ts +7 -0
  190. package/dist/ui/state/orchestration-reducer.js +150 -0
  191. package/dist/ui/state/orchestration-reducer.js.map +1 -0
  192. package/dist/ui/state/pool-delete-reducer.d.ts +37 -0
  193. package/dist/ui/state/pool-delete-reducer.js +47 -0
  194. package/dist/ui/state/pool-delete-reducer.js.map +1 -0
  195. package/dist/ui/state/pool-fill-reducer.d.ts +87 -0
  196. package/dist/ui/state/pool-fill-reducer.js +109 -0
  197. package/dist/ui/state/pool-fill-reducer.js.map +1 -0
  198. package/dist/ui/state/selectors.d.ts +18 -0
  199. package/dist/ui/state/selectors.js +36 -0
  200. package/dist/ui/state/selectors.js.map +1 -0
  201. package/dist/ui/state/types.d.ts +35 -0
  202. package/dist/ui/state/types.js +2 -0
  203. package/dist/ui/state/types.js.map +1 -0
  204. package/dist/ui/table.d.ts +4 -0
  205. package/dist/ui/table.js +33 -0
  206. package/dist/ui/table.js.map +1 -0
  207. package/dist/ui/utils/pool-utils.d.ts +6 -0
  208. package/dist/ui/utils/pool-utils.js +49 -0
  209. package/dist/ui/utils/pool-utils.js.map +1 -0
  210. package/dist/ui/utils/renderer-utils.d.ts +133 -0
  211. package/dist/ui/utils/renderer-utils.js +131 -0
  212. package/dist/ui/utils/renderer-utils.js.map +1 -0
  213. package/dist/ui/utils/theme.d.ts +12 -0
  214. package/dist/ui/utils/theme.js +4 -0
  215. package/dist/ui/utils/theme.js.map +1 -0
  216. package/dist/utils/package-resolver.d.ts +20 -0
  217. package/dist/utils/package-resolver.js +44 -0
  218. package/dist/utils/package-resolver.js.map +1 -0
  219. package/dist/utils/project-dir.d.ts +9 -0
  220. package/dist/utils/project-dir.js +13 -0
  221. package/dist/utils/project-dir.js.map +1 -0
  222. package/dist/utils/suppress.d.ts +13 -0
  223. package/dist/utils/suppress.js +29 -0
  224. package/dist/utils/suppress.js.map +1 -0
  225. package/dist/utils/validation-runner.js +69 -0
  226. package/dist/utils/validation-runner.js.map +1 -0
  227. package/dist/utils/watcher-runner.d.ts +1 -0
  228. package/dist/utils/watcher-runner.js +148 -0
  229. package/dist/utils/watcher-runner.js.map +1 -0
  230. package/dist/utils/watcher.d.ts +27 -0
  231. package/dist/utils/watcher.js +51 -0
  232. package/dist/utils/watcher.js.map +1 -0
  233. package/oclif.manifest.json +1507 -494
  234. package/package.json +23 -9
  235. package/dist/commands/build.d.ts +0 -30
  236. package/dist/commands/build.js +0 -228
  237. package/dist/commands/build.js.map +0 -1
  238. package/dist/commands/deploy.d.ts +0 -20
  239. package/dist/commands/deploy.js +0 -141
  240. package/dist/commands/deploy.js.map +0 -1
  241. package/dist/commands/hello/index.d.ts +0 -12
  242. package/dist/commands/hello/index.js +0 -20
  243. package/dist/commands/hello/index.js.map +0 -1
  244. package/dist/commands/hello/world.d.ts +0 -8
  245. package/dist/commands/hello/world.js +0 -15
  246. package/dist/commands/hello/world.js.map +0 -1
  247. package/dist/commands/pool/provision.d.ts +0 -22
  248. package/dist/commands/pool/provision.js +0 -115
  249. package/dist/commands/pool/provision.js.map +0 -1
  250. package/dist/commands/project.js.map +0 -1
  251. package/dist/ui/build-progress-renderer.d.ts +0 -98
  252. package/dist/ui/build-progress-renderer.js +0 -684
  253. package/dist/ui/build-progress-renderer.js.map +0 -1
  254. package/dist/ui/install-progress-renderer.d.ts +0 -112
  255. package/dist/ui/install-progress-renderer.js +0 -443
  256. package/dist/ui/install-progress-renderer.js.map +0 -1
  257. package/dist/ui/orchestration-listr.d.ts +0 -211
  258. package/dist/ui/orchestration-listr.js +0 -391
  259. package/dist/ui/orchestration-listr.js.map +0 -1
  260. package/dist/ui/pool-progress-renderer.d.ts +0 -68
  261. package/dist/ui/pool-progress-renderer.js +0 -298
  262. package/dist/ui/pool-progress-renderer.js.map +0 -1
  263. package/dist/ui/renderer-utils.d.ts +0 -68
  264. package/dist/ui/renderer-utils.js +0 -66
  265. package/dist/ui/renderer-utils.js.map +0 -1
  266. package/dist/utils/validation-watcher.js +0 -114
  267. package/dist/utils/validation-watcher.js.map +0 -1
  268. /package/dist/utils/{validation-watcher.d.ts → validation-runner.d.ts} +0 -0
@@ -1,23 +1,63 @@
1
- import { BootstrapTier, BuildOrchestrator, getPackagesForTier, InstallOrchestrator, PackageCreator, PackageService, ProjectService, } from '@b64hub/sfpm-core';
1
+ import { BuildOrchestrator, InstallOrchestrator, noopLogger, PackageManager, PackageService, ProjectService, stripScope, ValidationEventBus, ValidationResolver, WorkspaceProvider, } from '@b64hub/sfpm-core';
2
2
  import { confirm, select } from '@inquirer/prompts';
3
3
  import { Flags } from '@oclif/core';
4
4
  import { Org } from '@salesforce/core';
5
5
  import chalk from 'chalk';
6
6
  import fs from 'fs-extra';
7
7
  import { execSync } from 'node:child_process';
8
+ import EventEmitter from 'node:events';
9
+ import { createRequire } from 'node:module';
8
10
  import os from 'node:os';
9
11
  import path from 'node:path';
10
12
  import ora from 'ora';
11
13
  import SfpmCommand from '../sfpm-command.js';
12
- import { errorBox, infoBox, successBox, warningBox, } from '../ui/boxes.js';
13
- import { BuildProgressRenderer } from '../ui/build-progress-renderer.js';
14
- import { InstallProgressRenderer } from '../ui/install-progress-renderer.js';
14
+ import { BootstrapTier, getPackagesForTier, resolveAction, } from '../types/bootstrap.js';
15
+ import { attachBuildBridge } from '../ui/adapters/build-event-bridge.js';
16
+ import { attachInstallBridge } from '../ui/adapters/install-event-bridge.js';
17
+ import { errorBox, infoBox, successBox, } from '../ui/boxes.js';
18
+ import { connectDevHub } from '../ui/connect-devhub.js';
19
+ import { renderApp } from '../ui/renderers/run-orchestrator.js';
15
20
  const BOOTSTRAP_REPO = 'https://github.com/b64hub/sfpm-bootstrap';
21
+ /**
22
+ * Resolve sfpm packages from the CLI's own installation so the bootstrap
23
+ * repo's `sfpm.config.ts` can import them. The clone is a bare `git clone`
24
+ * with no `node_modules`, so nothing is resolvable from the config file
25
+ * itself. Packages the CLI doesn't have installed are skipped.
26
+ */
27
+ function bootstrapConfigAliases() {
28
+ const require = createRequire(import.meta.url);
29
+ const alias = {};
30
+ for (const name of ['@b64hub/sfpm-core', '@b64hub/sfpm-orgs', '@b64hub/sfpm-hooks', '@b64hub/sfpm-sfdmu']) {
31
+ try {
32
+ alias[name] = require.resolve(name);
33
+ }
34
+ catch {
35
+ // Not installed alongside this CLI — a config importing it will fail
36
+ // with jiti's own resolution error, which names the missing package.
37
+ }
38
+ }
39
+ return alias;
40
+ }
16
41
  const TIER_DESCRIPTIONS = {
17
42
  [BootstrapTier.Core]: 'sfpm-artifact only -- artifact tracking custom setting',
18
43
  [BootstrapTier.Full]: 'All packages -- adds artifact history & UI components',
19
44
  [BootstrapTier.Pool]: 'sfpm-artifact + sfpm-orgs -- adds scratch org & sandbox pooling',
20
45
  };
46
+ /**
47
+ * Fold `ValidationResolver.resolve()`'s per-package results down to just the
48
+ * failures, in the shape `buildPackages()`'s caller merges into the overall
49
+ * bootstrap `results` array. Exported as a pure function so it's testable
50
+ * without constructing a real `ValidationResolver`/`ProjectService`.
51
+ */
52
+ export function foldValidationFailures(validationResults) {
53
+ const failures = [];
54
+ for (const [packageName, validationResult] of validationResults) {
55
+ if (validationResult.status === 'failed') {
56
+ failures.push({ error: validationResult.error ?? 'Validation failed', packageName });
57
+ }
58
+ }
59
+ return failures;
60
+ }
21
61
  export default class Bootstrap extends SfpmCommand {
22
62
  static description = 'Bootstrap SFPM packages into a production org';
23
63
  static examples = [
@@ -27,9 +67,7 @@ export default class Bootstrap extends SfpmCommand {
27
67
  '<%= config.bin %> <%= command.id %> -o my-prod-org --force',
28
68
  ];
29
69
  static flags = {
30
- force: Flags.boolean({ char: 'f', description: 'force re-install even if packages are already installed' }),
31
- json: Flags.boolean({ description: 'output as JSON for CI/CD', exclusive: ['quiet'] }),
32
- quiet: Flags.boolean({ char: 'q', description: 'only show errors', exclusive: ['json'] }),
70
+ force: Flags.boolean({ char: 'f', description: 'force rebuild, re-promote, and re-install all packages' }),
33
71
  'target-org': Flags.string({ char: 'o', description: 'target org username (must also be a DevHub)', required: true }),
34
72
  tier: Flags.string({
35
73
  char: 't',
@@ -39,171 +77,189 @@ export default class Bootstrap extends SfpmCommand {
39
77
  };
40
78
  async execute() {
41
79
  const { flags } = await this.parse(Bootstrap);
42
- const mode = flags.json ? 'json' : flags.quiet ? 'quiet' : 'interactive';
43
- const isInteractive = mode === 'interactive';
44
- const logger = {
45
- debug: (msg) => this.debug(msg),
46
- error: (msg) => this.error(msg),
47
- info: (msg) => this.debug(msg),
48
- log: (msg) => this.log(msg),
49
- trace: (msg) => this.debug(msg),
50
- warn: (msg) => this.warn(msg),
80
+ const ctx = {
81
+ isInteractive: this.outputMode === 'interactive',
82
+ logger: this.sfpmLogger,
83
+ mode: this.outputMode,
84
+ targetOrg: flags['target-org'],
51
85
  };
52
- // ── Step 1: Select tier ─────────────────────────────────────────────
53
- const tier = await this.resolveTier(flags.tier, isInteractive);
86
+ const tier = await this.resolveTier(flags.tier, ctx.isInteractive);
54
87
  const selectedPackages = getPackagesForTier(tier);
55
88
  const packageNames = selectedPackages.map(p => p.name);
56
- if (isInteractive) {
89
+ if (ctx.isInteractive) {
57
90
  this.log(infoBox('Bootstrap', {
58
91
  Packages: packageNames.join(', '),
59
- 'Target Org': flags['target-org'],
92
+ 'Target Org': ctx.targetOrg,
60
93
  Tier: tier,
61
94
  }));
62
95
  }
63
- // ── Step 2: Clone bootstrap repo ────────────────────────────────────
64
- const tmpDir = await this.cloneRepo(isInteractive);
96
+ const tmpDir = await this.cloneRepo(ctx.isInteractive);
65
97
  try {
66
- // ── Step 3: Connect to org and verify DevHub ────────────────────
67
- const org = await this.connectToOrg(flags['target-org'], isInteractive);
68
- // ── Step 4: Check if packages are already installed ─────────────
69
- if (!flags.force) {
70
- const alreadyInstalled = await this.checkInstalledPackages(org, packageNames, logger);
71
- if (alreadyInstalled.length > 0) {
72
- if (isInteractive) {
73
- this.log(warningBox('Already Installed', {
74
- Hint: 'Use --force to re-install',
75
- Packages: alreadyInstalled.join(', '),
76
- }));
77
- }
78
- if (flags.json) {
79
- const result = {
80
- packages: alreadyInstalled.map(name => ({
81
- packageName: name, skipped: true, success: true,
82
- })),
83
- success: true,
84
- targetOrg: flags['target-org'],
85
- tier,
86
- };
87
- this.logJson(result);
88
- return result;
89
- }
90
- return;
91
- }
92
- }
93
- // ── Step 5: Ensure Package2 containers exist in DevHub ──────────
94
- const creator = new PackageCreator(org, logger);
95
- await creator.ensurePackages(selectedPackages, tmpDir, async (name) => {
96
- if (!isInteractive)
97
- return true;
98
- return confirm({
99
- default: true,
100
- message: `Package '${name}' does not exist in the DevHub. Create it?`,
101
- });
98
+ const { devhub: org } = await connectDevHub({
99
+ alias: ctx.targetOrg,
100
+ showSpinner: ctx.mode === 'interactive',
101
+ validate: [
102
+ {
103
+ label: 'Verifying DevHub status...',
104
+ async run(devhub) {
105
+ if (!await devhub.determineIfDevHubOrg()) {
106
+ throw new Error(`The target org '${ctx.targetOrg}' is not a DevHub. `
107
+ + 'Bootstrap requires a DevHub org to create and build packages. '
108
+ + 'Enable DevHub in Setup > Dev Hub or use a different org.');
109
+ }
110
+ },
111
+ },
112
+ ],
102
113
  });
103
- // ── Step 6: Load project from cloned repo ─────────────────────
104
- const projectService = await ProjectService.create(tmpDir);
105
- const projectConfig = projectService.getDefinitionProvider();
106
- const projectGraph = projectService.getProjectGraph();
107
- const sfpmConfig = projectService.getSfpmConfig();
108
- // ── Step 7: Build packages ────────────────────────────────────
109
- if (isInteractive) {
110
- this.log(chalk.bold('\nBuilding packages...\n'));
114
+ // ── 1. Resolve per-package status ──────────────────────────────
115
+ const statuses = await this.resolvePackageStatuses(org, selectedPackages, flags.force ?? false, ctx);
116
+ // If everything is up-to-date, short-circuit
117
+ if (statuses.every(s => s.action === 'skip')) {
118
+ return this.handleAllUpToDate(statuses, tier, flags, ctx);
111
119
  }
112
- const buildOptions = {
113
- devhubUsername: flags['target-org'],
114
- force: true,
115
- includeDependencies: true,
116
- };
117
- const buildOrchestrator = new BuildOrchestrator(projectConfig, projectGraph, buildOptions, logger, tmpDir);
118
- const buildRenderer = new BuildProgressRenderer({
119
- logger: {
120
- error: (msgOrError) => this.error(msgOrError),
121
- log: (msg) => this.log(msg),
122
- },
123
- mode,
124
- });
125
- buildRenderer.attachTo(buildOrchestrator);
126
- const buildResult = await buildOrchestrator.buildAll(packageNames);
127
- if (!buildResult.success) {
128
- const failedNames = buildResult.failedPackages.join(', ');
129
- if (flags.json) {
130
- const result = {
131
- packages: buildResult.results.map(p => ({
132
- error: p.error, packageName: p.packageName, skipped: p.skipped, success: p.success,
133
- })),
120
+ if (ctx.isInteractive) {
121
+ this.logPackageStatuses(statuses);
122
+ }
123
+ // ── 2. Setup project for packages that need building ──────────
124
+ const needsBuild = statuses.filter(s => s.action === 'build');
125
+ const needsPromote = statuses.filter(s => s.action === 'promote');
126
+ const needsInstall = statuses.filter(s => s.action === 'install' || s.action === 'build' || s.action === 'promote');
127
+ const results = statuses
128
+ .filter(s => s.action === 'skip')
129
+ .map(s => ({
130
+ action: 'skip', packageName: s.name, skipped: true, success: true, version: s.installedVersion,
131
+ }));
132
+ let projectService;
133
+ if (needsBuild.length > 0) {
134
+ projectService = await ProjectService.create(tmpDir, undefined, { alias: bootstrapConfigAliases() });
135
+ const provider = projectService.getDefinitionProvider();
136
+ await this.ensurePackageContainers(org, {
137
+ ctx, packages: selectedPackages, provider, tmpDir,
138
+ });
139
+ // ponytail: syncSfdxProject now handled by WorkspaceProvider.resolve()
140
+ // ── 3. Build packages that need it ─────────────────────────
141
+ const buildNames = needsBuild.map(s => s.name);
142
+ const { result: buildResult, validationFailures } = await this.buildPackages(projectService, buildNames, flags.force ?? false, ctx);
143
+ if (!buildResult.success) {
144
+ for (const name of buildNames) {
145
+ const failed = buildResult.failedPackages?.includes(name);
146
+ if (failed) {
147
+ results.push({
148
+ action: 'build',
149
+ error: 'Build failed',
150
+ packageName: name,
151
+ skipped: false,
152
+ success: false,
153
+ });
154
+ }
155
+ }
156
+ }
157
+ for (const failure of validationFailures) {
158
+ results.push({
159
+ action: 'build',
160
+ error: failure.error,
161
+ packageName: failure.packageName,
162
+ skipped: false,
134
163
  success: false,
135
- targetOrg: flags['target-org'],
136
- tier,
137
- };
138
- this.logJson(result);
139
- return result;
164
+ });
140
165
  }
141
- this.error(`Build failed for: ${failedNames}`, { exit: 1 });
142
166
  }
143
- // ── Step 8: Install packages ──────────────────────────────────
144
- if (isInteractive) {
145
- this.log(chalk.bold('\nInstalling packages...\n'));
146
- }
147
- const installOptions = {
148
- force: flags.force,
149
- includeDependencies: true,
150
- targetOrg: flags['target-org'],
151
- trackHistory: sfpmConfig.artifacts?.trackHistory,
152
- };
153
- const installOrchestrator = new InstallOrchestrator(projectConfig, projectGraph, installOptions, logger);
154
- const installRenderer = new InstallProgressRenderer({
155
- logger: {
156
- error: (msgOrError) => this.error(msgOrError),
157
- log: (msg) => this.log(msg),
158
- },
159
- mode,
160
- targetOrg: flags['target-org'],
161
- });
162
- installRenderer.attachTo(installOrchestrator);
163
- const installResult = await installOrchestrator.installAll(packageNames);
164
- // ── Step 9: Report results ────────────────────────────────────
165
- const result = {
166
- packages: installResult.results.map(p => ({
167
- error: p.error, packageName: p.packageName, skipped: p.skipped, success: p.success,
168
- })),
169
- success: installResult.success,
170
- targetOrg: flags['target-org'],
171
- tier,
172
- };
173
- if (flags.json) {
174
- this.logJson(result);
175
- return result;
176
- }
177
- if (installResult.success) {
178
- this.log(successBox('Bootstrap Complete', {
179
- Packages: packageNames.join(', '),
180
- 'Target Org': flags['target-org'],
181
- Tier: tier,
182
- }));
167
+ // ── 4. Promote unpromoted versions (newly built + previously built but not promoted) ──
168
+ const promoteNames = [
169
+ ...needsBuild.map(s => s.name),
170
+ ...needsPromote.map(s => s.name),
171
+ ];
172
+ if (promoteNames.length > 0) {
173
+ const promoteResults = await this.promotePackages(org, promoteNames, ctx);
174
+ for (const pr of promoteResults) {
175
+ if (!pr.success) {
176
+ results.push({
177
+ action: 'promote',
178
+ error: pr.error,
179
+ packageName: pr.name,
180
+ promoted: false,
181
+ skipped: false,
182
+ success: false,
183
+ });
184
+ }
185
+ }
183
186
  }
184
- else {
185
- const failedNames = installResult.failedPackages.join(', ');
186
- this.log(errorBox('Bootstrap Failed', {
187
- 'Failed Packages': failedNames,
188
- 'Target Org': flags['target-org'],
189
- }));
190
- this.error(`Install failed for: ${failedNames}`, { exit: 2 });
187
+ // ── 5. Install packages that need it ─────────────────────────
188
+ // Only install packages that haven't already failed
189
+ const failedNames = new Set(results.filter(r => !r.success).map(r => r.packageName));
190
+ const installNames = needsInstall
191
+ .map(s => s.name)
192
+ .filter(name => !failedNames.has(name));
193
+ if (installNames.length > 0) {
194
+ // Use a fresh dist-aware provider so packageVersionId + sourceHash from
195
+ // dist/package.json (written by the build step above) are visible.
196
+ const installService = await ProjectService.create(tmpDir, new WorkspaceProvider({ distAware: true, projectDir: tmpDir }), { alias: bootstrapConfigAliases() });
197
+ const installResults = await this.installPackages(installService, installNames, flags, ctx);
198
+ for (const ir of installResults) {
199
+ results.push(ir);
200
+ }
191
201
  }
192
- return result;
202
+ return this.finalizeResult(results, tier, flags, ctx);
193
203
  }
194
204
  finally {
195
- // ── Step 10: Cleanup ──────────────────────────────────────────
196
- await this.cleanup(tmpDir, isInteractive);
205
+ await this.cleanup(tmpDir, ctx.isInteractive);
197
206
  }
198
207
  }
199
208
  // ====================================================================
200
- // Private helpers
209
+ // Pipeline steps
201
210
  // ====================================================================
202
- async checkInstalledPackages(org, packageNames, logger) {
203
- const service = new PackageService(org, logger);
204
- const installed = await service.getAllInstalled2GPPackages();
205
- const installedNames = new Set(installed.map(p => p.name));
206
- return packageNames.filter(name => installedNames.has(name));
211
+ /**
212
+ * Build packages that need it, then resolve any pending org validations
213
+ * (e.g. unlocked package version creation) before ink is unmounted, so the
214
+ * live UI reflects validation progress instead of leaving packages stuck
215
+ * in a 'validating' state. Validation failures are returned alongside the
216
+ * build result rather than thrown, so the caller can fold them into the
217
+ * same results array as build/promote/install failures.
218
+ */
219
+ async buildPackages(projectService, packageNames, force, ctx) {
220
+ if (ctx.isInteractive) {
221
+ this.log(chalk.bold('\nBuilding packages...\n'));
222
+ }
223
+ const devhubOrg = await Org.create({ aliasOrUsername: ctx.targetOrg });
224
+ // json is the only non-ink mode; it's fully silent during the run (the
225
+ // SfpmCommand base class emits the JSON envelope at the end).
226
+ const isInk = ctx.mode !== 'json';
227
+ const uiBus = isInk ? new EventEmitter() : undefined;
228
+ const validationBus = isInk ? new ValidationEventBus() : undefined;
229
+ const { logger: pinoLogger, logPath } = this.createRunLogger(uiBus);
230
+ const buildOrchestrator = BuildOrchestrator.create(projectService.getDefinitionProvider(), { devhub: devhubOrg }, projectService.getProjectGraph(), {
231
+ force, includeDependencies: true,
232
+ validation: 'org',
233
+ }, isInk ? pinoLogger : ctx.logger);
234
+ let inkInstance;
235
+ if (uiBus) {
236
+ attachBuildBridge(buildOrchestrator.buildBus, buildOrchestrator.orchestrationBus, uiBus, validationBus);
237
+ inkInstance = renderApp(uiBus, {
238
+ logPath,
239
+ mode: ctx.mode === 'interactive' ? 'interactive' : 'plain',
240
+ org: { alias: ctx.targetOrg },
241
+ });
242
+ }
243
+ try {
244
+ const result = await buildOrchestrator.buildAll(packageNames);
245
+ const pendingValidations = result.results
246
+ .map(packageResult => packageResult.result?.pendingValidation)
247
+ .filter((descriptor) => descriptor?.operationType === 'package-version-request');
248
+ const validationFailures = [];
249
+ if (pendingValidations.length > 0) {
250
+ // Resolve while ink is still mounted so validationBus-driven UI updates
251
+ // (wired above via attachBuildBridge) are visible, matching build/index.ts.
252
+ const resolver = new ValidationResolver(projectService.getDefinitionProvider(), projectService.getProjectGraph(), validationBus ? noopLogger : ctx.logger, validationBus);
253
+ const validationResults = await resolver.resolve(pendingValidations);
254
+ validationFailures.push(...foldValidationFailures(validationResults));
255
+ }
256
+ if (inkInstance)
257
+ await inkInstance.waitUntilExit();
258
+ return { result, validationFailures };
259
+ }
260
+ finally {
261
+ inkInstance?.unmount();
262
+ }
207
263
  }
208
264
  async cleanup(tmpDir, isInteractive) {
209
265
  try {
@@ -235,29 +291,269 @@ export default class Bootstrap extends SfpmCommand {
235
291
  }
236
292
  return tmpDir;
237
293
  }
238
- async connectToOrg(username, isInteractive) {
239
- let spinner;
240
- if (isInteractive) {
241
- spinner = ora(`Connecting to ${username}...`).start();
294
+ // ====================================================================
295
+ // Private helpers
296
+ // ====================================================================
297
+ async ensurePackageContainers(org, options) {
298
+ const manager = PackageManager.getInstance(org, options.ctx.logger);
299
+ await manager.ensurePackages(options.packages, options.provider, options.tmpDir, async (name) => {
300
+ if (!options.ctx.isInteractive)
301
+ return true;
302
+ return confirm({
303
+ default: true,
304
+ message: `Package '${name}' does not exist in the DevHub. Create it?`,
305
+ });
306
+ });
307
+ }
308
+ finalizeResult(results, tier, flags, ctx) {
309
+ const result = {
310
+ packages: results,
311
+ success: results.every(r => r.success),
312
+ targetOrg: ctx.targetOrg,
313
+ tier,
314
+ };
315
+ if (this.outputMode !== 'json') {
316
+ this.renderFinalResult(result, ctx);
317
+ }
318
+ return result;
319
+ }
320
+ handleAllUpToDate(statuses, tier, _flags, ctx) {
321
+ const result = {
322
+ packages: statuses.map(s => ({
323
+ action: 'skip',
324
+ packageName: s.name,
325
+ skipped: true,
326
+ success: true,
327
+ version: s.installedVersion,
328
+ })),
329
+ success: true,
330
+ targetOrg: ctx.targetOrg,
331
+ tier,
332
+ };
333
+ if (ctx.isInteractive) {
334
+ this.log(successBox('All packages up-to-date', {
335
+ Hint: 'Use --force to rebuild and re-install',
336
+ Packages: statuses.map(s => `${stripScope(s.name)} (${s.installedVersion})`).join(', '),
337
+ 'Target Org': ctx.targetOrg,
338
+ }));
339
+ }
340
+ return result;
341
+ }
342
+ async installPackages(projectService, packageNames, flags, ctx) {
343
+ if (ctx.isInteractive) {
344
+ this.log(chalk.bold('\nInstalling packages...\n'));
242
345
  }
346
+ const sfpmConfig = projectService.getSfpmConfig();
347
+ const targetOrg = await Org.create({ aliasOrUsername: ctx.targetOrg });
348
+ // json is the only non-ink mode; it's fully silent during the run (the
349
+ // SfpmCommand base class emits the JSON envelope at the end).
350
+ const isInk = ctx.mode !== 'json';
351
+ const uiBus = isInk ? new EventEmitter() : undefined;
352
+ const { logger: pinoLogger, logPath } = this.createRunLogger(uiBus);
353
+ const installOrchestrator = InstallOrchestrator.forArtifact(targetOrg, projectService.getDefinitionProvider(), projectService.getProjectGraph(), {
354
+ force: flags.force,
355
+ includeDependencies: true,
356
+ testLevel: 'RunLocalTests',
357
+ }, isInk ? pinoLogger : ctx.logger);
358
+ let inkInstance;
359
+ if (uiBus) {
360
+ attachInstallBridge(installOrchestrator.installBus, installOrchestrator.orchestrationBus, uiBus);
361
+ inkInstance = renderApp(uiBus, {
362
+ logPath,
363
+ mode: ctx.mode === 'interactive' ? 'interactive' : 'plain',
364
+ org: { alias: ctx.targetOrg },
365
+ });
366
+ }
367
+ let installResult;
243
368
  try {
244
- const org = await Org.create({ aliasOrUsername: username });
245
- if (!await org.determineIfDevHubOrg()) {
246
- spinner?.fail(`${username} is not a DevHub`);
247
- throw new Error(`The target org '${username}' is not a DevHub. `
248
- + 'Bootstrap requires a DevHub org to create and build packages. '
249
- + 'Enable DevHub in Setup > Dev Hub or use a different org.');
369
+ installResult = await installOrchestrator.installAll(packageNames);
370
+ if (inkInstance)
371
+ await inkInstance.waitUntilExit();
372
+ }
373
+ finally {
374
+ inkInstance?.unmount();
375
+ }
376
+ return installResult.results.map(p => ({
377
+ action: 'install',
378
+ error: p.error,
379
+ packageName: p.packageName,
380
+ skipped: p.skipped,
381
+ success: p.success,
382
+ }));
383
+ }
384
+ logPackageStatuses(statuses) {
385
+ const lines = [];
386
+ for (const s of statuses) {
387
+ const name = stripScope(s.name);
388
+ switch (s.action) {
389
+ case 'build': {
390
+ lines.push(chalk.yellow(` [build] ${name}`));
391
+ break;
392
+ }
393
+ case 'install': {
394
+ lines.push(chalk.blue(` [install] ${name} (${s.latestReleasedVersion})`));
395
+ break;
396
+ }
397
+ case 'promote': {
398
+ lines.push(chalk.magenta(` [promote] ${name} (${s.latestReleasedVersion})`));
399
+ break;
400
+ }
401
+ case 'skip': {
402
+ lines.push(chalk.dim(` [skip] ${name} (${s.installedVersion})`));
403
+ break;
404
+ }
250
405
  }
251
- spinner?.succeed(`Connected to ${username} (DevHub)`);
252
- return org;
253
406
  }
254
- catch (error) {
255
- if (error instanceof Error && error.message.includes('not a DevHub')) {
256
- throw error;
407
+ this.log(`\n${lines.join('\n')}\n`);
408
+ }
409
+ async promotePackages(org, packageNames, ctx) {
410
+ if (ctx.isInteractive) {
411
+ this.log(chalk.bold('\nPromoting package versions...\n'));
412
+ }
413
+ const devhubService = new PackageService(org, ctx.logger);
414
+ const results = [];
415
+ // Pre-fetch all packages once to avoid repeated API calls
416
+ const allPackages = await devhubService.listPackages();
417
+ for (const name of packageNames) {
418
+ const unscopedName = stripScope(name);
419
+ let spinner;
420
+ if (ctx.isInteractive) {
421
+ spinner = ora(`Promoting ${unscopedName}...`).start();
422
+ }
423
+ try {
424
+ const pkg = allPackages.find(p => p.Name === unscopedName);
425
+ if (!pkg) {
426
+ const error = `Package "${unscopedName}" not found in DevHub`;
427
+ spinner?.fail(error);
428
+ results.push({ error, name, success: false });
429
+ continue;
430
+ }
431
+ // Get the latest non-released version (the one we just built)
432
+ const versions = await devhubService.listPackageVersions({ packages: [pkg.Id] }); // eslint-disable-line no-await-in-loop
433
+ const unpromoted = versions.find(v => !v.IsReleased);
434
+ if (!unpromoted) {
435
+ // All versions are already promoted — nothing to do
436
+ spinner?.succeed(`${unscopedName} -- already promoted`);
437
+ results.push({ name, success: true });
438
+ continue;
439
+ }
440
+ await devhubService.promoteVersion(unpromoted.SubscriberPackageVersionId); // eslint-disable-line no-await-in-loop
441
+ spinner?.succeed(`${unscopedName} -- promoted (${unpromoted.SubscriberPackageVersionId})`);
442
+ results.push({ name, success: true });
443
+ }
444
+ catch (error) {
445
+ const message = error instanceof Error ? error.message : String(error);
446
+ spinner?.fail(`${unscopedName} -- promote failed: ${message}`);
447
+ results.push({ error: message, name, success: false });
448
+ // Continue with next package — promotion can be retried on re-run
449
+ }
450
+ }
451
+ return results;
452
+ }
453
+ renderFinalResult(result, ctx) {
454
+ if (!ctx.isInteractive)
455
+ return;
456
+ if (result.success) {
457
+ const details = {
458
+ 'Target Org': ctx.targetOrg,
459
+ Tier: result.tier,
460
+ };
461
+ const installed = result.packages.filter(p => !p.skipped);
462
+ if (installed.length > 0) {
463
+ details.Installed = installed.map(p => p.packageName).join(', ');
464
+ }
465
+ const skipped = result.packages.filter(p => p.skipped);
466
+ if (skipped.length > 0) {
467
+ details.Skipped = skipped.map(p => p.packageName).join(', ');
257
468
  }
258
- spinner?.fail(`Failed to connect to ${username}`);
259
- throw new Error(`Unable to connect to org '${username}'. Ensure the org is authenticated via 'sf org login'.`, { cause: error instanceof Error ? error : undefined });
469
+ this.log(successBox('Bootstrap Complete', details));
470
+ }
471
+ else {
472
+ const failed = result.packages.filter(p => !p.success);
473
+ this.log(errorBox('Bootstrap Failed', {
474
+ 'Failed Packages': failed.map(p => `${p.packageName}: ${p.error ?? 'unknown error'}`).join('\n'),
475
+ Hint: 'Re-run the command to retry failed packages',
476
+ 'Target Org': ctx.targetOrg,
477
+ }));
478
+ }
479
+ }
480
+ /**
481
+ * Resolve per-package action by comparing DevHub versions to what's installed.
482
+ *
483
+ * - skip: installed version >= latest released version
484
+ * - install: a released version exists that's newer than what's installed
485
+ * - promote: an unreleased version exists (built but not promoted)
486
+ * - build: no version exists at all, or --force is set
487
+ */
488
+ async resolvePackageStatuses(org, selectedPackages, force, ctx) {
489
+ let spinner;
490
+ if (ctx.isInteractive) {
491
+ spinner = ora('Checking package versions...').start();
492
+ }
493
+ const devhubService = new PackageService(org, ctx.logger);
494
+ const installed = await devhubService.listInstalledPackages();
495
+ const installedByName = new Map(installed.map(p => [p.SubscriberPackage?.Name ?? '', p]));
496
+ const allDevHubPackages = await devhubService.listPackages();
497
+ const statuses = [];
498
+ // Sequential: each package queried individually from DevHub
499
+ for (const pkg of selectedPackages) {
500
+ const unscopedName = stripScope(pkg.name);
501
+ if (force) {
502
+ statuses.push({ action: 'build', name: pkg.name });
503
+ continue;
504
+ }
505
+ // Find the Package2 in the DevHub
506
+ const devhubPkg = allDevHubPackages.find(p => p.Name === unscopedName);
507
+ if (!devhubPkg) {
508
+ statuses.push({
509
+ action: resolveAction({
510
+ force, hasPackage: false, hasReleasedVersions: false, hasUnreleasedVersions: false,
511
+ }), name: pkg.name,
512
+ });
513
+ continue;
514
+ }
515
+ // Get released versions
516
+ // eslint-disable-next-line no-await-in-loop
517
+ const releasedVersions = await devhubService.listPackageVersions({ isReleased: true, packages: [devhubPkg.Id] });
518
+ // Get all versions (to detect unreleased)
519
+ const allVersions = releasedVersions.length === 0
520
+ ? await devhubService.listPackageVersions({ packages: [devhubPkg.Id] }) // eslint-disable-line no-await-in-loop
521
+ : releasedVersions;
522
+ const latestReleased = releasedVersions[0];
523
+ const latestVersion = latestReleased
524
+ ? `${latestReleased.MajorVersion}.${latestReleased.MinorVersion}.${latestReleased.PatchVersion}.${latestReleased.BuildNumber}`
525
+ : undefined;
526
+ const installedPkg = installedByName.get(unscopedName);
527
+ const installedSpv = installedPkg?.SubscriberPackageVersion;
528
+ const installedVersion = installedSpv
529
+ ? `${installedSpv.MajorVersion}.${installedSpv.MinorVersion}.${installedSpv.PatchVersion}.${installedSpv.BuildNumber}`
530
+ : undefined;
531
+ const action = resolveAction({
532
+ force,
533
+ hasPackage: true,
534
+ hasReleasedVersions: releasedVersions.length > 0,
535
+ hasUnreleasedVersions: allVersions.length > 0 && releasedVersions.length === 0,
536
+ installedVersion,
537
+ latestVersion,
538
+ });
539
+ const latest = latestReleased ?? allVersions[0];
540
+ const versionStr = latest
541
+ ? `${latest.MajorVersion}.${latest.MinorVersion}.${latest.PatchVersion}.${latest.BuildNumber}`
542
+ : undefined;
543
+ statuses.push({
544
+ action,
545
+ installedVersion,
546
+ latestReleasedVersion: versionStr,
547
+ name: pkg.name,
548
+ subscriberVersionId: latest?.SubscriberPackageVersionId,
549
+ });
260
550
  }
551
+ const skipped = statuses.filter(s => s.action === 'skip').length;
552
+ const builds = statuses.filter(s => s.action === 'build').length;
553
+ const promotes = statuses.filter(s => s.action === 'promote').length;
554
+ const installs = statuses.filter(s => s.action === 'install').length;
555
+ spinner?.succeed(`Version check complete: ${skipped} up-to-date, ${builds} need build, ${promotes} need promote, ${installs} need install`);
556
+ return statuses;
261
557
  }
262
558
  async resolveTier(flagValue, isInteractive) {
263
559
  if (flagValue) {