Skip to content

Commit 069b7a2

Browse files
committed
Switched to using pnpm
1 parent 49c293a commit 069b7a2

11 files changed

Lines changed: 4002 additions & 9006 deletions

.circleci/config.yml

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ aliases:
1414
if [[ "${BUILD_ARM64}" == "true" ]]; then
1515
GYP_ARGS="${GYP_ARGS} --target_arch=arm64"
1616
fi
17-
./node_modules/.bin/node-pre-gyp rebuild package testpackage $GYP_ARGS
17+
pnpm exec node-pre-gyp rebuild package testpackage $GYP_ARGS
1818
1919
- &build-command-windows
2020
name: Build
@@ -28,7 +28,7 @@ aliases:
2828
if [[ "${BUILD_ARM64}" == "true" ]]; then
2929
GYP_ARGS="${GYP_ARGS} --target_arch=arm64"
3030
fi
31-
./node_modules/.bin/node-pre-gyp rebuild package testpackage $GYP_ARGS
31+
pnpm exec node-pre-gyp rebuild package testpackage $GYP_ARGS
3232
3333
- &publish-command
3434
name: Publish
@@ -42,7 +42,7 @@ aliases:
4242
fi
4343
COMMIT_MESSAGE=`git log --format=%s -n 1 $CIRCLE_SHA1`
4444
if [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]] && [[ "$PUBLISH" == "true" ]]; then
45-
./node_modules/.bin/node-pre-gyp publish $GYP_ARGS
45+
pnpm exec node-pre-gyp publish $GYP_ARGS
4646
else
4747
echo "Not a tagged build - not publishing"
4848
fi
@@ -61,7 +61,7 @@ aliases:
6161
export PATH=/c/nodejs:$PATH
6262
COMMIT_MESSAGE=`git log --format=%s -n 1 $CIRCLE_SHA1`
6363
if [[ ${COMMIT_MESSAGE} =~ "[publish binary]" ]] && [[ "$PUBLISH" == "true" ]]; then
64-
./node_modules/.bin/node-pre-gyp publish $GYP_ARGS
64+
pnpm exec node-pre-gyp publish $GYP_ARGS
6565
else
6666
echo "Not a tagged build - not publishing"
6767
fi
@@ -74,10 +74,11 @@ aliases:
7474
# Install git-lfs (not part of the standard Docker images)- run: sudo apt-get update
7575
- run: curl -sSL https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
7676
- run: sudo apt-get update && sudo apt-get install -y git-lfs && git-lfs install --force && git-lfs pull
77-
- run: npm install --build-from-source
77+
- run: corepack enable && corepack prepare pnpm@10.14.0 --activate
78+
- run: npm_config_build_from_source=true pnpm install --frozen-lockfile
7879
- run: *build-command
7980

80-
- run: npm run test
81+
- run: pnpm test
8182
- run: *publish-command
8283

8384

@@ -99,11 +100,13 @@ aliases:
99100
name: Install
100101
command: |
101102
node -v
102-
npm install --build-from-source
103-
npm install electron@$ELECTRON_VERSION
103+
corepack enable
104+
corepack prepare pnpm@10.14.0 --activate
105+
pnpm install --frozen-lockfile
106+
pnpm add --save-dev electron@$ELECTRON_VERSION
104107
- run: *build-command
105-
- run: npm run pretest
106-
- run: xvfb-run ./node_modules/.bin/electron-mocha --timeout 480000
108+
- run: pnpm run pretest
109+
- run: xvfb-run pnpm exec electron-mocha --timeout 480000
107110
- run: *publish-command
108111

109112
- &common-macos
@@ -129,18 +132,21 @@ aliases:
129132
source $BASH_ENV
130133
mv node-v$NODE_VERSION-darwin-x64 $NODE_PATH
131134
node -v
135+
corepack enable
136+
corepack prepare pnpm@10.14.0 --activate
137+
pnpm -v
132138
133139
- run:
134140
name: Install & Build
135141
command: |
136142
node -v
137-
npm install --build-from-source
143+
npm_config_build_from_source=true pnpm install --frozen-lockfile
138144
- run: *build-command
139145
- run:
140146
name: Run Tests
141147
command: |
142148
if [[ "${SKIP_TEST}" != "true" ]]; then
143-
npm run test
149+
pnpm test
144150
fi
145151
- run: *publish-command
146152

