@swimlane/nodegit 1.1.10 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -16,16 +16,14 @@ jobs:
16
16
  name: build
17
17
  strategy:
18
18
  matrix:
19
- node: [22.x]
19
+ node: [24.x]
20
20
  os:
21
21
  # macos-14 is arm64 (m1)
22
22
  - name: darwin
23
23
  host: macos-14
24
24
 
25
- # ubuntu-20.04 is x86. Still no arm linux runners yet
26
- # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
27
25
  - name: linux-amd
28
- host: ubuntu-20.04
26
+ host: ubuntu-24.04
29
27
  env:
30
28
  CC: clang
31
29
  CXX: clang++
@@ -112,7 +110,7 @@ jobs:
112
110
  submodules: true
113
111
  - uses: actions/setup-node@v4
114
112
  with:
115
- node-version: 22.x
113
+ node-version: 24.x
116
114
  check-latest: true
117
115
  registry-url: "https://registry.npmjs.org"
118
116
  scope: "swimlane"
@@ -162,7 +160,7 @@ jobs:
162
160
  submodules: true
163
161
  - uses: actions/setup-node@v4
164
162
  with:
165
- node-version: 22.x
163
+ node-version: 24.x
166
164
  check-latest: true
167
165
  registry-url: "https://npm.pkg.github.com"
168
166
  scope: "@swimlane"
@@ -17,7 +17,7 @@ jobs:
17
17
  release-prep:
18
18
  name: Release | Prep
19
19
  runs-on:
20
- - large-amd
20
+ - ubuntu-latest
21
21
  outputs:
22
22
  release-outputs: ${{ toJSON(steps.release.outputs) }}
23
23
  steps:
@@ -21,8 +21,8 @@ jobs:
21
21
  npm_config_clang: 1
22
22
  GYP_DEFINES: use_obsolete_asm=true
23
23
  DEBIAN_FRONTEND: "noninteractive"
24
- runs-on: ubuntu-20.04
25
- container: ubuntu:20.04
24
+ runs-on: ubuntu-24.04
25
+ container: ubuntu:24.04
26
26
  steps:
27
27
  - name: prerequisites
28
28
  run: |
@@ -33,7 +33,7 @@ jobs:
33
33
  submodules: true
34
34
  - uses: actions/setup-node@v4
35
35
  with:
36
- node-version: 22.0.0
36
+ node-version: 24.0.0
37
37
  check-latest: true
38
38
  - name: Test
39
39
  run: |
@@ -61,14 +61,14 @@ jobs:
61
61
  CXX: clang++
62
62
  npm_config_clang: 1
63
63
  GYP_DEFINES: use_obsolete_asm=true
64
- runs-on: macos-13
64
+ runs-on: macos-15
65
65
  steps:
66
66
  - uses: actions/checkout@v4
67
67
  with:
68
68
  submodules: true
69
69
  - uses: actions/setup-node@v4
70
70
  with:
71
- node-version: 22.0.0
71
+ node-version: 24.0.0
72
72
  check-latest: true
73
73
  - name: Test
74
74
  run: |
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # NodeGit
2
2
 
3
- > Node bindings to the [libgit2](http://libgit2.github.com/) project.
3
+ > Node bindings to the [libgit2](http://libgit2.github.com/) project.
4
4
 
5
5
  [![Actions Status](https://github.com/nodegit/nodegit/workflows/Testing/badge.svg)](https://github.com/nodegit/nodegit/actions)
6
6
 
package/binding.gyp CHANGED
@@ -17,38 +17,8 @@
17
17
  },
18
18
 
19
19
  "targets": [{
20
- "target_name": "acquireOpenSSL",
21
- "type": "none",
22
- "conditions": [
23
- ["<(is_electron) == 1 and <!(node -p \"process.env.npm_config_openssl_dir ? 0 : 1\")", {
24
- "actions": [{
25
- "action_name": "acquire",
26
- "action": ["node", "utils/acquireOpenSSL.js", "<(macOS_deployment_target)"],
27
- "inputs": [""],
28
- "outputs": ["vendor/openssl"],
29
- "message": "Acquiring OpenSSL binaries and headers"
30
- }]
31
- }]
32
- ]
33
- }, {
34
- "target_name": "configureLibssh2",
35
- "type": "none",
36
- "actions": [{
37
- "action_name": "configure",
38
- "action": ["node", "utils/configureLibssh2.js"],
39
- "inputs": [""],
40
- "outputs": [""]
41
- }],
42
- "hard_dependencies": [
43
- "acquireOpenSSL"
44
- ]
45
- }, {
46
20
  "target_name": "nodegit",
47
21
 
48
- "hard_dependencies": [
49
- "configureLibssh2"
50
- ],
51
-
52
22
  "dependencies": [
53
23
  "vendor/libgit2.gyp:libgit2"
54
24
  ],
@@ -85,6 +55,7 @@
85
55
  "src/attr_options.cc",
86
56
  "src/blame.cc",
87
57
  "src/blame_hunk.cc",
58
+ "src/blame_line.cc",
88
59
  "src/blame_options.cc",
89
60
  "src/blob.cc",
90
61
  "src/blob_filter_options.cc",
@@ -103,9 +74,12 @@
103
74
  "src/clone.cc",
104
75
  "src/clone_options.cc",
105
76
  "src/commit.cc",
77
+ "src/commit_create_options.cc",
106
78
  "src/commit_graph.cc",
107
79
  "src/commit_graph_writer.cc",
80
+ "src/commitarray.cc",
108
81
  "src/config.cc",
82
+ "src/config_backend_memory_options.cc",
109
83
  "src/config_entry.cc",
110
84
  "src/config_entry.cc",
111
85
  "src/config_iterator.cc",
@@ -129,6 +103,8 @@
129
103
  "src/diff_patchid_options.cc",
130
104
  "src/diff_perfdata.cc",
131
105
  "src/diff_stats.cc",
106
+ "src/email.cc",
107
+ "src/email_create_options.cc",
132
108
  "src/error.cc",
133
109
  "src/fetch.cc",
134
110
  "src/fetch_options.cc",
@@ -224,6 +200,7 @@
224
200
  "src/treebuilder.cc",
225
201
  "src/worktree.cc",
226
202
  "src/worktree_add_options.cc",
203
+ "src/worktree_add_options.cc",
227
204
  "src/worktree_prune_options.cc",
228
205
  "src/worktree_prune_options.cc",
229
206
  "src/writestream.cc",
@@ -232,7 +209,7 @@
232
209
  "include_dirs": [
233
210
  "vendor/libv8-convert",
234
211
  "vendor/libssh2/include",
235
- "<!(node -e \"require('@axosoft/nan')\")"
212
+ "<!(node -e \"require('nan')\")"
236
213
  ],
237
214
 
238
215
  "cflags": [
@@ -296,7 +273,8 @@
296
273
  }]
297
274
  ],
298
275
  "defines": [
299
- "_HAS_EXCEPTIONS=1"
276
+ "_HAS_EXCEPTIONS=1",
277
+ "NOMINMAX=1"
300
278
  ],
301
279
  "msvs_settings": {
302
280
  "VCCLCompilerTool": {
@@ -312,9 +290,9 @@
312
290
  }
313
291
  },
314
292
  "libraries": [
315
- "winhttp.lib",
316
293
  "crypt32.lib",
317
- "rpcrt4.lib"
294
+ "rpcrt4.lib",
295
+ "secur32.lib"
318
296
  ]
319
297
  }
320
298
  ],
@@ -330,21 +308,28 @@
330
308
  "-std=c++<(cxx_version)"
331
309
  ],
