@@ -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
3131const 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 */
5757async 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 */
142152async 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