1
0
Fork 0
mirror of synced 2024-06-27 02:20:35 +12:00
budibase/scripts/syncProPackage.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-04-22 04:44:11 +12:00
const fs = require("fs")
const path = require("path")
const { execSync } = require("child_process")
2023-05-29 20:54:10 +12:00
let version = "0.0.0"
const localPro = fs.existsSync("packages/pro/src")
2023-04-22 04:52:05 +12:00
if (!localPro) {
2023-11-18 05:44:50 +13:00
version = "latest"
2023-04-22 04:44:11 +12:00
}
// Get the list of workspaces with mismatched dependencies
const output = execSync("yarn --silent workspaces info --json", {
encoding: "utf-8",
})
const data = JSON.parse(output)
// Loop through each workspace and update the dependencies
Object.keys(data).forEach(workspace => {
// Loop through each dependency and update its version in package.json
const packageJsonPath = path.join(data[workspace].location, "package.json")
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"))
2023-05-29 20:54:10 +12:00
if (packageJson.version !== "0.0.0") {
2023-05-06 02:55:16 +12:00
// Don't change if we are not using local versions
return
}
2023-04-22 04:44:11 +12:00
let hasChanges = false
if (packageJson.dependencies && packageJson.dependencies["@budibase/pro"]) {
2023-04-22 04:44:11 +12:00
packageJson.dependencies["@budibase/pro"] = version
hasChanges = true
}
// Write changes to package.json if there are any
if (hasChanges) {
fs.writeFileSync(
packageJsonPath,
JSON.stringify(packageJson, null, 2) + "\n"
)
}
})