Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Changesets

Run `npm run changeset` to describe a change and its semver bump. The release workflow turns
pending changesets into a "Version packages" PR; merging that PR publishes to npm.
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@4.0.1/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
32 changes: 32 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Bug report
description: Something isn't working as expected
labels: [bug]
body:
- type: textarea
id: what
attributes:
label: What happened?
description: Include what you expected to happen.
validations:
required: true
- type: textarea
id: repro
attributes:
label: Minimal reproduction
description: The smallest set of steps / code that shows the problem.
render: ts
validations:
required: true
- type: input
id: version
attributes:
label: cli-genie version
validations:
required: true
- type: input
id: env
attributes:
label: Node.js version, OS and terminal
placeholder: Node 24.1, macOS 15, iTerm2
validations:
required: true
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Feature request
description: Suggest an idea for CLI Genie
labels: [enhancement]
body:
- type: textarea
id: problem
attributes:
label: What problem would this solve?
validations:
required: true
- type: textarea
id: proposal
attributes:
label: Proposed API or behaviour
render: ts
- type: textarea
id: alternatives
attributes:
label: Alternatives considered
15 changes: 15 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: monthly
groups:
inquirer:
patterns: ['@inquirer/*']
dev-dependencies:
dependency-type: development
- package-ecosystem: github-actions
directory: /
schedule:
interval: monthly
8 changes: 8 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## What does this change?

## Checklist

- [ ] `npm run check` passes
- [ ] Tests added or updated
- [ ] Docs (README) updated if the public API changed
- [ ] Changeset added (`npm run changeset`) if this affects users
44 changes: 44 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CI

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
check:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [22, 24, 26]
include:
- os: windows-latest
node: 24
- os: macos-latest
node: 24
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: ${{ matrix.node }}
cache: npm
- run: npm ci
- run: npm run typecheck
- run: npm run lint
- run: npm run format:check
- run: npm test
- run: npm run build
- name: Smoke-test the packed package
shell: bash
run: |
npm pack
mkdir -p /tmp/smoke && cd /tmp/smoke && npm init -y >/dev/null
npm install "$GITHUB_WORKSPACE"/cli-genie-*.tgz
node -e "const g = require('cli-genie'); if (typeof g.CliGenie !== 'function') process.exit(1)"
node --input-type=module -e "import { CliGenie } from 'cli-genie'; if (typeof CliGenie !== 'function') process.exit(1)"
npx cli-genie --version
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Release

on:
push:
branches: [main]

concurrency: ${{ github.workflow }}-${{ github.ref }}

permissions:
contents: write
pull-requests: write
id-token: write # npm provenance / trusted publishing

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 24
cache: npm
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm run check
- name: Create release PR or publish to npm
uses: changesets/action@v2
with:
publish-script: npm run release
version-script: npx changeset version
commit-message: 'chore: version packages'
pr-title: 'chore: version packages'
# Publishing authenticates with npm trusted publishing (OIDC via `id-token: write`), so no NPM_TOKEN is needed.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Node.js
node_modules/

# Output of npm (installed packages)
package-lock.json

# Dependency directories
/node_modules

Expand All @@ -20,6 +17,8 @@ npm-debug.log*

# Build files
/dist
/coverage
*.tgz

# Mac OS
.DS_Store
Expand Down
5 changes: 0 additions & 5 deletions .npmignore

This file was deleted.

6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dist
coverage
node_modules
package-lock.json
.changeset/*.md
CHANGELOG.md
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"printWidth": 100,
"trailingComma": "all"
}
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Changelog

## 2.0.0

A ground-up rewrite in TypeScript. v1 code keeps working through compatibility helpers.
See "Migrating from v1" in the README for the breaking changes.

### Fixed

- The package now actually ships `CliGenie`. In 1.0.x, `.npmignore` excluded `src/utils`
and `main` pointed at the example script.
- `require('cli-genie').CliGenie` now works (it was `undefined`).
- Works with the ESM-only Inquirer releases. 1.0.x crashed on `require('inquirer')`.
- `when` / `validate` / `default` functions now receive earlier answers, so conditional
questions work.

### Added

- ESM + CommonJS builds with TypeScript type definitions.
- Step builders: `text`, `password`, `number`, `confirm`, `select`, `rawlist`, `checkbox`,
`expand`, `search`, `editor`. Messages, defaults and choices can be computed from earlier answers.
- Review screen (`summary`) with "change an answer" and "start over".
- Progress counter, `title` banner, genie theme (`theme: 'genie' | 'plain' | object`).
- Non-interactive mode with `initialAnswers`, `fromArgv()`, `fromEnv()`, type coercion and validation.
- Hooks: `transform`, `onAnswer`, `onComplete`, `onCancel`.
- `GenieCancelledError`, `MissingAnswerError`, `InvalidAnswerError`, `isCancelled()`.
- JSON wizard definitions (`defineWizard`, `loadWizard`) and the `cli-genie` command.
- Tests, linting, CI on Node 22/24/26, Dependabot and Changesets-based releases with npm provenance.

### Changed

- `run()` resolves with the answers instead of logging them, and throws instead of setting `process.exitCode`.
- Requires Node.js 22.13+.
- Uses `@inquirer/prompts` instead of `inquirer`.

## 1.0.1

- Initial public release.
46 changes: 46 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Contributing

Thanks for helping improve CLI Genie!

## Setup

```bash
git clone https://github.com/bentoms-dev/cli-genie.git
cd cli-genie
npm install
```

You'll need Node.js 22.13+ or 24+.

## Scripts

| Command | What it does |
| ------------------------ | ----------------------------------------------------- |
| `npm test` | Run the Vitest suite |
| `npm run test:watch` | Tests in watch mode |
| `npm run typecheck` | Type-check with `tsc` |
| `npm run lint` | ESLint |
| `npm run format` | Format with Prettier |
| `npm run build` | Build `dist/` (ESM, CJS, types and the CLI) with tsup |
| `npm run check` | Everything CI runs |
| `node examples/basic.js` | Try the library (after `npm run build`) |

## Tests

Interactive behaviour is tested end to end with
[`@inquirer/testing`](https://github.com/SBoudrias/Inquirer.js/tree/main/packages/testing).
Import `screen` from `@inquirer/testing/vitest` before anything that uses prompts. Then drive it
with `screen.type()` / `screen.keypress()` and use the `prompted(text)` helper in
`test/genie.test.ts` to wait for the next question.

## Releasing

Releases are automated with [Changesets](https://github.com/changesets/changesets):

1. Add a changeset to your PR with `npm run changeset`.
2. When it's merged, the Release workflow opens a "version packages" PR.
3. Merging that PR publishes to npm with provenance.

Publishing uses [npm trusted publishing](https://docs.npmjs.com/trusted-publishers), so no npm
token is stored in GitHub. The `cli-genie` package on npmjs.com trusts the `release.yml` workflow
in `bentoms-dev/cli-genie`, with "npm publish" allowed.
Loading
Loading