inquirer#Separator TypeScript Examples

The following examples show how to use inquirer#Separator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: version.ts    From gitmars with GNU General Public License v3.0 5 votes vote down vote up
prompt([
    {
        type: 'list',
        name: 'recommend',
        message: 'Choose which version do you want?',
        default: newVers.production[0].version,
        choices: [
            // new Separator(' === Increase (recommend) === '),
            ...newVers.increase.map(el => `${el.id}) ${el.version}`),
            // new Separator(' === Production (recommend) === '),
            ...newVers.production.map(el => `${el.id}) ${el.version}`),
            'create pre version',
            new Separator(' --- Exit --- '),
            'exit',
            new Separator()
        ]
    },
    {
        type: 'list',
        name: 'pre',
        message: 'Choose which version do you want?',
        default: newVers.pre[0].version,
        choices: [
            ...newVers.pre.map(el => `${el.id}) ${el.version}`),
            new Separator(' --- Exit --- '),
            'exit',
            new Separator()
        ],
        when(data) {
            return data.recommend === 'create pre version'
        }
    },
    {
        type: 'confirm',
        name: 'confirm',
        message: '[Be Cautious]: Do you need to create a git tag?',
        default: true,
        when(data) {
            return data.recommend !== 'exit' && data.pre !== 'exit'
        }
    }
]).then((data: { recommend: string; pre?: string; confirm: boolean }) => {
    if (data.recommend === 'exit' || data.pre === 'exit') {
        process.exit(0)
    }

    const PACKAGE_JSON_URL = resolve(ROOT, 'package.json')
    const [id] = (data.pre || data.recommend).split(')')
    const { command, version } = searchVerTarget(id)

    if (data.confirm) {
        execSync(command, execOption)
    } else {
        writeJSON(PACKAGE_JSON_URL, {
            ...pkg,
            version
        })
    }
    spawnSync('npx', ['prettier', '--write', './package.json'], spawnOption)
})