1
0
Fork 0
mirror of synced 2024-06-02 18:44:54 +12:00
budibase/scripts/pinVersions.js
2021-08-05 12:59:33 +01:00

37 lines
947 B
JavaScript

const fs = require("fs")
const path = require("path")
const MONOREPO_ROOT = "packages"
const packages = fs.readdirSync(MONOREPO_ROOT)
function pinDeps(dependencies) {
for (let dependency in dependencies) {
if (dependency.startsWith("@budibase")) {
dependencies[dependency] = dependencies[dependency].replace("^", "")
}
}
}
// iterate over the monorepo packages
for (let pkg of packages) {
const pkgPath = path.join(MONOREPO_ROOT, pkg)
// only directories
if (fs.statSync(pkgPath).isDirectory()) {
// get the package JSON file
const pkgJsonPath = path.join(pkgPath, "package.json")
const pkgJson = require(`../${pkgJsonPath}`)
// find any budibase dependencies, and pin them
pinDeps(pkgJson.dependencies)
pinDeps(pkgJson.devDependencies)
// update the package JSON files
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2))
}
}
console.log("Pinned dev versions for budibase packages successfully.")