Skip to content

Commit a1958a4

Browse files
committed
refactor: migrate to pnpm monorepo structure
Create 14 packages with clear separation of concerns: - @socketsecurity/cli: Full JavaScript CLI implementation - socket: Thin wrapper that downloads CLI on demand - 8 platform binary packages (@socketbin/cli-*) - 2 private build tool packages Move all CLI source code to packages/cli/ while preserving git history through renames. Configure pnpm workspace and add documentation for monorepo structure. BREAKING CHANGE: Repository structure changed to monorepo
1 parent 6bb8459 commit a1958a4

File tree

948 files changed

+3024
-95
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

948 files changed

+3024
-95
lines changed

MONOREPO.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Socket CLI Monorepo Guide
2+
3+
This document explains the monorepo structure and how the different packages relate to each other.
4+
5+
## Package Overview
6+
7+
### Three Release Builds
8+
9+
Socket CLI releases three distinct npm packages:
10+
11+
1. **`@socketsecurity/cli`** - Full JavaScript CLI implementation
12+
2. **`@socketsecurity/cli-with-sentry`** - Full JavaScript CLI with Sentry telemetry
13+
3. **`socket`** - Thin wrapper that downloads `@socketsecurity/cli` on demand
14+
15+
### Platform Binary Packages (8 total)
16+
17+
Optional platform-specific native binaries:
18+
19+
- `@socketbin/cli-darwin-arm64` - macOS Apple Silicon
20+
- `@socketbin/cli-darwin-x64` - macOS Intel
21+
- `@socketbin/cli-linux-arm64` - Linux ARM64 (glibc)
22+
- `@socketbin/cli-linux-x64` - Linux x64 (glibc)
23+
- `@socketbin/cli-alpine-arm64` - Alpine Linux ARM64 (musl)
24+
- `@socketbin/cli-alpine-x64` - Alpine Linux x64 (musl)
25+
- `@socketbin/cli-win32-arm64` - Windows ARM64
26+
- `@socketbin/cli-win32-x64` - Windows x64
27+
28+
### Private Build Tools (2 total)
29+
30+
- `@socketbin/custom-node` - Builds custom Node.js from source with Socket patches
31+
- `@socketbin/sea` - Builds Socket CLI as native Node.js SEA binaries (fallback)
32+
33+
## Directory Structure
34+
35+
```
36+
socket-cli/
37+
├── packages/
38+
│ ├── cli/ # @socketsecurity/cli
39+
│ │ ├── src/ # CLI source code
40+
│ │ ├── bin/ # CLI entry points
41+
│ │ ├── test/ # Tests
42+
│ │ ├── data/ # Static data
43+
│ │ └── package.json
44+
│ │
45+
│ ├── socket/ # socket (thin wrapper)
46+
│ │ ├── bin/
47+
│ │ │ ├── socket.js # Entry point
48+
│ │ │ └── bootstrap.js # Bootstrap logic
49+
│ │ └── package.json
50+
│ │
51+
│ ├── socketbin-custom-node-from-source/ # Custom Node.js builder
52+
│ │ ├── build/
53+
│ │ │ ├── patches/ # Socket security patches
54+
│ │ │ └── additions/ # Additional C++ code
55+
│ │ ├── scripts/
56+
│ │ │ └── build.mjs # Build script
57+
│ │ └── package.json
58+
│ │
59+
│ ├── socketbin-native-node-sea/ # SEA builder
60+
│ │ ├── scripts/
61+
│ │ │ ├── build.mjs # SEA build script
62+
│ │ │ └── publish.mjs # Publish script
63+
│ │ └── package.json
64+
│ │
65+
│ └── socketbin-cli-{platform}-{arch}/ # 8 platform packages
66+
│ ├── bin/
67+
│ │ └── socket (or socket.exe) # Native binary
68+
│ └── package.json
69+
70+
├── pnpm-workspace.yaml # pnpm workspace config
71+
└── package.json # Root workspace

package.json

Lines changed: 14 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,4 @@
11
{
2-
"name": "socket",
3-
"version": "1.1.25",
4-
"private": true,
5-
"description": "CLI for Socket.dev",
6-
"homepage": "https://github.com/SocketDev/socket-cli",
7-
"license": "MIT",
8-
"repository": {
9-
"type": "git",
10-
"url": "git+https://github.com/SocketDev/socket-cli.git"
11-
},
12-
"author": {
13-
"name": "Socket Inc",
14-
"email": "eng@socket.dev",
15-
"url": "https://socket.dev"
16-
},
17-
"bin": {
18-
"socket": "bin/cli.js",
19-
"socket-npm": "bin/npm-cli.js",
20-
"socket-npx": "bin/npx-cli.js",
21-
"socket-pnpm": "bin/pnpm-cli.js",
22-
"socket-yarn": "bin/yarn-cli.js"
23-
},
24-
"exports": {
25-
"./bin/cli.js": "./dist/cli.js",
26-
"./bin/npm-cli.js": "./dist/npm-cli.js",
27-
"./bin/npx-cli.js": "./dist/npx-cli.js",
28-
"./bin/pnpm-cli.js": "./dist/pnpm-cli.js",
29-
"./bin/yarn-cli.js": "./dist/yarn-cli.js",
30-
"./package.json": "./package.json",
31-
"./data/alert-translations.json": "./data/alert-translations.json",
32-
"./data/command-api-requirements.json": "./data/command-api-requirements.json"
33-
},
34-
"scripts": {
35-
"build": "node --import=./scripts/load.mjs scripts/build.mjs --src-only",
36-
"build:sea:internal:bootstrap": "rollup -c .config/rollup.cli-sea.config.mjs",
37-
"build:js": "node scripts/extract-yoga-wasm.mjs && node .config/esbuild.cli.build.mjs",
38-
"build:watch": "node scripts/extract-yoga-wasm.mjs && node .config/esbuild.cli.build.mjs --watch",
39-
"dev": "pnpm run build:watch",
40-
"publish:sea": "node --import=./scripts/load.mjs scripts/publish-sea.mjs",
41-
"check": "node --import=./scripts/load.mjs scripts/check.mjs",
42-
"check-ci": "pnpm run check",
43-
"claude": "node scripts/claude.mjs",
44-
"lint": "node --import=./scripts/load.mjs scripts/lint.mjs",
45-
"lint-ci": "pnpm run lint",
46-
"type": "tsc --noEmit",
47-
"type-ci": "pnpm run type",
48-
"cover": "node --import=./scripts/load.mjs scripts/cover.mjs",
49-
"clean": "run-p -c --aggregate-output clean:*",
50-
"clean:cache": "del-cli '**/.cache'",
51-
"clean:dist": "del-cli 'dist'",
52-
"clean:node_modules": "del-cli '**/node_modules'",
53-
"fix": "node --import=./scripts/load.mjs scripts/fix.mjs",
54-
"lint-staged": "dotenvx -q run -f .env.local -- lint-staged",
55-
"precommit": "dotenvx -q run -f .env.local -- lint-staged",
56-
"prepare": "dotenvx -q run -f .env.local -- husky",
57-
"bs": "dotenvx -q run -f .env.local -- pnpm run build --src-only; pnpm exec socket --",
58-
"s": "dotenvx -q run -f .env.local -- pnpm exec socket --",
59-
"e2e-tests": "dotenvx -q run -f .env.test -- vitest run --config vitest.e2e.config.mts",
60-
"test": "run-s check test:*",
61-
"test:prepare": "dotenvx -q run -f .env.test -- pnpm build && del-cli 'test/**/node_modules'",
62-
"test:unit": "dotenvx -q run -f .env.test -- vitest run",
63-
"test:unit:update": "dotenvx -q run -f .env.test -- vitest run --update",
64-
"test:unit:coverage": "dotenvx -q run -f .env.test -- vitest run --coverage",
65-
"test:validate": "node --import=./scripts/load.mjs scripts/validate-tests.mjs",
66-
"test:wrapper": "node --import=./scripts/load.mjs scripts/test-wrapper.mjs",
67-
"test-ci": "run-s test:*",
68-
"test-pre-commit": "dotenvx -q run -f .env.precommit -- pnpm test",
69-
"update": "node --import=./scripts/load.mjs scripts/update.mjs",
70-
"wasm": "node scripts/wasm.mjs",
71-
"wasm:build": "node scripts/wasm.mjs --build",
72-
"wasm:download": "node scripts/wasm.mjs --download"
73-
},
742
"devDependencies": {
753
"@babel/core": "7.28.4",
764
"@babel/parser": "^7.28.4",
@@ -186,20 +114,12 @@
186114
"node": ">=18",
187115
"pnpm": ">=10.16.0"
188116
},
189-
"files": [
190-
"bin/**",
191-
"data/**",
192-
"dist/**",
193-
"shadow-bin/**",
194-
"CHANGELOG.md",
195-
"logo-dark.png",
196-
"logo-light.png"
197-
],
198117
"lint-staged": {
199118
"*.{cjs,cts,js,json,md,mjs,mts,ts}": [
200119
"biome check --write --unsafe --no-errors-on-unmatched --files-ignore-unknown=true --colors=off"
201120
]
202121
},
122+
"name": "socket-cli-monorepo",
203123
"pnpm": {
204124
"overrides": {
205125
"@octokit/graphql": "9.0.1",
@@ -255,6 +175,18 @@
255175
"yoga-layout": "patches/yoga-layout.patch"
256176
}
257177
},
178+
"private": true,
179+
"scripts": {
180+
"build": "pnpm --filter \"./packages/**\" run build",
181+
"build:cli": "pnpm --filter @socketsecurity/cli run build",
182+
"build:socket": "pnpm --filter socket run build",
183+
"check": "pnpm --filter @socketsecurity/cli run check",
184+
"clean": "pnpm --filter \"./packages/**\" run clean",
185+
"lint": "pnpm --filter @socketsecurity/cli run lint",
186+
"prepare": "dotenvx -q run -f .env.local -- husky",
187+
"test": "pnpm --filter @socketsecurity/cli run test",
188+
"type": "pnpm --filter @socketsecurity/cli run type"
189+
},
258190
"typeCoverage": {
259191
"cache": true,
260192
"atLeast": 95,
@@ -266,9 +198,5 @@
266198
"ignore-files": "test/*",
267199
"strict": true
268200
},
269-
"dependencies": {
270-
"ajv-dist": "8.17.1",
271-
"compromise": "^14.14.4",
272-
"onnxruntime-web": "^1.23.0"
273-
}
201+
"version": "1.1.25"
274202
}

packages/cli/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# @socketsecurity/cli
2+
3+
Full Socket CLI implementation for supply chain security analysis.
4+
5+
## Installation
6+
7+
```bash
8+
npm install -g @socketsecurity/cli
9+
```
10+
11+
Or use via the thin `socket` wrapper:
12+
13+
```bash
14+
npm install -g socket
15+
```
16+
17+
## Usage
18+
19+
```bash
20+
socket --help
21+
socket scan
22+
socket npm install express
23+
socket optimize
24+
```
25+
26+
## Features
27+
28+
- **Security Scanning**: Analyze npm packages for supply chain risks
29+
- **CI/CD Integration**: Block risky dependencies in your pipeline
30+
- **Package Optimization**: Apply Socket registry overrides for safer alternatives
31+
- **Organization Management**: Manage Socket.dev organizations and repositories
32+
- **Wrapper Commands**: Secure alternatives to `npm`, `npx`, `pnpm`, `yarn`
33+
34+
## Documentation
35+
36+
Visit [https://docs.socket.dev/](https://docs.socket.dev/) for full documentation.
37+
38+
## License
39+
40+
MIT
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)