diff --git a/package-lock.json b/package-lock.json index 62c58f5..1c9ec11 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,11 +17,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" } }, "node_modules/@ampproject/remapping": { diff --git a/package.json b/package.json index 74a862a..ea3303c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/pin_all_deps.js b/scripts/pin_all_deps.js new file mode 100644 index 0000000..622666b --- /dev/null +++ b/scripts/pin_all_deps.js @@ -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));