Skip to content

Commit

Permalink
Update gulp related packages (major) (#46665)
Browse files Browse the repository at this point in the history
* Update gulp related packages

* ts-ify and gulp4-ify x-pack tasks, remove unused canvas tasks

* remove unnecessary gulp.TaskFunction usage

* fix old references

* update renovate config

* move constants into helpers directory

* typo

* compact tasks a bit, remove unnecessary paths

* fix build directories

* deprecate testonly task

* rather than justifying an unjustifiable ts-ignore, ts-ify the imported module

* update renovate config

* update browser download tests to mock axios

* add root index.d.ts to tsconfig

* export BrowserType

* remove unnecessary `@ts-ignore`

* use consistent casing
  • Loading branch information
renovate[bot] authored and Spencer committed Oct 5, 2019
1 parent 8fcae77 commit 445fa43
Show file tree
Hide file tree
Showing 51 changed files with 844 additions and 1,112 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@
"@types/supertest": "^2.0.5",
"@types/type-detect": "^4.0.1",
"@types/uuid": "^3.4.4",
"@types/vinyl-fs": "^2.4.11",
"@types/zen-observable": "^0.8.0",
"@typescript-eslint/eslint-plugin": "1.13.0",
"@typescript-eslint/parser": "1.13.0",
Expand Down
26 changes: 26 additions & 0 deletions packages/kbn-plugin-helpers/lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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 function babelRegister(): void;
export function resolveKibanaPath(path: string): string;
export function readFtrConfigFile(path: string): any;
export function run(
task: 'build' | 'start' | 'testAll' | 'testBrowser' | 'testServer' | 'postinstall',
options: any
): Promise<void>;
2 changes: 1 addition & 1 deletion packages/kbn-plugin-helpers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"globby": "^8.0.1",
"gulp-babel": "^8.0.0",
"gulp-rename": "1.4.0",
"gulp-zip": "4.2.0",
"gulp-zip": "5.0.0",
"inquirer": "^1.2.2",
"minimatch": "^3.0.4",
"node-sass": "^4.9.4",
Expand Down
4 changes: 4 additions & 0 deletions packages/kbn-plugin-helpers/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../tsconfig.json",
"include": ["lib/index.d.ts"]
}
20 changes: 20 additions & 0 deletions packages/kbn-test/index.d.ts
Original file line number Diff line number Diff line change
@@ -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 * from './src/index';
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,28 @@
* under the License.
*/

// @ts-ignore not typed yet
export { runTestsCli, startServersCli } from './functional_tests/cli';

// @ts-ignore not typed yet
export { runTests, startServers } from './functional_tests/tasks';

// @ts-ignore not typed yet
export { OPTIMIZE_BUNDLE_DIR, KIBANA_ROOT } from './functional_tests/lib/paths';

// @ts-ignore not typed yet
export { esTestConfig, createEsTestCluster } from './es';

// @ts-ignore not typed yet
export { kbnTestConfig, kibanaServerTestUser, kibanaTestUser, adminTestUser } from './kbn';

// @ts-ignore not typed yet
export { setupUsers, DEFAULT_SUPERUSER_PASS } from './functional_tests/lib/auth';

// @ts-ignore not typed yet
export { readConfigFile } from './functional_test_runner/lib/config/read_config_file';

// @ts-ignore not typed yet
export { runFtrCli } from './functional_test_runner/cli';

export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@
* under the License.
*/

