create-nx-workspace
Version:
89 lines (88 loc) • 2.85 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.withNxCloud = withNxCloud;
exports.withUseGitHub = withUseGitHub;
exports.withAllPrompts = withAllPrompts;
exports.withPackageManager = withPackageManager;
exports.withGitOptions = withGitOptions;
exports.withOptions = withOptions;
const chalk = require("chalk");
const ab_testing_1 = require("../utils/nx/ab-testing");
const package_manager_1 = require("../utils/package-manager");
function withNxCloud(argv) {
const { message } = ab_testing_1.messages.getPrompt('setupCI');
const result = argv.option('nxCloud', {
alias: 'ci',
describe: chalk.dim(message),
choices: ab_testing_1.NxCloudChoices,
type: 'string',
});
return result;
}
function withUseGitHub(argv) {
return argv.option('useGitHub', {
describe: chalk.dim `Will you be using GitHub as your git hosting provider?`,
type: 'boolean',
default: false,
});
}
function withAllPrompts(argv) {
return argv.option('allPrompts', {
alias: 'a',
describe: chalk.dim `Show all prompts.`,
type: 'boolean',
default: false,
});
}
function withPackageManager(argv) {
return argv.option('packageManager', {
alias: 'pm',
describe: chalk.dim `Package manager to use.`,
choices: [...package_manager_1.packageManagerList].sort(),
defaultDescription: 'npm',
type: 'string',
});
}
function withGitOptions(argv) {
return argv
.option('defaultBase', {
defaultDescription: 'main',
describe: chalk.dim `Default base to use for new projects.`,
type: 'string',
})
.option('skipGit', {
describe: chalk.dim `Skip initializing a git repository.`,
type: 'boolean',
default: false,
alias: 'g',
})
.option('skipGitHubPush', {
describe: chalk.dim `Skip pushing to GitHub via gh CLI.`,
type: 'boolean',
default: false,
})
.option('verbose', {
describe: chalk.dim `Enable verbose logging.`,
type: 'boolean',
default: false,
alias: 'v',
})
.option('commit.name', {
describe: chalk.dim `Name of the committer.`,
type: 'string',
})
.option('commit.email', {
describe: chalk.dim `E-mail of the committer.`,
type: 'string',
})
.option('commit.message', {
describe: chalk.dim `Commit message.`,
type: 'string',
default: 'Initial commit',
});
}
function withOptions(argv, ...options) {
// Reversing the options keeps the execution order correct.
// e.g. [withCI, withGIT] should transform into withGIT(withCI) so withCI resolves first.
return options.reverse().reduce((argv, option) => option(argv), argv);
}