daa0f22587
* chore(NA): ensure scripts run with --preserve-symlinks * chore(NA): run webpack configs with symlinks: false * chore(NA): fix pkg json load on kbn test * chore(NA): add script into setup node env * chore(NA): fix kbn test for relative improt * chore(NA): fix change on docs * chore(NA): move ensure node preserve symlinks into setup node env * chore(NA): update changed docs * chore(NA): update jest unit test * chore(NA): fix wrapper script exit code * chore(NA): updated generated plugin list docs * fix(NA): make functional test runner use kbn utils repo_root * chore(NA): fix eslint imports * chore(NA): missing react correct config on eslint package * chore(NA): use correct value to make test pass locally * chore(NA): fix jest tests * chore(NA): try remove extra preserve symlinks * chore(NA): fix windows environment * chore(NA): fix kbn-optimizer to run with preserve-symlinks * chore(NA): fix integration jest test for kbn/optimizer * chore(NA): remove require.resolve from eslintrc.js * chore(NA): avoid load json file * chore(NA): move kbn/utils import into kbn/dev-utils * chore(NA): use correct dependencies on eslint config package Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
131 lines
3.5 KiB
TypeScript
131 lines
3.5 KiB
TypeScript
/*
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
* 2.0; you may not use this file except in compliance with the Elastic License
|
|
* 2.0.
|
|
*/
|
|
|
|
import execa from 'execa';
|
|
import { resolve } from 'path';
|
|
import { writeFileSync } from 'fs';
|
|
import { promisify } from 'util';
|
|
import { pipeline } from 'stream';
|
|
|
|
import { REPO_ROOT } from '@kbn/utils';
|
|
import { ToolingLog, transformFileStream, transformFileWithBabel } from '@kbn/dev-utils';
|
|
import gulp from 'gulp';
|
|
import del from 'del';
|
|
import fancyLog from 'fancy-log';
|
|
import chalk from 'chalk';
|
|
import vfs from 'vinyl-fs';
|
|
|
|
import { generateNoticeFromSource } from '../../src/dev/notice';
|
|
import { gitInfo } from './helpers/git_info';
|
|
import { PKG_NAME } from './helpers/pkg';
|
|
import { BUILD_VERSION } from './helpers/build_version';
|
|
|
|
const asyncPipeline = promisify(pipeline);
|
|
|
|
const XPACK_DIR = resolve(REPO_ROOT, 'x-pack');
|
|
const BUILD_DIR = resolve(XPACK_DIR, 'build');
|
|
const PLUGIN_BUILD_DIR = resolve(BUILD_DIR, 'plugin/kibana/x-pack');
|
|
|
|
async function cleanBuildTask() {
|
|
fancyLog('Deleting', BUILD_DIR);
|
|
await del(BUILD_DIR);
|
|
|
|
fancyLog('[canvas] Deleting Shareable Runtime');
|
|
await del(resolve(XPACK_DIR, 'plugins/canvas/shareable_runtime/build'));
|
|
}
|
|
|
|
async function reportTask() {
|
|
const info = await gitInfo();
|
|
|
|
fancyLog('Package Name', chalk.yellow(PKG_NAME));
|
|
fancyLog('Version', chalk.yellow(BUILD_VERSION));
|
|
fancyLog('Build Number', chalk.yellow(`${info.number}`));
|
|
fancyLog('Build SHA', chalk.yellow(info.sha));
|
|
}
|
|
|
|
async function copySourceAndBabelify() {
|
|
// copy source files and apply some babel transformations in the process
|
|
await asyncPipeline(
|
|
vfs.src(
|
|
[
|
|
'LICENSE.txt',
|
|
'NOTICE.txt',
|
|
'package.json',
|
|
'yarn.lock',
|
|
'tsconfig.json',
|
|
'index.js',
|
|
'.i18nrc.json',
|
|
'plugins/**/*',
|
|
'plugins/reporting/.phantom/*',
|
|
'plugins/reporting/.chromium/*',
|
|
'typings/**/*',
|
|
],
|
|
{
|
|
cwd: XPACK_DIR,
|
|
base: XPACK_DIR,
|
|
buffer: true,
|
|
nodir: true,
|
|
ignore: [
|
|
'**/README.md',
|
|
'**/*.{test,test.mocks,mock,mocks}.*',
|
|
'**/*.d.ts',
|
|
'**/node_modules/**',
|
|
'**/public/**/*.{js,ts,tsx,json}',
|
|
'**/{__tests__,__mocks__,__snapshots__}/**',
|
|
'plugins/canvas/shareable_runtime/test/**',
|
|
'plugins/telemetry_collection_xpack/schema/**', // Skip telemetry schemas
|
|
],
|
|
allowEmpty: true,
|
|
}
|
|
),
|
|
|
|
transformFileStream(async (file) => {
|
|
if (['.js', '.ts', '.tsx'].includes(file.extname)) {
|
|
await transformFileWithBabel(file);
|
|
}
|
|
}),
|
|
|
|
vfs.dest(PLUGIN_BUILD_DIR)
|
|
);
|
|
}
|
|
|
|
async function buildCanvasShareableRuntime() {
|
|
await execa(
|
|
process.execPath,
|
|
['--preserve-symlinks', 'plugins/canvas/scripts/shareable_runtime'],
|
|
{
|
|
cwd: XPACK_DIR,
|
|
stdio: ['ignore', 'inherit', 'inherit'],
|
|
// @ts-ignore Incorrect @types - execa supports `buffer`
|
|
buffer: false,
|
|
}
|
|
);
|
|
}
|
|
|
|
async function generateNoticeText() {
|
|
const log = new ToolingLog({
|
|
level: 'info',
|
|
writeTo: process.stdout,
|
|
});
|
|
|
|
writeFileSync(
|
|
resolve(PLUGIN_BUILD_DIR, 'NOTICE.txt'),
|
|
await generateNoticeFromSource({
|
|
productName: 'Kibana X-Pack',
|
|
log,
|
|
directory: PLUGIN_BUILD_DIR,
|
|
})
|
|
);
|
|
}
|
|
|
|
export const buildTask = gulp.series(
|
|
cleanBuildTask,
|
|
reportTask,
|
|
buildCanvasShareableRuntime,
|
|
copySourceAndBabelify,
|
|
generateNoticeText
|
|
);
|