From afdc489d8ad8f4ab8bba2e1b8b359295e256de8a Mon Sep 17 00:00:00 2001 From: "lauren n. liberda" Date: Fri, 22 Mar 2024 20:54:07 +0100 Subject: [PATCH 1/2] allow building from source --- .npmignore | 4 ---- package.json | 4 ++-- postinstall.js | 6 ++++++ 3 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 postinstall.js diff --git a/.npmignore b/.npmignore index c7459bd..b182fcb 100644 --- a/.npmignore +++ b/.npmignore @@ -1,9 +1,5 @@ -src/ tests/ target/ -Cargo.lock -Cargo.toml -build.rs *.node *.tgz tsconfig.json diff --git a/package.json b/package.json index 106867d..e2be3a5 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,6 @@ }, "license": "Apache-2.0", "devDependencies": { - "@napi-rs/cli": "^2.18.0", "jest": "^28.1.0", "prettier": "^2.8.3", "typedoc": "^0.22.17", @@ -26,11 +25,12 @@ "lint": "prettier --check .", "release-build": "napi build --platform --release --strip", "build": "napi build --platform", - "postinstall": "node download-lib.js", + "postinstall": "node postinstall.js", "test": "jest --verbose --testTimeout 10000", "doc": "typedoc --tsconfig ." }, "dependencies": { + "@napi-rs/cli": "^2.18.0", "https-proxy-agent": "^5.0.1", "node-downloader-helper": "^2.1.5" } diff --git a/postinstall.js b/postinstall.js new file mode 100644 index 0000000..f06926d --- /dev/null +++ b/postinstall.js @@ -0,0 +1,6 @@ +if (process.env.npm_config_build_from_source) { + console.log('building @matrix-org/matrix-sdk-crypto-nodejs from source'); + require('child_process').spawnSync(process.env.npm_execpath || 'npm', ['run', 'release-build']); +} else { + require('./download-lib.js'); +} From 44dd8fb153c4b443a42065d8507d022b48abd1a1 Mon Sep 17 00:00:00 2001 From: "lauren n. liberda" Date: Sat, 23 Mar 2024 16:27:31 +0100 Subject: [PATCH 2/2] cargo build --locked --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e2be3a5..f5baba8 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "scripts": { "lint": "prettier --check .", - "release-build": "napi build --platform --release --strip", + "release-build": "napi build --platform --release --strip --cargo-flags=--locked", "build": "napi build --platform", "postinstall": "node postinstall.js", "test": "jest --verbose --testTimeout 10000",