({ type, name, debug })
| 146 | } |
| 147 | |
| 148 | export function updateOneFramework({ type, name, debug }) { |
| 149 | console.log(`Checking ${type}/${name}`); |
| 150 | const frameworkPath = path.join("frameworks", type, name); |
| 151 | const packageJSONPath = path.join(frameworkPath, "package.json"); |
| 152 | const packageJSONLockPath = path.join(frameworkPath, "package-lock.json"); |
| 153 | |
| 154 | if (!fs.existsSync(packageJSONPath)) { |
| 155 | return `WARN: skipping ${type}/${name} since there's no package.json`; |
| 156 | } |
| 157 | |
| 158 | try { |
| 159 | |
| 160 | const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, "utf8")); |
| 161 | const mainPackages = packageJSON?.["js-framework-benchmark"]?.frameworkVersionFromPackage; |
| 162 | |
| 163 | if (!mainPackages) { |
| 164 | return `WARN: ${type}/${name} has no frameworkVersionFromPackage`; |
| 165 | } |
| 166 | |
| 167 | if (debug) { |
| 168 | console.log(`Checking ${type}/${name} ${mainPackages}`); |
| 169 | } |
| 170 | |
| 171 | const packages = mainPackages.split(":"); |
| 172 | const update = shouldUpdate(packageJSONLockPath, packages); |
| 173 | |
| 174 | if (update) { |
| 175 | // return performUpdate(frameworkPath, type+"/"+name); |
| 176 | } else { |
| 177 | const isPackageObsolete = packages.map((element) => maybeObsolete(element)); |
| 178 | const anyPackageObsolete = isPackageObsolete.some((packageFramework) => packageFramework.isObsolete); |
| 179 | |
| 180 | if (anyPackageObsolete) { |
| 181 | const formattedPackages = isPackageObsolete |
| 182 | .map((result) => `${result.packageName}:${result.lastUpdate}`) |
| 183 | .join(", "); |
| 184 | |
| 185 | console.log(`Last npm update for ${type}/${name} - ${mainPackages} is older than a year: ${formattedPackages}`); |
| 186 | return `INFO: Retire ${type}/${name} - ${mainPackages} is older than a year`; |
| 187 | } |
| 188 | else { |
| 189 | return `INFO: Nothing to do for ${type}/${name}`; |
| 190 | } |
| 191 | } |
| 192 | } catch (error) { |
| 193 | console.error(`Failed to check ${type}/${name}. Error Code ${error.status} and message: ${error.message}`, error); |
| 194 | return `ERROR: Error checking ${type}/${name}`; |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | /** |
| 199 | * Checks frameworks in frameworks/keyed and frameworks/non-keyed for obsolescence, |
no test coverage detected