@savvy-web/silk-effects 10.2.0 → 10.2.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.
@@ -1,5 +1,8 @@
1
+ import { Option } from "effect";
1
2
  import { existsSync } from "node:fs";
2
3
  import { dirname, join, resolve } from "node:path";
4
+ import { Walker } from "@effected/walker";
5
+ import { nodeWalkerSyncOps } from "@effected/walker/node-sync";
3
6
 
4
7
  // src/commitlint/detection/dco.ts
5
8
  /**
@@ -24,13 +27,12 @@ const ROOT_MARKERS = [
24
27
  * @internal
25
28
  */
26
29
  function findProjectRoot(cwd) {
27
- let dir = resolve(cwd);
28
- while (true) {
29
- for (const marker of ROOT_MARKERS) if (existsSync(join(dir, marker))) return dir;
30
- const parent = dirname(dir);
31
- if (parent === dir) return null;
32
- dir = parent;
33
- }
30
+ const dirs = Walker.ascendSync(resolve(cwd), { path: nodeWalkerSyncOps.path });
31
+ const marker = Walker.findUpwardSync(dirs, (dir) => ROOT_MARKERS.map((name) => join(dir, name)), nodeWalkerSyncOps);
32
+ return Option.match(marker, {
33
+ onNone: () => null,
34
+ onSome: dirname
35
+ });
34
36
  }
35
37
  /**
36
38
  * Detect if DCO signoff should be required.
@@ -1,7 +1,8 @@
1
- import { Result } from "effect";
2
- import { existsSync } from "node:fs";
1
+ import { Option, Result } from "effect";
3
2
  import { dirname, join, resolve } from "node:path";
3
+ import { Walker } from "@effected/walker";
4
4
  import { detectPackageManagerSync } from "@effected/workspaces";
5
+ import { nodeWalkerSyncOps } from "@effected/walker/node-sync";
5
6
  import { LocalExec, Tool, makeToolDiscoverySync } from "@effected/commands";
6
7
  import { nodeSyncOps } from "@effected/workspaces/node-sync";
7
8
  import { execSync } from "node:child_process";
@@ -84,18 +85,13 @@ var Command = class Command {
84
85
  */
85
86
  static findRoot(cwd = process.cwd()) {
86
87
  if (Command.cachedRoot !== null) return Command.cachedRoot;
87
- let dir = resolve(cwd);
88
- while (true) {
89
- if (existsSync(join(dir, "package.json"))) {
90
- Command.cachedRoot = dir;
91
- return dir;
92
- }
93
- const parent = dirname(dir);
94
- if (parent === dir) break;
95
- dir = parent;
96
- }
97
- Command.cachedRoot = cwd;
98
- return cwd;
88
+ const dirs = Walker.ascendSync(resolve(cwd), { path: nodeWalkerSyncOps.path });
89
+ const manifest = Walker.findUpwardSync(dirs, (dir) => [join(dir, "package.json")], nodeWalkerSyncOps);
90
+ Command.cachedRoot = Option.match(manifest, {
91
+ onNone: () => cwd,
92
+ onSome: dirname
93
+ });
94
+ return Command.cachedRoot;
99
95
  }
