| 62 | const frameworksCache = new Map(); |
| 63 | |
| 64 | function getVersionFromPackageLock(packageJSONLockPath, packageNames) { |
| 65 | if (!fs.existsSync(packageJSONLockPath)) { |
| 66 | throw new Error(`package-lock.json not found at ${packageJSONLockPath}`); |
| 67 | } |
| 68 | |
| 69 | let versions = {}; |
| 70 | |
| 71 | for (let packageName of packageNames) { |
| 72 | const packageLockJSON = JSON.parse(fs.readFileSync(packageJSONLockPath, "utf8")); |
| 73 | const packageVersion = |
| 74 | packageLockJSON.dependencies?.[packageName]?.version || |
| 75 | packageLockJSON.packages?.[`node_modules/${packageName}`]?.version || |
| 76 | "ERROR: Not found in package-lock"; |
| 77 | versions[packageName] = packageVersion; |
| 78 | } |
| 79 | return versions; |
| 80 | } |
| 81 | |
| 82 | function shouldUpdate(packageJSONLockPath, packageNames, DEBUG) { |
| 83 | let versions = getVersionFromPackageLock(packageJSONLockPath, packageNames); |