@okfit/profiles 0.12.0 → 0.13.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/Derivation.js +7 -21
- package/index.d.ts +5 -13
- package/package.json +8 -7
- package/tsdoc-metadata.json +1 -1
package/Derivation.js
CHANGED
|
@@ -5,7 +5,6 @@ import { Actor, OkfitConfig } from "@okfit/core";
|
|
|
5
5
|
import { DateTime, Duration, Effect, FileSystem, Option, Path, Schema } from "effect";
|
|
6
6
|
import { Git } from "@effected/git";
|
|
7
7
|
import { JsoncFingerprint } from "@effected/jsonc";
|
|
8
|
-
import { Walker } from "@effected/walker";
|
|
9
8
|
|
|
10
9
|
// src/Derivation.ts
|
|
11
10
|
/**
|
|
@@ -162,26 +161,12 @@ var Derivation = class Derivation {
|
|
|
162
161
|
*/
|
|
163
162
|
static contentDigest = contentDigest;
|
|
164
163
|
/**
|
|
165
|
-
* The worktree root holding `start`: the nearest ancestor directory (inclusive) with a `.git` entry, a
|
|
166
|
-
* directory in a main checkout and a file in a linked worktree or submodule; `undefined` when none has one.
|
|
167
|
-
* Asked of the filesystem rather than of `git rev-parse --show-toplevel` because a pre-commit hook in a
|
|
168
|
-
* linked worktree exports `GIT_DIR` without `GIT_WORK_TREE`, and git then takes each call's cwd as the
|
|
169
|
-
* worktree, naming whatever directory it was asked from as the top level (okfit #315). Not
|
|
170
|
-
* symlink-resolved; callers `realPath` it as they would `Git.repoRoot`.
|
|
171
|
-
*/
|
|
172
|
-
static worktreeRoot = Effect.fn("Derivation.worktreeRoot")(function* (start) {
|
|
173
|
-
const fs = yield* FileSystem.FileSystem;
|
|
174
|
-
const path = yield* Path.Path;
|
|
175
|
-
const dirs = yield* Walker.ascend(path.resolve(start));
|
|
176
|
-
const root = yield* Walker.findRoot(dirs, (dir) => fs.exists(path.join(dir, ".git")));
|
|
177
|
-
return Option.getOrUndefined(root);
|
|
178
|
-
});
|
|
179
|
-
/**
|
|
180
164
|
* Spec 5.4 rule 2 as P-2 (DERIVE option C). Steps:
|
|
181
|
-
* 1. `root =
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
165
|
+
* 1. `root = Git.repoRoot(dirname(file), { ignoreRepositoryEnv: true })`: the option drops the
|
|
166
|
+
* repository-pointing variables (`GIT_DIR` and kin), so a linked worktree's hook environment cannot shrink
|
|
167
|
+
* the root to the file's directory (okfit #315). On `NotARepositoryError` it retries with that
|
|
168
|
+
* environment honoured, so a repository defined only by `GIT_DIR`/`GIT_WORK_TREE` still resolves; a file
|
|
169
|
+
* outside any repository surfaces `NotARepositoryError`. Submodules and worktrees work because both are asked from the file's directory (P-39).
|
|
185
170
|
* 2. `realPath` both (rev-parse is symlink-resolved), then the repo-relative posix path via `Path` (P-39).
|
|
186
171
|
* 3. `worktree = body(readFileString(file))`.
|
|
187
172
|
* 4. `Git.show(realRoot, "HEAD", rel)`: `UnknownRefError` is `uncommitted { unborn }` (P-11), `Option.none`
|
|
@@ -200,7 +185,8 @@ var Derivation = class Derivation {
|
|
|
200
185
|
const history = yield* GitHistory;
|
|
201
186
|
const fs = yield* FileSystem.FileSystem;
|
|
202
187
|
const path = yield* Path.Path;
|
|
203
|
-
const
|
|
188
|
+
const dir = path.dirname(options.file);
|
|
189
|
+
const root = yield* git.repoRoot(dir, { ignoreRepositoryEnv: true }).pipe(Effect.catchTag("NotARepositoryError", () => git.repoRoot(dir)));
|
|
204
190
|
const realRoot = yield* fs.realPath(root);
|
|
205
191
|
const realFile = yield* fs.realPath(options.file);
|
|
206
192
|
const rel = path.relative(realRoot, realFile).split(path.sep).join("/");
|
package/index.d.ts
CHANGED
|
@@ -306,21 +306,13 @@ export declare class Derivation {
|
|
|
306
306
|
* plus the normalised body, insensitive to style, key order and CRLF.
|
|
307
307
|
*/
|
|
308
308
|
static readonly contentDigest: (raw: Readonly<Record<string, unknown>>, source: string) => Effect.Effect<Digest, PlatformError.PlatformError, Crypto.Crypto>;
|
|
309
|
-
/**
|
|
310
|
-
* The worktree root holding `start`: the nearest ancestor directory (inclusive) with a `.git` entry, a
|
|
311
|
-
* directory in a main checkout and a file in a linked worktree or submodule; `undefined` when none has one.
|
|
312
|
-
* Asked of the filesystem rather than of `git rev-parse --show-toplevel` because a pre-commit hook in a
|
|
313
|
-
* linked worktree exports `GIT_DIR` without `GIT_WORK_TREE`, and git then takes each call's cwd as the
|
|
314
|
-
* worktree, naming whatever directory it was asked from as the top level (okfit #315). Not
|
|
315
|
-
* symlink-resolved; callers `realPath` it as they would `Git.repoRoot`.
|
|
316
|
-
*/
|
|
317
|
-
static readonly worktreeRoot: (start: string) => Effect.Effect<string | undefined, never, FileSystem.FileSystem | Path.Path>;
|
|
318
309
|
/**
|
|
319
310
|
* Spec 5.4 rule 2 as P-2 (DERIVE option C). Steps:
|
|
320
|
-
* 1. `root =
|
|
321
|
-
*
|
|
322
|
-
*
|
|
323
|
-
*
|
|
311
|
+
* 1. `root = Git.repoRoot(dirname(file), { ignoreRepositoryEnv: true })`: the option drops the
|
|
312
|
+
* repository-pointing variables (`GIT_DIR` and kin), so a linked worktree's hook environment cannot shrink
|
|
313
|
+
* the root to the file's directory (okfit #315). On `NotARepositoryError` it retries with that
|
|
314
|
+
* environment honoured, so a repository defined only by `GIT_DIR`/`GIT_WORK_TREE` still resolves; a file
|
|
315
|
+
* outside any repository surfaces `NotARepositoryError`. Submodules and worktrees work because both are asked from the file's directory (P-39).
|
|
324
316
|
* 2. `realPath` both (rev-parse is symlink-resolved), then the repo-relative posix path via `Path` (P-39).
|
|
325
317
|
* 3. `worktree = body(readFileString(file))`.
|
|
326
318
|
* 4. `Git.show(realRoot, "HEAD", rel)`: `UnknownRefError` is `uncommitted { unborn }` (P-11), `Option.none`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@okfit/profiles",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Named OKF configuration profiles for okfit, starting with the software-project profile.",
|
|
6
6
|
"keywords": [
|
|
@@ -35,12 +35,13 @@
|
|
|
35
35
|
"./package.json": "./package.json"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@effected/git": "^0.
|
|
39
|
-
"@effected/glob": "^0.
|
|
40
|
-
"@effected/jsonc": "^0.
|
|
41
|
-
"@effected/markdown": "^0.
|
|
42
|
-
"@effected/
|
|
43
|
-
"@
|
|
38
|
+
"@effected/git": "^0.27.0",
|
|
39
|
+
"@effected/glob": "^0.16.0",
|
|
40
|
+
"@effected/jsonc": "^0.21.0",
|
|
41
|
+
"@effected/markdown": "^0.24.0",
|
|
42
|
+
"@effected/source": "^0.1.0",
|
|
43
|
+
"@effected/walker": "^0.22.0",
|
|
44
|
+
"@okfit/core": "^0.11.8",
|
|
44
45
|
"effect": "^4.0.0"
|
|
45
46
|
},
|
|
46
47
|
"engines": {
|