@effected/walker 0.14.1 → 0.15.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/Descend.js CHANGED
@@ -12,6 +12,7 @@ import { Effect, FileSystem, Path, Schema } from "effect";
12
12
  var DescendError = class extends Schema.TaggedError()("DescendError", {
13
13
  /** The glob pattern's source text. */
14
14
  pattern: Schema.String,
15
+ /** Why the walk failed: a directory could not be read, or the walk went past `maxDepth`. */
15
16
  reason: Schema.Literals(["unreadableDirectory", "depthExceeded"]),
16
17
  /** The offending directory, relative to `cwd` (`""` is the walk's base). */
17
18
  path: Schema.String,
package/Expand.js CHANGED
@@ -69,13 +69,18 @@ var GlobExpansionError = class extends Schema.TaggedError()("GlobExpansionError"
69
69
  *
70
70
  * @example
71
71
  * ```ts
72
- * import { compileAndExpand } from "@effected/walker"
73
- * import { GlobPatternOptions } from "@effected/glob"
72
+ * import { GlobPatternOptions } from "@effected/glob";
73
+ * import { compileAndExpand } from "@effected/walker";
74
+ * import { Effect } from "effect";
74
75
  *
75
- * const files = yield* compileAndExpand("packages/*​/src/**​/*.ts", {
76
- * cwd: "/repo",
77
- * glob: GlobPatternOptions.make({ dot: true })
78
- * })
76
+ * const program = Effect.gen(function* () {
77
+ * // Sorted, cwd-relative POSIX paths; fails with `GlobExpansionError`.
78
+ * return yield* compileAndExpand("src/*.ts", {
79
+ * cwd: "/repo",
80
+ * glob: GlobPatternOptions.make({ dot: true }),
81
+ * });
82
+ * });
83
+ * // Requires `FileSystem` and `Path` from the platform layer.
79
84
  * ```
80
85
  *
81
86
  * @public
package/README.md CHANGED
@@ -7,10 +7,10 @@
7
7
 
8
8
  Path traversal as Effect primitives. `Walker.ascend` gives you the directory chain from a starting path to the filesystem root; `Walker.findUpward` returns the nearest existing file among per-directory candidates; `Walker.findRoot` returns the nearest directory a marker predicate accepts. Every probe absorbs its own failure, so a single unreadable ancestor cannot hide a valid `.git` or `pnpm-workspace.yaml` above it. Going the other way, `descend` expands a compiled [`@effected/glob`](https://www.npmjs.com/package/@effected/glob) pattern under a directory into the matching file paths — sorted, symlink-safe, and typed about unreadable subtrees instead of silently swallowing them. `FileSystem` and `Path` arrive from `effect` core, so no platform package is pulled in — not even in tests.
9
9
 
10
- > **Pre-release.** This package is part of the `@effected/*` kit, in pre-`1.0.0`
11
- > development against a single pinned Effect v4 prerelease. Packages graduate to
12
- > `1.0.0` once Effect `4.0.0` ships. To hold your own `effect` versions at
13
- > exactly the ones the kit is built and tested against, install
10
+ > **Pre-`1.0.0`.** This package is part of the `@effected/*` kit, built on stable
11
+ > Effect v4 (`effect` `^4.0.0`) and still in `0.x` development. Stable Effect
12
+ > makes a kit `1.0.0` possible, not automatic. To keep your `effect` and
13
+ > `@effect/*` versions on the line the kit is built and tested against, install
14
14
  > [`@effected/pnpm-plugin-effect`](https://www.npmjs.com/package/@effected/pnpm-plugin-effect).
15
15
  >
16
16
  > **Stability: unstable.** This package's API surface is not yet considered
package/Walker.js CHANGED
@@ -49,7 +49,8 @@ const findUpward = (dirs, candidatesFor) => Effect.gen(function* () {
49
49
  });
50
50
  const findRoot = (dirs, isRoot) => firstMatch(dirs, isRoot);
51
51
  /**
52
- * Upward path traversal primitives.
52
+ * Upward path traversal primitives: the directory chain from a start path to the
53
+ * root, and first-match scans over it.
53
54
  *
54
55
  * @public
55
56
  */
@@ -69,13 +70,25 @@ var Walker = class {
69
70
  * a pathological `Path` implementation that never reaches one.
70
71
  *
71
72
  * `stopAt` is compared in normalized form — see {@link AscendOptions.stopAt}.
72
- * Raw string equality made the ceiling fail OPEN: an unnormalized ceiling
73
- * matched nothing and the ascent ran silently to the filesystem root, which is
74
- * the unbounded walk the option exists to prevent, with no error to notice it
75
- * by. A relative ceiling **dies** for the same reason — resolving one against
76
- * `process.cwd()` would reintroduce the silent-wrong-walk failure through a
77
- * different door. See {@link AscendOptions.stopAt} for why that is a defect
78
- * rather than a typed error; the error channel stays `never`.
73
+ * Comparing raw strings would let an unnormalized ceiling match nothing and
74
+ * the ascent run silently to the filesystem root, which is the unbounded walk
75
+ * the option exists to prevent. A relative ceiling **dies** for the same
76
+ * reason — resolving one against `process.cwd()` would reintroduce the
77
+ * silent-wrong-walk failure through a different door. See
78
+ * {@link AscendOptions.stopAt} for why that is a defect rather than a typed
79
+ * error; the error channel stays `never`.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * import { Walker } from "@effected/walker";
84
+ * import { Effect } from "effect";
85
+ *
86
+ * const program = Effect.gen(function* () {
87
+ * // => ["/repo/packages/app", "/repo/packages", "/repo"]
88
+ * return yield* Walker.ascend("/repo/packages/app", { stopAt: "/repo" });
89
+ * });
90
+ * // Requires `Path` from the platform layer.
91
+ * ```
79
92
  */
80
93
  static ascend = ascend;
81
94
  /**
package/index.d.ts CHANGED
@@ -109,6 +109,7 @@ interface DescendResult {
109
109
  declare const DescendError_base: Schema.Class<DescendError, Schema.TaggedStruct<"DescendError", {
110
110
  /** The glob pattern's source text. */
111
111
  readonly pattern: Schema.String;
112
+ /** Why the walk failed: a directory could not be read, or the walk went past `maxDepth`. */
112
113
  readonly reason: Schema.Literals<readonly ["unreadableDirectory", "depthExceeded"]>;
113
114
  /** The offending directory, relative to `cwd` (`""` is the walk's base). */
114
115
  readonly path: Schema.String;
@@ -182,6 +183,20 @@ export declare function descend(pattern: GlobPattern, options: DescendRecordOpti
182
183
  * Passing `onUnreadable: "record"` resolves to a {@link DescendResult}
183
184
  * instead — see that overload.
184
185
  *
186
+ * @example
187
+ * ```ts
188
+ * import { GlobPattern } from "@effected/glob";
189
+ * import { descend } from "@effected/walker";
190
+ * import { Effect } from "effect";
191
+ *
192
+ * const program = Effect.gen(function* () {
193
+ * const pattern = yield* GlobPattern.compile("src/*.ts");
194
+ * // Sorted, cwd-relative POSIX paths of the matching files.
195
+ * return yield* descend(pattern, { cwd: "/repo" });
196
+ * });
197
+ * // Requires `FileSystem` and `Path` from the platform layer.
198
+ * ```
199
+ *
185
200
  * @public
186
201
  */
187
202
  export declare function descend(pattern: GlobPattern, options: DescendOptions): Effect.Effect<ReadonlyArray<string>, DescendError, FileSystem.FileSystem | Path.Path>;
@@ -271,13 +286,18 @@ export declare class GlobExpansionError extends GlobExpansionError_base {
271
286
  *
272
287
  * @example
273
288
  * ```ts
274
- * import { compileAndExpand } from "@effected/walker"
275
- * import { GlobPatternOptions } from "@effected/glob"
289
+ * import { GlobPatternOptions } from "@effected/glob";
290
+ * import { compileAndExpand } from "@effected/walker";
291
+ * import { Effect } from "effect";
276
292
  *
277
- * const files = yield* compileAndExpand("packages/*​/src/**​/*.ts", {
278
- * cwd: "/repo",
279
- * glob: GlobPatternOptions.make({ dot: true })
280
- * })
293
+ * const program = Effect.gen(function* () {
294
+ * // Sorted, cwd-relative POSIX paths; fails with `GlobExpansionError`.
295
+ * return yield* compileAndExpand("src/*.ts", {
296
+ * cwd: "/repo",
297
+ * glob: GlobPatternOptions.make({ dot: true }),
298
+ * });
299
+ * });
300
+ * // Requires `FileSystem` and `Path` from the platform layer.
281
301
  * ```
282
302
  *
283
303
  * @public
@@ -341,7 +361,8 @@ interface AscendOptions {
341
361
  readonly maxDepth?: number;
342
362
  }
343
363
  /**
344
- * Upward path traversal primitives.
364
+ * Upward path traversal primitives: the directory chain from a start path to the
365
+ * root, and first-match scans over it.
345
366
  *
346
367
  * @public
347
368
  */
@@ -361,13 +382,25 @@ export declare class Walker {
361
382
  * a pathological `Path` implementation that never reaches one.
362
383
  *
363
384
  * `stopAt` is compared in normalized form — see {@link AscendOptions.stopAt}.
364
- * Raw string equality made the ceiling fail OPEN: an unnormalized ceiling
365
- * matched nothing and the ascent ran silently to the filesystem root, which is
366
- * the unbounded walk the option exists to prevent, with no error to notice it
367
- * by. A relative ceiling **dies** for the same reason — resolving one against
368
- * `process.cwd()` would reintroduce the silent-wrong-walk failure through a
369
- * different door. See {@link AscendOptions.stopAt} for why that is a defect
370
- * rather than a typed error; the error channel stays `never`.
385
+ * Comparing raw strings would let an unnormalized ceiling match nothing and
386
+ * the ascent run silently to the filesystem root, which is the unbounded walk
387
+ * the option exists to prevent. A relative ceiling **dies** for the same
388
+ * reason — resolving one against `process.cwd()` would reintroduce the
389
+ * silent-wrong-walk failure through a different door. See
390
+ * {@link AscendOptions.stopAt} for why that is a defect rather than a typed
391
+ * error; the error channel stays `never`.
392
+ *
393
+ * @example
394
+ * ```ts
395
+ * import { Walker } from "@effected/walker";
396
+ * import { Effect } from "effect";
397
+ *
398
+ * const program = Effect.gen(function* () {
399
+ * // => ["/repo/packages/app", "/repo/packages", "/repo"]
400
+ * return yield* Walker.ascend("/repo/packages/app", { stopAt: "/repo" });
401
+ * });
402
+ * // Requires `Path` from the platform layer.
403
+ * ```
371
404
  */
372
405
  static readonly ascend: (start: string, options?: AscendOptions) => Effect.Effect<ReadonlyArray<string>, never, Path.Path>;
373
406
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effected/walker",
3
- "version": "0.14.1",
3
+ "version": "0.15.0",
4
4
  "private": false,
5
5
  "description": "Path traversal as Effect primitives: ascend a directory chain to the first matching candidate, or descend a tree expanding a glob against the filesystem.",
6
6
  "keywords": [
@@ -37,8 +37,8 @@
37
37
  "./package.json": "./package.json"
38
38
  },
39
39
  "peerDependencies": {
40
- "@effected/glob": "^0.9.0",
41
- "effect": "4.0.0-rc.118"
40
+ "@effected/glob": "^0.10.0",
41
+ "effect": "^4.0.0"
42
42
  },
43
43
  "engines": {
44
44
  "node": ">=24.11.0"