Skip to content

Instantly share code, notes, and snippets.

@u007
Created October 1, 2022 11:22
Show Gist options
  • Save u007/707fc3ea72e3a5c8e3cf790e6c8499c6 to your computer and use it in GitHub Desktop.
Save u007/707fc3ea72e3a5c8e3cf790e6c8499c6 to your computer and use it in GitHub Desktop.
upgrade package.json to all compatible version
upgrade:
npx ts-node-esm ./upgrade.ts
npm update -S
import * as fs from 'fs';
const loadPackage = async () => {
const packageJson = fs.readFileSync('./package.json').toString();
const packages = JSON.parse(packageJson);
for (const name of Object.keys(packages.dependencies)) {
console.log(name, ':', packages.dependencies[name]);
// if (name === "vue") {
// packages.dependencies[name] = "^3.0.0"
// continue;
// }
packages.dependencies[name] = '*';
}
for (const name of Object.keys(packages.devDependencies)) {
console.log('dev', name, ':', packages.devDependencies[name]);
// if (name === 'vite' || name === '@vitejs/plugin-vue') {
// packages.devDependencies[name] = "^2.0.0"
// continue;
// }
packages.devDependencies[name] = '*';
}
await fs.writeFileSync('./package.json', JSON.stringify(packages, null, 2));
};
loadPackage();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment