From 8dfa2769b8527dab421842f5c83dfe6599073646 Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Mon, 11 Jul 2016 13:07:54 -0400 Subject: [PATCH 01/29] chore(NA): load NODE_OPTIONS from options files across environments --- .gitignore | 1 + bin/kibana | 2 +- bin/kibana-keystore | 2 +- bin/kibana-keystore.bat | 9 ++ bin/kibana-plugin | 2 +- bin/kibana-plugin.bat | 12 ++- bin/kibana.bat | 11 ++- config/node.options | 8 ++ package.json | 6 +- scripts/run_with_node_options.js | 21 +++++ src/dev/ci_setup/node.ci.options | 5 + src/dev/ci_setup/setup_env.sh | 9 +- src/dev/run_with_node_options/index.js | 20 ++++ .../run_with_node_options.js | 93 +++++++++++++++++++ .../run_with_node_options_cli.js | 48 ++++++++++ 15 files changed, 239 insertions(+), 10 deletions(-) create mode 100644 config/node.options create mode 100644 scripts/run_with_node_options.js create mode 100644 src/dev/ci_setup/node.ci.options create mode 100644 src/dev/run_with_node_options/index.js create mode 100644 src/dev/run_with_node_options/run_with_node_options.js create mode 100644 src/dev/run_with_node_options/run_with_node_options_cli.js diff --git a/.gitignore b/.gitignore index efb5c57774633..59124f133616b 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ disabledPlugins webpackstats.json /config/* !/config/kibana.yml +!/config/node.options coverage selenium .babel_register_cache.json diff --git a/bin/kibana b/bin/kibana index 558facb9da32b..9c36164d737eb 100755 --- a/bin/kibana +++ b/bin/kibana @@ -21,4 +21,4 @@ if [ ! -x "$NODE" ]; then exit 1 fi -NODE_OPTIONS="--no-warnings --max-http-header-size=65536 ${NODE_OPTIONS}" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli" ${@} +NODE_OPTIONS="--max-http-header-size=65536 $(grep -v ^# < ${DIR}/config/node.options | xargs) $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli" ${@} diff --git a/bin/kibana-keystore b/bin/kibana-keystore index 43800c7b895d3..94dc64c6fe0e0 100755 --- a/bin/kibana-keystore +++ b/bin/kibana-keystore @@ -21,4 +21,4 @@ if [ ! -x "$NODE" ]; then exit 1 fi -"${NODE}" "${DIR}/src/cli_keystore" "$@" +NODE_OPTIONS="$(grep -v ^# < ${DIR}/config/node.options | xargs) $NODE_OPTIONS" "${NODE}" "${DIR}/src/cli_keystore" "$@" diff --git a/bin/kibana-keystore.bat b/bin/kibana-keystore.bat index b8311db2cfae5..1a02c4a796a4a 100644 --- a/bin/kibana-keystore.bat +++ b/bin/kibana-keystore.bat @@ -12,6 +12,15 @@ If Not Exist "%NODE%" ( Exit /B 1 ) +for /F "eol=# tokens=*" %%i in (%DIR%\config\node.options) do ( + If [%NODE_OPTIONS%]==[] ( + set NODE_OPTIONS="%%i" + ) + else ( + set NODE_OPTIONS="%%i %NODE_OPTIONS" + ) +) + TITLE Kibana Keystore "%NODE%" "%DIR%\src\cli_keystore" %* diff --git a/bin/kibana-plugin b/bin/kibana-plugin index b843d4966c6d1..4e40c86b63d4f 100755 --- a/bin/kibana-plugin +++ b/bin/kibana-plugin @@ -21,4 +21,4 @@ if [ ! -x "$NODE" ]; then exit 1 fi -NODE_OPTIONS="--no-warnings ${NODE_OPTIONS}" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli_plugin" "$@" +NODE_OPTIONS="$(grep -v ^# < ${DIR}/config/node.options | xargs) $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli_plugin" "$@" diff --git a/bin/kibana-plugin.bat b/bin/kibana-plugin.bat index bf382a0657ade..49ecd1ae760f5 100755 --- a/bin/kibana-plugin.bat +++ b/bin/kibana-plugin.bat @@ -13,9 +13,17 @@ If Not Exist "%NODE%" ( Exit /B 1 ) -TITLE Kibana Server +for /F "eol=# tokens=*" %%i in (%DIR%\config\node.options) do ( + If [%NODE_OPTIONS%]==[] ( + set NODE_OPTIONS="%%i" + ) + else ( + set NODE_OPTIONS="%%i %NODE_OPTIONS" + ) +) -set "NODE_OPTIONS=--no-warnings %NODE_OPTIONS%" && "%NODE%" "%DIR%\src\cli_plugin" %* +TITLE Kibana Server +"%NODE%" "%DIR%\src\cli_plugin" %* :finally diff --git a/bin/kibana.bat b/bin/kibana.bat index 9d8ba359e53af..e117a04310bf0 100755 --- a/bin/kibana.bat +++ b/bin/kibana.bat @@ -14,7 +14,16 @@ If Not Exist "%NODE%" ( Exit /B 1 ) -set "NODE_OPTIONS=--no-warnings --max-http-header-size=65536 %NODE_OPTIONS%" && "%NODE%" "%DIR%\src\cli" %* +for /F "eol=# tokens=*" %%i in (%DIR%\config\node.options) do ( + If [%NODE_OPTIONS%]==[] ( + set NODE_OPTIONS="%%i" + ) + else ( + set NODE_OPTIONS="%%i %NODE_OPTIONS" + ) +) + +set "NODE_OPTIONS=--max-http-header-size=65536 %NODE_OPTIONS%" && "%NODE%" "%DIR%\src\cli" %* :finally diff --git a/config/node.options b/config/node.options new file mode 100644 index 0000000000000..522f193d92fce --- /dev/null +++ b/config/node.options @@ -0,0 +1,8 @@ +## Node command line options +## See `node --help` and `node --v8-options` for available options + +## max size of old space in megabytes +#--max-old-space-size=512 + +## turn off warnings output +--no-warnings diff --git a/package.json b/package.json index b3dcfb2aa3b0a..9d75299dc3907 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,9 @@ }, "author": "Rashid Khan ", "scripts": { + "test2": "yarn runWithNodeOptions --c 'yarn run merda1'", + "merda1": "node -e 'console.log(require(\"v8\").getHeapStatistics())'", + "merda2": "node -e 'console.log(process.env.NODE_OPTIONS)'", "preinstall": "node ./preinstall_check", "kbn": "node scripts/kbn", "es": "node scripts/es", @@ -70,7 +73,8 @@ "spec_to_console": "node scripts/spec_to_console", "backport-skip-ci": "backport --prDescription \"[skip-ci]\"", "storybook": "node scripts/storybook", - "cover:report": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report --reporter=lcov && open ./target/coverage/report/lcov-report/index.html" + "cover:report": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report --reporter=lcov && open ./target/coverage/report/lcov-report/index.html", + "runWithNodeOptions": "node scripts/run_with_node_options" }, "repository": { "type": "git", diff --git a/scripts/run_with_node_options.js b/scripts/run_with_node_options.js new file mode 100644 index 0000000000000..a51d00b398eb0 --- /dev/null +++ b/scripts/run_with_node_options.js @@ -0,0 +1,21 @@ +/* + * 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. + */ + +require('../src/setup_node_env'); +require('../src/dev/run_with_node_options').runWithNodeOptionsCli(); diff --git a/src/dev/ci_setup/node.ci.options b/src/dev/ci_setup/node.ci.options new file mode 100644 index 0000000000000..566b91fabc136 --- /dev/null +++ b/src/dev/ci_setup/node.ci.options @@ -0,0 +1,5 @@ +## Node command line options for CI ENV +## See `node --help` and `node --v8-options` for available options + +## max size of old space in megabytes +--max-old-space-size=4096 diff --git a/src/dev/ci_setup/setup_env.sh b/src/dev/ci_setup/setup_env.sh index 05840926d35de..95697c38f08f7 100644 --- a/src/dev/ci_setup/setup_env.sh +++ b/src/dev/ci_setup/setup_env.sh @@ -9,13 +9,11 @@ fi installNode=$1 dir="$(pwd)" -cacheDir="$HOME/.kibana" +cacheDsir="$HOME/.kibana" RED='\033[0;31m' C_RESET='\033[0m' # Reset color -export NODE_OPTIONS="$NODE_OPTIONS --max-old-space-size=4096" - ### ### Since the Jenkins logging output collector doesn't look like a TTY ### Node/Chalk and other color libs disable their color output. But Jenkins @@ -53,6 +51,11 @@ export PARENT_DIR="$parentDir" kbnBranch="$(jq -r .branch "$KIBANA_DIR/package.json")" export KIBANA_PKG_BRANCH="$kbnBranch" +### +### Sets correct NODE_OPTIONS for CI +### +NODE_OPTIONS="$(grep -v ^# < ${KIBANA_DIR}/src/dev/ci_setup/node.ci.options | xargs) $NODE_OPTIONS" + ### ### download node ### diff --git a/src/dev/run_with_node_options/index.js b/src/dev/run_with_node_options/index.js new file mode 100644 index 0000000000000..632efec002614 --- /dev/null +++ b/src/dev/run_with_node_options/index.js @@ -0,0 +1,20 @@ +/* + * 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. + */ + +export { runWithNodeOptionsCli } from './run_with_node_options_cli'; diff --git a/src/dev/run_with_node_options/run_with_node_options.js b/src/dev/run_with_node_options/run_with_node_options.js new file mode 100644 index 0000000000000..03e9bb3959b1f --- /dev/null +++ b/src/dev/run_with_node_options/run_with_node_options.js @@ -0,0 +1,93 @@ +/* + * 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 execa from 'execa'; +import { existsSync, readFile } from 'fs'; +import { join } from 'path'; +import { promisify } from 'util'; +import { REPO_ROOT } from '../constants'; + +const readFileAsync = promisify(readFile); + +function removeComments(nodeOptionsFileStr) { + const commentsRegex = /(^#.*$)/gim; + let match = commentsRegex.exec(nodeOptionsFileStr); + let newString = nodeOptionsFileStr; + while (match != null) { + newString = newString.replace(match[1], ''); + match = commentsRegex.exec(nodeOptionsFileStr); + } + + return newString; +} + +function removeEmptyLines(nodeOptionsFileStr) { + const emptyLinesRegex = /(^\n)/gim; + return nodeOptionsFileStr.replace(emptyLinesRegex, ''); +} + +function getNodeOptionsStr(nodeOptionsFileStr) { + const fileParseRegex = /^((.+?)[=](.*))$/gim; + let matches = ''; + let match; + while ((match = fileParseRegex.exec(nodeOptionsFileStr)) !== null) { + matches += `${match[1].trim()}${matches ? ' ' : ''}`; + } + return matches; +} + +async function getNodeOptionsFromFile(filePath) { + if (!filePath || !existsSync(filePath)) { + return {}; + } + + const nodeOptionsFileStr = (await readFileAsync(filePath)).toString(); + const sanitizedNodeOptionsFileStr = removeEmptyLines(removeComments(nodeOptionsFileStr)); + const nodeOptionsStr = getNodeOptionsStr(sanitizedNodeOptionsFileStr); + + if (!nodeOptionsStr && !process.env.NODE_OPTIONS) { + return {}; + } + + const sanitizedNodeOptionsStr = nodeOptionsStr ? `${nodeOptionsStr} ` : ''; + + return { + NODE_OPTIONS: `${sanitizedNodeOptionsStr}${process.env.NODE_OPTIONS || ''}`, + }; +} + +async function runWithNodeOptions({ command }) { + if (!command) { + return; + } + + const nodeOptionsFromFile = await getNodeOptionsFromFile( + join(REPO_ROOT, 'config', 'node.dev.options') + ); + + const childEnv = Object.assign(process.env, nodeOptionsFromFile); + + await execa.command(command, { + shell: true, + stdio: 'inherit', + env: childEnv, + }); +} + +export { runWithNodeOptions }; diff --git a/src/dev/run_with_node_options/run_with_node_options_cli.js b/src/dev/run_with_node_options/run_with_node_options_cli.js new file mode 100644 index 0000000000000..38a0cca7dcbd9 --- /dev/null +++ b/src/dev/run_with_node_options/run_with_node_options_cli.js @@ -0,0 +1,48 @@ +/* + * 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 { run } from '@kbn/dev-utils'; +import { runWithNodeOptions } from './run_with_node_options'; + +function runWithNodeOptionsCli() { + run( + async ({ flags: { command } }) => { + await runWithNodeOptions({ + command, + }); + }, + { + description: 'Simple CLI, useful for to run node with node options', + flags: { + default: { + command: '', + }, + string: ['command'], + alias: { + c: 'command', + }, + help: ` + --command Run a shell command using node.dev.options file + `, + }, + } + ); +} + +export { runWithNodeOptionsCli }; From 76cde2ef32e23e8d9149c2cd01c2971e44cde588 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 19 Mar 2020 03:06:40 +0000 Subject: [PATCH 02/29] chore(NA): move node.ci.options to config folder --- .gitignore | 1 + {src/dev/ci_setup => config}/node.ci.options | 2 +- src/dev/build/tasks/copy_source_task.js | 1 + src/dev/ci_setup/setup_env.sh | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) rename {src/dev/ci_setup => config}/node.ci.options (76%) diff --git a/.gitignore b/.gitignore index 59124f133616b..0d666dd3f0ece 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ webpackstats.json /config/* !/config/kibana.yml !/config/node.options +!/config/node.ci.options coverage selenium .babel_register_cache.json diff --git a/src/dev/ci_setup/node.ci.options b/config/node.ci.options similarity index 76% rename from src/dev/ci_setup/node.ci.options rename to config/node.ci.options index 566b91fabc136..c75aaaed7d9f2 100644 --- a/src/dev/ci_setup/node.ci.options +++ b/config/node.ci.options @@ -1,4 +1,4 @@ -## Node command line options for CI ENV +## Node command line options for CI ## See `node --help` and `node --v8-options` for available options ## max size of old space in megabytes diff --git a/src/dev/build/tasks/copy_source_task.js b/src/dev/build/tasks/copy_source_task.js index ee9dc159de47f..4a708bc30c7e8 100644 --- a/src/dev/build/tasks/copy_source_task.js +++ b/src/dev/build/tasks/copy_source_task.js @@ -46,6 +46,7 @@ export const CopySourceTask = { 'typings/**', 'webpackShims/**', 'config/kibana.yml', + 'config/node.options', 'tsconfig*.json', '.i18nrc.json', 'kibana.d.ts', diff --git a/src/dev/ci_setup/setup_env.sh b/src/dev/ci_setup/setup_env.sh index 95697c38f08f7..64fdbf0ec0673 100644 --- a/src/dev/ci_setup/setup_env.sh +++ b/src/dev/ci_setup/setup_env.sh @@ -54,7 +54,7 @@ export KIBANA_PKG_BRANCH="$kbnBranch" ### ### Sets correct NODE_OPTIONS for CI ### -NODE_OPTIONS="$(grep -v ^# < ${KIBANA_DIR}/src/dev/ci_setup/node.ci.options | xargs) $NODE_OPTIONS" +NODE_OPTIONS="$(grep -v ^# < ${KIBANA_DIR}/config/node.ci.options | xargs) $NODE_OPTIONS" ### ### download node From 09764ca57f849af1e7fd75466161a4a1a0255304 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Mon, 30 Mar 2020 15:09:11 +0100 Subject: [PATCH 03/29] docs(NA): update docs to explain how to set node options from the cfg fil --- docs/setup/production.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/setup/production.asciidoc b/docs/setup/production.asciidoc index eef2b11e53d85..8d598298ef888 100644 --- a/docs/setup/production.asciidoc +++ b/docs/setup/production.asciidoc @@ -166,9 +166,9 @@ These can be used to automatically update the list of hosts as a cluster is resi Kibana has a default maximum memory limit of 1.4 GB, and in most cases, we recommend leaving this unconfigured. In some scenarios, such as large reporting jobs, it may make sense to tweak limits to meet more specific requirements. -You can modify this limit by setting `--max-old-space-size` in the `NODE_OPTIONS` environment variable. For deb and rpm, packages this is passed in via `/etc/default/kibana` and can be appended to the bottom of the file. +You can modify this limit by setting `--max-old-space-size` in the `node.options` config file that can be found inside `kibana/config` folder. The option accepts a limit in MB: -------- -NODE_OPTIONS="--max-old-space-size=2048" bin/kibana +--max-old-space-size=2048 -------- From fd041410cacde306cb637e7265ee59afdca04760 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Tue, 31 Mar 2020 00:22:42 +0100 Subject: [PATCH 04/29] chore(NA): removed test npm scripts --- package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/package.json b/package.json index ce3ff0dc16a4f..017943a9deebc 100644 --- a/package.json +++ b/package.json @@ -36,9 +36,6 @@ }, "author": "Rashid Khan ", "scripts": { - "test2": "yarn runWithNodeOptions --c 'yarn run merda1'", - "merda1": "node -e 'console.log(require(\"v8\").getHeapStatistics())'", - "merda2": "node -e 'console.log(process.env.NODE_OPTIONS)'", "preinstall": "node ./preinstall_check", "kbn": "node scripts/kbn", "es": "node scripts/es", From 3a2382b84649c575a90e3ccfd025f3062b5b2e47 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Fri, 3 Apr 2020 17:23:20 +0100 Subject: [PATCH 05/29] fix(NA): typo on setup script for CI --- src/dev/ci_setup/setup_env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev/ci_setup/setup_env.sh b/src/dev/ci_setup/setup_env.sh index 64fdbf0ec0673..ff71181f47a0d 100644 --- a/src/dev/ci_setup/setup_env.sh +++ b/src/dev/ci_setup/setup_env.sh @@ -9,7 +9,7 @@ fi installNode=$1 dir="$(pwd)" -cacheDsir="$HOME/.kibana" +cacheDir="$HOME/.kibana" RED='\033[0;31m' C_RESET='\033[0m' # Reset color From f551fd81d3beec3094df657b30a6440cabaf3e44 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Sat, 4 Apr 2020 01:25:35 +0100 Subject: [PATCH 06/29] chore(NA): add debug info --- src/dev/ci_setup/setup_env.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dev/ci_setup/setup_env.sh b/src/dev/ci_setup/setup_env.sh index ff71181f47a0d..33ba0a5253507 100644 --- a/src/dev/ci_setup/setup_env.sh +++ b/src/dev/ci_setup/setup_env.sh @@ -56,6 +56,11 @@ export KIBANA_PKG_BRANCH="$kbnBranch" ### NODE_OPTIONS="$(grep -v ^# < ${KIBANA_DIR}/config/node.ci.options | xargs) $NODE_OPTIONS" +for entry in "${KIBANA_DIR}/config"/* +do + echo "$entry" +done + ### ### download node ### From 00c9badfa8f5693cebf0bfbea2c4abfc2f248014 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Sat, 4 Apr 2020 01:29:31 +0100 Subject: [PATCH 07/29] chore(NA): export options on CI --- src/dev/ci_setup/setup_env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dev/ci_setup/setup_env.sh b/src/dev/ci_setup/setup_env.sh index 33ba0a5253507..905e019db1569 100644 --- a/src/dev/ci_setup/setup_env.sh +++ b/src/dev/ci_setup/setup_env.sh @@ -54,7 +54,7 @@ export KIBANA_PKG_BRANCH="$kbnBranch" ### ### Sets correct NODE_OPTIONS for CI ### -NODE_OPTIONS="$(grep -v ^# < ${KIBANA_DIR}/config/node.ci.options | xargs) $NODE_OPTIONS" +export NODE_OPTIONS="$(grep -v ^# < ${KIBANA_DIR}/config/node.ci.options | xargs) $NODE_OPTIONS" for entry in "${KIBANA_DIR}/config"/* do From ed3f6fa639f6cb9bd46c2c440fe16144d1340893 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Sat, 4 Apr 2020 01:40:17 +0100 Subject: [PATCH 08/29] chore(NA): remove debug info --- src/dev/ci_setup/setup_env.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/dev/ci_setup/setup_env.sh b/src/dev/ci_setup/setup_env.sh index 905e019db1569..a73c3a00e438a 100644 --- a/src/dev/ci_setup/setup_env.sh +++ b/src/dev/ci_setup/setup_env.sh @@ -56,11 +56,6 @@ export KIBANA_PKG_BRANCH="$kbnBranch" ### export NODE_OPTIONS="$(grep -v ^# < ${KIBANA_DIR}/config/node.ci.options | xargs) $NODE_OPTIONS" -for entry in "${KIBANA_DIR}/config"/* -do - echo "$entry" -done - ### ### download node ### From a4128eb3832fff3e3e54ef6adbad28d522dfb3b3 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 21 May 2020 18:20:28 +0100 Subject: [PATCH 09/29] chore(NA): support for configurable config folder using env var --- bin/kibana | 3 ++- bin/kibana-keystore | 3 ++- bin/kibana-keystore.bat | 18 +++++++++++------- bin/kibana-plugin | 3 ++- bin/kibana-plugin.bat | 18 +++++++++++------- bin/kibana.bat | 25 +++++++++++++++++-------- docs/setup/production.asciidoc | 2 +- src/dev/ci_setup/setup_env.sh | 3 ++- 8 files changed, 48 insertions(+), 27 deletions(-) diff --git a/bin/kibana b/bin/kibana index 9c36164d737eb..f74dddc02b383 100755 --- a/bin/kibana +++ b/bin/kibana @@ -14,6 +14,7 @@ while [ -h "$SCRIPT" ] ; do done DIR="$(dirname "${SCRIPT}")/.." +CONFIG_DIR=${KIBANA_PATH_CONF:-"$DIR/config"} NODE="${DIR}/node/bin/node" test -x "$NODE" if [ ! -x "$NODE" ]; then @@ -21,4 +22,4 @@ if [ ! -x "$NODE" ]; then exit 1 fi -NODE_OPTIONS="--max-http-header-size=65536 $(grep -v ^# < ${DIR}/config/node.options | xargs) $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli" ${@} +NODE_OPTIONS="--max-http-header-size=65536 $(grep -v ^# < ${CONFIG_DIR}/node.options | xargs) $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli" ${@} diff --git a/bin/kibana-keystore b/bin/kibana-keystore index 94dc64c6fe0e0..0aa9c8cafc607 100755 --- a/bin/kibana-keystore +++ b/bin/kibana-keystore @@ -14,6 +14,7 @@ while [ -h "$SCRIPT" ] ; do done DIR="$(dirname "${SCRIPT}")/.." +CONFIG_DIR=${KIBANA_PATH_CONF:-"$DIR/config"} NODE="${DIR}/node/bin/node" test -x "$NODE" if [ ! -x "$NODE" ]; then @@ -21,4 +22,4 @@ if [ ! -x "$NODE" ]; then exit 1 fi -NODE_OPTIONS="$(grep -v ^# < ${DIR}/config/node.options | xargs) $NODE_OPTIONS" "${NODE}" "${DIR}/src/cli_keystore" "$@" +NODE_OPTIONS="$(grep -v ^# < ${CONFIG_DIR}/node.options | xargs) $NODE_OPTIONS" "${NODE}" "${DIR}/src/cli_keystore" "$@" diff --git a/bin/kibana-keystore.bat b/bin/kibana-keystore.bat index 1a02c4a796a4a..c2584a5626da0 100644 --- a/bin/kibana-keystore.bat +++ b/bin/kibana-keystore.bat @@ -1,6 +1,6 @@ @echo off -SETLOCAL +SETLOCAL ENABLEDELAYEDEXPANSION set SCRIPT_DIR=%~dp0 for %%I in ("%SCRIPT_DIR%..") do set DIR=%%~dpfI @@ -12,12 +12,16 @@ If Not Exist "%NODE%" ( Exit /B 1 ) -for /F "eol=# tokens=*" %%i in (%DIR%\config\node.options) do ( - If [%NODE_OPTIONS%]==[] ( - set NODE_OPTIONS="%%i" - ) - else ( - set NODE_OPTIONS="%%i %NODE_OPTIONS" +set CONFIG_DIR=%KIBANA_PATH_CONF% +If [%KIBANA_PATH_CONF%] == [] ( + set CONFIG_DIR=%DIR%config +) + +for /F "eol=# tokens=*" %%i in (%CONFIG_DIR%\node.options) do ( + If [!NODE_OPTIONS!] == [] ( + set "NODE_OPTIONS=%%i" + ) Else ( + set "NODE_OPTIONS=!NODE_OPTIONS! %%i" ) ) diff --git a/bin/kibana-plugin b/bin/kibana-plugin index 4e40c86b63d4f..77ce39d48647c 100755 --- a/bin/kibana-plugin +++ b/bin/kibana-plugin @@ -14,6 +14,7 @@ while [ -h "$SCRIPT" ] ; do done DIR="$(dirname "${SCRIPT}")/.." +CONFIG_DIR=${KIBANA_PATH_CONF:-"$DIR/config"} NODE="${DIR}/node/bin/node" test -x "$NODE" if [ ! -x "$NODE" ]; then @@ -21,4 +22,4 @@ if [ ! -x "$NODE" ]; then exit 1 fi -NODE_OPTIONS="$(grep -v ^# < ${DIR}/config/node.options | xargs) $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli_plugin" "$@" +NODE_OPTIONS="$(grep -v ^# < ${CONFIG_DIR}/node.options | xargs) $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli_plugin" "$@" diff --git a/bin/kibana-plugin.bat b/bin/kibana-plugin.bat index 49ecd1ae760f5..6f8fdb22dfe4a 100755 --- a/bin/kibana-plugin.bat +++ b/bin/kibana-plugin.bat @@ -1,6 +1,6 @@ @echo off -SETLOCAL +SETLOCAL ENABLEDELAYEDEXPANSION set SCRIPT_DIR=%~dp0 for %%I in ("%SCRIPT_DIR%..") do set DIR=%%~dpfI @@ -13,12 +13,16 @@ If Not Exist "%NODE%" ( Exit /B 1 ) -for /F "eol=# tokens=*" %%i in (%DIR%\config\node.options) do ( - If [%NODE_OPTIONS%]==[] ( - set NODE_OPTIONS="%%i" - ) - else ( - set NODE_OPTIONS="%%i %NODE_OPTIONS" +set CONFIG_DIR=%KIBANA_PATH_CONF% +If [%KIBANA_PATH_CONF%] == [] ( + set CONFIG_DIR=%DIR%config +) + +for /F "eol=# tokens=*" %%i in (%CONFIG_DIR%\node.options) do ( + If [!NODE_OPTIONS!] == [] ( + set "NODE_OPTIONS=%%i" + ) Else ( + set "NODE_OPTIONS=!NODE_OPTIONS! %%i" ) ) diff --git a/bin/kibana.bat b/bin/kibana.bat index e117a04310bf0..07f05ed88cc1b 100755 --- a/bin/kibana.bat +++ b/bin/kibana.bat @@ -1,6 +1,6 @@ @echo off -SETLOCAL +SETLOCAL ENABLEDELAYEDEXPANSION set SCRIPT_DIR=%~dp0 for %%I in ("%SCRIPT_DIR%..") do set DIR=%%~dpfI @@ -14,16 +14,25 @@ If Not Exist "%NODE%" ( Exit /B 1 ) -for /F "eol=# tokens=*" %%i in (%DIR%\config\node.options) do ( - If [%NODE_OPTIONS%]==[] ( - set NODE_OPTIONS="%%i" - ) - else ( - set NODE_OPTIONS="%%i %NODE_OPTIONS" +set CONFIG_DIR=%KIBANA_PATH_CONF% +If [%KIBANA_PATH_CONF%] == [] ( + set CONFIG_DIR=%DIR%config +) + +for /F "eol=# tokens=*" %%i in (%CONFIG_DIR%\node.options) do ( + If [!NODE_OPTIONS!] == [] ( + set "NODE_OPTIONS=%%i" + ) Else ( + set "NODE_OPTIONS=!NODE_OPTIONS! %%i" ) ) -set "NODE_OPTIONS=--max-http-header-size=65536 %NODE_OPTIONS%" && "%NODE%" "%DIR%\src\cli" %* +:: Include pre-defined node option +set "NODE_OPTIONS=--max-http-header-size=65536 %NODE_OPTIONS%" + +:: This should run independently as the last instruction +:: as we need NODE_OPTIONS previously set to expand +"%NODE%" "%DIR%\src\cli" %* :finally diff --git a/docs/setup/production.asciidoc b/docs/setup/production.asciidoc index 9491bc8383436..0bd53b3660e63 100644 --- a/docs/setup/production.asciidoc +++ b/docs/setup/production.asciidoc @@ -167,7 +167,7 @@ These can be used to automatically update the list of hosts as a cluster is resi Kibana has a default maximum memory limit of 1.4 GB, and in most cases, we recommend leaving this unconfigured. In some scenarios, such as large reporting jobs, it may make sense to tweak limits to meet more specific requirements. -You can modify this limit by setting `--max-old-space-size` in the `node.options` config file that can be found inside `kibana/config` folder. +You can modify this limit by setting `--max-old-space-size` in the `node.options` config file that can be found inside `kibana/config` folder or any other configured with the environment variable `KIBANA_PATH_CONF` (for example in debian based system would be `/etc/kibana`). The option accepts a limit in MB: -------- diff --git a/src/dev/ci_setup/setup_env.sh b/src/dev/ci_setup/setup_env.sh index 4fe31743ff79a..737388c27bc92 100644 --- a/src/dev/ci_setup/setup_env.sh +++ b/src/dev/ci_setup/setup_env.sh @@ -54,7 +54,8 @@ export KIBANA_PKG_BRANCH="$kbnBranch" ### ### Sets correct NODE_OPTIONS for CI ### -export NODE_OPTIONS="$(grep -v ^# < ${KIBANA_DIR}/config/node.ci.options | xargs) $NODE_OPTIONS" +CONFIG_DIR=${KIBANA_PATH_CONF:-"$KIBANA_DIR/config"} +export NODE_OPTIONS="$(grep -v ^# < ${KIBANA_DIR}/node.ci.options | xargs) $NODE_OPTIONS" ### ### download node From 74721cdf8718c9c404c207d7b1aa1e18c6016eef Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 21 May 2020 18:32:54 +0100 Subject: [PATCH 10/29] chore(NA): add node.options file into docker img --- .../docker_generator/templates/dockerfile.template.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.js b/src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.js index 5832d00162b20..ba423b1b2f9e0 100755 --- a/src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.js +++ b/src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.js @@ -93,6 +93,7 @@ function generator({ # Set some Kibana configuration defaults. COPY --chown=1000:0 config/kibana.yml /usr/share/kibana/config/kibana.yml + COPY --chown=1000:0 config/node.options /usr/share/kibana/config/node.options # Add the launcher/wrapper script. It knows how to interpret environment # variables and translate them to Kibana CLI options. From 90c2ab8b4b31152dfca8bbaf4d8d85f419b8e7c3 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 21 May 2020 22:01:44 +0100 Subject: [PATCH 11/29] fix(NA): use calculated config dir on node options for ci --- src/dev/ci_setup/setup_env.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dev/ci_setup/setup_env.sh b/src/dev/ci_setup/setup_env.sh index 737388c27bc92..5669e612be716 100644 --- a/src/dev/ci_setup/setup_env.sh +++ b/src/dev/ci_setup/setup_env.sh @@ -54,8 +54,8 @@ export KIBANA_PKG_BRANCH="$kbnBranch" ### ### Sets correct NODE_OPTIONS for CI ### -CONFIG_DIR=${KIBANA_PATH_CONF:-"$KIBANA_DIR/config"} -export NODE_OPTIONS="$(grep -v ^# < ${KIBANA_DIR}/node.ci.options | xargs) $NODE_OPTIONS" +export KIBANA_CONFIG_DIR=${KIBANA_PATH_CONF:-"$KIBANA_DIR/config"} +export NODE_OPTIONS="$(grep -v ^# < ${KIBANA_CONFIG_DIR}/node.ci.options | xargs) $NODE_OPTIONS" ### ### download node From 7bcceac84bd569e6c1a5ce5a9953a3fe755dd033 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Wed, 3 Jun 2020 14:39:14 +0100 Subject: [PATCH 12/29] chore(NA): node bin scripts bootstrap and node_with_options implementation for bash --- bin/node | 32 ++++++++++++++++++++++++++++++++ bin/node_with_options | 12 ++++++++++++ bin/node_with_options.bat | 9 +++++++++ 3 files changed, 53 insertions(+) create mode 100755 bin/node create mode 100755 bin/node_with_options create mode 100755 bin/node_with_options.bat diff --git a/bin/node b/bin/node new file mode 100755 index 0000000000000..7870635f1bc08 --- /dev/null +++ b/bin/node @@ -0,0 +1,32 @@ +#!/usr/bin/env node + +/* + * 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 { execFileSync } = require('child_process'); +const os = require('os'); + +const args = process.argv.slice(2); +const stdio = [0, 1, 2]; + +if (os.platform() === 'win32') { + execFileSync(`${__dirname}/node_with_options.bat`, args, { stdio }); +} else { + execFileSync(`${__dirname}/node_with_options`, args, { stdio }); +} diff --git a/bin/node_with_options b/bin/node_with_options new file mode 100755 index 0000000000000..ad56c0632b8d8 --- /dev/null +++ b/bin/node_with_options @@ -0,0 +1,12 @@ +#!/bin/sh + +SCRIPT=$0 +DIR="$(dirname "${SCRIPT}")/.." +CONFIG_DIR=${KIBANA_PATH_CONF:-"$DIR/config"} +NODE_DEV_OPTIONS_FILE=${CONFIG_DIR}/node.dev.options + +if test -f "$NODE_DEV_OPTIONS_FILE"; then + NODE_DEV_OPTIONS=$(grep -v ^# < $NODE_DEV_OPTIONS_FILE | xargs) +fi + +NODE_OPTIONS="$NODE_DEV_OPTIONS $NODE_OPTIONS" exec "node" ${@} diff --git a/bin/node_with_options.bat b/bin/node_with_options.bat new file mode 100755 index 0000000000000..fb7b53b2ad6fe --- /dev/null +++ b/bin/node_with_options.bat @@ -0,0 +1,9 @@ +@echo off + +SETLOCAL + + + +:finally + +ENDLOCAL From c892867729e3a8508b8181fa0f21fa269c67d0e1 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Wed, 3 Jun 2020 19:46:20 +0100 Subject: [PATCH 13/29] chore(NA): complete node_with_options scripts with bat version --- bin/node_with_options | 9 ++++++--- bin/node_with_options.bat | 28 +++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/bin/node_with_options b/bin/node_with_options index ad56c0632b8d8..84aa69ccd455d 100755 --- a/bin/node_with_options +++ b/bin/node_with_options @@ -3,10 +3,13 @@ SCRIPT=$0 DIR="$(dirname "${SCRIPT}")/.." CONFIG_DIR=${KIBANA_PATH_CONF:-"$DIR/config"} + +# Setup node dev options file to node.dev.options NODE_DEV_OPTIONS_FILE=${CONFIG_DIR}/node.dev.options -if test -f "$NODE_DEV_OPTIONS_FILE"; then - NODE_DEV_OPTIONS=$(grep -v ^# < $NODE_DEV_OPTIONS_FILE | xargs) +# Fallback to node.ci.options in case node.dev.options not exists +if [ ! -f "$NODE_DEV_OPTIONS_FILE" ]; then + NODE_DEV_OPTIONS_FILE=${CONFIG_DIR}/node.ci.options fi -NODE_OPTIONS="$NODE_DEV_OPTIONS $NODE_OPTIONS" exec "node" ${@} +NODE_OPTIONS="$(grep -v ^# < $NODE_DEV_OPTIONS_FILE | xargs) $NODE_OPTIONS" exec "node" ${@} diff --git a/bin/node_with_options.bat b/bin/node_with_options.bat index fb7b53b2ad6fe..1bbdc46862c2b 100755 --- a/bin/node_with_options.bat +++ b/bin/node_with_options.bat @@ -1,8 +1,34 @@ @echo off -SETLOCAL +SETLOCAL ENABLEDELAYEDEXPANSION +set SCRIPT_DIR=%~dp0 +for %%I in ("%SCRIPT_DIR%..") do set DIR=%%~dpfI +set CONFIG_DIR=%KIBANA_PATH_CONF% +If [%KIBANA_PATH_CONF%] == [] ( + set CONFIG_DIR=%DIR%config +) + +:: Setup node dev options file to node.dev.options +set NODE_DEV_OPTIONS_FILE=%CONFIG_DIR%\node.dev.options + +:: Fallback to node.ci.options in case node.dev.options not exists +If not exist "%NODE_DEV_OPTIONS_FILE%" ( + set NODE_DEV_OPTIONS_FILE=%CONFIG_DIR%\node.ci.options +) + +for /F "eol=# tokens=*" %%i in (%NODE_DEV_OPTIONS_FILE%) do ( + If [!NODE_OPTIONS!] == [] ( + set "NODE_OPTIONS=%%i" + ) Else ( + set "NODE_OPTIONS=!NODE_OPTIONS! %%i" + ) +) + +:: This should run independently as the last instruction +:: as we need NODE_OPTIONS previously set to expand +node %* :finally From e8a0386f7c4d01aa708fa3db3b5c2b0f7c55c0f7 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Fri, 5 Jun 2020 01:19:59 +0100 Subject: [PATCH 14/29] chore(NA): add bin/node dev script and remove cli for run_with_node_options --- bin/node | 10 +- scripts/run_with_node_options.js | 21 ----- .../node_with_options.bat | 2 +- .../node_with_options.sh | 2 +- src/dev/run_with_node_options/index.js | 20 ---- .../run_with_node_options.js | 93 ------------------- .../run_with_node_options_cli.js | 48 ---------- 7 files changed, 10 insertions(+), 186 deletions(-) delete mode 100644 scripts/run_with_node_options.js rename {bin => src/dev/node_with_options_bin_scripts}/node_with_options.bat (93%) rename bin/node_with_options => src/dev/node_with_options_bin_scripts/node_with_options.sh (91%) delete mode 100644 src/dev/run_with_node_options/index.js delete mode 100644 src/dev/run_with_node_options/run_with_node_options.js delete mode 100644 src/dev/run_with_node_options/run_with_node_options_cli.js diff --git a/bin/node b/bin/node index 7870635f1bc08..f6e578bd7efdf 100755 --- a/bin/node +++ b/bin/node @@ -26,7 +26,13 @@ const args = process.argv.slice(2); const stdio = [0, 1, 2]; if (os.platform() === 'win32') { - execFileSync(`${__dirname}/node_with_options.bat`, args, { stdio }); + execFileSync( + `${__dirname}/../src/dev/node_with_options_bin_scripts/node_with_options.bat`, + args, + { stdio } + ); } else { - execFileSync(`${__dirname}/node_with_options`, args, { stdio }); + execFileSync(`${__dirname}/../src/dev/node_with_options_bin_scripts/node_with_options.sh`, args, { + stdio, + }); } diff --git a/scripts/run_with_node_options.js b/scripts/run_with_node_options.js deleted file mode 100644 index a51d00b398eb0..0000000000000 --- a/scripts/run_with_node_options.js +++ /dev/null @@ -1,21 +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. - */ - -require('../src/setup_node_env'); -require('../src/dev/run_with_node_options').runWithNodeOptionsCli(); diff --git a/bin/node_with_options.bat b/src/dev/node_with_options_bin_scripts/node_with_options.bat similarity index 93% rename from bin/node_with_options.bat rename to src/dev/node_with_options_bin_scripts/node_with_options.bat index 1bbdc46862c2b..d5af3e04c1eff 100755 --- a/bin/node_with_options.bat +++ b/src/dev/node_with_options_bin_scripts/node_with_options.bat @@ -3,7 +3,7 @@ SETLOCAL ENABLEDELAYEDEXPANSION set SCRIPT_DIR=%~dp0 -for %%I in ("%SCRIPT_DIR%..") do set DIR=%%~dpfI +for %%I in ("%SCRIPT_DIR%..\..\..") do set DIR=%%~dpfI set CONFIG_DIR=%KIBANA_PATH_CONF% If [%KIBANA_PATH_CONF%] == [] ( diff --git a/bin/node_with_options b/src/dev/node_with_options_bin_scripts/node_with_options.sh similarity index 91% rename from bin/node_with_options rename to src/dev/node_with_options_bin_scripts/node_with_options.sh index 84aa69ccd455d..e40ca84818194 100755 --- a/bin/node_with_options +++ b/src/dev/node_with_options_bin_scripts/node_with_options.sh @@ -1,7 +1,7 @@ #!/bin/sh SCRIPT=$0 -DIR="$(dirname "${SCRIPT}")/.." +DIR="$(dirname "${SCRIPT}")/../../.." CONFIG_DIR=${KIBANA_PATH_CONF:-"$DIR/config"} # Setup node dev options file to node.dev.options diff --git a/src/dev/run_with_node_options/index.js b/src/dev/run_with_node_options/index.js deleted file mode 100644 index 632efec002614..0000000000000 --- a/src/dev/run_with_node_options/index.js +++ /dev/null @@ -1,20 +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. - */ - -export { runWithNodeOptionsCli } from './run_with_node_options_cli'; diff --git a/src/dev/run_with_node_options/run_with_node_options.js b/src/dev/run_with_node_options/run_with_node_options.js deleted file mode 100644 index 03e9bb3959b1f..0000000000000 --- a/src/dev/run_with_node_options/run_with_node_options.js +++ /dev/null @@ -1,93 +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 execa from 'execa'; -import { existsSync, readFile } from 'fs'; -import { join } from 'path'; -import { promisify } from 'util'; -import { REPO_ROOT } from '../constants'; - -const readFileAsync = promisify(readFile); - -function removeComments(nodeOptionsFileStr) { - const commentsRegex = /(^#.*$)/gim; - let match = commentsRegex.exec(nodeOptionsFileStr); - let newString = nodeOptionsFileStr; - while (match != null) { - newString = newString.replace(match[1], ''); - match = commentsRegex.exec(nodeOptionsFileStr); - } - - return newString; -} - -function removeEmptyLines(nodeOptionsFileStr) { - const emptyLinesRegex = /(^\n)/gim; - return nodeOptionsFileStr.replace(emptyLinesRegex, ''); -} - -function getNodeOptionsStr(nodeOptionsFileStr) { - const fileParseRegex = /^((.+?)[=](.*))$/gim; - let matches = ''; - let match; - while ((match = fileParseRegex.exec(nodeOptionsFileStr)) !== null) { - matches += `${match[1].trim()}${matches ? ' ' : ''}`; - } - return matches; -} - -async function getNodeOptionsFromFile(filePath) { - if (!filePath || !existsSync(filePath)) { - return {}; - } - - const nodeOptionsFileStr = (await readFileAsync(filePath)).toString(); - const sanitizedNodeOptionsFileStr = removeEmptyLines(removeComments(nodeOptionsFileStr)); - const nodeOptionsStr = getNodeOptionsStr(sanitizedNodeOptionsFileStr); - - if (!nodeOptionsStr && !process.env.NODE_OPTIONS) { - return {}; - } - - const sanitizedNodeOptionsStr = nodeOptionsStr ? `${nodeOptionsStr} ` : ''; - - return { - NODE_OPTIONS: `${sanitizedNodeOptionsStr}${process.env.NODE_OPTIONS || ''}`, - }; -} - -async function runWithNodeOptions({ command }) { - if (!command) { - return; - } - - const nodeOptionsFromFile = await getNodeOptionsFromFile( - join(REPO_ROOT, 'config', 'node.dev.options') - ); - - const childEnv = Object.assign(process.env, nodeOptionsFromFile); - - await execa.command(command, { - shell: true, - stdio: 'inherit', - env: childEnv, - }); -} - -export { runWithNodeOptions }; diff --git a/src/dev/run_with_node_options/run_with_node_options_cli.js b/src/dev/run_with_node_options/run_with_node_options_cli.js deleted file mode 100644 index 38a0cca7dcbd9..0000000000000 --- a/src/dev/run_with_node_options/run_with_node_options_cli.js +++ /dev/null @@ -1,48 +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 { run } from '@kbn/dev-utils'; -import { runWithNodeOptions } from './run_with_node_options'; - -function runWithNodeOptionsCli() { - run( - async ({ flags: { command } }) => { - await runWithNodeOptions({ - command, - }); - }, - { - description: 'Simple CLI, useful for to run node with node options', - flags: { - default: { - command: '', - }, - string: ['command'], - alias: { - c: 'command', - }, - help: ` - --command Run a shell command using node.dev.options file - `, - }, - } - ); -} - -export { runWithNodeOptionsCli }; From 7100be06174cda53b14603e94ff6dd10560f6875 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Fri, 5 Jun 2020 01:39:21 +0100 Subject: [PATCH 15/29] chore(NA): increase default maxBuffer --- bin/node | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bin/node b/bin/node index f6e578bd7efdf..5b68e674add2a 100755 --- a/bin/node +++ b/bin/node @@ -24,15 +24,20 @@ const os = require('os'); const args = process.argv.slice(2); const stdio = [0, 1, 2]; +const maxBuffer = 100 * 1024 * 1024; if (os.platform() === 'win32') { execFileSync( `${__dirname}/../src/dev/node_with_options_bin_scripts/node_with_options.bat`, args, - { stdio } + { + maxBuffer, + stdio, + } ); } else { execFileSync(`${__dirname}/../src/dev/node_with_options_bin_scripts/node_with_options.sh`, args, { + maxBuffer, stdio, }); } From 65da39f9c9414c9b1fa0b84686ba8791b29862c3 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Fri, 5 Jun 2020 01:42:01 +0100 Subject: [PATCH 16/29] chore(NA): remove run with options script from package.json --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 1f9d29939a2b3..1201a1773e6cd 100644 --- a/package.json +++ b/package.json @@ -73,8 +73,7 @@ "backport-skip-ci": "backport --prDescription \"[skip-ci]\"", "storybook": "node scripts/storybook", "cover:report": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report --reporter=lcov && open ./target/coverage/report/lcov-report/index.html", - "cover:functional:merge": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report/functional --reporter=json-summary", - "runWithNodeOptions": "node scripts/run_with_node_options" + "cover:functional:merge": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report/functional --reporter=json-summary" }, "repository": { "type": "git", From a4ba6d764f7ae1e3f63d52d11a28707dee6dcfff Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Mon, 8 Jun 2020 22:17:27 +0100 Subject: [PATCH 17/29] chore(NA): include kbn-node script and underlying usage of it --- .eslintrc.js | 2 +- package.json | 60 ++++++------ .../src/kbn_node/get_node_bin_dir.ts | 35 +++++++ .../src/kbn_node/get_script_name.ts | 24 +++++ .../src/kbn_node/get_script_source.ts | 92 +++++++++++++++++++ .../src/kbn_node/register_kbn_node.ts | 52 +++++++++++ .../src/kbn_node/run_kbn_node.ts | 29 +++--- scripts/backport.js | 2 +- scripts/grunt.js | 20 ++++ scripts/kbn_node.js | 21 +++++ scripts/nyc.js | 20 ++++ scripts/register_kbn_node.js | 21 +++++ scripts/tsc.js | 20 ++++ scripts/typings_tester.js | 20 ++++ .../node_with_options.bat | 35 ------- .../node_with_options.sh | 15 --- x-pack/package.json | 18 ++-- x-pack/scripts/gulp.js | 7 ++ 18 files changed, 385 insertions(+), 108 deletions(-) create mode 100644 packages/kbn-dev-utils/src/kbn_node/get_node_bin_dir.ts create mode 100644 packages/kbn-dev-utils/src/kbn_node/get_script_name.ts create mode 100644 packages/kbn-dev-utils/src/kbn_node/get_script_source.ts create mode 100644 packages/kbn-dev-utils/src/kbn_node/register_kbn_node.ts rename bin/node => packages/kbn-dev-utils/src/kbn_node/run_kbn_node.ts (62%) mode change 100755 => 100644 create mode 100644 scripts/grunt.js create mode 100644 scripts/kbn_node.js create mode 100644 scripts/nyc.js create mode 100644 scripts/register_kbn_node.js create mode 100644 scripts/tsc.js create mode 100644 scripts/typings_tester.js delete mode 100755 src/dev/node_with_options_bin_scripts/node_with_options.bat delete mode 100755 src/dev/node_with_options_bin_scripts/node_with_options.sh create mode 100644 x-pack/scripts/gulp.js diff --git a/.eslintrc.js b/.eslintrc.js index f0b7d6864bef0..093426012ba4c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -164,7 +164,7 @@ module.exports = { * Files that require Elastic license headers instead of Apache 2.0 header */ { - files: ['x-pack/**/*.{js,ts,tsx}'], + files: ['x-pack/**/*.{js,ts,tsx}', 'x-pack/bin/node'], rules: { '@kbn/eslint/require-license-header': [ 'error', diff --git a/package.json b/package.json index 0873ab8c158e1..d7ad34c25eb77 100644 --- a/package.json +++ b/package.json @@ -39,41 +39,41 @@ "scripts": { "preinstall": "node ./preinstall_check", "kbn": "node scripts/kbn", - "es": "node scripts/es", - "test": "grunt test", - "test:karma": "grunt test:karma", - "test:karma:debug": "grunt test:karmaDebug", - "test:jest": "node scripts/jest", - "test:jest_integration": "node scripts/jest_integration", - "test:mocha": "node scripts/mocha", - "test:mocha:coverage": "grunt test:mochaCoverage", - "test:ftr": "node scripts/functional_tests", - "test:ftr:server": "node scripts/functional_tests_server", - "test:ftr:runner": "node scripts/functional_test_runner", - "test:coverage": "grunt test:coverage", - "typespec": "typings-tester --config x-pack/plugins/canvas/public/lib/aeroelastic/tsconfig.json x-pack/plugins/canvas/public/lib/aeroelastic/__fixtures__/typescript/typespec_tests.ts", - "checkLicenses": "node scripts/check_licenses --dev", - "build": "node scripts/build --all-platforms", - "start": "node scripts/kibana --dev", - "debug": "node --nolazy --inspect scripts/kibana --dev", - "debug-break": "node --nolazy --inspect-brk scripts/kibana --dev", + "es": "kbn-node scripts/es", + "test": "kbn-node scripts/grunt test", + "test:karma": "kbn-node scripts/grunt test:karma", + "test:karma:debug": "kbn-node scripts/grunt test:karmaDebug", + "test:jest": "kbn-node scripts/jest", + "test:jest_integration": "kbn-node scripts/jest_integration", + "test:mocha": "kbn-node scripts/mocha", + "test:mocha:coverage": "kbn-node scripts/grunt test:mochaCoverage", + "test:ftr": "kbn-node scripts/functional_tests", + "test:ftr:server": "kbn-node scripts/functional_tests_server", + "test:ftr:runner": "kbn-node scripts/functional_test_runner", + "test:coverage": "kbn-node scripts/grunt test:coverage", + "typespec": "kbn-node scripts/typings_tester --config x-pack/plugins/canvas/public/lib/aeroelastic/tsconfig.json x-pack/plugins/canvas/public/lib/aeroelastic/__fixtures__/typescript/typespec_tests.ts", + "checkLicenses": "kbn-node scripts/check_licenses --dev", + "build": "kbn-node scripts/build --all-platforms", + "start": "kbn-node scripts/kibana --dev", + "debug": "kbn-node --nolazy --inspect scripts/kibana --dev", + "debug-break": "kbn-node --nolazy --inspect-brk scripts/kibana --dev", "lint": "yarn run lint:es && yarn run lint:sass", - "lint:es": "node scripts/eslint", - "lint:sass": "node scripts/sasslint", - "makelogs": "node scripts/makelogs", + "lint:es": "kbn-node scripts/eslint", + "lint:sass": "kbn-node scripts/sasslint", + "makelogs": "kbn-node scripts/makelogs", "uiFramework:start": "cd packages/kbn-ui-framework && yarn docSiteStart", "uiFramework:build": "cd packages/kbn-ui-framework && yarn docSiteBuild", "uiFramework:createComponent": "cd packages/kbn-ui-framework && yarn createComponent", "uiFramework:documentComponent": "cd packages/kbn-ui-framework && yarn documentComponent", - "kbn:watch": "node scripts/kibana --dev --logging.json=false", - "build:types": "tsc --p tsconfig.types.json", - "docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept", - "kbn:bootstrap": "node scripts/register_git_hook", - "spec_to_console": "node scripts/spec_to_console", - "backport-skip-ci": "backport --prDescription \"[skip-ci]\"", - "storybook": "node scripts/storybook", - "cover:report": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report --reporter=lcov && open ./target/coverage/report/lcov-report/index.html", - "cover:functional:merge": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report/functional --reporter=json-summary" + "kbn:watch": "kbn-node scripts/kibana --dev --logging.json=false", + "build:types": "kbn-node scripts/tsc --p tsconfig.types.json", + "docs:acceptApiChanges": "kbn-node scripts/check_published_api_changes.js --accept", + "kbn:bootstrap": "node scripts/register_git_hook && node scripts/register_kbn_node", + "spec_to_console": "kbn-node scripts/spec_to_console", + "backport-skip-ci": "kbn-node scripts/backport --prDescription \"[skip-ci]\"", + "storybook": "kbn-node scripts/storybook", + "cover:report": "kbn-node scripts/nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report --reporter=lcov && open ./target/coverage/report/lcov-report/index.html", + "cover:functional:merge": "kbn-node scripts/nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report/functional --reporter=json-summary" }, "repository": { "type": "git", diff --git a/packages/kbn-dev-utils/src/kbn_node/get_node_bin_dir.ts b/packages/kbn-dev-utils/src/kbn_node/get_node_bin_dir.ts new file mode 100644 index 0000000000000..9a6622718487f --- /dev/null +++ b/packages/kbn-dev-utils/src/kbn_node/get_node_bin_dir.ts @@ -0,0 +1,35 @@ +/* + * 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 execa from 'execa'; +import { platform } from 'os'; +import { resolve } from 'path'; +import { REPO_ROOT } from '../repo_root'; + +// Retrieves the correct location for the current node installation dir +export function getNodeBinDir() { + const nixPrefix = 'bin'; + const nodeDir = execa + .sync('npm', ['config', 'get', 'prefix'], { + cwd: REPO_ROOT, + }) + .stdout.trim(); + + return platform() === 'win32' ? nodeDir : resolve(nodeDir, nixPrefix); +} diff --git a/packages/kbn-dev-utils/src/kbn_node/get_script_name.ts b/packages/kbn-dev-utils/src/kbn_node/get_script_name.ts new file mode 100644 index 0000000000000..240d7ac0e7402 --- /dev/null +++ b/packages/kbn-dev-utils/src/kbn_node/get_script_name.ts @@ -0,0 +1,24 @@ +/* + * 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 { platform } from 'os'; + +export function getScriptName() { + return platform() === 'win32' ? 'kbn-node.cmd' : 'kbn-node'; +} diff --git a/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts b/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts new file mode 100644 index 0000000000000..dc532894d35a5 --- /dev/null +++ b/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts @@ -0,0 +1,92 @@ +/* + * 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 { platform } from 'os'; +import { REPO_ROOT } from '../repo_root'; + +const SCRIPT_SOURCE_SH = `#!/bin/sh +# +# ** THIS IS AN AUTO-GENERATED FILE ** +# ** PLEASE DO NOT CHANGE IT MANUALLY ** +# +# GENERATED BY KIBANA \`node scripts/register_kbn_node\` +# IF YOU WANNA CHANGE SOMETHING IN THIS SCRIPT +# PLEASE RE-RUN 'yarn kbn bootstrap' or 'node scripts/register_kbn_node' + +DIR=${REPO_ROOT} +CONFIG_DIR=\${KIBANA_PATH_CONF:-"$DIR/config"} + +# Setup node dev options file to node.dev.options +NODE_DEV_OPTIONS_FILE=\${CONFIG_DIR}/node.dev.options + +# Fallback to node.ci.options in case node.dev.options not exists +if [ ! -f "$NODE_DEV_OPTIONS_FILE" ]; then + NODE_DEV_OPTIONS_FILE=\${CONFIG_DIR}/node.ci.options +fi + +NODE_OPTIONS="$(grep -v ^# < $NODE_DEV_OPTIONS_FILE | xargs) $NODE_OPTIONS" exec "node" \${@} +`; + +const SCRIPT_SOURCE_CMD = `:: +:: ** THIS IS AN AUTO-GENERATED FILE ** +:: ** PLEASE DO NOT CHANGE IT MANUALLY ** +:: +:: GENERATED BY KIBANA \`node scripts/register_kbn_node\` +:: IF YOU WANNA CHANGE SOMETHING IN THIS SCRIPT +:: PLEASE RE-RUN 'yarn kbn bootstrap' or 'node scripts/register_kbn_node' + +@echo off + +SETLOCAL ENABLEDELAYEDEXPANSION + +set DIR=${REPO_ROOT} + +set CONFIG_DIR=%KIBANA_PATH_CONF% +If [%KIBANA_PATH_CONF%] == [] ( + set CONFIG_DIR=%DIR%config +) + +:: Setup node dev options file to node.dev.options +set NODE_DEV_OPTIONS_FILE=%CONFIG_DIR%\\node.dev.options + +:: Fallback to node.ci.options in case node.dev.options not exists +If not exist "%NODE_DEV_OPTIONS_FILE%" ( + set NODE_DEV_OPTIONS_FILE=%CONFIG_DIR%\\node.ci.options +) + +for /F "eol=# tokens=*" %%i in (%NODE_DEV_OPTIONS_FILE%) do ( + If [!NODE_OPTIONS!] == [] ( + set "NODE_OPTIONS=%%i" + )Else ( + set "NODE_OPTIONS=!NODE_OPTIONS! %%i" + ) +) + +:: This should run independently as the last instruction +:: as we need NODE_OPTIONS previously set to expand +node %* + +:finally + +ENDLOCAL +`; + +export function getScriptSource() { + return platform() === 'win32' ? SCRIPT_SOURCE_CMD : SCRIPT_SOURCE_SH; +} diff --git a/packages/kbn-dev-utils/src/kbn_node/register_kbn_node.ts b/packages/kbn-dev-utils/src/kbn_node/register_kbn_node.ts new file mode 100644 index 0000000000000..f6e2557f65366 --- /dev/null +++ b/packages/kbn-dev-utils/src/kbn_node/register_kbn_node.ts @@ -0,0 +1,52 @@ +/* + * 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 { chmod, writeFile } from 'fs'; +import { resolve } from 'path'; +import { promisify } from 'util'; + +import { run } from '../run'; +import { getNodeBinDir } from './get_node_bin_dir'; +import { getScriptName } from './get_script_name'; +import { getScriptSource } from './get_script_source'; + +const chmodAsync = promisify(chmod); +const writeFileAsync = promisify(writeFile); + +run( + async ({ log }) => { + try { + const nodeDir = getNodeBinDir(); + const scriptName = getScriptName(); + const scriptSource = getScriptSource(); + const installPath = resolve(nodeDir, scriptName); + + log.info(`Registering kbn-node bin scripts...`); + await writeFileAsync(installPath, scriptSource); + await chmodAsync(installPath, 0o755); + log.success(`Kbn-node bin script was installed successfully.`); + } catch (e) { + log.error(`Kbn-node bin script was not installed as an error occur.`); + throw e; + } + }, + { + description: 'Register kbn-node bin script', + } +); diff --git a/bin/node b/packages/kbn-dev-utils/src/kbn_node/run_kbn_node.ts old mode 100755 new mode 100644 similarity index 62% rename from bin/node rename to packages/kbn-dev-utils/src/kbn_node/run_kbn_node.ts index 5b68e674add2a..94d001f0593b2 --- a/bin/node +++ b/packages/kbn-dev-utils/src/kbn_node/run_kbn_node.ts @@ -1,5 +1,3 @@ -#!/usr/bin/env node - /* * Licensed to Elasticsearch B.V. under one or more contributor * license agreements. See the NOTICE file distributed with @@ -19,25 +17,22 @@ * under the License. */ -const { execFileSync } = require('child_process'); -const os = require('os'); +import { execFileSync } from 'child_process'; +import { existsSync } from 'fs'; +import { resolve } from 'path'; +import { getNodeBinDir } from './get_node_bin_dir'; +import { getScriptName } from './get_script_name'; const args = process.argv.slice(2); const stdio = [0, 1, 2]; const maxBuffer = 100 * 1024 * 1024; +const nodeDir = getNodeBinDir(); +const scriptName = getScriptName(); -if (os.platform() === 'win32') { - execFileSync( - `${__dirname}/../src/dev/node_with_options_bin_scripts/node_with_options.bat`, - args, - { - maxBuffer, - stdio, - } - ); +if (existsSync(resolve(nodeDir, scriptName))) { + execFileSync(`${resolve(nodeDir, scriptName)}`, args, { maxBuffer, stdio }); } else { - execFileSync(`${__dirname}/../src/dev/node_with_options_bin_scripts/node_with_options.sh`, args, { - maxBuffer, - stdio, - }); + throw new Error( + `Kbn-node bin script is not installed. Please run 'yarn kbn bootstrap' or 'node scripts/register_kbn_node' and then retry.` + ); } diff --git a/scripts/backport.js b/scripts/backport.js index 64cd5721834ea..3c2a12217a315 100644 --- a/scripts/backport.js +++ b/scripts/backport.js @@ -18,4 +18,4 @@ */ require('../src/setup_node_env/node_version_validator'); -require('backport'); +require('../node_modules/.bin/backport'); diff --git a/scripts/grunt.js b/scripts/grunt.js new file mode 100644 index 0000000000000..4afae26fd929f --- /dev/null +++ b/scripts/grunt.js @@ -0,0 +1,20 @@ +/* + * 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. + */ + +require('../node_modules/.bin/grunt'); diff --git a/scripts/kbn_node.js b/scripts/kbn_node.js new file mode 100644 index 0000000000000..7320134023b61 --- /dev/null +++ b/scripts/kbn_node.js @@ -0,0 +1,21 @@ +/* + * 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. + */ + +require('../src/setup_node_env/prebuilt_dev_only_entry'); +require('@kbn/dev-utils/target/kbn_node/run_kbn_node'); diff --git a/scripts/nyc.js b/scripts/nyc.js new file mode 100644 index 0000000000000..85ba548584445 --- /dev/null +++ b/scripts/nyc.js @@ -0,0 +1,20 @@ +/* + * 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. + */ + +require('../node_modules/.bin/nyc'); diff --git a/scripts/register_kbn_node.js b/scripts/register_kbn_node.js new file mode 100644 index 0000000000000..b10b19ed1b696 --- /dev/null +++ b/scripts/register_kbn_node.js @@ -0,0 +1,21 @@ +/* + * 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. + */ + +require('../src/setup_node_env/prebuilt_dev_only_entry'); +require('@kbn/dev-utils/target/kbn_node/register_kbn_node'); diff --git a/scripts/tsc.js b/scripts/tsc.js new file mode 100644 index 0000000000000..319875c77115a --- /dev/null +++ b/scripts/tsc.js @@ -0,0 +1,20 @@ +/* + * 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. + */ + +require('../node_modules/.bin/tsc'); diff --git a/scripts/typings_tester.js b/scripts/typings_tester.js new file mode 100644 index 0000000000000..b9ba9d598a41d --- /dev/null +++ b/scripts/typings_tester.js @@ -0,0 +1,20 @@ +/* + * 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. + */ + +require('../node_modules/.bin/typings-tester'); diff --git a/src/dev/node_with_options_bin_scripts/node_with_options.bat b/src/dev/node_with_options_bin_scripts/node_with_options.bat deleted file mode 100755 index d5af3e04c1eff..0000000000000 --- a/src/dev/node_with_options_bin_scripts/node_with_options.bat +++ /dev/null @@ -1,35 +0,0 @@ -@echo off - -SETLOCAL ENABLEDELAYEDEXPANSION - -set SCRIPT_DIR=%~dp0 -for %%I in ("%SCRIPT_DIR%..\..\..") do set DIR=%%~dpfI - -set CONFIG_DIR=%KIBANA_PATH_CONF% -If [%KIBANA_PATH_CONF%] == [] ( - set CONFIG_DIR=%DIR%config -) - -:: Setup node dev options file to node.dev.options -set NODE_DEV_OPTIONS_FILE=%CONFIG_DIR%\node.dev.options - -:: Fallback to node.ci.options in case node.dev.options not exists -If not exist "%NODE_DEV_OPTIONS_FILE%" ( - set NODE_DEV_OPTIONS_FILE=%CONFIG_DIR%\node.ci.options -) - -for /F "eol=# tokens=*" %%i in (%NODE_DEV_OPTIONS_FILE%) do ( - If [!NODE_OPTIONS!] == [] ( - set "NODE_OPTIONS=%%i" - ) Else ( - set "NODE_OPTIONS=!NODE_OPTIONS! %%i" - ) -) - -:: This should run independently as the last instruction -:: as we need NODE_OPTIONS previously set to expand -node %* - -:finally - -ENDLOCAL diff --git a/src/dev/node_with_options_bin_scripts/node_with_options.sh b/src/dev/node_with_options_bin_scripts/node_with_options.sh deleted file mode 100755 index e40ca84818194..0000000000000 --- a/src/dev/node_with_options_bin_scripts/node_with_options.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -SCRIPT=$0 -DIR="$(dirname "${SCRIPT}")/../../.." -CONFIG_DIR=${KIBANA_PATH_CONF:-"$DIR/config"} - -# Setup node dev options file to node.dev.options -NODE_DEV_OPTIONS_FILE=${CONFIG_DIR}/node.dev.options - -# Fallback to node.ci.options in case node.dev.options not exists -if [ ! -f "$NODE_DEV_OPTIONS_FILE" ]; then - NODE_DEV_OPTIONS_FILE=${CONFIG_DIR}/node.ci.options -fi - -NODE_OPTIONS="$(grep -v ^# < $NODE_DEV_OPTIONS_FILE | xargs) $NODE_OPTIONS" exec "node" ${@} diff --git a/x-pack/package.json b/x-pack/package.json index c46d364e0ac46..13dc170a7ea21 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -5,16 +5,16 @@ "private": true, "license": "Elastic-License", "scripts": { - "kbn": "node ../scripts/kbn", + "kbn": "kbn-node ../scripts/kbn", "kbn:bootstrap": "node plugins/canvas/scripts/storybook --clean", - "start": "gulp dev", - "build": "gulp build", - "testonly": "echo 'Deprecated, use `yarn test`' && gulp test", - "test": "gulp test", - "test:karma:debug": "gulp test:karma:debug", - "test:karma": "gulp test:karma", - "test:jest": "node scripts/jest", - "test:mocha": "node scripts/mocha" + "start": "kbn-node scripts/gulp dev", + "build": "kbn-node scripts/gulp build", + "testonly": "echo 'Deprecated, use `yarn test`' && yarn test", + "test": "kbn-node scripts/gulp test", + "test:karma:debug": "kbn-node scripts/gulp test:karma:debug", + "test:karma": "kbn-node scripts/gulp test:karma", + "test:jest": "kbn-node scripts/jest", + "test:mocha": "kbn-node scripts/mocha" }, "kibana": { "build": { diff --git a/x-pack/scripts/gulp.js b/x-pack/scripts/gulp.js new file mode 100644 index 0000000000000..48d62d37679ec --- /dev/null +++ b/x-pack/scripts/gulp.js @@ -0,0 +1,7 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +require('../node_modules/.bin/gulp'); From 838bacbaae89f46acc21f492d5ac1e42633ad8a5 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Tue, 9 Jun 2020 16:58:18 +0100 Subject: [PATCH 18/29] chore(NA): remove change on eslint --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 093426012ba4c..f0b7d6864bef0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -164,7 +164,7 @@ module.exports = { * Files that require Elastic license headers instead of Apache 2.0 header */ { - files: ['x-pack/**/*.{js,ts,tsx}', 'x-pack/bin/node'], + files: ['x-pack/**/*.{js,ts,tsx}'], rules: { '@kbn/eslint/require-license-header': [ 'error', From 6fa71ebd8f50bb026678a16a1dbd791df588bdc4 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Mon, 15 Jun 2020 15:37:05 +0100 Subject: [PATCH 19/29] chore(NA): correct typo on kbn node script comment Co-authored-by: Tyler Smalley --- packages/kbn-dev-utils/src/kbn_node/get_script_source.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts b/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts index dc532894d35a5..8a28b91f4a9c7 100644 --- a/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts +++ b/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts @@ -48,7 +48,7 @@ const SCRIPT_SOURCE_CMD = `:: :: ** PLEASE DO NOT CHANGE IT MANUALLY ** :: :: GENERATED BY KIBANA \`node scripts/register_kbn_node\` -:: IF YOU WANNA CHANGE SOMETHING IN THIS SCRIPT +:: IF YOU WANT TO CHANGE SOMETHING IN THIS SCRIPT :: PLEASE RE-RUN 'yarn kbn bootstrap' or 'node scripts/register_kbn_node' @echo off From 09823d47b9561914f86e93a780f092bcfc9790df Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Mon, 15 Jun 2020 15:37:42 +0100 Subject: [PATCH 20/29] chore(NA): correct typo on kbn node script comment Co-authored-by: Tyler Smalley --- packages/kbn-dev-utils/src/kbn_node/get_script_source.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts b/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts index 8a28b91f4a9c7..1e5871c3f3dab 100644 --- a/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts +++ b/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts @@ -26,7 +26,7 @@ const SCRIPT_SOURCE_SH = `#!/bin/sh # ** PLEASE DO NOT CHANGE IT MANUALLY ** # # GENERATED BY KIBANA \`node scripts/register_kbn_node\` -# IF YOU WANNA CHANGE SOMETHING IN THIS SCRIPT +# IF YOU WANT TO CHANGE SOMETHING IN THIS SCRIPT # PLEASE RE-RUN 'yarn kbn bootstrap' or 'node scripts/register_kbn_node' DIR=${REPO_ROOT} From 6a3a2cfc14b138b6e1fc129f8d7e75d152b12cdc Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Mon, 15 Jun 2020 15:41:14 +0100 Subject: [PATCH 21/29] chore(NA): add line to describe each option should be specified in a separated line --- config/node.ci.options | 1 + config/node.options | 1 + 2 files changed, 2 insertions(+) diff --git a/config/node.ci.options b/config/node.ci.options index c75aaaed7d9f2..3823763d1025b 100644 --- a/config/node.ci.options +++ b/config/node.ci.options @@ -1,5 +1,6 @@ ## Node command line options for CI ## See `node --help` and `node --v8-options` for available options +## Please note you should specify one option per line ## max size of old space in megabytes --max-old-space-size=4096 diff --git a/config/node.options b/config/node.options index 522f193d92fce..88ae1b2dc6ce1 100644 --- a/config/node.options +++ b/config/node.options @@ -1,5 +1,6 @@ ## Node command line options ## See `node --help` and `node --v8-options` for available options +## Please note you should specify one option per line ## max size of old space in megabytes #--max-old-space-size=512 From 075c459c851a2510150cc4be926f41c53109c906 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Sat, 20 Jun 2020 00:23:14 +0100 Subject: [PATCH 22/29] chore(NA): remove node options from dev and ci env --- .gitignore | 1 - config/node.ci.options | 6 -- package.json | 60 ++++++------ .../src/kbn_node/get_node_bin_dir.ts | 35 ------- .../src/kbn_node/get_script_name.ts | 24 ----- .../src/kbn_node/get_script_source.ts | 92 ------------------- .../src/kbn_node/register_kbn_node.ts | 52 ----------- .../src/kbn_node/run_kbn_node.ts | 38 -------- scripts/backport.js | 2 +- scripts/grunt.js | 20 ---- scripts/kbn_node.js | 21 ----- scripts/nyc.js | 20 ---- scripts/register_kbn_node.js | 21 ----- scripts/tsc.js | 20 ---- scripts/typings_tester.js | 20 ---- src/dev/ci_setup/setup_env.sh | 8 +- x-pack/package.json | 18 ++-- x-pack/scripts/gulp.js | 7 -- 18 files changed, 42 insertions(+), 423 deletions(-) delete mode 100644 config/node.ci.options delete mode 100644 packages/kbn-dev-utils/src/kbn_node/get_node_bin_dir.ts delete mode 100644 packages/kbn-dev-utils/src/kbn_node/get_script_name.ts delete mode 100644 packages/kbn-dev-utils/src/kbn_node/get_script_source.ts delete mode 100644 packages/kbn-dev-utils/src/kbn_node/register_kbn_node.ts delete mode 100644 packages/kbn-dev-utils/src/kbn_node/run_kbn_node.ts delete mode 100644 scripts/grunt.js delete mode 100644 scripts/kbn_node.js delete mode 100644 scripts/nyc.js delete mode 100644 scripts/register_kbn_node.js delete mode 100644 scripts/tsc.js delete mode 100644 scripts/typings_tester.js delete mode 100644 x-pack/scripts/gulp.js diff --git a/.gitignore b/.gitignore index dcc1fb6ee530f..8051f54af22de 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,6 @@ webpackstats.json /config/* !/config/kibana.yml !/config/node.options -!/config/node.ci.options coverage selenium .babel_register_cache.json diff --git a/config/node.ci.options b/config/node.ci.options deleted file mode 100644 index 3823763d1025b..0000000000000 --- a/config/node.ci.options +++ /dev/null @@ -1,6 +0,0 @@ -## Node command line options for CI -## See `node --help` and `node --v8-options` for available options -## Please note you should specify one option per line - -## max size of old space in megabytes ---max-old-space-size=4096 diff --git a/package.json b/package.json index 94be39af69250..6fdc43685f93a 100644 --- a/package.json +++ b/package.json @@ -39,41 +39,41 @@ "scripts": { "preinstall": "node ./preinstall_check", "kbn": "node scripts/kbn", - "es": "kbn-node scripts/es", - "test": "kbn-node scripts/grunt test", - "test:karma": "kbn-node scripts/grunt test:karma", - "test:karma:debug": "kbn-node scripts/grunt test:karmaDebug", - "test:jest": "kbn-node scripts/jest", - "test:jest_integration": "kbn-node scripts/jest_integration", - "test:mocha": "kbn-node scripts/mocha", - "test:mocha:coverage": "kbn-node scripts/grunt test:mochaCoverage", - "test:ftr": "kbn-node scripts/functional_tests", - "test:ftr:server": "kbn-node scripts/functional_tests_server", - "test:ftr:runner": "kbn-node scripts/functional_test_runner", - "test:coverage": "kbn-node scripts/grunt test:coverage", - "typespec": "kbn-node scripts/typings_tester --config x-pack/plugins/canvas/public/lib/aeroelastic/tsconfig.json x-pack/plugins/canvas/public/lib/aeroelastic/__fixtures__/typescript/typespec_tests.ts", - "checkLicenses": "kbn-node scripts/check_licenses --dev", - "build": "kbn-node scripts/build --all-platforms", - "start": "kbn-node scripts/kibana --dev", - "debug": "kbn-node --nolazy --inspect scripts/kibana --dev", - "debug-break": "kbn-node --nolazy --inspect-brk scripts/kibana --dev", + "es": "node scripts/es", + "test": "grunt test", + "test:karma": "grunt test:karma", + "test:karma:debug": "grunt test:karmaDebug", + "test:jest": "node scripts/jest", + "test:jest_integration": "node scripts/jest_integration", + "test:mocha": "node scripts/mocha", + "test:mocha:coverage": "grunt test:mochaCoverage", + "test:ftr": "node scripts/functional_tests", + "test:ftr:server": "node scripts/functional_tests_server", + "test:ftr:runner": "node scripts/functional_test_runner", + "test:coverage": "grunt test:coverage", + "typespec": "typings_tester --config x-pack/plugins/canvas/public/lib/aeroelastic/tsconfig.json x-pack/plugins/canvas/public/lib/aeroelastic/__fixtures__/typescript/typespec_tests.ts", + "checkLicenses": "node scripts/check_licenses --dev", + "build": "node scripts/build --all-platforms", + "start": "node scripts/kibana --dev", + "debug": "node --nolazy --inspect scripts/kibana --dev", + "debug-break": "node --nolazy --inspect-brk scripts/kibana --dev", "lint": "yarn run lint:es && yarn run lint:sass", - "lint:es": "kbn-node scripts/eslint", - "lint:sass": "kbn-node scripts/sasslint", - "makelogs": "kbn-node scripts/makelogs", + "lint:es": "node scripts/eslint", + "lint:sass": "node scripts/sasslint", + "makelogs": "node scripts/makelogs", "uiFramework:start": "cd packages/kbn-ui-framework && yarn docSiteStart", "uiFramework:build": "cd packages/kbn-ui-framework && yarn docSiteBuild", "uiFramework:createComponent": "cd packages/kbn-ui-framework && yarn createComponent", "uiFramework:documentComponent": "cd packages/kbn-ui-framework && yarn documentComponent", - "kbn:watch": "kbn-node scripts/kibana --dev --logging.json=false", - "build:types": "kbn-node scripts/tsc --p tsconfig.types.json", - "docs:acceptApiChanges": "kbn-node scripts/check_published_api_changes.js --accept", - "kbn:bootstrap": "node scripts/register_git_hook && node scripts/register_kbn_node", - "spec_to_console": "kbn-node scripts/spec_to_console", - "backport-skip-ci": "kbn-node scripts/backport --prDescription \"[skip-ci]\"", - "storybook": "kbn-node scripts/storybook", - "cover:report": "kbn-node scripts/nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report --reporter=lcov && open ./target/coverage/report/lcov-report/index.html", - "cover:functional:merge": "kbn-node scripts/nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report/functional --reporter=json-summary" + "kbn:watch": "node scripts/kibana --dev --logging.json=false", + "build:types": "tsc --p tsconfig.types.json", + "docs:acceptApiChanges": "node scripts/check_published_api_changes.js --accept", + "kbn:bootstrap": "node scripts/register_git_hook", + "spec_to_console": "node scripts/spec_to_console", + "backport-skip-ci": "backport --prDescription \"[skip-ci]\"", + "storybook": "node scripts/storybook", + "cover:report": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report --reporter=lcov && open ./target/coverage/report/lcov-report/index.html", + "cover:functional:merge": "nyc report --temp-dir target/kibana-coverage/functional --report-dir target/coverage/report/functional --reporter=json-summary" }, "repository": { "type": "git", diff --git a/packages/kbn-dev-utils/src/kbn_node/get_node_bin_dir.ts b/packages/kbn-dev-utils/src/kbn_node/get_node_bin_dir.ts deleted file mode 100644 index 9a6622718487f..0000000000000 --- a/packages/kbn-dev-utils/src/kbn_node/get_node_bin_dir.ts +++ /dev/null @@ -1,35 +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 execa from 'execa'; -import { platform } from 'os'; -import { resolve } from 'path'; -import { REPO_ROOT } from '../repo_root'; - -// Retrieves the correct location for the current node installation dir -export function getNodeBinDir() { - const nixPrefix = 'bin'; - const nodeDir = execa - .sync('npm', ['config', 'get', 'prefix'], { - cwd: REPO_ROOT, - }) - .stdout.trim(); - - return platform() === 'win32' ? nodeDir : resolve(nodeDir, nixPrefix); -} diff --git a/packages/kbn-dev-utils/src/kbn_node/get_script_name.ts b/packages/kbn-dev-utils/src/kbn_node/get_script_name.ts deleted file mode 100644 index 240d7ac0e7402..0000000000000 --- a/packages/kbn-dev-utils/src/kbn_node/get_script_name.ts +++ /dev/null @@ -1,24 +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 { platform } from 'os'; - -export function getScriptName() { - return platform() === 'win32' ? 'kbn-node.cmd' : 'kbn-node'; -} diff --git a/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts b/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts deleted file mode 100644 index 1e5871c3f3dab..0000000000000 --- a/packages/kbn-dev-utils/src/kbn_node/get_script_source.ts +++ /dev/null @@ -1,92 +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 { platform } from 'os'; -import { REPO_ROOT } from '../repo_root'; - -const SCRIPT_SOURCE_SH = `#!/bin/sh -# -# ** THIS IS AN AUTO-GENERATED FILE ** -# ** PLEASE DO NOT CHANGE IT MANUALLY ** -# -# GENERATED BY KIBANA \`node scripts/register_kbn_node\` -# IF YOU WANT TO CHANGE SOMETHING IN THIS SCRIPT -# PLEASE RE-RUN 'yarn kbn bootstrap' or 'node scripts/register_kbn_node' - -DIR=${REPO_ROOT} -CONFIG_DIR=\${KIBANA_PATH_CONF:-"$DIR/config"} - -# Setup node dev options file to node.dev.options -NODE_DEV_OPTIONS_FILE=\${CONFIG_DIR}/node.dev.options - -# Fallback to node.ci.options in case node.dev.options not exists -if [ ! -f "$NODE_DEV_OPTIONS_FILE" ]; then - NODE_DEV_OPTIONS_FILE=\${CONFIG_DIR}/node.ci.options -fi - -NODE_OPTIONS="$(grep -v ^# < $NODE_DEV_OPTIONS_FILE | xargs) $NODE_OPTIONS" exec "node" \${@} -`; - -const SCRIPT_SOURCE_CMD = `:: -:: ** THIS IS AN AUTO-GENERATED FILE ** -:: ** PLEASE DO NOT CHANGE IT MANUALLY ** -:: -:: GENERATED BY KIBANA \`node scripts/register_kbn_node\` -:: IF YOU WANT TO CHANGE SOMETHING IN THIS SCRIPT -:: PLEASE RE-RUN 'yarn kbn bootstrap' or 'node scripts/register_kbn_node' - -@echo off - -SETLOCAL ENABLEDELAYEDEXPANSION - -set DIR=${REPO_ROOT} - -set CONFIG_DIR=%KIBANA_PATH_CONF% -If [%KIBANA_PATH_CONF%] == [] ( - set CONFIG_DIR=%DIR%config -) - -:: Setup node dev options file to node.dev.options -set NODE_DEV_OPTIONS_FILE=%CONFIG_DIR%\\node.dev.options - -:: Fallback to node.ci.options in case node.dev.options not exists -If not exist "%NODE_DEV_OPTIONS_FILE%" ( - set NODE_DEV_OPTIONS_FILE=%CONFIG_DIR%\\node.ci.options -) - -for /F "eol=# tokens=*" %%i in (%NODE_DEV_OPTIONS_FILE%) do ( - If [!NODE_OPTIONS!] == [] ( - set "NODE_OPTIONS=%%i" - )Else ( - set "NODE_OPTIONS=!NODE_OPTIONS! %%i" - ) -) - -:: This should run independently as the last instruction -:: as we need NODE_OPTIONS previously set to expand -node %* - -:finally - -ENDLOCAL -`; - -export function getScriptSource() { - return platform() === 'win32' ? SCRIPT_SOURCE_CMD : SCRIPT_SOURCE_SH; -} diff --git a/packages/kbn-dev-utils/src/kbn_node/register_kbn_node.ts b/packages/kbn-dev-utils/src/kbn_node/register_kbn_node.ts deleted file mode 100644 index f6e2557f65366..0000000000000 --- a/packages/kbn-dev-utils/src/kbn_node/register_kbn_node.ts +++ /dev/null @@ -1,52 +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 { chmod, writeFile } from 'fs'; -import { resolve } from 'path'; -import { promisify } from 'util'; - -import { run } from '../run'; -import { getNodeBinDir } from './get_node_bin_dir'; -import { getScriptName } from './get_script_name'; -import { getScriptSource } from './get_script_source'; - -const chmodAsync = promisify(chmod); -const writeFileAsync = promisify(writeFile); - -run( - async ({ log }) => { - try { - const nodeDir = getNodeBinDir(); - const scriptName = getScriptName(); - const scriptSource = getScriptSource(); - const installPath = resolve(nodeDir, scriptName); - - log.info(`Registering kbn-node bin scripts...`); - await writeFileAsync(installPath, scriptSource); - await chmodAsync(installPath, 0o755); - log.success(`Kbn-node bin script was installed successfully.`); - } catch (e) { - log.error(`Kbn-node bin script was not installed as an error occur.`); - throw e; - } - }, - { - description: 'Register kbn-node bin script', - } -); diff --git a/packages/kbn-dev-utils/src/kbn_node/run_kbn_node.ts b/packages/kbn-dev-utils/src/kbn_node/run_kbn_node.ts deleted file mode 100644 index 94d001f0593b2..0000000000000 --- a/packages/kbn-dev-utils/src/kbn_node/run_kbn_node.ts +++ /dev/null @@ -1,38 +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 { execFileSync } from 'child_process'; -import { existsSync } from 'fs'; -import { resolve } from 'path'; -import { getNodeBinDir } from './get_node_bin_dir'; -import { getScriptName } from './get_script_name'; - -const args = process.argv.slice(2); -const stdio = [0, 1, 2]; -const maxBuffer = 100 * 1024 * 1024; -const nodeDir = getNodeBinDir(); -const scriptName = getScriptName(); - -if (existsSync(resolve(nodeDir, scriptName))) { - execFileSync(`${resolve(nodeDir, scriptName)}`, args, { maxBuffer, stdio }); -} else { - throw new Error( - `Kbn-node bin script is not installed. Please run 'yarn kbn bootstrap' or 'node scripts/register_kbn_node' and then retry.` - ); -} diff --git a/scripts/backport.js b/scripts/backport.js index 3c2a12217a315..64cd5721834ea 100644 --- a/scripts/backport.js +++ b/scripts/backport.js @@ -18,4 +18,4 @@ */ require('../src/setup_node_env/node_version_validator'); -require('../node_modules/.bin/backport'); +require('backport'); diff --git a/scripts/grunt.js b/scripts/grunt.js deleted file mode 100644 index 4afae26fd929f..0000000000000 --- a/scripts/grunt.js +++ /dev/null @@ -1,20 +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. - */ - -require('../node_modules/.bin/grunt'); diff --git a/scripts/kbn_node.js b/scripts/kbn_node.js deleted file mode 100644 index 7320134023b61..0000000000000 --- a/scripts/kbn_node.js +++ /dev/null @@ -1,21 +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. - */ - -require('../src/setup_node_env/prebuilt_dev_only_entry'); -require('@kbn/dev-utils/target/kbn_node/run_kbn_node'); diff --git a/scripts/nyc.js b/scripts/nyc.js deleted file mode 100644 index 85ba548584445..0000000000000 --- a/scripts/nyc.js +++ /dev/null @@ -1,20 +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. - */ - -require('../node_modules/.bin/nyc'); diff --git a/scripts/register_kbn_node.js b/scripts/register_kbn_node.js deleted file mode 100644 index b10b19ed1b696..0000000000000 --- a/scripts/register_kbn_node.js +++ /dev/null @@ -1,21 +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. - */ - -require('../src/setup_node_env/prebuilt_dev_only_entry'); -require('@kbn/dev-utils/target/kbn_node/register_kbn_node'); diff --git a/scripts/tsc.js b/scripts/tsc.js deleted file mode 100644 index 319875c77115a..0000000000000 --- a/scripts/tsc.js +++ /dev/null @@ -1,20 +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. - */ - -require('../node_modules/.bin/tsc'); diff --git a/scripts/typings_tester.js b/scripts/typings_tester.js deleted file mode 100644 index b9ba9d598a41d..0000000000000 --- a/scripts/typings_tester.js +++ /dev/null @@ -1,20 +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. - */ - -require('../node_modules/.bin/typings-tester'); diff --git a/src/dev/ci_setup/setup_env.sh b/src/dev/ci_setup/setup_env.sh index f7656dcef3a98..343ff47199375 100644 --- a/src/dev/ci_setup/setup_env.sh +++ b/src/dev/ci_setup/setup_env.sh @@ -14,6 +14,8 @@ cacheDir="$HOME/.kibana" RED='\033[0;31m' C_RESET='\033[0m' # Reset color +export NODE_OPTIONS="$NODE_OPTIONS --max-old-space-size=4096" + ### ### Since the Jenkins logging output collector doesn't look like a TTY ### Node/Chalk and other color libs disable their color output. But Jenkins @@ -51,12 +53,6 @@ export PARENT_DIR="$parentDir" kbnBranch="$(jq -r .branch "$KIBANA_DIR/package.json")" export KIBANA_PKG_BRANCH="$kbnBranch" -### -### Sets correct NODE_OPTIONS for CI -### -export KIBANA_CONFIG_DIR=${KIBANA_PATH_CONF:-"$KIBANA_DIR/config"} -export NODE_OPTIONS="$(grep -v ^# < ${KIBANA_CONFIG_DIR}/node.ci.options | xargs) $NODE_OPTIONS" - ### ### download node ### diff --git a/x-pack/package.json b/x-pack/package.json index 28a4a639bb568..2513a36f50014 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -5,16 +5,16 @@ "private": true, "license": "Elastic-License", "scripts": { - "kbn": "kbn-node ../scripts/kbn", + "kbn": "node ../scripts/kbn", "kbn:bootstrap": "node plugins/canvas/scripts/storybook --clean", - "start": "kbn-node scripts/gulp dev", - "build": "kbn-node scripts/gulp build", - "testonly": "echo 'Deprecated, use `yarn test`' && yarn test", - "test": "kbn-node scripts/gulp test", - "test:karma:debug": "kbn-node scripts/gulp test:karma:debug", - "test:karma": "kbn-node scripts/gulp test:karma", - "test:jest": "kbn-node scripts/jest", - "test:mocha": "kbn-node scripts/mocha" + "start": "gulp dev", + "build": "gulp build", + "testonly": "echo 'Deprecated, use `yarn test`' && gulp test", + "test": "gulp test", + "test:karma:debug": "gulp test:karma:debug", + "test:karma": "gulp test:karma", + "test:jest": "node scripts/jest", + "test:mocha": "node scripts/mocha" }, "kibana": { "build": { diff --git a/x-pack/scripts/gulp.js b/x-pack/scripts/gulp.js deleted file mode 100644 index 48d62d37679ec..0000000000000 --- a/x-pack/scripts/gulp.js +++ /dev/null @@ -1,7 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -require('../node_modules/.bin/gulp'); From c4f33100b0b1eef79bebec61d15f723a9c976875 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Sat, 20 Jun 2020 00:30:54 +0100 Subject: [PATCH 23/29] chore(NA): remove changes from package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f0c6ffeddfd8d..4ad97041e6e76 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "test:ftr:server": "node scripts/functional_tests_server", "test:ftr:runner": "node scripts/functional_test_runner", "test:coverage": "grunt test:coverage", - "typespec": "typings_tester --config x-pack/plugins/canvas/public/lib/aeroelastic/tsconfig.json x-pack/plugins/canvas/public/lib/aeroelastic/__fixtures__/typescript/typespec_tests.ts", + "typespec": "typings-tester --config x-pack/plugins/canvas/public/lib/aeroelastic/tsconfig.json x-pack/plugins/canvas/public/lib/aeroelastic/__fixtures__/typescript/typespec_tests.ts", "checkLicenses": "node scripts/check_licenses --dev", "build": "node scripts/build --all-platforms", "start": "node scripts/kibana --dev", @@ -67,7 +67,7 @@ "uiFramework:documentComponent": "cd packages/kbn-ui-framework && yarn documentComponent", "kbn:watch": "node scripts/kibana --dev --logging.json=false", "build:types": "tsc --p tsconfig.types.json", - "docs:acceptApiChanges": "node scripts/check_published_api_changes.js --accept", + "docs:acceptApiChanges": "node --max-old-space-size=6144 scripts/check_published_api_changes.js --accept", "kbn:bootstrap": "node scripts/register_git_hook", "spec_to_console": "node scripts/spec_to_console", "backport-skip-ci": "backport --prDescription \"[skip-ci]\"", From 372f3805c4e4ea3f3491134f350fa53d6ede0112 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Wed, 24 Jun 2020 03:31:01 +0100 Subject: [PATCH 24/29] chore(NA): fix docker image build --- .../docker_generator/templates/dockerfile.template.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.js b/src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.js index ba423b1b2f9e0..5832d00162b20 100755 --- a/src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.js +++ b/src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.js @@ -93,7 +93,6 @@ function generator({ # Set some Kibana configuration defaults. COPY --chown=1000:0 config/kibana.yml /usr/share/kibana/config/kibana.yml - COPY --chown=1000:0 config/node.options /usr/share/kibana/config/node.options # Add the launcher/wrapper script. It knows how to interpret environment # variables and translate them to Kibana CLI options. From 89460b0781f9ac51874f6890a792b472d9cdecd0 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 25 Jun 2020 03:39:02 +0100 Subject: [PATCH 25/29] chore(NA): change value for example of --max-old-space-size in the node.options file Co-authored-by: Tyler Smalley --- config/node.options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/node.options b/config/node.options index 88ae1b2dc6ce1..7854b8212320b 100644 --- a/config/node.options +++ b/config/node.options @@ -3,7 +3,7 @@ ## Please note you should specify one option per line ## max size of old space in megabytes -#--max-old-space-size=512 +#--max-old-space-size=4096 ## turn off warnings output --no-warnings From fc2af9967cd9f2a2cd4143b077de28ca1beefc8c Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 25 Jun 2020 14:19:18 +0100 Subject: [PATCH 26/29] chore(NA): remove --no-warnings from node.options and force it in the bin scripts --- config/node.options | 3 --- src/dev/build/tasks/bin/scripts/kibana | 2 +- src/dev/build/tasks/bin/scripts/kibana-plugin | 2 +- src/dev/build/tasks/bin/scripts/kibana-plugin.bat | 3 +++ src/dev/build/tasks/bin/scripts/kibana.bat | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/node.options b/config/node.options index 7854b8212320b..2927d1b576716 100644 --- a/config/node.options +++ b/config/node.options @@ -4,6 +4,3 @@ ## max size of old space in megabytes #--max-old-space-size=4096 - -## turn off warnings output ---no-warnings diff --git a/src/dev/build/tasks/bin/scripts/kibana b/src/dev/build/tasks/bin/scripts/kibana index f74dddc02b383..42e752ec82719 100755 --- a/src/dev/build/tasks/bin/scripts/kibana +++ b/src/dev/build/tasks/bin/scripts/kibana @@ -22,4 +22,4 @@ if [ ! -x "$NODE" ]; then exit 1 fi -NODE_OPTIONS="--max-http-header-size=65536 $(grep -v ^# < ${CONFIG_DIR}/node.options | xargs) $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli" ${@} +NODE_OPTIONS="--no-warnings --max-http-header-size=65536 $(grep -v ^# < ${CONFIG_DIR}/node.options | xargs) $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli" ${@} diff --git a/src/dev/build/tasks/bin/scripts/kibana-plugin b/src/dev/build/tasks/bin/scripts/kibana-plugin index 77ce39d48647c..e47a3d5c6f729 100755 --- a/src/dev/build/tasks/bin/scripts/kibana-plugin +++ b/src/dev/build/tasks/bin/scripts/kibana-plugin @@ -22,4 +22,4 @@ if [ ! -x "$NODE" ]; then exit 1 fi -NODE_OPTIONS="$(grep -v ^# < ${CONFIG_DIR}/node.options | xargs) $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli_plugin" "$@" +NODE_OPTIONS="--no-warnings $(grep -v ^# < ${CONFIG_DIR}/node.options | xargs) $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli_plugin" "$@" diff --git a/src/dev/build/tasks/bin/scripts/kibana-plugin.bat b/src/dev/build/tasks/bin/scripts/kibana-plugin.bat index 6f8fdb22dfe4a..f385903e1a582 100755 --- a/src/dev/build/tasks/bin/scripts/kibana-plugin.bat +++ b/src/dev/build/tasks/bin/scripts/kibana-plugin.bat @@ -26,6 +26,9 @@ for /F "eol=# tokens=*" %%i in (%CONFIG_DIR%\node.options) do ( ) ) +:: Include pre-defined node option +set "NODE_OPTIONS=--no-warnings %NODE_OPTIONS%" + TITLE Kibana Server "%NODE%" "%DIR%\src\cli_plugin" %* diff --git a/src/dev/build/tasks/bin/scripts/kibana.bat b/src/dev/build/tasks/bin/scripts/kibana.bat index 07f05ed88cc1b..93d4a1c70cd42 100755 --- a/src/dev/build/tasks/bin/scripts/kibana.bat +++ b/src/dev/build/tasks/bin/scripts/kibana.bat @@ -28,7 +28,7 @@ for /F "eol=# tokens=*" %%i in (%CONFIG_DIR%\node.options) do ( ) :: Include pre-defined node option -set "NODE_OPTIONS=--max-http-header-size=65536 %NODE_OPTIONS%" +set "NODE_OPTIONS=--no-warnings --max-http-header-size=65536 %NODE_OPTIONS%" :: This should run independently as the last instruction :: as we need NODE_OPTIONS previously set to expand From e2f13d68f3a5cd29032297c219167f9703737be8 Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 25 Jun 2020 15:27:53 +0100 Subject: [PATCH 27/29] chore(NA): prevent 'The system cannot find the file' error message --- src/dev/build/tasks/bin/scripts/kibana-keystore.bat | 12 +++++++----- src/dev/build/tasks/bin/scripts/kibana-plugin.bat | 12 +++++++----- src/dev/build/tasks/bin/scripts/kibana.bat | 12 +++++++----- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/dev/build/tasks/bin/scripts/kibana-keystore.bat b/src/dev/build/tasks/bin/scripts/kibana-keystore.bat index c2584a5626da0..4c31b24d8c865 100644 --- a/src/dev/build/tasks/bin/scripts/kibana-keystore.bat +++ b/src/dev/build/tasks/bin/scripts/kibana-keystore.bat @@ -17,11 +17,13 @@ If [%KIBANA_PATH_CONF%] == [] ( set CONFIG_DIR=%DIR%config ) -for /F "eol=# tokens=*" %%i in (%CONFIG_DIR%\node.options) do ( - If [!NODE_OPTIONS!] == [] ( - set "NODE_OPTIONS=%%i" - ) Else ( - set "NODE_OPTIONS=!NODE_OPTIONS! %%i" +IF EXIST "%CONFIG_DIR%\node.options" ( + for /F "eol=# tokens=*" %%i in (%CONFIG_DIR%\node.options) do ( + If [!NODE_OPTIONS!] == [] ( + set "NODE_OPTIONS=%%i" + ) Else ( + set "NODE_OPTIONS=!NODE_OPTIONS! %%i" + ) ) ) diff --git a/src/dev/build/tasks/bin/scripts/kibana-plugin.bat b/src/dev/build/tasks/bin/scripts/kibana-plugin.bat index f385903e1a582..e70f6ba28eadc 100755 --- a/src/dev/build/tasks/bin/scripts/kibana-plugin.bat +++ b/src/dev/build/tasks/bin/scripts/kibana-plugin.bat @@ -18,11 +18,13 @@ If [%KIBANA_PATH_CONF%] == [] ( set CONFIG_DIR=%DIR%config ) -for /F "eol=# tokens=*" %%i in (%CONFIG_DIR%\node.options) do ( - If [!NODE_OPTIONS!] == [] ( - set "NODE_OPTIONS=%%i" - ) Else ( - set "NODE_OPTIONS=!NODE_OPTIONS! %%i" +IF EXIST "%CONFIG_DIR%\node.options" ( + for /F "eol=# tokens=*" %%i in (%CONFIG_DIR%\node.options) do ( + If [!NODE_OPTIONS!] == [] ( + set "NODE_OPTIONS=%%i" + ) Else ( + set "NODE_OPTIONS=!NODE_OPTIONS! %%i" + ) ) ) diff --git a/src/dev/build/tasks/bin/scripts/kibana.bat b/src/dev/build/tasks/bin/scripts/kibana.bat index 93d4a1c70cd42..58f9bf2c434a9 100755 --- a/src/dev/build/tasks/bin/scripts/kibana.bat +++ b/src/dev/build/tasks/bin/scripts/kibana.bat @@ -19,11 +19,13 @@ If [%KIBANA_PATH_CONF%] == [] ( set CONFIG_DIR=%DIR%config ) -for /F "eol=# tokens=*" %%i in (%CONFIG_DIR%\node.options) do ( - If [!NODE_OPTIONS!] == [] ( - set "NODE_OPTIONS=%%i" - ) Else ( - set "NODE_OPTIONS=!NODE_OPTIONS! %%i" +IF EXIST "%CONFIG_DIR%\node.options" ( + for /F "eol=# tokens=*" %%i in (%CONFIG_DIR%\node.options) do ( + If [!NODE_OPTIONS!] == [] ( + set "NODE_OPTIONS=%%i" + ) Else ( + set "NODE_OPTIONS=!NODE_OPTIONS! %%i" + ) ) ) From 0f6d1ebbe6f642f0060339ab426e8ea6df9a8cec Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 25 Jun 2020 15:45:09 +0100 Subject: [PATCH 28/29] chore(NA): introduce slash when building path for %DIR% --- src/dev/build/tasks/bin/scripts/kibana-keystore.bat | 2 +- src/dev/build/tasks/bin/scripts/kibana-plugin.bat | 2 +- src/dev/build/tasks/bin/scripts/kibana.bat | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dev/build/tasks/bin/scripts/kibana-keystore.bat b/src/dev/build/tasks/bin/scripts/kibana-keystore.bat index 4c31b24d8c865..389eb5bf488e4 100644 --- a/src/dev/build/tasks/bin/scripts/kibana-keystore.bat +++ b/src/dev/build/tasks/bin/scripts/kibana-keystore.bat @@ -14,7 +14,7 @@ If Not Exist "%NODE%" ( set CONFIG_DIR=%KIBANA_PATH_CONF% If [%KIBANA_PATH_CONF%] == [] ( - set CONFIG_DIR=%DIR%config + set CONFIG_DIR=%DIR%\config ) IF EXIST "%CONFIG_DIR%\node.options" ( diff --git a/src/dev/build/tasks/bin/scripts/kibana-plugin.bat b/src/dev/build/tasks/bin/scripts/kibana-plugin.bat index e70f6ba28eadc..6815b1b9eab8c 100755 --- a/src/dev/build/tasks/bin/scripts/kibana-plugin.bat +++ b/src/dev/build/tasks/bin/scripts/kibana-plugin.bat @@ -15,7 +15,7 @@ If Not Exist "%NODE%" ( set CONFIG_DIR=%KIBANA_PATH_CONF% If [%KIBANA_PATH_CONF%] == [] ( - set CONFIG_DIR=%DIR%config + set CONFIG_DIR=%DIR%\config ) IF EXIST "%CONFIG_DIR%\node.options" ( diff --git a/src/dev/build/tasks/bin/scripts/kibana.bat b/src/dev/build/tasks/bin/scripts/kibana.bat index 58f9bf2c434a9..d3edc92f110a5 100755 --- a/src/dev/build/tasks/bin/scripts/kibana.bat +++ b/src/dev/build/tasks/bin/scripts/kibana.bat @@ -16,7 +16,7 @@ If Not Exist "%NODE%" ( set CONFIG_DIR=%KIBANA_PATH_CONF% If [%KIBANA_PATH_CONF%] == [] ( - set CONFIG_DIR=%DIR%config + set CONFIG_DIR=%DIR%\config ) IF EXIST "%CONFIG_DIR%\node.options" ( From a3b0f06c6a5983f85c4b545820bd2203e12cd46e Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Tue, 30 Jun 2020 00:44:36 +0100 Subject: [PATCH 29/29] chore(NA): read options from file only if it exists --- src/dev/build/tasks/bin/scripts/kibana | 6 +++++- src/dev/build/tasks/bin/scripts/kibana-keystore | 6 +++++- src/dev/build/tasks/bin/scripts/kibana-plugin | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/dev/build/tasks/bin/scripts/kibana b/src/dev/build/tasks/bin/scripts/kibana index 42e752ec82719..3283e17008e7c 100755 --- a/src/dev/build/tasks/bin/scripts/kibana +++ b/src/dev/build/tasks/bin/scripts/kibana @@ -22,4 +22,8 @@ if [ ! -x "$NODE" ]; then exit 1 fi -NODE_OPTIONS="--no-warnings --max-http-header-size=65536 $(grep -v ^# < ${CONFIG_DIR}/node.options | xargs) $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli" ${@} +if [ -f "${CONFIG_DIR}/node.options" ]; then + KBN_NODE_OPTS="$(grep -v ^# < ${CONFIG_DIR}/node.options | xargs)" +fi + +NODE_OPTIONS="--no-warnings --max-http-header-size=65536 $KBN_NODE_OPTS $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli" ${@} diff --git a/src/dev/build/tasks/bin/scripts/kibana-keystore b/src/dev/build/tasks/bin/scripts/kibana-keystore index 0aa9c8cafc607..f83df118d24e8 100755 --- a/src/dev/build/tasks/bin/scripts/kibana-keystore +++ b/src/dev/build/tasks/bin/scripts/kibana-keystore @@ -22,4 +22,8 @@ if [ ! -x "$NODE" ]; then exit 1 fi -NODE_OPTIONS="$(grep -v ^# < ${CONFIG_DIR}/node.options | xargs) $NODE_OPTIONS" "${NODE}" "${DIR}/src/cli_keystore" "$@" +if [ -f "${CONFIG_DIR}/node.options" ]; then + KBN_NODE_OPTS="$(grep -v ^# < ${CONFIG_DIR}/node.options | xargs)" +fi + +NODE_OPTIONS="$KBN_NODE_OPTS $NODE_OPTIONS" "${NODE}" "${DIR}/src/cli_keystore" "$@" diff --git a/src/dev/build/tasks/bin/scripts/kibana-plugin b/src/dev/build/tasks/bin/scripts/kibana-plugin index e47a3d5c6f729..f1102e1ef5a32 100755 --- a/src/dev/build/tasks/bin/scripts/kibana-plugin +++ b/src/dev/build/tasks/bin/scripts/kibana-plugin @@ -22,4 +22,8 @@ if [ ! -x "$NODE" ]; then exit 1 fi -NODE_OPTIONS="--no-warnings $(grep -v ^# < ${CONFIG_DIR}/node.options | xargs) $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli_plugin" "$@" +if [ -f "${CONFIG_DIR}/node.options" ]; then + KBN_NODE_OPTS="$(grep -v ^# < ${CONFIG_DIR}/node.options | xargs)" +fi + +NODE_OPTIONS="--no-warnings $KBN_NODE_OPTS $NODE_OPTIONS" NODE_ENV=production exec "${NODE}" "${DIR}/src/cli_plugin" "$@"