Skip to content
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

Revert "Changed to use listr2 and enquirer prompts - breaking" #2

Merged
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: 0 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,13 @@
"cross-env": "7.0.3",
"decamelize": "5.0.0",
"dotenv-defaults": "5.0.2",
"enquirer": "2.3.6",
"envinfo": "7.8.1",
"execa": "5.1.1",
"fast-glob": "3.2.12",
"fs-extra": "10.1.0",
"latest-version": "5.1.0",
"listr": "0.14.3",
"listr-verbose-renderer": "0.6.0",
"listr2": "^5.0.5",
"lodash": "4.17.21",
"param-case": "3.0.4",
"pascalcase": "1.0.0",
Expand Down
22 changes: 12 additions & 10 deletions packages/cli/src/commands/generate/cell/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,18 @@ export const files = async ({
} else {
const userSpecifiedNameIsUnique = await operationNameIsUnique(operationName)
if (!userSpecifiedNameIsUnique) {
const answer = await options.listr2task.prompt({
type: 'confirm',
name: 'confirmed',
message: `Specified query name: "${operationName}" is not unique! Do you wish to continue?`,
initial: false,
})

if (!answer) {
options.listr2task.skip('Skipped to prevent non-unique query name.')
options.listr2ctx.skip = true
const answer = await prompts([
{
type: 'confirm',
name: 'continue',
message: `Specified query name: "${operationName}" is not unique! Do you wish to continue?\r\n`,
initial: false,
active: 'Yes',
inactive: 'No',
},
])
if (!answer.continue) {
process.exit(0)
}
}
}
Expand Down
15 changes: 5 additions & 10 deletions packages/cli/src/commands/generate/helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import fs from 'fs'
import path from 'path'

import { Listr } from 'listr2'
import Listr from 'listr'
import VerboseRenderer from 'listr-verbose-renderer'
import { paramCase } from 'param-case'
import pascalcase from 'pascalcase'
import terminalLink from 'terminal-link'
Expand Down Expand Up @@ -191,23 +192,17 @@ export const createYargsForComponentGeneration = ({
[
{
title: `Generating ${componentName} files...`,
task: async (_ctx, task) => {
options.listr2ctx = _ctx
options.listr2task = task
task: async () => {
const f = await filesFn(options)
if (_ctx.skip) {
return
}
return writeFilesTask(f, { overwriteExisting: options.force })
},
},
...includeAdditionalTasks(options),
],
{
concurrent: false,
collapse: false,
exitOnError: true,
renderer: options.verbose && 'verbose',
rendererOptions: { collapse: false },
renderer: options.verbose && VerboseRenderer,
}
)

Expand Down
9 changes: 2 additions & 7 deletions packages/cli/src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import * as babel from '@babel/core'
import camelcase from 'camelcase'
import decamelize from 'decamelize'
import execa from 'execa'
// import Listr from 'listr'
import Listr from 'listr'
import VerboseRenderer from 'listr-verbose-renderer'
import { Listr } from 'listr2'
import { memoize } from 'lodash'
import lodash from 'lodash/string'
import { paramCase } from 'param-case'
Expand Down Expand Up @@ -262,11 +261,7 @@ export const writeFilesTask = (files, options) => {
title: `...waiting to write file \`./${path.relative(base, file)}\`...`,
task: (ctx, task) => writeFile(file, contents, options, task),
}
}),
{
concurrent: true,
rendererOptions: { collapse: false },
}
})
)
}

Expand Down