- Notifications
You must be signed in to change notification settings - Fork31
Commit9cc003b
refactor: simplify package structure by consolidating lib packages (#882)
* fix(build): ensure lib-internal and SDK build before CLIAdd lib-internal and SDK to BUILD_PACKAGES array as the first twobuild steps to ensure they are built before the CLI package, whichdepends on both of them.This fixes the build order issue where CLI would fail because itimports from @socketsecurity/lib-internal and @socketsecurity/sdkbut their dist folders didn't exist yet.* refactor: migrate all imports to use lib-external and lib-internal- Scripts (build.mjs, etc.) → @socketsecurity/lib-external- Build infrastructure → @socketsecurity/lib-external- CLI source code (src/) → @socketsecurity/lib-internal- Add lib-external alias to root devDependenciesThis ensures proper separation between:- Published package (lib-external) for build scripts- Workspace package (lib-internal) for application source* refactor: rename @socketsecurity/lib to @socketsecurity/lib-internalChange the workspace package name from @socketsecurity/lib to@socketsecurity/lib-internal to clearly distinguish it from thepublished npm package.This ensures:- CLI source imports from @socketsecurity/lib-internal (workspace)- Scripts import from @socketsecurity/lib-external (published package)Updated CLI package.json to use @socketsecurity/lib-internal workspacedependency.* refactor: update all packages to use @socketsecurity/lib-internalUpdate all package.json files across the monorepo to use the renamed@socketsecurity/lib-internal workspace dependency.Git renamed packages/lib → packages/lib-internal to match the newpackage name.* refactor: remove bootstrap-smol referencesRemove bootstrap-smol source file, config, and exports as it's nolonger needed. Keep bootstrap-npm and bootstrap-sea.* fix(lib-internal): access .default property when requiring maintained-node-versionsFixed TypeError where CLI crashed on startup with "Cannot read properties of null (reading 'major')".The issue was that maintained-node-versions exports a default export, but the require() calls were not accessing the .default property. This caused semver.parse() to receive undefined instead of the version string.Changes:- packages/lib-internal/src/package-default-node-range.ts: Added .default to require- packages/lib-internal/src/constants/node.ts: Added .default to requireThis fix resolves 19 test failures in the CLI test suite (from 66 to 47 failures).* fix(tests): update test mocks to use @socketsecurity/lib-internalAfter renaming @socketsecurity/lib to @socketsecurity/lib-internal, test mocks were stillreferencing the old package name, causing 47 test failures. Updated all vi.mock() statementsand related imports in test files to use the correct lib-internal package.Changes:- Updated vi.mock() statements from @socketsecurity/lib/* to @socketsecurity/lib-internal/*- Updated await import() statements in tests to match mocked package paths- Fixed import statement in handle-purls-shallow-score.test.mts to match its mockTest results:- Before: 47 failed tests across 10 test files- After: All 2255 tests passing (196 test files, 100% pass rate)Files modified:- test/unit/commands/ci/handle-ci.test.mts- test/unit/commands/fix/ghsa-tracker.test.mts- test/unit/commands/fix/handle-fix.test.mts- test/unit/commands/fix/pr-lifecycle-logger.test.mts- test/unit/commands/package/handle-purl-deep-score.test.mts- test/unit/commands/package/handle-purls-shallow-score.test.mts- test/unit/commands/scan/fetch-diff-scan.test.mts- test/unit/commands/scan/fetch-scan.test.mts- test/unit/commands/scan/output-create-new-scan.test.mts- test/unit/commands/threat-feed/output-threat-feed.test.mts* fix(lib-internal): fix TypeScript compilation errorsFixed two pre-existing TypeScript errors that were preventing successful builds:1. bin.ts: Removed incompatible 'env' property from WhichOptions interface - The 'which' package has strict type checking that doesn't allow env property - This was causing TS2345 errors during build2. versions.ts: Added 'release' to versionDiff return type - semver.diff() can return 'release' type which wasn't in the union type - This was causing TS2322 errorThese fixes allow lib-internal to build successfully with TypeScript type declarations.* refactor(sdk): move SECURITY.md to docs/security.mdMoved SECURITY.md file to comply with monorepo markdown filename conventions.SCREAMING_CASE files are only allowed at root, docs/, or .claude/ directories.* refactor(lib-internal): remove invalid type export for babel pluginRemoved types export for babel-plugin-inline-require-calls as the .d.ts file doesn't exist.This was causing build warnings.* refactor(lib-internal): remove external imports rewriting systemRemoves fix-external-imports.mjs script and its call from fix-build.mjs.The external bundling system (build-externals.mjs + fix-external-imports.mjs)was designed for standalone npm package distribution, not monorepo usage.In standalone distribution, it would:- Bundle 30+ external dependencies into dist/external/- Rewrite imports from require('package') to require('./external/package')- Create a zero-dependency npm packageIn monorepo context:- All packages are in node_modules/ via pnpm workspaces- External bundling is explicitly disabled (build.mjs:409)- No need to bundle or rewrite importsThe build now runs:- Package exports generation- Path alias fixing- CommonJS exports fixingVerified that built files have correct imports (e.g., require("picomatch")instead of require("./external/picomatch")).* refactor(sdk): remove orphaned SECURITY.md fileRemoves SECURITY.md from sdk package root. This file was orphanedand not part of the sdk package documentation structure.* fix(ci): build lib-internal and SDK before CLIThe CLI package now depends on @socketsecurity/lib-internal and@socketsecurity/sdk as workspace dependencies. These packages must bebuilt before the CLI can be type-checked or built.Updated all CI job steps to build dependencies in the correct order:1. lib-internal2. SDK3. CLIThis fixes TypeScript compilation errors in CI where modules could notbe resolved.* fix(ci): use pnpm recursive filter to build workspace dependenciesChanged from manually chaining build commands to using pnpm'srecursive filter syntax (`--filter @socketsecurity/cli...`) whichautomatically builds all workspace dependencies in the correct order.The `...` suffix tells pnpm to include all dependencies of the CLIpackage, ensuring lib-internal and SDK are built before CLI.This is more maintainable and follows pnpm best practices.---------Co-authored-by: Test User <test@example.com>1 parentbf45b5b commit9cc003b
File tree
617 files changed
+434
-21795
lines changed- .github/workflows
- packages
- bootstrap
- .config
- src
- build-infra
- lib
- cli
- scripts
- src
- commands
- analytics
- audit-log
- ci
- console
- fix
- json
- login
- logout
- manifest
- npm
- npx
- oops
- package
- patch
- pip
- pnpm
- scan
- self-update
- threat-feed
- uninstall
- yarn
- test/unit/commands
- ci
- fix
- package
- scan
- threat-feed
- codet5-models-builder
- scripts
- lib-internal
- .config
- vitest-plugins
- data
- docs
- plugins
- scripts
- babel
- build-externals
- stubs
- utils
- src
- argv
- constants
- cover
- effects
- env
- links
- packages
- paths
- stdio
- themes
- utils
- validation
- test
- argv
- constants
- effects
- env
- isolated
- packages
- stdio
- themes
- utils
- validation
- lib/scripts
- minilm-builder
- scripts
- models
- scripts
- node-smol-builder
- additions
- 001-brotli-integration
- 002-bootstrap-loader/internal
- 003-compression-tools
- 004-polyfills
- docker
- docs
- patches
- scripts
- test
- wasm-bundle
- scripts
- src
- onnxruntime
- scripts
- sbom-generator
- docs
- examples
- scripts
- src
- enrichment
- formatters
- parsers
- actions
- cargo
- chrome
- go
- huggingface
- maven
- npm
- nuget
- openvsx
- pypi
- rubygems
- types
- test/fixtures
- go
- python
- rust
- sdk
- docs
- socket
- yoga-layout
- scripts
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
617 files changed
+434
-21795
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
| 67 | + | |
| 68 | + | |
70 | 69 | | |
71 | 70 | | |
72 | 71 | | |
| |||
88 | 87 | | |
89 | 88 | | |
90 | 89 | | |
91 | | - | |
92 | | - | |
93 | | - | |
| 90 | + | |
| 91 | + | |
94 | 92 | | |
95 | 93 | | |
96 | 94 | | |
| |||
220 | 218 | | |
221 | 219 | | |
222 | 220 | | |
223 | | - | |
224 | | - | |
225 | | - | |
| 221 | + | |
| 222 | + | |
226 | 223 | | |
227 | 224 | | |
228 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
39 | 41 | | |
40 | 42 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
22 | 21 | | |
23 | 22 | | |
24 | 23 | | |
25 | | - | |
| 24 | + | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | 59 | | |
70 | 60 | | |
71 | 61 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | | - | |
| 9 | + | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
| 10 | + | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
0 commit comments
Comments
(0)