Skip to content

Commit

Permalink
add check-compat-data-modules-by-versions script
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Sep 19, 2021
1 parent 077e863 commit 61e9d1c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@
"bundle-tests-pure": "webpack --entry ./tests/pure/index.js --output-filename pure.js",
"check-dependencies": "zx scripts/check-dependencies.mjs",
"check-mapping": "zx scripts/check-compat-data-mapping.mjs",
"check-modules-by-versions": "zx scripts/check-compat-data-modules-by-versions.mjs",
"check-unused-modules": "zx scripts/check-unused-modules.mjs",
"check": "run-s check-unused-modules check-mapping check-dependencies",
"check": "run-s check-unused-modules check-modules-by-versions check-mapping check-dependencies",
"generate-indexes": "zx scripts/generate-indexes.mjs",
"lint": "run-s init test-lint",
"test-lint": "eslint --ext .js,.mjs,.json ./",
Expand Down
22 changes: 22 additions & 0 deletions scripts/check-compat-data-modules-by-versions.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import semver from 'semver';
const { version } = require('../package');
const modulesByVersions = require('../packages/core-js-compat/modules-by-versions');

const { major, minor, patch } = semver.coerce(version);
let ok = true;

if (minor || patch) { // ignore for pre-releases
const zero = `${ major }.0`;
const result = await fetch(`https://unpkg.com/core-js-compat@${ major }/modules-by-versions.json`);
const prev = await result.json();
const set = new Set(prev[zero]);
for (const mod of modulesByVersions[zero]) {
if (!set.has(mod)) {
ok = false;
console.log(chalk.red(`${ chalk.cyan(mod) } should be added to modules-by-versions`));
}
}
}

if (!ok) throw console.log(chalk.red('\nmodules-by-versions should be updated'));
console.log(chalk.green('modules-by-versions checked'));

0 comments on commit 61e9d1c

Please sign in to comment.