Skip to content

Commit

Permalink
experiment: patch local deps for measure bundle size action
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-kot committed Jul 24, 2023
1 parent 8a75704 commit 40c3f33
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 133 deletions.
127 changes: 1 addition & 126 deletions .github/workflows/bundle-size/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .github/workflows/bundle-size/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*",
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/bundle-size/unlock-package-lock.js
Original file line number Diff line number Diff line change
@@ -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];
}
}
12 changes: 6 additions & 6 deletions scripts/unlock-package-lock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand All @@ -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];
}
}

0 comments on commit 40c3f33

Please sign in to comment.