Skip to content

Commit

Permalink
[npm] upgrade gulp to 4.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Jun 2, 2021
1 parent 7443e4d commit 1bf36e7
Show file tree
Hide file tree
Showing 11 changed files with 434 additions and 435 deletions.
33 changes: 2 additions & 31 deletions x-pack/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,6 @@
require('@kbn/plugin-helpers').babelRegister();
require('dotenv').config({ silent: true });

const path = require('path');
const gulp = require('gulp');
const mocha = require('gulp-mocha');
const multiProcess = require('gulp-multi-process');
const fancyLog = require('fancy-log');
const ansiColors = require('ansi-colors');
const pkg = require('./package.json');
const { tasks } = require('./tasks');

const buildDir = path.resolve(__dirname, 'build');
const buildTarget = path.resolve(buildDir, 'plugin');
const packageDir = path.resolve(buildDir, 'distributions');
const coverageDir = path.resolve(__dirname, 'coverage');

const gulpHelpers = {
buildDir,
buildTarget,
colors: ansiColors,
coverageDir,
log: fancyLog,
mocha,
multiProcess,
packageDir,
pkg,
};

require('./tasks/build')(gulp, gulpHelpers);
require('./tasks/clean')(gulp, gulpHelpers);
require('./tasks/dev')(gulp, gulpHelpers);
require('./tasks/prepare')(gulp, gulpHelpers);
require('./tasks/report')(gulp, gulpHelpers);
require('./tasks/test')(gulp, gulpHelpers);
require('./plugins/canvas/tasks')(gulp, gulpHelpers);
module.exports = tasks;
4 changes: 1 addition & 3 deletions x-pack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@
"graphql-codegen-introspection-template": "^0.13.0",
"graphql-codegen-typescript-resolvers-template": "^0.13.0",
"graphql-codegen-typescript-template": "^0.13.0",
"gulp": "3.9.1",
"gulp": "4.0.2",
"gulp-mocha": "2.2.0",
"gulp-multi-process": "^1.3.1",
"jest": "^23.6.0",
"jest-cli": "^23.6.0",
"jest-styled-components": "^6.2.2",
Expand All @@ -99,7 +98,6 @@
"react-test-renderer": "^16.2.0",
"redux-test-utils": "0.2.2",
"rsync": "0.4.0",
"run-sequence": "^2.2.1",
"sass-loader": "^7.1.0",
"simple-git": "1.37.0",
"sinon": "^5.0.7",
Expand Down
49 changes: 29 additions & 20 deletions x-pack/tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,39 @@

import { resolve } from 'path';
import { writeFileSync } from 'fs';
import gulp from 'gulp';
import pluginHelpers from '@kbn/plugin-helpers';
import { ToolingLog } from '@kbn/dev-utils';

import { generateNoticeFromSource } from '../../src/dev';

