Skip to content
This repository was archived by the owner on Feb 1, 2022. It is now read-only.

feat: use oclif/core #416

Merged
merged 1 commit into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const options: Table.Options = {
Example class:

```typescript
import {Command} from '@oclif/command'
import {Command} from '@oclif/core'
import {cli} from 'cli-ux'
import axios from 'axios'

Expand Down
2 changes: 1 addition & 1 deletion examples/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ async function main() {
cli.error('oh no')
}
main()
.catch(error => require('@oclif/errors/handle')(error))
.catch(error => require('@oclif/core/handle')(error))
4 changes: 2 additions & 2 deletions examples/table.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command} from '@oclif/command'
import {Command} from '@oclif/core'
import axios from 'axios'

import {cli} from '../src'
Expand All @@ -9,7 +9,7 @@ export default class Users extends Command {
}

async run() {
const {flags} = this.parse(Users)
const {flags} = await this.parse(Users)
const {data: users} = await axios.get('https://jsonplaceholder.typicode.com/users')

cli.table(users,
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"author": "Jeff Dickey @jdxcode",
"bugs": "https://github.com/oclif/cli-ux/issues",
"dependencies": {
"@oclif/command": "^1.6.0",
"@oclif/errors": "^1.2.1",
"@oclif/core": "^0.5.39",
"@oclif/linewrap": "^1.0.0",
"@oclif/screen": "^1.0.3",
"ansi-escapes": "^4.3.0",
Expand All @@ -33,8 +32,6 @@
"tslib": "^2.0.0"
},
"devDependencies": {
"@oclif/config": "^1.12.9",
"@oclif/parser": "^3.7.0",
"@types/ansi-styles": "^3.2.1",
"@types/chai": "^4.1.7",
"@types/chai-as-promised": "^7.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Errors from '@oclif/errors'
import {Errors} from '@oclif/core'
import * as util from 'util'

import {ActionBase} from './action/base'
Expand Down
6 changes: 3 additions & 3 deletions src/prompt.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {error} from '@oclif/errors'
import {Errors} from '@oclif/core'
import chalk from 'chalk'

import config from './config'
Expand Down Expand Up @@ -151,7 +151,7 @@ export async function anykey(message?: string): Promise<void> {
}
const char = await prompt(message, {type: 'single', required: false})
if (tty) process.stderr.write('\n')
if (char === 'q') error('quit')
if (char === '\u0003') error('ctrl-c')
if (char === 'q') Errors.error('quit')
if (char === '\u0003') Errors.error('ctrl-c')
return char
}
18 changes: 9 additions & 9 deletions src/styled/table.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {flags as F} from '@oclif/command'
import {Flags as F, Interfaces} from '@oclif/core'
import {stdtermwidth} from '@oclif/screen'
import chalk from 'chalk'
import capitalize from 'lodash/capitalize'
Expand Down Expand Up @@ -306,14 +306,14 @@ export function table<T extends Record<string, unknown>>(data: T[], columns: tab

export namespace table {
export const Flags: {
columns: F.IOptionFlag<string | undefined>;
sort: F.IOptionFlag<string | undefined>;
filter: F.IOptionFlag<string | undefined>;
csv: F.IFlag<boolean>;
output: F.IOptionFlag<string | undefined>;
extended: F.IFlag<boolean>;
'no-truncate': F.IFlag<boolean>;
'no-header': F.IFlag<boolean>;
columns: Interfaces.OptionFlag<string | undefined>;
sort: Interfaces.OptionFlag<string | undefined>;
filter: Interfaces.OptionFlag<string | undefined>;
csv: Interfaces.Flag<boolean>;
output: Interfaces.OptionFlag<string | undefined>;
extended: Interfaces.Flag<boolean>;
'no-truncate': Interfaces.Flag<boolean>;
'no-header': Interfaces.Flag<boolean>;
} = {
columns: F.string({exclusive: ['extended'], description: 'only show provided columns (comma-separated)'}),
sort: F.string({description: 'property to sort by (prepend \'-\' for descending)'}),
Expand Down
117 changes: 117 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,29 @@
is-wsl "^2.1.1"
tslib "^2.0.0"

"@oclif/core@^0.5.39":
version "0.5.39"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-0.5.39.tgz#d00705f31c5e6617145e84bb9dd50156cf3b01c5"
integrity sha512-4XusxLX8PnHDQxtRP25PImlkIj1Mlx6wt0NWb1FxQGvTJOAgXGJZl3YB02ZeXZLYbeKA2A3AqqxFTTKbADnZng==
dependencies:
"@oclif/linewrap" "^1.0.0"
chalk "^4.1.0"
clean-stack "^3.0.0"
cli-ux "^5.1.0"
debug "^4.1.1"
fs-extra "^9.0.1"
get-package-type "^0.1.0"
globby "^11.0.1"
indent-string "^4.0.0"
is-wsl "^2.1.1"
lodash.template "^4.4.0"
semver "^7.3.2"
string-width "^4.2.0"
strip-ansi "^6.0.0"
tslib "^2.0.0"
widest-line "^3.1.0"
wrap-ansi "^7.0.0"

"@oclif/errors@^1.2.1", "@oclif/errors@^1.2.2", "@oclif/errors@^1.3.3":
version "1.3.4"
resolved "https://registry.yarnpkg.com/@oclif/errors/-/errors-1.3.4.tgz#a96f94536b4e25caa72eff47e8b3ed04f6995f55"
Expand Down Expand Up @@ -367,6 +390,11 @@ ansi-regex@^5.0.0:
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75"
integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==

ansi-regex@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==

ansi-styles@^3.2.0, ansi-styles@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
Expand Down Expand Up @@ -427,6 +455,11 @@ astral-regex@^2.0.0:
resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31"
integrity sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==

at-least-node@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==

axios@^0.21.0:
version "0.21.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8"
Expand Down Expand Up @@ -565,6 +598,38 @@ cli-progress@^3.4.0:
colors "^1.1.2"
string-width "^4.2.0"

cli-ux@^5.1.0:
version "5.6.3"
resolved "https://registry.yarnpkg.com/cli-ux/-/cli-ux-5.6.3.tgz#eecdb2e0261171f2b28f2be6b18c490291c3a287"
integrity sha512-/oDU4v8BiDjX2OKcSunGH0iGDiEtj2rZaGyqNuv9IT4CgcSMyVWAMfn0+rEHaOc4n9ka78B0wo1+N1QX89f7mw==
dependencies:
"@oclif/command" "^1.6.0"
"@oclif/errors" "^1.2.1"
"@oclif/linewrap" "^1.0.0"
"@oclif/screen" "^1.0.3"
ansi-escapes "^4.3.0"
ansi-styles "^4.2.0"
cardinal "^2.1.1"
chalk "^4.1.0"
clean-stack "^3.0.0"
cli-progress "^3.4.0"
extract-stack "^2.0.0"
fs-extra "^8.1"
hyperlinker "^1.0.0"
indent-string "^4.0.0"
is-wsl "^2.2.0"
js-yaml "^3.13.1"
lodash "^4.17.11"
natural-orderby "^2.0.1"
object-treeify "^1.1.4"
password-prompt "^1.1.2"
semver "^7.3.2"
string-width "^4.2.0"
strip-ansi "^6.0.0"
supports-color "^8.1.0"
supports-hyperlinks "^2.1.0"
tslib "^2.0.0"

cliui@^7.0.2:
version "7.0.4"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f"
Expand Down Expand Up @@ -1095,6 +1160,16 @@ fs-extra@^8.1:
jsonfile "^4.0.0"
universalify "^0.1.0"

fs-extra@^9.0.1:
version "9.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"
integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==
dependencies:
at-least-node "^1.0.0"
graceful-fs "^4.2.0"
jsonfile "^6.0.1"
universalify "^2.0.0"

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
Expand Down Expand Up @@ -1125,6 +1200,11 @@ get-func-name@^2.0.0:
resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41"
integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=

get-package-type@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a"
integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==

glob-parent@^5.0.0, glob-parent@^5.1.0, glob-parent@~5.1.0:
version "5.1.1"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229"
Expand Down Expand Up @@ -1375,6 +1455,15 @@ jsonfile@^4.0.0:
optionalDependencies:
graceful-fs "^4.1.6"

jsonfile@^6.0.1:
version "6.1.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==
dependencies:
universalify "^2.0.0"
optionalDependencies:
graceful-fs "^4.1.6"

levn@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade"
Expand Down Expand Up @@ -1913,6 +2002,15 @@ string-width@^3.0.0:
is-fullwidth-code-point "^2.0.0"
strip-ansi "^5.1.0"

string-width@^4.0.0:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.1.0, string-width@^4.2.0:
version "4.2.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.2.tgz#dafd4f9559a7585cfba529c6a0a4f73488ebd4c5"
Expand Down Expand Up @@ -1943,6 +2041,13 @@ strip-ansi@^5.0.0, strip-ansi@^5.1.0:
dependencies:
ansi-regex "^4.1.0"

strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

[email protected], strip-json-comments@^3.1.0, strip-json-comments@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
Expand Down Expand Up @@ -2067,6 +2172,11 @@ universalify@^0.1.0:
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==

universalify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==

uri-js@^4.2.2:
version "4.2.2"
resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0"
Expand Down Expand Up @@ -2107,6 +2217,13 @@ widest-line@^2.0.1:
dependencies:
string-width "^2.1.1"

widest-line@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/widest-line/-/widest-line-3.1.0.tgz#8292333bbf66cb45ff0de1603b136b7ae1496eca"
integrity sha512-NsmoXalsWVDMGupxZ5R08ka9flZjjiLvHVAWYOKtiKM8ujtZWr9cRffak+uSE48+Ob8ObalXpwyeUiyDD6QFgg==
dependencies:
string-width "^4.0.0"

word-wrap@^1.2.3:
version "1.2.3"
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c"
Expand Down