From 40c3f339dcfdedfdeaa943aba42806fc15ed6480 Mon Sep 17 00:00:00 2001 From: Andrei Zhaleznichenka Date: Mon, 24 Jul 2023 14:50:14 +0200 Subject: [PATCH] experiment: patch local deps for measure bundle size action --- .../workflows/bundle-size/package-lock.json | 127 +----------------- .github/workflows/bundle-size/package.json | 3 +- .../bundle-size/unlock-package-lock.js | 29 ++++ scripts/unlock-package-lock.js | 12 +- 4 files changed, 38 insertions(+), 133 deletions(-) create mode 100644 .github/workflows/bundle-size/unlock-package-lock.js diff --git a/.github/workflows/bundle-size/package-lock.json b/.github/workflows/bundle-size/package-lock.json index 540fd9f8da..25e258f7d4 100644 --- a/.github/workflows/bundle-size/package-lock.json +++ b/.github/workflows/bundle-size/package-lock.json @@ -7,6 +7,7 @@ "": { "name": "bundle-size-test-project", "version": "0.0.0", + "hasInstallScript": true, "dependencies": { "@cloudscape-design/components": "*", "@vitejs/plugin-react": "^4.0.0", @@ -344,72 +345,6 @@ "node": ">=6.9.0" } }, - "node_modules/@cloudscape-design/collection-hooks": { - "version": "1.0.21", - "resolved": "https://registry.npmjs.org/@cloudscape-design/collection-hooks/-/collection-hooks-1.0.21.tgz", - "integrity": "sha512-H2svaXsqHK/XX2CAgU0hxIqiiAh3rvlG490DpNHGbQ8ouXCURc8Hz0Hws+DbZ/etEczpyW44uBBO6xfIXE41iQ==", - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0" - } - }, - "node_modules/@cloudscape-design/component-toolkit": { - "version": "1.0.0-beta.14", - "resolved": "https://registry.npmjs.org/@cloudscape-design/component-toolkit/-/component-toolkit-1.0.0-beta.14.tgz", - "integrity": "sha512-FUncISDyZJMOuuFDFzzXUdrew+deTpF7oJeox34b9Xm69L7fJYQV5mOkKckFW5/lnE52n3pENfU5hLb+ic+baw==", - "dependencies": { - "@juggle/resize-observer": "^3.3.1", - "tslib": "^2.3.1" - } - }, - "node_modules/@cloudscape-design/components": { - "version": "3.0.306", - "resolved": "https://registry.npmjs.org/@cloudscape-design/components/-/components-3.0.306.tgz", - "integrity": "sha512-zNOaIohtn2ZrH6O8h1CtNjUJ4VrTd4h7d5psOUtGuLV7RKojl1UsJ8eXAGzbCYi3dPte/UdDjmnoB3WwIEEZBw==", - "dependencies": { - "@cloudscape-design/collection-hooks": "^1.0.0", - "@cloudscape-design/component-toolkit": "^1.0.0-beta", - "@cloudscape-design/test-utils-core": "^1.0.0", - "@cloudscape-design/theming-runtime": "^1.0.0", - "@dnd-kit/core": "^6.0.8", - "@dnd-kit/sortable": "^7.0.2", - "@dnd-kit/utilities": "^3.2.1", - "@juggle/resize-observer": "^3.3.1", - "ace-builds": "^1.4.13", - "balanced-match": "^1.0.2", - "clsx": "^1.1.0", - "d3-shape": "^1.3.7", - "date-fns": "^2.25.0", - "intl-messageformat": "^10.3.1", - "mnth": "^2.0.0", - "react-focus-lock": "~2.8.1", - "react-keyed-flatten-children": "^1.3.0", - "react-transition-group": "^4.4.2", - "react-virtual": "^2.8.2", - "tslib": "^2.4.0", - "weekstart": "^1.1.0" - }, - "peerDependencies": { - "react": "^16.8 || ^17 || ^18", - "react-dom": "^16.8 || ^17 || ^18" - } - }, - "node_modules/@cloudscape-design/test-utils-core": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@cloudscape-design/test-utils-core/-/test-utils-core-1.0.10.tgz", - "integrity": "sha512-JScy8oujpinTwyPcF0JA1fhxbinvaJANuHjWeVeE63WW3/oum+30Q7f96yJu3sGOlEbCJ3EQ/rpWgaBoE9pq7Q==", - "dependencies": { - "css-selector-tokenizer": "^0.8.0", - "css.escape": "^1.5.1" - } - }, - "node_modules/@cloudscape-design/theming-runtime": { - "version": "1.0.17", - "resolved": "https://registry.npmjs.org/@cloudscape-design/theming-runtime/-/theming-runtime-1.0.17.tgz", - "integrity": "sha512-vgZ3D3lp3m/48/rfifZNtjNozZ43SO4zWkhHN6jNua/TattCfJo8WqURbNUwh7KDSsJOdls7Ni0HQvl9GzJXJQ==", - "dependencies": { - "tslib": "^2.4.0" - } - }, "node_modules/@dnd-kit/accessibility": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@dnd-kit/accessibility/-/accessibility-3.0.1.tgz", @@ -1936,66 +1871,6 @@ "to-fast-properties": "^2.0.0" } }, - "@cloudscape-design/collection-hooks": { - "version": "1.0.21", - "resolved": "https://registry.npmjs.org/@cloudscape-design/collection-hooks/-/collection-hooks-1.0.21.tgz", - "integrity": "sha512-H2svaXsqHK/XX2CAgU0hxIqiiAh3rvlG490DpNHGbQ8ouXCURc8Hz0Hws+DbZ/etEczpyW44uBBO6xfIXE41iQ==", - "requires": {} - }, - "@cloudscape-design/component-toolkit": { - "version": "1.0.0-beta.14", - "resolved": "https://registry.npmjs.org/@cloudscape-design/component-toolkit/-/component-toolkit-1.0.0-beta.14.tgz", - "integrity": "sha512-FUncISDyZJMOuuFDFzzXUdrew+deTpF7oJeox34b9Xm69L7fJYQV5mOkKckFW5/lnE52n3pENfU5hLb+ic+baw==", - "requires": { - "@juggle/resize-observer": "^3.3.1", - "tslib": "^2.3.1" - } - }, - "@cloudscape-design/components": { - "version": "3.0.306", - "resolved": "https://registry.npmjs.org/@cloudscape-design/components/-/components-3.0.306.tgz", - "integrity": "sha512-zNOaIohtn2ZrH6O8h1CtNjUJ4VrTd4h7d5psOUtGuLV7RKojl1UsJ8eXAGzbCYi3dPte/UdDjmnoB3WwIEEZBw==", - "requires": { - "@cloudscape-design/collection-hooks": "^1.0.0", - "@cloudscape-design/component-toolkit": "^1.0.0-beta", - "@cloudscape-design/test-utils-core": "^1.0.0", - "@cloudscape-design/theming-runtime": "^1.0.0", - "@dnd-kit/core": "^6.0.8", - "@dnd-kit/sortable": "^7.0.2", - "@dnd-kit/utilities": "^3.2.1", - "@juggle/resize-observer": "^3.3.1", - "ace-builds": "^1.4.13", - "balanced-match": "^1.0.2", - "clsx": "^1.1.0", - "d3-shape": "^1.3.7", - "date-fns": "^2.25.0", - "intl-messageformat": "^10.3.1", - "mnth": "^2.0.0", - "react-focus-lock": "~2.8.1", - "react-keyed-flatten-children": "^1.3.0", - "react-transition-group": "^4.4.2", - "react-virtual": "^2.8.2", - "tslib": "^2.4.0", - "weekstart": "^1.1.0" - } - }, - "@cloudscape-design/test-utils-core": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@cloudscape-design/test-utils-core/-/test-utils-core-1.0.10.tgz", - "integrity": "sha512-JScy8oujpinTwyPcF0JA1fhxbinvaJANuHjWeVeE63WW3/oum+30Q7f96yJu3sGOlEbCJ3EQ/rpWgaBoE9pq7Q==", - "requires": { - "css-selector-tokenizer": "^0.8.0", - "css.escape": "^1.5.1" - } - }, - "@cloudscape-design/theming-runtime": { - "version": "1.0.17", - "resolved": "https://registry.npmjs.org/@cloudscape-design/theming-runtime/-/theming-runtime-1.0.17.tgz", - "integrity": "sha512-vgZ3D3lp3m/48/rfifZNtjNozZ43SO4zWkhHN6jNua/TattCfJo8WqURbNUwh7KDSsJOdls7Ni0HQvl9GzJXJQ==", - "requires": { - "tslib": "^2.4.0" - } - }, "@dnd-kit/accessibility": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/@dnd-kit/accessibility/-/accessibility-3.0.1.tgz", diff --git a/.github/workflows/bundle-size/package.json b/.github/workflows/bundle-size/package.json index 6adaf36f7e..0623cf5018 100644 --- a/.github/workflows/bundle-size/package.json +++ b/.github/workflows/bundle-size/package.json @@ -4,7 +4,8 @@ "version": "0.0.0", "type": "module", "scripts": { - "build": "node build.js" + "build": "node build.js", + "preinstall": "node ../../../scripts/unlock-package-lock.js" }, "dependencies": { "@cloudscape-design/components": "*", diff --git a/.github/workflows/bundle-size/unlock-package-lock.js b/.github/workflows/bundle-size/unlock-package-lock.js new file mode 100644 index 0000000000..f599682120 --- /dev/null +++ b/.github/workflows/bundle-size/unlock-package-lock.js @@ -0,0 +1,29 @@ +#!/usr/bin/env node +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +const fs = require('fs'); +const path = require('path'); + +/** + * Remove specific @cloudscape-design/* packages where we should always use the latest minor release. + */ +const filename = path.resolve(__dirname, 'package-lock.json'); +const packageLock = JSON.parse(fs.readFileSync(filename)); + +Object.keys(packageLock.packages).forEach(dependencyName => { + removeDependencies(dependencyName, packageLock.packages); +}); + +Object.keys(packageLock.dependencies).forEach(dependencyName => { + removeDependencies(dependencyName, packageLock.dependencies); +}); + +fs.writeFileSync(filename, JSON.stringify(packageLock, null, 2) + '\n'); +console.log('Removed @cloudscape-design/ dependencies from package-lock file'); + +function removeDependencies(dependencyName, packages) { + if (dependencyName.includes('@cloudscape-design/')) { + delete packages[dependencyName]; + } +} diff --git a/scripts/unlock-package-lock.js b/scripts/unlock-package-lock.js index a7f29732dd..acf17c3902 100644 --- a/scripts/unlock-package-lock.js +++ b/scripts/unlock-package-lock.js @@ -11,12 +11,6 @@ const path = require('path'); const filename = path.resolve(__dirname, '..', 'package-lock.json'); const packageLock = JSON.parse(fs.readFileSync(filename)); -function removeDependencies(dependencyName, packages) { - if (dependencyName.includes('@cloudscape-design/')) { - delete packages[dependencyName]; - } -} - Object.keys(packageLock.packages).forEach(dependencyName => { removeDependencies(dependencyName, packageLock.packages); }); @@ -27,3 +21,9 @@ Object.keys(packageLock.dependencies).forEach(dependencyName => { fs.writeFileSync(filename, JSON.stringify(packageLock, null, 2) + '\n'); console.log('Removed @cloudscape-design/ dependencies from package-lock file'); + +function removeDependencies(dependencyName, packages) { + if (dependencyName.includes('@cloudscape-design/')) { + delete packages[dependencyName]; + } +}