()
| 57 | } |
| 58 | |
| 59 | async function main() { |
| 60 | const outdated = await getOutdated(); |
| 61 | if (!outdated){ |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | log.ok('Building with old dependencies'); |
| 66 | await buildAll(); |
| 67 | log.ok('Built with old dependencies'); |
| 68 | await command('mv build build-old'); |
| 69 | await command('mv darkreader.js darkreader-old.js'); |
| 70 | await command('mv darkreader.mjs darkreader-old.mjs'); |
| 71 | log.ok('Moved built output'); |
| 72 | |
| 73 | const patched = await patchPackage(outdated); |
| 74 | log.ok('Upgrading own dependencies'); |
| 75 | await writeFile(packagePath, `${JSON.stringify(patched, null, 2)}\n`); |
| 76 | await command('npm i'); |
| 77 | await command('git add package.json package-lock.json'); |
| 78 | await command('git commit -m "Bump own dependencies"'); |
| 79 | |
| 80 | log.ok('Upgrading transitive dependencies'); |
| 81 | await command('npm upgrade'); |
| 82 | await command('git add package.json package-lock.json'); |
| 83 | await command('git commit -m "Bump transitive dependencies"'); |
| 84 | log.ok('Installed new dependencies'); |
| 85 | |
| 86 | await buildAll(); |
| 87 | log.ok('Built with new dependencies'); |
| 88 | |
| 89 | await command('diff -r build-old/release/chrome build/release/chrome'); |
| 90 | await command('diff -r build-old/release/chrome-mv3 build/release/chrome-mv3'); |
| 91 | await command('diff -r build-old/release/firefox build/release/firefox'); |
| 92 | await command('diff -r build-old/release/thunderbird build/release/thunderbird'); |
| 93 | await command('diff darkreader-old.js darkreader.js'); |
| 94 | await command('diff darkreader-old.mjs darkreader.mjs'); |
| 95 | log.ok('Dependency upgrade does not result in change to built output'); |
| 96 | |
| 97 | // TODO: when moving this to CI, provide branch name in CI config, along with |
| 98 | // a token |
| 99 | await command('git push origin HEAD:bump-dependencies'); |
| 100 | log.ok('Pushed to GitHub'); |
| 101 | } |
| 102 | |
| 103 | main().catch(() => log.error('Could not automatically upgrade dependencies')); |
no test coverage detected