https://github.com/idleberg/yeoman-adapter-clack
A Yeoman adapter that replaces Inquirer with Clack as the default prompt library
https://github.com/idleberg/yeoman-adapter-clack
clack clack-prompt yeoman yeoman-adapter
Last synced: 5 months ago
JSON representation
A Yeoman adapter that replaces Inquirer with Clack as the default prompt library
- Host: GitHub
- URL: https://github.com/idleberg/yeoman-adapter-clack
- Owner: idleberg
- License: mit
- Created: 2026-01-02T09:07:17.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2026-01-05T12:31:16.000Z (5 months ago)
- Last Synced: 2026-01-13T19:46:29.553Z (5 months ago)
- Topics: clack, clack-prompt, yeoman, yeoman-adapter
- Language: TypeScript
- Homepage: https://www.npmjs.org/package/yeoman-adapter-clack
- Size: 239 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# yeoman-adapter-clack
> A Yeoman adapter that replaces `inquirer` with `@clack/prompts` as the default
> prompt library.
[](https://github.com/idleberg/yeoman-adapter-clack/blob/main/LICENSE)
[](https://www.npmjs.org/package/yeoman-adapter-clack)

## Installation đŋ
```shell
npm install yeoman-adapter-clack
```
## Usage đ
To make use of this adapter, you need to overwrite the default one.
> [!TIP]
>
> For easy migration, you can import `ClackCompatAdapter` instead. Unlike the
> default adapter, it's API-compatible with Inquirer.
```typescript
import { ClackAdapter } from "yeoman-adapter-clack";
import { createEnv } from "yeoman-environment";
import Generator from "yeoman-generator";
export default class extends Generator {
constructor(args, options) {
if (options.env) {
const adapter = options.env.adapter;
const isTestAdapter = adapter.constructor.name === "TestAdapter";
if (!isTestAdapter && !(adapter instanceof ClackAdapter)) {
options.env.adapter = new ClackAdapter();
}
} else {
options.env = createEnv({ adapter: new ClackAdapter() });
}
super(args, options);
}
}
```
> [!TIP]
>
> Alternatively, you can use replace the default generator with [@idleberg/yeoman-generator](https://www.npmjs.com/package/@idleberg/yeoman-generator). This also exposes access to the full Clack prompts API.
### API âī¸
#### `ClackAdapter`
Usage: `new ClackAdapter()`
The default adapter implements its own API for prompts. It's basically follows
[Clack prompt API](https://bomb.sh/docs/clack/packages/prompts/) with additional
properties based on the default
[Yeoman prompt API](https://yeoman.io/authoring/user-interactions).
**Example**
```typescript
const answers = await this.prompt([
{
// Required adapter-specific properties
type: "text",
name: "userName",
// Standard Clack API
message: "What is your name?",
placeholder: "John Appleseed",
validate: (value) => {
if (value.length < 2) return "Name must be at least 2 characters";
return undefined;
},
// Optional adapter-specific properties
store: true,
when: () => true,
},
]);
```
Supported types are `autocomplete`, `autocompleteMultiselect`, `confirm`,
`multiselect`, `password`, `select` and `text`. For backwards-compatibility,
there is also an `expand` type matching the behavior of
[Inquirer](https://www.npmjs.com/package/@inquirer/expand).
For further details, please check the
[type signatures](https://github.com/idleberg/yeoman-adapter-clack/blob/main/src/clack.d.ts).
#### `ClackCompatAdapter`
Usage: `new ClackCompatAdapter()`
This adapter provides an Inquirer-compatible prompt API, see the official
[Yeoman documentation](https://yeoman.io/authoring/user-interactions).
## Limitations âī¸
Sadly, not all features can be realized in Clack prompts. The following limitations apply:
- separators are not supported in the compatibility adapter and need to be removed
- the `expand` type does not support keyboard shortcuts
## License Šī¸
This work is licensed under [The MIT License](LICENSE).