From 9016f43220dcee9d93a7fc3c25d9d38ed6c0e8cd Mon Sep 17 00:00:00 2001 From: lete114 Date: Tue, 9 Jun 2026 20:59:18 +0800 Subject: [PATCH] feat: add non-interactive support for init command Add CLI options for all init prompts (author, desc, lang, mc-version, pm, packs, no-scripts, add-bp, add-rp) to allow fully non-interactive usage. - New options: -a/-d/-l/-v/-p/-k/--no-scripts/--add-bp/--add-rp - parsePacks() utility converts 'bp,rp' string to PackType[] - Each prompt checks for CLI-provided value before showing - reinitProject also respects new options - Unit tests for parsePacks (7) + integration tests for non-interactive (7) --- README.md | 21 +- .../__tests__/init.integration.test.ts | 159 ++++++++++ src/commands/__tests__/init.test.ts | 34 +++ src/commands/init.ts | 275 +++++++++++------- src/index.ts | 24 +- 5 files changed, 412 insertions(+), 101 deletions(-) create mode 100644 src/commands/__tests__/init.integration.test.ts create mode 100644 src/commands/__tests__/init.test.ts diff --git a/README.md b/README.md index 7447e14..1fa29c8 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,19 @@ Interactive prompts guide you through: - Template choice (when Script API is enabled) - Package manager (npm, pnpm, yarn) -Use `--yes` to skip prompts and create with defaults (explosive-bow + BP + RP + TS): +Use `--yes` to skip all prompts and create with defaults: ```bash mcbe-create init my-addon --yes ``` +Use short flags to customize non-interactively: + +```bash +mcbe-create init my-addon -a "Author" -d "My addon" -l js --no-scripts -k bp -y +mcbe-create init my-addon -v 1.20.0 -p pnpm --no-install +``` + Run `init` inside an existing project to add missing packs. ### Development @@ -70,7 +77,17 @@ mcbe-create info # Show project information |-------------------|------|---------|-------------| | `[project-name]` | `string` | — | Project name (prompted if omitted) | | `-t, --template