100
96
  /**
101
97
  * Detect the package manager declared by the root package.json.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvy-web/silk-effects",
3
- "version": "10.2.0",
3
+ "version": "10.2.1",
4
4
  "private": false,
5
5
  "description": "Shared Effect library for Silk Suite conventions",
6
6
  "homepage": "https://github.com/savvy-web/systems/tree/main/packages/silk-effects",
@@ -37,23 +37,23 @@
37
37
  "@changesets/get-release-plan": "^5.0.2",
38
38
  "@changesets/pre": "^3.0.0",
39
39
  "@changesets/read": "^1.0.1",
40
- "@effected/github-references": "^0.11.0",
41
- "@effected/glob": "^0.15.0",
42
- "@effected/jsonc": "^0.20.1",
43
- "@effected/markdown": "^0.23.0",
44
- "@effected/package-json": "^0.26.1",
45
- "@effected/toml": "^0.16.0",
46
- "@effected/walker": "^0.21.0",
47
- "@effected/yaml": "^0.25.1",
40
+ "@effected/github-references": "^0.12.0",
41
+ "@effected/glob": "^0.16.0",
42
+ "@effected/jsonc": "^0.21.0",
43
+ "@effected/markdown": "^0.24.0",
44
+ "@effected/package-json": "^0.27.0",
45
+ "@effected/toml": "^0.17.0",
46
+ "@effected/walker": "^0.22.0",
47
+ "@effected/yaml": "^0.26.0",
48
48
  "@manypkg/get-packages": "^3.1.0",
49
- "@savvy-web/silk-core": "^0.5.2",
49
+ "@savvy-web/silk-core": "^0.5.3",
50
50
  "shell-quote": "^1.12.0"
51
51
  },
52
52
  "peerDependencies": {
53
- "@effected/commands": "^0.17.0",
54
- "@effected/git": "^0.26.0",
55
- "@effected/templates": "^0.14.0",
56
- "@effected/workspaces": "^0.39.0",
53
+ "@effected/commands": "^0.18.0",
54
+ "@effected/git": "^0.27.0",
55
+ "@effected/templates": "^0.15.0",
56
+ "@effected/workspaces": "^0.40.0",
57
57
  "effect": "^4.0.0"
58
58
  }
59
59
  }
@@ -1,6 +1,7 @@
1
1
  import { REPOS_DIR } from "../constants.js";
2
2
  import { ReposLockdownError } from "../errors.js";
3
- import { Context, Effect, Exit, FileSystem, Layer, Option, Path } from "effect";
3
+ import { Context, Effect, Exit, FileSystem, Layer, Option, Path, Result } from "effect";
4
+ import { GitFile } from "@effected/git";
4
5
 
5
6
  // src/repos/services/lockdown.ts
6
7
  const FILE_LOCKED_BASE_MODE = 292;
@@ -47,9 +48,9 @@ const resolveModuleDir = (fs, path, root, name) => Effect.gen(function* () {
47
48
  if (info.value.type === "Directory") return dotGit;
48
49
  const content = yield* fs.readFileString(dotGit).pipe(Effect.option);
49
50
  if (Option.isNone(content)) return fallback;
50
- const match = /^gitdir:\s*(.+)$/m.exec(content.value);
51
- if (!match?.[1]) return fallback;
52
- const pointer = match[1].trim();
51
+ const gitFile = GitFile.parseResult(content.value);
52
+ if (Result.isFailure(gitFile)) return fallback;
53
+ const pointer = gitFile.success.gitdir;
53
54
  const resolved = path.isAbsolute(pointer) ? pointer : path.resolve(path.dirname(dotGit), pointer);
54
55
  const relative = path.relative(root, resolved);
55
56
  if (relative.startsWith("..") || path.isAbsolute(relative)) return fallback;
@@ -5,7 +5,7 @@ import { ReposConfigStore } from "./config-store.js";
5
5
  import { ReposLockdown, resolveModuleDir } from "./lockdown.js";
6
6
  import { submoduleNameFromKey } from "./drift.js";
7
7
  import { Clock, Context, Effect, Exit, FileSystem, Layer, Option, Path, Result, Schema } from "effect";
8
- import { Git, GitConfig, GitRemote, Gitmodules, LsRemoteEntry } from "@effected/git";
8
+ import { Git, GitConfig, GitFile, GitRemote, Gitmodules, LsRemoteEntry } from "@effected/git";
9
9
  import { createHash } from "node:crypto";
10
10
 
11
11
  // src/repos/services/manager.ts
@@ -678,9 +678,9 @@ var ReposManager = class extends Context.Service()("@savvy-web/silk-effects/Repo
678
678
  if (Option.isNone(info) || info.value.type === "Directory") return fallback;
679
679
  const content = yield* fs.readFileString(dotGit).pipe(Effect.option);
680
680
  if (Option.isNone(content)) return fallback;
681
- const match = /^gitdir:\s*(.+)$/m.exec(content.value);
682
- if (!match?.[1]) return fallback;
683
- const pointer = match[1].trim();
681
+ const gitFile = GitFile.parseResult(content.value);
682
+ if (Result.isFailure(gitFile)) return fallback;
683
+ const pointer = gitFile.success.gitdir;
684
684
  const gitdir = path.isAbsolute(pointer) ? pointer : path.resolve(root, pointer);
685
685
  const commondir = yield* fs.readFileString(path.join(gitdir, "commondir")).pipe(Effect.option);
686
686
  if (Option.isSome(commondir)) {
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.59.4"
8
+ "packageVersion": "7.60.0"
9
9
  }
10
10
  ]
11
11
  }