Skip to content

fix: print helpful guidance when init declines overwrite - #22

Open
vivekyadav-3 wants to merge 5 commits into
tanmayjoddar:mainfrom
vivekyadav-3:fix/init-silent-exit-on-no-overwrite
Open

fix: print helpful guidance when init declines overwrite#22
vivekyadav-3 wants to merge 5 commits into
tanmayjoddar:mainfrom
vivekyadav-3:fix/init-silent-exit-on-no-overwrite

Conversation

@vivekyadav-3

Copy link
Copy Markdown

Summary

Closes #4

When a user ran apidrift init and answered No to overwriting an
existing config, the CLI returned silently — no message, no guidance,
leaving the user confused about what to do next.

Changes

  • src/commands/init.js: Replaced silent return with a clear info
    block showing

Copilot AI review requested due to automatic review settings May 20, 2026 05:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread src/commands/init.js
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")}`);
Comment thread src/commands/init.js Outdated
initial: false,
});
if (!overwrite) {
console.log(chalk.yellow("✖ Keeping existing apidrift.config.json"));
Comment thread src/storage/snapshotStore.js Outdated
Comment on lines +29 to +30
.map((f) => f.replace(".json", ""))
.sort();
@vivekyadav-3

Copy link
Copy Markdown
Author

Hi @tanmayjoddar,
I have submitted this pull request to resolve the corresponding issue. The changes are fully tested, have no merge conflicts, and are ready for review.
Could you please take a look and merge this under GSSoC '26 when you get a chance? Thank you

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.

bug: init should not exit silently when config exists (no overwrite)

3 participants