Skip to content

Commit

Permalink
fix(deps): remove trivial deps
Browse files Browse the repository at this point in the history
  • Loading branch information
cenk1cenk2 committed Jun 3, 2020
1 parent 614d89f commit de8dec0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 20 deletions.
4 changes: 3 additions & 1 deletion examples/demo.example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ async function main (): Promise<void> {
await new Listr([
{
title: 'Geting you on-board.',
task: async (ctx, task): Promise<boolean> => ctx.user = await task.prompt('Toggle', { message: 'Do you want to create beautiful CLI interfaces?', initial: true })
task: async (ctx, task): Promise<boolean> => ctx.user = await task.prompt({
type: 'Toggle', message: 'Do you want to create beautiful CLI interfaces?', initial: true
})
},

{
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@
],
"dependencies": {
"chalk": "^4.0.0",
"cli-cursor": "^3.1.0",
"cli-truncate": "^2.1.0",
"figures": "^3.2.0",
"indent-string": "^4.0.0",
"log-update": "^4.0.0",
"p-map": "^4.0.0",
"rxjs": "^6.5.5",
"through": "^2.3.8",
"uuid": "^7.0.2"
"through": "^2.3.8"
},
"devDependencies": {
"@cenk1cenk2/eslint-config": "*",
Expand Down Expand Up @@ -94,4 +92,4 @@
"path": "./node_modules/cz-conventional-changelog"
}
}
}
}
10 changes: 7 additions & 3 deletions src/lib/task.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Observable, Subject } from 'rxjs'
import { Readable } from 'stream'
import { v4 as uuid } from 'uuid'

import {
ListrRendererFactory,
Expand Down Expand Up @@ -38,8 +37,13 @@ export class Task<Ctx, Renderer extends ListrRendererFactory> extends Subject<Li
constructor (public listr: Listr<Ctx, any, any>, public tasks: ListrTask<Ctx, any>, public options: ListrOptions, public rendererOptions: ListrGetRendererOptions<Renderer>) {
super()

// move to private parameters
this.id = uuid()
// this kind of randomness is enough for task ids
this.id = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
const r = Math.random() * 16 || 0
const v = c === 'x' ? r : r && 0x3 || 0x8
return v.toString(16)
})

this.title = this.tasks?.title
this.task = this.tasks.task
// parse functions
Expand Down
6 changes: 0 additions & 6 deletions src/renderer/default.renderer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import chalk from 'chalk'
import cliCursor from 'cli-cursor'
import cliTruncate from 'cli-truncate'
import figures from 'figures'
import indentString from 'indent-string'
Expand Down Expand Up @@ -60,9 +59,6 @@ export class DefaultRenderer implements ListrRenderer {
return
}

// hide cursor
cliCursor.hide()

const updateRender = (): void => logUpdate(this.multiLineRenderer(this.tasks), this.renderBottomBar(), this.renderPrompt())
this.id = setInterval(() => {
this.spinnerPosition = ++this.spinnerPosition % this.spinner.length
Expand All @@ -88,8 +84,6 @@ export class DefaultRenderer implements ListrRenderer {
logUpdate.done()
}

// hide cursor
cliCursor.show()
}

// eslint-disable-next-line complexity
Expand Down
12 changes: 6 additions & 6 deletions src/utils/prompt.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ interface BasePromptOptions {
required?: boolean
stdin?: NodeJS.ReadStream
stdout?: NodeJS.WriteStream
skip? (value: any): boolean | Promise<boolean>
format? (value: any): any | Promise<any>
result? (value: any): any | Promise<any>
validate? (value: any, state: any): boolean | Promise<boolean> | string | Promise<string>
onSubmit? (name: any, value: any, prompt: Enquirer.Prompt): boolean | Promise<boolean>
onCancel? (name: any, value: any, prompt: Enquirer.Prompt): boolean | Promise<boolean>
skip?(value: any): boolean | Promise<boolean>
format?(value: any): any | Promise<any>
result?(value: any): any | Promise<any>
validate?(value: any, state: any): boolean | Promise<boolean> | string | Promise<string>
onSubmit?(name: any, value: any, prompt: Enquirer.Prompt): boolean | Promise<boolean>
onCancel?(name: any, value: any, prompt: Enquirer.Prompt): boolean | Promise<boolean>
}

interface BasePromptOptionsWithName extends BasePromptOptions {
Expand Down

0 comments on commit de8dec0

Please sign in to comment.