2021-08-05 13:59:33 +02:00
|
|
|
const fs = require("fs")
|
|
|
|
const path = require("path")
|
|
|
|
|
|
|
|
const MONOREPO_ROOT = "packages"
|
|
|
|
|
2022-06-16 20:30:34 +02:00
|
|
|
const packages = getPackages()
|
|
|
|
|
|
|
|
function getPackages() {
|
|
|
|
if (fs.existsSync(MONOREPO_ROOT)) {
|
|
|
|
return fs.readdirSync(MONOREPO_ROOT).map(pkg => path.join(MONOREPO_ROOT, pkg))
|
|
|
|
} else {
|
|
|
|
return ["./"]
|
|
|
|
}
|
|
|
|
}
|
2021-08-05 13:59:33 +02:00
|
|
|
|
|
|
|
function pinDeps(dependencies) {
|
2022-06-16 20:30:34 +02:00
|
|
|
for (let dependency in dependencies) {
|
|
|
|
if (dependency.startsWith("@budibase")) {
|
|
|
|
dependencies[dependency] = dependencies[dependency].replace("^", "")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dependencies
|
2021-08-05 13:59:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// iterate over the monorepo packages
|
2022-06-16 20:30:34 +02:00
|
|
|
for (let pkgPath of packages) {
|
|
|
|
// only directories
|
|
|
|
if (fs.statSync(pkgPath).isDirectory()) {
|
|
|
|
// get the package JSON file
|
|
|
|
const pkgJsonPath = path.join(pkgPath, "package.json")
|
|
|
|
if (!fs.existsSync(pkgJsonPath)) {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath))
|
|
|
|
|
|
|
|
|
|
|
|
// find any budibase dependencies, and pin them
|
|
|
|
pkgJson.dependencies = pinDeps(pkgJson.dependencies)
|
|
|
|
pkgJson.devDependencies = pinDeps(pkgJson.devDependencies)
|
|
|
|
|
|
|
|
// update the package JSON files
|
|
|
|
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkgJson, null, 2))
|
|
|
|
}
|
2021-08-05 13:59:33 +02:00
|
|
|
}
|
|
|
|
|
2022-06-16 20:30:34 +02:00
|
|
|
console.log("Pinned dev versions for budibase packages successfully.")
|