From 844293cf988635f1f0f03a38bb01c5621af8bb20 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 26 May 2023 14:38:41 +0200 Subject: [PATCH] Reset pro dependencies before the npm push --- .github/workflows/release-develop.yml | 3 +++ .github/workflows/release-master.yml | 3 +++ scripts/resetProDependencies.js | 38 +++++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100755 scripts/resetProDependencies.js diff --git a/.github/workflows/release-develop.yml b/.github/workflows/release-develop.yml index c724b717e2..ebd2f4c3ef 100644 --- a/.github/workflows/release-develop.yml +++ b/.github/workflows/release-develop.yml @@ -54,6 +54,9 @@ jobs: - run: yarn build --configuration=production - run: yarn build:sdk + - name: Reset pro dependencies + run: node scripts/resetProDependencies.js + - name: Publish budibase packages to NPM env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-master.yml b/.github/workflows/release-master.yml index 4959194064..304b0de100 100644 --- a/.github/workflows/release-master.yml +++ b/.github/workflows/release-master.yml @@ -60,6 +60,9 @@ jobs: - run: yarn build --configuration=production - run: yarn build:sdk + - name: Reset pro dependencies + run: node scripts/resetProDependencies.js + - name: Publish budibase packages to NPM env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/scripts/resetProDependencies.js b/scripts/resetProDependencies.js new file mode 100755 index 0000000000..c6752c44c6 --- /dev/null +++ b/scripts/resetProDependencies.js @@ -0,0 +1,38 @@ +const fs = require("fs") +const path = require("path") +const { execSync } = require("child_process") + +// Get the list of workspaces with mismatched dependencies +const output = execSync("yarn --silent workspaces info --json", { + encoding: "utf-8", +}) +const data = JSON.parse(output) + +const packageJsonPath = path.join( + data["@budibase/pro"].location, + "package.json" +) +const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8")) + +let hasChanges = false + +const dependencies = data["@budibase/pro"].workspaceDependencies +dependencies.forEach(dependency => { + if (packageJson.dependencies?.[dependency]) { + packageJson.dependencies[dependency] = "0.0.1" + hasChanges = true + } + if (packageJson.devDependencies?.[dependency]) { + packageJson.devDependencies[dependency] = "0.0.1" + hasChanges = true + } + if (packageJson.peerDependencies?.[dependency]) { + packageJson.peerDependencies[dependency] = "0.0.1" + hasChanges = true + } +}) + +// Write changes to package.json if there are any +if (hasChanges) { + fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n") +}