maritime-cli 2.0.0 → 2.0.1

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 CHANGED
@@ -1,8 +1,8 @@
1
1
  # maritime-cli
2
2
 
3
- The Maritime command line client. This package downloads the `maritime`
4
- binary for your platform from the matching GitHub release and verifies its
5
- SHA-256 before it runs.
3
+ The Maritime command line client. This package ships the `maritime` binary
4
+ for every supported platform and unpacks the one for yours at install time,
5
+ after checking its SHA-256.
6
6
 
7
7
  ```bash
8
8
  npm i -g maritime-cli
@@ -13,5 +13,4 @@ Documentation, the command reference, and the source live in
13
13
  [cli/go](https://github.com/maritime-sh/maritime/tree/main/cli/go) of the
14
14
  Maritime repository.
15
15
 
16
- Set `MARITIME_CLI_DOWNLOAD_BASE` to install from a mirror of the release
17
- assets. Every command name from maritime-cli 1.x keeps working.
16
+ Every command name from maritime-cli 1.x keeps working.
@@ -0,0 +1,6 @@
1
+ db571b75258dcc13f10deee1fcb2b0d0338ba3d08213b69c26cce783eb313830 maritime_2.0.1_darwin_amd64.tar.gz
2
+ 1f6b25fcfe5e5771d3f40bee2ef00a6ff11fe654224d002134d6befd4607ea77 maritime_2.0.1_darwin_arm64.tar.gz
3
+ c41a060161f5bdb20b58af5feff7098da69187b9c03b83f909c300ab98797efc maritime_2.0.1_linux_amd64.tar.gz
4
+ 53eb11396800f22b41486291fb8874eb9755cbdc40c7a5802347789b4c606719 maritime_2.0.1_linux_arm64.tar.gz
5
+ f58e42877b03dbc05cfa053af1db8a6ea9fd492d78cc7e6faea3b5c924f12ea8 maritime_2.0.1_windows_amd64.zip
6
+ 6a913ff1ff4d3352da061fbdcfc38699c975bbaa3aac04abb4a362951bfd6bf3 maritime_2.0.1_windows_arm64.zip
package/install.js CHANGED
@@ -1,11 +1,14 @@
1
1
  'use strict'
2
- // Downloads the Maritime CLI binary for this platform from the GitHub
3
- // release that matches package.json's version, verifies its SHA-256 against
4
- // the release's checksums.txt, and unpacks it next to this file.
2
+ // Unpacks the Maritime CLI binary for this platform next to this file.
3
+ //
4
+ // The package ships the release archives for every platform under archives/
5
+ // together with their checksums.txt, so an install needs no network. When a
6
+ // bundled archive is missing, the archive is downloaded from
7
+ // MARITIME_CLI_DOWNLOAD_BASE, or from the GitHub release of this version.
8
+ // Either way the SHA-256 is verified before anything is unpacked.
5
9
  //
6
10
  // Runs as the package's postinstall step. Running it again is safe: an
7
- // existing binary of the right version is kept. Set
8
- // MARITIME_CLI_DOWNLOAD_BASE to install from a mirror of the release assets.
11
+ // existing binary of the right version is kept.
9
12
 
10
13
  const { createHash } = require('node:crypto')
11
14
  const fs = require('node:fs')
@@ -18,6 +21,7 @@ const VERSION = pkg.version
18
21
  const RELEASE_TAG = `cli-v${VERSION}`
19
22
  const DEFAULT_BASE = `https://github.com/maritime-sh/maritime/releases/download/${RELEASE_TAG}`
20
23
  const VENDOR_DIR = path.join(__dirname, 'vendor')
24
+ const ARCHIVE_DIR = path.join(__dirname, 'archives')
21
25
  const MARKER = path.join(VENDOR_DIR, 'version')
22
26
  const CHECKSUMS = 'checksums.txt'
23
27
  const SHA256_HEX_LENGTH = 64
@@ -42,6 +46,15 @@ function binaryPath() {
42
46
  return path.join(VENDOR_DIR, process.platform === 'win32' ? 'maritime.exe' : 'maritime')
43
47
  }
44
48
 
49
+ /** Returns the bundled file, or fetches it from base when it is not bundled. */
50
+ async function obtain(base, name) {
51
+ const bundled = path.join(ARCHIVE_DIR, name)
52
+ if (fs.existsSync(bundled)) {
53
+ return fs.readFileSync(bundled)
54
+ }
55
+ return download(`${base}/${name}`)
56
+ }
57
+
45
58
  /** Fetches url and returns its body as a Buffer. */
46
59
  async function download(url) {
47
60
  const controller = new AbortController()
@@ -82,8 +95,8 @@ async function install() {
82
95
  }
83
96
  const base = (process.env.MARITIME_CLI_DOWNLOAD_BASE || DEFAULT_BASE).replace(/\/+$/, '')
84
97
  const [archive, checksums] = await Promise.all([
85
- download(`${base}/${name}`),
86
- download(`${base}/${CHECKSUMS}`),
98
+ obtain(base, name),
99
+ obtain(base, CHECKSUMS),
87
100
  ])
88
101
  const actual = createHash('sha256').update(archive).digest('hex')
89
102
  const expected = expectedChecksum(checksums.toString('utf8'), name)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "maritime-cli",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Maritime command line client: provision, operate, and inspect AI agents on maritime.sh.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -15,6 +15,7 @@
15
15
  "files": [
16
16
  "bin",
17
17
  "install.js",
18
+ "archives",
18
19
  "README.md"
19
20
  ],
20
21
  "scripts": {