ink 3.1.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/colorize.d.ts +3 -3
- package/build/colorize.js +30 -35
- package/build/colorize.js.map +1 -1
- package/build/components/App.d.ts +12 -12
- package/build/components/App.js +287 -208
- package/build/components/App.js.map +1 -1
- package/build/components/AppContext.d.ts +2 -2
- package/build/components/AppContext.js +5 -6
- package/build/components/AppContext.js.map +1 -1
- package/build/components/Box.d.ts +5 -5
- package/build/components/Box.js +15 -38
- package/build/components/Box.js.map +1 -1
- package/build/components/ErrorOverview.d.ts +5 -5
- package/build/components/ErrorOverview.js +40 -58
- package/build/components/ErrorOverview.js.map +1 -1
- package/build/components/FocusContext.d.ts +2 -2
- package/build/components/FocusContext.js +13 -14
- package/build/components/FocusContext.js.map +1 -1
- package/build/components/Newline.d.ts +4 -5
- package/build/components/Newline.js +4 -9
- package/build/components/Newline.js.map +1 -1
- package/build/components/Spacer.d.ts +2 -3
- package/build/components/Spacer.js +5 -10
- package/build/components/Spacer.js.map +1 -1
- package/build/components/Static.d.ts +5 -9
- package/build/components/Static.js +12 -33
- package/build/components/Static.js.map +1 -1
- package/build/components/StderrContext.d.ts +4 -4
- package/build/components/StderrContext.js +7 -7
- package/build/components/StderrContext.js.map +1 -1
- package/build/components/StdinContext.d.ts +4 -4
- package/build/components/StdinContext.js +8 -7
- package/build/components/StdinContext.js.map +1 -1
- package/build/components/StdoutContext.d.ts +4 -4
- package/build/components/StdoutContext.js +7 -7
- package/build/components/StdoutContext.js.map +1 -1
- package/build/components/Text.d.ts +9 -10
- package/build/components/Text.js +14 -29
- package/build/components/Text.js.map +1 -1
- package/build/components/Transform.d.ts +4 -5
- package/build/components/Transform.js +4 -11
- package/build/components/Transform.js.map +1 -1
- package/build/devtools-window-polyfill.js +3 -8
- package/build/devtools-window-polyfill.js.map +1 -1
- package/build/devtools.d.ts +1 -1
- package/build/devtools.js +6 -6
- package/build/devtools.js.map +1 -1
- package/build/dom.d.ts +14 -17
- package/build/dom.js +34 -47
- package/build/dom.js.map +1 -1
- package/build/get-max-width.d.ts +2 -2
- package/build/get-max-width.js +7 -11
- package/build/get-max-width.js.map +1 -1
- package/build/hooks/use-app.d.ts +1 -1
- package/build/hooks/use-app.js +4 -9
- package/build/hooks/use-app.js.map +1 -1
- package/build/hooks/use-focus-manager.d.ts +3 -3
- package/build/hooks/use-focus-manager.js +4 -9
- package/build/hooks/use-focus-manager.js.map +1 -1
- package/build/hooks/use-focus.d.ts +4 -4
- package/build/hooks/use-focus.js +11 -16
- package/build/hooks/use-focus.js.map +1 -1
- package/build/hooks/use-input.d.ts +5 -5
- package/build/hooks/use-input.js +13 -14
- package/build/hooks/use-input.js.map +1 -1
- package/build/hooks/use-stderr.d.ts +1 -1
- package/build/hooks/use-stderr.js +4 -9
- package/build/hooks/use-stderr.js.map +1 -1
- package/build/hooks/use-stdin.d.ts +1 -1
- package/build/hooks/use-stdin.js +4 -9
- package/build/hooks/use-stdin.js.map +1 -1
- package/build/hooks/use-stdout.d.ts +1 -1
- package/build/hooks/use-stdout.js +4 -9
- package/build/hooks/use-stdout.js.map +1 -1
- package/build/index.d.ts +27 -20
- package/build/index.js +15 -32
- package/build/index.js.map +1 -1
- package/build/ink.d.ts +4 -4
- package/build/ink.js +166 -97
- package/build/ink.js.map +1 -1
- package/build/instances.d.ts +4 -2
- package/build/instances.js +2 -3
- package/build/instances.js.map +1 -1
- package/build/log-update.d.ts +5 -6
- package/build/log-update.js +8 -12
- package/build/log-update.js.map +1 -1
- package/build/measure-element.d.ts +5 -5
- package/build/measure-element.js +5 -9
- package/build/measure-element.js.map +1 -1
- package/build/measure-text.d.ts +4 -4
- package/build/measure-text.js +7 -10
- package/build/measure-text.js.map +1 -1
- package/build/output.d.ts +3 -3
- package/build/output.js +25 -15
- package/build/output.js.map +1 -1
- package/build/reconciler.d.ts +2 -2
- package/build/reconciler.js +100 -76
- package/build/reconciler.js.map +1 -1
- package/build/render-border.d.ts +4 -4
- package/build/render-border.js +8 -12
- package/build/render-border.js.map +1 -1
- package/build/render-node-to-output.d.ts +3 -3
- package/build/render-node-to-output.js +17 -24
- package/build/render-node-to-output.js.map +1 -1
- package/build/render.d.ts +8 -8
- package/build/render.js +23 -20
- package/build/render.js.map +1 -1
- package/build/renderer.d.ts +5 -5
- package/build/renderer.js +11 -16
- package/build/renderer.js.map +1 -1
- package/build/squash-text-nodes.d.ts +1 -1
- package/build/squash-text-nodes.js +1 -3
- package/build/squash-text-nodes.js.map +1 -1
- package/build/styles.d.ts +9 -9
- package/build/styles.js +39 -45
- package/build/styles.js.map +1 -1
- package/build/wrap-text.d.ts +3 -3
- package/build/wrap-text.js +9 -12
- package/build/wrap-text.js.map +1 -1
- package/license +1 -1
- package/package.json +87 -67
- package/readme.md +91 -49
package/package.json
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ink",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "React for CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "vadimdemedes/ink",
|
|
7
7
|
"author": {
|
|
8
|
-
"name": "
|
|
9
|
-
"email": "
|
|
8
|
+
"name": "Vadim Demedes",
|
|
9
|
+
"email": "vadimdemedes@hey.com",
|
|
10
10
|
"url": "https://github.com/vadimdemedes"
|
|
11
11
|
},
|
|
12
|
-
"
|
|
13
|
-
"
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
"types": "./build/index.d.ts",
|
|
15
|
+
"default": "./build/index.js"
|
|
16
|
+
},
|
|
14
17
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
18
|
+
"node": ">=14.16"
|
|
16
19
|
},
|
|
17
20
|
"scripts": {
|
|
18
21
|
"build": "tsc",
|
|
19
22
|
"prepare": "npm run build",
|
|
20
|
-
"test": "tsc --noEmit && xo && FORCE_COLOR=true ava"
|
|
23
|
+
"test": "tsc --noEmit && xo && FORCE_COLOR=true ava",
|
|
24
|
+
"example": "NODE_NO_WARNINGS=1 node --loader ts-node/esm",
|
|
25
|
+
"benchmark": "NODE_NO_WARNINGS=1 node --loader ts-node/esm"
|
|
21
26
|
},
|
|
22
27
|
"files": [
|
|
23
28
|
"build"
|
|
@@ -37,83 +42,91 @@
|
|
|
37
42
|
"text"
|
|
38
43
|
],
|
|
39
44
|
"dependencies": {
|
|
40
|
-
"ansi-escapes": "^
|
|
41
|
-
"auto-bind": "
|
|
42
|
-
"chalk": "^
|
|
43
|
-
"cli-boxes": "^
|
|
44
|
-
"cli-cursor": "^
|
|
45
|
-
"cli-truncate": "^
|
|
46
|
-
"code-excerpt": "^
|
|
47
|
-
"indent-string": "^
|
|
48
|
-
"is-ci": "^
|
|
49
|
-
"lodash": "^4.17.
|
|
50
|
-
"patch-console": "^
|
|
51
|
-
"react-
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"string-width": "^4.2.2",
|
|
45
|
+
"ansi-escapes": "^6.0.0",
|
|
46
|
+
"auto-bind": "^5.0.1",
|
|
47
|
+
"chalk": "^5.2.0",
|
|
48
|
+
"cli-boxes": "^3.0.0",
|
|
49
|
+
"cli-cursor": "^4.0.0",
|
|
50
|
+
"cli-truncate": "^3.1.0",
|
|
51
|
+
"code-excerpt": "^4.0.0",
|
|
52
|
+
"indent-string": "^5.0.0",
|
|
53
|
+
"is-ci": "^3.0.1",
|
|
54
|
+
"lodash-es": "^4.17.21",
|
|
55
|
+
"patch-console": "^2.0.0",
|
|
56
|
+
"react-reconciler": "^0.29.0",
|
|
57
|
+
"scheduler": "^0.23.0",
|
|
58
|
+
"signal-exit": "^3.0.7",
|
|
59
|
+
"slice-ansi": "^5.0.0",
|
|
60
|
+
"stack-utils": "^2.0.6",
|
|
61
|
+
"string-width": "^5.1.2",
|
|
58
62
|
"type-fest": "^0.12.0",
|
|
59
|
-
"widest-line": "^
|
|
60
|
-
"wrap-ansi": "^
|
|
61
|
-
"ws": "^
|
|
63
|
+
"widest-line": "^4.0.1",
|
|
64
|
+
"wrap-ansi": "^8.1.0",
|
|
65
|
+
"ws": "^8.12.0",
|
|
62
66
|
"yoga-layout-prebuilt": "^1.9.6"
|
|
63
67
|
},
|
|
64
68
|
"devDependencies": {
|
|
65
|
-
"@
|
|
69
|
+
"@faker-js/faker": "^7.6.0",
|
|
70
|
+
"@sindresorhus/tsconfig": "3.0.1",
|
|
71
|
+
"@types/benchmark": "^2.1.2",
|
|
66
72
|
"@types/is-ci": "^2.0.0",
|
|
67
|
-
"@types/lodash": "^4.
|
|
73
|
+
"@types/lodash-es": "^4.17.6",
|
|
74
|
+
"@types/ms": "^0.7.31",
|
|
68
75
|
"@types/node": "*",
|
|
69
|
-
"@types/react": "^
|
|
70
|
-
"@types/react-reconciler": "^0.
|
|
71
|
-
"@types/scheduler": "^0.16.
|
|
76
|
+
"@types/react": "^18.0.0",
|
|
77
|
+
"@types/react-reconciler": "^0.28.2",
|
|
78
|
+
"@types/scheduler": "^0.16.2",
|
|
72
79
|
"@types/signal-exit": "^3.0.0",
|
|
73
80
|
"@types/sinon": "^9.0.4",
|
|
74
81
|
"@types/slice-ansi": "^4.0.0",
|
|
75
82
|
"@types/stack-utils": "^1.0.1",
|
|
76
83
|
"@types/wrap-ansi": "^3.0.0",
|
|
84
|
+
"@types/ws": "^8.5.4",
|
|
77
85
|
"@vdemedes/prettier-config": "^1.0.1",
|
|
78
|
-
"ava": "^
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"eslint-plugin-react": "^7.18.0",
|
|
88
|
-
"eslint-plugin-react-hooks": "^2.3.0",
|
|
89
|
-
"import-jsx": "3.1.0",
|
|
90
|
-
"ms": "^2.1.1",
|
|
91
|
-
"node-pty": "^0.9.0",
|
|
92
|
-
"p-queue": "^6.2.1",
|
|
86
|
+
"ava": "^5.1.1",
|
|
87
|
+
"boxen": "^7.0.1",
|
|
88
|
+
"delay": "^5.0.0",
|
|
89
|
+
"eslint-config-xo-react": "^0.27.0",
|
|
90
|
+
"eslint-plugin-react": "^7.32.2",
|
|
91
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
92
|
+
"ms": "^2.1.3",
|
|
93
|
+
"node-pty": "0.10.1",
|
|
94
|
+
"p-queue": "^7.3.4",
|
|
93
95
|
"prettier": "^2.0.4",
|
|
94
|
-
"react": "^
|
|
95
|
-
"
|
|
96
|
+
"react": "^18.0.0",
|
|
97
|
+
"react-devtools-core": "^4.19.1",
|
|
98
|
+
"sinon": "^12.0.1",
|
|
96
99
|
"strip-ansi": "^6.0.0",
|
|
97
|
-
"ts-node": "
|
|
98
|
-
"typescript": "^
|
|
99
|
-
"xo": "^0.
|
|
100
|
+
"ts-node": "10.9.1",
|
|
101
|
+
"typescript": "^4.9.4",
|
|
102
|
+
"xo": "^0.53.0"
|
|
100
103
|
},
|
|
101
104
|
"peerDependencies": {
|
|
102
|
-
"@types/react": ">=
|
|
103
|
-
"react": ">=
|
|
105
|
+
"@types/react": ">=18.0.0",
|
|
106
|
+
"react": ">=18.0.0",
|
|
107
|
+
"react-devtools-core": "^4.19.1"
|
|
104
108
|
},
|
|
105
109
|
"peerDependenciesMeta": {
|
|
106
110
|
"@types/react": {
|
|
107
111
|
"optional": true
|
|
112
|
+
},
|
|
113
|
+
"react-devtools-core": {
|
|
114
|
+
"optional": true
|
|
108
115
|
}
|
|
109
116
|
},
|
|
110
117
|
"ava": {
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
"
|
|
118
|
+
"workerThreads": false,
|
|
119
|
+
"files": [
|
|
120
|
+
"test/**/*",
|
|
121
|
+
"!test/helpers/**/*",
|
|
122
|
+
"!test/fixtures/**/*"
|
|
114
123
|
],
|
|
115
|
-
"
|
|
116
|
-
"ts
|
|
124
|
+
"extensions": {
|
|
125
|
+
"ts": "module",
|
|
126
|
+
"tsx": "module"
|
|
127
|
+
},
|
|
128
|
+
"nodeArguments": [
|
|
129
|
+
"--loader=ts-node/esm"
|
|
117
130
|
]
|
|
118
131
|
},
|
|
119
132
|
"xo": {
|
|
@@ -127,7 +140,12 @@
|
|
|
127
140
|
"rules": {
|
|
128
141
|
"react/no-unescaped-entities": "off",
|
|
129
142
|
"react/state-in-constructor": "off",
|
|
130
|
-
"react/jsx-indent": "off"
|
|
143
|
+
"react/jsx-indent": "off",
|
|
144
|
+
"react/prop-types": "off",
|
|
145
|
+
"unicorn/import-index": "off",
|
|
146
|
+
"import/no-useless-path-segments": "off",
|
|
147
|
+
"react-hooks/exhaustive-deps": "off",
|
|
148
|
+
"complexity": "off"
|
|
131
149
|
},
|
|
132
150
|
"overrides": [
|
|
133
151
|
{
|
|
@@ -147,23 +165,25 @@
|
|
|
147
165
|
}
|
|
148
166
|
],
|
|
149
167
|
"unicorn/filename-case": "off",
|
|
150
|
-
"react/prop-types": "off",
|
|
151
168
|
"react/default-props-match-prop-types": "off",
|
|
152
169
|
"unicorn/prevent-abbreviations": "off",
|
|
153
|
-
"react/require-default-props": "
|
|
170
|
+
"react/require-default-props": "off",
|
|
154
171
|
"react/jsx-curly-brace-presence": "off",
|
|
155
|
-
"@typescript-eslint/no-empty-function": "
|
|
172
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
156
173
|
"@typescript-eslint/promise-function-async": "warn",
|
|
157
174
|
"@typescript-eslint/explicit-function-return": "off",
|
|
158
|
-
"@typescript-eslint/explicit-function-return-type": "off"
|
|
175
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
176
|
+
"dot-notation": "off",
|
|
177
|
+
"react/boolean-prop-naming": "off"
|
|
159
178
|
}
|
|
160
179
|
},
|
|
161
180
|
{
|
|
162
181
|
"files": [
|
|
163
|
-
"examples/**/*.
|
|
182
|
+
"examples/**/*.{ts,tsx}",
|
|
183
|
+
"benchmark/**/*.{ts,tsx}"
|
|
164
184
|
],
|
|
165
185
|
"rules": {
|
|
166
|
-
"
|
|
186
|
+
"import/no-unassigned-import": "off"
|
|
167
187
|
}
|
|
168
188
|
}
|
|
169
189
|
]
|
package/readme.md
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
[](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
2
6
|
<br>
|
|
3
7
|
<br>
|
|
4
|
-
<img width="
|
|
8
|
+
<img width="240" alt="Ink" src="media/logo.png">
|
|
5
9
|
<br>
|
|
6
10
|
<br>
|
|
7
11
|
<br>
|
|
8
|
-
</
|
|
12
|
+
</div>
|
|
9
13
|
|
|
10
14
|
> React for CLIs. Build and test your CLI output using components.
|
|
11
15
|
|
|
@@ -20,12 +24,39 @@ Since Ink is a React renderer, it means that all features of React are supported
|
|
|
20
24
|
Head over to [React](https://reactjs.org) website for documentation on how to use it.
|
|
21
25
|
Only Ink's methods will be documented in this readme.
|
|
22
26
|
|
|
23
|
-
**Note:** This is documentation for Ink
|
|
27
|
+
**Note:** This is documentation for Ink 4. If you're looking for docs on Ink 3, check out [this release](https://github.com/vadimdemedes/ink/tree/v3.2.0).
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
<div align="center">
|
|
32
|
+
<p>
|
|
33
|
+
<p>
|
|
34
|
+
<sup>
|
|
35
|
+
<a href="https://opencollective.com/vadimdemedes">My open source work is supported by the community ❤️</a>
|
|
36
|
+
</sup>
|
|
37
|
+
</p>
|
|
38
|
+
<sup>Special thanks to:</sup>
|
|
39
|
+
<br>
|
|
40
|
+
<a href="https://workos.com/?utm_campaign=github_repo&utm_medium=referral&utm_content=ink&utm_source=github">
|
|
41
|
+
<div>
|
|
42
|
+
<img src="https://vadimdemedes.com/github/workos.svg" width="200" alt="WorkOS">
|
|
43
|
+
</div>
|
|
44
|
+
<b>Your app, enterprise-ready.</b>
|
|
45
|
+
<div>
|
|
46
|
+
<sub>Start selling to enterprise customers with just a few lines of code.</sub>
|
|
47
|
+
<br>
|
|
48
|
+
<sup>Add Single Sign-On (and more) in minutes instead of months.</sup>
|
|
49
|
+
</div>
|
|
50
|
+
</a>
|
|
51
|
+
</p>
|
|
52
|
+
<br>
|
|
53
|
+
<br>
|
|
54
|
+
</div>
|
|
24
55
|
|
|
25
56
|
## Install
|
|
26
57
|
|
|
27
|
-
```
|
|
28
|
-
|
|
58
|
+
```sh
|
|
59
|
+
npm install ink react
|
|
29
60
|
```
|
|
30
61
|
|
|
31
62
|
## Usage
|
|
@@ -60,36 +91,42 @@ Feel free to play around with the code and fork this repl at [https://repl.it/@v
|
|
|
60
91
|
|
|
61
92
|
## Who's Using Ink?
|
|
62
93
|
|
|
94
|
+
- [Cloudflare's Wrangler](https://github.com/cloudflare/wrangler2) - The CLI for Cloudflare Workers.
|
|
63
95
|
- [Gatsby](https://www.gatsbyjs.org) - Gatsby is a modern web framework for blazing fast websites.
|
|
64
96
|
- [tap](https://node-tap.org) - A Test-Anything-Protocol library for JavaScript.
|
|
65
97
|
- [Terraform CDK](https://github.com/hashicorp/terraform-cdk) - CDK (Cloud Development Kit) for HashiCorp Terraform.
|
|
66
98
|
- [Twilio's SIGNAL](https://github.com/twilio-labs/plugin-signal2020) - CLI for Twilio's SIGNAL conference. [Blog post](https://www.twilio.com/blog/building-conference-cli-in-react).
|
|
67
99
|
- [Typewriter](https://github.com/segmentio/typewriter) - Generates strongly-typed [Segment](https://segment.com) analytics clients from arbitrary JSON Schema.
|
|
68
100
|
- [Prisma](https://www.prisma.io) - The unified data layer for modern applications.
|
|
69
|
-
- [Wallace](https://www.projectwallace.com) - Pretty CSS analytics
|
|
101
|
+
- [Wallace](https://www.projectwallace.com) - Pretty CSS analytics.
|
|
70
102
|
- [Blitz](https://blitzjs.com) - The Fullstack React Framework.
|
|
71
103
|
- [New York Times](https://github.com/nytimes/kyt) - NYT uses Ink `kyt` - a toolkit that encapsulates and manages the configuration for web apps.
|
|
72
104
|
- [tink](https://github.com/npm/tink) - Next-generation runtime and package manager.
|
|
73
|
-
- [
|
|
105
|
+
- [Inkle](https://github.com/jrr/inkle) - Wordle game.
|
|
106
|
+
- [loki](https://github.com/oblador/loki) - Visual regression testing for Storybook.
|
|
74
107
|
- [Bit](https://github.com/teambit/bit) - Build, distribute and collaborate on components.
|
|
75
108
|
- [Remirror](https://github.com/remirror/remirror) - Your friendly, world-class editor toolkit.
|
|
76
109
|
- [Prime](https://github.com/birkir/prime) - Open source GraphQL CMS.
|
|
77
110
|
- [Splash](https://github.com/Shopify/polaris-react/tree/master/scripts/splash) - Observe the splash zone of a change across the Shopify's [Polaris](https://polaris.shopify.com) component library.
|
|
78
|
-
- [emoj](https://github.com/sindresorhus/emoj) - Find relevant
|
|
79
|
-
- [emma](https://github.com/maticzav/emma-cli) -
|
|
111
|
+
- [emoj](https://github.com/sindresorhus/emoj) - Find relevant emojis.
|
|
112
|
+
- [emma](https://github.com/maticzav/emma-cli) - Find and install npm packages.
|
|
80
113
|
- [swiff](https://github.com/simple-integrated-marketing/swiff) - Multi-environment command line tools for time-saving web developers.
|
|
81
|
-
- [share](https://github.com/marionebl/share-cli) - Quickly share files
|
|
114
|
+
- [share](https://github.com/marionebl/share-cli) - Quickly share files.
|
|
82
115
|
- [Kubelive](https://github.com/ameerthehacker/kubelive) - CLI for Kubernetes to provide live data about the cluster and its resources.
|
|
83
|
-
- [changelog-view](https://github.com/jdeniau/changelog-view) -
|
|
84
|
-
- [cfpush](https://github.com/mamachanko/cfpush) - An interactive Cloud Foundry tutorial
|
|
85
|
-
- [startd](https://github.com/mgrip/startd) - Turn your React component into a web app
|
|
86
|
-
- [wiki-cli](https://github.com/hexrcs/wiki-cli) - Search Wikipedia and read summaries
|
|
116
|
+
- [changelog-view](https://github.com/jdeniau/changelog-view) - View changelogs.
|
|
117
|
+
- [cfpush](https://github.com/mamachanko/cfpush) - An interactive Cloud Foundry tutorial.
|
|
118
|
+
- [startd](https://github.com/mgrip/startd) - Turn your React component into a web app.
|
|
119
|
+
- [wiki-cli](https://github.com/hexrcs/wiki-cli) - Search Wikipedia and read summaries.
|
|
87
120
|
- [garson](https://github.com/goliney/garson) - Build interactive config-based command-line interfaces.
|
|
88
121
|
- [git-contrib-calendar](https://github.com/giannisp/git-contrib-calendar) - Display a contributions calendar for any git repository.
|
|
89
122
|
- [gitgud](https://github.com/GitGud-org/GitGud) - An interactive command-line GUI for Git.
|
|
90
|
-
- [Autarky](https://github.com/pranshuchittora/autarky) -
|
|
123
|
+
- [Autarky](https://github.com/pranshuchittora/autarky) - Find and delete old `node_modules` directories in order to free up disk space.
|
|
91
124
|
- [fast-cli](https://github.com/sindresorhus/fast-cli) - Test your download and upload speed.
|
|
92
125
|
- [tasuku](https://github.com/privatenumber/tasuku) - Minimal task runner.
|
|
126
|
+
- [mnswpr](https://github.com/mordv/mnswpr) - Minesweeper game.
|
|
127
|
+
- [lrn](https://github.com/krychu/lrn) - Learning by repetition.
|
|
128
|
+
- [turdle](https://github.com/mynameisankit/turdle) - Wordle game.
|
|
129
|
+
- [Shopify CLI](https://github.com/Shopify/cli) - Build apps, themes, and storefronts for Shopify.
|
|
93
130
|
|
|
94
131
|
## Contents
|
|
95
132
|
|
|
@@ -120,16 +157,14 @@ Feel free to play around with the code and fork this repl at [https://repl.it/@v
|
|
|
120
157
|
|
|
121
158
|
Use [create-ink-app](https://github.com/vadimdemedes/create-ink-app) to quickly scaffold a new Ink-based CLI.
|
|
122
159
|
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
$ cd my-ink-cli
|
|
126
|
-
$ npx create-ink-app
|
|
160
|
+
```sh
|
|
161
|
+
npx create-ink-app my-ink-cli
|
|
127
162
|
```
|
|
128
163
|
|
|
129
164
|
Alternatively, create a TypeScript project:
|
|
130
165
|
|
|
131
|
-
```
|
|
132
|
-
|
|
166
|
+
```sh
|
|
167
|
+
npx create-ink-app --typescript my-ink-cli
|
|
133
168
|
```
|
|
134
169
|
|
|
135
170
|
<details><summary>Manual setup</summary>
|
|
@@ -139,8 +174,8 @@ Ink requires the same Babel setup as you would do for regular React-based apps i
|
|
|
139
174
|
Set up Babel with a React preset to ensure all examples in this readme work as expected.
|
|
140
175
|
After [installing Babel](https://babeljs.io/docs/en/usage), install `@babel/preset-react` and insert the following configuration in `babel.config.json`:
|
|
141
176
|
|
|
142
|
-
```
|
|
143
|
-
|
|
177
|
+
```sh
|
|
178
|
+
npm install --save-dev @babel/preset-react
|
|
144
179
|
```
|
|
145
180
|
|
|
146
181
|
```json
|
|
@@ -172,17 +207,17 @@ render(<Demo />);
|
|
|
172
207
|
|
|
173
208
|
Then, transpile this file with Babel:
|
|
174
209
|
|
|
175
|
-
```
|
|
176
|
-
|
|
210
|
+
```sh
|
|
211
|
+
npx babel source.js -o cli.js
|
|
177
212
|
```
|
|
178
213
|
|
|
179
214
|
Now you can run `cli.js` with Node.js:
|
|
180
215
|
|
|
181
|
-
```
|
|
182
|
-
|
|
216
|
+
```sh
|
|
217
|
+
node cli
|
|
183
218
|
```
|
|
184
219
|
|
|
185
|
-
If you don't like transpiling files during development, you can use [import-jsx](https://github.com/vadimdemedes/import-jsx)
|
|
220
|
+
If you don't like transpiling files during development, you can use [import-jsx](https://github.com/vadimdemedes/import-jsx) or [@esbuild-kit/esm-loader](https://github.com/esbuild-kit/esm-loader) to `import` a JSX file and transpile it on the fly.
|
|
186
221
|
|
|
187
222
|
</p>
|
|
188
223
|
</details>
|
|
@@ -707,7 +742,7 @@ See [align-items](https://css-tricks.com/almanac/properties/a/align-items/).
|
|
|
707
742
|
|
|
708
743
|
Type: `string`\
|
|
709
744
|
Default: `auto`\
|
|
710
|
-
Allowed
|
|
745
|
+
Allowed values: `auto` `flex-start` `center` `flex-end`
|
|
711
746
|
|
|
712
747
|
See [align-self](https://css-tricks.com/almanac/properties/a/align-self/).
|
|
713
748
|
|
|
@@ -1335,7 +1370,7 @@ Default: `process.stdout`
|
|
|
1335
1370
|
import {useStdout} from 'ink';
|
|
1336
1371
|
|
|
1337
1372
|
const Example = () => {
|
|
1338
|
-
const {stdout} = useStdout;
|
|
1373
|
+
const {stdout} = useStdout();
|
|
1339
1374
|
|
|
1340
1375
|
return …
|
|
1341
1376
|
};
|
|
@@ -1461,7 +1496,7 @@ const Example = () => {
|
|
|
1461
1496
|
render(<Example />);
|
|
1462
1497
|
```
|
|
1463
1498
|
|
|
1464
|
-
See example in [examples/use-focus](examples/use-focus/use-focus.js) and [examples/use-focus-with-id](examples/use-focus/use-focus-with-id.js).
|
|
1499
|
+
See example in [examples/use-focus](examples/use-focus/use-focus.js) and [examples/use-focus-with-id](examples/use-focus-with-id/use-focus-with-id.js).
|
|
1465
1500
|
|
|
1466
1501
|
### useFocusManager()
|
|
1467
1502
|
|
|
@@ -1747,14 +1782,14 @@ Check out [ink-testing-library](https://github.com/vadimdemedes/ink-testing-libr
|
|
|
1747
1782
|
Ink supports [React Devtools](https://github.com/facebook/react/tree/master/packages/react-devtools) out-of-the-box.
|
|
1748
1783
|
To enable integration with React Devtools in your Ink-based CLI, run it with `DEV=true` environment variable:
|
|
1749
1784
|
|
|
1750
|
-
```
|
|
1751
|
-
|
|
1785
|
+
```sh
|
|
1786
|
+
DEV=true my-cli
|
|
1752
1787
|
```
|
|
1753
1788
|
|
|
1754
1789
|
Then, start React Devtools itself:
|
|
1755
1790
|
|
|
1756
|
-
```
|
|
1757
|
-
|
|
1791
|
+
```sh
|
|
1792
|
+
npx react-devtools
|
|
1758
1793
|
```
|
|
1759
1794
|
|
|
1760
1795
|
After it starts up, you should see the component tree of your CLI.
|
|
@@ -1767,23 +1802,23 @@ You can even inspect and change the props of components, and see the results imm
|
|
|
1767
1802
|
- [ink-text-input](https://github.com/vadimdemedes/ink-text-input) - Text input.
|
|
1768
1803
|
- [ink-spinner](https://github.com/vadimdemedes/ink-spinner) - Spinner.
|
|
1769
1804
|
- [ink-select-input](https://github.com/vadimdemedes/ink-select-input) - Select (dropdown) input.
|
|
1770
|
-
- [ink-link](https://github.com/sindresorhus/ink-link) - Link
|
|
1771
|
-
- [ink-gradient](https://github.com/sindresorhus/ink-gradient) - Gradient color
|
|
1772
|
-
- [ink-big-text](https://github.com/sindresorhus/ink-big-text) - Awesome text
|
|
1805
|
+
- [ink-link](https://github.com/sindresorhus/ink-link) - Link.
|
|
1806
|
+
- [ink-gradient](https://github.com/sindresorhus/ink-gradient) - Gradient color.
|
|
1807
|
+
- [ink-big-text](https://github.com/sindresorhus/ink-big-text) - Awesome text.
|
|
1773
1808
|
- [ink-image](https://github.com/kevva/ink-image) - Display images inside the terminal.
|
|
1774
|
-
- [ink-tab](https://github.com/jdeniau/ink-tab) - Tab
|
|
1775
|
-
- [ink-color-pipe](https://github.com/LitoMore/ink-color-pipe) - Create color text with simpler style strings
|
|
1809
|
+
- [ink-tab](https://github.com/jdeniau/ink-tab) - Tab.
|
|
1810
|
+
- [ink-color-pipe](https://github.com/LitoMore/ink-color-pipe) - Create color text with simpler style strings.
|
|
1776
1811
|
- [ink-multi-select](https://github.com/karaggeorge/ink-multi-select) - Select one or more values from a list
|
|
1777
|
-
- [ink-divider](https://github.com/JureSotosek/ink-divider) - A divider
|
|
1778
|
-
- [ink-progress-bar](https://github.com/brigand/ink-progress-bar) -
|
|
1779
|
-
- [ink-table](https://github.com/maticzav/ink-table) - Table
|
|
1812
|
+
- [ink-divider](https://github.com/JureSotosek/ink-divider) - A divider.
|
|
1813
|
+
- [ink-progress-bar](https://github.com/brigand/ink-progress-bar) - Progress bar.
|
|
1814
|
+
- [ink-table](https://github.com/maticzav/ink-table) - Table.
|
|
1780
1815
|
- [ink-ascii](https://github.com/hexrcs/ink-ascii) - Awesome text component with more font choices, based on Figlet.
|
|
1781
1816
|
- [ink-markdown](https://github.com/cameronhunter/ink-markdown) - Render syntax highlighted Markdown.
|
|
1782
1817
|
- [ink-quicksearch-input](https://github.com/Eximchain/ink-quicksearch-input) - Select component with fast quicksearch-like navigation.
|
|
1783
1818
|
- [ink-confirm-input](https://github.com/kevva/ink-confirm-input) - Yes/No confirmation input.
|
|
1784
1819
|
- [ink-syntax-highlight](https://github.com/vsashyn/ink-syntax-highlight) - Code syntax highlighting.
|
|
1785
|
-
- [ink-form](https://github.com/lukasbach/ink-form) - Form
|
|
1786
|
-
- [ink-task-list](https://github.com/privatenumber/ink-task-list) - Task list
|
|
1820
|
+
- [ink-form](https://github.com/lukasbach/ink-form) - Form.
|
|
1821
|
+
- [ink-task-list](https://github.com/privatenumber/ink-task-list) - Task list.
|
|
1787
1822
|
|
|
1788
1823
|
## Useful Hooks
|
|
1789
1824
|
|
|
@@ -1791,14 +1826,21 @@ You can even inspect and change the props of components, and see the results imm
|
|
|
1791
1826
|
|
|
1792
1827
|
## Examples
|
|
1793
1828
|
|
|
1829
|
+
The [`examples`](/examples) directory contains a set of real examples. You can run them with:
|
|
1830
|
+
|
|
1831
|
+
```bash
|
|
1832
|
+
npm run example examples/[example name]
|
|
1833
|
+
# e.g. npm run example examples/borders
|
|
1834
|
+
```
|
|
1835
|
+
|
|
1794
1836
|
- [Jest](examples/jest/jest.js) - Implementation of basic Jest UI [(live demo)](https://ink-jest-demo.vadimdemedes.repl.run/).
|
|
1795
1837
|
- [Counter](examples/counter/counter.js) - Simple counter that increments every 100ms [(live demo)](https://ink-counter-demo.vadimdemedes.repl.run/).
|
|
1796
|
-
- [Form with
|
|
1838
|
+
- [Form with validation](https://github.com/final-form/rff-cli-example) - Manage form state using [Final Form](https://github.com/final-form/final-form#-final-form).
|
|
1797
1839
|
- [Borders](examples/borders/borders.js) - Add borders to `<Box>` component.
|
|
1798
1840
|
- [Suspense](examples/suspense/suspense.js) - Use React Suspense.
|
|
1799
1841
|
- [Table](examples/table/table.js) - Render a table with multiple columns and rows.
|
|
1800
|
-
- [Focus
|
|
1801
|
-
- [User
|
|
1842
|
+
- [Focus management](examples/use-focus/use-focus.js) - Use `useFocus` hook to manage focus between components.
|
|
1843
|
+
- [User input](examples/use-input/use-input.js) - Listen to user input.
|
|
1802
1844
|
- [Write to stdout](examples/use-stdout/use-stdout.js) - Write to stdout bypassing main Ink output.
|
|
1803
1845
|
- [Write to stderr](examples/use-stderr/use-stderr.js) - Write to stderr bypassing main Ink output.
|
|
1804
1846
|
- [Static](examples/static/static.js) - Use `<Static>` to render permanent output.
|