Ink is a React renderer for CLIs.
It provides the same experience that React offers in the browser.
Uses Yoga to build Flexbox layouts.
Yoga is a cross-platform layout engine which implements Flexbox.
If you know React, you know Ink.
Embrace component-driven design.
Create user-friendly interactive CLI interfaces easily
mkdir my-fancy-cli
cd my-fancy-cli
npx create-ink-app
# Or create with TypeScript React
npx create-ink-app --typescript
.
├── dist
│ ├── cli.d.ts
│ ├── cli.js
│ ├── test.d.ts
│ ├── test.js
│ ├── ui.d.ts
│ └── ui.js
├── package-lock.json
├── package.json
├── readme.md
├── source
│ ├── cli.tsx
│ ├── test.tsx
│ └── ui.tsx
└── tsconfig.json
it uses meow as CLI helper
const cli = meow(
`
Usage
$ foo <input>
Options
--rainbow, -r Include a rainbow
Examples
$ foo unicorns --rainbow
🌈 unicorns 🌈
`,
{
flags: {
rainbow: {
type: 'boolean',
alias: 'r',
},
},
}
);
# .babelrc
{
"presets": [
"@babel/preset-react",
[
"@babel/preset-env",
{ "targets": { "node": true } }
]
]
}
npx babel source.js -o cli.js
npm install --save-dev @babel/preset-react
const importJsx = require('import-jsx');
importJsx('./Counter');
npm install --save import-jsx
ts-node -O '{\"module\": \"commonjs\"}'