Skip to content

Instantly share code, notes, and snippets.

@brophdawg11
Created August 24, 2022 23:50
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brophdawg11/b856e8e11dcd3f5041a84291e064f5dd to your computer and use it in GitHub Desktop.
Save brophdawg11/b856e8e11dcd3f5041a84291e064f5dd to your computer and use it in GitHub Desktop.
Node script to update installed Remix packages
#!/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