From 6f7f6bb6747b95ba4a94ba6f728af72ab1eba9fc Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford Date: Mon, 10 Aug 2020 18:46:26 -0700 Subject: [PATCH] add script to merge scratch-gui deps This is in preparation for having webpack build scratch-gui source instead of consuming its build output. This script merges the dependencies listed in package-deps.json with those listed in scratch-gui's package.json, using the package-deps.json version in case of conflict, then writes the result into the `devDependencies` section of scratch-desktop's package.json. --- package-deps.json | 24 ++++++++++++++++++++++++ scripts/rebuild-deps.js | 26 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 package-deps.json create mode 100644 scripts/rebuild-deps.js diff --git a/package-deps.json b/package-deps.json new file mode 100644 index 0000000..a3af1ca --- /dev/null +++ b/package-deps.json @@ -0,0 +1,24 @@ +{ + "description": "Deps of scratch-desktop that don't match scratch-gui. See scripts/rebuild-deps.js", + "devDependencies": { + "async": "^3.2.0", + "babel-plugin-react-intl": "^7.5.7", + "copy-webpack-plugin": "^5.1.1", + "electron": "^8.2.5", + "electron-builder": "^22.6.0", + "electron-devtools-installer": "^3.0.0", + "electron-notarize": "^0.3.0", + "electron-store": "^5.1.1", + "electron-webpack": "^2.8.2", + "eslint": "^7.0.0", + "eslint-config-scratch": "^6.0.0", + "eslint-plugin-import": "^2.20.0", + "eslint-plugin-react": "^7.20.0", + "mkdirp": "^1.0.4", + "nets": "^3.2.0", + "rimraf": "^3.0.2", + "scratch-gui": "github:LLK/scratch-gui#scratch-desktop", + "source-map-loader": "^0.2.4", + "uuid": "^8.0.0" + } +} diff --git a/scripts/rebuild-deps.js b/scripts/rebuild-deps.js new file mode 100644 index 0000000..d29422b --- /dev/null +++ b/scripts/rebuild-deps.js @@ -0,0 +1,26 @@ +const fs = require('fs'); + +const desktopPackage = require('../package.json'); +const desktopRawPackage = require('../package-deps.json'); +const guiPackage = require('../node_modules/scratch-gui/package.json'); + +const sortObject = obj => Object + .keys(obj) + .sort() + .reduce( + (accumulator, currentKey) => { + accumulator[currentKey] = obj[currentKey]; + return accumulator; + }, + {} + ); + +desktopPackage.devDependencies = sortObject(Object.assign( + {}, + guiPackage.devDependencies, + desktopRawPackage.devDependencies +)); + +let newDesktopPackage = JSON.stringify(desktopPackage, null, 2); +newDesktopPackage += '\n'; +fs.writeFileSync('package.json', newDesktopPackage);