fluncle 0.276.0 → 0.277.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 (2) hide show
  1. package/bin/fluncle.mjs +88 -41
  2. package/package.json +1 -1
package/bin/fluncle.mjs CHANGED
@@ -62,17 +62,24 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
62
62
 
63
63
  // src/output.ts
64
64
  import { writeSync } from "node:fs";
65
- function writeStdoutSync(text) {
65
+ function writeFdSync(fd, text) {
66
66
  const buf = Buffer.from(text, "utf8");
67
67
  let offset = 0;
68
68
  while (offset < buf.length) {
69
69
  try {
70
- offset += writeSync(1, buf, offset);
70
+ offset += writeSync(fd, buf, offset);
71
71
  } catch (error) {
72
- if (error.code === "EAGAIN") {
72
+ const code = error.code;
73
+ if (code === "EAGAIN") {
74
+ if (stopWaitingForReader()) {
75
+ return;
76
+ }
73
77
  Atomics.wait(EAGAIN_WAIT, 0, 0, 1);
74
78
  continue;
75
79
  }
80
+ if (code === "EPIPE") {
81
+ return;
82
+ }
76
83
  throw error;
77
84
  }
78
85
  }
@@ -81,10 +88,10 @@ function isJsonFailure(value) {
81
88
  return typeof value === "object" && value !== null && typeof value.code === "string" && typeof value.message === "string";
82
89
  }
83
90
  function printJson(value) {
84
- writeStdoutSync(JSON.stringify(value, null, 2) + `
91
+ writeFdSync(1, JSON.stringify(value, null, 2) + `
85
92
  `);
86
93
  }
87
- var EAGAIN_WAIT, CliError;
94
+ var EAGAIN_WAIT, stopWaitingForReader = () => false, CliError;
88
95
  var init_output = __esm(() => {
89
96
  EAGAIN_WAIT = new Int32Array(new SharedArrayBuffer(4));
90
97
  CliError = class CliError extends Error {
@@ -417,7 +424,7 @@ var require_main = __commonJS(function(exports, module) {
417
424
  });
418
425
 
419
426
  // src/deadline.ts
420
- function fireDeadlineNow() {
427
+ function fireDeadlineNow2() {
421
428
  state2.fire?.();
422
429
  }
423
430
  function deadlineAt() {
@@ -426,17 +433,17 @@ function deadlineAt() {
426
433
  function deadlineSignal() {
427
434
  return state2.controller.signal;
428
435
  }
429
- function remainingDeadlineMs(now = Date.now) {
436
+ function remainingDeadlineMs2(now = Date.now) {
430
437
  return state2.at === null ? null : state2.at - now();
431
438
  }
432
439
  function assertBeforeDeadline(doing) {
433
- const remaining = remainingDeadlineMs();
440
+ const remaining = remainingDeadlineMs2();
434
441
  if (remaining !== null && remaining <= 0) {
435
- fireDeadlineNow();
442
+ fireDeadlineNow2();
436
443
  throw new CliError("timeout", `the deadline passed while ${doing}`);
437
444
  }
438
445
  }
439
- function noteProgress(note) {
446
+ function noteProgress2(note) {
440
447
  state2.note = note;
441
448
  }
442
449
  var state2;
@@ -496,7 +503,7 @@ function resolveTokenRef() {
496
503
  return;
497
504
  }
498
505
  assertBeforeDeadline("reading FLUNCLE_API_TOKEN_REF with op");
499
- const remaining = remainingDeadlineMs();
506
+ const remaining = remainingDeadlineMs2();
500
507
  const timeout = remaining === null ? OP_READ_TIMEOUT_MS : Math.max(1, Math.min(OP_READ_TIMEOUT_MS, remaining));
501
508
  try {
502
509
  const secretRef = ref.startsWith("op://") ? ref : `op://${ref}`;
@@ -695,7 +702,7 @@ function parseVersion(version) {
695
702
  var currentVersion;
696
703
  var init_version = __esm(() => {
697
704
  init_output();
698
- currentVersion = "0.276.0".trim() ? "0.276.0".trim() : "0.1.0";
705
+ currentVersion = "0.277.0".trim() ? "0.277.0".trim() : "0.1.0";
699
706
  });
700
707
 
701
708
  // src/update-notifier.ts
@@ -1376,7 +1383,7 @@ var init_Redactable = __esm(() => {
1376
1383
  });
1377
1384
 
1378
1385
  // ../../node_modules/effect/dist/Formatter.js
1379
- function format(input, options) {
1386
+ function format2(input, options) {
1380
1387
  const space = options?.space ?? 0;
1381
1388
  const ancestors = new WeakSet;
1382
1389
  const gap = !space ? "" : typeof space === "number" ? " ".repeat(space) : space;
@@ -1505,7 +1512,7 @@ var init_Inspectable = __esm(() => {
1505
1512
  return this.toJSON();
1506
1513
  },
1507
1514
  toString() {
1508
- return format(this.toJSON());
1515
+ return format2(this.toJSON());
1509
1516
  }
1510
1517
  };
1511
1518
  });
@@ -1604,7 +1611,7 @@ var EffectTypeId = `~effect/Effect`, ExitTypeId = `~effect/Exit`, effectVariance
1604
1611
  },
1605
1612
  ...makePrimitiveProto(options),
1606
1613
  toString() {
1607
- return `${options.op}(${format(this[args])})`;
1614
+ return `${options.op}(${format2(this[args])})`;
1608
1615
  },
1609
1616
  toJSON() {
1610
1617
  return {
@@ -1678,7 +1685,7 @@ var init_core = __esm(() => {
1678
1685
  };
1679
1686
  },
1680
1687
  toString() {
1681
- return format(this.toJSON(), {
1688
+ return format2(this.toJSON(), {
1682
1689
  ignoreToString: true,
1683
1690
  space: 2
1684
1691
  });
@@ -1735,7 +1742,7 @@ var init_core = __esm(() => {
1735
1742
  };
1736
1743
  }
1737
1744
  toString() {
1738
- return `Cause(${format(this.reasons)})`;
1745
+ return `Cause(${format2(this.reasons)})`;
1739
1746
  }
1740
1747
  [NodeInspectSymbol]() {
1741
1748
  return this.toJSON();
@@ -1781,7 +1788,7 @@ var init_core = __esm(() => {
1781
1788
  return pipeArguments(this, arguments);
1782
1789
  }
1783
1790
  toString() {
1784
- return format(this);
1791
+ return format2(this);
1785
1792
  }
1786
1793
  [NodeInspectSymbol]() {
1787
1794
  return this.toString();
@@ -1794,7 +1801,7 @@ var init_core = __esm(() => {
1794
1801
  this.error = error;
1795
1802
  }
1796
1803
  toString() {
1797
- return `Fail(${format(this.error)})`;
1804
+ return `Fail(${format2(this.error)})`;
1798
1805
  }
1799
1806
  toJSON() {
1800
1807
  return {
@@ -1815,7 +1822,7 @@ var init_core = __esm(() => {
1815
1822
  this.defect = defect;
1816
1823
  }
1817
1824
  toString() {
1818
- return `Die(${format(this.defect)})`;
1825
+ return `Die(${format2(this.defect)})`;
1819
1826
  }
1820
1827
  toJSON() {
1821
1828
  return {
@@ -1982,7 +1989,7 @@ var init_option = __esm(() => {
1982
1989
  return combine(hash(this._tag))(hash(this.value));
1983
1990
  },
1984
1991
  toString() {
1985
- return `some(${format(this.value)})`;
1992
+ return `some(${format2(this.value)})`;
1986
1993
  },
1987
1994
  toJSON() {
1988
1995
  return {
@@ -2055,7 +2062,7 @@ var init_result = __esm(() => {
2055
2062
  return combine(hash(this._tag))(hash(this.success));
2056
2063
  },
2057
2064
  toString() {
2058
- return `success(${format(this.success)})`;
2065
+ return `success(${format2(this.success)})`;
2059
2066
  },
2060
2067
  toJSON() {
2061
2068
  return {
@@ -2075,7 +2082,7 @@ var init_result = __esm(() => {
2075
2082
  return combine(hash(this._tag))(hash(this.failure));
2076
2083
  },
2077
2084
  toString() {
2078
- return `failure(${format(this.failure)})`;
2085
+ return `failure(${format2(this.failure)})`;
2079
2086
  },
2080
2087
  toJSON() {
2081
2088
  return {
@@ -4252,7 +4259,7 @@ var init_Cron = __esm(() => {
4252
4259
  return toPojo(this);
4253
4260
  },
4254
4261
  toString() {
4255
- return `Cron(${format(toPojo(this))})`;
4262
+ return `Cron(${format2(toPojo(this))})`;
4256
4263
  },
4257
4264
  toJSON() {
4258
4265
  const out = toPojo(this);
@@ -4562,7 +4569,7 @@ var TypeId11 = "~effect/BigDecimal", BigDecimalProto, isBigDecimal = (u) => hasP
4562
4569
  }
4563
4570
  const powerOfTen = comparisonPowersOfTen[absoluteScaleDifference] ??= bigint102 ** BigInt(absoluteScaleDifference);
4564
4571
  return scaleDifference > 0 ? compareBigInt(self.value, that.value * powerOfTen) : compareBigInt(self.value * powerOfTen, that.value);
4565
- }, sign = (n) => n.value === bigint02 ? 0 : n.value < bigint02 ? -1 : 1, format3 = (n) => {
4572
+ }, sign = (n) => n.value === bigint02 ? 0 : n.value < bigint02 ? -1 : 1, format4 = (n) => {
4566
4573
  const normalized = normalize(n);
4567
4574
  if (Math.abs(normalized.scale) >= 16) {
4568
4575
  return toExponential(normalized);
@@ -4602,7 +4609,7 @@ var init_BigDecimal = __esm(() => {
4602
4609
  return isBigDecimal(that) && compare(this, that) === 0;
4603
4610
  },
4604
4611
  toString() {
4605
- return `BigDecimal(${format3(this)})`;
4612
+ return `BigDecimal(${format4(this)})`;
4606
4613
  },
4607
4614
  toJSON() {
4608
4615
  return {
@@ -4835,7 +4842,7 @@ var init_Chunk = __esm(() => {
4835
4842
  _A: (_) => _
4836
4843
  },
4837
4844
  toString() {
4838
- return `Chunk(${format(toReadonlyArray(this))})`;
4845
+ return `Chunk(${format2(toReadonlyArray(this))})`;
4839
4846
  },
4840
4847
  toJSON() {
4841
4848
  return {
@@ -6273,7 +6280,7 @@ var init_SchemaAST = __esm(() => {
6273
6280
  constructor(literal, annotations, checks, encoding, context) {
6274
6281
  super(annotations, checks, encoding, context);
6275
6282
  if (typeof literal === "number" && !globalThis.Number.isFinite(literal)) {
6276
- throw new Error(`A numeric literal must be finite, got ${format(literal)}`);
6283
+ throw new Error(`A numeric literal must be finite, got ${format2(literal)}`);
6277
6284
  }
6278
6285
  this.literal = literal;
6279
6286
  }
@@ -7650,7 +7657,7 @@ function isPattern2(regExp, annotations) {
7650
7657
  const source = regExp.source;
7651
7658
  const flags = regExp.flags;
7652
7659
  const canExport = /^[dg]*uy?$/.test(flags);
7653
- const runtimeRegExp = flags === "" ? `new RegExp(${format(source)})` : `new RegExp(${format(source)}, ${format(flags)})`;
7660
+ const runtimeRegExp = flags === "" ? `new RegExp(${format2(source)})` : `new RegExp(${format2(source)}, ${format2(flags)})`;
7654
7661
  return isPattern(regExp, {
7655
7662
  toJsonSchema: () => canExport ? {
7656
7663
  pattern: flags.endsWith("y") ? `^(?:${source})` : source
@@ -7969,7 +7976,7 @@ var init_MutableHashMap = __esm(() => {
7969
7976
  return this.backing[Symbol.iterator]();
7970
7977
  },
7971
7978
  toString() {
7972
- return `MutableHashMap(${format(Array.from(this))})`;
7979
+ return `MutableHashMap(${format2(Array.from(this))})`;
7973
7980
  },
7974
7981
  toJSON() {
7975
7982
  return {
@@ -8879,7 +8886,7 @@ var init_MutableHashSet = __esm(() => {
8879
8886
  return Array.from(this.keyMap).map(([_]) => _)[Symbol.iterator]();
8880
8887
  },
8881
8888
  toString() {
8882
- return `MutableHashSet(${format(Array.from(this))})`;
8889
+ return `MutableHashSet(${format2(Array.from(this))})`;
8883
8890
  },
8884
8891
  toJSON() {
8885
8892
  return {
@@ -9206,7 +9213,7 @@ var init_TxChunk = __esm(() => {
9206
9213
  return this.toJSON();
9207
9214
  },
9208
9215
  toString() {
9209
- return `TxChunk(${format(toJson(this.ref))})`;
9216
+ return `TxChunk(${format2(toJson(this.ref))})`;
9210
9217
  },
9211
9218
  toJSON() {
9212
9219
  return {
@@ -9252,7 +9259,7 @@ var init_TxHashMap = __esm(() => {
9252
9259
  return toJson(this);
9253
9260
  },
9254
9261
  toString() {
9255
- return `TxHashMap(${format(toJson(this.ref))})`;
9262
+ return `TxHashMap(${format2(toJson(this.ref))})`;
9256
9263
  },
9257
9264
  toJSON() {
9258
9265
  return {
@@ -9278,7 +9285,7 @@ var init_TxHashSet = __esm(() => {
9278
9285
  return toJson(this);
9279
9286
  },
9280
9287
  toString() {
9281
- return `TxHashSet(${format(toJson(this.ref))})`;
9288
+ return `TxHashSet(${format2(toJson(this.ref))})`;
9282
9289
  },
9283
9290
  toJSON() {
9284
9291
  return {
@@ -9716,7 +9723,7 @@ function adminHeaders() {
9716
9723
  }
9717
9724
  async function apiRequest(path, init = {}) {
9718
9725
  const url = `${getApiBaseUrl()}${path}`;
9719
- noteProgress(`waiting for the Fluncle API: ${init.method ?? "GET"} ${path}`);
9726
+ noteProgress2(`waiting for the Fluncle API: ${init.method ?? "GET"} ${path}`);
9720
9727
  return runPromise2(gen2(function* () {
9721
9728
  const { response, text } = yield* tryPromise2({
9722
9729
  catch: (cause) => new ApiTransportError({ cause }),
@@ -11135,7 +11142,7 @@ function parseVersion2(version) {
11135
11142
  var currentVersion2, latestReleaseUrl = "https://api.github.com/repos/mauricekleine/fluncle/releases/latest";
11136
11143
  var init_version2 = __esm(() => {
11137
11144
  init_output();
11138
- currentVersion2 = "0.276.0".trim() ? "0.276.0".trim() : "0.1.0";
11145
+ currentVersion2 = "0.277.0".trim() ? "0.277.0".trim() : "0.1.0";
11139
11146
  });
11140
11147
 
11141
11148
  // ../../packages/registry/src/index.ts
@@ -30567,7 +30574,7 @@ function createEvidenceHttp(overrides = {}) {
30567
30574
  fetch: (url, init) => globalThis.fetch(url, init),
30568
30575
  now: () => Date.now(),
30569
30576
  policies: SOURCE_POLICIES,
30570
- progress: noteProgress,
30577
+ progress: noteProgress2,
30571
30578
  random: Math.random,
30572
30579
  refresh: false,
30573
30580
  sleep: (ms) => runPromise2(sleep2(ms)),
@@ -33884,9 +33891,27 @@ function disarmDeadline() {
33884
33891
  state.cancel?.();
33885
33892
  state.cancel = null;
33886
33893
  }
33894
+ function fireDeadlineNow() {
33895
+ state.fire?.();
33896
+ }
33887
33897
  function deadlineFired() {
33888
33898
  return state.fired;
33889
33899
  }
33900
+ function remainingDeadlineMs(now = Date.now) {
33901
+ return state.at === null ? null : state.at - now();
33902
+ }
33903
+ function fireIfPastDeadline(waitingOn) {
33904
+ const remaining = remainingDeadlineMs();
33905
+ if (remaining === null || remaining > 0) {
33906
+ return false;
33907
+ }
33908
+ noteProgress(waitingOn);
33909
+ fireDeadlineNow();
33910
+ return true;
33911
+ }
33912
+ function noteProgress(note) {
33913
+ state.note = note;
33914
+ }
33890
33915
 
33891
33916
  // src/env.ts
33892
33917
  var import_dotenv = __toESM(require_main(), 1);
@@ -33965,22 +33990,43 @@ async function maybePrintLiveCallout(args) {
33965
33990
 
33966
33991
  // src/output.ts
33967
33992
  import { writeSync as writeSync2 } from "node:fs";
33993
+ import { format } from "node:util";
33968
33994
  var EAGAIN_WAIT2 = new Int32Array(new SharedArrayBuffer(4));
33969
- function writeStdoutSync2(text) {
33995
+ var stopWaitingForReader2 = () => false;
33996
+ function writeFdSync2(fd, text) {
33970
33997
  const buf = Buffer.from(text, "utf8");
33971
33998
  let offset = 0;
33972
33999
  while (offset < buf.length) {
33973
34000
  try {
33974
- offset += writeSync2(1, buf, offset);
34001
+ offset += writeSync2(fd, buf, offset);
33975
34002
  } catch (error) {
33976
- if (error.code === "EAGAIN") {
34003
+ const code = error.code;
34004
+ if (code === "EAGAIN") {
34005
+ if (stopWaitingForReader2()) {
34006
+ return;
34007
+ }
33977
34008
  Atomics.wait(EAGAIN_WAIT2, 0, 0, 1);
33978
34009
  continue;
33979
34010
  }
34011
+ if (code === "EPIPE") {
34012
+ return;
34013
+ }
33980
34014
  throw error;
33981
34015
  }
33982
34016
  }
33983
34017
  }
34018
+ function routeConsoleThroughBlockingWrites(pastDeadline) {
34019
+ stopWaitingForReader2 = pastDeadline;
34020
+ const toStdout = (...args) => writeFdSync2(1, `${format(...args)}
34021
+ `);
34022
+ const toStderr = (...args) => writeFdSync2(2, `${format(...args)}
34023
+ `);
34024
+ console.debug = toStdout;
34025
+ console.error = toStderr;
34026
+ console.info = toStdout;
34027
+ console.log = toStdout;
34028
+ console.warn = toStderr;
34029
+ }
33984
34030
  class CliError2 extends Error {
33985
34031
  code;
33986
34032
  constructor(code, message) {
@@ -33990,7 +34036,7 @@ class CliError2 extends Error {
33990
34036
  }
33991
34037
  }
33992
34038
  function printJson2(value) {
33993
- writeStdoutSync2(JSON.stringify(value, null, 2) + `
34039
+ writeFdSync2(1, JSON.stringify(value, null, 2) + `
33994
34040
  `);
33995
34041
  }
33996
34042
  function toJsonFailure(error) {
@@ -34099,6 +34145,7 @@ ${fluncleAsciiLogo}
34099
34145
  return program;
34100
34146
  }
34101
34147
  async function main(args = process.argv.slice(2)) {
34148
+ routeConsoleThroughBlockingWrites(() => fireIfPastDeadline("waiting for the stdout reader to take the output"));
34102
34149
  const program = createProgram();
34103
34150
  if (args.length === 0) {
34104
34151
  program.outputHelp();
package/package.json CHANGED
@@ -31,5 +31,5 @@
31
31
  "url": "git+https://github.com/mauricekleine/fluncle.git"
32
32
  },
33
33
  "type": "module",
34
- "version": "0.276.0"
34
+ "version": "0.277.0"
35
35
  }