Skip to content

Conversation

@pyramation
Copy link
Contributor

Summary

This PR adds two features to dev-utils:

1. New @inquirerer/test package (v1.0.0) - Testing utilities for inquirerer-based CLI applications:

  • createTestEnvironment() - Creates mock stdin/stdout/TTY streams for testing CLI prompts
  • KEY_SEQUENCES - Constants for simulating keypresses (ENTER, UP_ARROW, DOWN_ARROW, etc.)
  • normalizePackageJsonForSnapshot() - Normalizes dependency versions for stable snapshots
  • normalizePathsForSnapshot() / normalizeDatesForSnapshot() - Cross-platform snapshot helpers

2. Skip logic for checkForUpdates in @inquirerer/utils:

  • Auto-skips in CI environments (CI=true)
  • Respects INQUIRERER_SKIP_UPDATE_CHECK env var (generic skip)
  • Respects {TOOLNAME}_SKIP_UPDATE_CHECK env var (e.g., PGPM_SKIP_UPDATE_CHECK)
  • New force: true option to bypass skip logic
  • Returns skipped and skipReason fields in result

Review & Testing Checklist for Human

  • Verify Jest dependency handling in harness.ts - The code uses 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.
  • Test shouldSkipUpdateCheck with env var combinations - Verify CI detection, generic skip, and tool-specific skip all work correctly. Check that toEnvVarName() properly converts tool names like "my-cli" to "MY_CLI".
  • Verify force: true bypasses all skip logic - Ensure update checks can still be forced in CI when needed.
  • Check for dead code - Line 51 in harness.ts declares originalCreateInterface but never uses it.

Recommended test plan:

  1. Run pnpm build and pnpm test in dev-utils
  2. Manually test checkForUpdates with CI=true, INQUIRERER_SKIP_UPDATE_CHECK=1, and force: true
  3. Import @inquirerer/test in a test file and verify createTestEnvironment() works with inquirerer prompts

Notes

The @inquirerer/test package extracts and generalizes test utilities that were duplicated in pgpm/cli/test-utils/cli.ts and packages/cli/test-utils/cli.ts in the constructive repo.

After this PR is merged and published, a follow-up PR to constructive will update checkForUpdates calls to remove the manual !process.env.CI checks since that logic is now baked into the utility.

Link to Devin run: https://app.devin.ai/sessions/e5018850caff45ce8a126331548d69bc
Requested by: Dan Lynch (@pyramation)

@inquirerer/utils:
- Add shouldSkipUpdateCheck() helper that checks CI env and skip env vars
- Update checkForUpdates to auto-skip in CI or when INQUIRERER_SKIP_UPDATE_CHECK is set
- Support tool-specific skip via {TOOLNAME}_SKIP_UPDATE_CHECK (e.g., PGPM_SKIP_UPDATE_CHECK)
- Add 'force' option to bypass skip logic
- Return 'skipped' and 'skipReason' fields in result

@inquirerer/test (new package):
- CliTestHarness with mock stdin/stdout/TTY for testing CLI apps
- KEY_SEQUENCES constants (ENTER, UP_ARROW, DOWN_ARROW, SPACE, etc.)
- setupTests() / createTestEnvironment() for Jest integration
- normalizePackageJsonForSnapshot() for stable dependency snapshots
- normalizePathsForSnapshot() and normalizeDatesForSnapshot() utilities
- humanizeKeySequences() for readable test output
@devin-ai-integration
Copy link

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@pyramation pyramation merged commit 42ad508 into main Dec 27, 2025
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants