axios+telemetry cleanup
This commit is contained in:
23
utils/ide.ts
23
utils/ide.ts
@@ -1,6 +1,6 @@
|
||||
import type { Client } from '@modelcontextprotocol/sdk/client/index.js'
|
||||
import axios from 'axios'
|
||||
import { execa } from 'execa'
|
||||
import { chmod, writeFile } from 'fs/promises'
|
||||
import capitalize from 'lodash-es/capitalize.js'
|
||||
import memoize from 'lodash-es/memoize.js'
|
||||
import { createConnection } from 'net'
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
} from './execFileNoThrow.js'
|
||||
import { getFsImplementation } from './fsOperations.js'
|
||||
import { getAncestorPidsAsync } from './genericProcessUtils.js'
|
||||
import { isHttpError, nativeRequest } from './http.js'
|
||||
import { isJetBrainsPluginInstalledCached } from './jetbrains.js'
|
||||
import { logError } from './log.js'
|
||||
import { getPlatform } from './platform.js'
|
||||
@@ -925,7 +926,7 @@ function getInstallationEnv(): NodeJS.ProcessEnv | undefined {
|
||||
}
|
||||
|
||||
function getClaudeCodeVersion() {
|
||||
return MACRO.VERSION
|
||||
return '0.1.0-alpha'
|
||||
}
|
||||
|
||||
async function getInstalledVSCodeExtensionVersion(
|
||||
@@ -1424,10 +1425,12 @@ async function installFromArtifactory(command: string): Promise<string> {
|
||||
'https://artifactory.infra.ant.dev/artifactory/armorcode-claude-code-internal/claude-vscode-releases/stable'
|
||||
|
||||
try {
|
||||
const versionResponse = await axios.get(versionUrl, {
|
||||
const versionResponse = await nativeRequest<string>(versionUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
responseType: 'text',
|
||||
})
|
||||
|
||||
const version = versionResponse.data.trim()
|
||||
@@ -1443,20 +1446,16 @@ async function installFromArtifactory(command: string): Promise<string> {
|
||||
)
|
||||
|
||||
try {
|
||||
const vsixResponse = await axios.get(vsixUrl, {
|
||||
const vsixResponse = await nativeRequest<ArrayBuffer>(vsixUrl, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: `Bearer ${authToken}`,
|
||||
},
|
||||
responseType: 'stream',
|
||||
responseType: 'arraybuffer',
|
||||
})
|
||||
|
||||
// Write the downloaded file to disk
|
||||
const writeStream = getFsImplementation().createWriteStream(tempVsixPath)
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
vsixResponse.data.pipe(writeStream)
|
||||
writeStream.on('finish', resolve)
|
||||
writeStream.on('error', reject)
|
||||
})
|
||||
await writeFile(tempVsixPath, Buffer.from(vsixResponse.data))
|
||||
|
||||
// Install the .vsix file
|
||||
// Add delay to prevent code command crashes
|
||||
@@ -1484,7 +1483,7 @@ async function installFromArtifactory(command: string): Promise<string> {
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error)) {
|
||||
if (isHttpError(error)) {
|
||||
throw new Error(
|
||||
`Failed to fetch extension version from artifactory: ${error.message}`,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user