Repository navigation
feat(cli): run project commands with the project's own checkly install [RED-757] [ship] - #1563
Merged
Merged
Conversation
…l [RED-757] A checkly install other than the project's (a global install, pnpx, an npx of another version) could not run commands that load the project: the project's constructs register with the Session of the checkly the project imports, so the running CLI failed with "Unable to create a construct outside a Checkly CLI project". The launcher now detects this before oclif runs or any project file is imported. For commands marked parsesProject, when a Checkly config file exists and the nearest node_modules/checkly is a different install, it runs that install's bin with the same arguments, inherited stdio, forwarded signals and the same exit status. A one-line notice names the version used when it differs. CHECKLY_NO_DELEGATION=1 opts out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…757] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-757] Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oads [RED-757] Any checkly install now behaves like `npx checkly` in the same directory: the launcher looks for node_modules/checkly upwards from the working directory and, when it is a different install, runs every command with it before importing oclif. This replaces the per-command parsesProject flag, the argv parsing and the config-file gate, and makes the hand-off cheaper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… [RED-757] Commands load the project from the directory of --config/-c, so the launcher now starts its node_modules/checkly search there too, in every form oclif accepts the flag (including -c grouped after boolean short flags), and from the working directory otherwise. This hands off correctly when --config points into a package with its own checkly. Co-Authored-By: Claude Opus 5.5 <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.
Linear: RED-757
Problem
checkly test,deployand every other command that loads a project failed withUnable to create a construct '…' outside a Checkly CLI projectwhenever the runningchecklywas a different install from the project's ownnode_modules/checkly. That happens with a globalnpm i -g checkly,pnpm dlx/pnpx checkly, andnpx checkly@<other version>. The project's constructs register with theSessionof thechecklythe project imports, not the one that is running, and the error says nothing about the real cause.Change
Any
checklyinstall now behaves likenpx checklyin the project's directory.bin/launch.cjsloads.env, then looks fornode_modules/checklyupwards from the project's directory, the same search a barechecklyimport does. The project's directory is that of the--config/-cfile when one is given, as the commands themselves resolve it, and the working directory otherwise. When that is a different install by real path, the launcher runs every command with it, before@oclif/coreis even imported. The logic is insrc/services/project-cli.ts.--versionand--help, so the project's version decides what is available. The only argument the launcher reads is the config file. It accepts every form oclif does (--config v,--config=v,-c v,-c=v,-cv, andcafter boolean short flags in one group, like-pc v) and stops at--. Tests assert that-cmeans--configon every command, and that the scan's set of boolean short letters matches the commands that take-c, so the scan can ignore which command runs. pnpm symlinks and the project's ownnpx checklyresolve to the same install and stay in-process.--versiontakes about 30 ms longer than running the project's CLI directly..env-merged environment, because installs before 8.0.0 don't load.envthemselves. It also gets this process's Node flags, minus inspector flags inexecArgvandNODE_OPTIONS. SIGINT, SIGTERM and SIGHUP are forwarded; on Windows the console already delivers Ctrl+C to the child. The outer process exits with the child's exit code, or is killed by the same signal.Using checkly 9.5.0 from this project (node_modules/checkly) instead of checkly 10.0.0.When the invoked CLI is newer, it addsTo use 10.0.0, install it in this project.CHECKLY_NO_DELEGATION=1keeps the command with the invoked CLI.deno runpermissions.CHECKLY_HANDED_OFF_TOguard stops an install from handing off to itself again, while a nestedchecklyin another project can still hand off.localCliNote(theinitfooter) still recommendsnpx checkly, but no longer claims a global install cannot load the project. Global installs from before this release still can't.Testing
src/services/__tests__/project-cli.spec.ts:--config/-cscan, which is checked against oclif's own parser;bin/run.cjsagainst a fake project install. They cover argv, exit code, the.envenv, notice wording, handing off every invocation including from subdirectories, the search starting from a-cfile in another package, the opt-out, signal forwarding and signal exits;debug parse-projectfrom this package in aFixtureSandboxproject with its owncheckly. It succeeds with the hand-off and fails with the original error underCHECKLY_NO_DELEGATION=1.src/services/__tests__/project-cli-spawn-error.spec.ts: fallback when the install can't be started or read.checkly@9.5.0:--versionandvalidatefrom this checkout were handed off, including from a subdirectory.Docs: checkly/docs#593.
🤖 Generated with Claude Code