Revert "Using re2 for Timelion regular expressions (#55208) (#60059)"

This reverts commit 29f1dd5483.
This commit is contained in:
spalger 2020-03-13 09:18:45 -07:00
parent 29f1dd5483
commit 1017a4668b
12 changed files with 4 additions and 110 deletions

1
.gitignore vendored
View file

@ -4,7 +4,6 @@
/.es
.DS_Store
.node_binaries
.native_modules
node_modules
!/src/dev/npm/__tests__/fixtures/fixture1/node_modules
!/src/dev/notice/__fixtures__/node_modules

View file

@ -209,7 +209,6 @@
"pug": "^2.0.3",
"querystring-browser": "1.0.4",
"raw-loader": "0.5.1",
"re2": "1.10.5",
"react": "^16.6.0",
"react-addons-shallow-compare": "15.6.2",
"react-anything-sortable": "^1.7.4",

View file

@ -44,7 +44,6 @@ import {
ExtractNodeBuildsTask,
InstallDependenciesTask,
OptimizeBuildTask,
PatchNativeModulesTask,
RemovePackageJsonDepsTask,
RemoveWorkspacesTask,
TranspileBabelTask,
@ -128,7 +127,6 @@ export async function buildDistributables(options) {
* directories and perform platform-specific steps
*/
await run(CreateArchivesSourcesTask);
await run(PatchNativeModulesTask);
await run(CleanExtraBinScriptsTask);
await run(CleanExtraBrowsersTask);
await run(CleanNodeBuildsTask);

View file

@ -33,6 +33,5 @@ export {
deleteEmptyFolders,
compress,
} from './fs';
export { download } from './download';
export { scanDelete } from './scan_delete';
export { scanCopy } from './scan_copy';

View file

@ -32,7 +32,6 @@ export * from './nodejs_modules';
export * from './notice_file_task';
export * from './optimize_task';
export * from './os_packages';
export * from './patch_native_modules_task';
export * from './transpile_babel_task';
export * from './transpile_typescript_task';
export * from './transpile_scss_task';

View file

@ -22,7 +22,7 @@ import expect from 'expect.js';
import * as NodeShasumsNS from '../node_shasums';
import * as NodeDownloadInfoNS from '../node_download_info';
import * as DownloadNS from '../../../lib/download'; // sinon can't stub '../../../lib' properly
import * as DownloadNS from '../download';
import { DownloadNodeBuildsTask } from '../download_node_builds_task';
describe('src/dev/build/tasks/nodejs/download_node_builds_task', () => {

View file

@ -17,7 +17,7 @@
* under the License.
*/
import { download } from '../../lib';
import { download } from './download';
import { getNodeShasums } from './node_shasums';
import { getNodeDownloadInfo } from './node_download_info';

View file

@ -1,85 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import fs from 'fs';
import path from 'path';
import util from 'util';
import { deleteAll, download, untar } from '../lib';
const BASE_URL = `https://storage.googleapis.com/native-modules`;
const DOWNLOAD_DIRECTORY = '.native_modules';
const packages = [
{
name: 're2',
version: '1.10.5',
destinationPath: 'node_modules/re2/build/Release/',
shas: {
darwin: '066533b592094f91e00412499e44c338ce2466d63c9eaf0dc32be8214bde2099',
linux: '0322cac3c2e106129b650a8eac509f598ed283791d6116984fec4c151b24e574',
windows: '65b5bef7de2352f4787224c2c76a619b6683a868c8d4d71e0fdd500786fc422b',
},
},
];
async function getInstalledVersion(config, packageName) {
const packageJSONPath = config.resolveFromRepo(
path.join('node_modules', packageName, 'package.json')
);
const buffer = await util.promisify(fs.readFile)(packageJSONPath);
const packageJSON = JSON.parse(buffer);
return packageJSON.version;
}
async function patchModule(config, log, build, platform, pkg) {
const installedVersion = await getInstalledVersion(config, pkg.name);
if (installedVersion !== pkg.version) {
throw new Error(
`Can't patch ${pkg.name}'s native module, we were expecting version ${pkg.version} and found ${installedVersion}`
);
}
const platformName = platform.getName();
const archiveName = `${pkg.version}-${platformName}.tar.gz`;
const downloadUrl = `${BASE_URL}/${pkg.name}/${archiveName}`;
const downloadPath = config.resolveFromRepo(DOWNLOAD_DIRECTORY, archiveName);
const extractedPath = build.resolvePathForPlatform(platform, pkg.destinationPath);
log.debug(`Patching ${pkg.name} binaries from ${downloadUrl} to ${extractedPath}`);
await deleteAll([extractedPath], log);
await download({
log,
url: downloadUrl,
destination: downloadPath,
sha256: pkg.shas[platformName],
retries: 3,
});
await untar(downloadPath, extractedPath);
}
export const PatchNativeModulesTask = {
description: 'Patching platform-specific native modules',
async run(config, log, build) {
for (const pkg of packages) {
await Promise.all(
config.getTargetPlatforms().map(async platform => {
await patchModule(config, log, build, platform, pkg);
})
);
}
},
};

View file

@ -51,10 +51,7 @@ export default new Chainable('label', {
const config = args.byName;
return alter(args, function (eachSeries) {
if (config.regex) {
// not using a standard `import` so that if there's an issue with the re2 native module
// that it doesn't prevent Kibana from starting up and we only have an issue using Timelion labels
const RE2 = require('re2');
eachSeries.label = eachSeries.label.replace(new RE2(config.regex), config.label);
eachSeries.label = eachSeries.label.replace(new RegExp(config.regex), config.label);
} else {
eachSeries.label = config.label;
}

View file

@ -15382,16 +15382,11 @@ mute-stream@0.0.7:
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=
nan@^2.10.0:
nan@^2.10.0, nan@^2.9.2:
version "2.10.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f"
integrity sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==
nan@^2.14.0, nan@^2.9.2:
version "2.14.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c"
integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==
nanomatch@^1.2.5:
version "1.2.7"
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.7.tgz#53cd4aa109ff68b7f869591fdc9d10daeeea3e79"
@ -17707,13 +17702,6 @@ rc@^1.0.1, rc@^1.1.6, rc@^1.2.7:
minimist "^1.2.0"
strip-json-comments "~2.0.1"
re2@1.10.5:
version "1.10.5"
resolved "https://registry.yarnpkg.com/re2/-/re2-1.10.5.tgz#b3730438121c6bf59d459aff3471177eef513445"
integrity sha512-ssO3AD8/YJzuQUgEasS8PxA8n1yg8JB2VNSJhCebuuHLwaGiufhtFGUypS2bONrCPDbjwlMy7OZD9LkcrQMr1g==
dependencies:
nan "^2.14.0"
react-ace@^5.5.0:
version "5.10.0"
resolved "https://registry.yarnpkg.com/react-ace/-/react-ace-5.10.0.tgz#e328b37ac52759f700be5afdb86ada2f5ec84c5e"