@yao-pkg/pkg 6.0.0 → 6.1.0

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.
package/lib-es5/mach-o.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.signMachOExecutable = exports.patchMachOExecutable = void 0;
3
+ exports.signMachOExecutable = exports.removeMachOExecutableSignature = exports.patchMachOExecutable = void 0;
4
4
  const child_process_1 = require("child_process");
5
5
  function parseCStr(buf) {
6
6
  for (let i = 0; i < buf.length; i += 1) {
@@ -28,6 +28,11 @@ function patchCommand(type, buf, file) {
28
28
  buf.writeUInt32LE(strsizePatched, 12);
29
29
  }
30
30
  }
31
+ /**
32
+ * It would be nice to explain the purpose of this patching function
33
+ * @param file
34
+ * @returns
35
+ */
31
36
  function patchMachOExecutable(file) {
32
37
  const align = 8;
33
38
  const hsize = 32;
@@ -58,4 +63,10 @@ function signMachOExecutable(executable) {
58
63
  }
59
64
  }
60
65
  exports.signMachOExecutable = signMachOExecutable;
66
+ function removeMachOExecutableSignature(executable) {
67
+ (0, child_process_1.execFileSync)('codesign', ['--remove-signature', executable], {
68
+ stdio: 'inherit',
69
+ });
70
+ }
71
+ exports.removeMachOExecutableSignature = removeMachOExecutableSignature;
61
72
  //# sourceMappingURL=mach-o.js.map
package/lib-es5/sea.js CHANGED
@@ -192,7 +192,13 @@ async function bake(nodePath, target, blobPath) {
192
192
  // copy the executable as the output executable
193
193
  await (0, promises_1.copyFile)(nodePath, outPath);
194
194
  log_1.log.info(`Injecting the blob into ${outPath}...`);
195
- await exec(`npx postject "${outPath}" NODE_SEA_BLOB "${blobPath}" --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2`);
195
+ if (target.platform === 'macos') {
196
+ (0, mach_o_1.removeMachOExecutableSignature)(outPath);
197
+ await exec(`npx postject "${outPath}" NODE_SEA_BLOB "${blobPath}" --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2 --macho-segment-name NODE_SEA`);
198
+ }
199
+ else {
200
+ await exec(`npx postject "${outPath}" NODE_SEA_BLOB "${blobPath}" --sentinel-fuse NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2`);
201
+ }
196
202
  }
197
203
  /** Create NodeJS executable using sea */
198
204
  async function sea(entryPoint, opts) {
package/lib-es5/walker.js CHANGED
@@ -235,13 +235,30 @@ function stepDetect(record, marker, derivatives) {
235
235
  throw (0, log_1.wasReported)(error.message);
236
236
  }
237
237
  }
238
- function findCommonJunctionPoint(file, realFile) {
238
+ /**
239
+ * Find a common junction point between a symlink and the real file path.
240
+ *
241
+ * @param {string} file The file path, including symlink(s).
242
+ * @param {string} realFile The real path to the file.
243
+ *
244
+ * @throws {Error} If no common junction point is found prior to hitting the
245
+ * filesystem root.
246
+ */
247
+ async function findCommonJunctionPoint(file, realFile) {
239
248
  // find common denominator => where the link changes
240
- while ((0, common_1.toNormalizedRealPath)(path_1.default.dirname(file)) === path_1.default.dirname(realFile)) {
249
+ while (true) {
250
+ const stats = await promises_1.default.lstat(file);
251
+ if (stats.isSymbolicLink()) {
252
+ return { file, realFile };
253
+ }
241
254
  file = path_1.default.dirname(file);
242
255
  realFile = path_1.default.dirname(realFile);
256
+ // If the directory is /, break out of the loop and log an error.
257
+ if (file === path_1.default.parse(file).root ||
258
+ realFile === path_1.default.parse(realFile).root) {
259
+ throw new Error('Reached root directory without finding a common junction point');
260
+ }
243
261
  }
244
- return { file, realFile };
245
262
  }
246
263
  class Walker {
247
264
  constructor() {
@@ -286,8 +303,8 @@ class Walker {
286
303
  log_1.log.debug(`${what} ${task.file} is added to queue.`);
287
304
  }
288
305
  }
289
- appendSymlink(file, realFile) {
290
- const a = findCommonJunctionPoint(file, realFile);
306
+ async appendSymlink(file, realFile) {
307
+ const a = await findCommonJunctionPoint(file, realFile);
291
308
  file = a.file;
292
309
  realFile = a.realFile;
293
310
  if (!this.symLinks[file]) {
@@ -337,7 +354,7 @@ class Walker {
337
354
  store: common_1.STORE_STAT,
338
355
  });
339
356
  }
340
- appendBlobOrContent(task) {
357
+ async appendBlobOrContent(task) {
341
358
  if (strictVerify) {
342
359
  (0, assert_1.default)(task.file === (0, common_1.normalizePath)(task.file));
343
360
  }
@@ -360,7 +377,7 @@ class Walker {
360
377
  return;
361
378
  }
362
379
  this.append(Object.assign(Object.assign({}, task), { file: realFile }));
363
- this.appendSymlink(task.file, realFile);
380
+ await this.appendSymlink(task.file, realFile);
364
381
  this.appendStat({
365
382
  file: task.file,
366
383
  store: common_1.STORE_STAT,
@@ -382,7 +399,7 @@ class Walker {
382
399
  script,
383
400
  ]);
384
401
  }
385
- this.appendBlobOrContent({
402
+ await this.appendBlobOrContent({
386
403
  file: (0, common_1.normalizePath)(script),
387
404
  marker,
388
405
  store: common_1.STORE_BLOB,
@@ -398,7 +415,7 @@ class Walker {
398
415
  log_1.log.debug(' Adding asset : .... ', asset);
399
416
  const stat = await promises_1.default.stat(asset);
400
417
  if (stat.isFile()) {
401
- this.appendBlobOrContent({
418
+ await this.appendBlobOrContent({
402
419
  file: (0, common_1.normalizePath)(asset),
403
420
  marker,
404
421
  store: common_1.STORE_CONTENT,
@@ -420,7 +437,7 @@ class Walker {
420
437
  // 2) non-source (non-js) files of top-level package are shipped as CONTENT
421
438
  // 3) parsing some js 'files' of non-top-level packages fails, hence all CONTENT
422
439
  if (marker.toplevel) {
423
- this.appendBlobOrContent({
440
+ await this.appendBlobOrContent({
424
441
  file,
425
442
  marker,
426
443
  store: (0, common_1.isDotJS)(file) ? common_1.STORE_BLOB : common_1.STORE_CONTENT,
@@ -428,7 +445,7 @@ class Walker {
428
445
  });
429
446
  }
430
447
  else {
431
- this.appendBlobOrContent({
448
+ await this.appendBlobOrContent({
432
449
  file,
433
450
  marker,
434
451
  store: common_1.STORE_CONTENT,
@@ -576,7 +593,7 @@ class Walker {
576
593
  ]);
577
594
  }
578
595
  if (stat && stat.isFile()) {
579
- this.appendBlobOrContent({
596
+ await this.appendBlobOrContent({
580
597
  file,
581
598
  marker,
582
599
  store: common_1.STORE_CONTENT,
@@ -662,14 +679,14 @@ class Walker {
662
679
  (0, assert_1.default)(newPackageForNewRecords.packageJson ===
663
680
  (0, common_1.normalizePath)(newPackageForNewRecords.packageJson));
664
681
  }
665
- this.appendBlobOrContent({
682
+ await this.appendBlobOrContent({
666
683
  file: newPackageForNewRecords.packageJson,
667
684
  marker: newPackageForNewRecords.marker,
668
685
  store: common_1.STORE_CONTENT,
669
686
  reason: record.file,
670
687
  });
671
688
  }
672
- this.appendBlobOrContent({
689
+ await this.appendBlobOrContent({
673
690
  file: newFile,
674
691
  marker: newPackageForNewRecords ? newPackageForNewRecords.marker : marker,
675
692
  store: common_1.STORE_BLOB,
@@ -709,7 +726,7 @@ class Walker {
709
726
  await this.stepDerivatives(record, marker, derivatives1);
710
727
  if (store === common_1.STORE_BLOB) {
711
728
  if (unlikelyJavascript(record.file) || (0, common_1.isDotNODE)(record.file)) {
712
- this.appendBlobOrContent({
729
+ await this.appendBlobOrContent({
713
730
  file: record.file,
714
731
  marker,
715
732
  store: common_1.STORE_CONTENT,
@@ -717,7 +734,7 @@ class Walker {
717
734
  return; // discard
718
735
  }
719
736
  if (marker.public || marker.hasDictionary) {
720
- this.appendBlobOrContent({
737
+ await this.appendBlobOrContent({
721
738
  file: record.file,
722
739
  marker,
723
740
  store: common_1.STORE_CONTENT,
@@ -847,14 +864,14 @@ class Walker {
847
864
  this.symLinks = {};
848
865
  await this.readDictionary(marker);
849
866
  entrypoint = (0, common_1.normalizePath)(entrypoint);
850
- this.appendBlobOrContent({
867
+ await this.appendBlobOrContent({
851
868
  file: entrypoint,
852
869
  marker,
853
870
  store: common_1.STORE_BLOB,
854
871
  });
855
872
  if (addition) {
856
873
  addition = (0, common_1.normalizePath)(addition);
857
- this.appendBlobOrContent({
874
+ await this.appendBlobOrContent({
858
875
  file: addition,
859
876
  marker,
860
877
  store: common_1.STORE_CONTENT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yao-pkg/pkg",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "Package your Node.js project into an executable",
5
5
  "main": "lib-es5/index.js",
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  "@babel/generator": "^7.23.0",
26
26
  "@babel/parser": "^7.23.0",
27
27
  "@babel/types": "^7.23.0",
28
- "@yao-pkg/pkg-fetch": "3.5.16",
28
+ "@yao-pkg/pkg-fetch": "3.5.17",
29
29
  "into-stream": "^6.0.0",
30
30
  "minimist": "^1.2.6",
31
31
  "multistream": "^4.1.0",
@@ -60,11 +60,11 @@
60
60
  "eslint-config-prettier": "^9.0.0",
61
61
  "eslint-plugin-import": "^2.28.1",
62
62
  "json-stable-stringify": "^1.0.1",
63
- "lint-staged": "^10.5.4",
63
+ "lint-staged": "^15.2.10",
64
64
  "prettier": "^3.0.3",
65
65
  "release-it": "^16.2.1",
66
66
  "rimraf": "^3.0.2",
67
- "simple-git-hooks": ">=2.8.0",
67
+ "simple-git-hooks": "^2.11.1",
68
68
  "typescript": "^4.7.2"
69
69
  },
70
70
  "scripts": {
@@ -22,7 +22,7 @@ const fs = require('fs');
22
22
  const { isRegExp } = require('util').types;
23
23
  const Module = require('module');
24
24
  const path = require('path');
25
- const { promisify, _extend } = require('util');
25
+ const { promisify } = require('util');
26
26
  const { Script } = require('vm');
27
27
  const { homedir } = require('os');
28
28
  const util = require('util');
@@ -2005,7 +2005,7 @@ function payloadFileSync(pointer) {
2005
2005
  args.splice(pos, 0, {});
2006
2006
  }
2007
2007
  const opts = args[pos];
2008
- if (!opts.env) opts.env = _extend({}, process.env);
2008
+ if (!opts.env) opts.env = { ...process.env };
2009
2009
  // see https://github.com/vercel/pkg/issues/897#issuecomment-1049370335
2010
2010
  if (opts.env.PKG_EXECPATH !== undefined) return;
2011
2011
  opts.env.PKG_EXECPATH = EXECPATH;