MCPcopy Create free account
hub / github.com/JasonShin/sqlx-ts / install

Function install

node/postinstall.js:149–192  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

147}
148
149async function install() {
150 try {
151 const { filename, binaryName } = getBinaryInfo()
152 const baseUrl = `https://github.com/JasonShin/sqlx-ts/releases/download/v${tag}`
153 const zipUrl = `${baseUrl}/${filename}`
154 const checksumUrl = `${zipUrl}.sha256`
155
156 const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sqlx-ts-'))
157 const zipPath = path.join(tmpDir, filename)
158 const checksumPath = path.join(tmpDir, `${filename}.sha256`)
159 const targetPath = path.join(__dirname, 'sqlx-ts' + (platform === 'win32' ? '.exe' : ''))
160
161 info(`Downloading sqlx-ts v${tag} for ${platform}-${cpu}...`)
162 info(`URL: ${zipUrl}`)
163
164 // Download the zip file
165 await downloadFile(zipUrl, zipPath)
166 success('Download complete')
167
168 // Download and verify the checksum
169 info('Downloading checksum...')
170 await downloadFile(checksumUrl, checksumPath)
171 const expectedHash = fs.readFileSync(checksumPath, 'utf8').trim()
172 info(`Expected SHA-256: ${expectedHash}`)
173
174 // Verify the hash
175 info('Verifying checksum...')
176 await verifyHash(zipPath, expectedHash)
177 success('Checksum verified successfully')
178
179 // Extract the binary
180 info('Extracting binary...')
181 extractBinary(zipPath, binaryName, targetPath)
182
183 // Cleanup
184 fs.rmSync(tmpDir, { recursive: true, force: true })
185
186 info('sqlx-ts installation successful')
187 process.exit(0)
188 } catch (err) {
189 error(`Installation failed: ${err.message}`)
190 process.exit(1)
191 }
192}
193
194install()

Callers 1

postinstall.jsFile · 0.85

Calls 7

getBinaryInfoFunction · 0.85
infoFunction · 0.85
downloadFileFunction · 0.85
successFunction · 0.85
verifyHashFunction · 0.85
extractBinaryFunction · 0.85
errorFunction · 0.85

Tested by

no test coverage detected