From 30c9982b1d8a8f36e2e277ae6f873a05ddf6e00a Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Tue, 30 Jul 2024 00:19:27 +0700 Subject: [PATCH] drop `postinstall` --- .gitignore | 2 - README.md | 11 ----- package-lock.json | 3 -- packages/core-js-bundle/package.json | 5 +-- packages/core-js-pure/package.json | 3 -- packages/core-js/package.json | 3 -- packages/core-js/postinstall.js | 62 ---------------------------- scripts/copy.mjs | 1 - tests/eslint/eslint.config.js | 6 --- 9 files changed, 1 insertion(+), 95 deletions(-) delete mode 100644 packages/core-js/postinstall.js diff --git a/.gitignore b/.gitignore index 75fdbd442cab..f561cece2bd4 100644 --- a/.gitignore +++ b/.gitignore @@ -19,7 +19,6 @@ node_modules/ /packages/core-js-bundle/index.js /packages/core-js-bundle/minified.js /packages/core-js-bundle/minified.js.map -/packages/core-js-bundle/postinstall.js /packages/core-js-compat/LICENSE /packages/core-js-compat/built-in-definitions.json /packages/core-js-compat/data.json @@ -38,7 +37,6 @@ node_modules/ /packages/core-js-pure/LICENSE /packages/core-js-pure/index.js /packages/core-js-pure/configurator.js -/packages/core-js-pure/postinstall.js /tests/**/bundles/ /tests/compat/*.jar /tests/compat/compat-data.js diff --git a/README.md b/README.md index 35b2b8b6b78a..3f683a827fbb 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,6 @@ structuredClone(new Set([1, 2, 3])); // => new Set([1, 2, 3]) ### Index - [Usage](#usage) - [Installation](#installation) - - [`postinstall` message](#postinstall-message) - [CommonJS API](#commonjs-api) - [Babel](#babel) - [`@babel/polyfill`](#babelpolyfill) @@ -211,16 +210,6 @@ npm install --save @core-js/bundle@4.0.0-alpha.0 Or you can use `core-js` [from CDN](https://www.jsdelivr.com/package/npm/@core-js/bundle). -### `postinstall` message[⬆](#index) -The `core-js` project needs your help, so the package shows a message about it after installation. If it causes problems for you, you can disable it: -```sh -ADBLOCK=true npm install -// or -DISABLE_OPENCOLLECTIVE=true npm install -// or -npm install --loglevel silent -``` - ### CommonJS API[⬆](#index) You can import only-required-for-you polyfills, like in the examples at the top of `README.md`. Available CommonJS entry points for all polyfilled methods / constructors and namespaces. Just some examples: diff --git a/package-lock.json b/package-lock.json index c8bd26b84184..1ea1842708d2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2526,7 +2526,6 @@ }, "packages/core-js": { "version": "4.0.0-alpha.0", - "hasInstallScript": true, "license": "MIT", "funding": { "type": "opencollective", @@ -2553,7 +2552,6 @@ "packages/core-js-bundle": { "name": "@core-js/bundle", "version": "4.0.0-alpha.0", - "hasInstallScript": true, "license": "MIT", "funding": { "type": "opencollective", @@ -2578,7 +2576,6 @@ "packages/core-js-pure": { "name": "@core-js/pure", "version": "4.0.0-alpha.0", - "hasInstallScript": true, "license": "MIT", "funding": { "type": "opencollective", diff --git a/packages/core-js-bundle/package.json b/packages/core-js-bundle/package.json index 1547a4584abb..0db5263b97ff 100644 --- a/packages/core-js-bundle/package.json +++ b/packages/core-js-bundle/package.json @@ -69,8 +69,5 @@ "email": "zloirock@zloirock.ru", "url": "http://zloirock.ru" }, - "main": "index.js", - "scripts": { - "postinstall": "node -e \"try{require('./postinstall')}catch(e){}\"" - } + "main": "index.js" } diff --git a/packages/core-js-pure/package.json b/packages/core-js-pure/package.json index dcc483e06449..30a041565ab0 100644 --- a/packages/core-js-pure/package.json +++ b/packages/core-js-pure/package.json @@ -623,8 +623,5 @@ "./full/index.js": "./full/index.js", "./index": "./index.js", "./index.js": "./index.js" - }, - "scripts": { - "postinstall": "node -e \"try{require('./postinstall')}catch(e){}\"" } } diff --git a/packages/core-js/package.json b/packages/core-js/package.json index 2506d2eeec84..ba8be8b473f9 100644 --- a/packages/core-js/package.json +++ b/packages/core-js/package.json @@ -617,8 +617,5 @@ "./full/index.js": "./full/index.js", "./index": "./index.js", "./index.js": "./index.js" - }, - "scripts": { - "postinstall": "node -e \"try{require('./postinstall')}catch(e){}\"" } } diff --git a/packages/core-js/postinstall.js b/packages/core-js/postinstall.js deleted file mode 100644 index 36645bb14aff..000000000000 --- a/packages/core-js/postinstall.js +++ /dev/null @@ -1,62 +0,0 @@ -'use strict'; -/* eslint-disable node/no-sync -- avoiding overcomplicating */ -/* eslint-disable unicorn/prefer-node-protocol -- ancient env possible */ -var fs = require('fs'); -var os = require('os'); -var path = require('path'); - -var env = process.env; -var ADBLOCK = is(env.ADBLOCK); -var COLOR = is(env.npm_config_color); -var DISABLE_OPENCOLLECTIVE = is(env.DISABLE_OPENCOLLECTIVE); -var SILENT = ['silent', 'error', 'warn'].indexOf(env.npm_config_loglevel) !== -1; -var OPEN_SOURCE_CONTRIBUTOR = is(env.OPEN_SOURCE_CONTRIBUTOR); -var MINUTE = 60 * 1000; - -// you could add a PR with an env variable for your CI detection -var CI = [ - 'BUILD_NUMBER', - 'CI', - 'CONTINUOUS_INTEGRATION', - 'DRONE', - 'RUN_ID', -].some(function (it) { return is(env[it]); }); - -var BANNER = '\u001B[96mThank you for using core-js (\u001B[94m https://github.com/zloirock/core-js \u001B[96m) for polyfilling JavaScript standard library!\u001B[0m\n\n' + - '\u001B[96mThe project needs your help! Please consider supporting core-js:\u001B[0m\n' + - '\u001B[96m>\u001B[94m https://opencollective.com/core-js \u001B[0m\n' + - '\u001B[96m>\u001B[94m https://patreon.com/zloirock \u001B[0m\n' + - '\u001B[96m>\u001B[94m https://boosty.to/zloirock \u001B[0m\n' + - '\u001B[96m>\u001B[94m bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz \u001B[0m\n\n' + - '\u001B[96mI highly recommend reading this:\u001B[94m https://github.com/zloirock/core-js/blob/master/docs/2023-02-14-so-whats-next.md \u001B[96m\u001B[0m\n'; - -function is(it) { - return !!it && it !== '0' && it !== 'false'; -} - -function isBannerRequired() { - if (ADBLOCK || CI || DISABLE_OPENCOLLECTIVE || SILENT || OPEN_SOURCE_CONTRIBUTOR) return false; - var file = path.join(os.tmpdir(), 'core-js-banners'); - var banners = []; - try { - var DELTA = Date.now() - fs.statSync(file).mtime; - if (DELTA >= 0 && DELTA < MINUTE * 3) { - banners = JSON.parse(fs.readFileSync(file)); - if (banners.indexOf(BANNER) !== -1) return false; - } - } catch (error) { - banners = []; - } - try { - banners.push(BANNER); - fs.writeFileSync(file, JSON.stringify(banners), 'utf8'); - } catch (error) { /* empty */ } - return true; -} - -function showBanner() { - // eslint-disable-next-line no-console, regexp/no-control-character -- output - console.log(COLOR ? BANNER : BANNER.replace(/\u001B\[\d+m/g, '')); -} - -if (isBannerRequired()) showBanner(); diff --git a/scripts/copy.mjs b/scripts/copy.mjs index e3c2755f59ec..3ea4e62b210e 100644 --- a/scripts/copy.mjs +++ b/scripts/copy.mjs @@ -17,7 +17,6 @@ const license = (await glob('packages/*/package.json')).map(path => path.replace await Promise.all([ copy('packages/core-js-pure/override', 'packages/core-js-pure', options(true)), - copy('packages/core-js/postinstall.js', 'packages/core-js-bundle/postinstall.js', options(true)), ...license.map(path => copy('LICENSE', path, options(true))), ]); diff --git a/tests/eslint/eslint.config.js b/tests/eslint/eslint.config.js index d4bb880978d4..ccb7a944ad25 100644 --- a/tests/eslint/eslint.config.js +++ b/tests/eslint/eslint.config.js @@ -1695,12 +1695,6 @@ export default [ ], rules: polyfills, }, - { - files: [ - '**/postinstall.js', - ], - rules: disable(forbidES5BuiltIns), - }, { files: [ 'tests/@(helpers|unit-@(global|pure)|wpt-url-resources)/**',