amont 1.15.0 → 1.17.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/README.md +2 -2
- package/bin/amont.js +2 -89
- package/package.json +11 -8
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
A single Rust binary that checks `git commit` and `git push` — no YAML to
|
|
10
10
|
write, no runtime to install, nothing to configure before it is useful.
|
|
11
11
|
|
|
12
|
-
- **Useful in the first minute.** Thirty-
|
|
12
|
+
- **Useful in the first minute.** Thirty-three built-in checks — commit-message
|
|
13
13
|
conventions, merge-conflict markers, the linters and formatters for the
|
|
14
14
|
languages your repository actually uses, branch rules, your test suite —
|
|
15
15
|
and each one fires only where the repository has opted into its tool.
|
|
@@ -136,7 +136,7 @@ pre-push
|
|
|
136
136
|
● runs here ○ inert ⊘ skipped via hook.skip ✗ declaration unusable
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
Thirty-
|
|
139
|
+
Thirty-three built-in checks across five git hooks, plus any your repository declares
|
|
140
140
|
itself. The full list, with what each one needs before it fires, is in
|
|
141
141
|
[the checks reference](docs/checks.md).
|
|
142
142
|
|
package/bin/amont.js
CHANGED
|
@@ -1,90 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
3
|
-
|
|
4
|
-
// This wrapper exists only because a package manager can link a `bin` that
|
|
5
|
-
// lives inside the package, and the native executable lives in a DIFFERENT
|
|
6
|
-
// package — one of six, selected by npm from `os`/`cpu`/`libc`.
|
|
7
|
-
//
|
|
8
|
-
// It is not on the hook path. `amont init` bakes `current_exe()` — the native
|
|
9
|
-
// binary this spawns, not this file — into `.git/hooks`, so the ~30ms of node
|
|
10
|
-
// start-up below is paid once during `prepare` and never again on a commit.
|
|
11
|
-
// See npm/README.md.
|
|
12
|
-
|
|
13
|
-
const { spawnSync } = require("node:child_process");
|
|
14
|
-
const { existsSync } = require("node:fs");
|
|
15
|
-
|
|
16
|
-
// The same six targets `release.yaml` builds, spelled the way npm spells them.
|
|
17
|
-
// `libc` is why linux-x64 appears twice: a musl host cannot run the glibc build,
|
|
18
|
-
// and npm will install only the package whose `libc` matches.
|
|
19
|
-
const PACKAGES = {
|
|
20
|
-
"darwin arm64": "amont-darwin-arm64",
|
|
21
|
-
"darwin x64": "amont-darwin-x64",
|
|
22
|
-
"linux arm64": "amont-linux-arm64-gnu",
|
|
23
|
-
"linux x64": ["amont-linux-x64-gnu", "amont-linux-x64-musl"],
|
|
24
|
-
"win32 x64": "amont-win32-x64",
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function candidates() {
|
|
28
|
-
const found = PACKAGES[`${process.platform} ${process.arch}`];
|
|
29
|
-
if (!found) return [];
|
|
30
|
-
return Array.isArray(found) ? found : [found];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// `require.resolve` rather than a hand-built `../amont-<target>/bin/…` path.
|
|
34
|
-
// pnpm does not hoist — the real package sits under `node_modules/.pnpm/` — so a
|
|
35
|
-
// path assembled from `__dirname` is correct under npm and wrong under pnpm and
|
|
36
|
-
// yarn. Node's own resolver knows where the dependency actually is.
|
|
37
|
-
function binaryOf(pkg) {
|
|
38
|
-
const exe = process.platform === "win32" ? "amont.exe" : "amont";
|
|
39
|
-
try {
|
|
40
|
-
const p = require.resolve(`${pkg}/bin/${exe}`);
|
|
41
|
-
if (existsSync(p)) return p;
|
|
42
|
-
} catch {
|
|
43
|
-
// Not installed: either the wrong libc for this host, or an
|
|
44
|
-
// `--ignore-scripts`-style install that skipped optional deps.
|
|
45
|
-
}
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Existence is not runnability, so the loop is over SPAWNS, not paths. With a
|
|
50
|
-
// package manager that ignores the `libc` field — yarn classic does, and
|
|
51
|
-
// `npm install --force` is this file's own suggested remedy — BOTH linux-x64
|
|
52
|
-
// builds get installed, gnu listed first, and on a musl host the gnu binary
|
|
53
|
-
// fails at exec on the missing glibc loader while the right one sits a
|
|
54
|
-
// candidate later. Only a spawn-level failure (`result.error`) falls through:
|
|
55
|
-
// a binary that ran and exited non-zero has ANSWERED, and its exit code is the
|
|
56
|
-
// whole product of a hook runner.
|
|
57
|
-
const failures = [];
|
|
58
|
-
for (const pkg of candidates()) {
|
|
59
|
-
const binary = binaryOf(pkg);
|
|
60
|
-
if (!binary) continue;
|
|
61
|
-
// `spawnSync` with inherited stdio rather than `execFileSync`: this forwards
|
|
62
|
-
// the child's exit CODE. It also keeps the child's stdin, which `amont run`
|
|
63
|
-
// reads.
|
|
64
|
-
const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
|
|
65
|
-
if (result.error) {
|
|
66
|
-
failures.push(` ${binary}: ${result.error.message}`);
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
// A signalled child has a null status. Report it the way a shell does, so
|
|
70
|
-
// "killed by SIGINT" does not read as a clean exit 0.
|
|
71
|
-
if (result.status === null && result.signal) {
|
|
72
|
-
process.exit(128 + (require("node:os").constants.signals[result.signal] ?? 0));
|
|
73
|
-
}
|
|
74
|
-
process.exit(result.status ?? 1);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Name the platform. "amont binary not found" sends people to reinstall;
|
|
78
|
-
// "no build for linux/ppc64" tells them the actual answer, which is that they
|
|
79
|
-
// want `cargo install amont` or the shell installer.
|
|
80
|
-
const target = `${process.platform}/${process.arch}`;
|
|
81
|
-
process.stderr.write(
|
|
82
|
-
`amont: no runnable native binary for ${target}.\n` +
|
|
83
|
-
(failures.length ? ` Installed but could not run:\n${failures.join("\n")}\n` : "") +
|
|
84
|
-
` npm installs one of: ${Object.values(PACKAGES).flat().join(", ")}\n` +
|
|
85
|
-
` If your platform is not among them, build from source:\n` +
|
|
86
|
-
` cargo install amont\n` +
|
|
87
|
-
` If it is, the optional dependency did not install — try:\n` +
|
|
88
|
-
` npm install --force amont\n`,
|
|
89
|
-
);
|
|
90
|
-
process.exit(1);
|
|
2
|
+
// The hook runtime. See ./native.js for how the platform binary is found.
|
|
3
|
+
require("./native.js").become("amont");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amont",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Opinionated git hooks that judge what you are committing, not what is on disk",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"git",
|
|
@@ -21,21 +21,24 @@
|
|
|
21
21
|
"author": "Frederic Rousseau",
|
|
22
22
|
"type": "commonjs",
|
|
23
23
|
"bin": {
|
|
24
|
-
"amont": "bin/amont.js"
|
|
24
|
+
"amont": "bin/amont.js",
|
|
25
|
+
"amont-agent": "bin/amont-agent.js"
|
|
25
26
|
},
|
|
26
27
|
"files": [
|
|
27
28
|
"bin/amont.js",
|
|
29
|
+
"bin/amont-agent.js",
|
|
30
|
+
"bin/native.js",
|
|
28
31
|
"README.md"
|
|
29
32
|
],
|
|
30
33
|
"engines": {
|
|
31
34
|
"node": ">=18"
|
|
32
35
|
},
|
|
33
36
|
"optionalDependencies": {
|
|
34
|
-
"amont-darwin-arm64": "1.
|
|
35
|
-
"amont-darwin-x64": "1.
|
|
36
|
-
"amont-linux-arm64-gnu": "1.
|
|
37
|
-
"amont-linux-x64-gnu": "1.
|
|
38
|
-
"amont-linux-x64-musl": "1.
|
|
39
|
-
"amont-win32-x64": "1.
|
|
37
|
+
"amont-darwin-arm64": "1.17.0",
|
|
38
|
+
"amont-darwin-x64": "1.17.0",
|
|
39
|
+
"amont-linux-arm64-gnu": "1.17.0",
|
|
40
|
+
"amont-linux-x64-gnu": "1.17.0",
|
|
41
|
+
"amont-linux-x64-musl": "1.17.0",
|
|
42
|
+
"amont-win32-x64": "1.17.0"
|
|
40
43
|
}
|
|
41
44
|
}
|