@@ -167,17 +173,20 @@ aliases:
167173
source $BASH_ENV
168174
mv node-v$NODE_VERSION-darwin-x64 $NODE_PATH
169175
node -v
176+
corepack enable
177+
corepack prepare pnpm@10.14.0 --activate
178+
pnpm -v
170179
171180
- run:
172181
name: Install
173182
command: |
174183
node -v
175-
npm install --build-from-source
176-
npm install electron@$ELECTRON_VERSION
184+
pnpm install --frozen-lockfile
185+
pnpm add --save-dev electron@$ELECTRON_VERSION
177186
178187
- run: *build-command
179-
- run: npm run pretest
180-
- run: ./node_modules/.bin/electron-mocha --timeout 480000
188+
- run: pnpm run pretest
189+
- run: pnpm exec electron-mocha --timeout 480000
181190
- run:
182191
<<: *publish-command
183192

@@ -199,21 +208,25 @@ aliases:
199208
$env:PATH = 'C:\nodejs;{0}' -f $env:PATH
200209
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine)
201210
202-
# npm --vs2015 install --global windows-build-tools
211+
corepack enable
212+
corepack prepare pnpm@10.14.0 --activate
213+
pnpm -v
203214
204215
node -v
205216
- run:
206217
name: Install
207-
command: npm install --build-from-source
218+
command: |
219+
$env:npm_config_build_from_source = 'true'
220+
pnpm install --frozen-lockfile
208221
- run: *build-command-windows
209222
- run:
210223
name: Test
211224
shell: bash.exe
212225
command: |
213226
export PATH=/c/nodejs:$PATH
214227
if [[ "${SKIP_TEST}" != "true" ]]; then
215-
npm run test
216-
./node_modules/.bin/electron-mocha --timeout 480000
228+
pnpm test
229+
pnpm exec electron-mocha --timeout 480000
217230
fi
218231
- run: *publish-command-windows
219232
- store_artifacts:
@@ -225,36 +238,36 @@ aliases:
225238
# ./node_modules/.bin/electron "test/support/createdb-electron.js"
226239
# ./node_modules/.bin/electron-mocha --timeout 480000
227240
jobs:
228-
build-16:
241+
build-20:
229242
<<: *common-build
230243
environment:
231244
PUBLISH: true
232245
ELECTRON_VERSION: "16.0.2"
233246
docker:
234-
- image: circleci/node:16.9.1-stretch
247+
- image: cimg/node:20.19
235248

236249
# Node version should match electron's node version.
237250
# See https://github.com/mapbox/node-sqlite3/pull/1367
238251
build-electron-16:
239252
<<: *common-electron-linux
240253
docker:
241-
- image: circleci/node:16.9.1-stretch
254+
- image: cimg/node:20.19
242255
environment:
243256
ELECTRON_VERSION: "16.0.2"
244257

245258

246-
build-macos-16:
259+
build-macos-20:
247260
<<: *common-macos
248261
environment:
249262
PUBLISH: true
250-
NODE_VERSION: "16.9.1"
263+
NODE_VERSION: "20.19.6"
251264
ELECTRON_VERSION: "16.0.2"
252265

253-
build-macos-16-arm64:
266+
build-macos-20-arm64:
254267
<<: *common-macos
255268
environment:
256269
PUBLISH: true
257-
NODE_VERSION: "16.9.1"
270+
NODE_VERSION: "20.19.6"
258271
ELECTRON_VERSION: "16.0.2"
259272
BUILD_ARM64: true
260273
SKIP_TEST: true
@@ -263,28 +276,28 @@ jobs:
263276
# See https://github.com/mapbox/node-sqlite3/pull/1367
264277

265278
# Build the published N-API 6 binaries
266-
windows-16_x86:
279+
windows-20_x86:
267280
<<: *common-windows
268281
environment:
269-
NODE_VERSION: "16.9.1"
282+
NODE_VERSION: "20.19.6"
270283
NODE_ARCH: x86
271284
PUBLISH: true
272285
ELECTRON_VERSION: "16.0.2"
273286
BUILD_ARM64: false
274287

275-
windows-16_x64:
288+
windows-20_x64:
276289
<<: *common-windows
277290
environment:
278-
NODE_VERSION: "16.9.1"
291+
NODE_VERSION: "20.19.6"
279292
NODE_ARCH: x64
280293
PUBLISH: true
281294
ELECTRON_VERSION: "16.0.2"
282295
BUILD_ARM64: false
283296