332
310
  }],
333
- ["<(is_electron) == 1 and <(electron_openssl_static) == 1", {
311
+ ["<(is_electron) == 1", {
312
+ "conditions": [
313
+ ["<(electron_openssl_static) == 1", {
314
+ "libraries": [
315
+ "<(electron_openssl_root)/lib/libssl.a",
316
+ "<(electron_openssl_root)/lib/libcrypto.a"
317
+ ]
318
+ }],
319
+ ["<(electron_openssl_static) != 1", {
320
+ "library_dirs": [
321
+ "<(electron_openssl_root)/lib"
322
+ ],
323
+ "libraries": [
324
+ "-lcrypto",
325
+ "-lssl"
326
+ ]
327
+ }]
328
+ ],
334
329
  "include_dirs": [
335
330
  "<(electron_openssl_root)/include"
336
331
  ],
337
- "libraries": [#this order is significant on centos7 apparently...
338
- "<(electron_openssl_root)/lib/libssl.a",
339
- "<(electron_openssl_root)/lib/libcrypto.a"
340
- ]
341
332
  }],
342
- ["<(is_electron) == 1 and <(electron_openssl_static) != 1", {
343
- "libraries": [
344
- "-lcrypto",
345
- "-lssl"
346
- ]
347
- }]
348
333
  ],
349
334
  }],
