Skip to content

Commit 2fe6cf9

Browse files
committed
docs(install): clarify global Socket installs across Node versions
Explain how to install Socket globally with npm and restore the command after switching Node versions. Require the scoped package’s socket alias in the existing tarball smoke check. Assisted-by: Codex:GPT-6-Luna
1 parent 49c1e9c commit 2fe6cf9

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

‎.github/scripts/smoke-test-tarball.mts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,14 @@ try {
3939
readFileSync(join(consumer, 'node_modules', PKG, 'package.json'), 'utf8'),
4040
)
4141
const main = PKG.split('/').pop()!
42+
const requiredBins = PKG === '@socketsecurity/cli' ? [main, 'socket'] : [main]
4243
if (
4344
manifest.name !== PKG ||
4445
manifest.version !== VERSION ||
45-
!Object.hasOwn(manifest.bin ?? {}, main)
46+
requiredBins.some(bin => !Object.hasOwn(manifest.bin ?? {}, bin))
4647
) {
4748
throw new Error(
48-
`Installed manifest does not match ${PKG}@${VERSION} or lacks its main executable.`,
49+
`Installed manifest does not match ${PKG}@${VERSION} or lacks a required executable (${requiredBins.join(', ')}).`,
4950
)
5051
}
5152
for (const bin of Object.keys(manifest.bin)) {

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ npm install -g socket
1313
socket --help
1414
```
1515

16+
The `-g` flag installs Socket globally. Node version managers such as
17+
[fnm](https://github.com/Schniz/fnm), [mise](https://mise.jdx.dev/), and
18+
[nvm](https://github.com/nvm-sh/nvm) can use separate Node installations. If `socket`
19+
is missing after switching versions, run `npm install -g socket` with that Node
20+
version active.
21+
1622
## Usage
1723

1824
### Commands

‎test/release-smoke-test-tarball.test.mts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,23 @@ describe('installed native package smoke test cleanup', () => {
7070
expect.objectContaining({ recursive: true, force: true }),
7171
)
7272
})
73+
74+
it('requires the socket executable for the scoped CLI package even when cli exists', async () => {
75+
vi.stubEnv('PKG', '@socketsecurity/cli')
76+
vi.mocked(readFileSync).mockReturnValue(
77+
JSON.stringify({
78+
name: '@socketsecurity/cli',
79+
version,
80+
bin: { cli: 'bin/cli.js' },
81+
}),
82+
)
83+
84+
await expect(smokeTest()).rejects.toThrow(
85+
/required executable \(cli, socket\)/u,
86+
)
87+
expect(rmSync).toHaveBeenCalledExactlyOnceWith(
88+
consumer,
89+
expect.objectContaining({ recursive: true, force: true }),
90+
)
91+
})
7392
})

0 commit comments

Comments
 (0)