mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
Co-authored-by: spalger <spalger@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: spalger <spalger@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
9882afcf8b
commit
941fdca61a
5 changed files with 143 additions and 66 deletions
|
@ -1,9 +1,13 @@
|
|||
{
|
||||
"name": "@kbn/es",
|
||||
"main": "./src/index.js",
|
||||
"main": "./target/index.js",
|
||||
"version": "1.0.0",
|
||||
"license": "Apache-2.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"kbn:bootstrap": "node scripts/build",
|
||||
"kbn:watch": "node scripts/build --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@elastic/elasticsearch": "7.9.0-rc.1",
|
||||
"@kbn/dev-utils": "1.0.0",
|
||||
|
@ -19,5 +23,10 @@
|
|||
"tar-fs": "^2.1.0",
|
||||
"tree-kill": "^1.2.2",
|
||||
"yauzl": "^2.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kbn/babel-preset": "1.0.0",
|
||||
"@babel/cli": "^7.10.5",
|
||||
"del": "^5.1.0"
|
||||
}
|
||||
}
|
||||
|
|
71
packages/kbn-es/scripts/build.js
Normal file
71
packages/kbn-es/scripts/build.js
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const { resolve } = require('path');
|
||||
|
||||
const del = require('del');
|
||||
const { run, withProcRunner } = require('@kbn/dev-utils');
|
||||
|
||||
const ROOT_DIR = resolve(__dirname, '..');
|
||||
const BUILD_DIR = resolve(ROOT_DIR, 'target');
|
||||
|
||||
run(
|
||||
async ({ log, flags }) => {
|
||||
await withProcRunner(log, async (proc) => {
|
||||
log.info('Deleting old output');
|
||||
await del(BUILD_DIR);
|
||||
|
||||
const cwd = ROOT_DIR;
|
||||
|
||||
log.info(`Starting babel${flags.watch ? ' in watch mode' : ''}`);
|
||||
await proc.run(`babel`, {
|
||||
cmd: 'babel',
|
||||
args: [
|
||||
'src',
|
||||
'--no-babelrc',
|
||||
'--presets',
|
||||
require.resolve('@kbn/babel-preset/node_preset'),
|
||||
'--extensions',
|
||||
'.ts,.js',
|
||||
'--copy-files',
|
||||
'--out-dir',
|
||||
BUILD_DIR,
|
||||
...(flags.watch ? ['--watch'] : ['--quiet']),
|
||||
...(!flags['source-maps'] || !!process.env.CODE_COVERAGE
|
||||
? []
|
||||
: ['--source-maps', 'inline']),
|
||||
],
|
||||
wait: true,
|
||||
cwd,
|
||||
});
|
||||
|
||||
log.success('Complete');
|
||||
});
|
||||
},
|
||||
{
|
||||
description: 'Simple build tool for @kbn/es package',
|
||||
flags: {
|
||||
boolean: ['watch', 'source-maps'],
|
||||
help: `
|
||||
--watch Run in watch mode
|
||||
--source-maps Include sourcemaps
|
||||
`,
|
||||
},
|
||||
}
|
||||
);
|
|
@ -25,65 +25,67 @@ const { exitCode, start, ssl } = JSON.parse(process.argv[2]);
|
|||
const { createServer } = ssl ? require('https') : require('http');
|
||||
const { ES_KEY_PATH, ES_CERT_PATH } = require('@kbn/dev-utils');
|
||||
|
||||
process.exitCode = exitCode;
|
||||
(function main() {
|
||||
process.exitCode = exitCode;
|
||||
|
||||
if (!start) {
|
||||
return;
|
||||
}
|
||||
if (!start) {
|
||||
return;
|
||||
}
|
||||
|
||||
let serverUrl;
|
||||
const server = createServer(
|
||||
{
|
||||
// Note: the integration uses the ES_P12_PATH, but that keystore contains
|
||||
// the same key/cert as ES_KEY_PATH and ES_CERT_PATH
|
||||
key: ssl ? fs.readFileSync(ES_KEY_PATH) : undefined,
|
||||
cert: ssl ? fs.readFileSync(ES_CERT_PATH) : undefined,
|
||||
},
|
||||
(req, res) => {
|
||||
const url = new URL(req.url, serverUrl);
|
||||
const send = (code, body) => {
|
||||
res.writeHead(code, { 'content-type': 'application/json' });
|
||||
res.end(JSON.stringify(body));
|
||||
};
|
||||
let serverUrl;
|
||||
const server = createServer(
|
||||
{
|
||||
// Note: the integration uses the ES_P12_PATH, but that keystore contains
|
||||
// the same key/cert as ES_KEY_PATH and ES_CERT_PATH
|
||||
key: ssl ? fs.readFileSync(ES_KEY_PATH) : undefined,
|
||||
cert: ssl ? fs.readFileSync(ES_CERT_PATH) : undefined,
|
||||
},
|
||||
(req, res) => {
|
||||
const url = new URL(req.url, serverUrl);
|
||||
const send = (code, body) => {
|
||||
res.writeHead(code, { 'content-type': 'application/json' });
|
||||
res.end(JSON.stringify(body));
|
||||
};
|
||||
|
||||
if (url.pathname === '/_xpack') {
|
||||
return send(400, {
|
||||
if (url.pathname === '/_xpack') {
|
||||
return send(400, {
|
||||
error: {
|
||||
reason: 'foo bar',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return send(404, {
|
||||
error: {
|
||||
reason: 'foo bar',
|
||||
reason: 'not found',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return send(404, {
|
||||
error: {
|
||||
reason: 'not found',
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// setup server auto close after 1 second of silence
|
||||
let serverCloseTimer;
|
||||
const delayServerClose = () => {
|
||||
clearTimeout(serverCloseTimer);
|
||||
serverCloseTimer = setTimeout(() => server.close(), 1000);
|
||||
};
|
||||
server.on('request', delayServerClose);
|
||||
server.on('listening', delayServerClose);
|
||||
|
||||
server.listen(0, '127.0.0.1', function () {
|
||||
const { port, address: hostname } = server.address();
|
||||
serverUrl = new URL(
|
||||
formatUrl({
|
||||
protocol: 'http:',
|
||||
port,
|
||||
hostname,
|
||||
})
|
||||
);
|
||||
|
||||
console.log(
|
||||
`[o.e.h.AbstractHttpServerTransport] [computer] publish_address {127.0.0.1:${port}}, bound_addresses {[::1]:${port}}, {127.0.0.1:${port}}`
|
||||
);
|
||||
// setup server auto close after 1 second of silence
|
||||
let serverCloseTimer;
|
||||
const delayServerClose = () => {
|
||||
clearTimeout(serverCloseTimer);
|
||||
serverCloseTimer = setTimeout(() => server.close(), 1000);
|
||||
};
|
||||
server.on('request', delayServerClose);
|
||||
server.on('listening', delayServerClose);
|
||||
|
||||
console.log('started');
|
||||
});
|
||||
server.listen(0, '127.0.0.1', function () {
|
||||
const { port, address: hostname } = server.address();
|
||||
serverUrl = new URL(
|
||||
formatUrl({
|
||||
protocol: 'http:',
|
||||
port,
|
||||
hostname,
|
||||
})
|
||||
);
|
||||
|
||||
console.log(
|
||||
`[o.e.h.AbstractHttpServerTransport] [computer] publish_address {127.0.0.1:${port}}, bound_addresses {[::1]:${port}}, {127.0.0.1:${port}}`
|
||||
);
|
||||
|
||||
console.log('started');
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
require('../src/setup_node_env');
|
||||
require('../src/setup_node_env/prebuilt_dev_only_entry');
|
||||
|
||||
var resolve = require('path').resolve;
|
||||
var pkg = require('../package.json');
|
||||
|
|
19
yarn.lock
19
yarn.lock
|
@ -3,9 +3,9 @@
|
|||
|
||||
|
||||
"@babel/cli@^7.10.5":
|
||||
version "7.10.5"
|
||||
resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.10.5.tgz#57df2987c8cf89d0fc7d4b157ec59d7619f1b77a"
|
||||
integrity sha512-j9H9qSf3kLdM0Ao3aGPbGZ73mEA9XazuupcS6cDGWuiyAcANoguhP0r2Lx32H5JGw4sSSoHG3x/mxVnHgvOoyA==
|
||||
version "7.11.6"
|
||||
resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.11.6.tgz#1fcbe61c2a6900c3539c06ee58901141f3558482"
|
||||
integrity sha512-+w7BZCvkewSmaRM6H4L2QM3RL90teqEIHDIFXAmrW33+0jhlymnDAEdqVeCZATvxhQuio1ifoGVlJJbIiH9Ffg==
|
||||
dependencies:
|
||||
commander "^4.0.1"
|
||||
convert-source-map "^1.1.0"
|
||||
|
@ -20277,15 +20277,10 @@ moment-timezone@^0.5.27:
|
|||
dependencies:
|
||||
moment ">= 2.9.0"
|
||||
|
||||
"moment@>= 2.9.0", moment@>=1.6.0, moment@>=2.14.0, moment@^2.10.6, moment@^2.24.0:
|
||||
version "2.24.0"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.24.0.tgz#0d055d53f5052aa653c9f6eb68bb5d12bf5c2b5b"
|
||||
integrity sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==
|
||||
|
||||
moment@^2.19.3, moment@^2.27.0:
|
||||
version "2.27.0"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.27.0.tgz#8bff4e3e26a236220dfe3e36de756b6ebaa0105d"
|
||||
integrity sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==
|
||||
"moment@>= 2.9.0", moment@>=1.6.0, moment@>=2.14.0, moment@^2.10.6, moment@^2.19.3, moment@^2.24.0, moment@^2.27.0:
|
||||
version "2.28.0"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.28.0.tgz#cdfe73ce01327cee6537b0fafac2e0f21a237d75"
|
||||
integrity sha512-Z5KOjYmnHyd/ukynmFd/WwyXHd7L4J9vTI/nn5Ap9AVUgaAE15VvQ9MOGmJJygEUklupqIrFnor/tjTwRU+tQw==
|
||||
|
||||
monaco-editor@~0.17.0:
|
||||
version "0.17.1"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue