fix: print helpful guidance when init declines overwrite - #22
Open
vivekyadav-3 wants to merge 5 commits into
Open
fix: print helpful guidance when init declines overwrite#22vivekyadav-3 wants to merge 5 commits into
vivekyadav-3 wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Improves CLI UX by printing clear next steps when apidrift init detects an existing config and the user declines to overwrite it, preventing a confusing “silent exit”. Also makes snapshot listing order stable by sorting snapshot tags.
Changes:
- Print a “next steps” guidance block when overwrite is declined in
apidrift init. - Sort snapshot tags returned by
listSnapshots()for stable output ordering.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/commands/init.js |
Adds user-facing guidance when declining to overwrite an existing apidrift.config.json. |
src/storage/snapshotStore.js |
Sorts snapshot tag names for deterministic listing. |
Comments suppressed due to low confidence (1)
src/commands/init.js:45
- This “Next steps” block largely duplicates the one printed after creating a new config (later in this file). Consider extracting a small helper to print the shared guidance (with a parameter for the step-1 wording) to avoid the two blocks drifting over time.
console.log(" Your current config was not modified. Next steps:");
console.log(
` 1. Make sure you have a ${chalk.cyan(".env")} file with your tokens:`
);
console.log(` ${chalk.gray("STAGING_TOKEN=your_token_here")}`);
console.log(` ${chalk.gray("PROD_TOKEN=your_token_here")}`);
console.log(
` 2. Add ${chalk.cyan(".env")} to your ${chalk.cyan(".gitignore")} to keep tokens out of git`
);
console.log(
` 3. Run: ${chalk.cyan("apidrift snapshot --tag v1.0 --env staging")}`
);
console.log("");
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+33
to
+38
| console.log(" Your current config was not modified. Next steps:"); | ||
| console.log( | ||
| ` 1. Make sure you have a ${chalk.cyan(".env")} file with your tokens:` | ||
| ); | ||
| console.log(` ${chalk.gray("STAGING_TOKEN=your_token_here")}`); | ||
| console.log(` ${chalk.gray("PROD_TOKEN=your_token_here")}`); |
| initial: false, | ||
| }); | ||
| if (!overwrite) { | ||
| console.log(chalk.yellow("✖ Keeping existing apidrift.config.json")); |
Comment on lines
+29
to
+30
| .map((f) => f.replace(".json", "")) | ||
| .sort(); |
Author
|
Hi @tanmayjoddar, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Closes #4
When a user ran
apidrift initand answered No to overwriting anexisting config, the CLI returned silently — no message, no guidance,
leaving the user confused about what to do next.
Changes
src/commands/init.js: Replaced silentreturnwith a clear infoblock showing