-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: release package as a library (#80)
* feat: release package as a library * fix: export ApiClient * chore: update README
- Loading branch information
Showing
16 changed files
with
101 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
export { | ||
ApiClient, | ||
BugSplatApiClient, | ||
VersionsApiClient, | ||
SymbolsApiClient, | ||
OAuthClientCredentialsClient, | ||
UploadableFile, | ||
GZippedSymbolFile | ||
} from '@bugsplat/js-api-client'; | ||
} from '@bugsplat/js-api-client'; | ||
|
||
export { uploadSymbolFiles } from './src/upload'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { ApiClient, SymbolsApiClient, VersionsApiClient } from "@bugsplat/js-api-client"; | ||
import { existsSync } from "node:fs"; | ||
import { mkdir } from "node:fs/promises"; | ||
import { basename, dirname, extname, join, relative } from "node:path"; | ||
import { pool } from "workerpool"; | ||
import { SymbolFileInfo } from './info'; | ||
import { tryGetPdbGuid, tryGetPeGuid } from './pdb'; | ||
import { getSymFileInfo } from './sym'; | ||
import { safeRemoveTmp, tmpDir } from './tmp'; | ||
import { createWorkersFromSymbolFiles } from './worker'; | ||
import { glob } from "glob"; | ||
|
||
const workerPool = pool(join(__dirname, 'compression.js')); | ||
|
||
export async function uploadSymbolFiles(bugsplat: ApiClient, database: string, application: string, version: string, directory: string, filesGlob: string) { | ||
try { | ||
const globPattern = `${directory}/${filesGlob}`; | ||
|
||
const symbolFilePaths = await glob(globPattern); | ||
|
||
if (!symbolFilePaths.length) { | ||
throw new Error(`Could not find any files to upload using glob ${globPattern}!`); | ||
} | ||
|
||
console.log(`Found files:\n ${symbolFilePaths.join('\n')}`); | ||
console.log(`About to upload symbols for ${database}-${application}-${version}...`); | ||
|
||
if (!existsSync(tmpDir)) { | ||
await mkdir(tmpDir); | ||
} | ||
|
||
const symbolsApiClient = new SymbolsApiClient(bugsplat); | ||
const versionsApiClient = new VersionsApiClient(bugsplat); | ||
const symbolFiles = await Promise.all(symbolFilePaths.map(async (symbolFilePath) => await createSymbolFileInfo(directory, symbolFilePath))); | ||
const workers = createWorkersFromSymbolFiles(workerPool, symbolFiles, [symbolsApiClient, versionsApiClient]); | ||
const uploads = workers.map((worker) => worker.upload(database, application, version)); | ||
await Promise.all(uploads); | ||
|
||
console.log('Symbols uploaded successfully!'); | ||
} finally { | ||
await safeRemoveTmp(); | ||
} | ||
} | ||
|
||
async function createSymbolFileInfo(searchDirectory: string, symbolFilePath: string): Promise<SymbolFileInfo> { | ||
const path = symbolFilePath; | ||
const relativePath = relative(searchDirectory, dirname(path)); | ||
const extLowerCase = extname(path).toLowerCase(); | ||
const isSymFile = extLowerCase.includes('.sym'); | ||
const isPdbFile = extLowerCase.includes('.pdb'); | ||
const isPeFile = extLowerCase.includes('.exe') || extLowerCase.includes('.dll'); | ||
|
||
let dbgId = ''; | ||
let moduleName = ''; | ||
|
||
if (isPdbFile) { | ||
dbgId = await tryGetPdbGuid(path); | ||
} | ||
|
||
if (isPeFile) { | ||
dbgId = await tryGetPeGuid(path); | ||
} | ||
|
||
if (isSymFile) { | ||
({ dbgId, moduleName } = await getSymFileInfo(path)); | ||
} | ||
|
||
moduleName = moduleName || basename(path); | ||
|
||
return { | ||
path, | ||
dbgId, | ||
moduleName, | ||
relativePath | ||
} as SymbolFileInfo; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,6 @@ | |
"files": [ | ||
"./index.ts", | ||
"./bin/index.ts", | ||
"./bin/compression.js" | ||
"src/compression.js" | ||
] | ||
} |