@oakoss/oakum 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/README.md +26 -10
- package/oakum.js +40 -0
- package/package.json +27 -100
- package/platforms.json +43 -0
- package/.npmignore +0 -2
- package/binary-install.js +0 -348
- package/binary.js +0 -124
- package/install.js +0 -4
- package/npm-shrinkwrap.json +0 -52
- package/run-oakum.js +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.13.0 (2026-12-03)
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
The npm package ships the binary in a per-platform package (`@oakoss/oakum-linux-x64` and the like) instead of downloading it from the GitHub release in `postinstall`, so installing from npm needs only the registry and no `--allow-build` approval. `init` and `migrate` print `pnpm add -D @oakoss/oakum@<version>`, and the printed npm workflow drops its `pnpm exec oakum --version` step. A repository that exempts oakum from pnpm's `minimumReleaseAge` needs `'@oakoss/oakum-*'` in `minimumReleaseAgeExclude` beside `'@oakoss/oakum'`, or the install fails on the platform package. An install that omits optional dependencies gets no binary, and `oakum` then exits 1 naming the missing package. The `allowBuilds` entry for `@oakoss/oakum` is no longer needed. When a signal kills oakum, `oakum` from npm exits with 128 plus the signal's number, as a shell reports it, where 0.12.1 exited 0.
|
|
8
|
+
|
|
9
|
+
## 0.12.1 (2026-11-17)
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
The `.changeset/README.md` that `init` writes names the two markdown-lint settings oakum's files need (MD041 off for `.changeset/*.md`, MD024 `siblings_only` for changelogs), and `migrate` names them itself rather than claiming `init` prints them. The same README says a clean `check` prints its `check:` and `coverage:` lines, not nothing. `upgrade` refreshes a README v0.10.0 through v0.12.0 wrote.
|
|
14
|
+
|
|
3
15
|
## 0.12.0 (2026-11-16)
|
|
4
16
|
|
|
5
17
|
### Added
|
|
@@ -659,4 +671,4 @@ Release workflow checks out the homebrew tap in a subdirectory so the composite
|
|
|
659
671
|
|
|
660
672
|
Self-host release CI uploads cargo-dist artifacts into the GitHub Release oakum already created, instead of calling create again.
|
|
661
673
|
|
|
662
|
-
Generated by oakum 0.
|
|
674
|
+
Generated by oakum 0.12.1.
|
package/README.md
CHANGED
|
@@ -16,23 +16,39 @@ A library whose published range still covers the new version does not need repub
|
|
|
16
16
|
|
|
17
17
|
Oakum derives which is which — from the binary targets Cargo resolves for a package, from the `bin` field in npm — rather than asking you to declare it. Reading resolved targets rather than looking for `src/main.rs` is what makes `autobins = false` and explicit `[[bin]]` entries come out right.
|
|
18
18
|
|
|
19
|
-
## Design rules
|
|
20
|
-
|
|
21
|
-
**Config expresses preference; facts are derived.** What depends on what, what is publishable, what needs a bump, and which artifact ships are all read from the repository on every run. Templates, titles, the tag format oakum writes, and commit messages are yours, because they describe output rather than the repository, so they cannot go stale. One key is neither: `resolves-dependencies-at`, set per package under `[packages.<name>]`, which states when your package manager fixes a dependency — a fact about the ecosystem that oakum cannot read from your repository. `init` writes a `#:schema ./_schema.json` line, and `init` and `upgrade` keep `_schema.json` next to `_config.toml`, unless `_schema.json` has been deleted and the line names another schema, such as the `schema.json` the npm package ships; that directive is taplo's, not part of TOML, so editor support varies. Every key, with its type and any default, is in the [configuration reference](docs/guide/configuration.md).
|
|
22
|
-
|
|
23
|
-
**Every command writes only the files it owns.** Oakum does not install git hooks, touch git config, edit `AGENTS.md`, write CI workflows, or create commits you did not ask for. `version` owns the manifests it bumps, the lockfile entries those bumps invalidate, and declared `extra-files`. A Cargo version bump invalidates `Cargo.lock`, and a rewritten workspace range invalidates its `pnpm-lock.yaml` entry, so leaving either stale would break the next `--locked` build or frozen install. Nothing beyond that is written. `check` is pure: it reports drift and names the fix, never applies it.
|
|
24
|
-
|
|
25
|
-
**Failure is loud, and "we didn't look" is never reported as "it's fine."** Every verification has three outcomes, not two. A version that could not be confirmed says so.
|
|
26
|
-
|
|
27
19
|
## Install
|
|
28
20
|
|
|
29
21
|
Three install channels, one cargo-dist build behind all of them, so the versions cannot diverge ([ADR-0021](docs/decisions/0021-distribute-through-three-channels.md)):
|
|
30
22
|
|
|
31
23
|
- `cargo install oakum` — builds from crates.io
|
|
32
24
|
- `brew install oakoss/tap/oakum`
|
|
33
|
-
- `pnpm add -D
|
|
25
|
+
- `pnpm add -D @oakoss/oakum@<version>` — the exact version is the install pin oakum enforces. The binary comes in a per-platform package such as `@oakoss/oakum-linux-x64`, an optional dependency of `@oakoss/oakum`, so the install runs no script and needs only the npm registry ([ADR-0041](docs/decisions/0041-ship-npm-binaries-in-platform-packages.md)). npm packages exist for macOS (arm64, x64), Linux x64 (any libc), Linux arm64 (glibc), and Windows (x64, and arm64 through emulation)
|
|
26
|
+
|
|
27
|
+
None of these works offline. The npm channel works through an npm registry mirror; Homebrew and the shell installer fetch from the GitHub release, and `cargo install oakum` works through a crates.io mirror.
|
|
28
|
+
|
|
29
|
+
## Quick start
|
|
30
|
+
|
|
31
|
+
In an npm or Cargo repository:
|
|
34
32
|
|
|
35
|
-
|
|
33
|
+
1. `oakum init` writes `.changeset/` and prints a GitHub Actions workflow and the install pin your repository needs. Save the workflow under `.github/workflows/` and add the pin; oakum writes neither, and `add` refuses until the pin exists.
|
|
34
|
+
2. On a branch, `oakum add --packages <name>:<level> --message "<what users see>"` writes a bump file naming a package your change releases and how far (`patch`, `minor` or `major`); `oakum add --interactive` asks instead. With conventional commits on, `oakum generate` writes one from your commits.
|
|
35
|
+
3. `oakum status` shows the next release: each package, its new version, and why.
|
|
36
|
+
4. On every pull request, the workflow runs `oakum check --strict`, which fails when a changed package has nothing saying what the change releases, and comments the release plan.
|
|
37
|
+
5. On the default branch, it keeps a version pull request open with the bumped manifests and changelogs. Merging that pull request is the release: the workflow tags it and publishes the GitHub release.
|
|
38
|
+
|
|
39
|
+
Already on changesets, knope or bumpy? `oakum migrate` converts their config and pending bump files in place of step 1 ([Migrating](docs/guide/migrating.md)).
|
|
40
|
+
|
|
41
|
+
## Documentation
|
|
42
|
+
|
|
43
|
+
Start with the [user guide](docs/README.md#using-oakum): writing bump files, what covers a change, running oakum in GitHub Actions, and every config key. Design decisions and their reasons are in [docs/decisions/](docs/decisions/). To work on oakum itself, start with [Getting started](docs/contributing/index.md#getting-started).
|
|
44
|
+
|
|
45
|
+
## Design rules
|
|
46
|
+
|
|
47
|
+
**Config expresses preference; facts are derived.** What depends on what, what is publishable, what needs a bump, and which artifact ships are all read from the repository on every run. Templates, titles, the tag format oakum writes, and commit messages are yours, because they describe output rather than the repository, so they cannot go stale. One key is neither: `resolves-dependencies-at`, set per package under `[packages.<name>]`, which states when your package manager fixes a dependency — a fact about the ecosystem that oakum cannot read from your repository. `init` writes a `#:schema ./_schema.json` line, and `init` and `upgrade` keep `_schema.json` next to `_config.toml`, unless `_schema.json` has been deleted and the line names another schema, such as the `schema.json` the npm package ships; that directive is taplo's, not part of TOML, so editor support varies. Every key, with its type and any default, is in the [configuration reference](docs/guide/configuration.md).
|
|
48
|
+
|
|
49
|
+
**Every command writes only the files it owns.** Oakum does not install git hooks, touch git config, edit `AGENTS.md`, write CI workflows, or create commits you did not ask for. `version` owns the manifests it bumps, the lockfile entries those bumps invalidate, and declared `extra-files`. A Cargo version bump invalidates `Cargo.lock`, and a rewritten workspace range invalidates its `pnpm-lock.yaml` entry, so leaving either stale would break the next `--locked` build or frozen install. Nothing beyond that is written. `check` is pure: it reports drift and names the fix, never applies it.
|
|
50
|
+
|
|
51
|
+
**Failure is loud, and "we didn't look" is never reported as "it's fine."** Every verification has three outcomes, not two. A version that could not be confirmed says so.
|
|
36
52
|
|
|
37
53
|
## Non-goals
|
|
38
54
|
|
package/oakum.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { spawnSync } = require('child_process');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { packages } = require('./platforms.json');
|
|
8
|
+
|
|
9
|
+
function fail(message) {
|
|
10
|
+
console.error(`oakum: ${message}`);
|
|
11
|
+
process.exit(1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const host = `${process.platform}-${process.arch}`;
|
|
15
|
+
const entry = packages.find((p) => p.hosts.includes(host));
|
|
16
|
+
if (!entry) {
|
|
17
|
+
fail(`no npm package carries a binary for ${host}; \`cargo install oakum\` builds one`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let dir;
|
|
21
|
+
try {
|
|
22
|
+
dir = path.dirname(require.resolve(`${entry.name}/package.json`));
|
|
23
|
+
} catch (_err) {
|
|
24
|
+
const libc = entry.libc ? ` It needs ${entry.libc.join(' or ')}.` : '';
|
|
25
|
+
fail(
|
|
26
|
+
`${entry.name} is not installed. @oakoss/oakum lists it in optionalDependencies, so an install with optional dependencies omitted, or one that skipped it as unsupported here, leaves no binary.${libc}`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const binary = path.join(dir, 'bin', process.platform === 'win32' ? 'oakum.exe' : 'oakum');
|
|
31
|
+
const result = spawnSync(binary, process.argv.slice(2), { stdio: 'inherit' });
|
|
32
|
+
if (result.error) {
|
|
33
|
+
fail(`could not run ${binary}: ${result.error.message}`);
|
|
34
|
+
}
|
|
35
|
+
// The shell's status for a signal death. Re-raising it here would not work for
|
|
36
|
+
// SIGUSR1, which starts Node's inspector, or SIGPIPE, which Node ignores.
|
|
37
|
+
if (result.signal) {
|
|
38
|
+
process.exit(128 + os.constants.signals[result.signal]);
|
|
39
|
+
}
|
|
40
|
+
process.exit(result.status === null ? 1 : result.status);
|
package/package.json
CHANGED
|
@@ -1,113 +1,40 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
],
|
|
5
|
-
"author": "Jace Babin",
|
|
6
|
-
"bin": {
|
|
7
|
-
"oakum": "run-oakum.js"
|
|
8
|
-
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"detect-libc": "^2.1.2"
|
|
11
|
-
},
|
|
2
|
+
"name": "@oakoss/oakum",
|
|
3
|
+
"version": "0.13.0",
|
|
12
4
|
"description": "A polyglot release tool that derives dependent version bumps from the dependency graph",
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
"engines": {
|
|
17
|
-
"node": ">=14.14",
|
|
18
|
-
"npm": ">=6"
|
|
19
|
-
},
|
|
20
|
-
"glibcMinimum": {
|
|
21
|
-
"major": 2,
|
|
22
|
-
"series": 35
|
|
23
|
-
},
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Jace Babin",
|
|
24
7
|
"homepage": "https://github.com/oakoss/oakum",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/oakoss/oakum.git"
|
|
11
|
+
},
|
|
25
12
|
"keywords": [
|
|
26
|
-
"command-line-utilities",
|
|
27
|
-
"development-tools",
|
|
28
13
|
"release",
|
|
29
14
|
"versioning",
|
|
30
15
|
"changelog",
|
|
31
16
|
"semver",
|
|
32
17
|
"monorepo"
|
|
33
18
|
],
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
"preferUnplugged": true,
|
|
37
|
-
"repository": "https://github.com/oakoss/oakum",
|
|
38
|
-
"scripts": {
|
|
39
|
-
"fmt": "prettier --write **/*.js",
|
|
40
|
-
"fmt:check": "prettier --check **/*.js",
|
|
41
|
-
"postinstall": "node ./install.js"
|
|
19
|
+
"bin": {
|
|
20
|
+
"oakum": "oakum.js"
|
|
42
21
|
},
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"bins": {
|
|
54
|
-
"oakum": "oakum.exe"
|
|
55
|
-
},
|
|
56
|
-
"zipExt": ".zip"
|
|
57
|
-
},
|
|
58
|
-
"aarch64-unknown-linux-gnu": {
|
|
59
|
-
"artifactName": "oakum-aarch64-unknown-linux-gnu.tar.xz",
|
|
60
|
-
"bins": {
|
|
61
|
-
"oakum": "oakum"
|
|
62
|
-
},
|
|
63
|
-
"zipExt": ".tar.xz"
|
|
64
|
-
},
|
|
65
|
-
"x86_64-apple-darwin": {
|
|
66
|
-
"artifactName": "oakum-x86_64-apple-darwin.tar.xz",
|
|
67
|
-
"bins": {
|
|
68
|
-
"oakum": "oakum"
|
|
69
|
-
},
|
|
70
|
-
"zipExt": ".tar.xz"
|
|
71
|
-
},
|
|
72
|
-
"x86_64-pc-windows-gnu": {
|
|
73
|
-
"artifactName": "oakum-x86_64-pc-windows-msvc.zip",
|
|
74
|
-
"bins": {
|
|
75
|
-
"oakum": "oakum.exe"
|
|
76
|
-
},
|
|
77
|
-
"zipExt": ".zip"
|
|
78
|
-
},
|
|
79
|
-
"x86_64-pc-windows-msvc": {
|
|
80
|
-
"artifactName": "oakum-x86_64-pc-windows-msvc.zip",
|
|
81
|
-
"bins": {
|
|
82
|
-
"oakum": "oakum.exe"
|
|
83
|
-
},
|
|
84
|
-
"zipExt": ".zip"
|
|
85
|
-
},
|
|
86
|
-
"x86_64-unknown-linux-gnu": {
|
|
87
|
-
"artifactName": "oakum-x86_64-unknown-linux-gnu.tar.xz",
|
|
88
|
-
"bins": {
|
|
89
|
-
"oakum": "oakum"
|
|
90
|
-
},
|
|
91
|
-
"zipExt": ".tar.xz"
|
|
92
|
-
},
|
|
93
|
-
"x86_64-unknown-linux-musl-dynamic": {
|
|
94
|
-
"artifactName": "oakum-x86_64-unknown-linux-musl.tar.xz",
|
|
95
|
-
"bins": {
|
|
96
|
-
"oakum": "oakum"
|
|
97
|
-
},
|
|
98
|
-
"zipExt": ".tar.xz"
|
|
99
|
-
},
|
|
100
|
-
"x86_64-unknown-linux-musl-static": {
|
|
101
|
-
"artifactName": "oakum-x86_64-unknown-linux-musl.tar.xz",
|
|
102
|
-
"bins": {
|
|
103
|
-
"oakum": "oakum"
|
|
104
|
-
},
|
|
105
|
-
"zipExt": ".tar.xz"
|
|
106
|
-
}
|
|
22
|
+
"files": [
|
|
23
|
+
"oakum.js",
|
|
24
|
+
"platforms.json",
|
|
25
|
+
"README.md",
|
|
26
|
+
"LICENSE",
|
|
27
|
+
"CHANGELOG.md",
|
|
28
|
+
"schema.json"
|
|
29
|
+
],
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=14.14"
|
|
107
32
|
},
|
|
108
|
-
"
|
|
109
|
-
|
|
110
|
-
"
|
|
111
|
-
"
|
|
33
|
+
"optionalDependencies": {
|
|
34
|
+
"@oakoss/oakum-darwin-arm64": "0.13.0",
|
|
35
|
+
"@oakoss/oakum-darwin-x64": "0.13.0",
|
|
36
|
+
"@oakoss/oakum-linux-x64": "0.13.0",
|
|
37
|
+
"@oakoss/oakum-linux-arm64": "0.13.0",
|
|
38
|
+
"@oakoss/oakum-win32-x64": "0.13.0"
|
|
112
39
|
}
|
|
113
|
-
}
|
|
40
|
+
}
|
package/platforms.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"packages": [
|
|
3
|
+
{
|
|
4
|
+
"name": "@oakoss/oakum-darwin-arm64",
|
|
5
|
+
"target": "aarch64-apple-darwin",
|
|
6
|
+
"hosts": [
|
|
7
|
+
"darwin-arm64"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "@oakoss/oakum-darwin-x64",
|
|
12
|
+
"target": "x86_64-apple-darwin",
|
|
13
|
+
"hosts": [
|
|
14
|
+
"darwin-x64"
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "@oakoss/oakum-linux-x64",
|
|
19
|
+
"target": "x86_64-unknown-linux-musl",
|
|
20
|
+
"hosts": [
|
|
21
|
+
"linux-x64"
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "@oakoss/oakum-linux-arm64",
|
|
26
|
+
"target": "aarch64-unknown-linux-gnu",
|
|
27
|
+
"hosts": [
|
|
28
|
+
"linux-arm64"
|
|
29
|
+
],
|
|
30
|
+
"libc": [
|
|
31
|
+
"glibc"
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"name": "@oakoss/oakum-win32-x64",
|
|
36
|
+
"target": "x86_64-pc-windows-msvc",
|
|
37
|
+
"hosts": [
|
|
38
|
+
"win32-x64",
|
|
39
|
+
"win32-arm64"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
package/.npmignore
DELETED
package/binary-install.js
DELETED
|
@@ -1,348 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
createWriteStream,
|
|
3
|
-
existsSync,
|
|
4
|
-
mkdirSync,
|
|
5
|
-
mkdtemp,
|
|
6
|
-
rmSync,
|
|
7
|
-
} = require("fs");
|
|
8
|
-
const { join, sep } = require("path");
|
|
9
|
-
const { spawnSync } = require("child_process");
|
|
10
|
-
const { tmpdir } = require("os");
|
|
11
|
-
|
|
12
|
-
const https = require("node:https");
|
|
13
|
-
const http = require("node:http");
|
|
14
|
-
|
|
15
|
-
const tmpDir = tmpdir();
|
|
16
|
-
|
|
17
|
-
const error = (msg) => {
|
|
18
|
-
console.error(msg);
|
|
19
|
-
process.exit(1);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
function getProxyForUrl(urlString) {
|
|
23
|
-
const url = new URL(urlString);
|
|
24
|
-
const isHttps = url.protocol === "https:";
|
|
25
|
-
|
|
26
|
-
const noProxy = process.env.NO_PROXY || process.env.no_proxy || "";
|
|
27
|
-
if (noProxy === "*") return null;
|
|
28
|
-
if (noProxy) {
|
|
29
|
-
const hostname = url.hostname.toLowerCase();
|
|
30
|
-
const noProxyList = noProxy.split(",").map((s) => s.trim().toLowerCase());
|
|
31
|
-
for (const entry of noProxyList) {
|
|
32
|
-
if (hostname === entry || hostname.endsWith("." + entry)) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const proxyEnv = isHttps
|
|
39
|
-
? process.env.HTTPS_PROXY || process.env.https_proxy
|
|
40
|
-
: process.env.HTTP_PROXY || process.env.http_proxy;
|
|
41
|
-
|
|
42
|
-
if (!proxyEnv) return null;
|
|
43
|
-
|
|
44
|
-
const proxyUrl = new URL(proxyEnv);
|
|
45
|
-
|
|
46
|
-
let auth = null;
|
|
47
|
-
if (proxyUrl.username || proxyUrl.password) {
|
|
48
|
-
auth = `${proxyUrl.username}:${proxyUrl.password}`;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
hostname: proxyUrl.hostname,
|
|
53
|
-
port: proxyUrl.port || (proxyUrl.protocol === "https:" ? 443 : 80),
|
|
54
|
-
auth: auth,
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function connectThroughProxy(proxy, target) {
|
|
59
|
-
return new Promise((resolve, reject) => {
|
|
60
|
-
const headers = {};
|
|
61
|
-
if (proxy.auth) {
|
|
62
|
-
headers["Proxy-Authorization"] =
|
|
63
|
-
"Basic " + Buffer.from(proxy.auth).toString("base64");
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const connectReq = http.request({
|
|
67
|
-
hostname: proxy.hostname,
|
|
68
|
-
port: proxy.port,
|
|
69
|
-
method: "CONNECT",
|
|
70
|
-
path: `${target.hostname}:${target.port || 443}`,
|
|
71
|
-
headers,
|
|
72
|
-
});
|
|
73
|
-
connectReq.on("connect", (res, socket) => {
|
|
74
|
-
if (res.statusCode === 200) {
|
|
75
|
-
resolve(socket);
|
|
76
|
-
} else {
|
|
77
|
-
reject(new Error(`Proxy CONNECT failed with status ${res.statusCode}`));
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
connectReq.on("error", reject);
|
|
81
|
-
connectReq.end();
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function download(urlString, maxRedirects) {
|
|
86
|
-
if (maxRedirects === undefined) maxRedirects = 5;
|
|
87
|
-
return new Promise((resolve, reject) => {
|
|
88
|
-
if (maxRedirects < 0) {
|
|
89
|
-
return reject(new Error("Too many redirects"));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const parsed = new URL(urlString);
|
|
93
|
-
const isHttps = parsed.protocol === "https:";
|
|
94
|
-
const mod = isHttps ? https : http;
|
|
95
|
-
const proxy = getProxyForUrl(urlString);
|
|
96
|
-
|
|
97
|
-
const doRequest = (extraOptions) => {
|
|
98
|
-
const options = Object.assign(
|
|
99
|
-
{
|
|
100
|
-
hostname: parsed.hostname,
|
|
101
|
-
port: parsed.port || (isHttps ? 443 : 80),
|
|
102
|
-
path: parsed.pathname + parsed.search,
|
|
103
|
-
method: "GET",
|
|
104
|
-
headers: { "User-Agent": "cargo-dist-npm-installer" },
|
|
105
|
-
},
|
|
106
|
-
extraOptions || {},
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
if (proxy && !isHttps) {
|
|
110
|
-
// HTTP through HTTP proxy: request the full URL via the proxy
|
|
111
|
-
options.hostname = proxy.hostname;
|
|
112
|
-
options.port = proxy.port;
|
|
113
|
-
options.path = urlString;
|
|
114
|
-
if (proxy.auth) {
|
|
115
|
-
options.headers["Proxy-Authorization"] =
|
|
116
|
-
"Basic " + Buffer.from(proxy.auth).toString("base64");
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const req = mod.request(options, (res) => {
|
|
121
|
-
if (
|
|
122
|
-
res.statusCode >= 300 &&
|
|
123
|
-
res.statusCode < 400 &&
|
|
124
|
-
res.headers.location
|
|
125
|
-
) {
|
|
126
|
-
res.resume();
|
|
127
|
-
const nextUrl = new URL(res.headers.location, urlString).toString();
|
|
128
|
-
return download(nextUrl, maxRedirects - 1).then(resolve, reject);
|
|
129
|
-
}
|
|
130
|
-
if (res.statusCode < 200 || res.statusCode >= 300) {
|
|
131
|
-
res.resume();
|
|
132
|
-
return reject(new Error(`HTTP ${res.statusCode} from ${urlString}`));
|
|
133
|
-
}
|
|
134
|
-
resolve(res);
|
|
135
|
-
});
|
|
136
|
-
req.on("error", reject);
|
|
137
|
-
req.end();
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
if (proxy && isHttps) {
|
|
141
|
-
connectThroughProxy(proxy, parsed).then(
|
|
142
|
-
(socket) => doRequest({ socket, agent: false }),
|
|
143
|
-
reject,
|
|
144
|
-
);
|
|
145
|
-
} else {
|
|
146
|
-
doRequest();
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
class Package {
|
|
152
|
-
constructor(platform, name, url, filename, zipExt, binaries) {
|
|
153
|
-
let errors = [];
|
|
154
|
-
if (typeof url !== "string") {
|
|
155
|
-
errors.push("url must be a string");
|
|
156
|
-
} else {
|
|
157
|
-
try {
|
|
158
|
-
new URL(url);
|
|
159
|
-
} catch (e) {
|
|
160
|
-
errors.push(e);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
if (name && typeof name !== "string") {
|
|
164
|
-
errors.push("package name must be a string");
|
|
165
|
-
}
|
|
166
|
-
if (!name) {
|
|
167
|
-
errors.push("You must specify the name of your package");
|
|
168
|
-
}
|
|
169
|
-
if (binaries && typeof binaries !== "object") {
|
|
170
|
-
errors.push("binaries must be a string => string map");
|
|
171
|
-
}
|
|
172
|
-
if (!binaries) {
|
|
173
|
-
errors.push("You must specify the binaries in the package");
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if (errors.length > 0) {
|
|
177
|
-
let errorMsg =
|
|
178
|
-
"One or more of the parameters you passed to the Binary constructor are invalid:\n";
|
|
179
|
-
errors.forEach((error) => {
|
|
180
|
-
errorMsg += error;
|
|
181
|
-
});
|
|
182
|
-
errorMsg +=
|
|
183
|
-
'\n\nCorrect usage: new Package("my-binary", "https://example.com/binary/download.tar.gz", {"my-binary": "my-binary"})';
|
|
184
|
-
error(errorMsg);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
this.platform = platform;
|
|
188
|
-
this.url = url;
|
|
189
|
-
this.name = name;
|
|
190
|
-
this.filename = filename;
|
|
191
|
-
this.zipExt = zipExt;
|
|
192
|
-
this.installDirectory = join(__dirname, "node_modules", ".bin_real");
|
|
193
|
-
this.binaries = binaries;
|
|
194
|
-
|
|
195
|
-
if (!existsSync(this.installDirectory)) {
|
|
196
|
-
mkdirSync(this.installDirectory, { recursive: true });
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
exists() {
|
|
201
|
-
for (const binaryName in this.binaries) {
|
|
202
|
-
const binRelPath = this.binaries[binaryName];
|
|
203
|
-
const binPath = join(this.installDirectory, binRelPath);
|
|
204
|
-
if (!existsSync(binPath)) {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return true;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
install(suppressLogs = false) {
|
|
212
|
-
if (this.exists()) {
|
|
213
|
-
if (!suppressLogs) {
|
|
214
|
-
console.error(
|
|
215
|
-
`${this.name} is already installed, skipping installation.`,
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
return Promise.resolve();
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
try {
|
|
222
|
-
rmSync(this.installDirectory, { recursive: true, force: true });
|
|
223
|
-
} catch {
|
|
224
|
-
// ignore - directory may not exist
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
mkdirSync(this.installDirectory, { recursive: true });
|
|
228
|
-
|
|
229
|
-
if (!suppressLogs) {
|
|
230
|
-
console.error(`Downloading release from ${this.url}`);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
return download(this.url)
|
|
234
|
-
.then((res) => {
|
|
235
|
-
return new Promise((resolve, reject) => {
|
|
236
|
-
mkdtemp(`${tmpDir}${sep}`, (err, directory) => {
|
|
237
|
-
if (err) return reject(err);
|
|
238
|
-
let tempFile = join(directory, this.filename);
|
|
239
|
-
const sink = res.pipe(createWriteStream(tempFile));
|
|
240
|
-
sink.on("error", (err) => reject(err));
|
|
241
|
-
sink.on("close", () => {
|
|
242
|
-
if (/\.tar\.*/.test(this.zipExt)) {
|
|
243
|
-
const result = spawnSync("tar", [
|
|
244
|
-
"xf",
|
|
245
|
-
tempFile,
|
|
246
|
-
// The tarballs are stored with a leading directory
|
|
247
|
-
// component; we strip one component in the
|
|
248
|
-
// shell installers too.
|
|
249
|
-
"--strip-components",
|
|
250
|
-
"1",
|
|
251
|
-
"-C",
|
|
252
|
-
this.installDirectory,
|
|
253
|
-
]);
|
|
254
|
-
if (result.status == 0) {
|
|
255
|
-
resolve();
|
|
256
|
-
} else if (result.error) {
|
|
257
|
-
reject(result.error);
|
|
258
|
-
} else {
|
|
259
|
-
reject(
|
|
260
|
-
new Error(
|
|
261
|
-
`An error occurred untarring the artifact: stdout: ${result.stdout}; stderr: ${result.stderr}`,
|
|
262
|
-
),
|
|
263
|
-
);
|
|
264
|
-
}
|
|
265
|
-
} else if (this.zipExt == ".zip") {
|
|
266
|
-
let result;
|
|
267
|
-
if (this.platform.artifactName.includes("windows")) {
|
|
268
|
-
// Windows does not have "unzip" by default on many installations, instead
|
|
269
|
-
// we use Expand-Archive from powershell
|
|
270
|
-
result = spawnSync("powershell.exe", [
|
|
271
|
-
"-NoProfile",
|
|
272
|
-
"-NonInteractive",
|
|
273
|
-
"-Command",
|
|
274
|
-
`& {
|
|
275
|
-
param([string]$LiteralPath, [string]$DestinationPath)
|
|
276
|
-
Expand-Archive -LiteralPath $LiteralPath -DestinationPath $DestinationPath -Force
|
|
277
|
-
}`,
|
|
278
|
-
tempFile,
|
|
279
|
-
this.installDirectory,
|
|
280
|
-
]);
|
|
281
|
-
} else {
|
|
282
|
-
result = spawnSync("unzip", [
|
|
283
|
-
"-q",
|
|
284
|
-
tempFile,
|
|
285
|
-
"-d",
|
|
286
|
-
this.installDirectory,
|
|
287
|
-
]);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (result.status == 0) {
|
|
291
|
-
resolve();
|
|
292
|
-
} else if (result.error) {
|
|
293
|
-
reject(result.error);
|
|
294
|
-
} else {
|
|
295
|
-
reject(
|
|
296
|
-
new Error(
|
|
297
|
-
`An error occurred unzipping the artifact: stdout: ${result.stdout}; stderr: ${result.stderr}`,
|
|
298
|
-
),
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
} else {
|
|
302
|
-
reject(
|
|
303
|
-
new Error(`Unrecognized file extension: ${this.zipExt}`),
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
});
|
|
309
|
-
})
|
|
310
|
-
.then(() => {
|
|
311
|
-
if (!suppressLogs) {
|
|
312
|
-
console.error(`${this.name} has been installed!`);
|
|
313
|
-
}
|
|
314
|
-
})
|
|
315
|
-
.catch((e) => {
|
|
316
|
-
error(`Error fetching release: ${e.message}`);
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
run(binaryName) {
|
|
321
|
-
const promise = !this.exists() ? this.install(true) : Promise.resolve();
|
|
322
|
-
|
|
323
|
-
promise
|
|
324
|
-
.then(() => {
|
|
325
|
-
const [, , ...args] = process.argv;
|
|
326
|
-
|
|
327
|
-
const options = { cwd: process.cwd(), stdio: "inherit" };
|
|
328
|
-
|
|
329
|
-
const binRelPath = this.binaries[binaryName];
|
|
330
|
-
if (!binRelPath) {
|
|
331
|
-
error(`${binaryName} is not a known binary in ${this.name}`);
|
|
332
|
-
}
|
|
333
|
-
const binPath = join(this.installDirectory, binRelPath);
|
|
334
|
-
const result = spawnSync(binPath, args, options);
|
|
335
|
-
|
|
336
|
-
if (result.error) {
|
|
337
|
-
error(result.error);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
process.exit(result.status);
|
|
341
|
-
})
|
|
342
|
-
.catch((e) => {
|
|
343
|
-
error(e.message);
|
|
344
|
-
});
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
module.exports.Package = Package;
|
package/binary.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
const { Package } = require("./binary-install");
|
|
2
|
-
const os = require("os");
|
|
3
|
-
const libc = require("detect-libc");
|
|
4
|
-
|
|
5
|
-
const error = (msg) => {
|
|
6
|
-
console.error(msg);
|
|
7
|
-
process.exit(1);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const {
|
|
11
|
-
name,
|
|
12
|
-
artifactDownloadUrls,
|
|
13
|
-
supportedPlatforms,
|
|
14
|
-
glibcMinimum,
|
|
15
|
-
} = require("./package.json");
|
|
16
|
-
|
|
17
|
-
// FIXME: implement NPM installer handling of fallback download URLs
|
|
18
|
-
const artifactDownloadUrl = artifactDownloadUrls[0];
|
|
19
|
-
const builderGlibcMajorVersion = glibcMinimum.major;
|
|
20
|
-
const builderGlibcMinorVersion = glibcMinimum.series;
|
|
21
|
-
|
|
22
|
-
const getPlatform = () => {
|
|
23
|
-
const rawOsType = os.type();
|
|
24
|
-
const rawArchitecture = os.arch();
|
|
25
|
-
|
|
26
|
-
// We want to use rust-style target triples as the canonical key
|
|
27
|
-
// for a platform, so translate the "os" library's concepts into rust ones
|
|
28
|
-
let osType = "";
|
|
29
|
-
switch (rawOsType) {
|
|
30
|
-
case "Windows_NT":
|
|
31
|
-
osType = "pc-windows-msvc";
|
|
32
|
-
break;
|
|
33
|
-
case "Darwin":
|
|
34
|
-
osType = "apple-darwin";
|
|
35
|
-
break;
|
|
36
|
-
case "Linux":
|
|
37
|
-
osType = "unknown-linux-gnu";
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let arch = "";
|
|
42
|
-
switch (rawArchitecture) {
|
|
43
|
-
case "x64":
|
|
44
|
-
arch = "x86_64";
|
|
45
|
-
break;
|
|
46
|
-
case "arm64":
|
|
47
|
-
arch = "aarch64";
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (rawOsType === "Linux") {
|
|
52
|
-
if (libc.familySync() == "musl") {
|
|
53
|
-
osType = "unknown-linux-musl-dynamic";
|
|
54
|
-
} else if (libc.isNonGlibcLinuxSync()) {
|
|
55
|
-
console.warn(
|
|
56
|
-
"Your libc is neither glibc nor musl; trying static musl binary instead",
|
|
57
|
-
);
|
|
58
|
-
osType = "unknown-linux-musl-static";
|
|
59
|
-
} else {
|
|
60
|
-
let libcVersion = libc.versionSync();
|
|
61
|
-
let splitLibcVersion = libcVersion.split(".");
|
|
62
|
-
let libcMajorVersion = splitLibcVersion[0];
|
|
63
|
-
let libcMinorVersion = splitLibcVersion[1];
|
|
64
|
-
if (
|
|
65
|
-
libcMajorVersion != builderGlibcMajorVersion ||
|
|
66
|
-
libcMinorVersion < builderGlibcMinorVersion
|
|
67
|
-
) {
|
|
68
|
-
// We can't run the glibc binaries, but we can run the static musl ones
|
|
69
|
-
// if they exist
|
|
70
|
-
console.warn(
|
|
71
|
-
"Your glibc isn't compatible; trying static musl binary instead",
|
|
72
|
-
);
|
|
73
|
-
osType = "unknown-linux-musl-static";
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Assume the above succeeded and build a target triple to look things up with.
|
|
79
|
-
// If any of it failed, this lookup will fail and we'll handle it like normal.
|
|
80
|
-
let targetTriple = `${arch}-${osType}`;
|
|
81
|
-
let platform = supportedPlatforms[targetTriple];
|
|
82
|
-
|
|
83
|
-
if (!platform) {
|
|
84
|
-
error(
|
|
85
|
-
`Platform with type "${rawOsType}" and architecture "${rawArchitecture}" is not supported by ${name}.\nYour system must be one of the following:\n\n${Object.keys(
|
|
86
|
-
supportedPlatforms,
|
|
87
|
-
).join(",")}`,
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return platform;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const getPackage = () => {
|
|
95
|
-
const platform = getPlatform();
|
|
96
|
-
const url = `${artifactDownloadUrl}/${platform.artifactName}`;
|
|
97
|
-
let filename = platform.artifactName;
|
|
98
|
-
let ext = platform.zipExt;
|
|
99
|
-
let binary = new Package(platform, name, url, filename, ext, platform.bins);
|
|
100
|
-
|
|
101
|
-
return binary;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const install = (suppressLogs) => {
|
|
105
|
-
if (!artifactDownloadUrl || artifactDownloadUrl.length === 0) {
|
|
106
|
-
console.warn("in demo mode, not installing binaries");
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const pkg = getPackage();
|
|
110
|
-
|
|
111
|
-
return pkg.install(suppressLogs);
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const run = (binaryName) => {
|
|
115
|
-
const pkg = getPackage();
|
|
116
|
-
|
|
117
|
-
pkg.run(binaryName);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
module.exports = {
|
|
121
|
-
install,
|
|
122
|
-
run,
|
|
123
|
-
getPackage,
|
|
124
|
-
};
|
package/install.js
DELETED
package/npm-shrinkwrap.json
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"lockfileVersion": 3,
|
|
3
|
-
"name": "@oakoss/oakum",
|
|
4
|
-
"packages": {
|
|
5
|
-
"": {
|
|
6
|
-
"bin": {
|
|
7
|
-
"oakum": "run-oakum.js"
|
|
8
|
-
},
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"detect-libc": "^2.1.2"
|
|
11
|
-
},
|
|
12
|
-
"devDependencies": {
|
|
13
|
-
"prettier": "^3.8.3"
|
|
14
|
-
},
|
|
15
|
-
"engines": {
|
|
16
|
-
"node": ">=14.14",
|
|
17
|
-
"npm": ">=6"
|
|
18
|
-
},
|
|
19
|
-
"hasInstallScript": true,
|
|
20
|
-
"license": "MIT",
|
|
21
|
-
"name": "@oakoss/oakum",
|
|
22
|
-
"version": "0.12.0"
|
|
23
|
-
},
|
|
24
|
-
"node_modules/detect-libc": {
|
|
25
|
-
"engines": {
|
|
26
|
-
"node": ">=8"
|
|
27
|
-
},
|
|
28
|
-
"integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
|
|
29
|
-
"license": "Apache-2.0",
|
|
30
|
-
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
|
|
31
|
-
"version": "2.1.2"
|
|
32
|
-
},
|
|
33
|
-
"node_modules/prettier": {
|
|
34
|
-
"bin": {
|
|
35
|
-
"prettier": "bin/prettier.cjs"
|
|
36
|
-
},
|
|
37
|
-
"dev": true,
|
|
38
|
-
"engines": {
|
|
39
|
-
"node": ">=14"
|
|
40
|
-
},
|
|
41
|
-
"funding": {
|
|
42
|
-
"url": "https://github.com/prettier/prettier?sponsor=1"
|
|
43
|
-
},
|
|
44
|
-
"integrity": "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==",
|
|
45
|
-
"license": "MIT",
|
|
46
|
-
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.3.tgz",
|
|
47
|
-
"version": "3.8.3"
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
"requires": true,
|
|
51
|
-
"version": "0.12.0"
|
|
52
|
-
}
|
package/run-oakum.js
DELETED