@perfsee/plugin-utils
Advanced tools
Comparing version 1.10.0 to 1.12.2
@@ -24,2 +24,3 @@ "use strict"; | ||
const stream_1 = require("stream"); | ||
const util_1 = require("util"); | ||
const zlib_1 = require("zlib"); | ||
@@ -152,3 +153,2 @@ const chalk_1 = tslib_1.__importDefault(require("chalk")); | ||
}; | ||
const stream = (0, fs_1.createReadStream)(packPath); | ||
console.info(chalk_1.default.green('[perfsee] start uploading build'), { | ||
@@ -164,17 +164,24 @@ size: utils_1.PrettyBytes.stringify((0, fs_1.statSync)(packPath).size), | ||
const platform = this.options.platform ?? (0, build_env_1.getBuildEnv)().platform; | ||
const res = await (0, node_fetch_1.default)(`${platform}/api/v1/artifacts?${query}`, { | ||
method: 'POST', | ||
body: stream, | ||
headers: { | ||
authorization: `Bearer ${this.options.token}`, | ||
'content-type': 'application/octet-stream', | ||
}, | ||
}); | ||
if (res.ok) { | ||
const { url } = await res.json(); | ||
console.info(chalk_1.default.green(`[perfsee] uploading succeed! The analyze result would be available at ${url} soon!`)); | ||
let res; | ||
for (const tryTime of Array.from({ length: (this.options.maxRetries || 0) + 1 }, (_, i) => i)) { | ||
if (tryTime !== 0) { | ||
console.error(`[perfsee] uploading failed! ${res?.statusText}. Retrying...`); | ||
} | ||
const stream = (0, fs_1.createReadStream)(packPath); | ||
res = await (0, node_fetch_1.default)(`${platform}/api/v1/artifacts?${query}`, { | ||
method: 'POST', | ||
body: stream, | ||
headers: { | ||
authorization: `Bearer ${this.options.token}`, | ||
'content-type': 'application/octet-stream', | ||
}, | ||
}); | ||
if (res.ok) { | ||
const { url } = await res.json(); | ||
console.info(chalk_1.default.green(`[perfsee] uploading succeed! The analyze result would be available at ${url} soon!`)); | ||
return; | ||
} | ||
await (0, util_1.promisify)(setTimeout)(this.options.retryDelay || 100); | ||
} | ||
else { | ||
throw new Error(`[perfsee] uploading failed! ${res.statusText}. Response: ${await res.text()}`); | ||
} | ||
throw new Error(`[perfsee] uploading failed! ${res?.statusText}. Response: ${await res?.text()}`); | ||
} | ||
@@ -181,0 +188,0 @@ /** |
@@ -83,4 +83,16 @@ import { BundleResult, PerfseeReportStats } from '@perfsee/bundle-analyzer'; | ||
processStats?: (stats: PerfseeReportStats) => undefined | PerfseeReportStats; | ||
/** | ||
* Tetry times of uploading artifacts. | ||
* | ||
* @default 0 | ||
*/ | ||
maxRetries?: number; | ||
/** | ||
* The amount of time in milliseconds to wait between retries. | ||
* | ||
* @default 100 | ||
*/ | ||
retryDelay?: number; | ||
} | ||
export declare function getDefaultOptions(): Required<Pick<CommonPluginOptions, 'artifactName' | 'enableAudit' | 'token' | 'toolkit'>>; | ||
export declare function initOptions(userOptions: CommonPluginOptions): CommonPluginOptions; |
{ | ||
"name": "@perfsee/plugin-utils", | ||
"version": "1.10.0", | ||
"version": "1.12.2", | ||
"description": "pertsuite plugin utilities", | ||
@@ -24,3 +24,3 @@ "repository": "https://github.com/perfsee/perfsee", | ||
"@perfsee/bundle-analyzer": "1.10.0", | ||
"@perfsee/jsonr": "1.10.0", | ||
"@perfsee/jsonr": "1.12.2", | ||
"@perfsee/utils": "1.10.0", | ||
@@ -48,3 +48,3 @@ "chalk": "^4.1.2", | ||
}, | ||
"gitHead": "3ae1d9a696ddec12aafd28edcb8464edc9b3edd4" | ||
"gitHead": "555355c0878dea8cc5859fbe591052f438931f08" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
2008333
8424
+ Added@perfsee/jsonr@1.12.2(transitive)
Updated@perfsee/jsonr@1.12.2