Skip to content

Commit

Permalink
Chore/eng 5899 pin all dependencies (#198)
Browse files Browse the repository at this point in the history
* chore: add script to pin all deps

* chore: run script to pin deps and commit lockfile
  • Loading branch information
teebszet authored Dec 19, 2024
1 parent a51866e commit bd1f442
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@
"husky": "8.0.3",
"lint-staged": "13.2.3",
"prettier": "2.8.4",
"prettier-plugin-organize-imports": "^4.0.0",
"prettier-plugin-organize-imports": "4.0.0",
"rimraf": "3.0.2",
"ts-jest": "29.0.5",
"tsup": "8.0.2",
"typescript": "5"
"typescript": "5.4.4"
},
"repository": {
"type": "git",
Expand Down
28 changes: 28 additions & 0 deletions scripts/pin_all_deps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This script is used to pin all dependencies in package.json to the exact
* versions declared in package-lock.json.
*
* It assumes lockfileVersion >= 2
*
* Usage: node pin_all_deps.js
*/

const fs = require('fs');
const packageLock = require('../package-lock.json');
const packageJson = require('../package.json');

for (const packageName in packageJson.dependencies) {
const installedPathKey = `node_modules/${packageName}`;
if (packageJson.dependencies.hasOwnProperty(packageName) && packageLock.packages[installedPathKey]) {
packageJson.dependencies[packageName] = packageLock.packages[installedPathKey].version;
}
}

for (const packageName in packageJson.devDependencies) {
const installedPathKey = `node_modules/${packageName}`;
if (packageJson.devDependencies.hasOwnProperty(packageName) && packageLock.packages[installedPathKey]) {
packageJson.devDependencies[packageName] = packageLock.packages[installedPathKey].version;
}
}

fs.writeFileSync('../package.json', JSON.stringify(packageJson, null, 2));

0 comments on commit bd1f442

Please sign in to comment.