build-raptor 0.137.0 → 0.139.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.
Files changed (3) hide show
  1. package/build-raptor.js +161 -152
  2. package/index.js +159 -150
  3. package/package.json +3 -3
package/build-raptor.js CHANGED
@@ -3,7 +3,8 @@ var __defProp = Object.defineProperty;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
4
 
5
5
  // modules/build-raptor-core/dist/src/breakdown.js
6
- import * as fse5 from "fs-extra";
6
+ import fs5 from "fs";
7
+ import fse5 from "fs-extra/esm";
7
8
 
8
9
  // modules/misc/dist/src/maps.js
9
10
  function hardGet(map, key) {
@@ -137,13 +138,14 @@ function errorLike(err) {
137
138
  __name(errorLike, "errorLike");
138
139
 
139
140
  // modules/misc/dist/src/directory-scanner.js
140
- import * as fs from "fs";
141
- import * as fse2 from "fs-extra";
141
+ import * as fs2 from "fs";
142
+ import fse2 from "fs-extra/esm";
142
143
  import * as path from "path";
143
144
 
144
145
  // modules/misc/dist/src/misc.js
145
146
  import * as crypto from "crypto";
146
- import * as fse from "fs-extra";
147
+ import fs from "fs";
148
+ import fse from "fs-extra/esm";
147
149
  import jsonStringify from "safe-stable-stringify";
148
150
  import * as util from "util";
149
151
  function computeObjectHash(input) {
@@ -160,7 +162,7 @@ async function dumpFile(inputPath, output) {
160
162
  throw new Error(`Cannot dump non existing file: ${inputPath}`);
161
163
  }
162
164
  return new Promise((res, rej) => {
163
- const inputStream = fse.createReadStream(inputPath);
165
+ const inputStream = fs.createReadStream(inputPath);
164
166
  inputStream.on("end", () => {
165
167
  res();
166
168
  });
@@ -294,9 +296,9 @@ var DirectoryScanner = class _DirectoryScanner {
294
296
  readContent(resolvedPath, stat) {
295
297
  try {
296
298
  if (stat.isSymbolicLink()) {
297
- return Buffer.from(fs.readlinkSync(resolvedPath));
299
+ return Buffer.from(fs2.readlinkSync(resolvedPath));
298
300
  }
299
- return fs.readFileSync(resolvedPath);
301
+ return fs2.readFileSync(resolvedPath);
300
302
  } catch (e) {
301
303
  throw new Error(`failed to read ${stat.isSymbolicLink() ? "symbolic link" : "file"} at ${resolvedPath}: ${e}`);
302
304
  }
@@ -308,7 +310,7 @@ var DirectoryScanner = class _DirectoryScanner {
308
310
  // does the sorting).
309
311
  async readDirSorted(resolvedPath) {
310
312
  try {
311
- const ret = await fse2.readdir(resolvedPath);
313
+ const ret = await fs2.promises.readdir(resolvedPath);
312
314
  ret.sort();
313
315
  return ret;
314
316
  } catch (e) {
@@ -317,7 +319,7 @@ var DirectoryScanner = class _DirectoryScanner {
317
319
  }
318
320
  async getStat(resolvedPath) {
319
321
  try {
320
- return fs.lstatSync(resolvedPath);
322
+ return fs2.lstatSync(resolvedPath);
321
323
  } catch (e) {
322
324
  throw new Error(`Cannot stat ${resolvedPath}: ${e}`);
323
325
  }
@@ -337,8 +339,8 @@ var SinglePublisher = class {
337
339
  this.subscribers.push(subscriber);
338
340
  }
339
341
  async publish(e) {
340
- const promises3 = this.subscribers.map((s) => s(e));
341
- await Promise.all(promises3);
342
+ const promises6 = this.subscribers.map((s) => s(e));
343
+ await Promise.all(promises6);
342
344
  }
343
345
  };
344
346
  var TypedPublisher = class {
@@ -434,11 +436,12 @@ var Executor = class {
434
436
  };
435
437
 
436
438
  // modules/misc/dist/src/file-system-storage-client.js
437
- import * as fse3 from "fs-extra";
439
+ import fs4 from "fs";
440
+ import fse3 from "fs-extra/esm";
438
441
  import * as path3 from "path";
439
442
 
440
443
  // modules/misc/dist/src/clean-directory.js
441
- import * as fs2 from "fs";
444
+ import * as fs3 from "fs";
442
445
  import * as path2 from "path";
443
446
  function cleanDirectory(directoryPath, deletionFactor, triggerCleanupIfByteSizeExceeds) {
444
447
  const size = calculateDirectorySize(directoryPath);
@@ -451,9 +454,9 @@ function cleanDirectory(directoryPath, deletionFactor, triggerCleanupIfByteSizeE
451
454
  __name(cleanDirectory, "cleanDirectory");
452
455
  function calculateDirectorySize(directoryPath) {
453
456
  let ret = 0;
454
- for (const f of fs2.readdirSync(directoryPath)) {
457
+ for (const f of fs3.readdirSync(directoryPath)) {
455
458
  const resolved = path2.join(directoryPath, f);
456
- const stats = fs2.statSync(resolved);
459
+ const stats = fs3.statSync(resolved);
457
460
  ret += stats.size;
458
461
  }
459
462
  return ret;
@@ -462,18 +465,18 @@ __name(calculateDirectorySize, "calculateDirectorySize");
462
465
  function deleteFiles(directoryPath, deletionFactor) {
463
466
  let files;
464
467
  try {
465
- files = fs2.readdirSync(directoryPath);
468
+ files = fs3.readdirSync(directoryPath);
466
469
  } catch (e) {
467
470
  throw new Error(`failed when reading ${directoryPath}: ${e}`);
468
471
  }
469
- const mapped = files.map((f) => ({ f, atime: fs2.statSync(path2.join(directoryPath, f)).atime.toISOString() }));
472
+ const mapped = files.map((f) => ({ f, atime: fs3.statSync(path2.join(directoryPath, f)).atime.toISOString() }));
470
473
  const sorted = sortBy(mapped, (at) => at.atime);
471
474
  const numFilesToDelete = Math.min(sorted.length, Math.floor(sorted.length * deletionFactor));
472
475
  const ret = sorted.slice(0, numFilesToDelete).map((at) => at.f);
473
476
  for (const f of ret) {
474
477
  const filePath = path2.join(directoryPath, f);
475
478
  try {
476
- fs2.unlinkSync(filePath);
479
+ fs3.unlinkSync(filePath);
477
480
  } catch (e) {
478
481
  throw new Error(`cleanup of ${filePath} failed: ${e}`);
479
482
  }
@@ -505,26 +508,26 @@ var FilesystemStorageClient = class _FilesystemStorageClient {
505
508
  return path3.join(this.dir, `${middle}-${s}`);
506
509
  }
507
510
  async putObject(key, content) {
508
- await fse3.writeFile(this.keyToPath(key), content);
511
+ await fs4.promises.writeFile(this.keyToPath(key), content);
509
512
  }
510
513
  async putContentAddressable(content) {
511
514
  const ret = computeHash(content);
512
515
  const p = this.hashToPath("cas", ret);
513
- await fse3.writeFile(p, content);
516
+ await fs4.promises.writeFile(p, content);
514
517
  return ret;
515
518
  }
516
519
  async getContentAddressable(hash) {
517
520
  const p = this.hashToPath("cas", hash);
518
- return await fse3.readFile(p);
521
+ return await fs4.promises.readFile(p);
519
522
  }
520
523
  async getObject(key, type = "string") {
521
524
  const p = this.keyToPath(key);
522
525
  try {
523
526
  if (type === "string") {
524
- return await fse3.readFile(p, "utf-8");
527
+ return await fs4.promises.readFile(p, "utf-8");
525
528
  }
526
529
  if (type === "buffer") {
527
- return await fse3.readFile(p);
530
+ return await fs4.promises.readFile(p);
528
531
  }
529
532
  shouldNeverHappen(type);
530
533
  } catch (e) {
@@ -537,7 +540,7 @@ var FilesystemStorageClient = class _FilesystemStorageClient {
537
540
  };
538
541
 
539
542
  // modules/misc/dist/src/folderify.js
540
- import * as fse4 from "fs-extra";
543
+ import fse4 from "fs-extra/esm";
541
544
  import * as Tmp from "tmp-promise";
542
545
 
543
546
  // modules/misc/dist/src/graph.js
@@ -881,11 +884,11 @@ __name(intify, "intify");
881
884
 
882
885
  // modules/misc/dist/src/promises.js
883
886
  import PQueue2 from "p-queue";
884
- function promises(input) {
887
+ function promises2(input) {
885
888
  const adjusted = new DefaultReifiable(input.map((p) => Promise.resolve(p)));
886
889
  return new PromisesImpl(adjusted, (t) => Promise.resolve(t), () => Promise.resolve(true));
887
890
  }
888
- __name(promises, "promises");
891
+ __name(promises2, "promises");
889
892
  var PromisesImpl = class _PromisesImpl {
890
893
  static {
891
894
  __name(this, "PromisesImpl");
@@ -1141,7 +1144,7 @@ var Breakdown = class {
1141
1144
  if (!outputFile) {
1142
1145
  return [];
1143
1146
  }
1144
- const content = await fse5.readFile(outputFile, "utf8");
1147
+ const content = await fs5.promises.readFile(outputFile, "utf8");
1145
1148
  const trimmed = content.trim();
1146
1149
  return format3 === "string" ? trimmed : trimmed.split("\n");
1147
1150
  }
@@ -1158,7 +1161,7 @@ var Breakdown = class {
1158
1161
  if (!await fse5.pathExists(resolved)) {
1159
1162
  return void 0;
1160
1163
  }
1161
- const content = await fse5.readFile(resolved, "utf8");
1164
+ const content = await fs5.promises.readFile(resolved, "utf8");
1162
1165
  return content.trim().split("\n");
1163
1166
  }
1164
1167
  };
@@ -1215,11 +1218,11 @@ function BuildRunId(input) {
1215
1218
  __name(BuildRunId, "BuildRunId");
1216
1219
 
1217
1220
  // modules/build-raptor-core/dist/src/engine-bootstrapper.js
1218
- import * as fs9 from "fs";
1221
+ import * as fs14 from "fs";
1219
1222
  import * as JsoncParser from "jsonc-parser";
1220
1223
 
1221
1224
  // modules/logger/dist/src/logger.js
1222
- import * as fs3 from "fs";
1225
+ import * as fs6 from "fs";
1223
1226
  import { format } from "logform";
1224
1227
  import * as path6 from "path";
1225
1228
  import jsonStringify2 from "safe-stable-stringify";
@@ -1230,9 +1233,9 @@ var criticalityLegend = {
1230
1233
  low: 200
1231
1234
  };
1232
1235
  function createDefaultLogger(logFile, pickiness, logLevel, uiStream) {
1233
- const stat = fs3.statSync(logFile, { throwIfNoEntry: false });
1236
+ const stat = fs6.statSync(logFile, { throwIfNoEntry: false });
1234
1237
  if (stat && stat.size > 0) {
1235
- fs3.rmSync(logFile, { force: true });
1238
+ fs6.rmSync(logFile, { force: true });
1236
1239
  }
1237
1240
  return new FileLogger(logFile, pickiness, logLevel, uiStream);
1238
1241
  }
@@ -1325,13 +1328,13 @@ import { z as z7 } from "zod";
1325
1328
 
1326
1329
  // modules/build-raptor-core/dist/src/engine.js
1327
1330
  import child_process from "child_process";
1328
- import * as fs5 from "fs";
1329
- import * as fse10 from "fs-extra";
1331
+ import * as fs10 from "fs";
1332
+ import fse8 from "fs-extra/esm";
1330
1333
  import ignore from "ignore";
1331
1334
  import * as path10 from "path";
1332
1335
 
1333
1336
  // modules/build-raptor-core/dist/src/fingerprint-ledger.js
1334
- import * as fse6 from "fs-extra";
1337
+ import fse6 from "fs-extra/esm";
1335
1338
  import { z as z2 } from "zod";
1336
1339
  var LedgerItem = z2.union([
1337
1340
  z2.object({
@@ -1460,8 +1463,7 @@ var PersistedFingerprintLedger = class {
1460
1463
  var TRUNCATION_THRESHOLD = 200 * 1e3 * 1e3;
1461
1464
 
1462
1465
  // modules/build-raptor-core/dist/src/fingerprinter.js
1463
- import * as fs4 from "fs";
1464
- import * as fse7 from "fs-extra";
1466
+ import * as fs7 from "fs";
1465
1467
  import * as path7 from "path";
1466
1468
 
1467
1469
  // modules/build-raptor-core/dist/src/hasher.js
@@ -1565,7 +1567,7 @@ var Fingerprinter = class {
1565
1567
  const respectGitIgnore = this.dirScanner.isValid(pathInRepo, stat);
1566
1568
  const active = this.dirScanner.isValid(pathInRepo, stat);
1567
1569
  if (!stat.isDirectory()) {
1568
- const content = await readFile4(resolved);
1570
+ const content = await readFile(resolved);
1569
1571
  const hasher2 = new Hasher(pathInRepo, this.seed);
1570
1572
  hasher2.update(content);
1571
1573
  return await this.store(hasher2, active, content.toString("utf-8"));
@@ -1593,17 +1595,17 @@ var Fingerprinter = class {
1593
1595
  return { hasher, active };
1594
1596
  }
1595
1597
  };
1596
- async function readFile4(p) {
1598
+ async function readFile(p) {
1597
1599
  try {
1598
- return await fse7.readFile(p);
1600
+ return await fs7.promises.readFile(p);
1599
1601
  } catch (e) {
1600
1602
  throw new Error(`Failed to read ${p}: ${e}`);
1601
1603
  }
1602
1604
  }
1603
- __name(readFile4, "readFile");
1605
+ __name(readFile, "readFile");
1604
1606
  function statPath(p) {
1605
1607
  try {
1606
- return fs4.statSync(p, { throwIfNoEntry: false });
1608
+ return fs7.statSync(p, { throwIfNoEntry: false });
1607
1609
  } catch (e) {
1608
1610
  throw new Error(`Failed to stat ${p}: ${e}`);
1609
1611
  }
@@ -1611,7 +1613,7 @@ function statPath(p) {
1611
1613
  __name(statPath, "statPath");
1612
1614
  async function readDir(p) {
1613
1615
  try {
1614
- return await fse7.readdir(p, { withFileTypes: true });
1616
+ return await fs7.promises.readdir(p, { withFileTypes: true });
1615
1617
  } catch (e) {
1616
1618
  throw new Error(`Failed to read dir ${p}: ${e}`);
1617
1619
  }
@@ -1942,7 +1944,7 @@ var Planner = class {
1942
1944
  };
1943
1945
 
1944
1946
  // modules/build-raptor-core/dist/src/purger.js
1945
- import * as fse8 from "fs-extra";
1947
+ import fs8 from "fs";
1946
1948
  var Purger = class {
1947
1949
  static {
1948
1950
  __name(this, "Purger");
@@ -1952,10 +1954,10 @@ var Purger = class {
1952
1954
  this.repoRootDir = repoRootDir;
1953
1955
  }
1954
1956
  async removeLocations(outputLocations) {
1955
- await promises(outputLocations).forEach(20, async (p) => {
1957
+ await promises2(outputLocations).forEach(20, async (p) => {
1956
1958
  const resolved = this.repoRootDir.resolve(p);
1957
1959
  this.logger.info(`purging ${resolved}`);
1958
- await fse8.rm(resolved, { recursive: true, force: true });
1960
+ await fs8.promises.rm(resolved, { recursive: true, force: true });
1959
1961
  });
1960
1962
  }
1961
1963
  async purgeOutputsOfTask(task) {
@@ -1974,7 +1976,8 @@ function shouldPurge(loc) {
1974
1976
  __name(shouldPurge, "shouldPurge");
1975
1977
 
1976
1978
  // modules/build-raptor-core/dist/src/task-executor.js
1977
- import * as fse9 from "fs-extra";
1979
+ import fs9 from "fs";
1980
+ import fse7 from "fs-extra/esm";
1978
1981
  import * as path9 from "path";
1979
1982
  var TaskExecutor = class {
1980
1983
  static {
@@ -2052,7 +2055,7 @@ var SingleTaskExecutor = class {
2052
2055
  }
2053
2056
  async postProcess(status, outputFile, time) {
2054
2057
  if (this.shouldDiagnose) {
2055
- const content = fse9.readFileSync(outputFile, "utf-8");
2058
+ const content = fs9.readFileSync(outputFile, "utf-8");
2056
2059
  this.diagnose(`content of ${outputFile} is ${content}`);
2057
2060
  }
2058
2061
  await this.eventPublisher.publish("executionEnded", {
@@ -2085,9 +2088,9 @@ var SingleTaskExecutor = class {
2085
2088
  }
2086
2089
  async validateOutputs() {
2087
2090
  const t = this.task;
2088
- const missing = await promises(t.outputLocations).filter(async (loc) => {
2091
+ const missing = await promises2(t.outputLocations).filter(async (loc) => {
2089
2092
  const resolved = this.model.rootDir.resolve(loc.pathInRepo);
2090
- const exists = await fse9.pathExists(resolved);
2093
+ const exists = await fse7.pathExists(resolved);
2091
2094
  return !exists;
2092
2095
  }).reify(100);
2093
2096
  if (!missing.length) {
@@ -2242,7 +2245,7 @@ ${formatted}`);
2242
2245
  this.diagnose(`purging outputs`);
2243
2246
  const taskNames = [this.taskName];
2244
2247
  const tasks = taskNames.map((tn) => this.tracker.getTask(tn));
2245
- await promises(tasks).forEach(20, async (task) => {
2248
+ await promises2(tasks).forEach(20, async (task) => {
2246
2249
  await this.purger.purgeOutputsOfTask(task);
2247
2250
  });
2248
2251
  }
@@ -2443,7 +2446,7 @@ var Engine = class {
2443
2446
  }
2444
2447
  async run(buildRunId) {
2445
2448
  this.steps.transmit({ step: "BUILD_RUN_STARTED", buildRunId, commitHash: this.options.commitHash });
2446
- fs5.writeFileSync(path10.join(this.options.buildRaptorDir, "build-run-id"), buildRunId);
2449
+ fs10.writeFileSync(path10.join(this.options.buildRaptorDir, "build-run-id"), buildRunId);
2447
2450
  await this.fingerprintLedger.updateRun(buildRunId);
2448
2451
  await this.repoProtocol.initialize(this.rootDir, this.eventPublisher, this.options.config.outDirName, this.options.config.repoProtocol);
2449
2452
  try {
@@ -2531,8 +2534,8 @@ ${JSON.stringify(taskList, null, 2)}`);
2531
2534
  async loadModel(buildRunId) {
2532
2535
  const gitIgnorePath = this.rootDir.resolve(PathInRepo(".gitignore"));
2533
2536
  const ig = ignore();
2534
- if (await fse10.pathExists(gitIgnorePath)) {
2535
- const gitIgnoreContent = await fse10.readFile(gitIgnorePath, "utf8");
2537
+ if (await fse8.pathExists(gitIgnorePath)) {
2538
+ const gitIgnoreContent = await fs10.promises.readFile(gitIgnorePath, "utf8");
2536
2539
  const lines = gitIgnoreContent.split("\n");
2537
2540
  this.logger.info(`Found a .gitignore file:
2538
2541
  ${JSON.stringify(lines, null, 2)}`);
@@ -2880,7 +2883,7 @@ var Step = z4.discriminatedUnion("step", [
2880
2883
  var StepByStep = Step.array();
2881
2884
 
2882
2885
  // modules/build-raptor-core/dist/src/step-by-step-transmitter.js
2883
- import * as fs6 from "fs";
2886
+ import * as fs11 from "fs";
2884
2887
  import * as util2 from "util";
2885
2888
  var StepByStepTransmitter = class {
2886
2889
  static {
@@ -2912,7 +2915,7 @@ var StepByStepTransmitter = class {
2912
2915
  return;
2913
2916
  }
2914
2917
  const parsed = StepByStep.parse(this.steps);
2915
- fs6.writeFileSync(this.stepByStepFile, JSON.stringify(parsed));
2918
+ fs11.writeFileSync(this.stepByStepFile, JSON.stringify(parsed));
2916
2919
  this.logger.info(`step by step written to ${this.stepByStepFile}`);
2917
2920
  }
2918
2921
  async dynamicallyLoadProcessor(stepByStepProcessorModuleName, lookFor = "processor") {
@@ -2928,9 +2931,9 @@ var StepByStepTransmitter = class {
2928
2931
  };
2929
2932
 
2930
2933
  // modules/build-raptor-core/dist/src/task-store.js
2931
- import * as fs8 from "fs";
2934
+ import * as fs13 from "fs";
2932
2935
  import { createWriteStream } from "fs";
2933
- import * as fse11 from "fs-extra";
2936
+ import fse9 from "fs-extra/esm";
2934
2937
  import * as path12 from "path";
2935
2938
  import * as stream from "stream";
2936
2939
  import * as Tmp2 from "tmp-promise";
@@ -2939,7 +2942,7 @@ import * as zlib from "zlib";
2939
2942
  import { z as z6 } from "zod";
2940
2943
 
2941
2944
  // modules/build-raptor-core/dist/src/tar-stream.js
2942
- import * as fs7 from "fs";
2945
+ import * as fs12 from "fs";
2943
2946
  import * as path11 from "path";
2944
2947
  import { z as z5 } from "zod";
2945
2948
  var Info = z5.object({
@@ -3046,7 +3049,7 @@ var TarStream = class _TarStream {
3046
3049
  const resolved = resolve2(parsedInfo);
3047
3050
  const date = new Date(Number(parsedInfo.mtime));
3048
3051
  try {
3049
- fs7.utimesSync(resolved, date, date);
3052
+ fs12.utimesSync(resolved, date, date);
3050
3053
  } catch (e) {
3051
3054
  logger.error(`utimeSync failure: ${JSON.stringify({ resolved, date, parsedInfo })}`, e);
3052
3055
  throw new Error(`could not update time of ${resolved} to ${date.toISOString()}: ${e}`);
@@ -3075,19 +3078,19 @@ var TarStream = class _TarStream {
3075
3078
  source.copy(contentBuf, 0, offset, contentEndOffset);
3076
3079
  offset = contentEndOffset;
3077
3080
  const resolved = resolve2(parsedInfo);
3078
- fs7.mkdirSync(path11.dirname(resolved), { recursive: true });
3081
+ fs12.mkdirSync(path11.dirname(resolved), { recursive: true });
3079
3082
  if (parsedInfo.isSymlink) {
3080
3083
  symlinks.push({ info: parsedInfo, content: contentBuf });
3081
3084
  } else {
3082
- fs7.writeFileSync(resolved, contentBuf, { mode: parsedInfo.mode });
3085
+ fs12.writeFileSync(resolved, contentBuf, { mode: parsedInfo.mode });
3083
3086
  updateStats(parsedInfo);
3084
3087
  }
3085
3088
  }
3086
3089
  for (const { info, content } of symlinks) {
3087
3090
  const resolved = resolve2(info);
3088
- fs7.mkdirSync(path11.dirname(resolved), { recursive: true });
3091
+ fs12.mkdirSync(path11.dirname(resolved), { recursive: true });
3089
3092
  const linkTarget = content.toString("utf-8");
3090
- fs7.symlinkSync(linkTarget, resolved);
3093
+ fs12.symlinkSync(linkTarget, resolved);
3091
3094
  if (!path11.isAbsolute(linkTarget)) {
3092
3095
  updateStats(info);
3093
3096
  }
@@ -3189,13 +3192,13 @@ var TaskStore = class {
3189
3192
  return { buffer: emptyBuffer(), publicFiles: {} };
3190
3193
  }
3191
3194
  this.trace?.push(`bundling ${JSON.stringify(outputs)}`);
3192
- const pairs = await promises(outputs.filter((o) => o.isPublic)).map(async (o) => {
3195
+ const pairs = await promises2(outputs.filter((o) => o.isPublic)).map(async (o) => {
3193
3196
  const resolved = this.repoRootDir.resolve(o.pathInRepo);
3194
- const stat = fs8.statSync(resolved);
3197
+ const stat = fs13.statSync(resolved);
3195
3198
  if (!stat.isFile()) {
3196
3199
  throw new BuildFailedError(`cannot publish an output location that is not a file: "${o.pathInRepo.val}"`);
3197
3200
  }
3198
- const content = fs8.readFileSync(resolved);
3201
+ const content = fs13.readFileSync(resolved);
3199
3202
  const h = await this.client.putContentAddressable(content);
3200
3203
  return [o.pathInRepo.val, h];
3201
3204
  }).reify(STORAGE_CONCURRENCY);
@@ -3211,7 +3214,7 @@ var TaskStore = class {
3211
3214
  const scanner = new DirectoryScanner(this.repoRootDir.resolve());
3212
3215
  for (const curr of outputs.filter((o) => !o.isPublic)) {
3213
3216
  const o = curr.pathInRepo;
3214
- const exists = await fse11.pathExists(this.repoRootDir.resolve(o));
3217
+ const exists = await fse9.pathExists(this.repoRootDir.resolve(o));
3215
3218
  if (!exists) {
3216
3219
  throw new Error(`Output location <${o}> does not exist (under <${this.repoRootDir}>)`);
3217
3220
  }
@@ -3223,7 +3226,7 @@ var TaskStore = class {
3223
3226
  throw new Error(`Cannot handle non-files in output: ${p} (under ${this.repoRootDir})`);
3224
3227
  }
3225
3228
  const resolved = this.repoRootDir.resolve(PathInRepo(p));
3226
- const { mtime, atime, ctime } = fs8.statSync(resolved);
3229
+ const { mtime, atime, ctime } = fs13.statSync(resolved);
3227
3230
  this.trace?.push(`adding an entry: ${stat.mode.toString(8)} ${p} ${mtime.toISOString()}`);
3228
3231
  if (stat.isSymbolicLink()) {
3229
3232
  const linkTarget = content.toString("utf-8");
@@ -3241,7 +3244,7 @@ var TaskStore = class {
3241
3244
  const gzip = zlib.createGzip();
3242
3245
  const destination = createWriteStream(tempFile.path);
3243
3246
  await pipeline2(source, gzip, destination);
3244
- const gzipped = await fse11.readFile(tempFile.path);
3247
+ const gzipped = await fs13.promises.readFile(tempFile.path);
3245
3248
  this.trace?.push(`gzipped is ${gzipped.length} long`);
3246
3249
  const ret = Buffer.concat([lenBuf, metadataBuf, gzipped]);
3247
3250
  this.trace?.push(`bundling digest of ret is ${computeObjectHash({ data: ret.toString("hex") })}`);
@@ -3255,8 +3258,8 @@ var TaskStore = class {
3255
3258
  const unparsed = JSON.parse(buf.slice(LEN_BUF_SIZE, LEN_BUF_SIZE + metadataLen).toString("utf-8"));
3256
3259
  const metadata = Metadata.parse(unparsed);
3257
3260
  const outputs = metadata.outputs.map((at) => PathInRepo(at));
3258
- const removeOutputDir = /* @__PURE__ */ __name(async (o) => await fse11.rm(this.repoRootDir.resolve(o), { recursive: true, force: true }), "removeOutputDir");
3259
- await promises(outputs).map(async (o) => await removeOutputDir(o)).reify(20);
3261
+ const removeOutputDir = /* @__PURE__ */ __name(async (o) => await fs13.promises.rm(this.repoRootDir.resolve(o), { recursive: true, force: true }), "removeOutputDir");
3262
+ await promises2(outputs).map(async (o) => await removeOutputDir(o)).reify(20);
3260
3263
  const source = buf.slice(LEN_BUF_SIZE + metadataLen);
3261
3264
  const unzipped = await unzip2(source);
3262
3265
  try {
@@ -3264,7 +3267,7 @@ var TaskStore = class {
3264
3267
  } catch (e) {
3265
3268
  throw new Error(`unbundling a buffer (${buf.length} bytes) has failed: ${e}`);
3266
3269
  }
3267
- await promises(Object.keys(metadata.publicFiles)).forEach(STORAGE_CONCURRENCY, async (pir) => {
3270
+ await promises2(Object.keys(metadata.publicFiles)).forEach(STORAGE_CONCURRENCY, async (pir) => {
3268
3271
  const pathInRepo = PathInRepo(pir);
3269
3272
  const resolved = this.repoRootDir.resolve(pathInRepo);
3270
3273
  const hash = metadata.publicFiles[pathInRepo.val];
@@ -3272,7 +3275,7 @@ var TaskStore = class {
3272
3275
  throw new Error(`hash not found for "${pathInRepo}"`);
3273
3276
  }
3274
3277
  const buf2 = await this.client.getContentAddressable(hash);
3275
- fs8.writeFileSync(resolved, buf2);
3278
+ fs13.writeFileSync(resolved, buf2);
3276
3279
  });
3277
3280
  return { files: outputs, publicFiles: metadata.publicFiles };
3278
3281
  }
@@ -3372,7 +3375,7 @@ var EngineBootstrapper = class _EngineBootstrapper {
3372
3375
  }
3373
3376
  resolveConfigFile() {
3374
3377
  const arr = _EngineBootstrapper.CONFIG_FILES.map((at) => PathInRepo(at));
3375
- const existings = arr.flatMap((at) => fs9.existsSync(this.rootDir.resolve(at)) ? [at] : []);
3378
+ const existings = arr.flatMap((at) => fs14.existsSync(this.rootDir.resolve(at)) ? [at] : []);
3376
3379
  if (existings.length > 1) {
3377
3380
  const quoted = existings.map((at) => `"${at}"`);
3378
3381
  throw new Error(`Found competing config files: ${quoted.join(", ")}. To avoid confusion, you must keep just one.`);
@@ -3385,10 +3388,10 @@ var EngineBootstrapper = class _EngineBootstrapper {
3385
3388
  }
3386
3389
  const p = this.rootDir.resolve(pathToConfigFile);
3387
3390
  try {
3388
- if (!fs9.existsSync(p)) {
3391
+ if (!fs14.existsSync(p)) {
3389
3392
  return BuildRaptorConfig.parse({});
3390
3393
  }
3391
- const content = fs9.readFileSync(p, "utf-8");
3394
+ const content = fs14.readFileSync(p, "utf-8");
3392
3395
  const errors = [];
3393
3396
  const parsed = JsoncParser.parse(content, errors, { allowTrailingComma: true, allowEmptyContent: true });
3394
3397
  const e = errors.at(0);
@@ -3483,14 +3486,14 @@ function summarizeTask(t) {
3483
3486
  __name(summarizeTask, "summarizeTask");
3484
3487
 
3485
3488
  // modules/build-raptor-core/dist/src/find-repo-dir.js
3486
- import fs10 from "fs";
3489
+ import fs15 from "fs";
3487
3490
  import path14 from "path";
3488
3491
  function findRepoDir(dir3) {
3489
3492
  while (true) {
3490
3493
  const pj = path14.join(dir3, "package.json");
3491
- const ex = fs10.existsSync(pj);
3494
+ const ex = fs15.existsSync(pj);
3492
3495
  if (ex) {
3493
- const content = JSON.parse(fs10.readFileSync(pj, "utf-8"));
3496
+ const content = JSON.parse(fs15.readFileSync(pj, "utf-8"));
3494
3497
  const keys = Object.keys(content);
3495
3498
  if (keys.includes("workspaces")) {
3496
3499
  return dir3;
@@ -3506,8 +3509,8 @@ function findRepoDir(dir3) {
3506
3509
  __name(findRepoDir, "findRepoDir");
3507
3510
 
3508
3511
  // modules/build-raptor/dist/src/build-raptor-cli.js
3509
- import fs12 from "fs";
3510
- import * as fse13 from "fs-extra";
3512
+ import fs17 from "fs";
3513
+ import fse11 from "fs-extra/esm";
3511
3514
  import * as os from "os";
3512
3515
  import * as path16 from "path";
3513
3516
 
@@ -3657,8 +3660,8 @@ import { hideBin } from "yargs/helpers";
3657
3660
  // modules/yarn-repo-protocol/dist/src/yarn-repo-protocol.js
3658
3661
  import escapeStringRegexp from "escape-string-regexp";
3659
3662
  import execa from "execa";
3660
- import * as fs11 from "fs";
3661
- import * as fse12 from "fs-extra";
3663
+ import fs16 from "fs";
3664
+ import fse10 from "fs-extra/esm";
3662
3665
  import * as path15 from "path";
3663
3666
 
3664
3667
  // modules/reporter-output/dist/src/reporter-output.js
@@ -3879,23 +3882,23 @@ ${formattedIssues.join("\n")}`);
3879
3882
  async generateSymlinksToPackages(rootDir, units) {
3880
3883
  const nodeModules = PathInRepo("node_modules");
3881
3884
  const nodeModulesLoc = rootDir.resolve(nodeModules);
3882
- await fse12.mkdirp(rootDir.resolve(nodeModules));
3885
+ await fse10.mkdirp(rootDir.resolve(nodeModules));
3883
3886
  for (const u of units) {
3884
3887
  const link = nodeModules.expand(u.id);
3885
3888
  const linkLoc = rootDir.resolve(link);
3886
- const exists = await fse12.pathExists(linkLoc);
3889
+ const exists = await fse10.pathExists(linkLoc);
3887
3890
  if (exists) {
3888
3891
  continue;
3889
3892
  }
3890
3893
  const packageLoc = rootDir.resolve(u.pathInRepo);
3891
3894
  const packageFromNodeModules = path15.relative(nodeModulesLoc, packageLoc);
3892
- await fse12.symlink(packageFromNodeModules, linkLoc);
3895
+ await fs16.promises.symlink(packageFromNodeModules, linkLoc);
3893
3896
  }
3894
3897
  }
3895
3898
  async generateTsConfigFiles(rootDir, units, graph) {
3896
3899
  const rootBase = rootDir.resolve(PathInRepo(this.tsconfigBaseName));
3897
- const rootBaseExists = await fse12.pathExists(rootBase);
3898
- const rootBaseContent = rootBaseExists ? await fse12.readJSON(rootBase) : {};
3900
+ const rootBaseExists = await fse10.pathExists(rootBase);
3901
+ const rootBaseContent = rootBaseExists ? await fse10.readJSON(rootBase) : {};
3899
3902
  const defaultOptions = {
3900
3903
  module: "CommonJS",
3901
3904
  inlineSourceMap: true,
@@ -3913,8 +3916,8 @@ ${formattedIssues.join("\n")}`);
3913
3916
  for (const u of units) {
3914
3917
  const deps = graph.neighborsOf(u.id);
3915
3918
  const localBase = rootDir.resolve(u.pathInRepo.expand(this.tsconfigBaseName));
3916
- const localBaseExists = await fse12.pathExists(localBase);
3917
- const localBaseContent = localBaseExists ? await fse12.readJSON(localBase) : {};
3919
+ const localBaseExists = await fse10.pathExists(localBase);
3920
+ const localBaseContent = localBaseExists ? await fse10.readJSON(localBase) : {};
3918
3921
  const additions = [...localBaseContent.include ?? [], ...rootBaseContent.include ?? []];
3919
3922
  const tsconf = {
3920
3923
  ...localBaseExists ? { extends: `./${this.tsconfigBaseName}` } : rootBaseExists ? { extends: path15.relative(u.pathInRepo.val, this.tsconfigBaseName) } : {},
@@ -3942,15 +3945,15 @@ ${formattedIssues.join("\n")}`);
3942
3945
  }
3943
3946
  const content = JSON.stringify(tsconf, null, 2);
3944
3947
  const p = rootDir.resolve(u.pathInRepo.expand("tsconfig.json"));
3945
- if (await fse12.pathExists(p)) {
3946
- const existing = JSON.stringify(await fse12.readJSON(p, "utf-8"), null, 2);
3948
+ if (await fse10.pathExists(p)) {
3949
+ const existing = JSON.stringify(await fse10.readJSON(p, "utf-8"), null, 2);
3947
3950
  if (existing.trim() === content.trim()) {
3948
3951
  this.logger.info(`skipping generation of tsconfig.json in ${u.id} - no changes`);
3949
3952
  continue;
3950
3953
  }
3951
3954
  }
3952
3955
  this.logger.info(`updating the tsconfig.json file of ${u.id}`);
3953
- await fse12.writeFile(p, content);
3956
+ await fs16.promises.writeFile(p, content);
3954
3957
  }
3955
3958
  }
3956
3959
  async close() {
@@ -3958,9 +3961,15 @@ ${formattedIssues.join("\n")}`);
3958
3961
  async run(cmd, args, dir3, outputFile, additionalEnvVars = {}) {
3959
3962
  const summary = `<${dir3}$ ${cmd} ${args.join(" ")}>`;
3960
3963
  this.logger.info(`Dispatching ${summary}. output: ${outputFile}`);
3961
- const out = await fse12.open(outputFile, "w");
3964
+ const out = await fs16.promises.open(outputFile, "w");
3962
3965
  try {
3963
- const p = await execa(cmd, args, { cwd: dir3, stdout: out, stderr: out, reject: false, env: additionalEnvVars });
3966
+ const p = await execa(cmd, args, {
3967
+ cwd: dir3,
3968
+ stdout: out.fd,
3969
+ stderr: out.fd,
3970
+ reject: false,
3971
+ env: additionalEnvVars
3972
+ });
3964
3973
  this.logger.info(`exitCode of ${cmd} ${args.join(" ")} is ${p.exitCode}`);
3965
3974
  if (p.exitCode === 0) {
3966
3975
  return "OK";
@@ -3970,7 +3979,7 @@ ${formattedIssues.join("\n")}`);
3970
3979
  this.logger.error(`execution of ${summary} failed`, e);
3971
3980
  return "CRASH";
3972
3981
  } finally {
3973
- await fse12.close(out);
3982
+ await out.close();
3974
3983
  }
3975
3984
  }
3976
3985
  // TODO(imaman): this should be retired. custom build tasks should be used instead.
@@ -3984,8 +3993,8 @@ ${formattedIssues.join("\n")}`);
3984
3993
  }
3985
3994
  const tempFile = await getTempFile();
3986
3995
  const ret = await this.run("npm", ["run", this.scriptNames.postBuild], dir3, tempFile);
3987
- const toAppend = await fse12.readFile(tempFile);
3988
- await fse12.appendFile(outputFile, toAppend);
3996
+ const toAppend = await fs16.promises.readFile(tempFile);
3997
+ await fs16.promises.appendFile(outputFile, toAppend);
3989
3998
  return ret;
3990
3999
  }
3991
4000
  async checkBuiltFiles(dir3) {
@@ -3994,7 +4003,7 @@ ${formattedIssues.join("\n")}`);
3994
4003
  const inputDir = path15.join(dir3, codeDir);
3995
4004
  const paths = await DirectoryScanner.listPaths(inputDir, { startingPointMustExist: false });
3996
4005
  for (const p of paths) {
3997
- inputFiles.set(p, fs11.statSync(path15.join(inputDir, p)).mode);
4006
+ inputFiles.set(p, fs16.statSync(path15.join(inputDir, p)).mode);
3998
4007
  }
3999
4008
  const d = path15.join(dir3, `${this.dist()}/${codeDir}`);
4000
4009
  const distFiles = await DirectoryScanner.listPaths(d, { startingPointMustExist: false });
@@ -4020,9 +4029,9 @@ ${formattedIssues.join("\n")}`);
4020
4029
  const resolved = path15.join(d, f);
4021
4030
  if (orig === void 0) {
4022
4031
  this.logger.info(`deleting unmatched dist file: ${f}`);
4023
- fs11.rmSync(resolved);
4032
+ fs16.rmSync(resolved);
4024
4033
  } else {
4025
- fs11.chmodSync(resolved, orig);
4034
+ fs16.chmodSync(resolved, orig);
4026
4035
  }
4027
4036
  }
4028
4037
  }
@@ -4042,7 +4051,7 @@ ${formattedIssues.join("\n")}`);
4042
4051
  throw new Error(`cannot execute ${taskName} when its feature toggle is set to ${ft}`);
4043
4052
  }, "off"),
4044
4053
  dormant: /* @__PURE__ */ __name(async () => {
4045
- fs11.writeFileSync(outputFile, "");
4054
+ fs16.writeFileSync(outputFile, "");
4046
4055
  const ret = "OK";
4047
4056
  return ret;
4048
4057
  }, "dormant"),
@@ -4077,17 +4086,17 @@ ${formattedIssues.join("\n")}`);
4077
4086
  const hasSpecFiles = await this.hasSpecFiles(testsDir);
4078
4087
  if (!hasSpecFiles) {
4079
4088
  this.logger.info(`No *.spec.ts files found in ${testsDir}, skipping test execution`);
4080
- await fs11.promises.writeFile(outputFile, `No test files found in ${testsDir}
4089
+ await fs16.promises.writeFile(outputFile, `No test files found in ${testsDir}
4081
4090
  `);
4082
4091
  const dirInRepo = this.state.rootDir.unresolve(dir3);
4083
4092
  const resolvedSummaryFile = this.state.rootDir.resolve(dirInRepo.expand(this.testRunSummaryFile));
4084
- fs11.writeFileSync(resolvedSummaryFile, JSON.stringify({}));
4093
+ fs16.writeFileSync(resolvedSummaryFile, JSON.stringify({}));
4085
4094
  const jof = path15.join(dir3, JEST_OUTPUT_FILE);
4086
- fs11.writeFileSync(jof, JSON.stringify([]));
4095
+ fs16.writeFileSync(jof, JSON.stringify([]));
4087
4096
  const tempFile2 = await getTempFile();
4088
4097
  const validateResult2 = await this.runValidate(u, dir3, tempFile2);
4089
- const toAppend2 = await fse12.readFile(tempFile2);
4090
- await fse12.appendFile(outputFile, toAppend2);
4098
+ const toAppend2 = await fs16.promises.readFile(tempFile2);
4099
+ await fs16.promises.appendFile(outputFile, toAppend2);
4091
4100
  return validateResult2;
4092
4101
  }
4093
4102
  const tempFile = await getTempFile();
@@ -4096,8 +4105,8 @@ ${formattedIssues.join("\n")}`);
4096
4105
  testCommand ? this.runCustomTest(u.id, dir3, taskName, outputFile) : this.runJest(dir3, taskName, outputFile),
4097
4106
  this.runValidate(u, dir3, tempFile)
4098
4107
  ]);
4099
- const toAppend = await fse12.readFile(tempFile);
4100
- await fse12.appendFile(outputFile, toAppend);
4108
+ const toAppend = await fs16.promises.readFile(tempFile);
4109
+ await fs16.promises.appendFile(outputFile, toAppend);
4101
4110
  return switchOn(testResult, {
4102
4111
  CRASH: /* @__PURE__ */ __name(() => testResult, "CRASH"),
4103
4112
  FAIL: /* @__PURE__ */ __name(() => testResult, "FAIL"),
@@ -4106,22 +4115,22 @@ ${formattedIssues.join("\n")}`);
4106
4115
  }
4107
4116
  if (taskKind === "pack") {
4108
4117
  const ret = await this.pack(u, dir3);
4109
- await fse12.writeFile(outputFile, "");
4118
+ await fs16.promises.writeFile(outputFile, "");
4110
4119
  return ret;
4111
4120
  }
4112
4121
  if (taskKind === "publish-assets") {
4113
4122
  const scriptName = this.scriptNames.prepareAssets;
4114
4123
  const fullPath = path15.join(dir3, PREPARED_ASSETS_DIR);
4115
- await fse12.rm(fullPath, { force: true, recursive: true });
4116
- await fse12.mkdirp(fullPath);
4124
+ await fs16.promises.rm(fullPath, { force: true, recursive: true });
4125
+ await fse10.mkdirp(fullPath);
4117
4126
  const ret = await this.run("npm", ["run", scriptName], dir3, outputFile);
4118
- const exists = await fse12.pathExists(fullPath);
4127
+ const exists = await fse10.pathExists(fullPath);
4119
4128
  if (!exists) {
4120
4129
  throw new BuildFailedError(`Output file ${path15.basename(fullPath)} was not created by the ${scriptName} run script in ${dir3}`);
4121
4130
  }
4122
- const files = await fse12.readdir(fullPath);
4131
+ const files = await fs16.promises.readdir(fullPath);
4123
4132
  await Promise.all(files.map(async (f) => {
4124
- const contentToPublish = await fse12.readFile(path15.join(fullPath, f));
4133
+ const contentToPublish = await fs16.promises.readFile(path15.join(fullPath, f));
4125
4134
  this.logger.info(`unit ${u.id}: publishing asset ${f}`);
4126
4135
  const casAddress = await this.assetPublisher.publishAsset(u, contentToPublish, f);
4127
4136
  this.logger.info(`unit ${u.id}: asset ${f} published to cas ${casAddress}`);
@@ -4138,7 +4147,7 @@ ${formattedIssues.join("\n")}`);
4138
4147
  async runUberBuild(outputFile, taskName) {
4139
4148
  if (this.state.uberBuildPromise) {
4140
4149
  const ret2 = await this.state.uberBuildPromise;
4141
- await fse12.writeFile(outputFile, ``);
4150
+ await fs16.promises.writeFile(outputFile, ``);
4142
4151
  return ret2;
4143
4152
  }
4144
4153
  this.logger.info(`logging uberbuild in ${outputFile} (triggered by ${taskName})`);
@@ -4152,7 +4161,7 @@ ${formattedIssues.join("\n")}`);
4152
4161
  async runJest(dir3, taskName, outputFile) {
4153
4162
  const dirInRepo = this.state.rootDir.unresolve(dir3);
4154
4163
  const resolvedSummaryFile = this.state.rootDir.resolve(dirInRepo.expand(this.testRunSummaryFile));
4155
- fs11.writeFileSync(resolvedSummaryFile, JSON.stringify({}));
4164
+ fs16.writeFileSync(resolvedSummaryFile, JSON.stringify({}));
4156
4165
  const jof = path15.join(dir3, JEST_OUTPUT_FILE);
4157
4166
  const testsToRun = await this.computeTestsToRun(jof);
4158
4167
  const reporterOutputFile = (await Tmp4.file()).path;
@@ -4166,14 +4175,14 @@ ${formattedIssues.join("\n")}`);
4166
4175
  "--reporters",
4167
4176
  "default"
4168
4177
  ], dir3, outputFile, this.state.config.additionalJestEnvVars);
4169
- const readStdout = /* @__PURE__ */ __name(() => fs11.readFileSync(outputFile, "utf-8").trim(), "readStdout");
4170
- const latest = fs11.readFileSync(reporterOutputFile, "utf-8");
4178
+ const readStdout = /* @__PURE__ */ __name(() => fs16.readFileSync(outputFile, "utf-8").trim(), "readStdout");
4179
+ const latest = fs16.readFileSync(reporterOutputFile, "utf-8");
4171
4180
  if (latest.trim().length === 0) {
4172
4181
  const output = readStdout();
4173
4182
  if (output.length) {
4174
4183
  this.logger.print(`<No Jest tests were invoked. Jest output follows below. latest=${JSON.stringify(latest)}>
4175
4184
  ${output}`);
4176
- fs11.writeFileSync(jof, JSON.stringify(emptyRerunList));
4185
+ fs16.writeFileSync(jof, JSON.stringify(emptyRerunList));
4177
4186
  return "FAIL";
4178
4187
  }
4179
4188
  }
@@ -4213,7 +4222,7 @@ ${output}`);
4213
4222
  }
4214
4223
  });
4215
4224
  const summary = generateTestRunSummary(this.state.rootDir, reporterOutput);
4216
- fs11.writeFileSync(resolvedSummaryFile, JSON.stringify(summary));
4225
+ fs16.writeFileSync(resolvedSummaryFile, JSON.stringify(summary));
4217
4226
  const failingCases = reporterOutput.cases.filter((at) => switchOn(at.status, {
4218
4227
  disabled: /* @__PURE__ */ __name(() => false, "disabled"),
4219
4228
  failed: /* @__PURE__ */ __name(() => true, "failed"),
@@ -4223,7 +4232,7 @@ ${output}`);
4223
4232
  todo: /* @__PURE__ */ __name(() => false, "todo")
4224
4233
  }));
4225
4234
  const rerunList = sortBy(failingCases.map((at) => ({ fileName: at.fileName, testCaseFullName: at.testCaseFullName })), (at) => `${at.fileName} ${at.testCaseFullName}`);
4226
- fs11.writeFileSync(jof, JSON.stringify(RerunList.parse(rerunList)));
4235
+ fs16.writeFileSync(jof, JSON.stringify(RerunList.parse(rerunList)));
4227
4236
  return ret;
4228
4237
  }
4229
4238
  async runCustomTest(unitId, dir3, _taskName, outputFile) {
@@ -4234,7 +4243,7 @@ ${output}`);
4234
4243
  const commandPath = this.state.rootDir.resolve(PathInRepo(testCommand));
4235
4244
  const dirInRepo = this.state.rootDir.unresolve(dir3);
4236
4245
  const resolvedSummaryFile = this.state.rootDir.resolve(dirInRepo.expand(this.testRunSummaryFile));
4237
- fs11.writeFileSync(resolvedSummaryFile, JSON.stringify({}));
4246
+ fs16.writeFileSync(resolvedSummaryFile, JSON.stringify({}));
4238
4247
  const args = [
4239
4248
  dir3,
4240
4249
  // Package directory absolute path
@@ -4245,8 +4254,8 @@ ${output}`);
4245
4254
  ];
4246
4255
  const ret = await this.run(commandPath, args, dir3, outputFile);
4247
4256
  const jof = path15.join(dir3, JEST_OUTPUT_FILE);
4248
- if (!fs11.existsSync(jof)) {
4249
- fs11.writeFileSync(jof, JSON.stringify([]));
4257
+ if (!fs16.existsSync(jof)) {
4258
+ fs16.writeFileSync(jof, JSON.stringify([]));
4250
4259
  }
4251
4260
  return ret;
4252
4261
  }
@@ -4313,23 +4322,23 @@ ${output}`);
4313
4322
  const packDist = path15.join(path15.join(dir3, PACK_DIR), "dist");
4314
4323
  const packDistSrc = path15.join(packDist, this.src);
4315
4324
  const packDistDeps = path15.join(packDist, "deps");
4316
- fs11.mkdirSync(packDistSrc, { recursive: true });
4317
- fs11.cpSync(path15.join(dir3, this.dist("s")), packDistSrc, { recursive: true });
4325
+ fs16.mkdirSync(packDistSrc, { recursive: true });
4326
+ fs16.cpSync(path15.join(dir3, this.dist("s")), packDistSrc, { recursive: true });
4318
4327
  this.logger.info(`updated packagejson is ${JSON.stringify(packageDef)}`);
4319
4328
  const packageJsonPath = path15.join(dir3, PACK_DIR, "package.json");
4320
4329
  const depUnits = this.state.graph.traverseFrom(u.id, { direction: "forward" }).filter((at) => at !== u.id).map((at) => this.unitOf(at));
4321
4330
  for (const at of depUnits) {
4322
4331
  const d = path15.join(packDistDeps, at.id);
4323
- fs11.mkdirSync(d, { recursive: true });
4324
- fs11.cpSync(this.state.rootDir.resolve(at.pathInRepo.expand(this.dist("s"))), d, { recursive: true });
4332
+ fs16.mkdirSync(d, { recursive: true });
4333
+ fs16.cpSync(this.state.rootDir.resolve(at.pathInRepo.expand(this.dist("s"))), d, { recursive: true });
4325
4334
  }
4326
4335
  try {
4327
- fs11.writeFileSync(packageJsonPath, JSON.stringify(packageDef, null, 2));
4336
+ fs16.writeFileSync(packageJsonPath, JSON.stringify(packageDef, null, 2));
4328
4337
  } catch (e) {
4329
4338
  throw new Error(`Failed to write new package definition at ${packageJsonPath}: ${e}`);
4330
4339
  }
4331
4340
  const indexJs = path15.join(dir3, PACK_DIR, this.dist("s"), "index.js");
4332
- const content = fs11.readFileSync(indexJs, "utf-8");
4341
+ const content = fs16.readFileSync(indexJs, "utf-8");
4333
4342
  const preamble = [
4334
4343
  "(() => {",
4335
4344
  " const fs = require(`fs`)",
@@ -4347,7 +4356,7 @@ ${output}`);
4347
4356
  "})()",
4348
4357
  ""
4349
4358
  ].join("\n");
4350
- fs11.writeFileSync(indexJs, preamble + content);
4359
+ fs16.writeFileSync(indexJs, preamble + content);
4351
4360
  return "OK";
4352
4361
  }
4353
4362
  async getYarnInfo(rootDir) {
@@ -4551,10 +4560,10 @@ ${output}`);
4551
4560
  throw new BuildFailedError(`Circular reference detected in build task definition: ${cycle.join(" -> ")}`);
4552
4561
  }
4553
4562
  absPathToIndex.set(fileToRead, absPathToIndex.size);
4554
- if (!fs11.existsSync(fileToRead)) {
4563
+ if (!fs16.existsSync(fileToRead)) {
4555
4564
  throw new BuildFailedError(`Could no find file ${where} while resolving build task "${name}" from ${originatingFrom}`);
4556
4565
  }
4557
- const unparsed = JSON.parse(fs11.readFileSync(fileToRead, "utf-8"));
4566
+ const unparsed = JSON.parse(fs16.readFileSync(fileToRead, "utf-8"));
4558
4567
  const parseResult = BuildTaskRecord.safeParse(unparsed);
4559
4568
  if (!parseResult.success) {
4560
4569
  throw new BuildFailedError(`buildTask object (in ${fileToRead}) is not well formed: ${parseResult.error.message}`);
@@ -4571,12 +4580,12 @@ ${output}`);
4571
4580
  }
4572
4581
  }
4573
4582
  async computeTestsToRun(resolved) {
4574
- const exists = await fse12.pathExists(resolved);
4583
+ const exists = await fse10.pathExists(resolved);
4575
4584
  if (!exists) {
4576
4585
  this.logger.info("jest-output.json does not exist. running everything!");
4577
4586
  return [this.tests];
4578
4587
  }
4579
- const content = await fse12.readFile(resolved, "utf-8");
4588
+ const content = await fs16.promises.readFile(resolved, "utf-8");
4580
4589
  let parsed;
4581
4590
  try {
4582
4591
  parsed = JSON.parse(content);
@@ -4615,9 +4624,9 @@ function computeUnits(yarnInfo) {
4615
4624
  __name(computeUnits, "computeUnits");
4616
4625
  async function readPackages(rootDir, units) {
4617
4626
  const ret = /* @__PURE__ */ new Map();
4618
- await promises(units).forEach(20, async (um) => {
4627
+ await promises2(units).forEach(20, async (um) => {
4619
4628
  const p = rootDir.resolve(um.pathInRepo.expand("package.json"));
4620
- const content = await fse12.readJSON(p);
4629
+ const content = await fse10.readJSON(p);
4621
4630
  ret.set(um.id, content);
4622
4631
  });
4623
4632
  return ret;
@@ -4627,9 +4636,9 @@ async function createOutDirs(rootDir, units, outDirName) {
4627
4636
  if (!outDirName) {
4628
4637
  return;
4629
4638
  }
4630
- await promises(units).forEach(20, async (um) => {
4639
+ await promises2(units).forEach(20, async (um) => {
4631
4640
  const p = rootDir.resolve(um.pathInRepo.expand(outDirName));
4632
- await fse12.ensureDir(p);
4641
+ await fse10.ensureDir(p);
4633
4642
  });
4634
4643
  }
4635
4644
  __name(createOutDirs, "createOutDirs");
@@ -4796,7 +4805,7 @@ async function makeBootstrapper(options) {
4796
4805
  throw new Error(`could not find a repo dir (a directory with a package.json file that has a 'workspace' attribute) in or above ${userDir}`);
4797
4806
  }
4798
4807
  const buildRaptorDir = path16.join(rootDir, ".build-raptor");
4799
- await fse13.ensureDir(buildRaptorDir);
4808
+ await fse11.ensureDir(buildRaptorDir);
4800
4809
  const logFile = path16.join(buildRaptorDir, "main.log");
4801
4810
  const logger = createDefaultLogger(logFile, options.criticality);
4802
4811
  logger.info(`Logger initialized`);
@@ -4815,7 +4824,7 @@ async function makeBootstrapper(options) {
4815
4824
  ${JSON.stringify({ isCi, commitHash, startedAt: new Date(t0).toISOString() }, null, 2)}`);
4816
4825
  }
4817
4826
  const buildRaptorDirTasks = path16.join(buildRaptorDir, "tasks");
4818
- await fse13.rm(buildRaptorDirTasks, { recursive: true, force: true });
4827
+ await fs17.promises.rm(buildRaptorDirTasks, { recursive: true, force: true });
4819
4828
  const storageClient = await storageClientFactory(logger);
4820
4829
  const assetPublisher = new DefaultAssetPublisher(storageClient, logger);
4821
4830
  const repoProtocol = new YarnRepoProtocol(logger, assetPublisher);
@@ -4824,7 +4833,7 @@ ${JSON.stringify({ isCi, commitHash, startedAt: new Date(t0).toISOString() }, nu
4824
4833
  const visualizer = options.taskProgressOutput ? new TaskExecutionVisualizer() : void 0;
4825
4834
  const taskTimings = options.printTiming ? /* @__PURE__ */ new Map() : void 0;
4826
4835
  const allTestsFile = path16.join(buildRaptorDir, "all-tests");
4827
- fs12.writeFileSync(allTestsFile, "");
4836
+ fs17.writeFileSync(allTestsFile, "");
4828
4837
  let atLeastOneTest = false;
4829
4838
  bootstrapper.transmitter.addProcessor((s) => {
4830
4839
  if (s.step === "ASSET_PUBLISHED" || s.step === "BUILD_RUN_STARTED" || s.step === "PUBLIC_FILES" || s.step === "TASK_STORE_GET" || s.step === "TASK_STORE_PUT") {
@@ -4885,9 +4894,9 @@ ${whereIsTheLogMessage}${line}`);
4885
4894
  }
4886
4895
  });
4887
4896
  bootstrapper.subscribable.on("executionEnded", async (arg) => {
4888
- await fse13.ensureDir(buildRaptorDirTasks);
4897
+ await fse11.ensureDir(buildRaptorDirTasks);
4889
4898
  const fileName = path16.join(buildRaptorDirTasks, toReasonableFileName(arg.taskName));
4890
- const stream2 = fse13.createWriteStream(fileName);
4899
+ const stream2 = fs17.createWriteStream(fileName);
4891
4900
  try {
4892
4901
  await dumpFile(arg.outputFile, stream2);
4893
4902
  logger.info(`wrote output of ${arg.taskName} to ${fileName}`);
@@ -4908,7 +4917,7 @@ ${whereIsTheLogMessage}${line}`);
4908
4917
 
4909
4918
  `);
4910
4919
  }
4911
- fs12.appendFileSync(allTestsFile, fs12.readFileSync(arg.outputFile) + "\n");
4920
+ fs17.appendFileSync(allTestsFile, fs17.readFileSync(arg.outputFile) + "\n");
4912
4921
  logger.info(`output of ${arg.taskName} dumped`);
4913
4922
  });
4914
4923
  bootstrapper.subscribable.on("executionSkipped", (tn) => {
@@ -4992,7 +5001,7 @@ function reportTests(logger, arr, tr, allTasksFile) {
4992
5001
  const duration = at.durationMillis === void 0 ? "" : ` (${at.durationMillis} ms)`;
4993
5002
  const message = `${spaces}${v} ${at.testPath.at(-1)}${duration}`;
4994
5003
  logger.print(message, "high");
4995
- fs12.appendFileSync(allTasksFile, message + "\n");
5004
+ fs17.appendFileSync(allTasksFile, message + "\n");
4996
5005
  prev = k;
4997
5006
  }
4998
5007
  }
@@ -5002,13 +5011,13 @@ function reportTests(logger, arr, tr, allTasksFile) {
5002
5011
  const passing = sorted.filter((at) => isPassing(at.tests));
5003
5012
  for (const at of passing) {
5004
5013
  const message = `\u2705 PASSED ${at.fileName}`;
5005
- fs12.appendFileSync(allTasksFile, message + "\n");
5014
+ fs17.appendFileSync(allTasksFile, message + "\n");
5006
5015
  if (renderPassingTests) {
5007
5016
  logger.print(message, "high");
5008
5017
  }
5009
5018
  }
5010
5019
  for (const at of sorted.filter((at2) => !isPassing(at2.tests))) {
5011
- fs12.appendFileSync(allTasksFile, at.fileName + "\n");
5020
+ fs17.appendFileSync(allTasksFile, at.fileName + "\n");
5012
5021
  logger.print(at.fileName, "high");
5013
5022
  printTests(at.tests);
5014
5023
  }
@@ -5178,12 +5187,12 @@ function main() {
5178
5187
  });
5179
5188
  const configContent = bootstrapper.getConfigFileExample();
5180
5189
  const outputPath = path16.join(userDir, EngineBootstrapper.CONFIG_FILES[0]);
5181
- if (fs12.existsSync(outputPath)) {
5190
+ if (fs17.existsSync(outputPath)) {
5182
5191
  logger.print(`Error: ${outputPath} already exists. Remove it first if you want to regenerate.`);
5183
5192
  process.exitCode = 1;
5184
5193
  return;
5185
5194
  }
5186
- fs12.writeFileSync(outputPath, configContent + "\n");
5195
+ fs17.writeFileSync(outputPath, configContent + "\n");
5187
5196
  logger.print(`Created ${outputPath}`);
5188
5197
  }).demandCommand(1).parse();
5189
5198
  }