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

feat(core): add colors to create-nx-workspace #9705

Merged
merged 1 commit into from Apr 6, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 17 additions & 12 deletions packages/create-nx-workspace/bin/create-nx-workspace.ts
Expand Up @@ -18,6 +18,7 @@ import { validateNpmPackage } from './validate-npm-package';
import { deduceDefaultBase } from './default-base';
import { stringifyCollection } from './utils';
import { yargsDecorator } from './decorator';
import chalk = require('chalk');

type Arguments = {
name: string;
Expand Down Expand Up @@ -127,52 +128,52 @@ export const commandsObject: yargs.Argv<Arguments> = yargs
(yargs) =>
yargs
.option('name', {
describe: `Workspace name (e.g. org name)`,
describe: chalk.dim`Workspace name (e.g. org name)`,
type: 'string',
})
.option('preset', {
describe: `Customizes the initial content of your workspace. To build your own see https://nx.dev/nx-plugin/overview#preset`,
describe: chalk.dim`Customizes the initial content of your workspace. To build your own see https://nx.dev/nx-plugin/overview#preset`,
choices: Object.values(Preset),
type: 'string',
})
.option('appName', {
describe: `The name of the application when a preset with pregenerated app is selected`,
describe: chalk.dim`The name of the application when a preset with pregenerated app is selected`,
type: 'string',
})
.option('interactive', {
describe: `Enable interactive mode with presets`,
describe: chalk.dim`Enable interactive mode with presets`,
type: 'boolean',
})
.option('cli', {
describe: `CLI to power the Nx workspace`,
describe: chalk.dim`CLI to power the Nx workspace`,
choices: ['nx', 'angular'],
type: 'string',
})
.option('style', {
describe: `Style option to be used when a preset with pregenerated app is selected`,
describe: chalk.dim`Style option to be used when a preset with pregenerated app is selected`,
type: 'string',
})
.option('nxCloud', {
describe: `Use Nx Cloud`,
describe: chalk.dim`Use Nx Cloud`,
defaultDescription: 'true',
type: 'boolean',
})
.option('allPrompts', {
alias: 'a',
describe: `Show all prompts`,
describe: chalk.dim`Show all prompts`,
type: 'boolean',
default: false,
})
.option('packageManager', {
alias: 'pm',
describe: `Package manager to use`,
describe: chalk.dim`Package manager to use`,
choices: [...packageManagerList].sort(),
defaultDescription: 'npm',
type: 'string',
})
.option('defaultBase', {
defaultDescription: 'main',
describe: `Default base to use for new projects`,
describe: chalk.dim`Default base to use for new projects`,
type: 'string',
}),
async (argv: yargs.ArgumentsCamelCase<Arguments>) => {
Expand All @@ -186,9 +187,13 @@ export const commandsObject: yargs.Argv<Arguments> = yargs
},
[getConfiguration]
)
.help('help')
.help('help', chalk.dim`Show help`)
.updateLocale(yargsDecorator)
.version(nxVersion) as yargs.Argv<Arguments>;
.version(
'version',
chalk.dim`Show version`,
nxVersion
) as yargs.Argv<Arguments>;

async function main(parsedArgs: yargs.Arguments<Arguments>) {
const {
Expand Down
12 changes: 10 additions & 2 deletions packages/create-nx-workspace/bin/decorator.ts
@@ -1,6 +1,14 @@
import * as chalk from 'chalk';

export const yargsDecorator = {
'Options:': `${chalk.bold('Options')}:`,
'Positionals:': `${chalk.bold('Positionals')}:`,
'Options:': `${chalk.green`Options`}:`,
'Examples:': `${chalk.green`Examples`}:`,
boolean: `${chalk.blue`boolean`}`,
count: `${chalk.blue`count`}`,
string: `${chalk.blue`string`}`,
array: `${chalk.blue`array`}`,
required: `${chalk.blue`required`}`,
'default:': `${chalk.blue`default`}:`,
'choices:': `${chalk.blue`choices`}:`,
'aliases:': `${chalk.blue`aliases`}:`,
};