Created
August 24, 2022 23:50
-
-
Save brophdawg11/b856e8e11dcd3f5041a84291e064f5dd to your computer and use it in GitHub Desktop.
Node script to update installed Remix packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// Usage: | |
// node update-remix.js [version] | |
const { join } = require("path"); | |
const { execSync } = require("child_process"); | |
const [, , version] = process.argv; | |
if (!version) { | |
throw new Error("No version specified"); | |
} | |
const packageJsonPath = join(process.cwd(), "package.json"); | |
console.log(`Updating remix packages in ${packageJsonPath} to ${version}`); | |
const packageJson = require(packageJsonPath); | |
function installUpdates(deps, isDev) { | |
const packages = Object.keys(deps) | |
.filter((k) => k.startsWith("@remix-run/") || k === "remix") | |
.map((k) => `${k}@${version}`) | |
.join(" "); | |
const save = isDev ? "--save-dev" : "--save"; | |
const cmd = `npm install ${save} ${packages}`; | |
console.log(`Executing: ${cmd}`); | |
execSync(cmd); | |
} | |
installUpdates(packageJson.dependencies, false); | |
installUpdates(packageJson.devDependencies, true); | |
console.log(`Running 'npm ci' to sync up all deps`); | |
execSync("npm ci"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment