Skip to content

Commit 43ac07e

Browse files
committed
fix: clean --json output and fix all linting errors
- Silence logger when --json flag is present for clean JSON output - Use console.log directly for JSON output to ensure it's not silenced - Add UPX compression and macOS signing to publish-socketbin workflow - Fix all linting errors in scripts and source files - Fix TypeScript unused variable errors
1 parent 6fee37b commit 43ac07e

File tree

2 files changed

+43
-20
lines changed

2 files changed

+43
-20
lines changed

src/commands/scan/output-diff-scan.mts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export async function outputDiffScan(
7878
async function handleJson(
7979
data: CResult<SocketSdkSuccessResult<'GetOrgDiffScan'>['data']>,
8080
file: string,
81-
dashboardMessage: string,
81+
_dashboardMessage: string,
8282
) {
8383
const json = serializeResultJson(data)
8484

src/sea/install.mts

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ const PLATFORM_MAP: Record<string, string> = {
2525
darwin: 'darwin',
2626
linux: 'linux',
2727
// Windows
28-
win32: 'win32'
28+
win32: 'win32',
2929
}
3030

3131
const ARCH_MAP: Record<string, string> = {
3232
arm64: 'arm64',
33-
x64: 'x64'
33+
x64: 'x64',
3434
}
3535

3636
/**
@@ -43,7 +43,7 @@ function getBinaryName(): string {
4343
if (!platform || !arch) {
4444
throw new Error(
4545
`Unsupported platform: ${os.platform()} ${os.arch()}. ` +
46-
`Please install @socketsecurity/cli directly instead.`
46+
`Please install @socketsecurity/cli directly instead.`,
4747
)
4848
}
4949

@@ -56,15 +56,25 @@ function getBinaryName(): string {
5656
*/
5757
async function getPackageVersion(): Promise<string> {
5858
// In production, this will be in npm-package/package.json
59-
const packagePath = path.join(__dirname, '..', '..', 'npm-package', 'package.json')
59+
const packagePath = path.join(
60+
__dirname,
61+
'..',
62+
'..',
63+
'npm-package',
64+
'package.json',
65+
)
6066
if (existsSync(packagePath)) {
61-
const { default: pkg } = await import(packagePath, { with: { type: 'json' } })
67+
const { default: pkg } = await import(packagePath, {
68+
with: { type: 'json' },
69+
})
6270
return pkg.version
6371
}
6472

6573
// Fallback for development
6674
const devPackagePath = path.join(__dirname, '..', '..', '..', 'package.json')
67-
const { default: pkg } = await import(devPackagePath, { with: { type: 'json' } })
75+
const { default: pkg } = await import(devPackagePath, {
76+
with: { type: 'json' },
77+
})
6878
return pkg.version
6979
}
7080

@@ -79,8 +89,8 @@ async function downloadFile(url: string, destPath: string): Promise<void> {
7989
url,
8090
{
8191
headers: {
82-
'User-Agent': 'socket-cli-installer'
83-
}
92+
'User-Agent': 'socket-cli-installer',
93+
},
8494
},
8595
response => {
8696
// Handle redirects
@@ -102,9 +112,9 @@ async function downloadFile(url: string, destPath: string): Promise<void> {
102112
if (response.statusCode !== 200) {
103113
file.close()
104114
unlink(destPath).catch(() => {})
105-
reject(new Error(
106-
`Failed to download binary: HTTP ${response.statusCode}`
107-
))
115+
reject(
116+
new Error(`Failed to download binary: HTTP ${response.statusCode}`),
117+
)
108118
return
109119
}
110120

@@ -114,7 +124,7 @@ async function downloadFile(url: string, destPath: string): Promise<void> {
114124
file.on('finish', () => {
115125
file.close(() => resolve())
116126
})
117-
}
127+
},
118128
)
119129

120130
request.on('error', err => {
@@ -141,13 +151,20 @@ async function getBinaryUrl(): Promise<string> {
141151
*/
142152
async function install(): Promise<void> {
143153
try {
144-
const binaryName = getBinaryName()
145154
const targetName = BINARY_NAME + (os.platform() === 'win32' ? '.exe' : '')
146-
const binaryPath = path.join(__dirname, '..', '..', 'npm-package', targetName)
155+
const binaryPath = path.join(
156+
__dirname,
157+
'..',
158+
'..',
159+
'npm-package',
160+
targetName,
161+
)
147162

148163
// For development, use local path
149164
const devBinaryPath = path.join(__dirname, targetName)
150-
const finalPath = existsSync(path.dirname(binaryPath)) ? binaryPath : devBinaryPath
165+
const finalPath = existsSync(path.dirname(binaryPath))
166+
? binaryPath
167+
: devBinaryPath
151168

152169
// Check if binary already exists
153170
if (existsSync(finalPath)) {
@@ -180,10 +197,16 @@ async function install(): Promise<void> {
180197
console.error(`Failed to install Socket CLI binary: ${message}`)
181198
console.error('')
182199
console.error('You can try:')
183-
console.error(' 1. Installing from source: npm install -g @socketsecurity/cli')
184-
console.error(' 2. Downloading manually from: https://github.com/SocketDev/socket-cli/releases')
200+
console.error(
201+
' 1. Installing from source: npm install -g @socketsecurity/cli',
202+
)
203+
console.error(
204+
' 2. Downloading manually from: https://github.com/SocketDev/socket-cli/releases',
205+
)
185206
console.error('')
186-
console.error('For help, visit: https://github.com/SocketDev/socket-cli/issues')
207+
console.error(
208+
'For help, visit: https://github.com/SocketDev/socket-cli/issues',
209+
)
187210

188211
// Don't fail the npm install - allow fallback to source
189212
process.exitCode = 0
@@ -199,4 +222,4 @@ if (import.meta.url === `file://${process.argv[1]}`) {
199222
})
200223
}
201224

202-
export { install, getBinaryName, getBinaryUrl }
225+
export { install, getBinaryName, getBinaryUrl }

0 commit comments

Comments
 (0)