electrobun 2.0.2-beta.9 → 2.0.3-beta.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.
@@ -27,7 +27,7 @@ const { homedir, tmpdir } = require("node:os");
27
27
  const path = require("node:path");
28
28
 
29
29
  // Stamped by push-version.js from package/hutch.config.ts.
30
- const PAIRED_HUTCH_VERSION = "0.26.0-canary.6";
30
+ const PAIRED_HUTCH_VERSION = "0.27.1";
31
31
  const ELECTROBUN_VERSION = require("../package.json").version;
32
32
 
33
33
  const MINIMUM_DEFAULTS_HUTCH_VERSION = "0.22.0";
@@ -420,9 +420,10 @@ function validateArchiveEntries(
420
420
  environment,
421
421
  execute = execFileSync,
422
422
  expectedHutchVersion = PAIRED_HUTCH_VERSION,
423
+ hostPlatform = process.platform,
423
424
  tarExecutable,
424
425
  ) {
425
- const tar = tarExecutable ?? tarCommand(platform, environment);
426
+ const tar = tarExecutable ?? tarCommand(hostPlatform, environment);
426
427
  const archiveDirectory = path.dirname(archivePath);
427
428
  const archiveFilename = path.basename(archivePath);
428
429
  // Windows bsdtar can corrupt non-ACP absolute argv paths. Node passes cwd
@@ -539,7 +540,9 @@ function writeCacheManifest(
539
540
  platform,
540
541
  expectedHutchVersion,
541
542
  archive,
543
+ hostPlatform = process.platform,
542
544
  ) {
545
+ const hostSupportsPosixModes = hostPlatform !== "win32";
543
546
  const files = {};
544
547
  for (const [relative, maximum] of cacheMemberLimits(platform)) {
545
548
  const file = path.join(root, ...relative.split("/"));
@@ -551,7 +554,7 @@ function writeCacheManifest(
551
554
  size: stat.size,
552
555
  sha256: sha256File(file),
553
556
  ...(platform !== "win32" && relative.startsWith("bin/")
554
- ? { mode: stat.mode & 0o777 }
557
+ ? { mode: hostSupportsPosixModes ? stat.mode & 0o777 : 0o755 }
555
558
  : {}),
556
559
  };
557
560
  }
@@ -575,8 +578,10 @@ function validateCachedHutch(
575
578
  platform,
576
579
  expectedHutchVersion = PAIRED_HUTCH_VERSION,
577
580
  requireCacheManifest = true,
581
+ hostPlatform = process.platform,
578
582
  ) {
579
583
  try {
584
+ const hostSupportsPosixModes = hostPlatform !== "win32";
580
585
  const members = cacheMemberLimits(platform);
581
586
  const memberPaths = new Map(
582
587
  [...members.keys()].map((relative) => [
@@ -610,7 +615,7 @@ function validateCachedHutch(
610
615
  }
611
616
  if (!requireCacheManifest) return binary;
612
617
 
613
- if (platform !== "win32") {
618
+ if (platform !== "win32" && hostSupportsPosixModes) {
614
619
  for (const executable of [binary, engine]) {
615
620
  try {
616
621
  accessSync(executable, fsConstants.X_OK);
@@ -625,7 +630,7 @@ function validateCachedHutch(
625
630
  !manifestStat.isFile() ||
626
631
  manifestStat.size < 1 ||
627
632
  manifestStat.size > maxReleaseMetadataBytes ||
628
- (platform !== "win32" && (manifestStat.mode & 0o022) !== 0)
633
+ (hostSupportsPosixModes && (manifestStat.mode & 0o022) !== 0)
629
634
  ) {
630
635
  return null;
631
636
  }
@@ -665,8 +670,10 @@ function validateCachedHutch(
665
670
  (Number.isSafeInteger(descriptor.mode) &&
666
671
  descriptor.mode >= 0 &&
667
672
  descriptor.mode <= 0o777 &&
673
+ (descriptor.mode & 0o100) !== 0 &&
668
674
  (descriptor.mode & 0o022) === 0 &&
669
- (stat.mode & 0o777) === descriptor.mode);
675
+ (!hostSupportsPosixModes ||
676
+ (stat.mode & 0o777) === descriptor.mode));
670
677
  if (
671
678
  descriptor.size !== stat.size ||
672
679
  !/^[0-9a-f]{64}$/.test(descriptor.sha256) ||
@@ -682,8 +689,8 @@ function validateCachedHutch(
682
689
  }
683
690
  }
684
691
 
685
- function tarCommand(platform, environment) {
686
- return platform === "win32"
692
+ function tarCommand(hostPlatform, environment) {
693
+ return hostPlatform === "win32"
687
694
  ? path.win32.join(environment.SystemRoot || "C:\\Windows", "System32", "tar.exe")
688
695
  : "tar";
689
696
  }
@@ -958,6 +965,7 @@ function installDownloadedArchive({
958
965
  environment,
959
966
  execute = execFileSync,
960
967
  expectedHutchVersion = PAIRED_HUTCH_VERSION,
968
+ hostPlatform = process.platform,
961
969
  makeLockDirectory = mkdirSync,
962
970
  platform,
963
971
  platformKey,
@@ -980,9 +988,10 @@ function installDownloadedArchive({
980
988
  environment,
981
989
  execute,
982
990
  expectedHutchVersion,
991
+ hostPlatform,
983
992
  tarExecutable,
984
993
  );
985
- execute(tarExecutable ?? tarCommand(platform, environment), ["-xzf", "hutch.tar.gz"], {
994
+ execute(tarExecutable ?? tarCommand(hostPlatform, environment), ["-xzf", "hutch.tar.gz"], {
986
995
  cwd: temporary,
987
996
  stdio: "pipe",
988
997
  });
@@ -993,9 +1002,10 @@ function installDownloadedArchive({
993
1002
  platform,
994
1003
  expectedHutchVersion,
995
1004
  false,
1005
+ hostPlatform,
996
1006
  );
997
1007
  if (!binary) throw new Error("extracted Hutch archive identity is invalid");
998
- if (platform !== "win32") {
1008
+ if (platform !== "win32" && hostPlatform !== "win32") {
999
1009
  chmodSync(binary, 0o755);
1000
1010
  chmodSync(hutchEngineInRoot(extracted, platform), 0o755);
1001
1011
  }
@@ -1005,12 +1015,15 @@ function installDownloadedArchive({
1005
1015
  platform,
1006
1016
  expectedHutchVersion,
1007
1017
  archive,
1018
+ hostPlatform,
1008
1019
  );
1009
1020
  binary = validateCachedHutch(
1010
1021
  extracted,
1011
1022
  platformKey,
1012
1023
  platform,
1013
1024
  expectedHutchVersion,
1025
+ true,
1026
+ hostPlatform,
1014
1027
  );
1015
1028
  if (!binary) throw new Error("sealed Hutch cache is invalid");
1016
1029
 
@@ -1033,6 +1046,8 @@ function installDownloadedArchive({
1033
1046
  platformKey,
1034
1047
  platform,
1035
1048
  expectedHutchVersion,
1049
+ true,
1050
+ hostPlatform,
1036
1051
  );
1037
1052
  if (existing) return existing;
1038
1053
 
@@ -1044,6 +1059,8 @@ function installDownloadedArchive({
1044
1059
  platformKey,
1045
1060
  platform,
1046
1061
  expectedHutchVersion,
1062
+ true,
1063
+ hostPlatform,
1047
1064
  );
1048
1065
  if (beforeQuarantine) return beforeQuarantine;
1049
1066
  const invalidQuarantine = `${root}.invalid-${process.pid}-${randomBytes(8).toString("hex")}`;
@@ -1053,6 +1070,8 @@ function installDownloadedArchive({
1053
1070
  platformKey,
1054
1071
  platform,
1055
1072
  expectedHutchVersion,
1073
+ true,
1074
+ hostPlatform,
1056
1075
  );
1057
1076
  if (validNow) return validNow;
1058
1077
  try {
@@ -1065,6 +1084,8 @@ function installDownloadedArchive({
1065
1084
  platformKey,
1066
1085
  platform,
1067
1086
  expectedHutchVersion,
1087
+ true,
1088
+ hostPlatform,
1068
1089
  );
1069
1090
  if (recovered) return recovered;
1070
1091
  if (error.code === "ENOENT" && !pathEntryExists(root)) break;
@@ -1092,6 +1113,8 @@ function installDownloadedArchive({
1092
1113
  platformKey,
1093
1114
  platform,
1094
1115
  expectedHutchVersion,
1116
+ true,
1117
+ hostPlatform,
1095
1118
  );
1096
1119
  if (raced) break;
1097
1120
  if (
@@ -1121,6 +1144,8 @@ function installDownloadedArchive({
1121
1144
  platformKey,
1122
1145
  platform,
1123
1146
  expectedHutchVersion,
1147
+ true,
1148
+ hostPlatform,
1124
1149
  );
1125
1150
  if (!installed) throw new Error("installed Hutch cache is invalid");
1126
1151
  // From this point the cache is a complete immutable unit. Other resolver
@@ -1235,6 +1260,7 @@ async function resolveHutchBinary(options = {}) {
1235
1260
  const environment = options.environment ?? process.env;
1236
1261
  const platform = options.platform ?? process.platform;
1237
1262
  const arch = options.arch ?? process.arch;
1263
+ const hostPlatform = options.hostPlatform ?? process.platform;
1238
1264
  const userHome = options.userHome ?? homedir();
1239
1265
  const fileExists = options.existsSync ?? existsSync;
1240
1266
  const install = options.installHutch ?? installHutch;
@@ -1243,6 +1269,7 @@ async function resolveHutchBinary(options = {}) {
1243
1269
  ...options,
1244
1270
  environment,
1245
1271
  fileExists,
1272
+ hostPlatform,
1246
1273
  install,
1247
1274
  platform,
1248
1275
  userHome,
@@ -1267,7 +1294,14 @@ async function resolveHutchBinary(options = {}) {
1267
1294
  const root =
1268
1295
  options.cacheRoot ??
1269
1296
  downloadedHutchRoot(environment, platform, userHome, platformKey);
1270
- const cached = validateCachedHutch(root, platformKey, platform);
1297
+ const cached = validateCachedHutch(
1298
+ root,
1299
+ platformKey,
1300
+ platform,
1301
+ PAIRED_HUTCH_VERSION,
1302
+ true,
1303
+ hostPlatform,
1304
+ );
1271
1305
  if (cached) return cached;
1272
1306
 
1273
1307
  if (!environmentFlagEnabled(environment, "DASH_RELEASE_OFFLINE")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "electrobun",
3
- "version": "2.0.2-beta.9",
3
+ "version": "2.0.3-beta.0",
4
4
  "description": "The lightweight npm bootstrap for Electrobun and Hutch.",
5
5
  "license": "MIT",
6
6
  "author": "Blackboard Technologies Inc.",