@straddlecom/cli 1.0.2 → 1.0.4
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 +3 -3
- package/bin/straddle.js +17 -8
- package/install.js +5 -3
- package/package.json +16 -5
- package/resolve.js +20 -0
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ Or try it without a global installation:
|
|
|
17
17
|
npx @straddlecom/cli --help
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
Requires Node.js 18 or newer and macOS, Linux, or Windows on x64 or ARM64.
|
|
20
|
+
Requires Node.js 18 or newer and macOS, Linux, or Windows on x64 or ARM64. You do not need Go installed.
|
|
21
21
|
|
|
22
22
|
## Get started
|
|
23
23
|
|
|
@@ -33,9 +33,9 @@ For authentication, account setup, and available commands, see the [CLI document
|
|
|
33
33
|
|
|
34
34
|
## How installation works
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
npm installs the Go binary for your operating system and architecture as an optional dependency, `@straddlecom/cli-<platform>-<arch>`. Those packages hold only the binary and run no install scripts, so installation works when npm install scripts are disabled. The `straddle` command runs that binary. Node tools can locate it with `require('@straddlecom/cli').binaryPath()`, which returns `null` when no binary is installed.
|
|
37
37
|
|
|
38
|
-
If npm install
|
|
38
|
+
If that package is missing, for example after `npm install --omit=optional` or from a lockfile written on another operating system, the launcher downloads the binary from the matching [GitHub release](https://github.com/straddle-build/straddle-cli/releases) the first time you run `straddle`. It checks the archive's SHA-256 digest against that release's `checksums.txt` before extracting it, which needs `tar` on macOS/Linux or PowerShell on Windows.
|
|
39
39
|
|
|
40
40
|
## Links
|
|
41
41
|
|
package/bin/straddle.js
CHANGED
|
@@ -1,20 +1,29 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Launcher for @straddlecom/cli: executes the
|
|
3
|
-
//
|
|
2
|
+
// Launcher for @straddlecom/cli: executes the binary from this platform's
|
|
3
|
+
// @straddlecom/cli-<platform>-<arch> package, downloading it into vendor/
|
|
4
|
+
// first when that optional dependency was not installed.
|
|
4
5
|
'use strict';
|
|
5
6
|
|
|
6
|
-
const fs = require('node:fs');
|
|
7
7
|
const path = require('node:path');
|
|
8
8
|
const { spawnSync } = require('node:child_process');
|
|
9
|
+
const { binaryPath } = require('../resolve.js');
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
const binPath = path.join(__dirname, '..', 'vendor', bin);
|
|
11
|
+
let binPath = binaryPath();
|
|
12
12
|
|
|
13
|
-
if (
|
|
13
|
+
if (binPath === null) {
|
|
14
|
+
console.error(
|
|
15
|
+
`@straddlecom/cli: @straddlecom/cli-${process.platform}-${process.arch} is not installed. ` +
|
|
16
|
+
'npm skips this optional dependency under --omit=optional, with a lockfile written on ' +
|
|
17
|
+
'another OS, or on an unsupported platform. Downloading the binary from GitHub Releases instead.'
|
|
18
|
+
);
|
|
14
19
|
const installer = path.join(__dirname, '..', 'install.js');
|
|
15
20
|
const result = spawnSync(process.execPath, [installer], { stdio: 'inherit' });
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
binPath = binaryPath();
|
|
22
|
+
if (result.status !== 0 || binPath === null) {
|
|
23
|
+
console.error(
|
|
24
|
+
'@straddlecom/cli: binary install failed; see errors above. ' +
|
|
25
|
+
'Reinstall with optional dependencies (npm install @straddlecom/cli --include=optional).'
|
|
26
|
+
);
|
|
18
27
|
process.exit(result.status === null || result.status === 0 ? 1 : result.status);
|
|
19
28
|
}
|
|
20
29
|
}
|
package/install.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
//
|
|
3
|
-
// platform
|
|
4
|
-
//
|
|
2
|
+
// Fallback installer for @straddlecom/cli, run by bin/straddle.js when this
|
|
3
|
+
// platform's @straddlecom/cli-<platform>-<arch> package is not installed:
|
|
4
|
+
// downloads the straddle binary from GitHub Releases, verifies its sha256
|
|
5
|
+
// against the release checksums.txt, and unpacks it into vendor/. Node
|
|
6
|
+
// builtins only.
|
|
5
7
|
'use strict';
|
|
6
8
|
|
|
7
9
|
const crypto = require('node:crypto');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@straddlecom/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Straddle CLI for Pay by Bank and Embed APIs, local payments data, and analytics",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -11,13 +11,16 @@
|
|
|
11
11
|
"bin": {
|
|
12
12
|
"straddle": "bin/straddle.js"
|
|
13
13
|
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./resolve.js",
|
|
16
|
+
"./resolve": "./resolve.js",
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
14
19
|
"files": [
|
|
15
20
|
"bin",
|
|
16
|
-
"install.js"
|
|
21
|
+
"install.js",
|
|
22
|
+
"resolve.js"
|
|
17
23
|
],
|
|
18
|
-
"scripts": {
|
|
19
|
-
"postinstall": "node install.js"
|
|
20
|
-
},
|
|
21
24
|
"os": [
|
|
22
25
|
"darwin",
|
|
23
26
|
"linux",
|
|
@@ -29,5 +32,13 @@
|
|
|
29
32
|
],
|
|
30
33
|
"engines": {
|
|
31
34
|
"node": ">=18"
|
|
35
|
+
},
|
|
36
|
+
"optionalDependencies": {
|
|
37
|
+
"@straddlecom/cli-darwin-arm64": "1.0.4",
|
|
38
|
+
"@straddlecom/cli-darwin-x64": "1.0.4",
|
|
39
|
+
"@straddlecom/cli-linux-arm64": "1.0.4",
|
|
40
|
+
"@straddlecom/cli-linux-x64": "1.0.4",
|
|
41
|
+
"@straddlecom/cli-win32-arm64": "1.0.4",
|
|
42
|
+
"@straddlecom/cli-win32-x64": "1.0.4"
|
|
32
43
|
}
|
|
33
44
|
}
|
package/resolve.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Locates the straddle binary for this platform. Releases ship it in the
|
|
2
|
+
// @straddlecom/cli-<platform>-<arch> optional dependency; vendor/ holds a copy
|
|
3
|
+
// that bin/straddle.js downloaded when that package was not installed.
|
|
4
|
+
'use strict';
|
|
5
|
+
|
|
6
|
+
const fs = require('node:fs');
|
|
7
|
+
const path = require('node:path');
|
|
8
|
+
|
|
9
|
+
function binaryPath() {
|
|
10
|
+
const exe = process.platform === 'win32' ? 'straddle.exe' : 'straddle';
|
|
11
|
+
try {
|
|
12
|
+
return require.resolve(`@straddlecom/cli-${process.platform}-${process.arch}/bin/${exe}`);
|
|
13
|
+
} catch {
|
|
14
|
+
// Missing or unsupported platform package; try the downloaded copy.
|
|
15
|
+
}
|
|
16
|
+
const vendored = path.join(__dirname, 'vendor', exe);
|
|
17
|
+
return fs.existsSync(vendored) ? vendored : null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = { binaryPath };
|