350
335
  [
package/lib/credential.js CHANGED
@@ -16,6 +16,7 @@ NodeGit.Cred = {
16
16
  defaultNew: deprecatedFn("defaultNew"),
17
17
  sshKeyFromAgent: deprecatedFn("sshKeyFromAgent"),
18
18
  sshKeyNew: deprecatedFn("sshKeyNew"),
19
+ sshKeyMemoryNew: deprecatedFn("sshKeyMemoryNew"),
19
20
  usernameNew: deprecatedFn("usernameNew"),
20
21
  userpassPlaintextNew: deprecatedFn("userpassPlaintextNew"),
21
22
  TYPE: Object.keys(Credential.TYPE).reduce(
package/lib/enums.js CHANGED
@@ -69,8 +69,7 @@ NodeGit.Checkout.NOTIFY = {
69
69
  ALL: 65535,
70
70
  };
71
71
  NodeGit.Checkout.STRATEGY = {
72
- NONE: 0,
73
- SAFE: 1,
72
+ SAFE: 0,
74
73
  FORCE: 2,
75
74
  RECREATE_MISSING: 4,
76
75
  ALLOW_CONFLICTS: 16,
@@ -91,6 +90,7 @@ NodeGit.Checkout.STRATEGY = {
91
90
  DONT_WRITE_INDEX: 8388608,
92
91
  DRY_RUN: 16777216,
93
92
  CONFLICT_STYLE_ZDIFF3: 33554432,
93
+ NONE: 1073741824,
94
94
  UPDATE_SUBMODULES: 65536,
95
95
  UPDATE_SUBMODULES_IF_CHANGED: 131072,
96
96
  };
@@ -109,7 +109,8 @@ NodeGit.Config.LEVEL = {
109
109
  XDG: 3,
110
110
  GLOBAL: 4,
111
111
  LOCAL: 5,
112
- APP: 6,
112
+ WORKTREE: 6,
113
+ APP: 7,
113
114
  HIGHEST_LEVEL: -1,
114
115
  };
115
116
  NodeGit.Config.MAP = {
@@ -237,11 +238,11 @@ NodeGit.Enums.DIRECTION = {
237
238
  FETCH: 0,
238
239
  PUSH: 1,
239
240
  };
240
- NodeGit.Enums.EMAIL_CREATE_FLAGS = {
241
- EMAIL_CREATE_DEFAULT: 0,
242
- EMAIL_CREATE_OMIT_NUMBERS: 1,
243
- EMAIL_CREATE_ALWAYS_NUMBER: 2,
244
- EMAIL_CREATE_NO_RENAMES: 4,
241
+ NodeGit.Email.CREATE_FLAGS = {
242
+ CREATE_DEFAULT: 0,
243
+ CREATE_OMIT_NUMBERS: 1,
244
+ CREATE_ALWAYS_NUMBER: 2,
245
+ CREATE_NO_RENAMES: 4,
245
246
  };
246
247
  NodeGit.Error.ERROR = {
247
248
  NONE: 0,
@@ -315,12 +316,23 @@ NodeGit.Error.CODE = {
315
316
  EAPPLYFAIL: -35,
316
317
  EOWNER: -36,
317
318
  TIMEOUT: -37,
319
+ EUNCHANGED: -38,
320
+ ENOTSUPPORTED: -39,
321
+ EREADONLY: -40,
318
322
  };
319
323
  NodeGit.Enums.FEATURE = {
320
324
  THREADS: 1,
321
325
  HTTPS: 2,
322
326
  SSH: 4,
323
327
  NSEC: 8,
328
+ HTTP_PARSER: 16,
329
+ REGEX: 32,
330
+ I18N: 64,
331
+ AUTH_NTLM: 128,
332
+ AUTH_NEGOTIATE: 256,
333
+ COMPRESSION: 512,
334
+ SHA1: 1024,
335
+ SHA256: 2048,
324
336
  };
325
337
  NodeGit.Fetch.DEPTH = {
326
338
  FULL: 0,
@@ -431,6 +443,9 @@ NodeGit.Libgit2.OPT = {
431
443
  GET_SERVER_CONNECT_TIMEOUT: 40,
432
444
  SET_SERVER_TIMEOUT: 41,
433
445
  GET_SERVER_TIMEOUT: 42,
446
+ SET_USER_AGENT_PRODUCT: 43,
447
+ GET_USER_AGENT_PRODUCT: 44,
448
+ ADD_SSL_X509_CERT: 45,
434
449
  };
435
450
  NodeGit.Merge.ANALYSIS = {
436
451
  NONE: 0,
@@ -559,6 +574,10 @@ NodeGit.Remote.REDIRECT = {
559
574
  INITIAL: 2,
560
575
  ALL: 4,
561
576
  };
577
+ NodeGit.Remote.UPDATE_FLAGS = {
578
+ UPDATE_FETCHHEAD: 1,
579
+ UPDATE_REPORT_UNCHANGED: 2,
580
+ };
562
581
  NodeGit.Repository.INIT_FLAG = {
563
582
  BARE: 1,
564
583
  NO_REINIT: 2,
@@ -588,7 +607,8 @@ NodeGit.Repository.ITEM = {
588
607
  LOGS: 11,
589
608
  MODULES: 12,
590
609
  WORKTREES: 13,
591
- _LAST: 14,
610
+ WORKTREE_CONFIG: 14,
611
+ _LAST: 15,
592
612
  };
593
613
  NodeGit.Repository.OPEN_FLAG = {
594
614
  OPEN_NO_SEARCH: 1,
package/lib/nodegit.js CHANGED
@@ -233,6 +233,7 @@ _Commit.prototype.nthGenAncestor = promisify(_Commit_nthGenAncestor);
233
233
  var _Commit_parent = _Commit.prototype.parent;
234
234
  _Commit.prototype.parent = promisify(_Commit_parent);
235
235
 
236
+ var _Commitarray = rawApi.Commitarray;
236
237
  var _Config = rawApi.Config;
237
238
 
238
239
  var _Config_findGlobal = _Config.findGlobal;
@@ -399,6 +400,20 @@ var _DiffStats = rawApi.DiffStats;
399
400
  var _DiffStats_toBuf = _DiffStats.prototype.toBuf;
400
401
  _DiffStats.prototype.toBuf = promisify(_DiffStats_toBuf);
401
402
 
403
+ var _Email = rawApi.Email;
404
+
405
+ var _Email_createFromCommit = _Email.createFromCommit;
406
+ _Email.createFromCommit = promisify(_Email_createFromCommit);
407
+
408
+ var _Email_createFromDiff = _Email.createFromDiff;
409
+ _Email.createFromDiff = promisify(_Email_createFromDiff);
410
+
411
+ rawApi.EmailCreateOptions = util.deprecate(function EmailCreateOptions() {
412
+ try {
413
+ require("./deprecated/structs/EmailCreateOptions").call(this, rawApi);
414
+ }
415
+ catch (error) { /* allow these to be undefined */ }
416
+ }, "Instantiation of EmailCreateOptions is deprecated and will be removed in an upcoming version");
402
417
  var _Error = rawApi.Error;
403
418
  rawApi.FetchOptions = util.deprecate(function FetchOptions() {
404
419
  try {
@@ -516,6 +531,9 @@ _Index.prototype.find = promisify(_Index_find);
516
531
  var _Index_findPrefix = _Index.prototype.findPrefix;
517
532
  _Index.prototype.findPrefix = promisify(_Index_findPrefix);
518
533
 
534
+ var _Index_open = _Index.open;
535
+ _Index.open = promisify(_Index_open);
536
+
519
537
  var _Index_read = _Index.prototype.read;
520
538
  _Index.prototype.read = promisify(_Index_read);
521
539
 
@@ -706,12 +724,15 @@ _Odb.prototype.addDiskAlternate = promisify(_Odb_addDiskAlternate);
706
724
  var _Odb_existsPrefix = _Odb.prototype.existsPrefix;
707
725
  _Odb.prototype.existsPrefix = promisify(_Odb_existsPrefix);
708
726
 
727
+ var _Odb_hashfile = _Odb.hashfile;
728
+ _Odb.hashfile = promisify(_Odb_hashfile);
729
+
730
+ var _Odb_open = _Odb.open;
731
+ _Odb.open = promisify(_Odb_open);
732
+
709
733
  var _Odb_read = _Odb.prototype.read;
710
734
  _Odb.prototype.read = promisify(_Odb_read);
711
735
 
712
- var _Odb_readPrefix = _Odb.prototype.readPrefix;
713
- _Odb.prototype.readPrefix = promisify(_Odb_readPrefix);
714
-
715
736
  var _Odb_write = _Odb.prototype.write;
716
737
  _Odb.prototype.write = promisify(_Odb_write);
717
738
 
@@ -967,6 +988,9 @@ rawApi.RemoteCreateOptions = util.deprecate(function RemoteCreateOptions() {
967
988
  }, "Instantiation of RemoteCreateOptions is deprecated and will be removed in an upcoming version");
968
989
  var _Repository = rawApi.Repository;
969
990
 
991
+ var _Repository_commitParents = _Repository.prototype.commitParents;
992
+ _Repository.prototype.commitParents = promisify(_Repository_commitParents);
993
+
970
994
  var _Repository_config = _Repository.prototype.config;
971
995
  _Repository.prototype.config = promisify(_Repository_config);
972
996
 
@@ -1018,6 +1042,9 @@ _Repository.prototype.refdb = promisify(_Repository_refdb);
1018
1042
  var _Repository_setHead = _Repository.prototype.setHead;
1019
1043
  _Repository.prototype.setHead = promisify(_Repository_setHead);
1020
1044
 
1045
+ var _Repository_wrapOdb = _Repository.wrapOdb;
1046
+ _Repository.wrapOdb = promisify(_Repository_wrapOdb);
1047
+
1021
1048
  var _Repository_cleanup = _Repository.prototype.cleanup;
1022
1049
  _Repository.prototype.cleanup = promisify(_Repository_cleanup);
1023
1050
 
@@ -1091,6 +1118,9 @@ var _Signature = rawApi.Signature;
1091
1118
  var _Signature_default = _Signature.default;
1092
1119
  _Signature.default = promisify(_Signature_default);
1093
1120
 
1121
+ var _Signature_defaultFromEnv = _Signature.defaultFromEnv;
1122
+ _Signature.defaultFromEnv = promisify(_Signature_defaultFromEnv);
1123
+
1094
1124
  var _Signature_fromBuffer = _Signature.fromBuffer;
1095
1125
  _Signature.fromBuffer = promisify(_Signature_fromBuffer);
1096
1126
 
@@ -1325,6 +1355,12 @@ _Worktree.openFromRepository = promisify(_Worktree_openFromRepository);
1325
1355
  var _Worktree_prune = _Worktree.prototype.prune;
1326
1356
  _Worktree.prototype.prune = promisify(_Worktree_prune);
1327
1357
 
1358
+ rawApi.WorktreeAddOptions = util.deprecate(function WorktreeAddOptions() {
1359
+ try {
1360
+ require("./deprecated/structs/WorktreeAddOptions").call(this, rawApi);
1361
+ }
1362
+ catch (error) { /* allow these to be undefined */ }
1363
+ }, "Instantiation of WorktreeAddOptions is deprecated and will be removed in an upcoming version");
1328
1364
  rawApi.WorktreeAddOptions = util.deprecate(function WorktreeAddOptions() {
1329
1365
  try {
1330
1366
  require("./deprecated/structs/WorktreeAddOptions").call(this, rawApi);
@@ -1395,6 +1431,7 @@ importExtension("attr");
1395
1431
  importExtension("attr_options");
1396
1432
  importExtension("blame");
1397
1433
  importExtension("blame_hunk");
1434
+ importExtension("blame_line");
1398
1435
  importExtension("blame_options");
1399
1436
  importExtension("blob");
1400
1437
  importExtension("blob_filter_options");
@@ -1413,9 +1450,12 @@ importExtension("cherrypick_options");
1413
1450
  importExtension("clone");
1414
1451
  importExtension("clone_options");
1415
1452
  importExtension("commit");
1453
+ importExtension("commit_create_options");
1416
1454
  importExtension("commit_graph");
1417
1455
  importExtension("commit_graph_writer");
1456
+ importExtension("commitarray");
1418
1457
  importExtension("config");
1458
+ importExtension("config_backend_memory_options");
1419
1459
  importExtension("config_entry");
1420
1460
  importExtension("config_entry");
1421
1461
  importExtension("config_iterator");
@@ -1439,6 +1479,8 @@ importExtension("diff_parse_options");
1439
1479
  importExtension("diff_patchid_options");
1440
1480
  importExtension("diff_perfdata");
1441
1481
  importExtension("diff_stats");
1482
+ importExtension("email");
1483
+ importExtension("email_create_options");
1442
1484
  importExtension("error");
1443
1485
  importExtension("fetch");
1444
1486
  importExtension("fetch_options");
@@ -1534,6 +1576,7 @@ importExtension("tree_update");
1534
1576
  importExtension("treebuilder");
1535
1577
  importExtension("worktree");
1536
1578
  importExtension("worktree_add_options");
1579
+ importExtension("worktree_add_options");
1537
1580
  importExtension("worktree_prune_options");
1538
1581
  importExtension("worktree_prune_options");
1539
1582
  importExtension("writestream");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@swimlane/nodegit",
3
3
  "description": "Node.js libgit2 asynchronous native bindings",
4
- "version": "1.1.10",
4
+ "version": "2.0.4",
5
5
  "homepage": "http://nodegit.org",
6
6
  "keywords": [
7
7
  "libgit2",
@@ -32,47 +32,57 @@
32
32
  "lib": "./lib"
33
33
  },
34
34
  "engines": {
35
- "node": ">= 16"
35
+ "node": ">= 20"
36
36
  },
37
37
  "dependencies": {
38
- "@axosoft/nan": "^2.20.0-gk.1",
39
38
  "fs-extra": "^7.0.0",
40
- "got": "^11.8.6",
39
+ "got": "^14.4.7",
41
40
  "json5": "^2.1.0",
42
- "lodash": "^4.17.14",
43
- "node-gyp": "^10.0.1",
44
- "node-gyp-build": "^4.8.1",
45
- "ramda": "^0.25.0",
46
- "tar-fs": "^2.1.1"
41
+ "lodash": "^4.18.1",
42
+ "nan": "axosoft/nan#v2.26.2-axosoft.0",
43
+ "node-gyp": "^11.2.0",
44
+ "node-gyp-build": "^4.8.4",
45
+ "tar-fs": "^3.0.9"
46
+ },
47
+ "overrides": {
48
+ "tar": "^7.5.11",
49
+ "picomatch": "^4.0.4",
50
+ "mocha": {
51
+ "diff": "^8.0.3",
52
+ "serialize-javascript": "^7.0.5"
53
+ },
54
+ "jshint": {
55
+ "minimatch": "3.1.5"
56
+ },
57
+ "brace-expansion@<1.1.12": "^1.1.13",
58
+ "brace-expansion@<2.0.3": "^2.0.3"
47
59
  },
48
60
  "devDependencies": {
49
- "cheerio": "^1.0.0-rc.2",
61
+ "aws-sdk": "^2.1095.0",
50
62
  "clean-for-publish": "~1.0.2",
51
63
  "combyne": "~0.8.1",
52
- "coveralls": "^3.0.2",
53
- "istanbul": "^0.4.5",
54
64
  "js-beautify": "~1.5.10",
55
65
  "jshint": "^2.10.0",
56
66
  "lcov-result-merger": "^3.1.0",
57
- "mocha": "^5.2.0",
67
+ "mocha": "^11.4.0",
68
+ "nyc": "^17.1.0",
58
69
  "walk": "^2.3.9"
59
70
  },
60
71
  "scripts": {
61
72
  "cov": "npm run cppcov && npm run filtercov && npm run mergecov",
62
- "coveralls": "cat ./test/coverage/merged.lcov | coveralls",
63
73
  "cppcov": "mkdir -p test/coverage/cpp && ./lcov-1.10/bin/lcov --gcov-tool /usr/bin/gcov-4.9 --capture --directory build/Release/obj.target/nodegit/src --output-file test/coverage/cpp/lcov_full.info",
64
74
  "filtercov": "./lcov-1.10/bin/lcov --extract test/coverage/cpp/lcov_full.info $(pwd)/src/* $(pwd)/src/**/* $(pwd)/include/* $(pwd)/include/**/* --output-file test/coverage/cpp/lcov.info && rm test/coverage/cpp/lcov_full.info",
65
75
  "generateJson": "node generate/scripts/generateJson",
66
76
  "generateMissingTests": "node generate/scripts/generateMissingTests",
67
77
  "generateNativeCode": "node generate/scripts/generateNativeCode",
68
- "install": "node lifecycleScripts/preinstall.js && node-gyp-build",
78
+ "install": "node lifecycleScripts/preinstall && node-gyp-build",
69
79
  "installDebug": "BUILD_DEBUG=true npm install",
70
80
  "lint": "jshint lib test/tests test/utils lifecycleScripts",
71
81
  "mergecov": "lcov-result-merger 'test/**/*.info' 'test/coverage/merged.lcov' && ./lcov-1.10/bin/genhtml test/coverage/merged.lcov --output-directory test/coverage/report",
72
82
  "mocha": "mocha --expose-gc test/runner test/tests --timeout 15000",
73
83
  "mochaDebug": "mocha --expose-gc --inspect-brk test/runner test/tests --timeout 15000",
74
- "preinstall": "node lifecycleScripts/preinstall",
75
84
  "postinstall": "node lifecycleScripts/postinstall",
85
+ "preinstall": "node lifecycleScripts/preinstall",
76
86
  "rebuild": "node generate && node-gyp configure build",
77
87
  "rebuildDebug": "node generate && node-gyp configure --debug build",
78
88
  "recompile": "node-gyp configure build",
@@ -1,4 +1,4 @@
1
- FROM node:22.13.1-alpine3.21
1
+ FROM node:24.15.0-alpine3.22
2
2
 
3
3
  RUN apk add build-base git krb5-dev libgit2-dev libssh-dev pkgconfig python3 tzdata
4
4
 
@@ -1,4 +1,4 @@
1
- FROM node:22.13.1-bullseye
1
+ FROM node:24.15.0-bullseye
2
2
 
3
3
  ENV DEBIAN_FRONTEND noninteractive
4
4
  ENV LC_ALL en_US.UTF-8
@@ -1,27 +1,29 @@
1
- const crypto = require("crypto");
2
- const execPromise = require("./execPromise");
3
- // for fs.remove. replace with fs.rm after dropping v12 support
4
- const fse = require("fs-extra");
5
- const fsNonPromise = require("fs");
6
- const { promises: fs } = fsNonPromise;
7
- const path = require("path");
8
- const got = require("got");
9
- const { performance } = require("perf_hooks");
10
- const { promisify } = require("util");
11
- const stream = require("stream");
12
- const tar = require("tar-fs");
13
- const zlib = require("zlib");
1
+ import crypto from "crypto";
2
+ import { spawn } from "child_process";
3
+ import execPromise from "./execPromise.js";
4
+ import got from "got";
5
+ import path from "path";
6
+ import stream from "stream";
7
+ import tar from "tar-fs";
8
+ import zlib from "zlib";
9
+ import { createWriteStream, promises as fs } from "fs";
10
+ import { performance } from "perf_hooks";
11
+ import { promisify } from "util";
12
+
13
+ import { hostArch, targetArch } from "./buildFlags.js";
14
14
 
15
15
  const pipeline = promisify(stream.pipeline);
16
16
 
17
- const packageJson = require('../package.json')
17
+ import packageJson from '../package.json' with { type: "json" };
18
18
 
19
- const OPENSSL_VERSION = "1.1.1t";
20
- const win32BatPath = path.join(__dirname, "build-openssl.bat");
21
- const vendorPath = path.resolve(__dirname, "..", "vendor");
19
+ const OPENSSL_VERSION = "3.0.18";
20
+ const win32BatPath = path.join(import.meta.dirname, "build-openssl.bat");
21
+ const vendorPath = path.resolve(import.meta.dirname, "..", "vendor");
22
22
  const opensslPatchPath = path.join(vendorPath, "patches", "openssl");
23
23
  const extractPath = path.join(vendorPath, "openssl");
24
24
 
25
+ const exists = (filePath) => fs.stat(filePath).then(() => true).catch(() => false);
26
+
25
27
  const pathsToIncludeForPackage = [
26
28
  "include", "lib"
27
29
  ];
@@ -58,7 +60,9 @@ const makeHashVerifyOnFinal = (expected) => (digest) => {
58
60
  // currently this only needs to be done on linux
59
61
  const applyOpenSSLPatches = async (buildCwd, operatingSystem) => {
60
62
  try {
61
- for (const patchFilename of await fse.readdir(opensslPatchPath)) {
63
+ await fs.access(opensslPatchPath);
64
+
65
+ for (const patchFilename of await fs.readdir(opensslPatchPath)) {
62
66
  const patchTarget = patchFilename.split("-")[1];
63
67
  if (patchFilename.split(".").pop() === "patch" && (patchTarget === operatingSystem || patchTarget === "all")) {
64
68
  console.log(`applying ${patchFilename}`);
@@ -68,6 +72,11 @@ const applyOpenSSLPatches = async (buildCwd, operatingSystem) => {
68
72
  }
69
73
  }
70
74
  } catch(e) {
75
+ if (e.code === "ENOENT") {
76
+ // no patches to apply
77
+ return;
78
+ }
79
+
71
80
  console.log("Patch application failed: ", e);
72
81
  throw e;
73
82
  }
@@ -78,8 +87,10 @@ const buildDarwin = async (buildCwd, macOsDeploymentTarget) => {
78
87
  throw new Error("Expected macOsDeploymentTarget to be specified");
79
88
  }
80
89
 
81
- const arguments = [
82
- process.arch === "x64" ? "darwin64-x86_64-cc" : "darwin64-arm64-cc",
90
+ const buildConfig = targetArch === "x64" ? "darwin64-x86_64-cc" : "darwin64-arm64-cc";
91
+
92
+ const configureArgs = [
93
+ buildConfig,
83
94
  // speed up ecdh on little-endian platforms with 128bit int support
84
95
  "enable-ec_nistp_64_gcc_128",
85
96
  // compile static libraries
@@ -88,6 +99,8 @@ const buildDarwin = async (buildCwd, macOsDeploymentTarget) => {
88
99
  "no-ssl2",
89
100
  "no-ssl3",
90
101
  "no-comp",
102
+ // disable tty ui since it fails a bunch of tests on GHA runners and we're just gonna link anyways
103
+ "no-ui-console",
91
104
  // set install directory
92
105
  `--prefix="${extractPath}"`,
93
106
  `--openssldir="${extractPath}"`,
@@ -95,13 +108,13 @@ const buildDarwin = async (buildCwd, macOsDeploymentTarget) => {
95
108
  `-mmacosx-version-min=${macOsDeploymentTarget}`
96
109
  ];
97
110
 
98
- await execPromise(`./Configure ${arguments.join(" ")}`, {
111
+ await execPromise(`./Configure ${configureArgs.join(" ")}`, {
99
112
  cwd: buildCwd
100
113
  }, { pipeOutput: true });
101
114
 
102
115
  await applyOpenSSLPatches(buildCwd, "darwin");
103
116
 
104
- // only build the libraries, not the tests/fuzzer or apps
117
+ // only build the libraries, not the fuzzer or apps
105
118
  await execPromise("make build_libs", {
106
119
  cwd: buildCwd
107
120
  }, { pipeOutput: true });
@@ -117,37 +130,36 @@ const buildDarwin = async (buildCwd, macOsDeploymentTarget) => {
117
130
  };
118
131
 
119
132
  const buildLinux = async (buildCwd) => {
120
- const arguments = [
121
- "linux-x86_64",
122
- // Electron(at least on centos7) imports the libcups library at runtime, which has a
123
- // dependency on the system libssl/libcrypto which causes symbol conflicts and segfaults.
124
- // To fix this we need to hide all the openssl symbols to prevent them from being overridden
125
- // by the runtime linker.
126
- "-fvisibility=hidden",
127
- // compile static libraries
128
- "no-shared",
129
- // disable ssl2, ssl3, and compression
130
- "no-ssl2",
133
+ const buildConfig = targetArch === "x64" ? "linux-x86_64" : "linux-aarch64";
134
+
135
+ const configureArgs = [
136
+ buildConfig,
137
+ // disable ssl3, and compression
131
138
  "no-ssl3",
132
139
  "no-comp",
133
140
  // set install directory
134
141
  `--prefix="${extractPath}"`,
135
- `--openssldir="${extractPath}"`
142
+ `--openssldir="${extractPath}"`,
143
+ "--libdir=lib",
136
144
  ];
137
- await execPromise(`./Configure ${arguments.join(" ")}`, {
145
+ await execPromise(`./Configure ${configureArgs.join(" ")}`, {
138
146
  cwd: buildCwd
139
147
  }, { pipeOutput: true });
140
148
 
141
149
  await applyOpenSSLPatches(buildCwd, "linux");
142
150
 
143
- // only build the libraries, not the tests/fuzzer or apps
151
+ // only build the libraries, not the fuzzer or apps
144
152
  await execPromise("make build_libs", {
145
- cwd: buildCwd
153
+ cwd: buildCwd,
154
+ maxBuffer: 10 * 1024 * 1024
146
155
  }, { pipeOutput: true });
147
156
 
148
- await execPromise("make test", {
149
- cwd: buildCwd
150
- }, { pipeOutput: true });
157
+ if (hostArch === targetArch) {
158
+ await execPromise("make test", {
159
+ cwd: buildCwd,
160
+ maxBuffer: 10 * 1024 * 1024
161
+ }, { pipeOutput: true });
162
+ }
151
163
 
152
164
  // only install software, not the docs
153
165
  await execPromise("make install_sw", {
@@ -156,44 +168,108 @@ const buildLinux = async (buildCwd) => {
156
168
  }, { pipeOutput: true });
157
169
  };
158
170
 
159
- const buildWin32 = async (buildCwd, vsBuildArch) => {
160
- if (!vsBuildArch) {
161
- throw new Error("Expected vsBuildArch to be specified");
162
- }
171
+ const buildWin32 = async (buildCwd) => {
172
+ let vcvarsallPath = undefined;
163
173
 
164
- const programFilesPath = (process.arch === "x64"
165
- ? process.env["ProgramFiles(x86)"]
166
- : process.env.ProgramFiles) || "C:\\Program Files";
167
- const vcvarsallPath = process.env.npm_config_vcvarsall_path || `${
168
- programFilesPath
169
- }\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Auxiliary\\Build\\vcvarsall.bat`;
170
- try {
171
- await fs.stat(vcvarsallPath);
172
- } catch {
173
- throw new Error(`vcvarsall.bat not found at ${vcvarsallPath}`);
174
+ if (process.env.npm_config_vcvarsall_path && await exists(process.env.npm_config_vcvarsall_path)) {
175
+ vcvarsallPath = process.env.npm_config_vcvarsall_path;
176
+ } else {
177
+ const potentialMsvsPaths = [];
178
+
179
+ // GYP_MSVS_OVERRIDE_PATH is set by node-gyp so this should cover most cases
180
+ if (process.env.GYP_MSVS_OVERRIDE_PATH) {
181
+ potentialMsvsPaths.push(process.env.GYP_MSVS_OVERRIDE_PATH);
182
+ }
183
+
184
+ const packageTypes = ["BuildTools", "Community", "Professional", "Enterprise"];
185
+ const versions = ["2022", "2019"]
186
+
187
+ const computePossiblePaths = (parentPath) => {
188
+ let possiblePaths = []
189
+ for (const packageType of packageTypes) {
190
+ for (const version of versions) {
191
+ possiblePaths.push(path.join(parentPath, version, packageType));
192
+ }
193
+ }
194
+
195
+ return possiblePaths;
196
+ }
197
+
198
+ if (process.env["ProgramFiles(x86)"]) {
199
+ const parentPath = path.join(process.env["ProgramFiles(x86)"], 'Microsoft Visual Studio');
200
+ potentialMsvsPaths.push(...computePossiblePaths(parentPath));
201
+ }
202
+
203
+ if (process.env.ProgramFiles) {
204
+ const parentPath = path.join(process.env.ProgramFiles, 'Microsoft Visual Studio');
205
+ potentialMsvsPaths.push(...computePossiblePaths(parentPath));
206
+ }
207
+
208
+ for (const potentialPath of potentialMsvsPaths) {
209
+ const wholePath = path.join(potentialPath, 'VC', 'Auxiliary', 'Build', 'vcvarsall.bat');
210
+ console.log("checking", wholePath);
211
+ if (await exists(wholePath)) {
212
+ vcvarsallPath = wholePath;
213
+ break;
214
+ }
215
+ }
216
+
217
+ if (!vcvarsallPath) {
218
+ throw new Error(`vcvarsall.bat not found`);
219
+ }
174
220
  }
175
221
 
176
222
  let vcTarget;
177
- switch (vsBuildArch) {
178
- case "x64": {
223
+ switch (targetArch) {
224
+ case "x64":
179
225
  vcTarget = "VC-WIN64A";
180
226
  break;
181
- }
182
227
 
183
- case "x86": {
228
+ case "x86":
184
229
  vcTarget = "VC-WIN32";
185
230
  break;
186
- }
187
-
188
- default: {
189
- throw new Error(`Unknown vsBuildArch: ${vsBuildArch}`);
190
- }
231
+
232
+ case "arm64":
233
+ vcTarget = "VC-WIN64-ARM";
234
+ break;
191
235
  }
192
236
 
193
- await execPromise(`"${win32BatPath}" "${vcvarsallPath}" ${vsBuildArch} ${vcTarget}`, {
194
- cwd: buildCwd,
195
- maxBuffer: 10 * 1024 * 1024 // we should really just use spawn
196
- }, { pipeOutput: true });
237
+ let vsBuildArch = hostArch === targetArch
238
+ ? hostArch
239
+ : `${hostArch}_${targetArch}`;
240
+
241
+ console.log("Using vcvarsall.bat at: ", vcvarsallPath);
242
+ console.log("Using vsBuildArch: ", vsBuildArch);
243
+ console.log("Using vcTarget: ", vcTarget);
244
+
245
+ await new Promise((resolve, reject) => {
246
+ const buildProcess = spawn(`"${win32BatPath}" "${vcvarsallPath}" ${vsBuildArch} ${vcTarget}`, {
247
+ cwd: buildCwd,
248
+ shell: process.platform === "win32",
249
+ env: {
250
+ ...process.env,
251
+ NODEGIT_SKIP_TESTS: targetArch !== hostArch ? "1" : undefined
252
+ }
253
+ });
254
+
255
+ buildProcess.stdout.on("data", function(data) {
256
+ console.info(data.toString().trim());
257
+ });
258
+
259
+ buildProcess.stderr.on("data", function(data) {
260
+ console.error(data.toString().trim());
261
+ });
262
+
263
+ buildProcess.on("close", function(code) {
264
+ if (!code) {
265
+ resolve();
266
+ } else {
267
+ reject(code);
268
+ }
269
+ });
270
+ });
271
+
272
+
197
273
  };
198
274
 
199
275
  const removeOpenSSLIfOudated = async (openSSLVersion) => {
@@ -217,7 +293,7 @@ const removeOpenSSLIfOudated = async (openSSLVersion) => {
217
293
  }
218
294
 
219
295
  console.log("Removing outdated OpenSSL at: ", extractPath);
220
- await fse.remove(extractPath);
296
+ await fs.rm(extractPath, { recursive: true, force: true });
221
297
  console.log("Outdated OpenSSL removed.");
222
298
  } catch (err) {
223
299
  console.log("Remove outdated OpenSSL failed: ", err);
@@ -237,19 +313,13 @@ const makeOnStreamDownloadProgress = () => {
237
313
 
238
314
  const buildOpenSSLIfNecessary = async ({
239
315
  macOsDeploymentTarget,
240
- openSSLVersion,
241
- vsBuildArch
316
+ openSSLVersion
242
317
  }) => {
243
318
  if (process.platform !== "darwin" && process.platform !== "win32" && process.platform !== "linux") {
244
319
  console.log(`Skipping OpenSSL build, not required on ${process.platform}`);
245
320
  return;
246
321
  }
247
322
 
248
- if (process.platform === "linux" && process.env.NODEGIT_OPENSSL_STATIC_LINK !== "1") {
249
- console.log(`Skipping OpenSSL build, NODEGIT_OPENSSL_STATIC_LINK !== 1`);
250
- return;
251
- }
252
-
253
323
  await removeOpenSSLIfOudated(openSSLVersion);
254
324
 
255
325
  try {
@@ -261,7 +331,7 @@ const buildOpenSSLIfNecessary = async ({
261
331
  const openSSLUrl = getOpenSSLSourceUrl(openSSLVersion);
262
332
  const openSSLSha256Url = getOpenSSLSourceSha256Url(openSSLVersion);
263
333
 
264
- const openSSLSha256 = (await got(openSSLSha256Url)).body.trim();
334
+ const openSSLSha256 = (await got(openSSLSha256Url)).body.trim().split(' ')[0];
265
335
 
266
336
  const downloadStream = got.stream(openSSLUrl);
267
337
  downloadStream.on("downloadProgress", makeOnStreamDownloadProgress());
@@ -282,7 +352,7 @@ const buildOpenSSLIfNecessary = async ({
282
352
  } else if (process.platform === "linux") {
283
353
  await buildLinux(buildCwd);
284
354
  } else if (process.platform === "win32") {
285
- await buildWin32(buildCwd, vsBuildArch);
355
+ await buildWin32(buildCwd);
286
356
  } else {
287
357
  throw new Error(`Unknown platform: ${process.platform}`);
288
358
  }
@@ -300,11 +370,6 @@ const downloadOpenSSLIfNecessary = async ({
300
370
  return;
301
371
  }
302
372
 
303
- if (process.platform === "linux" && process.env.NODEGIT_OPENSSL_STATIC_LINK !== "1") {
304
- console.log(`Skipping OpenSSL download, NODEGIT_OPENSSL_STATIC_LINK !== 1`);
305
- return;
306
- }
307
-
308
373
  try {
309
374
  await fs.stat(extractPath);
310
375
  console.log("Skipping OpenSSL download, dir exists");
@@ -334,18 +399,17 @@ const downloadOpenSSLIfNecessary = async ({
334
399
  console.log("Download finished.");
335
400
  }
336
401
 
337
- const getOpenSSLPackageName = () => {
338
- let arch = process.arch;
339
- if (process.platform === "win32" && (
340
- process.arch === "ia32" || process.env.NODEGIT_VS_BUILD_ARCH === "x86"
341
- )) {
342
- arch = "x86";
343
- }
344
-
345
- return `openssl-${OPENSSL_VERSION}-${process.platform}-${arch}.tar.gz`;
402
+ export const getOpenSSLPackageName = () => {
403
+ return `openssl-${OPENSSL_VERSION}-${process.platform}-${targetArch}.tar.gz`;
346
404
  }
347
405
 
348
- const getOpenSSLPackageUrl = () => `${packageJson.binary.host}${getOpenSSLPackageName()}`;
406
+ export const getOpenSSLPackagePath = () => path.join(import.meta.dirname, getOpenSSLPackageName());
407
+
408
+ const getOpenSSLPackageUrl = () => {
409
+ const hostUrl = new URL(packageJson.binary.host);
410
+ hostUrl.pathname = getOpenSSLPackageName();
411
+ return hostUrl.toString();
412
+ };
349
413
 
350
414
  const buildPackage = async () => {
351
415
  let resolve, reject;
@@ -361,17 +425,17 @@ const buildPackage = async () => {
361
425
  return path.extname(name) === ".pc"
362
426
  || path.basename(name) === "pkgconfig";
363
427
  },
364
- dmode: 0755,
365
- fmode: 0644
428
+ dmode: 0o0755,
429
+ fmode: 0o0644
366
430
  }),
367
431
  zlib.createGzip(),
368
432
  new HashVerify("sha256", (digest) => {
369
433
  resolve(digest);
370
434
  }),
371
- fsNonPromise.createWriteStream(getOpenSSLPackageName())
435
+ createWriteStream(getOpenSSLPackagePath())
372
436
  );
373
437
  const digest = await promise;
374
- await fs.writeFile(`${getOpenSSLPackageName()}.sha256`, digest);
438
+ await fs.writeFile(`${getOpenSSLPackagePath()}.sha256`, digest);
375
439
  };
376
440
 
377
441
  const acquireOpenSSL = async () => {
@@ -394,24 +458,15 @@ const acquireOpenSSL = async () => {
394
458
 
395
459
  let macOsDeploymentTarget;
396
460
  if (process.platform === "darwin") {
397
- macOsDeploymentTarget = process.argv[2];
461
+ macOsDeploymentTarget = process.argv[2] ?? process.env.OPENSSL_MACOS_DEPLOYMENT_TARGET
398
462
  if (!macOsDeploymentTarget || !macOsDeploymentTarget.match(/\d+\.\d+/)) {
399
463
  throw new Error(`Invalid macOsDeploymentTarget: ${macOsDeploymentTarget}`);
400
464
  }
401
465
  }
402
466
 
403
- let vsBuildArch;
404
- if (process.platform === "win32") {
405
- vsBuildArch = process.env.NODEGIT_VS_BUILD_ARCH || (process.arch === "x64" ? "x64" : "x86");
406
- if (!["x64", "x86"].includes(vsBuildArch)) {
407
- throw new Error(`Invalid vsBuildArch: ${vsBuildArch}`);
408
- }
409
- }
410
-
411
467
  await buildOpenSSLIfNecessary({
412
468
  openSSLVersion: OPENSSL_VERSION,
413
- macOsDeploymentTarget,
414
- vsBuildArch
469
+ macOsDeploymentTarget
415
470
  });
416
471
  if (process.env.NODEGIT_OPENSSL_BUILD_PACKAGE) {
417
472
  await buildPackage();
@@ -422,15 +477,12 @@ const acquireOpenSSL = async () => {
422
477
  }
423
478
  };
424
479
 
425
- module.exports = {
426
- acquireOpenSSL,
427
- getOpenSSLPackageName,
428
- OPENSSL_VERSION
429
- };
430
-
431
- if (require.main === module) {
432
- acquireOpenSSL().catch((error) => {
480
+ if (process.argv[1] === import.meta.filename) {
481
+ try {
482
+ await acquireOpenSSL();
483
+ }
484
+ catch(error) {
433
485
  console.error("Acquire OpenSSL failed: ", error);
434
486
  process.exit(1);
435
- });
487
+ }
436
488
  }
@@ -1,9 +1,18 @@
1
+ rem Build OpenSSL for Windows
2
+ rem %1 - path to vcvarsall.bat
3
+ rem %2 - architecture argument for vcvarsall.bat
4
+ rem %3 - OpenSSL Configure target
5
+
1
6
  @call %1 %2
2
7
 
3
8
  perl .\Configure %3 no-shared no-ssl2 no-ssl3 no-comp --prefix="%cd%\.." --openssldir="%cd%\.." || goto :error
4
9
 
5
10
  nmake || goto :error
6
- nmake test || goto :error
11
+
12
+ if "%NODEGIT_SKIP_TESTS%" NEQ "1" (
13
+ nmake test || goto :error
14
+ )
15
+
7
16
  nmake install || goto :error
8
17
 
9
18
  goto :EOF
@@ -10,7 +10,29 @@ try {
10
10
  isGitRepo = false;
11
11
  }
12
12
 
13
+ const convertArch = (archStr) => {
14
+ const convertedArch = {
15
+ 'ia32': 'x86',
16
+ 'x86': 'x86',
17
+ 'x64': 'x64',
18
+ 'arm64': 'arm64'
19
+ }[archStr];
20
+
21
+ if (!convertedArch) {
22
+ throw new Error('unsupported architecture');
23
+ }
24
+
25
+ return convertedArch;
26
+ }
27
+
28
+ const hostArch = convertArch(process.arch);
29
+ const targetArch = process.env.npm_config_arch
30
+ ? convertArch(process.env.npm_config_arch)
31
+ : hostArch;
32
+
13
33
  module.exports = {
34
+ hostArch,
35
+ targetArch,
14
36
  debugBuild: !!process.env.BUILD_DEBUG,
15
37
  isElectron: process.env.npm_config_runtime === "electron",
16
38
  isGitRepo: isGitRepo,
@@ -2,6 +2,8 @@ var cp = require("child_process");
2
2
  var fse = require("fs-extra");
3
3
  var path = require("path");
4
4
 
5
+ const { hostArch, targetArch } = require("./buildFlags");
6
+
5
7
  const opensslVendorDirectory = path.resolve(__dirname, "..", "vendor", "openssl");
6
8
  const libssh2VendorDirectory = path.resolve(__dirname, "..", "vendor", "libssh2");
7
9
  const libssh2ConfigureScript = path.join(libssh2VendorDirectory, "configure");
@@ -19,20 +21,21 @@ module.exports = function retrieveExternalDependencies() {
19
21
  }
20
22
 
21
23
  // Run the `configure` script on Linux
24
+ let cpArgs = ` --with-libssl-prefix=${opensslVendorDirectory}`;
25
+
26
+ const archConfigMap = {
27
+ 'x64': 'x86_64-linux-gnu',
28
+ 'arm64': 'aarch64-linux-gnu'
29
+ };
30
+
31
+ cpArgs += ` --build=${archConfigMap[hostArch]}`;
32
+ cpArgs += ` --host=${archConfigMap[targetArch]}`;
33
+
22
34
  return new Promise(function(resolve, reject) {
23
- var newEnv = {};
24
- Object.keys(process.env).forEach(function(key) {
25
- newEnv[key] = process.env[key];
26
- });
27
-
28
- let cpArgs = process.env.NODEGIT_OPENSSL_STATIC_LINK === '1'
29
- ? ` --with-libssl-prefix=${opensslVendorDirectory}`
30
- : '';
31
35
  cp.exec(
32
36
  `${libssh2ConfigureScript}${cpArgs}`,
33
37
  {
34
- cwd: libssh2VendorDirectory,
35
- env: newEnv
38
+ cwd: libssh2VendorDirectory
36
39
  },
37
40
  function(err, stdout, stderr) {
38
41
  if (err) {
@@ -1,18 +1,29 @@
1
1
  const targetSpecified = process.argv[2] !== 'none';
2
2
 
3
- let isNode18OrElectron20AndUp = false;
3
+ let cxxStandard = '14';
4
+
4
5
  if (targetSpecified) {
5
- // Assume electron if target is specified.
6
+ // --target= is used by both prebuildify (Node version) and electron-rebuild
7
+ // (Electron version). Node 24+ ships V8 13.x which requires C++20 for the
8
+ // `requires` clauses in v8-persistent-handle.h; Electron 32+ similarly needs
9
+ // C++20. Anything older falls back to C++17.
6
10
  // If building node 18 / 19 via target, will need to specify C++ standard manually
7
11
  const majorVersion = process.argv[2].split('.')[0];
8
- isNode18OrElectron20AndUp = majorVersion >= 20;
12
+ if (Number.parseInt(majorVersion) >= 32) {
13
+ cxxStandard = '20';
14
+ } else if (Number.parseInt(majorVersion) >= 24) {
15
+ cxxStandard = '20';
16
+ } else if (Number.parseInt(majorVersion) >= 21) {
17
+ cxxStandard = '17';
18
+ }
9
19
  } else {
20
+ const abiVersion = Number.parseInt(process.versions.modules) ?? 0;
10
21
  // Node 18 === 108
11
- isNode18OrElectron20AndUp = Number.parseInt(process.versions.modules) >= 108;
22
+ if (abiVersion >= 131) {
23
+ cxxStandard = '20';
24
+ } else if (abiVersion >= 108) {
25
+ cxxStandard = '17';
26
+ }
12
27
  }
13
28
 
14
- const defaultCxxStandard = isNode18OrElectron20AndUp
15
- ? '17'
16
- : '14';
17
-
18
- process.stdout.write(defaultCxxStandard);
29
+ process.stdout.write(cxxStandard);
@@ -0,0 +1,32 @@
1
+ import aws from 'aws-sdk';
2
+ import fs from "fs";
3
+ import path from "path";
4
+
5
+ import pkgJson from '../package.json' with { type: "json" };
6
+ import { getOpenSSLPackagePath, getOpenSSLPackageName } from './acquireOpenSSL.mjs';
7
+
8
+ const s3 = new aws.S3();
9
+
10
+ const uploadBinaryToS3 = (fileName, bucketName, pathToFile) =>
11
+ s3.upload({
12
+ Body: fs.createReadStream(pathToFile),
13
+ Bucket: bucketName,
14
+ Key: fileName,
15
+ ACL: "public-read"
16
+ }).promise();
17
+
18
+ export const uploadOpenSSL = async () => {
19
+ const packageName = path.basename(getOpenSSLPackageName());
20
+ const packagePath = getOpenSSLPackagePath();
21
+ console.log(`Uploading ${packagePath} to s3://${pkgJson.binary.bucket_name}/${packageName}`);
22
+ await uploadBinaryToS3(packageName, pkgJson.binary.bucket_name, packagePath);
23
+ const sha256PackageName = `${packageName}.sha256`;
24
+ await uploadBinaryToS3(sha256PackageName, pkgJson.binary.bucket_name, `${packagePath}.sha256`);
25
+ };
26
+
27
+ if (process.argv[1] === import.meta.filename) {
28
+ uploadOpenSSL().catch((error) => {
29
+ console.error('Push to S3 failed: ', error);
30
+ process.exit(1);
31
+ });
32
+ }
@@ -1,32 +0,0 @@
1
- var buildFlags = require("../utils/buildFlags");
2
-
3
- module.exports = async function install() {
4
- console.log("[nodegit] Running install script");
5
-
6
- var args = ["install"];
7
-
8
- if (buildFlags.mustBuild) {
9
- console.info(
10
- "[nodegit] Pre-built download disabled, building from source.",
11
- );
12
- args.push("--build-from-source");
13
-
14
- if (buildFlags.debugBuild) {
15
- console.info("[nodegit] Building debug version.");
16
- args.push("--debug");
17
- }
18
- } else {
19
- args.push("--fallback-to-build");
20
- }
21
-
22
- return;
23
- };
24
-
25
- // Called on the command line
26
- if (require.main === module) {
27
- module.exports().catch(function (e) {
28
- console.error("[nodegit] ERROR - Could not finish install");
29
- console.error("[nodegit] ERROR - finished with error code: " + e);
30
- process.exit(e);
31
- });
32
- }