// @ts-ignore not typed yet
export { createAutoJUnitReporter } from './auto_junit_reporter';
// @ts-ignore not typed yet
export { setupJUnitReportGeneration } from './junit_report_generation';
// @ts-ignore not typed yet
export { runMochaCli } from './run_mocha_cli';
// @ts-ignore not typed yet
export { recordLog, snapshotLogsForRunnable } from './log_cache';
// @ts-ignore not typed yet
export { escapeCdata } from './xml';
4 changes: 2 additions & 2 deletions packages/kbn-test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "../../tsconfig.json",
"include": [
"types/**/*",
"src/functional_test_runner/**/*",
"src/mocha/xml.ts"
"src/**/*",
"index.d.ts"
]
}
24 changes: 24 additions & 0 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,14 @@
'@types/uuid',
],
},
{
groupSlug: 'vinyl-fs',
groupName: 'vinyl-fs related packages',
packageNames: [
'vinyl-fs',
'@types/vinyl-fs',
],
},
{
groupSlug: 'zen-observable',
groupName: 'zen-observable related packages',
Expand Down Expand Up @@ -639,6 +647,14 @@
'@types/color',
],
},
{
groupSlug: 'fancy-log',
groupName: 'fancy-log related packages',
packageNames: [
'fancy-log',
'@types/fancy-log',
],
},
{
groupSlug: 'file-saver',
groupName: 'file-saver related packages',
Expand All @@ -647,6 +663,14 @@
'@types/file-saver',
],
},
{
groupSlug: 'getos',
groupName: 'getos related packages',
packageNames: [
'getos',
'@types/getos',
],
},
{
groupSlug: 'git-url-parse',
groupName: 'git-url-parse related packages',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,30 @@
*/

import vfs from 'vinyl-fs';
import { ToolingLog } from '@kbn/dev-utils';

const NOTICE_COMMENT_RE = /\/\*[\s\n\*]*@notice([\w\W]+?)\*\//g;
const NEWLINE_RE = /\r?\n/g;

interface Options {
/**
* Name to print at the top of the notice
*/
productName: string;
/**
* absolute path to the repo to search for @notice comments
*/
directory: string;
log: ToolingLog;
}

/**
* Generates the text for the NOTICE.txt file at the root of the
* repo which details the licenses for code that is copied/vendored
* into the repository.
*
* @param {Object} options
* @property {string} options.productName Name to print at the top of the notice
* @property {ToolingLog} options.log
* @property {string} options.directory absolute path to the repo to search for @notice comments
* @return {string}
*/
export async function generateNoticeFromSource({ productName, directory, log }) {
const globs = [
'**/*.{js,less,css,ts}',
];
export async function generateNoticeFromSource({ productName, directory, log }: Options) {
const globs = ['**/*.{js,less,css,ts}'];

const options = {
cwd: directory,
Expand All @@ -46,18 +51,18 @@ export async function generateNoticeFromSource({ productName, directory, log })
'packages/*/{node_modules,build,target,dist}/**',
'x-pack/{node_modules,build,target,dist,data}/**',
'x-pack/packages/*/{node_modules,build,target,dist}/**',
]
],
};

log.debug('vfs.src globs', globs);
log.debug('vfs.src options', options);
log.info(`Searching ${directory} for multi-line comments starting with @notice`);

const files = vfs.src(globs, options);
const noticeComments = [];
const noticeComments: string[] = [];
await new Promise((resolve, reject) => {
files
.on('data', (file) => {
.on('data', file => {
log.verbose(`Checking for @notice comments in ${file.relative}`);

const source = file.contents.toString('utf8');
Expand All @@ -75,19 +80,19 @@ export async function generateNoticeFromSource({ productName, directory, log })

let noticeText = '';
noticeText += `${productName}\n`;
noticeText += `Copyright 2012-${(new Date()).getUTCFullYear()} Elasticsearch B.V.\n`;
noticeText += `Copyright 2012-${new Date().getUTCFullYear()} Elasticsearch B.V.\n`;

for (const comment of noticeComments.sort()) {
noticeText += '\n---\n';
noticeText += comment
.split(NEWLINE_RE)
.map(line => (
.map(line =>
line
// trim whitespace
.trim()
// trim leading * and a single space
.replace(/(^\* ?)/, '')
))
)
.join('\n')
.trim();
noticeText += '\n';
Expand Down
1 change: 1 addition & 0 deletions src/dev/notice/index.js → src/dev/notice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
*/

export { generateNoticeFromSource } from './generate_notice_from_source';
// @ts-ignore not typed yet
export { generateBuildNoticeText } from './generate_build_notice_text';
44 changes: 14 additions & 30 deletions x-pack/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,20 @@
* you may not use this file except in compliance with the Elastic License.
*/

require('@kbn/plugin-helpers').babelRegister();
require('dotenv').config({ silent: true });
require('../src/setup_node_env');

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 pkg = require('./package.json');
const { buildTask } = require('./tasks/build');
const { devTask } = require('./tasks/dev');
const { testTask, testBrowserTask, testBrowserDevTask, testServerTask } = require('./tasks/test');
const { prepareTask } = require('./tasks/prepare');

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,
coverageDir,
log: fancyLog,
mocha,
multiProcess,
packageDir,
pkg,
// export the tasks that are runnable from the CLI
module.exports = {
build: buildTask,
dev: devTask,
prepare: prepareTask,
test: testTask,
testserver: testServerTask,
testbrowser: testBrowserTask,
'testbrowser-dev': testBrowserDevTask,
};

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('./legacy/plugins/canvas/tasks')(gulp, gulpHelpers);
51 changes: 0 additions & 51 deletions x-pack/legacy/plugins/canvas/tasks/helpers/babelhook.js

This file was deleted.

23 changes: 0 additions & 23 deletions x-pack/legacy/plugins/canvas/tasks/helpers/dom_setup.js

This file was deleted.

10 changes: 0 additions & 10 deletions x-pack/legacy/plugins/canvas/tasks/helpers/enzyme_setup.js

This file was deleted.

Loading

0 comments on commit 445fa43

Please sign in to comment.