diff --git a/.ci/Jenkinsfile_coverage b/.ci/Jenkinsfile_coverage index 0688cdd5e6859..3d289cadb3f84 100644 --- a/.ci/Jenkinsfile_coverage +++ b/.ci/Jenkinsfile_coverage @@ -85,7 +85,9 @@ stage("Kibana Pipeline") { // This stage is just here to help the BlueOcean UI a # Check my work :) cat src/dev/code_coverage/shell_scripts/bootstrapped.txt - node src/dev/code_coverage/node_scripts/cc_app_bootstrap/index.js ${BUILD_NUMBER} src/dev/code_coverage/shell_scripts/bootstrapped.txt + node src/dev/code_coverage/node_scripts/cc_app_bootstrap/index.js ${BUILD_NUMBER} \ +src/dev/code_coverage/shell_scripts/bootstrapped.txt \ +src/dev/code_coverage/cc_app/public/initial_data.js """, diff --git a/src/dev/code_coverage/node_scripts/cc_app_bootstrap/bootstrap_app_initial_data.js b/src/dev/code_coverage/node_scripts/cc_app_bootstrap/bootstrap_app_initial_data.js index c182926ad889d..72d4d0b55ab55 100644 --- a/src/dev/code_coverage/node_scripts/cc_app_bootstrap/bootstrap_app_initial_data.js +++ b/src/dev/code_coverage/node_scripts/cc_app_bootstrap/bootstrap_app_initial_data.js @@ -18,16 +18,13 @@ */ import { run } from '@kbn/dev-utils'; +import { parseAndPopulate } from './parse_and_populate'; const description = 'Populate the initial data for the code coverage static site.'; -const exec = buildNumber => outFile => ({ log }) => { - log.info(`### Job Num: ${buildNumber}`); - log.info(`### Dat file: ${outFile}`); - // Parse it - // Populate cc_app/public/inital_data.js +const exec = buildNumber => srcFile => destFile => ({ log }) => + parseAndPopulate(buildNumber)(srcFile)(destFile)(log); -}; -export const populate = (buildNumber, outFile) => - run(exec(buildNumber)(outFile), { description }); +export const populate = (buildNumber, srcFile, destFile) => + run(exec(buildNumber)(srcFile)(destFile), { description }); diff --git a/src/dev/code_coverage/node_scripts/cc_app_bootstrap/index.js b/src/dev/code_coverage/node_scripts/cc_app_bootstrap/index.js index 7b653d058c807..9e0285bcdde87 100644 --- a/src/dev/code_coverage/node_scripts/cc_app_bootstrap/index.js +++ b/src/dev/code_coverage/node_scripts/cc_app_bootstrap/index.js @@ -1,5 +1,5 @@ require('../../../../../src/setup_node_env'); -const [ , , buildNumber, outFile ] = process.argv; +const [ , , buildNumber, srcFile, destFile ] = process.argv; -require('./bootstrap_app_initial_data').populate(buildNumber, outFile); +require('./bootstrap_app_initial_data').populate(buildNumber, srcFile, destFile); diff --git a/src/dev/code_coverage/node_scripts/cc_app_bootstrap/parse_and_populate.js b/src/dev/code_coverage/node_scripts/cc_app_bootstrap/parse_and_populate.js new file mode 100644 index 0000000000000..66410a19e575b --- /dev/null +++ b/src/dev/code_coverage/node_scripts/cc_app_bootstrap/parse_and_populate.js @@ -0,0 +1,58 @@ +/* + * 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 * as Rx from 'rxjs'; +import * as readline from 'readline'; +import * as fs from 'fs'; +import { resolve } from 'path'; + + +const KIBANA_ROOT_PATH = '../../../../..'; +const KIBANA_ROOT = resolve(__dirname, KIBANA_ROOT_PATH); + +const resolvePaths = (...xs) => xs.map(x => resolve(KIBANA_ROOT, x)); + + +export const parseAndPopulate = buildNumber => srcFile => destFile => log => { + initPrint(buildNumber, srcFile, destFile)(log) + + const [resolvedSrcFile, resolvedDestFile] = resolvePaths(srcFile, destFile); + log.verbose(`\n### resolvedSrcFile: \n\t${resolvedSrcFile}`); + log.verbose(`\n### resolvedDestFile: \n\t${resolvedDestFile}`); + + // const input = fs.createReadStream(srcFile) + // const rl = readline.createInterface({ input }); + // + // + // const lines$ = Rx.Observable.fromEvent(rl, 'line') + // .takeUntil(Rx.Observable.fromEvent(rl, 'close')) + // .subscribe( + // console.log, + // err => console.log("Error: %s", err), + // () => console.log("Completed")); +}; + +function initPrint(...args) { + return function initPrintInner(log) { + log.verbose(`Job Num: ${args[0]}`); + log.verbose(`### Dat file: ${args[1]}`); + log.verbose(`### Dest file: ${args[2]}`); + } +} +