diff --git a/package.json b/package.json index 363fcfdd76..e482802164 100644 --- a/package.json +++ b/package.json @@ -163,6 +163,7 @@ "@emotion/react": "^11.11.4", "@emotion/server": "^11.11.0", "@ianvs/prettier-plugin-sort-imports": "^4.2.1", + "@inquirer/prompts": "^5.1.2", "@madccc/duplicate-package-checker-webpack-plugin": "^1.0.0", "@microflash/rehype-figure": "^2.1.0", "@npmcli/run-script": "^8.1.0", @@ -180,7 +181,6 @@ "@types/fs-extra": "^11.0.4", "@types/gtag.js": "^0.0.20", "@types/http-server": "^0.12.4", - "@types/inquirer": "^9.0.7", "@types/isomorphic-fetch": "^0.0.39", "@types/jest": "^29.5.12", "@types/jest-axe": "^3.5.9", @@ -250,7 +250,6 @@ "husky": "^9.0.11", "identity-obj-proxy": "^3.0.0", "immer": "^10.1.1", - "inquirer": "^9.2.23", "is-ci": "^3.0.1", "isomorphic-fetch": "^3.0.0", "jest": "^29.7.0", diff --git a/scripts/post-publish.ts b/scripts/post-publish.ts index dddfa88fac..8e950b2eb6 100644 --- a/scripts/post-publish.ts +++ b/scripts/post-publish.ts @@ -1,9 +1,10 @@ +/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable no-console */ import { execSync, spawnSync } from 'child_process'; +import { confirm, select } from '@inquirer/prompts'; import chalk from 'chalk'; import dayjs from 'dayjs'; import relativeTime from 'dayjs/plugin/relativeTime'; -import inquirer from 'inquirer'; import fetch from 'isomorphic-fetch'; import ora from 'ora'; import semver from 'semver'; @@ -106,39 +107,31 @@ const SAFE_DAYS_DIFF = 1000 * 60 * 60 * 24 * 3; // 3 days not update seems to be defaultVersion = distTags[CONCH_TAG]; } - // Selection - let { conchVersion } = await inquirer.prompt([ - { - type: 'list', - name: 'conchVersion', - default: defaultVersion, - message: 'Please select Conch Version:', - choices: latestVersions.map((info) => { - const { value, publishTime, depreciated } = info; - const desc = dayjs(publishTime).fromNow(); - - // - - return { - ...info, - name: [ - // Warning - depreciated ? '🚨' : '✅', - // Version - value, - // Date Diff - `(${desc})`, - // Default Mark - value === defaultVersion ? '(default)' : '', - // Current Mark - value === distTags[CONCH_TAG] ? chalk.gray('- current') : '', - ] - .filter((str) => String(str).trim()) - .join(' '), - }; - }), - }, - ]); + let conchVersion = await select({ + default: defaultVersion, + message: 'Please select Conch Version:', + choices: latestVersions.map((info) => { + const { value, publishTime, depreciated } = info; + const desc = dayjs(publishTime).fromNow(); + return { + value, + name: [ + // Warning + depreciated ? '🚨' : '✅', + // Version + value, + // Date Diff + `(${desc})`, + // Default Mark + value === defaultVersion ? '(default)' : '', + // Current Mark + value === distTags[CONCH_TAG] ? chalk.gray('- current') : '', + ] + .filter((str) => Boolean(String(str).trim())) + .join(' '), + }; + }), + }); // Make sure it's not deprecated version const deprecatedObj = matchDeprecated(conchVersion); @@ -150,17 +143,13 @@ const SAFE_DAYS_DIFF = 1000 * 60 * 60 * 24 * 3; // 3 days not update seems to be }); console.log('\n'); - const { conchConfirm } = await inquirer.prompt([ - { - type: 'confirm', - name: 'conchVersion', - default: false, - message: 'SURE to continue?!!', - }, - ]); + const conchConfirm = await confirm({ + default: false, + message: 'SURE to continue ?!!', + }); if (!conchConfirm) { - conchVersion = null; + conchVersion = ''; } } diff --git a/scripts/print-changelog.ts b/scripts/print-changelog.ts index a5080af7ff..01ac224fe6 100644 --- a/scripts/print-changelog.ts +++ b/scripts/print-changelog.ts @@ -1,9 +1,10 @@ +/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable no-await-in-loop, no-console */ import { spawn } from 'child_process'; import path from 'path'; +import { input, select } from '@inquirer/prompts'; import chalk from 'chalk'; import fs from 'fs-extra'; -import inquirer from 'inquirer'; import fetch from 'isomorphic-fetch'; import jQuery from 'jquery'; import jsdom from 'jsdom'; @@ -72,40 +73,32 @@ const getDescription = (entity?: Line): string => { async function printLog() { const tags = await git.tags(); - const { fromVersion } = await inquirer.prompt([ - { - type: 'list', - name: 'fromVersion', - message: '🏷 Please choose tag to compare with current branch:', - choices: tags.all - .filter((item) => !item.includes('experimental')) - .filter((item) => !item.includes('alpha')) - .filter((item) => !item.includes('resource')) - .reverse() - .slice(0, 50), - }, - ]); - let { toVersion } = await inquirer.prompt([ - { - type: 'list', - name: 'toVersion', - message: `🔀 Please choose branch to compare with ${chalk.magenta(fromVersion)}:`, - choices: ['master', '4.x-stable', '3.x-stable', 'feature', 'custom input ⌨️'], - }, - ]); + const fromVersion = await select({ + message: '🏷 Please choose tag to compare with current branch:', + choices: tags.all + .filter((item) => !item.includes('experimental')) + .filter((item) => !item.includes('alpha')) + .filter((item) => !item.includes('resource')) + .reverse() + .slice(0, 50) + .map((item) => ({ name: item, value: item })), + }); + + let toVersion = await select({ + message: `🔀 Please choose branch to compare with ${chalk.magenta(fromVersion)}:`, + choices: ['master', '4.x-stable', '3.x-stable', 'feature', 'custom input ⌨️'].map((i) => ({ + name: i, + value: i, + })), + }); if (toVersion.startsWith('custom input')) { - const result = await inquirer.prompt([ - { - type: 'input', - name: 'toVersion', - message: `🔀 Please input custom git hash id or branch name to compare with ${chalk.magenta( - fromVersion, - )}:`, - default: 'master', - }, - ]); - toVersion = result.toVersion; + toVersion = await input({ + default: 'master', + message: `🔀 Please input custom git hash id or branch name to compare with ${chalk.magenta( + fromVersion, + )}:`, + }); } if (!/\d+\.\d+\.\d+/.test(fromVersion)) {