refactor(cloud): move the fleet inventory and attach preflight into ts-cloud - #2380
Conversation
…s-cloud The two commands landed in #2378 and #2379 carried their whole implementation here: a fleet inventory, an attach preflight, and hand-rolled copies of ts-cloud's own `buildHostSitePortsScript`, `parseHostSiteFragments` and `occupiedHostPorts`. The copies were not a shortcut - `deploy/site-ports` shipped declarations with no reachable runtime, so the real ones could not be imported at all - but they were still a second reading of ts-cloud's own file format living in another repository, with nothing to keep the two in step. None of that logic is buddy's. Reading a box's gateway registry, deciding whether a project may attach to somebody else's server, and writing `attachTo` back into a cloud config are all things ts-cloud owns, and they belong beside `site-ports` and `site-move` rather than beside a CLI. stacksjs/ts-cloud#192 moves them there and fixes the export gap that forced the duplication (stacksjs/ts-cloud#191). So `cloud-inventory.ts` and `cloud-attach.ts` are deleted, along with their 74 tests, which moved with them. What is left here is what is genuinely the CLI's: - resolving the provider token and listing the fleet, now through ts-cloud's own `HetznerClient.listServers()` rather than a hand-rolled fetch and pagination loop; - reading `config/cloud.ts` and shaping this project's sites, using ts-cloud's `resolveSiteKind` and `siteInstallBase` rather than re-deriving either; - the refusal, exit-code and `--json` behaviour; - describing the two config edits an attach needs, which stays here because `tenants` is a Stacks config key and the second edit lives in a repository this command cannot write to. The command surface is unchanged: `buddy docs:buddy` regenerates identically. BLOCKED on a ts-cloud release carrying #192. Every remaining typecheck error is `Property '<name>' does not exist on @stacksjs/ts-cloud`, and nothing else. No dependency bump is needed - the declared range is already `^0.12.7`, which the next patch satisfies; only the lockfile moves.
561d449 to
cffb9b2
Compare
|
Rebased onto The rebase touched two things worth namingConflict 1 -
Conflict 2 - A bug the port surfacedWriting
ts-cloud already knew: Not fixable here - that code no longer lives in this repo, which is rather the point. Verification on the rebased branch
|
@stacksjs/actions
@stacksjs/ai
@stacksjs/alias
@stacksjs/analytics
@stacksjs/api
@stacksjs/arrays
@stacksjs/audio
@stacksjs/auth
@stacksjs/browser
@stacksjs/browser-extension
@stacksjs/buddy
@stacksjs/build
@stacksjs/cache
@stacksjs/calendar-api
@stacksjs/charts
@stacksjs/chat
@stacksjs/cli
@stacksjs/cloud
@stacksjs/cms
@stacksjs/collections
@stacksjs/commerce
@stacksjs/composables
@stacksjs/config
@stacksjs/cron
@stacksjs/database
@stacksjs/datetime
@stacksjs/defaults
@stacksjs/desktop-build
@stacksjs/dns
@stacksjs/docs
@stacksjs/email
@stacksjs/enums
@stacksjs/env
@stacksjs/error-handling
@stacksjs/events
@stacksjs/faker
@stacksjs/feature-flags
@stacksjs/forms
@stacksjs/git
@stacksjs/github
@stacksjs/health
@stacksjs/http
@stacksjs/i18n
@stacksjs/image
@stacksjs/lint
@stacksjs/logging
@stacksjs/mobile
@stacksjs/newsletter
@stacksjs/notifications
@stacksjs/objects
@stacksjs/orm
@stacksjs/path
@stacksjs/payments
@stacksjs/push
@stacksjs/query-builder
@stacksjs/queue
@stacksjs/realtime
@stacksjs/registry
@stacksjs/repl
@stacksjs/router
@stacksjs/scheduler
@stacksjs/search-engine
@stacksjs/security
@stacksjs/server
@stacksjs/shell
@stacksjs/sites
@stacksjs/skills
@stacksjs/slug
@stacksjs/sms
@stacksjs/socials
@stacksjs/storage
@stacksjs/strings
@stacksjs/testing
@stacksjs/tinker
@stacksjs/tunnel
@stacksjs/types
@stacksjs/ui
@stacksjs/utils
@stacksjs/validation
@stacksjs/video
@stacksjs/whois
commit: |
Draft: blocked on a ts-cloud release carrying stacksjs/ts-cloud#192 (merged as
b06d37a). Ready to mark ready the moment that publishes.Why
#2378 and #2379 carried their whole implementation here: a fleet inventory, an attach preflight, and hand-rolled copies of ts-cloud's own
buildHostSitePortsScript,parseHostSiteFragmentsandoccupiedHostPorts.Those copies were not laziness.
deploy/site-portsshipped declarations with no reachable runtime, so the real functions could not be imported at all. But they were still a second reading of ts-cloud's own file format, living in another repository, with nothing to keep the two in step - andsite-ports.tscares about that enough to pin its one duplicated constant with a test.None of that logic is buddy's. Reading a box's gateway registry, deciding whether a project may attach to somebody else's server, and writing
attachToback into a cloud config are things ts-cloud owns. stacksjs/ts-cloud#192 moves them besidesite-portsandsite-movewhere they belong, and fixes the export gap that forced the duplication (stacksjs/ts-cloud#191).What moves
src/cloud-inventory.tsoperations/inventorysrc/cloud-attach.tsoperations/site-attach+setAttachToInCloudConfigtests/cloud-inventory.test.ts,tests/cloud-attach.test.ts(74 tests)site-portsalready coveredThe duplicated primitives are gone: the inventory now calls ts-cloud's
buildHostSitePortsScript/parseHostSiteFragments, and the attach preflight callsoccupiedHostPorts, so the collision check and the port allocator can no longer disagree about which ports are taken.What stays
The part that is genuinely the CLI's:
HetznerClient.listServers()rather than a hand-rolled fetch with its own pagination loop;config/cloud.tsand shaping this project's sites, viaresolveSiteKindandsiteInstallBaserather than re-deriving either;--json;tenantsis a Stacks config key, and the second edit lives in a repository this command cannot write to.Verification
buddy lintclean (3198 files, 0 errors).buddy docs:buddyregenerates identically: the command surface, options and help text are unchanged.bun run typecheck: every remaining error isProperty '<name>' does not exist on @stacksjs/ts-cloud, for the eleven names chore(deps): update dependency pathe to ^0.3.9 #192 adds, and nothing else. Verified against the locally built ts-clouddistthat all eleven are exported from the root barrel.Release note
No dependency bump needed. The declared range is already
^0.12.7, which the next patch satisfies; only the lockfile moves. Once ts-cloud publishes, this needsbun install --lockfile-onlyand nothing more.