first commit
This commit is contained in:
12
.editorconfig
Normal file
12
.editorconfig
Normal file
@@ -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
|
||||
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* text=auto eol=lf
|
||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
node_modules
|
||||
dist
|
||||
1
.prettierignore
Normal file
1
.prettierignore
Normal file
@@ -0,0 +1 @@
|
||||
dist
|
||||
10064
package-lock.json
generated
Normal file
10064
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
58
package.json
Normal file
58
package.json
Normal file
@@ -0,0 +1,58 @@
|
||||
{
|
||||
"name": "dash-cli",
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"bin": "dist/cli.js",
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "babel --out-dir=dist source",
|
||||
"dev": "babel --out-dir=dist --watch source",
|
||||
"test": "prettier --check . && xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"ink": "^4.1.0",
|
||||
"meow": "^11.0.0",
|
||||
"react": "^18.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.21.0",
|
||||
"@babel/preset-react": "^7.18.6",
|
||||
"@vdemedes/prettier-config": "^2.0.1",
|
||||
"ava": "^5.2.0",
|
||||
"chalk": "^5.2.0",
|
||||
"eslint-config-xo-react": "^0.27.0",
|
||||
"eslint-plugin-react": "^7.32.2",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"import-jsx": "^5.0.0",
|
||||
"ink-testing-library": "^3.0.0",
|
||||
"prettier": "^2.8.7",
|
||||
"xo": "^0.53.1"
|
||||
},
|
||||
"ava": {
|
||||
"environmentVariables": {
|
||||
"NODE_NO_WARNINGS": "1"
|
||||
},
|
||||
"nodeArguments": [
|
||||
"--loader=import-jsx"
|
||||
]
|
||||
},
|
||||
"xo": {
|
||||
"extends": "xo-react",
|
||||
"prettier": true,
|
||||
"rules": {
|
||||
"react/prop-types": "off"
|
||||
}
|
||||
},
|
||||
"prettier": "@vdemedes/prettier-config",
|
||||
"babel": {
|
||||
"presets": [
|
||||
"@babel/preset-react"
|
||||
]
|
||||
}
|
||||
}
|
||||
25
readme.md
Normal file
25
readme.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# dash-cli
|
||||
|
||||
> This readme is automatically generated by [create-ink-app](https://github.com/vadimdemedes/create-ink-app)
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
$ npm install --global dash-cli
|
||||
```
|
||||
|
||||
## CLI
|
||||
|
||||
```
|
||||
$ dash-cli --help
|
||||
|
||||
Usage
|
||||
$ dash-cli
|
||||
|
||||
Options
|
||||
--name Your name
|
||||
|
||||
Examples
|
||||
$ dash-cli --name=Jane
|
||||
Hello, Jane
|
||||
```
|
||||
10
source/app.js
Normal file
10
source/app.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import React from 'react';
|
||||
import {Text} from 'ink';
|
||||
|
||||
export default function App({name = 'Stranger'}) {
|
||||
return (
|
||||
<Text>
|
||||
Hello, <Text color="green">{name}</Text>
|
||||
</Text>
|
||||
);
|
||||
}
|
||||
24
source/cli.js
Normal file
24
source/cli.js
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/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
|
||||
$ dash-cli
|
||||
|
||||
Options
|
||||
--name Your name
|
||||
|
||||
Examples
|
||||
$ dash-cli --name=Jane
|
||||
Hello, Jane
|
||||
`,
|
||||
{
|
||||
importMeta: import.meta,
|
||||
},
|
||||
);
|
||||
|
||||
render(<App name={cli.flags.name} />);
|
||||
17
test.js
Normal file
17
test.js
Normal file
@@ -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')}`);
|
||||
});
|
||||
Reference in New Issue
Block a user