feat: add @inquirerer/test package and skip logic for checkForUpdates #42
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.
Summary
This PR adds two features to dev-utils:
1. New
@inquirerer/testpackage (v1.0.0) - Testing utilities for inquirerer-based CLI applications:createTestEnvironment()- Creates mock stdin/stdout/TTY streams for testing CLI promptsKEY_SEQUENCES- Constants for simulating keypresses (ENTER, UP_ARROW, DOWN_ARROW, etc.)normalizePackageJsonForSnapshot()- Normalizes dependency versions for stable snapshotsnormalizePathsForSnapshot()/normalizeDatesForSnapshot()- Cross-platform snapshot helpers2. Skip logic for
checkForUpdatesin@inquirerer/utils:CI=true)INQUIRERER_SKIP_UPDATE_CHECKenv var (generic skip){TOOLNAME}_SKIP_UPDATE_CHECKenv var (e.g.,PGPM_SKIP_UPDATE_CHECK)force: trueoption to bypass skip logicskippedandskipReasonfields in resultReview & Testing Checklist for Human
jest.fn()directly but Jest is marked as optional peer dependency. Test that importing the package works correctly in both Jest and non-Jest environments.shouldSkipUpdateCheckwith env var combinations - Verify CI detection, generic skip, and tool-specific skip all work correctly. Check thattoEnvVarName()properly converts tool names like "my-cli" to "MY_CLI".force: truebypasses all skip logic - Ensure update checks can still be forced in CI when needed.originalCreateInterfacebut never uses it.Recommended test plan:
pnpm buildandpnpm testin dev-utilscheckForUpdateswithCI=true,INQUIRERER_SKIP_UPDATE_CHECK=1, andforce: true@inquirerer/testin a test file and verifycreateTestEnvironment()works with inquirerer promptsNotes
The
@inquirerer/testpackage extracts and generalizes test utilities that were duplicated inpgpm/cli/test-utils/cli.tsandpackages/cli/test-utils/cli.tsin the constructive repo.After this PR is merged and published, a follow-up PR to constructive will update
checkForUpdatescalls to remove the manual!process.env.CIchecks since that logic is now baked into the utility.Link to Devin run: https://app.devin.ai/sessions/e5018850caff45ce8a126331548d69bc
Requested by: Dan Lynch (@pyramation)