feat: add presets and secure onboarding - #59
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
📝 WalkthroughWalkthroughThe PR adds a versioned preset catalog, strict validation, interactive ChangesPreset catalog and onboarding
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant InitCLI
participant PresetCatalog
participant ClientSnippets
participant ConfigFile
User->>InitCLI: Run miftah init
InitCLI->>PresetCatalog: Build and validate selected preset
InitCLI->>ClientSnippets: Render selected client configuration
InitCLI->>ConfigFile: Write config exclusively
InitCLI->>User: Print created path and snippets
Possibly related PRs
Poem
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (1 error, 1 warning)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 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/cli/init.ts`:
- Around line 68-93: Update createCancellation so cancellation.promise has a
rejection handler attached immediately when created, preventing unhandled
rejection when collectInteractiveValues completes without calling prompt().
Preserve the existing rejection behavior for prompt()’s Promise.race and the
current dispose/listener cleanup semantics.
- Around line 264-281: Update runInitCommand to catch the EEXIST failure from
the exclusive writeFile operation and convert it into the established
CliUsageError used by other init validation failures, while preserving the
exclusive-write behavior. Add coverage for rerunning initialization against an
existing output file and verify it reports the friendly usage error.
In `@src/config/presets.ts`:
- Around line 357-365: Update the unknown-preset check in buildPresetConfig to
use Object.hasOwn instead of Object.prototype.hasOwnProperty.call, preserving
the existing preset validation and error behavior.
- Around line 11-17: Update semverPrereleaseIdentifier in the
exactNpmPackageSpec construction to use the canonical narrower prerelease
grammar, replacing the overlapping leading character class with digits-only
before the required non-digit identifier character. Keep the existing numeric
identifier and overall package-spec matching behavior unchanged.
In `@tests/init-command.test.ts`:
- Around line 92-116: Extend the init command tests around runInitCommand to
create an existing output file, rerun init against that same output path, and
assert that it rejects with CliUsageError. Keep the test focused on the EEXIST
scenario and verify the existing file remains unchanged.
🪄 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: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d4b50eb7-664e-41b2-91e7-2922602c3c2c
📒 Files selected for processing (24)
CHANGELOG.mdREADME.mddocs/claude-desktop.mddocs/cli.mddocs/config.mddocs/examples/github.mddocs/examples/sentry.mddocs/presets-and-clients.mddocs/security.mdexamples/generic.miftah.jsonexamples/github.miftah.jsonexamples/sentry.miftah.jsonsrc/cli/client-snippets.tssrc/cli/init.tssrc/cli/main.tssrc/cli/parse.tssrc/config/presets.tstests/cli-parse.test.tstests/client-snippets.test.tstests/config-runtime-parity.test.tstests/init-command.test.tstests/preset-catalog.test.tstests/preset-docs-contract.test.tstests/presets.test.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
initonboarding with client snippetsValidation
npm testnpm run lintnpm run typechecknpm run buildnpm run smoke:clinpm run check:packnpm run test:packageRefs #19
Summary by CodeRabbit
miftah initto generate strict preset-based configs and optional client onboarding snippets (interactive and non-interactive modes).