chore: Migrate CJS to ESM (#44742)

pull/44751/head
lijianan 1 year ago committed by GitHub
parent 5b75f3f817
commit 535a7da43d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -84,7 +84,7 @@
"pub": "npm run version && npm run collect-token-statistic && npm run token-meta && antd-tools run pub",
"biome:format": "biome format --write .",
"prepublishOnly": "antd-tools run guard",
"postpublish": "node ./scripts/post-script.js",
"postpublish": "tsx scripts/post-script.ts",
"site": "dumi build && cp .surgeignore _site",
"sort": "npx sort-package-json",
"sort-api": "antd-tools run sort-api-table",
@ -241,7 +241,7 @@
"husky": "^8.0.1",
"identity-obj-proxy": "^3.0.0",
"immer": "^10.0.1",
"inquirer": "^9.1.2",
"inquirer": "^9.2.11",
"is-ci": "^3.0.1",
"isomorphic-fetch": "^3.0.0",
"jest": "^29.4.1",

@ -1,10 +1,11 @@
/* eslint-disable no-console */
const { spawnSync } = require('child_process');
const fetch = require('isomorphic-fetch');
const semver = require('semver');
const dayjs = require('dayjs');
const chalk = require('chalk');
const relativeTime = require('dayjs/plugin/relativeTime');
import { spawnSync } from 'child_process';
import chalk from 'chalk';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import inquirer from 'inquirer';
import fetch from 'isomorphic-fetch';
import semver from 'semver';
dayjs.extend(relativeTime);
@ -45,14 +46,14 @@ const DEPRECIATED_VERSION = {
'https://github.com/ant-design/ant-design/issues/43684',
],
'5.8.0': ['https://github.com/ant-design/ant-design/issues/43943'],
};
} as const;
function matchDeprecated(version) {
function matchDeprecated(v: string) {
const match = Object.keys(DEPRECIATED_VERSION).find((depreciated) =>
semver.satisfies(version, depreciated),
semver.satisfies(v, depreciated),
);
const reason = DEPRECIATED_VERSION[match] || [];
const reason = DEPRECIATED_VERSION[match as keyof typeof DEPRECIATED_VERSION] || [];
return {
match,
@ -72,7 +73,7 @@ const SAFE_DAYS_DIFF = 1000 * 60 * 60 * 24 * 3; // 3 days not update seems to be
// }
const { time, 'dist-tags': distTags } = await fetch('http://registry.npmjs.org/antd').then(
(res) => res.json(),
(res: Response) => res.json(),
);
console.log('🐚 Latest Conch Version:', chalk.green(distTags[CONCH_TAG] || 'null'), '\n');
@ -128,11 +129,10 @@ const SAFE_DAYS_DIFF = 1000 * 60 * 60 * 24 * 3; // 3 days not update seems to be
let defaultVersion = defaultVersionObj ? defaultVersionObj.value : null;
// If default version is less than current, use current
if (semver.compare(defaultVersion, distTags[CONCH_TAG]) < 0) {
if (semver.compare(defaultVersion!, distTags[CONCH_TAG]) < 0) {
defaultVersion = distTags[CONCH_TAG];
}
const { default: inquirer } = await import('inquirer');
// Selection
let { conchVersion } = await inquirer.prompt([
{
@ -196,9 +196,6 @@ 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',
stdin: 'inherit',
});
spawnSync('npm', ['dist-tag', 'add', `antd@${conchVersion}`, CONCH_TAG], { stdio: 'inherit' });
}
})();
Loading…
Cancel
Save