feat(config): read ~/.testsprite/config for persistent defaults (endpoint_url, output, project_id)#179
feat(config): read ~/.testsprite/config for persistent defaults (endpoint_url, output, project_id)#179Andy00L wants to merge 2 commits into
Conversation
…oint_url, output, project_id)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds a shared INI parser, reads ChangesConfig file settings support
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant loadConfig
participant readConfigFileSettings
participant ConfigFile
CLI->>loadConfig: resolve config defaults
loadConfig->>readConfigFileSettings: read profile settings
readConfigFileSettings->>ConfigFile: read ~/.testsprite/config
ConfigFile-->>readConfigFileSettings: INI values
readConfigFileSettings-->>loadConfig: endpointUrl, output, projectId
loadConfig-->>CLI: resolved settings
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/lib/config.test.ts (1)
92-140: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winGood coverage for the
defaultprofile; missing a non-default-profile case.None of these tests exercise
readConfigFileSettings/loadConfigwith a profile other thandefaultagainst a[profile x]-style section header — the exact scenario flagged inconfig.ts'sreadConfigFileSettingsreview comment. Adding a case likewriteConfigFile('[profile dev]\nendpoint_url = ...\n')+readConfigFileSettings('dev', { path })would have caught the section-naming mismatch.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/config.test.ts` around lines 92 - 140, Add a test case in the `readConfigFileSettings + the config-file layer of loadConfig` suite that exercises a non-default profile with a `[profile ...]` section header, since the current coverage only verifies `[default]`. Use `writeConfigFile` and `readConfigFileSettings` to confirm the profile-specific keys are read when the requested profile is something like `dev`, and optionally assert `loadConfig` respects that profile-based config path too. This should target the `readConfigFileSettings` behavior around section-name handling so the `default`-only assumption is covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/index.ts`:
- Around line 22-32: The fallback logic in configFileOutputDefault() is using
process.env.TESTSPRITE_PROFILE too early, so it can miss an explicit --profile
value and read the wrong config section. Update the output default resolution in
src/index.ts so it runs after argv parsing or receives the active profile from
the parsed CLI state, and ensure the lookup still uses readConfigFileSettings()
plus isOutputMode() with the resolved profile name.
---
Nitpick comments:
In `@src/lib/config.test.ts`:
- Around line 92-140: Add a test case in the `readConfigFileSettings + the
config-file layer of loadConfig` suite that exercises a non-default profile with
a `[profile ...]` section header, since the current coverage only verifies
`[default]`. Use `writeConfigFile` and `readConfigFileSettings` to confirm the
profile-specific keys are read when the requested profile is something like
`dev`, and optionally assert `loadConfig` respects that profile-based config
path too. This should target the `readConfigFileSettings` behavior around
section-name handling so the `default`-only assumption is covered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6c91dc19-aa0d-4143-93e3-adf7fd100b10
📒 Files selected for processing (5)
src/commands/test.tssrc/index.tssrc/lib/config.test.tssrc/lib/config.tssrc/lib/credentials.ts
|
Fixed the review finding: the config-file --output default now honors the profile selected by --profile (argv is peeked for both '--profile ' and '--profile=' spellings before Commander parses), then TESTSPRITE_PROFILE, then 'default' — matching the documented profile precedence. |
|
Approved in design — the aws-cli credentials-vs-config split, the
The |
What does this PR do?
defaultConfigPath()reserved~/.testsprite/configbutloadConfigneverread it, so every non-credential preference had to be repeated per command.
This implements the aws-cli credentials-vs-config split: profile-sectioned INI
settings (
endpoint_url,output,project_id) read via a newreadConfigFileSettings(profile). Precedence is exactly as accepted intriage — flag > env > config file > built-in default:
endpoint_urlslots into theloadConfigcascade just above the built-indefault (below
--endpoint-urlandTESTSPRITE_API_URL);outputbecomes the default of the global--outputflag (flag still wins);project_idbacks--projecton the project-scoped test commands, with thevalidation error now naming both options.
The file is optional by design: missing/unreadable file or section resolves to
{}and falls through.TESTSPRITE_CONFIG_FILEoverrides the path.Related issue
Fixes #100
Type of change
Checklist
mainbranch.npm run lintandnpm run format:checkpass.npm run typecheckpasses.npm testpasses and coverage stays at or above the 80% gate.Notes for reviewers
The INI walk is extracted from
parseCredentialsinto a sharedparseIniFile(null-prototype accumulator +
__proto__/constructor/prototypesection andkey guards);
parseCredentialsdelegates to it, byte-for-byte same behavior —including the recent CR/LF hardening, which is untouched. No secrets ever live
in the config file (the key stays in
credentials). Env-var default for--project(TESTSPRITE_PROJECT_ID) is intentionally NOT included here — thatis issue #76; per its triage, env will slot above the config file.
Summary by CodeRabbit
--outputvalue.