Skip to content

test(cli): cover offline cache, credentials, secret refs, ignore files#734

Merged
HugoRCD merged 1 commit into
mainfrom
test/v5-cli-coverage
Apr 20, 2026
Merged

test(cli): cover offline cache, credentials, secret refs, ignore files#734
HugoRCD merged 1 commit into
mainfrom
test/v5-cli-coverage

Conversation

@HugoRCD
Copy link
Copy Markdown
Owner

@HugoRCD HugoRCD commented Apr 20, 2026

Summary

  • Adds 47 vitest cases for the v5 CLI additions: encrypted offline cache, keychain credentials with XDG file fallback + legacy ~/.shelve migration, shelve:// secret references, agent-ignore files, and parseDuration.
  • Fixes a latent bug in CredentialsService.writeToken where freshly provisioned machines (no ~/.config) would fail with ENOENT before ever writing the token — the config directory is now created on demand.

Test plan

  • `pnpm --filter @shelve/cli test` (build + typecheck + lint + 51 vitest cases) passes locally.
  • Keychain is mocked so no OS credential store is touched.
  • Cache and config writes are sandboxed under `mkdtempSync`.

PR order

This is PR 1/4 in the v5 follow-up series. It is independent and can land in any order relative to the other three.

Adds 47 new vitest cases exercising the v5 additions to the CLI:

- CacheService: AES-256-GCM roundtrip, TTL expiry, token rotation and
  tamper detection, stable cache keys across URL trailing slashes.
- CredentialsService: XDG file fallback (keychain mocked out), token
  read/write/clear, legacy `~/.shelve` migration with deletion, no-op
  when the XDG file already has data.
- `writeAgentIgnoreFiles`: idempotent writes, preservation of
  pre-existing user content, upsert of the shelve-managed block.
- `parseEnvTemplate` / `resolveReferences`: literals, short-form and
  scoped `shelve://` references, rename-on-resolve, reporting of
  cross-env and missing references.
- `parseDuration`: unit parsing (ms/s/m/h/d), decimals, case and
  whitespace tolerance, fallback on garbage input.

Along the way `CredentialsService.writeToken` now mkdirs
`$XDG_CONFIG_HOME` on first write so freshly provisioned machines no
longer fail with ENOENT when rc9 hands off to `writeFileSync`.
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
shelve-app Ready Ready Preview, Comment, Open in v0 Apr 20, 2026 4:50pm
shelve-lp Ready Ready Preview, Comment Apr 20, 2026 4:50pm
shelve-vault Ready Ready Preview, Comment Apr 20, 2026 4:50pm

@github-actions github-actions Bot added the test label Apr 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@HugoRCD HugoRCD merged commit d63f766 into main Apr 20, 2026
13 of 14 checks passed
@HugoRCD HugoRCD deleted the test/v5-cli-coverage branch April 20, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant