-
Notifications
You must be signed in to change notification settings - Fork 895
add ink #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add ink #95
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| root = true | ||
|
|
||
| [*] | ||
| indent_style = tab | ||
| end_of_line = lf | ||
| charset = utf-8 | ||
| trim_trailing_whitespace = true | ||
| insert_final_newline = true | ||
|
|
||
| [*.yml] | ||
| indent_style = space | ||
| indent_size = 2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * text=auto eol=lf |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| node_modules | ||
| dist |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| dist |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| { | ||
| "name": "cli", | ||
| "version": "0.0.0", | ||
| "license": "MIT", | ||
| "bin": "dist/cli.js", | ||
| "type": "module", | ||
| "engines": { | ||
| "node": ">=16" | ||
| }, | ||
| "scripts": { | ||
| "build": "tsc", | ||
| "dev": "tsc --watch", | ||
| "start": "bun watch.ts", | ||
| "typecheck": "tsc --noEmit", | ||
| "test": "prettier --check . && xo && ava", | ||
| "lint": "biome check --write .", | ||
| "lint:check": "biome check .", | ||
| "format": "biome format --write .", | ||
| "format:check": "biome format ." | ||
| }, | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "dependencies": { | ||
| "ink": "^4.1.0", | ||
| "meow": "^11.0.0", | ||
| "react": "^19.1.1" | ||
| }, | ||
|
Comment on lines
+24
to
+28
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify React 19.1.1 compatibility with Ink 4.1.0. React 19 is a very recent release. Ensure that Ink 4.1.0 has been tested and verified to work with React 19, as terminal UI rendering can be sensitive to React internals. You may search the web for documentation or recent issues to confirm compatibility: 🌐 Web query: 💡 Result: No — Ink 4.1.0 is not compatible with React 19. (React 19 support was added later; Ink v6+ requires/supports React 19.) [1][2] Sources:
Ink 4.1.0 is incompatible with React 19.1.1 — update to Ink v6+ or downgrade React. Ink 4.1.0 does not support React 19; React 19 support was added in Ink v6+. The current dependency configuration will fail at runtime. Either upgrade Ink to v6+ (which requires React 19) or downgrade React to a version compatible with Ink 4.1.0. File: apps/cli/package.json (lines 18–22) |
||
| "devDependencies": { | ||
| "@sindresorhus/tsconfig": "^3.0.1", | ||
| "@types/react": "^19.1.11", | ||
| "@vdemedes/prettier-config": "^2.0.1", | ||
| "ava": "^5.2.0", | ||
| "chalk": "^5.6.2", | ||
| "chokidar": "^3.5.3", | ||
| "eslint-config-xo-react": "^0.27.0", | ||
| "eslint-plugin-react": "^7.32.2", | ||
| "eslint-plugin-react-hooks": "^4.6.0", | ||
| "ink-testing-library": "^3.0.0", | ||
| "prettier": "^2.8.7", | ||
| "typescript": "^5.9.3", | ||
| "xo": "^0.53.1" | ||
| }, | ||
| "ava": { | ||
| "extensions": { | ||
| "ts": "module", | ||
| "tsx": "module" | ||
| } | ||
| }, | ||
| "xo": { | ||
| "extends": "xo-react", | ||
| "prettier": true, | ||
| "rules": { | ||
| "react/prop-types": "off" | ||
| } | ||
| }, | ||
| "prettier": "@vdemedes/prettier-config" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # cli | ||
|
|
||
| > This readme is automatically generated by [create-ink-app](https://github.com/vadimdemedes/create-ink-app) | ||
|
|
||
| ## Install | ||
|
|
||
| ```bash | ||
| $ npm install --global cli | ||
| ``` | ||
|
|
||
| ## CLI | ||
|
|
||
| ``` | ||
| $ cli --help | ||
|
|
||
| Usage | ||
| $ cli | ||
|
|
||
| Options | ||
| --name Your name | ||
|
|
||
| Examples | ||
| $ cli --name=Jane | ||
| Hello, Jane | ||
| ``` |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,63 @@ | ||||||
| import { Box, Text, useApp, useInput } from "ink"; | ||||||
| import React, { useEffect, useState } from "react"; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove unused React import causing pipeline failure. The React import is not needed in modern React with the JSX transform and is causing a CI failure. Apply this diff: import { Box, Text, useApp, useInput } from "ink";
-import React, { useEffect, useState } from "react";
+import { useEffect, useState } from "react";📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: CI[error] 2-2: lint/correctness/noUnusedImports FIXABLE - Import 'React' is unused. 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| type Props = { | ||||||
| name: string | undefined; | ||||||
| }; | ||||||
|
|
||||||
| export default function App({ name = "Stranger" }: Props) { | ||||||
| const [counter, setCounter] = useState(0); | ||||||
| const [input, setInput] = useState(""); | ||||||
| const { exit } = useApp(); | ||||||
|
|
||||||
| useEffect(() => { | ||||||
| const timer = setInterval(() => { | ||||||
| setCounter((c) => c + 1); | ||||||
| }, 1000); | ||||||
|
|
||||||
| return () => clearInterval(timer); | ||||||
| }, []); | ||||||
|
|
||||||
| useInput((input, key) => { | ||||||
| if (key.escape || (key.ctrl && input === "c")) { | ||||||
| exit(); | ||||||
| } | ||||||
|
|
||||||
| if (key.return) { | ||||||
| setInput(""); | ||||||
| } else if (key.backspace || key.delete) { | ||||||
| setInput((prev) => prev.slice(0, -1)); | ||||||
| } else if (!key.ctrl && !key.meta) { | ||||||
| setInput((prev) => prev + input); | ||||||
| } | ||||||
| }); | ||||||
|
|
||||||
| return ( | ||||||
| <Box | ||||||
| flexDirection="column" | ||||||
| padding={1} | ||||||
| borderStyle="round" | ||||||
| borderColor="red" | ||||||
| > | ||||||
| <Text> | ||||||
| 👋 Welcome,{" "} | ||||||
| <Text color="red" bold> | ||||||
| {name} | ||||||
| </Text> | ||||||
| ! 🚀 | ||||||
| </Text> | ||||||
| <Text color="green">⏱️ Runtime: {counter}s</Text> | ||||||
| <Box marginTop={1}> | ||||||
| <Text> | ||||||
| Type something:{" "} | ||||||
| <Text color="yellow" bold> | ||||||
| {input} | ||||||
| </Text> | ||||||
| </Text> | ||||||
| </Box> | ||||||
| <Box marginTop={1}> | ||||||
| <Text dimColor>Press ESC or Ctrl+C to exit</Text> | ||||||
| </Box> | ||||||
| </Box> | ||||||
| ); | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| #!/usr/bin/env node | ||
| import React from "react"; | ||
| import { render } from "ink"; | ||
| import meow from "meow"; | ||
| import App from "./app.js"; | ||
|
|
||
| const cli = meow( | ||
| ` | ||
| Usage | ||
| $ cli | ||
|
|
||
| Options | ||
| --name Your name | ||
|
|
||
| Examples | ||
| $ cli --name=Jane | ||
| Hello, Jane | ||
| `, | ||
| { | ||
| importMeta: import.meta, | ||
| flags: { | ||
| name: { | ||
| type: "string", | ||
| }, | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| render(<App name={cli.flags.name} />); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import React from "react"; | ||
| import chalk from "chalk"; | ||
| import test from "ava"; | ||
| import { render } from "ink-testing-library"; | ||
| import App from "./source/app.js"; | ||
|
|
||
| test("greet unknown user", (t) => { | ||
| const { lastFrame } = render(<App />); | ||
|
|
||
| t.is(lastFrame(), `Hello, ${chalk.green("Stranger")}`); | ||
| }); | ||
|
|
||
| test("greet user with a name", (t) => { | ||
| const { lastFrame } = render(<App name="Jane" />); | ||
|
|
||
| t.is(lastFrame(), `Hello, ${chalk.green("Jane")}`); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "extends": "@sindresorhus/tsconfig", | ||
| "compilerOptions": { | ||
| "outDir": "dist", | ||
| "skipLibCheck": true, | ||
| "types": [] | ||
| }, | ||
| "include": ["source"] | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||||||||
| #!/usr/bin/env node | ||||||||||||
| import { spawn, type ChildProcess } from "node:child_process"; | ||||||||||||
| import chokidar from "chokidar"; | ||||||||||||
|
|
||||||||||||
|
Comment on lines
+2
to
+4
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix import sorting to resolve pipeline failure. The imports are not sorted according to the project's linting rules, causing a CI failure. Apply this diff: -import { spawn, type ChildProcess } from "node:child_process";
-import chokidar from "chokidar";
+import chokidar from "chokidar";
+import { spawn, type ChildProcess } from "node:child_process";📝 Committable suggestion
Suggested change
🧰 Tools🪛 GitHub Actions: CI[warning] 2-4: assist/source/organizeImports FIXABLE - The imports and exports are not sorted. 🤖 Prompt for AI Agents |
||||||||||||
| let child: ChildProcess | null = null; | ||||||||||||
|
|
||||||||||||
| function startApp() { | ||||||||||||
| if (child) { | ||||||||||||
| child.kill(); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| console.log("\x1b[36m[watch] Starting app...\x1b[0m"); | ||||||||||||
| child = spawn("node", ["dist/cli.js"], { | ||||||||||||
| stdio: "inherit", | ||||||||||||
| shell: false, | ||||||||||||
| }); | ||||||||||||
|
|
||||||||||||
| child.on("exit", (code) => { | ||||||||||||
| if (code !== null && code !== 0 && code !== 130) { | ||||||||||||
| console.log(`\x1b[33m[watch] App exited with code ${code}\x1b[0m`); | ||||||||||||
| } | ||||||||||||
| }); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| const watcher = chokidar.watch("dist/**/*", { | ||||||||||||
| ignoreInitial: false, | ||||||||||||
| persistent: true, | ||||||||||||
| }); | ||||||||||||
|
|
||||||||||||
| watcher.on("ready", () => { | ||||||||||||
| console.log("\x1b[36m[watch] Watching dist/ for changes...\x1b[0m"); | ||||||||||||
| startApp(); | ||||||||||||
| }); | ||||||||||||
|
|
||||||||||||
| watcher.on("change", (path) => { | ||||||||||||
| console.log(`\x1b[36m[watch] File changed: ${path}\x1b[0m`); | ||||||||||||
| startApp(); | ||||||||||||
| }); | ||||||||||||
|
|
||||||||||||
| process.on("SIGINT", () => { | ||||||||||||
| if (child) { | ||||||||||||
| child.kill(); | ||||||||||||
| } | ||||||||||||
| process.exit(0); | ||||||||||||
| }); | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Verify Node.js version requirement for React 19.
The manifest specifies Node >=16, but React 19 is a recent release that may require a newer Node.js version. Node 16 reached end-of-life in September 2023.
Verify the minimum Node.js version required by React 19:
🌐 Web query:
💡 Result:
React itself (React 19) has no strict minimum Node.js requirement — it's a client library; the React 19 upgrade guide doesn't set a Node version. [1]
However, many popular toolchains and frameworks used with React 19 (Vite, Next, Chakra, etc.) require modern Node — commonly Node 20+ (or Node 18.18+/22+ for some tools). So upgrade your Node runtime to at least Node 20 to avoid toolchain/CI issues. [1][2]
Sources:
🏁 Script executed:
Length of output: 1226
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 27
🏁 Script executed:
Length of output: 45
🏁 Script executed:
Length of output: 86
🏁 Script executed:
Length of output: 19
Update Node.js engine requirement to >=16.15 minimum.
The specification ">=16" is insufficient because ava 5.2.0 requires Node >=16.15 when using the Node 16 track. This means Node 16.0–16.14 would fail tests. Since Node 16 is EOL (September 2023), consider updating to
">=18"for better alignment with modern toolchains.🤖 Prompt for AI Agents