diff --git a/package.json b/package.json index ee71179ca2..d07d2c922d 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "pub": "npm run version && npm run collect-token-statistic && npm run token-meta && antd-tools run pub", "rome:format": "rome format --write .", "prepublishOnly": "antd-tools run guard", - "postpublish": "ts-node --esm --project tsconfig.node.json scripts/post-script.ts", + "postpublish": "node ./scripts/post-script.js", "site": "dumi build && cp .surgeignore _site", "sort": "npx sort-package-json", "sort-api": "antd-tools run sort-api-table", diff --git a/scripts/post-script.ts b/scripts/post-script.js similarity index 92% rename from scripts/post-script.ts rename to scripts/post-script.js index 14d0f44931..7fd39745b8 100644 --- a/scripts/post-script.ts +++ b/scripts/post-script.js @@ -1,10 +1,10 @@ /* eslint-disable no-console */ -import chalk from 'chalk'; -import { spawnSync } from 'child_process'; -import dayjs from 'dayjs'; -import relativeTime from 'dayjs/plugin/relativeTime'; -import fetch from 'isomorphic-fetch'; -import semver from 'semver'; +const fetch = require('isomorphic-fetch'); +const semver = require('semver'); +const dayjs = require('dayjs'); +const chalk = require('chalk'); +const { spawnSync } = require('child_process'); +const relativeTime = require('dayjs/plugin/relativeTime'); dayjs.extend(relativeTime); @@ -39,12 +39,12 @@ const DEPRECIATED_VERSION = { ], }; -function matchDeprecated(version: string) { +function matchDeprecated(version) { const match = Object.keys(DEPRECIATED_VERSION).find((depreciated) => semver.satisfies(version, depreciated), ); - const reason = DEPRECIATED_VERSION[match as keyof typeof DEPRECIATED_VERSION] || []; + const reason = DEPRECIATED_VERSION[match] || []; return { match, @@ -98,13 +98,12 @@ const SAFE_DAYS_DIFF = 1000 * 60 * 60 * 24 * 3; // 3 days not update seems to be const startDefaultVersionIndex = filteredLatestVersions.findIndex( ({ timeDiff }) => timeDiff >= SAFE_DAYS_START, ); - const defaultVersionList = filteredLatestVersions .slice(0, startDefaultVersionIndex + 1) .reverse(); // Find safe version - let defaultVersionObj: any; + let defaultVersionObj; for (let i = 0; i < defaultVersionList.length - 1; i += 1) { defaultVersionObj = defaultVersionList[i]; const nextVersionObj = defaultVersionList[i + 1]; @@ -126,7 +125,6 @@ const SAFE_DAYS_DIFF = 1000 * 60 * 60 * 24 * 3; // 3 days not update seems to be } const { default: inquirer } = await import('inquirer'); - // Selection let { conchVersion } = await inquirer.prompt([ { @@ -138,6 +136,8 @@ const SAFE_DAYS_DIFF = 1000 * 60 * 60 * 24 * 3; // 3 days not update seems to be const { value, publishTime, depreciated } = info; const desc = dayjs(publishTime).fromNow(); + // + return { ...info, name: [ @@ -188,6 +188,9 @@ const SAFE_DAYS_DIFF = 1000 * 60 * 60 * 24 * 3; // 3 days not update seems to be console.log(`🎃 Conch Version not change. Safe to ${chalk.green('ignore')}.`); } else { console.log('💾 Tagging Conch Version:', chalk.green(conchVersion)); - spawnSync('npm', ['dist-tag', 'add', `antd@${conchVersion}`, CONCH_TAG], { stdio: 'inherit' }); + spawnSync('npm', ['dist-tag', 'add', `antd@${conchVersion}`, CONCH_TAG], { + stdio: 'inherit', + stdin: 'inherit', + }); } })();