Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9cc003b

Browse files
jdaltonTest User
and
Test User
authored
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

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

‎.github/workflows/ci.yml‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
name:Run CI Pipeline
3636
uses:SocketDev/socket-registry/.github/workflows/ci.yml@1a96ced97aaa85d61543351b90d6f463b983c46c# main
3737
with:
38-
test-setup-script:'pnpm --filter @socketsecurity/cli run build'
38+
test-setup-script:'pnpm --filter @socketsecurity/cli... run build'
3939
lint-script:'pnpm --filter @socketsecurity/cli run check'
4040
type-check-script:'pnpm --filter @socketsecurity/cli run type'
4141
run-test:false# Tests run in separate sharded job below.
@@ -64,9 +64,8 @@ jobs:
6464
with:
6565
node-version:${{ matrix.node-version }}
6666

67-
-name:Build CLI
68-
working-directory:packages/cli
69-
run:pnpm run build
67+
-name:Build dependencies and CLI
68+
run:pnpm --filter @socketsecurity/cli... run build
7069

7170
-name:Run unit tests (shard ${{ matrix.shard }})
7271
working-directory:packages/cli
@@ -88,9 +87,8 @@ jobs:
8887
with:
8988
node-version:${{ matrix.node-version }}
9089

91-
-name:Build CLI
92-
working-directory:packages/cli
93-
run:pnpm run build
90+
-name:Build dependencies and CLI
91+
run:pnpm --filter @socketsecurity/cli... run build
9492

9593
-name:Generate cache keys for binary distributions
9694
id:cache-keys
@@ -220,9 +218,8 @@ jobs:
220218
with:
221219
node-version:${{ matrix.node-version }}
222220

223-
-name:Build CLI
224-
working-directory:packages/cli
225-
run:pnpm run build
221+
-name:Build dependencies and CLI
222+
run:pnpm --filter @socketsecurity/cli... run build
226223

227224
-name:Run e2e tests
228225
working-directory:packages/cli

‎package.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
"@socketregistry/packageurl-js":"catalog:",
3636
"@socketregistry/yocto-spinner":"catalog:",
3737
"@socketsecurity/config":"catalog:",
38+
"@socketsecurity/lib":"3.2.8",
39+
"@socketsecurity/lib-external":"npm:@socketsecurity/lib@3.2.8",
3840
"@socketsecurity/registry":"catalog:",
3941
"@types/cmd-shim":"catalog:",
4042
"@types/ink":"catalog:",

‎packages/bootstrap/.config/esbuild.smol.config.mjs‎

Lines changed: 0 additions & 52 deletions
This file was deleted.

‎packages/bootstrap/package.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
".":"./dist/index.js",
88
"./bootstrap-npm.js":"./dist/bootstrap-npm.js",
99
"./bootstrap-sea.js":"./dist/bootstrap-sea.js",
10-
"./bootstrap-smol.js":"./dist/bootstrap-smol.js",
1110
"./node-version.json":"./node-version.json"
1211
},
1312
"scripts": {
@@ -22,7 +21,7 @@
2221
"@babel/types":"catalog:",
2322
"@socketsecurity/build-infra":"workspace:*",
2423
"@socketsecurity/cli":"workspace:*",
25-
"@socketsecurity/lib":"workspace:*",
24+
"@socketsecurity/lib-internal":"workspace:*",
2625
"del-cli":"catalog:",
2726
"esbuild":"catalog:",
2827
"magic-string":"catalog:",

‎packages/bootstrap/src/bootstrap-smol.mts‎

Lines changed: 0 additions & 70 deletions
This file was deleted.

‎packages/bootstrap/src/index.mts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,6 @@ module.exports = {
5656
returnloadBootstrap('bootstrap-sea.js')
5757
},
5858

59-
/**
60-
* Load smol bootstrap (for smol Node.js binary - also available compressed).
61-
* Note: This is also embedded in base64 in the Node.js binary via
62-
* packages/node-smol-builder, but providing compressed version for consistency.
63-
*@returns {any} Bootstrap exports
64-
*/
65-
loadSmolBootstrap(){
66-
returnloadBootstrap('bootstrap-smol.js')
67-
},
68-
6959
// Re-export the loader function for custom usage.
7060
loadBootstrap,
7161
}

‎packages/build-infra/lib/build-helpers.mjs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import{promisesasfs}from'node:fs'
99
importpathfrom'node:path'
1010

11-
importbinPkgfrom'@socketsecurity/lib/bin'
12-
importplatformPkgfrom'@socketsecurity/lib/constants/platform'
13-
importspawnPkgfrom'@socketsecurity/lib/spawn'
11+
importbinPkgfrom'@socketsecurity/lib-external/bin'
12+
importplatformPkgfrom'@socketsecurity/lib-external/constants/platform'
13+
importspawnPkgfrom'@socketsecurity/lib-external/spawn'
1414

1515
const{ whichBinSync}=binPkg
1616
const{WIN32}=platformPkg

‎packages/build-infra/lib/build-output.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Provides consistent, pretty logging for build processes.
55
*/
66

7-
importloggerPkgfrom'@socketsecurity/lib/logger'
7+
importloggerPkgfrom'@socketsecurity/lib-external/logger'
88

99
constlogger=loggerPkg.getDefaultLogger()
1010

‎packages/build-infra/lib/cmake-builder.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
import{cpus}from'node:os'
88

9-
importplatformPkgfrom'@socketsecurity/lib/constants/platform'
10-
importspawnPkgfrom'@socketsecurity/lib/spawn'
9+
importplatformPkgfrom'@socketsecurity/lib-external/constants/platform'
10+
importspawnPkgfrom'@socketsecurity/lib-external/spawn'
1111

1212
const{WIN32}=platformPkg
1313
const{ spawn}=spawnPkg

‎packages/build-infra/lib/emscripten-builder.mjs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import{cpus}from'node:os'
88
importpathfrom'node:path'
99

10-
importplatformPkgfrom'@socketsecurity/lib/constants/platform'
11-
importspawnPkgfrom'@socketsecurity/lib/spawn'
10+
importplatformPkgfrom'@socketsecurity/lib-external/constants/platform'
11+
importspawnPkgfrom'@socketsecurity/lib-external/spawn'
1212

1313
const{WIN32}=platformPkg
1414
const{ spawn}=spawnPkg

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp