paper-snapshot-cli 0.1.0 → 0.1.1
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/dist/bin.mjs +62 -10
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -6974,6 +6974,11 @@ const causeElectDefects = (self) => hasDies(self) && hasFails(self) ? causeFromR
|
|
|
6974
6974
|
*/
|
|
6975
6975
|
const findRecoverableError = (self) => hasDies(self) ? fail$7(causeElectDefects(self)) : findError(self);
|
|
6976
6976
|
/** @internal */
|
|
6977
|
+
const findDefect = (self) => {
|
|
6978
|
+
const reason = self.reasons.find(isDieReason$1);
|
|
6979
|
+
return reason ? succeed$6(reason.defect) : fail$7(self);
|
|
6980
|
+
};
|
|
6981
|
+
/** @internal */
|
|
6977
6982
|
const hasInterrupts$1 = (self) => self.reasons.some(isInterruptReason);
|
|
6978
6983
|
/** @internal */
|
|
6979
6984
|
const causeFilterInterruptors = (self) => {
|
|
@@ -7891,6 +7896,8 @@ const tapCauseFilter = /*#__PURE__*/ dual(3, (self, filter, f) => catchCause$1(s
|
|
|
7891
7896
|
/** @internal */
|
|
7892
7897
|
const tapError$1 = /*#__PURE__*/ dual(2, (self, f) => tapCauseFilter(self, findError, (e) => f(e)));
|
|
7893
7898
|
/** @internal */
|
|
7899
|
+
const tapDefect$1 = /*#__PURE__*/ dual(2, (self, f) => tapCauseFilter(self, findDefect, (_) => f(_)));
|
|
7900
|
+
/** @internal */
|
|
7894
7901
|
const catchIf = /*#__PURE__*/ dual((args) => isEffect$1(args[0]), (self, predicate, f, orElse) => catchCause$1(self, (cause) => {
|
|
7895
7902
|
const error = findRecoverableError(cause);
|
|
7896
7903
|
if (isFailure$1(error)) return failCause$3(error.failure);
|
|
@@ -12851,6 +12858,42 @@ const tapError = tapError$1;
|
|
|
12851
12858
|
*/
|
|
12852
12859
|
const tapCause = tapCause$1;
|
|
12853
12860
|
/**
|
|
12861
|
+
* Runs an effectful operation when the source effect dies with a defect.
|
|
12862
|
+
*
|
|
12863
|
+
* **Details**
|
|
12864
|
+
*
|
|
12865
|
+
* Use this for diagnostics such as logging unexpected thrown exceptions or
|
|
12866
|
+
* values passed to `die`. Recoverable failures are not handled. When the
|
|
12867
|
+
* operation succeeds, the original defect is preserved; if the operation fails,
|
|
12868
|
+
* its error is also represented in the returned effect.
|
|
12869
|
+
*
|
|
12870
|
+
* **Example** (Observing defects)
|
|
12871
|
+
*
|
|
12872
|
+
* ```ts import.meta.vitest
|
|
12873
|
+
* import { Effect, Exit } from "effect"
|
|
12874
|
+
* const output: Array<unknown> = []
|
|
12875
|
+
*
|
|
12876
|
+
* // Simulate a severe failure in the system
|
|
12877
|
+
* const task2: Effect.Effect<number> = Effect.die(
|
|
12878
|
+
* "Something went wrong"
|
|
12879
|
+
* )
|
|
12880
|
+
*
|
|
12881
|
+
* // Log the defect using tapDefect
|
|
12882
|
+
* const tapping2 = Effect.tapDefect(
|
|
12883
|
+
* task2,
|
|
12884
|
+
* (defect) => Effect.sync(() => { output.push(`defect: ${defect}`) })
|
|
12885
|
+
* )
|
|
12886
|
+
*
|
|
12887
|
+
* void output.push(Effect.runSyncExit(tapping2))
|
|
12888
|
+
* output // => ["defect: Something went wrong", Exit.die("Something went wrong")]
|
|
12889
|
+
* ```
|
|
12890
|
+
*
|
|
12891
|
+
* @stability stable
|
|
12892
|
+
* @category error handling
|
|
12893
|
+
* @since 2.0.0
|
|
12894
|
+
*/
|
|
12895
|
+
const tapDefect = tapDefect$1;
|
|
12896
|
+
/**
|
|
12854
12897
|
* Discards both the success and failure values of an effect.
|
|
12855
12898
|
*
|
|
12856
12899
|
* **When to use**
|
|
@@ -38122,17 +38165,26 @@ const apply = (base, entry) => ({
|
|
|
38122
38165
|
rightOf: override(entry.rightOf, base.rightOf),
|
|
38123
38166
|
replace: override(entry.replace, base.replace)
|
|
38124
38167
|
});
|
|
38125
|
-
|
|
38168
|
+
const localHost = /^(?:localhost|[^/:]+\.(?:localhost|local|test)|127\.\d+\.\d+\.\d+|0\.0\.0\.0|10\.\d+\.\d+\.\d+|192\.168\.\d+\.\d+|172\.(?:1[6-9]|2\d|3[01])\.\d+\.\d+|\[::1\])(?::\d+)?(?:[/?#]|$)/i;
|
|
38169
|
+
const isPath = (url) => url.startsWith("/") || url.startsWith(".");
|
|
38170
|
+
/** `localhost:3000` and `example.com/pricing` get a scheme: http for local hosts, https otherwise. */
|
|
38171
|
+
const withScheme = (url) => isPath(url) || /^[a-z][a-z\d+.-]*:\/\//i.test(url) || /^(?:about|data|file):/i.test(url) ? url : `${localHost.test(url) ? "http" : "https"}://${url}`;
|
|
38172
|
+
/** Paths like `/pricing` resolve against the base URL (or the first full URL in the run). */
|
|
38126
38173
|
const resolveUrls = (jobs, baseUrl) => gen(function* () {
|
|
38127
|
-
const
|
|
38128
|
-
|
|
38129
|
-
|
|
38174
|
+
const normalized = jobs.map((job) => ({
|
|
38175
|
+
...job,
|
|
38176
|
+
url: map$9(job.url, withScheme)
|
|
38177
|
+
}));
|
|
38178
|
+
const base = orElse$2(map$9(baseUrl, withScheme), () => fromNullishOr(normalized.flatMap((job) => toArray(job.url)).find((url) => !isPath(url))));
|
|
38179
|
+
return yield* forEach$1(normalized, (job) => {
|
|
38180
|
+
if (isNone(job.url) || !isPath(job.url.value)) return succeed$2(job);
|
|
38130
38181
|
const relative = job.url.value;
|
|
38131
|
-
|
|
38132
|
-
|
|
38133
|
-
|
|
38182
|
+
const resolved = flatMap$4(base, (origin) => fromNullishOr(URL.parse(relative, origin)?.href));
|
|
38183
|
+
return match$5(resolved, {
|
|
38184
|
+
onNone: () => fail$3(new ManifestError({ message: `"${relative}" is a path; start with a full URL or pass --base-url` })),
|
|
38185
|
+
onSome: (url) => succeed$2({
|
|
38134
38186
|
...job,
|
|
38135
|
-
url: some(
|
|
38187
|
+
url: some(url)
|
|
38136
38188
|
})
|
|
38137
38189
|
});
|
|
38138
38190
|
});
|
|
@@ -54708,7 +54760,7 @@ const NodeInfo = fromJsonString(Struct({
|
|
|
54708
54760
|
const layer = succeed$3(Service, Service.of({ connect: fn("Paper.connect")(function* (settings) {
|
|
54709
54761
|
const client = new Client({
|
|
54710
54762
|
name: "paper-snapshot",
|
|
54711
|
-
version: "0.1.
|
|
54763
|
+
version: "0.1.1"
|
|
54712
54764
|
});
|
|
54713
54765
|
yield* acquireRelease(tryPromise({
|
|
54714
54766
|
try: () => client.connect(new StdioClientTransport({
|
|
@@ -55363,7 +55415,7 @@ const command = make$3("paper-snapshot", flags, run).pipe(withDescription("Snaps
|
|
|
55363
55415
|
//#region src/bin.ts
|
|
55364
55416
|
const LoggerLive = mergeAll(layer$4([consolePretty()]), succeed$3(LogToStderr, true));
|
|
55365
55417
|
const MainLive = mergeAll(layer$2, layer$1.pipe(provide$2(layer$3)), layer).pipe(provideMerge(layer$5), provideMerge(LoggerLive));
|
|
55366
|
-
run$1(command, { version: "0.1.
|
|
55418
|
+
run$1(command, { version: "0.1.1" }).pipe(tapError((error) => isCliError(error) ? void_ : error$1(`paper-snapshot: ${error.message}`)), tapDefect((defect) => error$1(`paper-snapshot: unexpected error: ${defect instanceof Error ? defect.stack ?? defect.message : String(defect)}`)), provide(MainLive), runMain({
|
|
55367
55419
|
disableErrorReporting: true,
|
|
55368
55420
|
teardown: (exit, onExit) => defaultTeardown(exit, (code) => {
|
|
55369
55421
|
onExit(code);
|
package/package.json
CHANGED