Skip to content

Commit e0d3c09

Browse files
committed
Replace @socketsecurity/registry subpath imports with @socketsecurity/lib
Updated imports across source files to use @socketsecurity/lib: - constants/* (agents, node, platform, paths, socket, etc.) - lib/* (spawn, fs, paths, etc.) - env/* - packages/* - types - utils/* Preserved bare @socketsecurity/registry imports for getManifestData.
1 parent eb0278a commit e0d3c09

File tree

103 files changed

+282
-243
lines changed

Some content is hidden

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

103 files changed

+282
-243
lines changed

scripts/lint.mjs

Lines changed: 119 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ import { fileURLToPath } from 'node:url'
99

1010
import { isQuiet } from '@socketsecurity/lib/argv/flags'
1111
import { parseArgs } from '@socketsecurity/lib/argv/parse'
12-
import {
13-
getChangedFiles,
14-
getStagedFiles,
15-
} from '@socketsecurity/lib/git'
12+
import { getChangedFiles, getStagedFiles } from '@socketsecurity/lib/git'
1613
import { logger } from '@socketsecurity/lib/logger'
1714
import { printHeader } from '@socketsecurity/lib/stdio/header'
1815

@@ -89,7 +86,7 @@ function filterLintableFiles(files) {
8986
}
9087

9188
/**
92-
* Run ESLint on specific files.
89+
* Run linters on specific files.
9390
*/
9491
async function runLintOnFiles(files, options = {}) {
9592
const { fix = false, quiet = false } = options
@@ -103,45 +100,70 @@ async function runLintOnFiles(files, options = {}) {
103100
logger.progress(`Linting ${files.length} file(s)`)
104101
}
105102

106-
const args = [
107-
'exec',
108-
'eslint',
109-
'-c',
110-
'.config/eslint.config.mjs',
111-
'--report-unused-disable-directives',
112-
'--ignore-pattern',
113-
'build/',
114-
'--ignore-pattern',
115-
'binaries/',
116-
'--ignore-pattern',
117-
'dist/',
118-
'--ignore-pattern',
119-
'external/',
120-
'--ignore-pattern',
121-
'.cache/',
122-
'--ignore-pattern',
123-
'.claude/',
124-
'--ignore-pattern',
125-
'pkg-binaries/',
126-
...(fix ? ['--fix'] : []),
127-
...files,
103+
// Build the linter configurations.
104+
const linters = [
105+
{
106+
args: [
107+
'exec',
108+
'biome',
109+
'check',
110+
'--log-level=none',
111+
...(fix ? ['--write', '--unsafe'] : []),
112+
...files,
113+
],
114+
name: 'biome',
115+
enabled: true,
116+
},
117+
{
118+
args: [
119+
'exec',
120+
'eslint',
121+
'-c',
122+
'.config/eslint.config.mjs',
123+
'--report-unused-disable-directives',
124+
'--ignore-pattern',
125+
'build/',
126+
'--ignore-pattern',
127+
'binaries/',
128+
'--ignore-pattern',
129+
'dist/',
130+
'--ignore-pattern',
131+
'external/',
132+
'--ignore-pattern',
133+
'.cache/',
134+
'--ignore-pattern',
135+
'.claude/',
136+
'--ignore-pattern',
137+
'pkg-binaries/',
138+
...(fix ? ['--fix'] : []),
139+
...files,
140+
],
141+
name: 'eslint',
142+
enabled: true,
143+
},
128144
]
129145

130-
const result = await runCommandQuiet('pnpm', args)
146+
for (const { args, enabled } of linters) {
147+
if (!enabled) {
148+
continue
149+
}
131150

132-
if (result.exitCode !== 0) {
133-
// When fixing, non-zero exit codes are normal if fixes were applied
134-
if (!fix || (result.stderr && result.stderr.trim().length > 0)) {
135-
if (!quiet) {
136-
logger.error('Linting failed')
137-
}
138-
if (result.stderr) {
139-
console.error(result.stderr)
140-
}
141-
if (result.stdout && !fix) {
142-
console.log(result.stdout)
151+
const result = await runCommandQuiet('pnpm', args)
152+
153+
if (result.exitCode !== 0) {
154+
// When fixing, non-zero exit codes are normal if fixes were applied.
155+
if (!fix || (result.stderr && result.stderr.trim().length > 0)) {
156+
if (!quiet) {
157+
logger.error('Linting failed')
158+
}
159+
if (result.stderr) {
160+
console.error(result.stderr)
161+
}
162+
if (result.stdout && !fix) {
163+
console.log(result.stdout)
164+
}
165+
return result.exitCode
143166
}
144-
return result.exitCode
145167
}
146168
}
147169

@@ -154,7 +176,7 @@ async function runLintOnFiles(files, options = {}) {
154176
}
155177

156178
/**
157-
* Run ESLint on all files.
179+
* Run linters on all files.
158180
*/
159181
async function runLintOnAll(options = {}) {
160182
const { fix = false, quiet = false } = options
@@ -163,49 +185,66 @@ async function runLintOnAll(options = {}) {
163185
logger.progress('Linting all files')
164186
}
165187

166-
const args = [
167-
'exec',
168-
'eslint',
169-
'-c',
170-
'.config/eslint.config.mjs',
171-
'--report-unused-disable-directives',
172-
'--no-warn-ignored',
173-
'--ignore-pattern',
174-
'build/',
175-
'--ignore-pattern',
176-
'binaries/',
177-
'--ignore-pattern',
178-
'dist/',
179-
'--ignore-pattern',
180-
'external/',
181-
'--ignore-pattern',
182-
'.cache/',
183-
'--ignore-pattern',
184-
'.claude/',
185-
'--ignore-pattern',
186-
'pkg-binaries/',
187-
...(fix ? ['--fix'] : []),
188-
'src/',
189-
'scripts/',
190-
'test/',
191-
'.config/',
188+
const linters = [
189+
{
190+
args: [
191+
'exec',
192+
'biome',
193+
'check',
194+
...(fix ? ['--write', '--unsafe'] : []),
195+
'.',
196+
],
197+
name: 'biome',
198+
},
199+
{
200+
args: [
201+
'exec',
202+
'eslint',
203+
'-c',
204+
'.config/eslint.config.mjs',
205+
'--report-unused-disable-directives',
206+
'--no-warn-ignored',
207+
'--ignore-pattern',
208+
'build/',
209+
'--ignore-pattern',
210+
'binaries/',
211+
'--ignore-pattern',
212+
'dist/',
213+
'--ignore-pattern',
214+
'external/',
215+
'--ignore-pattern',
216+
'.cache/',
217+
'--ignore-pattern',
218+
'.claude/',
219+
'--ignore-pattern',
220+
'pkg-binaries/',
221+
...(fix ? ['--fix'] : []),
222+
'src/',
223+
'scripts/',
224+
'test/',
225+
'.config/',
226+
],
227+
name: 'eslint',
228+
},
192229
]
193230

194-
const result = await runCommandQuiet('pnpm', args)
231+
for (const { args } of linters) {
232+
const result = await runCommandQuiet('pnpm', args)
195233

196-
if (result.exitCode !== 0) {
197-
// When fixing, non-zero exit codes are normal if fixes were applied
198-
if (!fix || (result.stderr && result.stderr.trim().length > 0)) {
199-
if (!quiet) {
200-
logger.error('Linting failed')
201-
}
202-
if (result.stderr) {
203-
console.error(result.stderr)
204-
}
205-
if (result.stdout && !fix) {
206-
console.log(result.stdout)
234+
if (result.exitCode !== 0) {
235+
// When fixing, non-zero exit codes are normal if fixes were applied.
236+
if (!fix || (result.stderr && result.stderr.trim().length > 0)) {
237+
if (!quiet) {
238+
logger.error('Linting failed')
239+
}
240+
if (result.stderr) {
241+
console.error(result.stderr)
242+
}
243+
if (result.stdout && !fix) {
244+
console.log(result.stdout)
245+
}
246+
return result.exitCode
207247
}
208-
return result.exitCode
209248
}
210249
}
211250

scripts/utils/get-local-package-aliases.mjs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,35 @@ import path from 'node:path'
1313
* Falls back to published versions in CI or when packages don't exist.
1414
*
1515
* @param {string} [rootDir] - The root directory of the current project. Defaults to inferring from caller location.
16-
* @returns {Record<string, string>} Package aliases mapping (package root, not dist).
16+
* @returns {Record<string, string>} Package aliases mapping (to dist folders for build tools).
1717
*/
1818
export function getLocalPackageAliases(rootDir) {
1919
const aliases = {}
2020

2121
// If no rootDir provided, try to infer from stack trace or use process.cwd().
2222
const baseDir = rootDir || process.cwd()
2323

24-
// Check for ../socket-lib for @socketsecurity/lib.
25-
const libPath = path.join(baseDir, '..', 'socket-lib')
26-
if (existsSync(path.join(libPath, 'package.json'))) {
24+
// Check for ../socket-lib/dist for @socketsecurity/lib.
25+
const libPath = path.join(baseDir, '..', 'socket-lib', 'dist')
26+
if (existsSync(path.join(libPath, '../package.json'))) {
2727
aliases['@socketsecurity/lib'] = libPath
2828
}
2929

30-
// Check for ../socket-registry/registry for @socketsecurity/registry.
31-
const registryPath = path.join(baseDir, '..', 'socket-registry', 'registry')
32-
if (existsSync(path.join(registryPath, 'package.json'))) {
33-
aliases['@socketsecurity/registry'] = registryPath
30+
// Check for ../socket-packageurl-js/dist.
31+
const packageurlPath = path.join(baseDir, '..', 'socket-packageurl-js', 'dist')
32+
if (existsSync(path.join(packageurlPath, '../package.json'))) {
33+
aliases['@socketregistry/packageurl-js'] = packageurlPath
3434
}
3535

36-
// Check for ../socket-packageurl-js.
37-
const packageurlPath = path.join(baseDir, '..', 'socket-packageurl-js')
38-
if (existsSync(path.join(packageurlPath, 'package.json'))) {
39-
aliases['@socketregistry/packageurl-js'] = packageurlPath
36+
// Check for ../socket-registry/registry/dist for @socketsecurity/registry.
37+
const registryPath = path.join(baseDir, '..', 'socket-registry', 'registry', 'dist')
38+
if (existsSync(path.join(registryPath, '../package.json'))) {
39+
aliases['@socketsecurity/registry'] = registryPath
4040
}
4141

42-
// Check for ../socket-sdk-js.
43-
const sdkPath = path.join(baseDir, '..', 'socket-sdk-js')
44-
if (existsSync(path.join(sdkPath, 'package.json'))) {
42+
// Check for ../socket-sdk-js/dist.
43+
const sdkPath = path.join(baseDir, '..', 'socket-sdk-js', 'dist')
44+
if (existsSync(path.join(sdkPath, '../package.json'))) {
4545
aliases['@socketsecurity/sdk'] = sdkPath
4646
}
4747

src/commands/analytics/cmd-analytics.test.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import semver from 'semver'
22
import { describe, expect } from 'vitest'
33

4-
import { NODE_VERSION } from '@socketsecurity/registry/constants/node'
5-
import { WIN32 } from '@socketsecurity/registry/constants/platform'
4+
import { NODE_VERSION } from '@socketsecurity/lib/constants/node'
5+
import { WIN32 } from '@socketsecurity/lib/constants/platform'
66

77
import { FLAG_CONFIG, FLAG_DRY_RUN, FLAG_HELP } from '../../../src/constants/cli.mts'
88
import { getBinCliPath } from '../../../src/constants/paths.mts'

src/commands/config/cmd-config-get.test.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import semver from 'semver'
22
import { describe, expect } from 'vitest'
33

4-
import { NODE_VERSION } from '@socketsecurity/registry/constants/node'
5-
import { WIN32 } from '@socketsecurity/registry/constants/platform'
4+
import { NODE_VERSION } from '@socketsecurity/lib/constants/node'
5+
import { WIN32 } from '@socketsecurity/lib/constants/platform'
66

77
import { cmdit, spawnSocketCli } from '../../../test/utils.mts'
88
import { FLAG_CONFIG, FLAG_DRY_RUN, FLAG_HELP } from '../constants/cli.mts'

src/commands/fix/cmd-fix.test.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from 'node:path'
22

33
import { afterEach, describe, expect } from 'vitest'
44

5-
import { WIN32 } from '@socketsecurity/registry/constants/platform'
5+
import { WIN32 } from '@socketsecurity/lib/constants/platform'
66

77
import { withTempFixture } from '../../../src/utils/test-fixtures.mts'
88
import { cmdit, spawnSocketCli, testPath } from '../../../test/utils.mts'

src/commands/fix/pull-request.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { RequestError } from '@octokit/request-error'
22

33
import { debug, debugDir } from '@socketsecurity/lib/debug'
44
import { isNonEmptyString } from '@socketsecurity/lib/strings'
5-
import { UNKNOWN_VALUE } from '@socketsecurity/registry/constants/core'
5+
import { UNKNOWN_VALUE } from '@socketsecurity/lib/constants/core'
66

77
import {
88
getSocketFixBranchPattern,

src/commands/login/attempt-login.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { joinAnd } from '@socketsecurity/lib/arrays'
22
import { logger } from '@socketsecurity/lib/logger'
33
import { confirm, password, select } from '@socketsecurity/lib/prompts'
4-
import { SOCKET_PUBLIC_API_TOKEN } from '@socketsecurity/registry/constants/socket'
4+
import { SOCKET_PUBLIC_API_TOKEN } from '@socketsecurity/lib/constants/socket'
55

66
import { applyLogin } from './apply-login.mts'
77
import {

src/commands/manifest/convert-gradle-to-maven.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'node:path'
33

44
import { logger } from '@socketsecurity/lib/logger'
55
import { spawn } from '@socketsecurity/lib/spawn'
6-
import { getSpinner } from '@socketsecurity/registry/constants/process'
6+
import { getSpinner } from '@socketsecurity/lib/constants/process'
77

88
import { distPath } from '../../constants/paths.mjs'
99

src/commands/manifest/convert-sbt-to-maven.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { safeReadFile } from '@socketsecurity/lib/fs'
22
import { logger } from '@socketsecurity/lib/logger'
33
import { spawn } from '@socketsecurity/lib/spawn'
4-
import { getSpinner } from '@socketsecurity/registry/constants/process'
4+
import { getSpinner } from '@socketsecurity/lib/constants/process'
55

66
export async function convertSbtToMaven({
77
bin,

src/commands/manifest/run-cdxgen.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import path from 'node:path'
44
import colors from 'yoctocolors-cjs'
55

66
import { logger } from '@socketsecurity/lib/logger'
7-
import { NPM, PNPM, YARN } from '@socketsecurity/registry/constants/agents'
8-
import { SOCKET_PUBLIC_API_TOKEN } from '@socketsecurity/registry/constants/socket'
7+
import { NPM, PNPM, YARN } from '@socketsecurity/lib/constants/agents'
8+
import { SOCKET_PUBLIC_API_TOKEN } from '@socketsecurity/lib/constants/socket'
99

1010
import { FLAG_HELP } from '../../constants/cli.mjs'
1111
import {

0 commit comments

Comments
 (0)