@zukhruf/git-hooks 0.8.21 → 0.8.22
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/README.md +275 -37
- package/dist/commit.d.ts +3 -12
- package/dist/commit.d.ts.map +1 -1
- package/dist/commit.js +17 -97
- package/dist/commit.js.map +1 -1
- package/dist/dependency-checks.d.ts.map +1 -1
- package/dist/dependency-checks.js +49 -44
- package/dist/dependency-checks.js.map +1 -1
- package/dist/dockerfile-installs.d.ts +7 -0
- package/dist/dockerfile-installs.d.ts.map +1 -0
- package/dist/dockerfile-installs.js +132 -0
- package/dist/dockerfile-installs.js.map +1 -0
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +33 -24
- package/dist/format.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/lockfile-sync.d.ts +8 -0
- package/dist/lockfile-sync.d.ts.map +1 -0
- package/dist/lockfile-sync.js +82 -0
- package/dist/lockfile-sync.js.map +1 -0
- package/dist/no-numeric-pins.d.ts.map +1 -1
- package/dist/no-numeric-pins.js +12 -3
- package/dist/no-numeric-pins.js.map +1 -1
- package/dist/npm/lockfile.d.ts +4 -0
- package/dist/npm/lockfile.d.ts.map +1 -1
- package/dist/npm/lockfile.js +31 -0
- package/dist/npm/lockfile.js.map +1 -1
- package/dist/npmrc-policy.d.ts +7 -0
- package/dist/npmrc-policy.d.ts.map +1 -0
- package/dist/npmrc-policy.js +93 -0
- package/dist/npmrc-policy.js.map +1 -0
- package/dist/push.d.ts +0 -2
- package/dist/push.d.ts.map +1 -1
- package/dist/push.js +0 -17
- package/dist/push.js.map +1 -1
- package/dist/run/commit-msg.d.ts +9 -0
- package/dist/run/commit-msg.d.ts.map +1 -0
- package/dist/run/commit-msg.js +8 -0
- package/dist/run/commit-msg.js.map +1 -0
- package/dist/run/pre-commit.d.ts +14 -0
- package/dist/run/pre-commit.d.ts.map +1 -0
- package/dist/run/pre-commit.js +41 -0
- package/dist/run/pre-commit.js.map +1 -0
- package/dist/run/pre-push.d.ts +14 -0
- package/dist/run/pre-push.d.ts.map +1 -0
- package/dist/run/pre-push.js +27 -0
- package/dist/run/pre-push.js.map +1 -0
- package/dist/run/step-runner.d.ts +17 -0
- package/dist/run/step-runner.d.ts.map +1 -0
- package/dist/run/step-runner.js +27 -0
- package/dist/run/step-runner.js.map +1 -0
- package/dist/scripts/commit-msg.d.ts +1 -1
- package/dist/scripts/commit-msg.d.ts.map +1 -1
- package/dist/scripts/commit-msg.js +9 -8
- package/dist/scripts/commit-msg.js.map +1 -1
- package/dist/scripts/pre-commit.d.ts +1 -1
- package/dist/scripts/pre-commit.d.ts.map +1 -1
- package/dist/scripts/pre-commit.js +10 -35
- package/dist/scripts/pre-commit.js.map +1 -1
- package/dist/scripts/pre-push.d.ts +1 -1
- package/dist/scripts/pre-push.d.ts.map +1 -1
- package/dist/scripts/pre-push.js +8 -24
- package/dist/scripts/pre-push.js.map +1 -1
- package/dist/snapshot/snapshot.d.ts.map +1 -1
- package/dist/snapshot/snapshot.js +6 -4
- package/dist/snapshot/snapshot.js.map +1 -1
- package/dist/snapshot/snapshots.d.ts.map +1 -1
- package/dist/snapshot/snapshots.js +4 -5
- package/dist/snapshot/snapshots.js.map +1 -1
- package/dist/testing.d.ts +23 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +41 -0
- package/dist/testing.js.map +1 -0
- package/package.json +10 -4
- package/dist/snapshot/nx.d.ts +0 -7
- package/dist/snapshot/nx.d.ts.map +0 -1
- package/dist/snapshot/nx.js +0 -20
- package/dist/snapshot/nx.js.map +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Commit } from "../commit.js";
|
|
2
|
+
import { gitIn } from "../git.js";
|
|
3
|
+
import { Snapshots } from "../snapshot/snapshots.js";
|
|
4
|
+
import { StepRunner } from "./step-runner.js";
|
|
5
|
+
// Runs the steps of a pre-commit hook on the staged commit. The snapshots
|
|
6
|
+
// that the steps open are deleted after the last step, also when a step fails
|
|
7
|
+
// or throws. When every step passed or skipped, the index must still hold the
|
|
8
|
+
// tree that the steps judged, with what they generated: another session that
|
|
9
|
+
// runs `git add` while the hook runs would put an unjudged change in the
|
|
10
|
+
// commit.
|
|
11
|
+
export async function runPreCommit({ root, hookEnvironment, toolEnvironment, print }, steps) {
|
|
12
|
+
const runner = new StepRunner(print);
|
|
13
|
+
await using snapshots = new Snapshots({
|
|
14
|
+
hook: 'pre-commit',
|
|
15
|
+
root,
|
|
16
|
+
git: gitIn(root, hookEnvironment),
|
|
17
|
+
toolEnvironment,
|
|
18
|
+
notice: runner.notice,
|
|
19
|
+
clock: globalThis,
|
|
20
|
+
});
|
|
21
|
+
let judged;
|
|
22
|
+
const commit = new Commit({
|
|
23
|
+
root,
|
|
24
|
+
environment: hookEnvironment,
|
|
25
|
+
snapshots,
|
|
26
|
+
notice: runner.notice,
|
|
27
|
+
generated: (tree) => {
|
|
28
|
+
judged = tree;
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
judged = (await commit.tree()).id;
|
|
32
|
+
const result = await runner.run(commit, steps);
|
|
33
|
+
if (result.kind === 'failed' || (await commit.tree()).id === judged)
|
|
34
|
+
return result;
|
|
35
|
+
return {
|
|
36
|
+
kind: 'stopped',
|
|
37
|
+
outcomes: result.outcomes,
|
|
38
|
+
reason: 'the index changed while the hook ran: another git command staged a change that the steps did not judge; commit again',
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=pre-commit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-commit.js","sourceRoot":"","sources":["../../src/run/pre-commit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0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-0,0 +1,14 @@
|
|
|
1
|
+
import { Push } from '../push.ts';
|
|
2
|
+
import type { Step } from '../step.ts';
|
|
3
|
+
import { type HookRun, type StepsResult } from './step-runner.ts';
|
|
4
|
+
interface PrePushRun extends HookRun {
|
|
5
|
+
readonly toolEnvironment: NodeJS.ProcessEnv;
|
|
6
|
+
readonly remote: {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly url: string;
|
|
9
|
+
};
|
|
10
|
+
readonly input: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function runPrePush({ root, hookEnvironment, toolEnvironment, print, remote, input }: PrePushRun, steps: readonly Step<Push>[]): Promise<StepsResult>;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=pre-push.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-push.d.ts","sourceRoot":"","sources":["../../src/run/pre-push.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,KAAK,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE9E,UAAU,UAAW,SAAQ,OAAO;IAElC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC,UAAU,CAAC;IAE5C,QAAQ,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IAEjE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAID,wBAAsB,UAAU,CAC9B,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,UAAU,EAC5E,KAAK,EAAE,SAAS,IAAI,CAAC,IAAI,CAAC,EAAE,GAC3B,OAAO,CAAC,WAAW,CAAC,CAmBtB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { gitIn } from "../git.js";
|
|
2
|
+
import { Push } from "../push.js";
|
|
3
|
+
import { Snapshots } from "../snapshot/snapshots.js";
|
|
4
|
+
import { StepRunner } from "./step-runner.js";
|
|
5
|
+
// Runs the steps of a pre-push hook on the push. The snapshots that the steps
|
|
6
|
+
// open are deleted after the last step, also when a step fails or throws.
|
|
7
|
+
export async function runPrePush({ root, hookEnvironment, toolEnvironment, print, remote, input }, steps) {
|
|
8
|
+
const runner = new StepRunner(print);
|
|
9
|
+
await using snapshots = new Snapshots({
|
|
10
|
+
hook: 'pre-push',
|
|
11
|
+
root,
|
|
12
|
+
git: gitIn(root, hookEnvironment),
|
|
13
|
+
toolEnvironment,
|
|
14
|
+
notice: runner.notice,
|
|
15
|
+
clock: globalThis,
|
|
16
|
+
});
|
|
17
|
+
const push = await Push.read({
|
|
18
|
+
root,
|
|
19
|
+
environment: hookEnvironment,
|
|
20
|
+
snapshots,
|
|
21
|
+
remote,
|
|
22
|
+
input,
|
|
23
|
+
});
|
|
24
|
+
// Awaited here, so the snapshots stay open until the last step ends.
|
|
25
|
+
return await runner.run(push, steps);
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=pre-push.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pre-push.js","sourceRoot":"","sources":["../../src/run/pre-push.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAErD,OAAO,EAAgB,UAAU,EAAoB,MAAM,kBAAkB,CAAC;AAW9E,8EAA8E;AAC9E,0EAA0E;AAC1E,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,EAAE,IAAI,EAAE,eAAe,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAc,EAC5E,KAA4B;IAE5B,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC;IACrC,YAAY,SAAS,GAAG,IAAI,SAAS,CAAC;QACpC,IAAI,EAAE,UAAU;QAChB,IAAI;QACJ,GAAG,EAAE,KAAK,CAAC,IAAI,EAAE,eAAe,CAAC;QACjC,eAAe;QACf,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,UAAU;KAClB,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;QAC3B,IAAI;QACJ,WAAW,EAAE,eAAe;QAC5B,SAAS;QACT,MAAM;QACN,KAAK;KACN,CAAC,CAAC;IACH,qEAAqE;IACrE,OAAO,MAAM,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Outcome, Step } from '../step.ts';
|
|
2
|
+
export interface HookRun {
|
|
3
|
+
readonly root: string;
|
|
4
|
+
readonly hookEnvironment: NodeJS.ProcessEnv;
|
|
5
|
+
readonly print: (name: string, message: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface StepsResult {
|
|
8
|
+
readonly kind: 'passed' | 'failed';
|
|
9
|
+
readonly outcomes: readonly Outcome[];
|
|
10
|
+
}
|
|
11
|
+
export declare class StepRunner {
|
|
12
|
+
#private;
|
|
13
|
+
constructor(print: (name: string, message: string) => void);
|
|
14
|
+
readonly notice: (message: string) => void;
|
|
15
|
+
run<Subject>(subject: Subject, steps: readonly Step<Subject>[]): Promise<StepsResult>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=step-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-runner.d.ts","sourceRoot":"","sources":["../../src/run/step-runner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAGhD,MAAM,WAAW,OAAO;IAEtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC,UAAU,CAAC;IAE5C,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACzD;AAID,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;CACvC;AAMD,qBAAa,UAAU;;gBAIT,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI;IAI1D,QAAQ,CAAC,MAAM,GAAI,SAAS,MAAM,KAAG,IAAI,CAEvC;IAEI,GAAG,CAAC,OAAO,EACf,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,IAAI,CAAC,OAAO,CAAC,EAAE,GAC9B,OAAO,CAAC,WAAW,CAAC;CAWxB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Runs the steps of a hook on one subject in order, and stops at the first
|
|
2
|
+
// fail. It prints the outcome of each step under the name of the step. A
|
|
3
|
+
// notice that the subject or its snapshots give while a step runs is printed
|
|
4
|
+
// under the name of that step too.
|
|
5
|
+
export class StepRunner {
|
|
6
|
+
#print;
|
|
7
|
+
#current = '';
|
|
8
|
+
constructor(print) {
|
|
9
|
+
this.#print = print;
|
|
10
|
+
}
|
|
11
|
+
notice = (message) => {
|
|
12
|
+
this.#print(this.#current, message);
|
|
13
|
+
};
|
|
14
|
+
async run(subject, steps) {
|
|
15
|
+
const outcomes = [];
|
|
16
|
+
for (const step of steps) {
|
|
17
|
+
this.#current = step.name;
|
|
18
|
+
const outcome = await step.run(subject);
|
|
19
|
+
outcomes.push(outcome);
|
|
20
|
+
this.#print(step.name, outcome.message);
|
|
21
|
+
if (outcome.kind === 'fail')
|
|
22
|
+
return { kind: 'failed', outcomes };
|
|
23
|
+
}
|
|
24
|
+
return { kind: 'passed', outcomes };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=step-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-runner.js","sourceRoot":"","sources":["../../src/run/step-runner.ts"],"names":[],"mappings":"AAmBA,2EAA2E;AAC3E,yEAAyE;AACzE,6EAA6E;AAC7E,mCAAmC;AACnC,MAAM,OAAO,UAAU;IACZ,MAAM,CAA0C;IACzD,QAAQ,GAAG,EAAE,CAAC;IAEd,YAAY,KAA8C;QACxD,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAEQ,MAAM,GAAG,CAAC,OAAe,EAAQ,EAAE;QAC1C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC,CAAC;IAEF,KAAK,CAAC,GAAG,CACP,OAAgB,EAChB,KAA+B;QAE/B,MAAM,QAAQ,GAAc,EAAE,CAAC;QAC/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;YAC1B,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACxC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;YACxC,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;gBAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;QACnE,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommitMessage } from '../commit-message.ts';
|
|
1
|
+
import type { CommitMessage } from '../commit-message.ts';
|
|
2
2
|
import type { Step } from '../step.ts';
|
|
3
3
|
export declare function commitMsg(steps: readonly Step<CommitMessage>[]): Promise<void>;
|
|
4
4
|
//# sourceMappingURL=commit-msg.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit-msg.d.ts","sourceRoot":"","sources":["../../src/scripts/commit-msg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"commit-msg.d.ts","sourceRoot":"","sources":["../../src/scripts/commit-msg.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAKvC,wBAAsB,SAAS,CAC7B,KAAK,EAAE,SAAS,IAAI,CAAC,aAAa,CAAC,EAAE,GACpC,OAAO,CAAC,IAAI,CAAC,CAaf"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { runCommitMsg } from "../run/commit-msg.js";
|
|
2
2
|
import { Host } from "./host.js";
|
|
3
3
|
// What a repo's `.husky/commit-msg.ts` calls. Git gives the hook the file that
|
|
4
4
|
// holds the message as its argument.
|
|
5
5
|
export async function commitMsg(steps) {
|
|
6
6
|
const host = new Host();
|
|
7
7
|
const [file = ''] = host.arguments;
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
host.print(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
const { kind } = await runCommitMsg({
|
|
9
|
+
root: host.root,
|
|
10
|
+
hookEnvironment: host.hookEnvironment,
|
|
11
|
+
print: (name, message) => host.print(name, message),
|
|
12
|
+
file,
|
|
13
|
+
}, steps);
|
|
14
|
+
if (kind === 'failed')
|
|
15
|
+
host.stop('commit stopped by the commit-msg hook');
|
|
15
16
|
}
|
|
16
17
|
//# sourceMappingURL=commit-msg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commit-msg.js","sourceRoot":"","sources":["../../src/scripts/commit-msg.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"commit-msg.js","sourceRoot":"","sources":["../../src/scripts/commit-msg.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,+EAA+E;AAC/E,qCAAqC;AACrC,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,KAAqC;IAErC,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACxB,MAAM,CAAC,IAAI,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;IACnC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,YAAY,CACjC;QACE,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC;QACnD,IAAI;KACL,EACD,KAAK,CACN,CAAC;IACF,IAAI,IAAI,KAAK,QAAQ;QAAE,IAAI,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pre-commit.d.ts","sourceRoot":"","sources":["../../src/scripts/pre-commit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"pre-commit.d.ts","sourceRoot":"","sources":["../../src/scripts/pre-commit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAIvC,wBAAsB,SAAS,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAc7E"}
|
|
@@ -1,42 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { gitIn } from "../git.js";
|
|
3
|
-
import { Snapshots } from "../snapshot/snapshots.js";
|
|
1
|
+
import { runPreCommit } from "../run/pre-commit.js";
|
|
4
2
|
import { Host } from "./host.js";
|
|
5
|
-
// What a repo's `.husky/pre-commit.ts` calls.
|
|
6
|
-
// open are deleted after the last step, also when a step fails or throws.
|
|
7
|
-
// When every step passed or skipped, the index must still hold the tree that
|
|
8
|
-
// the steps judged, with what they generated: another session that runs
|
|
9
|
-
// `git add` while the hook runs would put an unjudged change in the commit.
|
|
3
|
+
// What a repo's `.husky/pre-commit.ts` calls.
|
|
10
4
|
export async function preCommit(steps) {
|
|
11
5
|
const host = new Host();
|
|
12
|
-
|
|
13
|
-
await using snapshots = new Snapshots({
|
|
14
|
-
hook: 'pre-commit',
|
|
6
|
+
const result = await runPreCommit({
|
|
15
7
|
root: host.root,
|
|
16
|
-
|
|
8
|
+
hookEnvironment: host.hookEnvironment,
|
|
17
9
|
toolEnvironment: await host.toolEnvironment(),
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
environment: host.hookEnvironment,
|
|
25
|
-
snapshots,
|
|
26
|
-
notice: (message) => host.print(current, message),
|
|
27
|
-
generated: (tree) => {
|
|
28
|
-
judged = tree;
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
judged = (await commit.tree()).id;
|
|
32
|
-
for (const step of steps) {
|
|
33
|
-
current = step.name;
|
|
34
|
-
const outcome = await step.run(commit);
|
|
35
|
-
host.print(step.name, outcome.message);
|
|
36
|
-
if (outcome.kind === 'fail')
|
|
37
|
-
return host.stop('commit stopped by the pre-commit hook');
|
|
38
|
-
}
|
|
39
|
-
if ((await commit.tree()).id !== judged)
|
|
40
|
-
return host.stop('the index changed while the hook ran: another git command staged a change that the steps did not judge; commit again');
|
|
10
|
+
print: (name, message) => host.print(name, message),
|
|
11
|
+
}, steps);
|
|
12
|
+
if (result.kind === 'failed')
|
|
13
|
+
host.stop('commit stopped by the pre-commit hook');
|
|
14
|
+
if (result.kind === 'stopped')
|
|
15
|
+
host.stop(result.reason);
|
|
41
16
|
}
|
|
42
17
|
//# sourceMappingURL=pre-commit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pre-commit.js","sourceRoot":"","sources":["../../src/scripts/pre-commit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pre-commit.js","sourceRoot":"","sources":["../../src/scripts/pre-commit.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,8CAA8C;AAC9C,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,KAA8B;IAC5D,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACxB,MAAM,MAAM,GAAG,MAAM,YAAY,CAC/B;QACE,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,eAAe,EAAE,MAAM,IAAI,CAAC,eAAe,EAAE;QAC7C,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC;KACpD,EACD,KAAK,CACN,CAAC;IACF,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ;QAC1B,IAAI,CAAC,IAAI,CAAC,uCAAuC,CAAC,CAAC;IACrD,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;QAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pre-push.d.ts","sourceRoot":"","sources":["../../src/scripts/pre-push.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pre-push.d.ts","sourceRoot":"","sources":["../../src/scripts/pre-push.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAMvC,wBAAsB,OAAO,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAezE"}
|
package/dist/scripts/pre-push.js
CHANGED
|
@@ -1,36 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Push } from "../push.js";
|
|
3
|
-
import { Snapshots } from "../snapshot/snapshots.js";
|
|
1
|
+
import { runPrePush } from "../run/pre-push.js";
|
|
4
2
|
import { Host } from "./host.js";
|
|
5
3
|
// What a repo's `.husky/pre-push.ts` calls. Git gives the hook the name and
|
|
6
4
|
// the URL of the remote as arguments, and one ref update on each line of the
|
|
7
|
-
// standard input.
|
|
8
|
-
// last step, also when a step fails or throws.
|
|
5
|
+
// standard input.
|
|
9
6
|
export async function prePush(steps) {
|
|
10
7
|
const host = new Host();
|
|
11
|
-
let current = '';
|
|
12
8
|
const [name = '', url = ''] = host.arguments;
|
|
13
|
-
|
|
14
|
-
hook: 'pre-push',
|
|
9
|
+
const { kind } = await runPrePush({
|
|
15
10
|
root: host.root,
|
|
16
|
-
|
|
11
|
+
hookEnvironment: host.hookEnvironment,
|
|
17
12
|
toolEnvironment: await host.toolEnvironment(),
|
|
18
|
-
|
|
19
|
-
clock: globalThis,
|
|
20
|
-
});
|
|
21
|
-
const push = await Push.read({
|
|
22
|
-
root: host.root,
|
|
23
|
-
environment: host.hookEnvironment,
|
|
24
|
-
snapshots,
|
|
13
|
+
print: (step, message) => host.print(step, message),
|
|
25
14
|
remote: { name, url },
|
|
26
15
|
input: await host.input(),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const outcome = await step.run(push);
|
|
31
|
-
host.print(step.name, outcome.message);
|
|
32
|
-
if (outcome.kind === 'fail')
|
|
33
|
-
return host.stop('push stopped by the pre-push hook');
|
|
34
|
-
}
|
|
16
|
+
}, steps);
|
|
17
|
+
if (kind === 'failed')
|
|
18
|
+
host.stop('push stopped by the pre-push hook');
|
|
35
19
|
}
|
|
36
20
|
//# sourceMappingURL=pre-push.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pre-push.js","sourceRoot":"","sources":["../../src/scripts/pre-push.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pre-push.js","sourceRoot":"","sources":["../../src/scripts/pre-push.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,4EAA4E;AAC5E,6EAA6E;AAC7E,kBAAkB;AAClB,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,KAA4B;IACxD,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;IACxB,MAAM,CAAC,IAAI,GAAG,EAAE,EAAE,GAAG,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;IAC7C,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,UAAU,CAC/B;QACE,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,eAAe,EAAE,MAAM,IAAI,CAAC,eAAe,EAAE;QAC7C,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC;QACnD,MAAM,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE;QACrB,KAAK,EAAE,MAAM,IAAI,CAAC,KAAK,EAAE;KAC1B,EACD,KAAK,CACN,CAAC;IACF,IAAI,IAAI,KAAK,QAAQ;QAAE,IAAI,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/snapshot/snapshot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAI5C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAGD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAKD,qBAAa,QAAQ;;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAGZ,KAAK,EAAE,KAAK;
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/snapshot/snapshot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAI5C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAGD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD;AAKD,qBAAa,QAAQ;;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAGZ,KAAK,EAAE,KAAK;IAWlB,GAAG,CACP,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,aAAa,CAAC;CAmB1B;AAID,qBAAa,gBAAiB,SAAQ,QAAQ;IAE5C,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;gBAEtB,KAAK,EAAE,KAAK;IAOxB,GAAG,CACD,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,OAAO,GAAE,UAAe,GACvB,OAAO,CAAC,aAAa,CAAC;CAW1B"}
|
|
@@ -13,15 +13,17 @@ export class Snapshot {
|
|
|
13
13
|
}
|
|
14
14
|
// Runs a command from the PATH, or a file at an absolute path, in the
|
|
15
15
|
// snapshot. An exit code other than 0 is a result, not an error. A command
|
|
16
|
-
// that cannot start throws the error of Node. No shell runs, except
|
|
17
|
-
// .cmd file
|
|
18
|
-
//
|
|
16
|
+
// that cannot start throws the error of Node. No shell runs, except on
|
|
17
|
+
// Windows for a .cmd file and for a command from the PATH, which can be a
|
|
18
|
+
// .cmd file such as npm: Node starts a .cmd file only through a shell. The
|
|
19
|
+
// arguments then get no quotes.
|
|
19
20
|
async run(command, args, options = {}) {
|
|
20
21
|
const child = spawn(command, args, {
|
|
21
22
|
cwd: this.folder,
|
|
22
23
|
env: { ...this.#environment, ...options.env },
|
|
23
24
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
24
|
-
shell: process.platform === 'win32' &&
|
|
25
|
+
shell: process.platform === 'win32' &&
|
|
26
|
+
(command.endsWith('.cmd') || !/[\\/]/.test(command)),
|
|
25
27
|
});
|
|
26
28
|
const [stdout, stderr, status] = await Promise.all([
|
|
27
29
|
text(child.stdout),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/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,CAAC,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,IAAI,CACpD,EACD,IAAI,EACJ,OAAO,CACR,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshots.d.ts","sourceRoot":"","sources":["../../src/snapshot/snapshots.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"snapshots.d.ts","sourceRoot":"","sources":["../../src/snapshot/snapshots.ts"],"names":[],"mappings":"AAIA,OAAO,EAAS,KAAK,SAAS,EAAQ,MAAM,gBAAgB,CAAC;AAG7D,OAAO,EAAE,KAAK,GAAG,EAAS,MAAM,WAAW,CAAC;AAK5C,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,MAAM,EAAE,MAAM;CAI3B;AAGD,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC;IACxC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC;AAmBD,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,UAAU,CAAC;AAEjD,UAAU,gBAAgB;IACxB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAExB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAElB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC,UAAU,CAAC;IAE5C,QAAQ,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAG3C,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAKD,wBAAsB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAS3D;AAOD,qBAAa,SAAU,YAAW,eAAe;;IAC/C,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC,UAAU,CAAC;gBAWhC,EACV,IAAI,EACJ,IAAI,EACJ,GAAG,EACH,eAAe,EACf,MAAM,EACN,KAAK,GACN,EAAE,gBAAgB;IAWb,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC;IAmBrE,WAAW,CACf,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,KAAK,GAAG,eAAe,CAAC;IAe7B,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAoH7C"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
|
-
import { mkdir
|
|
3
|
-
import { tmpdir } from 'node:os';
|
|
2
|
+
import { mkdir } from 'node:fs/promises';
|
|
4
3
|
import { join } from 'node:path';
|
|
5
4
|
import { Latch, poll } from '@zukhruf/async';
|
|
6
|
-
import { FileLock } from '@zukhruf/fs';
|
|
5
|
+
import { FileLock, TemporaryFiles } from '@zukhruf/fs';
|
|
7
6
|
import { gitIn } from "../git.js";
|
|
8
7
|
import { hasInstallDrift } from "./drift.js";
|
|
9
8
|
import { installFor, leaseInstall } from "./installs.js";
|
|
@@ -111,8 +110,8 @@ export class Snapshots {
|
|
|
111
110
|
}
|
|
112
111
|
async #clone(commit, resources) {
|
|
113
112
|
const cache = join(await stateFolder(this.#git), this.#hook === 'pre-push' ? 'nx' : 'nx-pre-commit');
|
|
114
|
-
const temporary = resources.use(await
|
|
115
|
-
const folder = join(
|
|
113
|
+
const temporary = resources.use(await new TemporaryFiles().directory('git-hooks-snapshot-'));
|
|
114
|
+
const folder = join(temporary.path, 'tree');
|
|
116
115
|
await gitIn(temporary.path, this.toolEnvironment)('clone', '--shared', '--no-checkout', '--quiet', this.#root, folder);
|
|
117
116
|
await gitIn(folder, this.toolEnvironment)('checkout', '--detach', '--quiet', commit);
|
|
118
117
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshots.js","sourceRoot":"","sources":["../../src/snapshot/snapshots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"snapshots.js","sourceRoot":"","sources":["../../src/snapshot/snapshots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAkB,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAY,KAAK,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,MAAc;QACxB,KAAK,CAAC,GAAG,MAAM,2BAA2B,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AA4CD,0EAA0E;AAC1E,6EAA6E;AAC7E,gBAAgB;AAChB,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,GAAQ;IACxC,MAAM,KAAK,GAAG,IAAI,CAChB,CACE,MAAM,GAAG,CAAC,WAAW,EAAE,wBAAwB,EAAE,kBAAkB,CAAC,CACrE,CAAC,IAAI,EAAE,EACR,WAAW,CACZ,CAAC;IACF,MAAM,KAAK,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;I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AS,SAAS,CAAI,IAAsB;IAC1C,MAAM,OAAO,GAAe,IAAI,KAAK,EAAE,CAAC;IACxC,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,CAC7D,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CACrB,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,KAAK,UAAU,OAAO,CAAI,OAAmB;IAC3C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IACpC,IAAI,MAAM,CAAC,MAAM,KAAK,UAAU;QAAE,MAAM,MAAM,CAAC,MAAM,CAAC;IACtD,OAAO,MAAM,CAAC,KAAK,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { CommitMessage } from './commit-message.ts';
|
|
2
|
+
import type { Commit } from './commit.ts';
|
|
3
|
+
import type { Push } from './push.ts';
|
|
4
|
+
import type { Outcome, Step } from './step.ts';
|
|
5
|
+
export declare function preCommit({ root, environment }: {
|
|
6
|
+
root: string;
|
|
7
|
+
environment: NodeJS.ProcessEnv;
|
|
8
|
+
}, steps: readonly Step<Commit>[]): Promise<readonly Outcome[]>;
|
|
9
|
+
export declare function prePush({ root, environment, remote, input, }: {
|
|
10
|
+
root: string;
|
|
11
|
+
environment: NodeJS.ProcessEnv;
|
|
12
|
+
remote: {
|
|
13
|
+
name: string;
|
|
14
|
+
url: string;
|
|
15
|
+
};
|
|
16
|
+
input: string;
|
|
17
|
+
}, steps: readonly Step<Push>[]): Promise<readonly Outcome[]>;
|
|
18
|
+
export declare function commitMsg({ root, environment, file, }: {
|
|
19
|
+
root: string;
|
|
20
|
+
environment: NodeJS.ProcessEnv;
|
|
21
|
+
file: string;
|
|
22
|
+
}, steps: readonly Step<CommitMessage>[]): Promise<readonly Outcome[]>;
|
|
23
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,OAAO,CAAC,SAAS,OAAO,EAAE,CAAC,CAM7B"}
|
package/dist/testing.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { withoutRepoVariables } from "./repo-variables.js";
|
|
2
|
+
import { runCommitMsg } from "./run/commit-msg.js";
|
|
3
|
+
import { runPreCommit } from "./run/pre-commit.js";
|
|
4
|
+
import { runPrePush } from "./run/pre-push.js";
|
|
5
|
+
// Each function runs steps as its hook runs them, on the repo at `root`, and
|
|
6
|
+
// gives the outcome of each step that ran, so a repo tests its own steps
|
|
7
|
+
// through the real loop. `environment` stands for the hook environment.
|
|
8
|
+
// Runs pre-commit steps on the staged commit. When the hook would stop the
|
|
9
|
+
// commit after the steps, such as when the index changed while they ran, the
|
|
10
|
+
// last outcome is that fail.
|
|
11
|
+
export async function preCommit({ root, environment }, steps) {
|
|
12
|
+
const result = await runPreCommit({
|
|
13
|
+
root,
|
|
14
|
+
hookEnvironment: environment,
|
|
15
|
+
toolEnvironment: await withoutRepoVariables(environment),
|
|
16
|
+
print: () => { },
|
|
17
|
+
}, steps);
|
|
18
|
+
return result.kind === 'stopped'
|
|
19
|
+
? [...result.outcomes, { kind: 'fail', message: result.reason }]
|
|
20
|
+
: result.outcomes;
|
|
21
|
+
}
|
|
22
|
+
// Runs pre-push steps on a push to `remote`. `input` holds the lines that git
|
|
23
|
+
// gives the hook on its standard input: `<local ref> <local sha> <remote ref>
|
|
24
|
+
// <remote sha>` for each ref update.
|
|
25
|
+
export async function prePush({ root, environment, remote, input, }, steps) {
|
|
26
|
+
const { outcomes } = await runPrePush({
|
|
27
|
+
root,
|
|
28
|
+
hookEnvironment: environment,
|
|
29
|
+
toolEnvironment: await withoutRepoVariables(environment),
|
|
30
|
+
print: () => { },
|
|
31
|
+
remote,
|
|
32
|
+
input,
|
|
33
|
+
}, steps);
|
|
34
|
+
return outcomes;
|
|
35
|
+
}
|
|
36
|
+
// Runs commit-msg steps on the message in `file`.
|
|
37
|
+
export async function commitMsg({ root, environment, file, }, steps) {
|
|
38
|
+
const { outcomes } = await runCommitMsg({ root, hookEnvironment: environment, print: () => { }, file }, steps);
|
|
39
|
+
return outcomes;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,6EAA6E;AAC7E,yEAAyE;AACzE,wEAAwE;AAExE,2EAA2E;AAC3E,6EAA6E;AAC7E,6BAA6B;AAC7B,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,EAAE,IAAI,EAAE,WAAW,EAAoD,EACvE,KAA8B;IAE9B,MAAM,MAAM,GAAG,MAAM,YAAY,CAC/B;QACE,IAAI;QACJ,eAAe,EAAE,WAAW;QAC5B,eAAe,EAAE,MAAM,oBAAoB,CAAC,WAAW,CAAC;QACxD,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;KAChB,EACD,KAAK,CACN,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,KAAK,SAAS;QAC9B,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QAChE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC;AACtB,CAAC;AAED,8EAA8E;AAC9E,8EAA8E;AAC9E,qCAAqC;AACrC,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,EACE,IAAI,EACJ,WAAW,EACX,MAAM,EACN,KAAK,GAMN,EACD,KAA4B;IAE5B,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,UAAU,CACnC;QACE,IAAI;QACJ,eAAe,EAAE,WAAW;QAC5B,eAAe,EAAE,MAAM,oBAAoB,CAAC,WAAW,CAAC;QACxD,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;QACf,MAAM;QACN,KAAK;KACN,EACD,KAAK,CACN,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,kDAAkD;AAClD,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,EACE,IAAI,EACJ,WAAW,EACX,IAAI,GAC2D,EACjE,KAAqC;IAErC,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,YAAY,CACrC,EAAE,IAAI,EAAE,eAAe,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,IAAI,EAAE,EAC7D,KAAK,CACN,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zukhruf/git-hooks",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.22",
|
|
4
4
|
"description": "Git hooks in TypeScript, a class per step. Pre-commit checks staged files with Prettier, stages only what nx sync wrote, and builds generated files. Commit-msg stops a subject whose scope nx release misreads. Pre-push builds pushed commits in snapshots.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,6 +35,12 @@
|
|
|
35
35
|
"types": "./dist/index.d.ts",
|
|
36
36
|
"import": "./dist/index.js",
|
|
37
37
|
"default": "./dist/index.js"
|
|
38
|
+
},
|
|
39
|
+
"./testing": {
|
|
40
|
+
"@zukhruf/source": "./src/testing.ts",
|
|
41
|
+
"types": "./dist/testing.d.ts",
|
|
42
|
+
"import": "./dist/testing.js",
|
|
43
|
+
"default": "./dist/testing.js"
|
|
38
44
|
}
|
|
39
45
|
},
|
|
40
46
|
"files": [
|
|
@@ -47,8 +53,8 @@
|
|
|
47
53
|
"access": "public"
|
|
48
54
|
},
|
|
49
55
|
"dependencies": {
|
|
50
|
-
"@zukhruf/async": "^0.8.
|
|
51
|
-
"@zukhruf/fs": "^0.8.
|
|
56
|
+
"@zukhruf/async": "^0.8.22",
|
|
57
|
+
"@zukhruf/fs": "^0.8.22"
|
|
52
58
|
},
|
|
53
59
|
"peerDependencies": {
|
|
54
60
|
"eslint": "^9.30.0 || ^10.0.0",
|
|
@@ -64,7 +70,7 @@
|
|
|
64
70
|
}
|
|
65
71
|
},
|
|
66
72
|
"devDependencies": {
|
|
67
|
-
"@zukhruf/testing": "^0.8.
|
|
73
|
+
"@zukhruf/testing": "^0.8.22",
|
|
68
74
|
"eslint": "^10.12.0",
|
|
69
75
|
"jsonc-eslint-parser": "^3.3.0",
|
|
70
76
|
"prettier": "^3.9.9"
|
package/dist/snapshot/nx.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nx.d.ts","sourceRoot":"","sources":["../../src/snapshot/nx.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAID,wBAAgB,KAAK,CACnB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,CAAC,UAAU,EAC9B,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,OAAO,CAAC,KAAK,CAAC,CAoBhB"}
|
package/dist/snapshot/nx.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { execFile } from 'node:child_process';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
// Runs the nx of the snapshot's node_modules in the snapshot. On Windows,
|
|
4
|
-
// npm writes `.bin/nx.cmd`, which only a shell runs.
|
|
5
|
-
export function runNx(folder, environment, args) {
|
|
6
|
-
const windows = process.platform === 'win32';
|
|
7
|
-
return new Promise((resolve) => {
|
|
8
|
-
execFile(join(folder, 'node_modules/.bin', windows ? 'nx.cmd' : 'nx'), args, {
|
|
9
|
-
cwd: folder,
|
|
10
|
-
env: environment,
|
|
11
|
-
encoding: 'utf8',
|
|
12
|
-
maxBuffer: 2 ** 30,
|
|
13
|
-
shell: windows,
|
|
14
|
-
}, (error, stdout, stderr) => {
|
|
15
|
-
const code = error === null ? 0 : typeof error.code === 'number' ? error.code : 1;
|
|
16
|
-
resolve({ code, stdout, stderr });
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=nx.js.map
|