fix(cli): run the installer from a checkout without installed dependencies - #219
Open
cdotta wants to merge 1 commit into
Open
fix(cli): run the installer from a checkout without installed dependencies#219cdotta wants to merge 1 commit into
cdotta wants to merge 1 commit into
Conversation
…ncies README documents cloning Facility and running the installer directly, and describes it as not requiring Facility to be deployed at all. Every command died instead, including --version and --help: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'postgres' imported from packages/cli/src/instance.mjs cli.mjs statically imports instance.mjs, which statically imports the postgres driver, so every command eagerly loaded a database driver that only 'instance bootstrap' uses. Deferred to the call site; the existing options.postgres injection keeps tests unaffected. Refs theam#45. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The README documents cloning Facility and running the installer directly, and describes the installer as not requiring Facility to be deployed at all:
git clone https://github.com/theam/facility.git /absolute/path/to/facility cd your-repository node /absolute/path/to/facility/packages/cli/bin/facility.mjs initThere is no install step in that recipe, and from a fresh clone every command fails:
Not only
init—doctor,--helpand--versionfail identically, with an unhandled stack trace rather than a diagnostic.cli.mjsstatically importsbootstrapInstancefrominstance.mjs, which statically imports thepostgresdriver at module scope, so every command eagerly loads a database driver that onlyinstance bootstrapuses.postgresis a correctly declared dependency and this is fine once the CLI is published to npm (#1). The problem is only the documented run-from-a-checkout path.Change
Defer the import to its call site. The module already supports driver injection (
options.postgres ?? …), so the bootstrap tests are unaffected.Test
packages/cli/test/plain-checkout.test.mjscopies the published files (bin,src,templates,modules,package.json) into a temp directory with nonode_modules— a faithful plain checkout, since the CLI has exactly one external dependency — and asserts--version,--helpandinitall succeed. Fails onmain, passes with this change.Verification
node --test test/*.test.mjsinpackages/cli— all passnode guards/run.mjs— cleanRelated to #45, which frames this as documentation alignment. This makes the documented flow work as written instead, which seemed the better outcome — happy to close it as docs-only if you disagree.