@j178/prek 0.3.9 → 0.3.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.10
4
+
5
+ Released on 2026-04-21.
6
+
7
+ ### Enhancements
8
+
9
+ - Disallow rev for non-remote repos in schema ([#1964](https://github.com/j178/prek/pull/1964))
10
+ - Hide up-to-date output in non-verbose mode ([#1942](https://github.com/j178/prek/pull/1942))
11
+ - Improve merge conflict marker detection ([#1937](https://github.com/j178/prek/pull/1937))
12
+ - Keep finished hooks visible ([#1967](https://github.com/j178/prek/pull/1967))
13
+ - Preserve frozen comment spacing in auto-update ([#1945](https://github.com/j178/prek/pull/1945))
14
+ - Reimplement `@j178/prek` npm package ([#1973](https://github.com/j178/prek/pull/1973))
15
+
16
+ ### Bug fixes
17
+
18
+ - Prefer stable Rust toolchains ([#1974](https://github.com/j178/prek/pull/1974))
19
+
20
+ ### Documentation
21
+
22
+ - Add `SKILL.md` for prek ([#1950](https://github.com/j178/prek/pull/1950))
23
+ - Document `gh skill install j178/prek prek` to install prek skill for agents ([#1951](https://github.com/j178/prek/pull/1951))
24
+ - Improve compatibility and migration docs ([#1940](https://github.com/j178/prek/pull/1940))
25
+
26
+ ### Other changes
27
+
28
+ - Sync latest identify tags ([#1947](https://github.com/j178/prek/pull/1947))
29
+
30
+ ### Contributors
31
+
32
+ - @github-actions
33
+ - @renovate
34
+ - @j178
35
+
3
36
  ## 0.3.9
4
37
 
5
38
  Released on 2026-04-13.
package/README.md CHANGED
@@ -65,7 +65,7 @@ On Linux and macOS:
65
65
  <!-- --8<-- [start: linux-standalone-install] -->
66
66
 
67
67
  ```bash
68
- curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prek/releases/download/v0.3.9/prek-installer.sh | sh
68
+ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prek/releases/download/v0.3.10/prek-installer.sh | sh
69
69
  ```
70
70
 
71
71
  <!-- --8<-- [end: linux-standalone-install] -->
@@ -75,7 +75,7 @@ On Windows:
75
75
  <!-- --8<-- [start: windows-standalone-install] -->
76
76
 
77
77
  ```powershell
78
- powershell -ExecutionPolicy ByPass -c "irm https://github.com/j178/prek/releases/download/v0.3.9/prek-installer.ps1 | iex"
78
+ powershell -ExecutionPolicy ByPass -c "irm https://github.com/j178/prek/releases/download/v0.3.10/prek-installer.ps1 | iex"
79
79
  ```
80
80
 
81
81
  <!-- --8<-- [end: windows-standalone-install] -->
@@ -319,6 +319,21 @@ prek is also available via [`taiki-e/install-action`](https://github.com/taiki-e
319
319
 
320
320
  </details>
321
321
 
322
+ <details>
323
+ <summary>prek skill for agents</summary>
324
+
325
+ <!-- --8<-- [start: gh-skill-install] -->
326
+
327
+ To let agents use `prek`, install the `prek` skill with `gh skill` (`v2.90.0+`):
328
+
329
+ ```bash
330
+ gh skill install j178/prek prek
331
+ ```
332
+
333
+ <!-- --8<-- [end: gh-skill-install] -->
334
+
335
+ </details>
336
+
322
337
  <!-- --8<-- [start: self-update] -->
323
338
 
324
339
  If installed via the standalone installer, prek can update itself to the latest version:
@@ -340,66 +355,66 @@ prek self update
340
355
 
341
356
  ### prek is faster
342
357
 
343
- - It is [multiple times faster](https://prek.j178.dev/benchmark/) than `pre-commit` and takes up half the disk space.
344
- - It redesigned how hook environments and toolchains are managed, they are all shared between hooks, which reduces the disk space usage and speeds up the installation process.
345
- - Repositories are cloned in parallel, and hooks are installed in parallel if their dependencies are disjoint.
346
- - Hooks can run in parallel by priority (hooks with the same [`priority`](https://prek.j178.dev/configuration/#priority) may run concurrently), reducing end-to-end runtime.
358
+ - It is [multiple times faster](https://prek.j178.dev/benchmark/) than `pre-commit` while also using less disk space.
359
+ - Hook environments and toolchains are shared across hooks instead of being duplicated per repository, which reduces both install time and cache size.
360
+ - Repositories are fetched in parallel, hook environments are prepared in parallel when their dependencies do not overlap, and hooks can run concurrently by [`priority`](https://prek.j178.dev/configuration/#priority).
347
361
  - It uses [`uv`](https://github.com/astral-sh/uv) for creating Python virtualenvs and installing dependencies, which is known for its speed and efficiency.
348
- - It implements some common hooks in Rust, [built in prek](https://prek.j178.dev/builtin/), which are faster than their Python counterparts.
362
+ - It implements some common hooks in Rust as [builtins](https://prek.j178.dev/builtin/), which are faster than their Python counterparts.
349
363
  - It supports `repo: builtin` for offline, zero-setup hooks, which is not available in `pre-commit`.
350
364
 
351
- ### prek provides a better user experience
365
+ ### prek is easier to work with
366
+
367
+ - No need to install Python or any other runtime just to use `prek`; it is a single binary.
368
+ - `prek` automatically installs the toolchains it needs for supported languages, so you spend less time managing Python versions, Node runtimes, Ruby installs, and similar setup.
369
+ - It supports native [`prek.toml`](https://prek.j178.dev/configuration/) in addition to pre-commit YAML, and [`prek util yaml-to-toml`](https://prek.j178.dev/cli/#prek-util-yaml-to-toml) helps migrate existing configs.
370
+ - Built-in support for [workspaces](https://prek.j178.dev/workspace/) means monorepos can keep separate configs per project and still run everything from one command.
371
+ - [`prek install`](https://prek.j178.dev/cli/#prek-install) and [`prek uninstall`](https://prek.j178.dev/cli/#prek-uninstall) honor repo-local and worktree-local `core.hooksPath`.
372
+ - [`prek run`](https://prek.j178.dev/cli/#prek-run) supports selecting or skipping multiple projects or hooks in workspace mode, instead of only accepting a single optional hook id, and adds quality-of-life improvements such as `--dry-run`, `--directory`, `--last-commit`, and `--no-fail-fast`.
373
+ - [`prek list`](https://prek.j178.dev/cli/#prek-list), [`prek util identify`](https://prek.j178.dev/cli/#prek-util-identify), and [`prek util list-builtins`](https://prek.j178.dev/cli/#prek-util-list-builtins) make it easier to inspect configured hooks, debug file matching, and discover builtins.
374
+
375
+ ### prek includes security-focused safeguards
352
376
 
353
- - No need to install Python or any other runtime, just download a single binary.
354
- - No hassle with your Python version or virtual environments, prek automatically installs the required Python version and creates a virtual environment for you.
355
- - Built-in support for [workspaces](https://prek.j178.dev/workspace/) (or monorepos), each subproject can have its own `.pre-commit-config.yaml` file.
356
- - [`prek run`](https://prek.j178.dev/cli/#prek-run) has some nifty improvements over `pre-commit run`, such as:
357
- - `prek run --directory <dir>` runs hooks for files in the specified directory, no need to use `git ls-files -- <dir> | xargs pre-commit run --files` anymore.
358
- - `prek run --last-commit` runs hooks for files changed in the last commit.
359
- - `prek run [HOOK] [HOOK]` selects and runs multiple hooks.
360
- - [`prek list`](https://prek.j178.dev/cli/#prek-list) command lists all available hooks, their ids, and descriptions, providing a better overview of the configured hooks.
361
- - [`prek auto-update`](https://prek.j178.dev/cli/#prek-auto-update) supports `--cooldown-days` to mitigate open source supply chain attacks.
362
- - prek provides shell completions for `prek run <hook_id>` command, making it easier to run specific hooks without remembering their ids.
377
+ - [`prek auto-update`](https://prek.j178.dev/cli/#prek-auto-update) supports `--cooldown-days`, so you can keep newly published releases on hold for a cooling-off period before adopting them.
378
+ - [`prek auto-update`](https://prek.j178.dev/cli/#prek-auto-update) validates pinned SHA revisions against the fetched upstream refs, including impostor-commit detection, and keeps `# frozen:` comments in sync with the configured commit.
379
+ - [`prek auto-update --check`](https://prek.j178.dev/cli/#prek-auto-update--check) is useful in CI when you want updates or frozen-reference mismatches to fail the job without rewriting the config.
363
380
 
364
381
  For more detailed improvements prek offers, take a look at [Difference from pre-commit](https://prek.j178.dev/diff/).
365
382
 
366
383
  ## Who is using prek?
367
384
 
368
- prek is pretty new, but it is already being used or recommend by some projects and organizations:
369
-
370
- - [apache/airflow](https://github.com/apache/airflow/issues/44995)
371
- - [python/cpython](https://github.com/python/cpython/issues/143148)
372
- - [pdm-project/pdm](https://github.com/pdm-project/pdm/pull/3593)
373
- - [fastapi/fastapi](https://github.com/fastapi/fastapi/pull/14572)
374
- - [fastapi/typer](https://github.com/fastapi/typer/pull/1453)
375
- - [fastapi/asyncer](https://github.com/fastapi/asyncer/pull/437)
376
- - [astral-sh/ruff](https://github.com/astral-sh/ruff/pull/22505)
377
- - [astral-sh/ty](https://github.com/astral-sh/ty/pull/2469)
378
- - [openclaw/openclaw](https://github.com/openclaw/openclaw/pull/1720)
379
- - [home-assistant/core](https://github.com/home-assistant/core/pull/160427)
380
- - [python-telegram-bot/python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot/pull/5142)
381
- - [DetachHead/basedpyright](https://github.com/DetachHead/basedpyright/pull/1413)
382
- - [OpenLineage/OpenLineage](https://github.com/OpenLineage/OpenLineage/pull/3965)
383
- - [authlib/authlib](https://github.com/authlib/authlib/pull/804)
384
- - [django/djangoproject.com](https://github.com/django/djangoproject.com/pull/2252)
385
- - [Future-House/paper-qa](https://github.com/Future-House/paper-qa/pull/1098)
386
- - [requests-cache/requests-cache](https://github.com/requests-cache/requests-cache/pull/1116)
387
- - [Goldziher/kreuzberg](https://github.com/Goldziher/kreuzberg/pull/142)
388
- - [python-attrs/attrs](https://github.com/python-attrs/attrs/commit/c95b177682e76a63478d29d040f9cb36a8d31915)
389
- - [jlowin/fastmcp](https://github.com/jlowin/fastmcp/pull/2309)
390
- - [apache/iceberg-python](https://github.com/apache/iceberg-python/pull/2533)
391
- - [apache/iggy](https://github.com/apache/iggy/pull/2383)
392
- - [apache/lucene](https://github.com/apache/lucene/pull/15629)
393
- - [jcrist/msgspec](https://github.com/jcrist/msgspec/pull/918)
394
- - [python-humanize/humanize](https://github.com/python-humanize/humanize/pull/276)
395
- - [MoonshotAI/kimi-cli](https://github.com/MoonshotAI/kimi-cli/pull/535)
396
- - [simple-icons/simple-icons](https://github.com/simple-icons/simple-icons/pull/14245)
397
- - [ast-grep/ast-grep](https://github.com/ast-grep/ast-grep.github.io/commit/e30818144b2967a7f9172c8cf2f4596bba219bf5)
398
- - [commitizen-tools/commitizen](https://github.com/commitizen-tools/commitizen)
399
- - [cocoindex-io/cocoindex](https://github.com/cocoindex-io/cocoindex/pull/1564)
400
- - [cachix/devenv](https://github.com/cachix/devenv/pull/2304)
401
- - [copper-project/copper-rs](https://github.com/copper-project/copper-rs/pull/783)
402
- - [bramstroker/homeassistant-powercalc](https://github.com/bramstroker/homeassistant-powercalc/pull/3978)
385
+ prek is pretty new, but it is already being used or recommended by some projects and organizations.
386
+ GitHub stars are current as of April 15, 2026.
387
+
388
+ - [apache/airflow](https://github.com/apache/airflow/issues/44995) <sub>45,050 stars</sub>
389
+ - [python/cpython](https://github.com/python/cpython/issues/143148) <sub>72,330 stars</sub>
390
+ - [pdm-project/pdm](https://github.com/pdm-project/pdm/pull/3593) <sub>8,553 stars</sub>
391
+ - [fastapi/fastapi](https://github.com/fastapi/fastapi/pull/14572) <sub>97,209 stars</sub>
392
+ - [fastapi/typer](https://github.com/fastapi/typer/pull/1453) <sub>19,210 stars</sub>
393
+ - [fastapi/asyncer](https://github.com/fastapi/asyncer/pull/437) <sub>2,407 stars</sub>
394
+ - [astral-sh/ruff](https://github.com/astral-sh/ruff/pull/22505) <sub>47,070 stars</sub>
395
+ - [astral-sh/ty](https://github.com/astral-sh/ty/pull/2469) <sub>18,308 stars</sub>
396
+ - [openclaw/openclaw](https://github.com/openclaw/openclaw/pull/1720) <sub>357,512 stars</sub>
397
+ - [home-assistant/core](https://github.com/home-assistant/core/pull/160427) <sub>86,029 stars</sub>
398
+ - [python-telegram-bot/python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot/pull/5142) <sub>29,025 stars</sub>
399
+ - [DetachHead/basedpyright](https://github.com/DetachHead/basedpyright/pull/1413) <sub>3,267 stars</sub>
400
+ - [OpenLineage/OpenLineage](https://github.com/OpenLineage/OpenLineage/pull/3965) <sub>2,406 stars</sub>
401
+ - [authlib/authlib](https://github.com/authlib/authlib/pull/804) <sub>5,271 stars</sub>
402
+ - [django/djangoproject.com](https://github.com/django/djangoproject.com/pull/2252) <sub>1,994 stars</sub>
403
+ - [Future-House/paper-qa](https://github.com/Future-House/paper-qa/pull/1098) <sub>8,377 stars</sub>
404
+ - [Goldziher/kreuzberg](https://github.com/Goldziher/kreuzberg/pull/142) <sub>7,550 stars</sub>
405
+ - [python-attrs/attrs](https://github.com/python-attrs/attrs/commit/c95b177682e76a63478d29d040f9cb36a8d31915) <sub>5,770 stars</sub>
406
+ - [jlowin/fastmcp](https://github.com/jlowin/fastmcp/pull/2309) <sub>24,539 stars</sub>
407
+ - [apache/iggy](https://github.com/apache/iggy/pull/2383) <sub>4,116 stars</sub>
408
+ - [apache/lucene](https://github.com/apache/lucene/pull/15629) <sub>3,401 stars</sub>
409
+ - [jcrist/msgspec](https://github.com/jcrist/msgspec/pull/918) <sub>3,692 stars</sub>
410
+ - [MoonshotAI/kimi-cli](https://github.com/MoonshotAI/kimi-cli/pull/535) <sub>7,800 stars</sub>
411
+ - [simple-icons/simple-icons](https://github.com/simple-icons/simple-icons/pull/14245) <sub>24,873 stars</sub>
412
+ - [ast-grep/ast-grep](https://github.com/ast-grep/ast-grep.github.io/commit/e30818144b2967a7f9172c8cf2f4596bba219bf5) <sub>13,413 stars</sub>
413
+ - [commitizen-tools/commitizen](https://github.com/commitizen-tools/commitizen) <sub>3,377 stars</sub>
414
+ - [cocoindex-io/cocoindex](https://github.com/cocoindex-io/cocoindex/pull/1564) <sub>6,865 stars</sub>
415
+ - [cachix/devenv](https://github.com/cachix/devenv/pull/2304) <sub>6,665 stars</sub>
416
+ - [pyodide/pyodide](https://github.com/pyodide/pyodide/pull/6182) <sub>14,527 stars</sub>
417
+ - [prowler-cloud/prowler](https://github.com/prowler-cloud/prowler/pull/10601) <sub>13,592 stars</sub>
403
418
 
404
419
  <!-- --8<-- [end: why] -->
405
420
 
package/bin/prek.js ADDED
@@ -0,0 +1,234 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { spawnSync } = require("child_process");
6
+ const { createRequire } = require("module");
7
+
8
+ const DEBUG = process.env.PREK_DEBUG === "1";
9
+ const PLATFORMS = require("../platforms.json");
10
+
11
+ function debug(message) {
12
+ if (DEBUG) {
13
+ console.error(`[prek-debug] ${message}`);
14
+ }
15
+ }
16
+
17
+ function isMusl() {
18
+ if (process.platform !== "linux") {
19
+ return false;
20
+ }
21
+
22
+ if (fs.existsSync("/etc/alpine-release")) {
23
+ debug("detected musl via /etc/alpine-release");
24
+ return true;
25
+ }
26
+
27
+ const report = process.report?.getReport?.();
28
+ if (report?.header?.glibcVersionRuntime) {
29
+ debug(`detected glibc ${report.header.glibcVersionRuntime}`);
30
+ return false;
31
+ }
32
+ if (report?.sharedObjects?.some((entry) => entry.includes("musl"))) {
33
+ debug("detected musl via process.report shared objects");
34
+ return true;
35
+ }
36
+
37
+ try {
38
+ const result = spawnSync("ldd", ["--version"], {
39
+ encoding: "utf8",
40
+ stdio: ["ignore", "pipe", "pipe"],
41
+ });
42
+ const output = `${result.stdout ?? ""}${result.stderr ?? ""}`.toLowerCase();
43
+ const musl = output.includes("musl");
44
+ debug(`detected ${musl ? "musl" : "glibc"} via ldd`);
45
+ return musl;
46
+ } catch {
47
+ debug("failed to run ldd, assuming glibc");
48
+ }
49
+
50
+ try {
51
+ for (const libDir of ["/lib", "/lib64"]) {
52
+ if (!fs.existsSync(libDir)) {
53
+ continue;
54
+ }
55
+
56
+ const files = fs.readdirSync(libDir);
57
+ if (
58
+ files.some(
59
+ (file) => file.startsWith("ld-musl-") || file.startsWith("libc.musl-"),
60
+ )
61
+ ) {
62
+ debug(`detected musl via ${libDir}`);
63
+ return true;
64
+ }
65
+ }
66
+ } catch {
67
+ debug("failed to scan /lib and /lib64 for musl");
68
+ }
69
+
70
+ const ldLibraryPath = process.env.LD_LIBRARY_PATH ?? "";
71
+ if (ldLibraryPath.toLowerCase().includes("musl")) {
72
+ debug("detected musl via LD_LIBRARY_PATH");
73
+ return true;
74
+ }
75
+
76
+ return false;
77
+ }
78
+
79
+ function armVersion() {
80
+ const version = Number(process.config.variables.arm_version ?? 0);
81
+ return Number.isFinite(version) ? version : 0;
82
+ }
83
+
84
+ function matchesArmVersion(spec) {
85
+ const version = armVersion();
86
+ if (spec.armVersionMin != null && version < spec.armVersionMin) {
87
+ return false;
88
+ }
89
+ if (spec.armVersionMax != null && version > spec.armVersionMax) {
90
+ return false;
91
+ }
92
+ return true;
93
+ }
94
+
95
+ function currentLibc() {
96
+ if (process.platform !== "linux") {
97
+ return null;
98
+ }
99
+ return isMusl() ? "musl" : "glibc";
100
+ }
101
+
102
+ function pickPlatformPackage() {
103
+ const libc = currentLibc();
104
+ debug(
105
+ `selecting package for platform=${process.platform} arch=${process.arch}` +
106
+ `${libc ? ` libc=${libc}` : ""} armVersion=${armVersion()}`,
107
+ );
108
+
109
+ const candidates = PLATFORMS.filter((spec) => {
110
+ if (!spec.os.includes(process.platform)) {
111
+ return false;
112
+ }
113
+ if (!spec.cpu.includes(process.arch)) {
114
+ return false;
115
+ }
116
+ if (spec.libc && spec.libc !== libc) {
117
+ return false;
118
+ }
119
+ if (!matchesArmVersion(spec)) {
120
+ return false;
121
+ }
122
+ return true;
123
+ }).sort((left, right) => {
124
+ const leftSpecificity = left.armVersionMin ?? 0;
125
+ const rightSpecificity = right.armVersionMin ?? 0;
126
+ return rightSpecificity - leftSpecificity;
127
+ });
128
+
129
+ if (candidates.length === 0) {
130
+ const libcSuffix = libc ? ` (${libc})` : "";
131
+ throw new Error(
132
+ `Unsupported platform: ${process.platform} ${process.arch}${libcSuffix}`,
133
+ );
134
+ }
135
+
136
+ return candidates[0];
137
+ }
138
+
139
+ function resolvePackageJson(packageName) {
140
+ const specifier = `${packageName}/package.json`;
141
+ const attempts = [];
142
+
143
+ const resolvers = [
144
+ () => createRequire(__filename).resolve(specifier),
145
+ () =>
146
+ path.resolve(
147
+ __dirname,
148
+ "..",
149
+ "..",
150
+ packageName.split("/")[1],
151
+ "package.json",
152
+ ),
153
+ ];
154
+
155
+ for (const resolve of resolvers) {
156
+ try {
157
+ const packageJsonPath = resolve();
158
+ attempts.push(packageJsonPath);
159
+ debug(`resolved ${specifier} candidate: ${packageJsonPath}`);
160
+ if (fs.existsSync(packageJsonPath)) {
161
+ debug(`using ${specifier}: ${packageJsonPath}`);
162
+ return packageJsonPath;
163
+ }
164
+ debug(`candidate does not exist: ${packageJsonPath}`);
165
+ } catch (error) {
166
+ attempts.push(String(error.message ?? error));
167
+ debug(`failed to resolve ${specifier}: ${error.message ?? error}`);
168
+ }
169
+ }
170
+
171
+ debug(`resolution attempts for ${packageName}: ${attempts.join(" | ")}`);
172
+ throw new Error(
173
+ `Platform package ${packageName} is not installed. Reinstall @j178/prek for this platform.`,
174
+ );
175
+ }
176
+
177
+ function ensureExecutable(binaryPath) {
178
+ if (process.platform === "win32") {
179
+ return;
180
+ }
181
+
182
+ try {
183
+ fs.accessSync(binaryPath, fs.constants.X_OK);
184
+ } catch {
185
+ fs.chmodSync(binaryPath, 0o755);
186
+ }
187
+ }
188
+
189
+ function main() {
190
+ if (process.env.PREK_BINARY) {
191
+ const override = path.resolve(process.env.PREK_BINARY);
192
+ debug(`using PREK_BINARY override: ${override}`);
193
+ if (!fs.existsSync(override)) {
194
+ throw new Error(`PREK_BINARY does not exist: ${override}`);
195
+ }
196
+ ensureExecutable(override);
197
+ runBinary(override);
198
+ return;
199
+ }
200
+
201
+ const spec = pickPlatformPackage();
202
+ debug(`selected package ${spec.packageName}`);
203
+
204
+ const packageJsonPath = resolvePackageJson(spec.packageName);
205
+ const binaryPath = path.join(path.dirname(packageJsonPath), spec.binaryName);
206
+ debug(`selected binary ${binaryPath}`);
207
+ ensureExecutable(binaryPath);
208
+ runBinary(binaryPath);
209
+ }
210
+
211
+ function runBinary(binaryPath) {
212
+ debug(`running ${binaryPath} ${process.argv.slice(2).join(" ")}`);
213
+ const result = spawnSync(binaryPath, process.argv.slice(2), {
214
+ stdio: "inherit",
215
+ });
216
+
217
+ if (result.error) {
218
+ throw result.error;
219
+ }
220
+
221
+ if (result.signal) {
222
+ process.kill(process.pid, result.signal);
223
+ return;
224
+ }
225
+
226
+ process.exit(result.status ?? 1);
227
+ }
228
+
229
+ try {
230
+ main();
231
+ } catch (error) {
232
+ console.error(`prek: ${error.message}`);
233
+ process.exit(1);
234
+ }
package/package.json CHANGED
@@ -1,220 +1,46 @@
1
1
  {
2
- "artifactDownloadUrls": [
3
- "https://github.com/j178/prek/releases/download/v0.3.9"
4
- ],
5
- "author": "j178 <hi@j178.dev>",
6
- "bin": {
7
- "prek": "run-prek.js"
2
+ "name": "@j178/prek",
3
+ "version": "0.3.10",
4
+ "description": "A Git hook manager written in Rust, designed as a drop-in alternative to pre-commit.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/j178/prek.git"
8
9
  },
9
- "dependencies": {
10
- "axios": "^1.13.5",
11
- "axios-proxy-builder": "^0.1.2",
12
- "console.table": "^0.10.0",
13
- "detect-libc": "^2.1.2",
14
- "rimraf": "^6.1.3"
10
+ "homepage": "https://prek.j178.dev/",
11
+ "bugs": {
12
+ "url": "https://github.com/j178/prek/issues"
15
13
  },
16
- "description": "A Git hook manager written in Rust, designed as a drop-in alternative to pre-commit.",
17
- "devDependencies": {
18
- "prettier": "^3.8.1"
14
+ "bin": {
15
+ "prek": "bin/prek.js"
19
16
  },
20
17
  "engines": {
21
- "node": ">=14",
22
- "npm": ">=6"
18
+ "node": ">=18"
23
19
  },
24
- "glibcMinimum": {
25
- "major": 2,
26
- "series": 31
27
- },
28
- "homepage": "https://prek.j178.dev/",
29
- "license": "MIT",
30
- "name": "@j178/prek",
31
20
  "preferUnplugged": true,
32
- "repository": "https://github.com/j178/prek",
33
- "scripts": {
34
- "fmt": "prettier --write **/*.js",
35
- "fmt:check": "prettier --check **/*.js",
36
- "postinstall": "node ./install.js"
37
- },
38
- "supportedPlatforms": {
39
- "aarch64-apple-darwin": {
40
- "artifactName": "prek-aarch64-apple-darwin.tar.gz",
41
- "bins": {
42
- "prek": "prek"
43
- },
44
- "zipExt": ".tar.gz"
45
- },
46
- "aarch64-pc-windows-gnu": {
47
- "artifactName": "prek-aarch64-pc-windows-msvc.zip",
48
- "bins": {
49
- "prek": "prek.exe"
50
- },
51
- "zipExt": ".zip"
52
- },
53
- "aarch64-pc-windows-msvc": {
54
- "artifactName": "prek-aarch64-pc-windows-msvc.zip",
55
- "bins": {
56
- "prek": "prek.exe"
57
- },
58
- "zipExt": ".zip"
59
- },
60
- "aarch64-unknown-linux-gnu": {
61
- "artifactName": "prek-aarch64-unknown-linux-gnu.tar.gz",
62
- "bins": {
63
- "prek": "prek"
64
- },
65
- "zipExt": ".tar.gz"
66
- },
67
- "aarch64-unknown-linux-musl-dynamic": {
68
- "artifactName": "prek-aarch64-unknown-linux-musl.tar.gz",
69
- "bins": {
70
- "prek": "prek"
71
- },
72
- "zipExt": ".tar.gz"
73
- },
74
- "aarch64-unknown-linux-musl-static": {
75
- "artifactName": "prek-aarch64-unknown-linux-musl.tar.gz",
76
- "bins": {
77
- "prek": "prek"
78
- },
79
- "zipExt": ".tar.gz"
80
- },
81
- "arm-unknown-linux-gnueabihf": {
82
- "artifactName": "prek-arm-unknown-linux-musleabihf.tar.gz",
83
- "bins": {
84
- "prek": "prek"
85
- },
86
- "zipExt": ".tar.gz"
87
- },
88
- "arm-unknown-linux-musl-dynamiceabihf": {
89
- "artifactName": "prek-arm-unknown-linux-musleabihf.tar.gz",
90
- "bins": {
91
- "prek": "prek"
92
- },
93
- "zipExt": ".tar.gz"
94
- },
95
- "arm-unknown-linux-musl-staticeabihf": {
96
- "artifactName": "prek-arm-unknown-linux-musleabihf.tar.gz",
97
- "bins": {
98
- "prek": "prek"
99
- },
100
- "zipExt": ".tar.gz"
101
- },
102
- "armv7-unknown-linux-gnueabihf": {
103
- "artifactName": "prek-armv7-unknown-linux-gnueabihf.tar.gz",
104
- "bins": {
105
- "prek": "prek"
106
- },
107
- "zipExt": ".tar.gz"
108
- },
109
- "armv7-unknown-linux-musl-dynamiceabihf": {
110
- "artifactName": "prek-armv7-unknown-linux-musleabihf.tar.gz",
111
- "bins": {
112
- "prek": "prek"
113
- },
114
- "zipExt": ".tar.gz"
115
- },
116
- "armv7-unknown-linux-musl-staticeabihf": {
117
- "artifactName": "prek-armv7-unknown-linux-musleabihf.tar.gz",
118
- "bins": {
119
- "prek": "prek"
120
- },
121
- "zipExt": ".tar.gz"
122
- },
123
- "i686-pc-windows-gnu": {
124
- "artifactName": "prek-i686-pc-windows-msvc.zip",
125
- "bins": {
126
- "prek": "prek.exe"
127
- },
128
- "zipExt": ".zip"
129
- },
130
- "i686-pc-windows-msvc": {
131
- "artifactName": "prek-i686-pc-windows-msvc.zip",
132
- "bins": {
133
- "prek": "prek.exe"
134
- },
135
- "zipExt": ".zip"
136
- },
137
- "i686-unknown-linux-gnu": {
138
- "artifactName": "prek-i686-unknown-linux-gnu.tar.gz",
139
- "bins": {
140
- "prek": "prek"
141
- },
142
- "zipExt": ".tar.gz"
143
- },
144
- "i686-unknown-linux-musl-dynamic": {
145
- "artifactName": "prek-i686-unknown-linux-musl.tar.gz",
146
- "bins": {
147
- "prek": "prek"
148
- },
149
- "zipExt": ".tar.gz"
150
- },
151
- "i686-unknown-linux-musl-static": {
152
- "artifactName": "prek-i686-unknown-linux-musl.tar.gz",
153
- "bins": {
154
- "prek": "prek"
155
- },
156
- "zipExt": ".tar.gz"
157
- },
158
- "riscv64gc-unknown-linux-gnu": {
159
- "artifactName": "prek-riscv64gc-unknown-linux-gnu.tar.gz",
160
- "bins": {
161
- "prek": "prek"
162
- },
163
- "zipExt": ".tar.gz"
164
- },
165
- "s390x-unknown-linux-gnu": {
166
- "artifactName": "prek-s390x-unknown-linux-gnu.tar.gz",
167
- "bins": {
168
- "prek": "prek"
169
- },
170
- "zipExt": ".tar.gz"
171
- },
172
- "x86_64-apple-darwin": {
173
- "artifactName": "prek-x86_64-apple-darwin.tar.gz",
174
- "bins": {
175
- "prek": "prek"
176
- },
177
- "zipExt": ".tar.gz"
178
- },
179
- "x86_64-pc-windows-gnu": {
180
- "artifactName": "prek-x86_64-pc-windows-msvc.zip",
181
- "bins": {
182
- "prek": "prek.exe"
183
- },
184
- "zipExt": ".zip"
185
- },
186
- "x86_64-pc-windows-msvc": {
187
- "artifactName": "prek-x86_64-pc-windows-msvc.zip",
188
- "bins": {
189
- "prek": "prek.exe"
190
- },
191
- "zipExt": ".zip"
192
- },
193
- "x86_64-unknown-linux-gnu": {
194
- "artifactName": "prek-x86_64-unknown-linux-gnu.tar.gz",
195
- "bins": {
196
- "prek": "prek"
197
- },
198
- "zipExt": ".tar.gz"
199
- },
200
- "x86_64-unknown-linux-musl-dynamic": {
201
- "artifactName": "prek-x86_64-unknown-linux-musl.tar.gz",
202
- "bins": {
203
- "prek": "prek"
204
- },
205
- "zipExt": ".tar.gz"
206
- },
207
- "x86_64-unknown-linux-musl-static": {
208
- "artifactName": "prek-x86_64-unknown-linux-musl.tar.gz",
209
- "bins": {
210
- "prek": "prek"
211
- },
212
- "zipExt": ".tar.gz"
213
- }
214
- },
215
- "version": "0.3.9",
216
- "volta": {
217
- "node": "18.14.1",
218
- "npm": "9.5.0"
21
+ "files": [
22
+ "bin",
23
+ "platforms.json",
24
+ "README.md",
25
+ "CHANGELOG.md",
26
+ "LICENSE"
27
+ ],
28
+ "optionalDependencies": {
29
+ "@j178/prek-darwin-arm64": "0.3.10",
30
+ "@j178/prek-darwin-x64": "0.3.10",
31
+ "@j178/prek-linux-arm64-gnu": "0.3.10",
32
+ "@j178/prek-linux-arm64-musl": "0.3.10",
33
+ "@j178/prek-linux-arm-gnueabihf": "0.3.10",
34
+ "@j178/prek-linux-arm-musleabihf": "0.3.10",
35
+ "@j178/prek-linux-armv7-musleabihf": "0.3.10",
36
+ "@j178/prek-linux-ia32-gnu": "0.3.10",
37
+ "@j178/prek-linux-ia32-musl": "0.3.10",
38
+ "@j178/prek-linux-riscv64-gnu": "0.3.10",
39
+ "@j178/prek-linux-s390x-gnu": "0.3.10",
40
+ "@j178/prek-linux-x64-gnu": "0.3.10",
41
+ "@j178/prek-linux-x64-musl": "0.3.10",
42
+ "@j178/prek-win32-arm64-msvc": "0.3.10",
43
+ "@j178/prek-win32-ia32-msvc": "0.3.10",
44
+ "@j178/prek-win32-x64-msvc": "0.3.10"
219
45
  }
220
- }
46
+ }
package/platforms.json ADDED
@@ -0,0 +1,191 @@
1
+ [
2
+ {
3
+ "rustTarget": "aarch64-apple-darwin",
4
+ "packageName": "@j178/prek-darwin-arm64",
5
+ "binaryName": "prek",
6
+ "os": [
7
+ "darwin"
8
+ ],
9
+ "cpu": [
10
+ "arm64"
11
+ ]
12
+ },
13
+ {
14
+ "rustTarget": "x86_64-apple-darwin",
15
+ "packageName": "@j178/prek-darwin-x64",
16
+ "binaryName": "prek",
17
+ "os": [
18
+ "darwin"
19
+ ],
20
+ "cpu": [
21
+ "x64"
22
+ ]
23
+ },
24
+ {
25
+ "rustTarget": "aarch64-unknown-linux-gnu",
26
+ "packageName": "@j178/prek-linux-arm64-gnu",
27
+ "binaryName": "prek",
28
+ "os": [
29
+ "linux"
30
+ ],
31
+ "cpu": [
32
+ "arm64"
33
+ ],
34
+ "libc": "glibc"
35
+ },
36
+ {
37
+ "rustTarget": "aarch64-unknown-linux-musl",
38
+ "packageName": "@j178/prek-linux-arm64-musl",
39
+ "binaryName": "prek",
40
+ "os": [
41
+ "linux"
42
+ ],
43
+ "cpu": [
44
+ "arm64"
45
+ ],
46
+ "libc": "musl"
47
+ },
48
+ {
49
+ "rustTarget": "armv7-unknown-linux-gnueabihf",
50
+ "packageName": "@j178/prek-linux-arm-gnueabihf",
51
+ "binaryName": "prek",
52
+ "os": [
53
+ "linux"
54
+ ],
55
+ "cpu": [
56
+ "arm"
57
+ ],
58
+ "libc": "glibc",
59
+ "armVersionMin": 7
60
+ },
61
+ {
62
+ "rustTarget": "arm-unknown-linux-musleabihf",
63
+ "packageName": "@j178/prek-linux-arm-musleabihf",
64
+ "binaryName": "prek",
65
+ "os": [
66
+ "linux"
67
+ ],
68
+ "cpu": [
69
+ "arm"
70
+ ],
71
+ "libc": "musl"
72
+ },
73
+ {
74
+ "rustTarget": "armv7-unknown-linux-musleabihf",
75
+ "packageName": "@j178/prek-linux-armv7-musleabihf",
76
+ "binaryName": "prek",
77
+ "os": [
78
+ "linux"
79
+ ],
80
+ "cpu": [
81
+ "arm"
82
+ ],
83
+ "libc": "musl",
84
+ "armVersionMin": 7
85
+ },
86
+ {
87
+ "rustTarget": "i686-unknown-linux-gnu",
88
+ "packageName": "@j178/prek-linux-ia32-gnu",
89
+ "binaryName": "prek",
90
+ "os": [
91
+ "linux"
92
+ ],
93
+ "cpu": [
94
+ "ia32"
95
+ ],
96
+ "libc": "glibc"
97
+ },
98
+ {
99
+ "rustTarget": "i686-unknown-linux-musl",
100
+ "packageName": "@j178/prek-linux-ia32-musl",
101
+ "binaryName": "prek",
102
+ "os": [
103
+ "linux"
104
+ ],
105
+ "cpu": [
106
+ "ia32"
107
+ ],
108
+ "libc": "musl"
109
+ },
110
+ {
111
+ "rustTarget": "riscv64gc-unknown-linux-gnu",
112
+ "packageName": "@j178/prek-linux-riscv64-gnu",
113
+ "binaryName": "prek",
114
+ "os": [
115
+ "linux"
116
+ ],
117
+ "cpu": [
118
+ "riscv64"
119
+ ],
120
+ "libc": "glibc"
121
+ },
122
+ {
123
+ "rustTarget": "s390x-unknown-linux-gnu",
124
+ "packageName": "@j178/prek-linux-s390x-gnu",
125
+ "binaryName": "prek",
126
+ "os": [
127
+ "linux"
128
+ ],
129
+ "cpu": [
130
+ "s390x"
131
+ ],
132
+ "libc": "glibc"
133
+ },
134
+ {
135
+ "rustTarget": "x86_64-unknown-linux-gnu",
136
+ "packageName": "@j178/prek-linux-x64-gnu",
137
+ "binaryName": "prek",
138
+ "os": [
139
+ "linux"
140
+ ],
141
+ "cpu": [
142
+ "x64"
143
+ ],
144
+ "libc": "glibc"
145
+ },
146
+ {
147
+ "rustTarget": "x86_64-unknown-linux-musl",
148
+ "packageName": "@j178/prek-linux-x64-musl",
149
+ "binaryName": "prek",
150
+ "os": [
151
+ "linux"
152
+ ],
153
+ "cpu": [
154
+ "x64"
155
+ ],
156
+ "libc": "musl"
157
+ },
158
+ {
159
+ "rustTarget": "aarch64-pc-windows-msvc",
160
+ "packageName": "@j178/prek-win32-arm64-msvc",
161
+ "binaryName": "prek.exe",
162
+ "os": [
163
+ "win32"
164
+ ],
165
+ "cpu": [
166
+ "arm64"
167
+ ]
168
+ },
169
+ {
170
+ "rustTarget": "i686-pc-windows-msvc",
171
+ "packageName": "@j178/prek-win32-ia32-msvc",
172
+ "binaryName": "prek.exe",
173
+ "os": [
174
+ "win32"
175
+ ],
176
+ "cpu": [
177
+ "ia32"
178
+ ]
179
+ },
180
+ {
181
+ "rustTarget": "x86_64-pc-windows-msvc",
182
+ "packageName": "@j178/prek-win32-x64-msvc",
183
+ "binaryName": "prek.exe",
184
+ "os": [
185
+ "win32"
186
+ ],
187
+ "cpu": [
188
+ "x64"
189
+ ]
190
+ }
191
+ ]
package/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- /node_modules
2
-
package/binary-install.js DELETED
@@ -1,212 +0,0 @@
1
- const { createWriteStream, existsSync, mkdirSync, mkdtemp } = require("fs");
2
- const { join, sep } = require("path");
3
- const { spawnSync } = require("child_process");
4
- const { tmpdir } = require("os");
5
-
6
- const axios = require("axios");
7
- const rimraf = require("rimraf");
8
- const tmpDir = tmpdir();
9
-
10
- const error = (msg) => {
11
- console.error(msg);
12
- process.exit(1);
13
- };
14
-
15
- class Package {
16
- constructor(platform, name, url, filename, zipExt, binaries) {
17
- let errors = [];
18
- if (typeof url !== "string") {
19
- errors.push("url must be a string");
20
- } else {
21
- try {
22
- new URL(url);
23
- } catch (e) {
24
- errors.push(e);
25
- }
26
- }
27
- if (name && typeof name !== "string") {
28
- errors.push("package name must be a string");
29
- }
30
- if (!name) {
31
- errors.push("You must specify the name of your package");
32
- }
33
- if (binaries && typeof binaries !== "object") {
34
- errors.push("binaries must be a string => string map");
35
- }
36
- if (!binaries) {
37
- errors.push("You must specify the binaries in the package");
38
- }
39
-
40
- if (errors.length > 0) {
41
- let errorMsg =
42
- "One or more of the parameters you passed to the Binary constructor are invalid:\n";
43
- errors.forEach((error) => {
44
- errorMsg += error;
45
- });
46
- errorMsg +=
47
- '\n\nCorrect usage: new Package("my-binary", "https://example.com/binary/download.tar.gz", {"my-binary": "my-binary"})';
48
- error(errorMsg);
49
- }
50
-
51
- this.platform = platform;
52
- this.url = url;
53
- this.name = name;
54
- this.filename = filename;
55
- this.zipExt = zipExt;
56
- this.installDirectory = join(__dirname, "node_modules", ".bin_real");
57
- this.binaries = binaries;
58
-
59
- if (!existsSync(this.installDirectory)) {
60
- mkdirSync(this.installDirectory, { recursive: true });
61
- }
62
- }
63
-
64
- exists() {
65
- for (const binaryName in this.binaries) {
66
- const binRelPath = this.binaries[binaryName];
67
- const binPath = join(this.installDirectory, binRelPath);
68
- if (!existsSync(binPath)) {
69
- return false;
70
- }
71
- }
72
- return true;
73
- }
74
-
75
- install(fetchOptions, suppressLogs = false) {
76
- if (this.exists()) {
77
- if (!suppressLogs) {
78
- console.error(
79
- `${this.name} is already installed, skipping installation.`,
80
- );
81
- }
82
- return Promise.resolve();
83
- }
84
-
85
- if (existsSync(this.installDirectory)) {
86
- rimraf.sync(this.installDirectory);
87
- }
88
-
89
- mkdirSync(this.installDirectory, { recursive: true });
90
-
91
- if (!suppressLogs) {
92
- console.error(`Downloading release from ${this.url}`);
93
- }
94
-
95
- return axios({ ...fetchOptions, url: this.url, responseType: "stream" })
96
- .then((res) => {
97
- return new Promise((resolve, reject) => {
98
- mkdtemp(`${tmpDir}${sep}`, (err, directory) => {
99
- let tempFile = join(directory, this.filename);
100
- const sink = res.data.pipe(createWriteStream(tempFile));
101
- sink.on("error", (err) => reject(err));
102
- sink.on("close", () => {
103
- if (/\.tar\.*/.test(this.zipExt)) {
104
- const result = spawnSync("tar", [
105
- "xf",
106
- tempFile,
107
- // The tarballs are stored with a leading directory
108
- // component; we strip one component in the
109
- // shell installers too.
110
- "--strip-components",
111
- "1",
112
- "-C",
113
- this.installDirectory,
114
- ]);
115
- if (result.status == 0) {
116
- resolve();
117
- } else if (result.error) {
118
- reject(result.error);
119
- } else {
120
- reject(
121
- new Error(
122
- `An error occurred untarring the artifact: stdout: ${result.stdout}; stderr: ${result.stderr}`,
123
- ),
124
- );
125
- }
126
- } else if (this.zipExt == ".zip") {
127
- let result;
128
- if (this.platform.artifactName.includes("windows")) {
129
- // Windows does not have "unzip" by default on many installations, instead
130
- // we use Expand-Archive from powershell
131
- result = spawnSync("powershell.exe", [
132
- "-NoProfile",
133
- "-NonInteractive",
134
- "-Command",
135
- `& {
136
- param([string]$LiteralPath, [string]$DestinationPath)
137
- Expand-Archive -LiteralPath $LiteralPath -DestinationPath $DestinationPath -Force
138
- }`,
139
- tempFile,
140
- this.installDirectory,
141
- ]);
142
- } else {
143
- result = spawnSync("unzip", [
144
- "-q",
145
- tempFile,
146
- "-d",
147
- this.installDirectory,
148
- ]);
149
- }
150
-
151
- if (result.status == 0) {
152
- resolve();
153
- } else if (result.error) {
154
- reject(result.error);
155
- } else {
156
- reject(
157
- new Error(
158
- `An error occurred unzipping the artifact: stdout: ${result.stdout}; stderr: ${result.stderr}`,
159
- ),
160
- );
161
- }
162
- } else {
163
- reject(
164
- new Error(`Unrecognized file extension: ${this.zipExt}`),
165
- );
166
- }
167
- });
168
- });
169
- });
170
- })
171
- .then(() => {
172
- if (!suppressLogs) {
173
- console.error(`${this.name} has been installed!`);
174
- }
175
- })
176
- .catch((e) => {
177
- error(`Error fetching release: ${e.message}`);
178
- });
179
- }
180
-
181
- run(binaryName, fetchOptions) {
182
- const promise = !this.exists()
183
- ? this.install(fetchOptions, true)
184
- : Promise.resolve();
185
-
186
- promise
187
- .then(() => {
188
- const [, , ...args] = process.argv;
189
-
190
- const options = { cwd: process.cwd(), stdio: "inherit" };
191
-
192
- const binRelPath = this.binaries[binaryName];
193
- if (!binRelPath) {
194
- error(`${binaryName} is not a known binary in ${this.name}`);
195
- }
196
- const binPath = join(this.installDirectory, binRelPath);
197
- const result = spawnSync(binPath, args, options);
198
-
199
- if (result.error) {
200
- error(result.error);
201
- }
202
-
203
- process.exit(result.status);
204
- })
205
- .catch((e) => {
206
- error(e.message);
207
- process.exit(1);
208
- });
209
- }
210
- }
211
-
212
- module.exports.Package = Package;
package/binary.js DELETED
@@ -1,128 +0,0 @@
1
- const { Package } = require("./binary-install");
2
- const os = require("os");
3
- const cTable = require("console.table");
4
- const libc = require("detect-libc");
5
- const { configureProxy } = require("axios-proxy-builder");
6
-
7
- const error = (msg) => {
8
- console.error(msg);
9
- process.exit(1);
10
- };
11
-
12
- const {
13
- name,
14
- artifactDownloadUrls,
15
- supportedPlatforms,
16
- glibcMinimum,
17
- } = require("./package.json");
18
-
19
- // FIXME: implement NPM installer handling of fallback download URLs
20
- const artifactDownloadUrl = artifactDownloadUrls[0];
21
- const builderGlibcMajorVersion = glibcMinimum.major;
22
- const builderGlibcMinorVersion = glibcMinimum.series;
23
-
24
- const getPlatform = () => {
25
- const rawOsType = os.type();
26
- const rawArchitecture = os.arch();
27
-
28
- // We want to use rust-style target triples as the canonical key
29
- // for a platform, so translate the "os" library's concepts into rust ones
30
- let osType = "";
31
- switch (rawOsType) {
32
- case "Windows_NT":
33
- osType = "pc-windows-msvc";
34
- break;
35
- case "Darwin":
36
- osType = "apple-darwin";
37
- break;
38
- case "Linux":
39
- osType = "unknown-linux-gnu";
40
- break;
41
- }
42
-
43
- let arch = "";
44
- switch (rawArchitecture) {
45
- case "x64":
46
- arch = "x86_64";
47
- break;
48
- case "arm64":
49
- arch = "aarch64";
50
- break;
51
- }
52
-
53
- if (rawOsType === "Linux") {
54
- if (libc.familySync() == "musl") {
55
- osType = "unknown-linux-musl-dynamic";
56
- } else if (libc.isNonGlibcLinuxSync()) {
57
- console.warn(
58
- "Your libc is neither glibc nor musl; trying static musl binary instead",
59
- );
60
- osType = "unknown-linux-musl-static";
61
- } else {
62
- let libcVersion = libc.versionSync();
63
- let splitLibcVersion = libcVersion.split(".");
64
- let libcMajorVersion = splitLibcVersion[0];
65
- let libcMinorVersion = splitLibcVersion[1];
66
- if (
67
- libcMajorVersion != builderGlibcMajorVersion ||
68
- libcMinorVersion < builderGlibcMinorVersion
69
- ) {
70
- // We can't run the glibc binaries, but we can run the static musl ones
71
- // if they exist
72
- console.warn(
73
- "Your glibc isn't compatible; trying static musl binary instead",
74
- );
75
- osType = "unknown-linux-musl-static";
76
- }
77
- }
78
- }
79
-
80
- // Assume the above succeeded and build a target triple to look things up with.
81
- // If any of it failed, this lookup will fail and we'll handle it like normal.
82
- let targetTriple = `${arch}-${osType}`;
83
- let platform = supportedPlatforms[targetTriple];
84
-
85
- if (!platform) {
86
- error(
87
- `Platform with type "${rawOsType}" and architecture "${rawArchitecture}" is not supported by ${name}.\nYour system must be one of the following:\n\n${Object.keys(
88
- supportedPlatforms,
89
- ).join(",")}`,
90
- );
91
- }
92
-
93
- return platform;
94
- };
95
-
96
- const getPackage = () => {
97
- const platform = getPlatform();
98
- const url = `${artifactDownloadUrl}/${platform.artifactName}`;
99
- let filename = platform.artifactName;
100
- let ext = platform.zipExt;
101
- let binary = new Package(platform, name, url, filename, ext, platform.bins);
102
-
103
- return binary;
104
- };
105
-
106
- const install = (suppressLogs) => {
107
- if (!artifactDownloadUrl || artifactDownloadUrl.length === 0) {
108
- console.warn("in demo mode, not installing binaries");
109
- return;
110
- }
111
- const package = getPackage();
112
- const proxy = configureProxy(package.url);
113
-
114
- return package.install(proxy, suppressLogs);
115
- };
116
-
117
- const run = (binaryName) => {
118
- const package = getPackage();
119
- const proxy = configureProxy(package.url);
120
-
121
- package.run(binaryName, proxy);
122
- };
123
-
124
- module.exports = {
125
- install,
126
- run,
127
- getPackage,
128
- };
package/install.js DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { install } = require("./binary");
4
- install(false);
package/run-prek.js DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { run } = require("./binary");
4
- run("prek");