@clef-sh/core 0.1.14 → 0.1.15-beta.98
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/__mocks__/write-file-atomic.d.ts +5 -0
- package/dist/__mocks__/write-file-atomic.d.ts.map +1 -0
- package/dist/bulk/ops.d.ts +13 -4
- package/dist/bulk/ops.d.ts.map +1 -1
- package/dist/git/integration.d.ts +73 -2
- package/dist/git/integration.d.ts.map +1 -1
- package/dist/import/index.d.ts +12 -3
- package/dist/import/index.d.ts.map +1 -1
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4695 -1433
- package/dist/index.js.map +4 -4
- package/dist/index.mjs +3971 -692
- package/dist/index.mjs.map +4 -4
- package/dist/lint/runner.d.ts.map +1 -1
- package/dist/manifest/io.d.ts +16 -0
- package/dist/manifest/io.d.ts.map +1 -1
- package/dist/manifest/parser.d.ts.map +1 -1
- package/dist/migration/backend.d.ts +20 -3
- package/dist/migration/backend.d.ts.map +1 -1
- package/dist/recipients/index.d.ts +9 -4
- package/dist/recipients/index.d.ts.map +1 -1
- package/dist/reset/manager.d.ts +118 -0
- package/dist/reset/manager.d.ts.map +1 -0
- package/dist/service-identity/manager.d.ts +67 -10
- package/dist/service-identity/manager.d.ts.map +1 -1
- package/dist/sops/client.d.ts.map +1 -1
- package/dist/structure/manager.d.ts +155 -0
- package/dist/structure/manager.d.ts.map +1 -0
- package/dist/tx/errors.d.ts +32 -0
- package/dist/tx/errors.d.ts.map +1 -0
- package/dist/tx/index.d.ts +4 -0
- package/dist/tx/index.d.ts.map +1 -0
- package/dist/tx/transaction-manager.d.ts +66 -0
- package/dist/tx/transaction-manager.d.ts.map +1 -0
- package/package.json +5 -1
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { GitIntegration } from "../git/integration";
|
|
2
|
+
/**
|
|
3
|
+
* Options for a single transactional mutation.
|
|
4
|
+
*/
|
|
5
|
+
export interface TransactionOptions {
|
|
6
|
+
/** Human-readable commit message. Required. */
|
|
7
|
+
description: string;
|
|
8
|
+
/**
|
|
9
|
+
* Paths the mutation will touch (relative to repoRoot).
|
|
10
|
+
* Used for `git add` and to scope rollback's `git clean`.
|
|
11
|
+
* Be precise — anything outside this list is not protected by the transaction.
|
|
12
|
+
*/
|
|
13
|
+
paths: string[];
|
|
14
|
+
/**
|
|
15
|
+
* The work itself. Write files via `write-file-atomic` and update the
|
|
16
|
+
* manifest via the existing helpers. May throw — that triggers rollback.
|
|
17
|
+
*/
|
|
18
|
+
mutate: () => Promise<void>;
|
|
19
|
+
/** Auto-commit on success. Default: true */
|
|
20
|
+
commit?: boolean;
|
|
21
|
+
/** Allow running with a dirty working tree. Default: false */
|
|
22
|
+
allowDirty?: boolean;
|
|
23
|
+
/** Skip the pre-commit hook (`git commit --no-verify`). Default: false */
|
|
24
|
+
noVerify?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result of a successful transaction.
|
|
28
|
+
*/
|
|
29
|
+
export interface TransactionResult {
|
|
30
|
+
/** SHA of the commit created, or null if `commit: false` was passed */
|
|
31
|
+
sha: string | null;
|
|
32
|
+
/** Paths included in the commit */
|
|
33
|
+
paths: string[];
|
|
34
|
+
/** True if the working tree was already dirty when the transaction started */
|
|
35
|
+
startedDirty: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Wraps mutations to the matrix in a transactional commit:
|
|
39
|
+
* 1. Acquire a single-writer lock on .clef/.lock
|
|
40
|
+
* 2. Validate the working tree (clean, in a git repo, not mid-rebase, etc.)
|
|
41
|
+
* 3. Run the mutation
|
|
42
|
+
* 4. git add the declared paths and git commit
|
|
43
|
+
* 5. On any failure between steps 3 and 4: git reset --hard to the
|
|
44
|
+
* pre-mutation HEAD, git clean -fd the declared paths, rethrow.
|
|
45
|
+
*
|
|
46
|
+
* Each transaction creates exactly one git commit. Each commit can be
|
|
47
|
+
* reverted with `git revert <sha>`.
|
|
48
|
+
*/
|
|
49
|
+
export declare class TransactionManager {
|
|
50
|
+
private readonly git;
|
|
51
|
+
constructor(git: GitIntegration);
|
|
52
|
+
run(repoRoot: string, opts: TransactionOptions): Promise<TransactionResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Restore the working tree to the pre-mutation state.
|
|
55
|
+
*
|
|
56
|
+
* If the transaction started with a clean tree, we can `git reset --hard`
|
|
57
|
+
* to the pre-mutation SHA without losing any work.
|
|
58
|
+
*
|
|
59
|
+
* If the transaction started dirty (allowDirty was set), we cannot safely
|
|
60
|
+
* reset because that would discard the user's pre-existing uncommitted
|
|
61
|
+
* changes. In that case, we throw a rollback error and tell the user to
|
|
62
|
+
* inspect manually.
|
|
63
|
+
*/
|
|
64
|
+
private rollback;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=transaction-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction-manager.d.ts","sourceRoot":"","sources":["../../src/tx/transaction-manager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAOpD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB;;;OAGG;IACH,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,4CAA4C;IAC5C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,uEAAuE;IACvE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,mCAAmC;IACnC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,8EAA8E;IAC9E,YAAY,EAAE,OAAO,CAAC;CACvB;AAeD;;;;;;;;;;;GAWG;AACH,qBAAa,kBAAkB;IACjB,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,cAAc;IAE1C,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAuIjF;;;;;;;;;;OAUG;YACW,QAAQ;CAqCvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clef-sh/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15-beta.98",
|
|
4
4
|
"description": "Core library for Clef — git-native secrets management",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,11 +33,15 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"age-encryption": "^0.3.0",
|
|
36
|
+
"proper-lockfile": "^4.1.2",
|
|
37
|
+
"write-file-atomic": "^7.0.0",
|
|
36
38
|
"yaml": "^2.8.3"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@types/jest": "^29.5.0",
|
|
40
42
|
"@types/node": "^20.11.0",
|
|
43
|
+
"@types/proper-lockfile": "^4.1.4",
|
|
44
|
+
"@types/write-file-atomic": "^4.0.3",
|
|
41
45
|
"esbuild": "^0.27.4",
|
|
42
46
|
"jest": "^29.7.0",
|
|
43
47
|
"ts-jest": "^29.1.0",
|