Created
October 1, 2022 11:22
-
-
Save u007/707fc3ea72e3a5c8e3cf790e6c8499c6 to your computer and use it in GitHub Desktop.
upgrade package.json to all compatible version
This file contains 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
upgrade: | |
npx ts-node-esm ./upgrade.ts | |
npm update -S |
This file contains 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
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