284-
windows-16_arm64:
297+
windows-20_arm64:
285298
<<: *common-windows
286299
environment:
287-
NODE_VERSION: "16.9.1"
300+
NODE_VERSION: "20.19.6"
288301
NODE_ARCH: x64
289302
PUBLISH: true
290303
ELECTRON_VERSION: "16.0.2"
@@ -295,10 +308,10 @@ workflows:
295308
version: 2
296309
build_all:
297310
jobs:
298-
- build-16
311+
- build-20
299312
- build-electron-16
300-
- build-macos-16-arm64
301-
- build-macos-16
302-
- windows-16_x86
303-
- windows-16_x64
304-
- windows-16_arm64
313+
- build-macos-20-arm64
314+
- build-macos-20
315+
- windows-20_x86
316+
- windows-20_x64
317+
- windows-20_arm64

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Makefile.gyp
1515
gyp-mac-tool
1616
.dirstamp
1717
npm-debug.log
18+
pnpm-debug.log
1819
test/support/big.db
1920
test/tmp
2021
test/nw/app.nw

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,19 @@ If no matching binary is available for your platform or runtime, the published p
1313
# Installation
1414

1515
```sh
16-
yarn add "@journeyapps/sqlcipher"
16+
pnpm add "@journeyapps/sqlcipher"
1717
# Or: npm install --save "@journeyapps/sqlcipher"
1818
```
1919

20+
## Development
21+
22+
This repository uses `pnpm` for local development and CI.
23+
24+
```sh
25+
pnpm install
26+
pnpm test
27+
```
28+
2029
# Usage
2130

2231
``` js
@@ -55,7 +64,7 @@ A copy of the source for SQLCipher 4.14.0 is bundled, which is based on SQLite 3
5564

5665
Building from source when installing the package is supported again.
5766

58-
The published tarball includes `binding.gyp`, `deps/`, and `src/` so that `npm install --build-from-source`, `node-gyp rebuild`, and rebuild tools such as `electron-rebuild` can compile the addon when needed.
67+
The published tarball includes `binding.gyp`, `deps/`, and `src/` so that `pnpm install`, `npm install`, `node-gyp rebuild`, and rebuild tools such as `electron-rebuild` can compile the addon when needed.
5968

6069
Platform notes:
6170

SQLCipher.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ This will refresh the files in `deps/OpenSSL-Win32`, `deps/OpenSSL-Win64`, `deps
4848
Run:
4949

5050
```sh
51-
./node_modules/.bin/node-gyp rebuild
51+
pnpm exec node-gyp rebuild
5252
```
5353

5454
Then run the tests:
5555

5656
```sh
57-
npm run test
57+
pnpm test
5858
```
5959

6060
If you want to verify the source-build fallback path specifically, temporarily move the matching prebuilt binary out of `lib/binding/` and rerun the tests.
@@ -73,4 +73,3 @@ This repository now builds SQLCipher with:
7373
* Use CommonCrypto on macOS.
7474
* Use the vendored Windows OpenSSL headers and static libraries for Windows release binaries.
7575
* Add additional define statements required by SQLCipher.
76-

lib/sqlite3-binding.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
var bindings = require('bindings');
2+
var fs = require('fs');
23
var path = require('path');
34
var pkg = require('../package.json');
45

6+
function getLocalBuildPath() {
7+
return path.join(__dirname, '..', 'build', 'Release', 'node_sqlite3.node');
8+
}
9+
510
function getPrebuiltPath() {
611
var napiVersion = Number(process.versions.napi || 0);
712
var versions = (((pkg.binary || {}).napi_versions) || [])
@@ -25,9 +30,19 @@ function getPrebuiltPath() {
2530
}
2631

2732
function loadBinding() {
33+
var localBuildPath = getLocalBuildPath();
2834
var bindingPath = getPrebuiltPath();
35+
var localBuildError;
2936
var prebuiltError;
3037

38+
if (fs.existsSync(localBuildPath)) {
39+
try {
40+
return require(localBuildPath);
41+
} catch (err) {
42+
localBuildError = err;
43+
}
44+
}
45+
3146
if (bindingPath) {
3247
try {
3348
return require(bindingPath);
@@ -39,6 +54,9 @@ function loadBinding() {
3954
try {
4055
return bindings('node_sqlite3.node');
4156
} catch (err) {
57+
if (localBuildError) {
58+
err.message += '\nFailed to load local build addon from ' + localBuildPath + ': ' + localBuildError.message;
59+
}
4260
if (prebuiltError) {
4361
err.message += '\nFailed to load prebuilt addon from ' + bindingPath + ': ' + prebuiltError.message;
4462
}

0 commit comments

Comments
 (0)