Skip to content

Commit 3b8e197

Browse files
committed
refactor(cli): move socket-lib CLI trio out of src/bin/ into src/cli/
src/bin/ is the binary-resolution library (find/resolve/which/exec/ shadow). The socket-lib CLI app — entry dispatcher (socket-lib.ts), the check subcommand group (check.ts), and the primordials handler (check-primordials.ts) — was misfiled there. Move it to src/cli/ so bin/ stays a pure helper module. Exports regenerate ./cli/* (glob-driven); bin.socket-lib repoints to dist/cli/socket-lib.js. Tests follow to test/unit/cli/. prim CLI (tools/prim) untouched.
1 parent 91ad4ef commit 3b8e197

7 files changed

Lines changed: 29 additions & 29 deletions

File tree

package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"bin": {
2323
"prim": "./dist/bin/prim.cjs",
24-
"socket-lib": "./dist/bin/socket-lib.js"
24+
"socket-lib": "./dist/cli/socket-lib.js"
2525
},
2626
"files": [
2727
"dist",
@@ -225,16 +225,6 @@
225225
"types": "./dist/arrays/unique.d.ts",
226226
"default": "./dist/arrays/unique.js"
227227
},
228-
"./bin/check": {
229-
"source": "./src/bin/check.ts",
230-
"types": "./dist/bin/check.d.ts",
231-
"default": "./dist/bin/check.js"
232-
},
233-
"./bin/check-primordials": {
234-
"source": "./src/bin/check-primordials.ts",
235-
"types": "./dist/bin/check-primordials.d.ts",
236-
"default": "./dist/bin/check-primordials.js"
237-
},
238228
"./bin/exec": {
239229
"source": "./src/bin/exec.ts",
240230
"types": "./dist/bin/exec.d.ts",
@@ -255,11 +245,6 @@
255245
"types": "./dist/bin/shadow.d.ts",
256246
"default": "./dist/bin/shadow.js"
257247
},
258-
"./bin/socket-lib": {
259-
"source": "./src/bin/socket-lib.ts",
260-
"types": "./dist/bin/socket-lib.d.ts",
261-
"default": "./dist/bin/socket-lib.js"
262-
},
263248
"./bin/types": {
264249
"source": "./src/bin/types.ts",
265250
"types": "./dist/bin/types.d.ts",
@@ -315,6 +300,21 @@
315300
"types": "./dist/checks/primordials-defaults.d.ts",
316301
"default": "./dist/checks/primordials-defaults.js"
317302
},
303+
"./cli/check": {
304+
"source": "./src/cli/check.ts",
305+
"types": "./dist/cli/check.d.ts",
306+
"default": "./dist/cli/check.js"
307+
},
308+
"./cli/check-primordials": {
309+
"source": "./src/cli/check-primordials.ts",
310+
"types": "./dist/cli/check-primordials.d.ts",
311+
"default": "./dist/cli/check-primordials.js"
312+
},
313+
"./cli/socket-lib": {
314+
"source": "./src/cli/socket-lib.ts",
315+
"types": "./dist/cli/socket-lib.d.ts",
316+
"default": "./dist/cli/socket-lib.js"
317+
},
318318
"./colors/convert": {
319319
"browser": {
320320
"source": "./src/colors/convert.ts",
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* @file `socket-lib` CLI entry point — top-level dispatcher. socket-lib — print
44
* help, list commands socket-lib check <name> [opts...] — run a fleet-wide
5-
* check Subcommands live as siblings under `src/bin/`; each is its own file
5+
* check Subcommands live as siblings under `src/cli/`; each is its own file
66
* so a misbehaving check can't crash other commands at parse time. The
77
* dispatcher just routes; subcommands own their own arg parsing. The CLI is
88
* shipped via the `bin` field in package.json and intended to be invoked as
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { fileURLToPath } from 'node:url'
1616

1717
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
1818

19-
import { runCheckPrimordials } from '../../../src/bin/check-primordials'
19+
import { runCheckPrimordials } from '../../../src/cli/check-primordials'
2020
import { safeDelete } from '../../../src/fs/safe'
2121

2222
// Absolute path to socket-lib's own primordials source. Each test
@@ -291,13 +291,13 @@ describe('runCheckPrimordials', () => {
291291
describe('resolveConfigPath', () => {
292292
it('returns the explicit path verbatim when provided', async () => {
293293
const { resolveConfigPath } =
294-
await import('../../../src/bin/check-primordials')
294+
await import('../../../src/cli/check-primordials')
295295
expect(resolveConfigPath('/explicit/path.json')).toBe('/explicit/path.json')
296296
})
297297

298298
it('returns the first fallback when no explicit path is given', async () => {
299299
const { resolveConfigPath } =
300-
await import('../../../src/bin/check-primordials')
300+
await import('../../../src/cli/check-primordials')
301301
// No explicit + none of the fallback paths exist → returns the head
302302
// of FALLBACK_CONFIG_PATHS so the "config file not found" error
303303
// names the canonical default.
@@ -309,14 +309,14 @@ describe('resolveConfigPath', () => {
309309

310310
describe('printHelp', () => {
311311
it('writes usage text to stdout without throwing', async () => {
312-
const { printHelp } = await import('../../../src/bin/check-primordials')
312+
const { printHelp } = await import('../../../src/cli/check-primordials')
313313
expect(() => printHelp()).not.toThrow()
314314
})
315315
})
316316

317317
describe('renderHuman', () => {
318318
it('emits success when no findings + silent=false', async () => {
319-
const { renderHuman } = await import('../../../src/bin/check-primordials')
319+
const { renderHuman } = await import('../../../src/cli/check-primordials')
320320
expect(() =>
321321
renderHuman(
322322
{
@@ -336,7 +336,7 @@ describe('renderHuman', () => {
336336
})
337337

338338
it('emits nothing when silent + no findings', async () => {
339-
const { renderHuman } = await import('../../../src/bin/check-primordials')
339+
const { renderHuman } = await import('../../../src/cli/check-primordials')
340340
expect(() =>
341341
renderHuman(
342342
{
@@ -356,7 +356,7 @@ describe('renderHuman', () => {
356356
})
357357

358358
it('renders findings with hint when --explain is set', async () => {
359-
const { renderHuman } = await import('../../../src/bin/check-primordials')
359+
const { renderHuman } = await import('../../../src/cli/check-primordials')
360360
expect(() =>
361361
renderHuman(
362362
{
@@ -383,7 +383,7 @@ describe('renderHuman', () => {
383383
})
384384

385385
it('renders findings without files when files list is empty', async () => {
386-
const { renderHuman } = await import('../../../src/bin/check-primordials')
386+
const { renderHuman } = await import('../../../src/cli/check-primordials')
387387
expect(() =>
388388
renderHuman(
389389
{
@@ -410,7 +410,7 @@ describe('renderHuman', () => {
410410
})
411411

412412
it('emits trailing "run with --explain" hint when not explaining', async () => {
413-
const { renderHuman } = await import('../../../src/bin/check-primordials')
413+
const { renderHuman } = await import('../../../src/cli/check-primordials')
414414
expect(() =>
415415
renderHuman(
416416
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { describe, expect, it } from 'vitest'
99

10-
import { runCheck } from '../../../src/bin/check'
10+
import { runCheck } from '../../../src/cli/check'
1111

1212
describe('socket-lib check dispatcher', () => {
1313
it('prints help and exits 0 when called with no args', async () => {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
* dispatcher's job is to route the first argv slot — print help when empty /
44
* --help, hand off to runCheck when 'check', error out otherwise. Tests call
55
* the exported `main` function directly so coverage attributes to
6-
* src/bin/socket-lib.ts; the require.main === module entry guard is a no-op
6+
* src/cli/socket-lib.ts; the require.main === module entry guard is a no-op
77
* when imported.
88
*/
99

1010
import { describe, expect, it } from 'vitest'
1111

12-
import { main, printHelp } from '../../../src/bin/socket-lib'
12+
import { main, printHelp } from '../../../src/cli/socket-lib'
1313

1414
describe('socket-lib CLI dispatcher', () => {
1515
it('prints help and exits 0 with no args', async () => {

0 commit comments

Comments
 (0)