Skip to content

feat(cli): [NSoC_2026] allow choosing between Blank and Husky in secureflow --init (#1758) - #1801

Merged
GauravKarakoti merged 1 commit into
GauravKarakoti:mainfrom
Myparadox-creator:feat/init-blank-husky-choice-1758
Nov 16, 2026
Merged

GauravKarakoti merged 1 commit into
GauravKarakoti:mainfrom
Myparadox-creator:feat/init-blank-husky-choice-1758

Conversation

@Myparadox-creator

Copy link
Copy Markdown
Contributor

Description

Summary of Changes

by updating the secureflow --init command to allow users to choose between Blank and Husky initialization modes.

  1. Interactive Prompt & Flag Detection (cli/src/lib/tui.ts):

    • Added InitMode = "husky" | "blank".
    • Implemented detectInitMode(argv) to support CLI flags/arguments: --blank, -b, --husky, --init=blank, --init blank, --init=husky, and --init husky.
    • Implemented promptInitChoice(rl, stdin, stdout) using native Node.js readline to provide a clean interactive selection menu when running in an interactive terminal.
    • Preserves backward compatibility by defaulting to "husky" when in non-interactive / CI environments if no flag is specified.
  2. Blank Mode Initialization (initBlankPrepareScript):

    • Checks if package.json exists; if not, runs npm init --y to initialize the project directory.
    • Reads package.json and configures the "prepare" lifecycle script:
      • If no scripts object exists, initializes it.
      • If no prepare script exists, sets "prepare": "npx secureflow".
      • If a prepare script is already present, appends && npx secureflow (e.g. "prepare": "xyz && npx secureflow").
      • Detects if secureflow is already part of the prepare script to avoid redundant duplications.
    • Formats package.json cleanly with 2-space indentation and trailing newline.
  3. Greeting & CLI Help Updates:

    • formatInitGreeting: tailored next steps based on initialization mode (for Blank mode, highlights npm run prepare lifecycle execution; for Husky mode, highlights git pre-commit hook scanning).
    • cli/src/index.ts: updated CLI options and help menu to document --init, --husky, and --blank.
  4. Test Coverage:

    • Added unit tests in cli/src/lib/tui.test.ts covering initBlankPrepareScript, detectInitMode, promptInitChoice, initSecureFlow, and greeting output.
    • Added unit tests in cli/src/index.test.ts verifying CLI execution for --init with both success and failure exit codes.
    • All 62 unit tests pass cleanly (31/31 in tui.test.ts, 31/31 in index.test.ts).
  5. Changeset:

    • Added .changeset/init-blank-husky-choice-1758.md for secureflow-cli minor release.

PR Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • My changes generate no new warnings/errors
  • I have added tests that prove my feature works
  • All unit tests pass locally
  • Commit message follows [NSoC_2026] tag requirement
  • Added changeset for versioning

Related Issue

Closes #1758

@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

@Myparadox-creator is attempting to deploy a commit to the Gaurav's projects Team on Vercel.

A member of the Team first needs to authorize it.

Comment thread cli/src/lib/tui.ts
message = `Appended npx secureflow to existing prepare script ("${pkg.scripts.prepare}")`;
}

fs.writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2) + "\n", "utf-8");
@GauravKarakoti
GauravKarakoti merged commit 843ab3c into GauravKarakoti:main Nov 16, 2026
7 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

secureflow --init update

3 participants