export default (gulp, { buildTarget }) => {
gulp.task('build', ['clean', 'report', 'prepare:build'], async () => {
await pluginHelpers.run('build', {
skipArchive: true,
buildDestination: buildTarget,
});
import { buildTarget } from './helpers/paths';
import { clean } from './clean';
import { report } from './report';
import { prepare } from './prepare';

const buildRoot = resolve(buildTarget, 'kibana/x-pack');
const log = new ToolingLog({
level: 'info',
writeTo: process.stdout
});
async function pluginHelpersBuild() {
await pluginHelpers.run('build', {
skipArchive: true,
buildDestination: buildTarget,
});
}

writeFileSync(
resolve(buildRoot, 'NOTICE.txt'),
await generateNoticeFromSource({
productName: 'Kibana X-Pack',
log,
directory: buildRoot
})
);
async function generateNotice() {
const buildRoot = resolve(buildTarget, 'kibana/x-pack');
const log = new ToolingLog({
level: 'info',
writeTo: process.stdout
});
};

writeFileSync(
resolve(buildRoot, 'NOTICE.txt'),
await generateNoticeFromSource({
productName: 'Kibana X-Pack',
log,
directory: buildRoot
})
);
}

export const build = gulp.series(gulp.parallel(clean, report, prepare), pluginHelpersBuild, generateNotice);
33 changes: 19 additions & 14 deletions x-pack/tasks/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,24 @@
* you may not use this file except in compliance with the Elastic License.
*/
import del from 'del';
import gulp from 'gulp';
import log from 'fancy-log';

export default (gulp, { coverageDir, buildDir, packageDir, log }) => {
gulp.task('clean-test', () => {
log('Deleting', coverageDir);
return del([coverageDir]);
});
import { coverageDir, buildDir, packageDir } from './helpers/paths';

gulp.task('clean', ['clean-test'], () => {
const toDelete = [
buildDir,
packageDir,
];
log('Deleting', toDelete.join(', '));
return del(toDelete);
});
};
export async function cleanTest() {
log('Deleting', coverageDir);
await del([coverageDir]);
}

async function cleanDist() {
const toDelete = [
buildDir,
packageDir,
];

log('Deleting', toDelete.join(', '));
await del(toDelete);
}

export const clean = gulp.series(cleanTest, cleanDist);
12 changes: 9 additions & 3 deletions x-pack/tasks/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
* you may not use this file except in compliance with the Elastic License.
*/

import gulp from 'gulp';
import pluginHelpers from '@kbn/plugin-helpers';

import getFlags from './helpers/get_flags';
import { prepare } from './prepare';

async function pluginHelpersStart() {
await pluginHelpers.run('start', { flags: getFlags() });
}

export const dev = gulp.series(prepare, pluginHelpersStart);

export default (gulp) => {
gulp.task('dev', ['prepare:dev'], () => pluginHelpers.run('start', { flags: getFlags() }));
};
13 changes: 13 additions & 0 deletions x-pack/tasks/helpers/paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* 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.
*/


import Path from 'path';

export const buildDir = Path.resolve(__dirname, '../../build');
export const buildTarget = Path.resolve(buildDir, 'plugin');
export const packageDir = Path.resolve(buildDir, 'distributions');
export const coverageDir = Path.resolve(__dirname, '../../coverage');
23 changes: 23 additions & 0 deletions x-pack/tasks/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.
*/


import { build } from './build';
import { clean, cleanTest } from './clean';
import { dev } from './dev';
import { test, testbrowser, testbrowserDev, testonly, testserver } from './test';

export const tasks = {
build,
clean,
'clean:test': cleanTest,
dev,
test,
testbrowser,
'testbrowser:dev': testbrowserDev,
testonly,
testserver,
};
13 changes: 3 additions & 10 deletions x-pack/tasks/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@

import { ensureAllBrowsersDownloaded } from '../plugins/reporting/server/browsers';

export default gulp => {
// anything that should always happen before anything else
gulp.task('prepare', () => ensureAllBrowsersDownloaded());

// anything that needs to happen before development
gulp.task('prepare:dev', ['prepare']);

// anything that needs to happen before building
gulp.task('prepare:build', ['prepare']);
};
export async function prepare() {
await ensureAllBrowsersDownloaded();
}
24 changes: 13 additions & 11 deletions x-pack/tasks/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@
* you may not use this file except in compliance with the Elastic License.
*/

import colors from 'ansi-colors';
import log from 'fancy-log';

import pkg from '../package.json';

import buildVersion from './helpers/build_version';
import gitInfo from './helpers/git_info';

export default (gulp, { log, colors, pkg }) => {
gulp.task('report', () => {
return gitInfo()
.then(function (info) {
log('Package Name', colors.yellow(pkg.name));
log('Version', colors.yellow(buildVersion(pkg)));
log('Build Number', colors.yellow(info.number));
log('Build SHA', colors.yellow(info.sha));
});
});
};
export async function report() {
const info = await gitInfo();

log('Package Name', colors.yellow(pkg.name));
log('Version', colors.yellow(buildVersion(pkg)));
log('Build Number', colors.yellow(info.number));
log('Build SHA', colors.yellow(info.sha));
}
58 changes: 28 additions & 30 deletions x-pack/tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
* you may not use this file except in compliance with the Elastic License.
*/

import runSequence from 'run-sequence';
import pluginHelpers from '@kbn/plugin-helpers';
import gulp from 'gulp';
import mocha from 'gulp-mocha';

import { createAutoJUnitReporter } from '../../src/dev';

import { getEnabledPlugins } from './helpers/get_plugins';
import { forPluginServerTests } from './helpers/globs';
import { createAutoJUnitReporter } from '../../src/dev';
import { cleanTest } from './clean';

const MOCHA_OPTIONS = {
ui: 'bdd',
Expand All @@ -17,38 +21,32 @@ const MOCHA_OPTIONS = {
}),
};

export default (gulp, { mocha }) => {
gulp.task('test', (cb) => {
const preTasks = ['clean-test'];
runSequence(preTasks, 'testserver', 'testbrowser', cb);
});
export function testserver() {
const globs = [
'common/**/__tests__/**/*.js',
'server/**/__tests__/**/*.js',
].concat(forPluginServerTests());

gulp.task('testonly', ['testserver', 'testbrowser']);
return gulp.src(globs, { read: false })
.pipe(mocha(MOCHA_OPTIONS));
}

gulp.task('testserver', () => {
const globs = [
'common/**/__tests__/**/*.js',
'server/**/__tests__/**/*.js',
].concat(forPluginServerTests());
export async function testbrowser() {
const plugins = await getEnabledPlugins();

return gulp.src(globs, { read: false })
.pipe(mocha(MOCHA_OPTIONS));
await pluginHelpers.run('testBrowser', {
plugins: plugins.join(','),
});
}

gulp.task('testbrowser', () => {
return getEnabledPlugins().then(plugins => {
return pluginHelpers.run('testBrowser', {
plugins: plugins.join(','),
});
});
});
export async function testbrowserDev() {
const plugins = await getEnabledPlugins();

gulp.task('testbrowser-dev', () => {
return getEnabledPlugins().then(plugins => {
return pluginHelpers.run('testBrowser', {
dev: true,
plugins: plugins.join(','),
});
});
await pluginHelpers.run('testBrowser', {
dev: true,
plugins: plugins.join(','),
});
};
}

export const testonly = gulp.series(testserver, testbrowser);
export const test = gulp.series(cleanTest, testserver, testbrowser);
Loading

0 comments on commit 1bf36e7

Please sign in to comment.