-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from medly/refactor/inquirer
refactor: show right set of questions if user does not pass any argum…
- Loading branch information
Showing
13 changed files
with
149 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,26 @@ | ||
const inquirer = require('inquirer'); | ||
const chalk = require('chalk'); | ||
|
||
const questions = [{ type: 'list', name: 'packageManager', message: 'Package Manager', choices: ['npm', 'yarn', 'pnpm'], default: 'yarn' }]; | ||
const questions = cmdOptions => [ | ||
{ | ||
type: 'input', | ||
name: 'projectName', | ||
message: 'Project Name', | ||
default: 'medly-app', | ||
when: () => !cmdOptions.projectName | ||
}, | ||
{ | ||
type: 'list', | ||
name: 'packageManager', | ||
message: 'Package Manager', | ||
choices: [ | ||
{ name: chalk.hex('#CC3534')('npm'), value: 'npm' }, | ||
{ name: chalk.hex('#2C8EBB')('yarn'), value: 'yarn' }, | ||
{ name: chalk.hex('#F9AD00')('pnpm'), value: 'pnpm' } | ||
], | ||
default: 'yarn', | ||
when: () => !cmdOptions.projectName || cmdOptions.interactive | ||
} | ||
]; | ||
|
||
module.exports = async function () { | ||
return inquirer.prompt(questions); | ||
}; | ||
module.exports = async cmdOptions => ({ ...cmdOptions, ...(await inquirer.prompt(questions(cmdOptions))) }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,41 +35,41 @@ | |
}, | ||
"prettier": "@medly/prettier-config", | ||
"dependencies": [ | ||
"@medly-components/core", | ||
"@medly-components/forms", | ||
"@medly-components/layout", | ||
"@medly-components/loaders", | ||
"@medly-components/theme", | ||
"axios", | ||
"react", | ||
"react-dom", | ||
"react-redux", | ||
"react-router-dom", | ||
"redux", | ||
"redux-saga", | ||
"styled-components" | ||
"@medly-components/core@latest", | ||
"@medly-components/forms@latest", | ||
"@medly-components/layout@latest", | ||
"@medly-components/loaders@latest", | ||
"@medly-components/theme@latest", | ||
"axios@latest", | ||
"react@latest", | ||
"react-dom@latest", | ||
"react-redux@latest", | ||
"react-router-dom@latest", | ||
"redux@latest", | ||
"redux-saga@latest", | ||
"styled-components@latest" | ||
], | ||
"devDependencies": [ | ||
"[email protected]", | ||
"@medly/babel-config-react", | ||
"@medly/eslint-config-react", | ||
"@medly/prettier-config", | ||
"@medly/stylelint-config", | ||
"@medly/typescript-config-react", | ||
"@medly/webpack-config", | ||
"@medly/jest-config-react", | ||
"@testing-library/react", | ||
"@types/react", | ||
"@types/react-dom", | ||
"@types/react-redux", | ||
"@types/react-router-dom", | ||
"@types/redux-mock-store", | ||
"@types/styled-components", | ||
"axios-mock-adapter", | ||
"lint-staged", | ||
"npm-run-all", | ||
"redux-devtools-extension", | ||
"redux-mock-store", | ||
"rimraf" | ||
"@medly/babel-config-react@latest", | ||
"@medly/eslint-config-react@latest", | ||
"@medly/prettier-config@latest", | ||
"@medly/stylelint-config@latest", | ||
"@medly/typescript-config-react@latest", | ||
"@medly/webpack-config@latest", | ||
"@medly/jest-config-react@latest", | ||
"@testing-library/react@latest", | ||
"@types/react@latest", | ||
"@types/react-dom@latest", | ||
"@types/react-redux@latest", | ||
"@types/react-router-dom@latest", | ||
"@types/redux-mock-store@latest", | ||
"@types/styled-components@latest", | ||
"axios-mock-adapter@latest", | ||
"lint-staged@latest", | ||
"npm-run-all@latest", | ||
"redux-devtools-extension@latest", | ||
"redux-mock-store@latest", | ||
"rimraf@latest" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,51 @@ | ||
const inquirer = require('inquirer'); | ||
const chalk = require('chalk'); | ||
|
||
const questions = [ | ||
const questions = cmdOptions => [ | ||
{ | ||
type: 'input', | ||
name: 'projectName', | ||
message: 'Project Name', | ||
default: 'medly-module', | ||
when: () => !cmdOptions.projectName | ||
}, | ||
{ | ||
type: 'list', | ||
name: 'registry', | ||
message: 'Registry to publish the module', | ||
choices: ['none', 'github', 'npm'], | ||
default: cmdOptions.registry || 'none', | ||
when: () => !cmdOptions.projectName || cmdOptions.interactive | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'owner', | ||
message: 'Owner of the package', | ||
when(answers) { | ||
return answers.registry !== 'none'; | ||
} | ||
when: answers => !cmdOptions.owner && answers.registry && answers.registry !== 'none' | ||
}, | ||
{ | ||
type: 'list', | ||
name: 'language', | ||
message: 'Language', | ||
choices: [ | ||
{ name: chalk.hex('#007acc')('typescript'), value: 'typescript' }, | ||
{ name: chalk.yellow('javascript'), value: 'javascript' } | ||
], | ||
default: cmdOptions.language, | ||
when: () => !cmdOptions.projectName || cmdOptions.interactive | ||
}, | ||
{ type: 'list', name: 'language', message: 'Language', choices: ['typescript', 'javascript'], default: 'typescript' }, | ||
{ type: 'list', name: 'registry', message: 'Registry to publish the module', choices: ['none', 'github', 'npm'], default: 'none' }, | ||
{ type: 'list', name: 'packageManager', message: 'Package Manager', choices: ['npm', 'yarn', 'pnpm'], default: 'yarn' } | ||
{ | ||
type: 'list', | ||
name: 'packageManager', | ||
message: 'Package Manager', | ||
choices: [ | ||
{ name: chalk.hex('#CC3534')('npm'), value: 'npm' }, | ||
{ name: chalk.hex('#2C8EBB')('yarn'), value: 'yarn' }, | ||
{ name: chalk.hex('#F9AD00')('pnpm'), value: 'pnpm' } | ||
], | ||
default: cmdOptions.packageManager, | ||
when: () => !cmdOptions.projectName || cmdOptions.interactive | ||
} | ||
]; | ||
|
||
module.exports = async function () { | ||
return inquirer.prompt(questions); | ||
}; | ||
module.exports = async cmdOptions => ({ ...cmdOptions, ...(await inquirer.prompt(questions(cmdOptions))) }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,17 +24,17 @@ | |
"dependencies": [], | ||
"devDependencies": [ | ||
"[email protected]", | ||
"@commitlint/cli", | ||
"@commitlint/config-conventional", | ||
"@medly/babel-config", | ||
"@medly/eslint-config", | ||
"@medly/prettier-config", | ||
"@medly/rollup-config", | ||
"@medly/semantic-release-config", | ||
"commitizen", | ||
"cross-env", | ||
"cz-conventional-changelog", | ||
"jest" | ||
"@commitlint/cli@latest", | ||
"@commitlint/config-conventional@latest", | ||
"@medly/babel-config@latest", | ||
"@medly/eslint-config@latest", | ||
"@medly/prettier-config@latest", | ||
"@medly/rollup-config@latest", | ||
"@medly/semantic-release-config@latest", | ||
"commitizen@latest", | ||
"cross-env@latest", | ||
"cz-conventional-changelog@latest", | ||
"jest@latest" | ||
], | ||
"config": { | ||
"commitizen": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,19 +25,19 @@ | |
"dependencies": [], | ||
"devDependencies": [ | ||
"[email protected]", | ||
"@commitlint/cli", | ||
"@commitlint/config-conventional", | ||
"@medly/babel-config", | ||
"@medly/eslint-config", | ||
"@medly/prettier-config", | ||
"@medly/rollup-config", | ||
"@medly/semantic-release-config", | ||
"@medly/typescript-config", | ||
"commitizen", | ||
"cross-env", | ||
"cz-conventional-changelog", | ||
"jest", | ||
"ts-node" | ||
"@commitlint/cli@latest", | ||
"@commitlint/config-conventional@latest", | ||
"@medly/babel-config@latest", | ||
"@medly/eslint-config@latest", | ||
"@medly/prettier-config@latest", | ||
"@medly/rollup-config@latest", | ||
"@medly/semantic-release-config@latest", | ||
"@medly/typescript-config@latest", | ||
"commitizen@latest", | ||
"cross-env@latest", | ||
"cz-conventional-changelog@latest", | ||
"jest@latest", | ||
"ts-node@latest" | ||
], | ||
"config": { | ||
"commitizen": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters