@goliapkg/sentori-cli 0.1.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 +41 -0
- package/bin/sentori-cli.js +32 -0
- package/package.json +40 -0
- package/scripts/postinstall.js +90 -0
package/README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# @goliapkg/sentori-cli
|
|
2
|
+
|
|
3
|
+
Thin npm wrapper around the [Sentori](https://sentori.golia.jp) Rust CLI. The package downloads the prebuilt binary for your platform on `npm install` (postinstall hook) so `npx @goliapkg/sentori-cli` works the moment you have it in `package.json`.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
bun add -d @goliapkg/sentori-cli
|
|
9
|
+
# or npm / pnpm / yarn
|
|
10
|
+
|
|
11
|
+
npx @goliapkg/sentori-cli upload sourcemap \
|
|
12
|
+
--release myapp@1.2.3+456 \
|
|
13
|
+
--token st_pk_... \
|
|
14
|
+
--ingest-url https://ingest.sentori.your-host.com \
|
|
15
|
+
dist/bundle.js.map
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Supported platforms:
|
|
19
|
+
|
|
20
|
+
| OS | Arch |
|
|
21
|
+
|----|------|
|
|
22
|
+
| Linux | x64, arm64 |
|
|
23
|
+
| macOS | x64 (Intel), arm64 (Apple Silicon) |
|
|
24
|
+
|
|
25
|
+
If your platform isn't covered, the postinstall hook will print a soft warning and you can fall back to:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
cargo install --git https://github.com/goliajp/sentori --bin sentori-cli
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Skipping postinstall
|
|
32
|
+
|
|
33
|
+
`SENTORI_SKIP_DOWNLOAD=1` skips the binary download — useful in monorepo bootstrap or sandbox CI environments where the binary will be vendored separately.
|
|
34
|
+
|
|
35
|
+
## Verifying the binary
|
|
36
|
+
|
|
37
|
+
Each release artifact ships with a `.sha256` sidecar published next to the `.tar.gz` on the GitHub Release page; the postinstall script downloads only the tarball but you can manually verify:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
curl -L https://github.com/goliajp/sentori/releases/download/cli-v<VERSION>/sentori-cli-cli-v<VERSION>-darwin-arm64.tar.gz.sha256
|
|
41
|
+
```
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Phase 17 sub-B: Node entry point for `npx @goliapkg/sentori-cli ...`.
|
|
3
|
+
// Forwards argv + stdio to the prebuilt Rust binary that postinstall
|
|
4
|
+
// dropped at ../vendor/sentori-cli.
|
|
5
|
+
|
|
6
|
+
'use strict'
|
|
7
|
+
|
|
8
|
+
const path = require('node:path')
|
|
9
|
+
const fs = require('node:fs')
|
|
10
|
+
const { spawn } = require('node:child_process')
|
|
11
|
+
|
|
12
|
+
const bin = path.join(__dirname, '..', 'vendor', 'sentori-cli')
|
|
13
|
+
if (!fs.existsSync(bin)) {
|
|
14
|
+
console.error(
|
|
15
|
+
'sentori-cli binary missing — postinstall did not complete. ' +
|
|
16
|
+
'Try: `npm rebuild @goliapkg/sentori-cli` or set SENTORI_SKIP_DOWNLOAD=0 then reinstall.'
|
|
17
|
+
)
|
|
18
|
+
process.exit(127)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const child = spawn(bin, process.argv.slice(2), { stdio: 'inherit' })
|
|
22
|
+
child.on('exit', (code, signal) => {
|
|
23
|
+
if (signal) {
|
|
24
|
+
process.kill(process.pid, signal)
|
|
25
|
+
} else {
|
|
26
|
+
process.exit(code ?? 1)
|
|
27
|
+
}
|
|
28
|
+
})
|
|
29
|
+
child.on('error', (e) => {
|
|
30
|
+
console.error('failed to run sentori-cli:', e.message)
|
|
31
|
+
process.exit(1)
|
|
32
|
+
})
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@goliapkg/sentori-cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Sentori CLI — upload source maps + other release artifacts to a Sentori server. Thin wrapper that downloads the matching prebuilt Rust binary at install time.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://sentori.golia.jp",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/goliajp/sentori.git",
|
|
10
|
+
"directory": "cli/npm"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/goliajp/sentori/issues"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"sentori",
|
|
17
|
+
"cli",
|
|
18
|
+
"sourcemap",
|
|
19
|
+
"error-tracking"
|
|
20
|
+
],
|
|
21
|
+
"bin": {
|
|
22
|
+
"sentori-cli": "bin/sentori-cli.js"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"postinstall": "node scripts/postinstall.js || echo 'sentori-cli postinstall failed — run `npx @goliapkg/sentori-cli` once you have network'"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"bin/",
|
|
29
|
+
"scripts/",
|
|
30
|
+
"README.md"
|
|
31
|
+
],
|
|
32
|
+
"engines": {
|
|
33
|
+
"node": ">=18"
|
|
34
|
+
},
|
|
35
|
+
"os": ["darwin", "linux"],
|
|
36
|
+
"cpu": ["x64", "arm64"],
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Phase 17 sub-B: download the prebuilt sentori-cli binary that
|
|
3
|
+
// matches the current platform / arch and place it at ../vendor/.
|
|
4
|
+
//
|
|
5
|
+
// Skips if SENTORI_SKIP_DOWNLOAD=1 (CI, monorepo bootstrap, etc.).
|
|
6
|
+
|
|
7
|
+
'use strict'
|
|
8
|
+
|
|
9
|
+
const fs = require('node:fs')
|
|
10
|
+
const https = require('node:https')
|
|
11
|
+
const path = require('node:path')
|
|
12
|
+
const { spawnSync } = require('node:child_process')
|
|
13
|
+
|
|
14
|
+
const pkg = require(path.join(__dirname, '..', 'package.json'))
|
|
15
|
+
const TAG = `cli-v${pkg.version}`
|
|
16
|
+
|
|
17
|
+
const SUPPORTED = {
|
|
18
|
+
'linux-x64': 'linux-x64',
|
|
19
|
+
'linux-arm64': 'linux-arm64',
|
|
20
|
+
'darwin-x64': 'darwin-x64',
|
|
21
|
+
'darwin-arm64': 'darwin-arm64',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function detect() {
|
|
25
|
+
return `${process.platform}-${process.arch}`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function fetch(url, destStream) {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
const handle = (u) => {
|
|
31
|
+
https
|
|
32
|
+
.get(u, { headers: { 'user-agent': `sentori-cli-installer/${pkg.version}` } }, (res) => {
|
|
33
|
+
const code = res.statusCode || 0
|
|
34
|
+
if (code >= 300 && code < 400 && res.headers.location) {
|
|
35
|
+
return handle(res.headers.location)
|
|
36
|
+
}
|
|
37
|
+
if (code !== 200) {
|
|
38
|
+
return reject(new Error(`HTTP ${code} from ${u}`))
|
|
39
|
+
}
|
|
40
|
+
res.pipe(destStream)
|
|
41
|
+
destStream.on('finish', resolve)
|
|
42
|
+
destStream.on('error', reject)
|
|
43
|
+
})
|
|
44
|
+
.on('error', reject)
|
|
45
|
+
}
|
|
46
|
+
handle(url)
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function main() {
|
|
51
|
+
if (process.env.SENTORI_SKIP_DOWNLOAD === '1') {
|
|
52
|
+
console.log('SENTORI_SKIP_DOWNLOAD=1; skipping sentori-cli binary download')
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const key = detect()
|
|
57
|
+
const slug = SUPPORTED[key]
|
|
58
|
+
if (!slug) {
|
|
59
|
+
console.error(
|
|
60
|
+
`sentori-cli has no prebuilt binary for ${key}. ` +
|
|
61
|
+
`Cargo install instead: cargo install --git https://github.com/goliajp/sentori --bin sentori-cli`
|
|
62
|
+
)
|
|
63
|
+
process.exit(0) // soft fail — user can still cargo install
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const filename = `sentori-cli-${TAG}-${slug}.tar.gz`
|
|
67
|
+
const url = `https://github.com/goliajp/sentori/releases/download/${TAG}/${filename}`
|
|
68
|
+
const vendorDir = path.join(__dirname, '..', 'vendor')
|
|
69
|
+
fs.mkdirSync(vendorDir, { recursive: true })
|
|
70
|
+
const tarball = path.join(vendorDir, 'sentori-cli.tar.gz')
|
|
71
|
+
|
|
72
|
+
console.log(`sentori-cli ${pkg.version}: downloading ${slug} from GitHub Release`)
|
|
73
|
+
await fetch(url, fs.createWriteStream(tarball))
|
|
74
|
+
|
|
75
|
+
const tar = spawnSync('tar', ['-xzf', tarball, '-C', vendorDir], { stdio: 'inherit' })
|
|
76
|
+
if (tar.status !== 0) {
|
|
77
|
+
console.error('tar -xzf failed; is `tar` on PATH?')
|
|
78
|
+
process.exit(1)
|
|
79
|
+
}
|
|
80
|
+
fs.unlinkSync(tarball)
|
|
81
|
+
|
|
82
|
+
const bin = path.join(vendorDir, 'sentori-cli')
|
|
83
|
+
fs.chmodSync(bin, 0o755)
|
|
84
|
+
console.log(`✓ sentori-cli ${pkg.version} ready (${slug})`)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
main().catch((e) => {
|
|
88
|
+
console.error('sentori-cli install failed:', e.message)
|
|
89
|
+
process.exit(1)
|
|
90
|
+
})
|