mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 10:23:14 -04:00
wreck has been deprecated and will receive no further security updates in favor of @hapi/wreck
This commit is contained in:
parent
7448f64e1d
commit
e9bfc7fb11
15 changed files with 209 additions and 161 deletions
|
@ -20,7 +20,7 @@
|
|||
import { scanCopy, untar, deleteAll } from '../lib';
|
||||
import { createWriteStream } from 'fs';
|
||||
import { binaryInfo } from '../../../../x-pack/plugins/code/tasks/nodegit_info';
|
||||
import wreck from 'wreck';
|
||||
import wreck from '@hapi/wreck';
|
||||
import mkdirp from 'mkdirp';
|
||||
import { dirname, join, basename } from 'path';
|
||||
import { createPromiseFromStreams } from '../../../legacy/utils/streams';
|
||||
|
@ -29,15 +29,10 @@ async function download(url, destination, log) {
|
|||
const response = await wreck.request('GET', url);
|
||||
|
||||
if (response.statusCode !== 200) {
|
||||
throw new Error(
|
||||
`Unexpected status code ${response.statusCode} when downloading ${url}`
|
||||
);
|
||||
throw new Error(`Unexpected status code ${response.statusCode} when downloading ${url}`);
|
||||
}
|
||||
mkdirp.sync(dirname(destination));
|
||||
await createPromiseFromStreams([
|
||||
response,
|
||||
createWriteStream(destination)
|
||||
]);
|
||||
await createPromiseFromStreams([response, createWriteStream(destination)]);
|
||||
log.debug('Downloaded ', url);
|
||||
}
|
||||
|
||||
|
@ -46,7 +41,7 @@ async function downloadAndExtractTarball(url, dest, log, retry) {
|
|||
await download(url, dest, log);
|
||||
const extractDir = join(dirname(dest), basename(dest, '.tar.gz'));
|
||||
await untar(dest, extractDir, {
|
||||
strip: 1
|
||||
strip: 1,
|
||||
});
|
||||
return extractDir;
|
||||
} catch (e) {
|
||||
|
@ -66,7 +61,10 @@ async function patchNodeGit(config, log, build, platform) {
|
|||
const downloadPath = build.resolvePathForPlatform(platform, '.nodegit_binaries', packageName);
|
||||
const extractDir = await downloadAndExtractTarball(downloadUrl, downloadPath, log, 3);
|
||||
|
||||
const destination = build.resolvePathForPlatform(platform, 'node_modules/@elastic/nodegit/build/Release');
|
||||
const destination = build.resolvePathForPlatform(
|
||||
platform,
|
||||
'node_modules/@elastic/nodegit/build/Release'
|
||||
);
|
||||
log.debug('Replacing nodegit binaries from ', extractDir);
|
||||
await deleteAll([destination], log);
|
||||
await scanCopy({
|
||||
|
@ -77,15 +75,15 @@ async function patchNodeGit(config, log, build, platform) {
|
|||
await deleteAll([extractDir, downloadPath], log);
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const PatchNativeModulesTask = {
|
||||
description: 'Patching platform-specific native modules directories',
|
||||
async run(config, log, build) {
|
||||
await Promise.all(config.getTargetPlatforms().map(async platform => {
|
||||
if (!build.isOss()) {
|
||||
await patchNodeGit(config, log, build, platform);
|
||||
}
|
||||
}));
|
||||
}
|
||||
await Promise.all(
|
||||
config.getTargetPlatforms().map(async platform => {
|
||||
if (!build.isOss()) {
|
||||
await patchNodeGit(config, log, build, platform);
|
||||
}
|
||||
})
|
||||
);
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue