diff --git a/ui/package.json b/ui/package.json index 1af09b2c1..be043a5b3 100644 --- a/ui/package.json +++ b/ui/package.json @@ -28,7 +28,10 @@ "tauri": "tauri", "eject": "vite eject", "build": "vite build", - "package-ad4m": "yarn run build && yarn tauri build --verbose" + "package-ad4m": "run-script-os", + "package-ad4m:windows": "yarn run build && yarn tauri build --verbose", + "package-ad4m:macos": "yarn run build && yarn tauri build --verbose", + "package-ad4m:linux": "yarn run build && ./scripts/path-safe-buffer.sh && yarn tauri build --verbose && ./scripts/reverse-path-safe-buffer.sh" }, "eslintConfig": { "extends": [ @@ -62,7 +65,8 @@ "customize-cra": "1.0.0", "react-app-rewired": "^2.2.1", "react-error-overlay": "6.0.9", - "vite": "^4.0.1" + "vite": "^4.0.1", + "run-script-os": "^1.1.6" }, "resolutions": { "react-error-overlay": "6.0.9" diff --git a/ui/scripts/patch-safe-buffer.sh b/ui/scripts/patch-safe-buffer.sh new file mode 100644 index 000000000..64ed7b27a --- /dev/null +++ b/ui/scripts/patch-safe-buffer.sh @@ -0,0 +1,3 @@ +sed "s/import buffer from 'node:buffer';/const buffer = require('buffer');/" ../node_modules/safe-buffer/index.js + +sed "s/import buffer from 'node:buffer'/const buffer = require('buffer');/" ../node_modules/safer-buffer/safer.js diff --git a/ui/scripts/reverse-path-safe-buffer.sh b/ui/scripts/reverse-path-safe-buffer.sh new file mode 100644 index 000000000..031fdc4d5 --- /dev/null +++ b/ui/scripts/reverse-path-safe-buffer.sh @@ -0,0 +1,3 @@ +sed "s/const buffer = require('buffer');/import buffer from 'node:buffer';/" ../node_modules/safe-buffer/index.js + +sed "s/const buffer = require('buffer');/import buffer from 'node:buffer';/" ../node_modules/safer-buffer/safer.js \ No newline at end of file