diff --git a/.eslintrc.js b/.eslintrc.js index 7834423f0ee1a89..4b7ea84daeda3f9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -17,6 +17,7 @@ module.exports = { // Enable Prettier { files: [ + 'packages/kbn-build/src/**/*.js', ], plugins: [ 'prettier', diff --git a/packages/kbn-build/src/cli.js b/packages/kbn-build/src/cli.js index bbf07152be016c2..27c6eea55e7a49b 100644 --- a/packages/kbn-build/src/cli.js +++ b/packages/kbn-build/src/cli.js @@ -45,8 +45,8 @@ export async function run(argv) { const options = getopts(argv, { alias: { - h: 'help' - } + h: 'help', + }, }); const args = options._; diff --git a/packages/kbn-build/src/production/__tests__/index.js b/packages/kbn-build/src/production/__tests__/index.js index c83089955de6fa9..f38fb1d7d0e638c 100644 --- a/packages/kbn-build/src/production/__tests__/index.js +++ b/packages/kbn-build/src/production/__tests__/index.js @@ -11,8 +11,8 @@ import { getProjects } from '../../utils/projects'; // and more integration-y, as we're trying to not add very slow tests to our // Jest unit tests. -describe('kbn-build production', function () { - it('builds and copies projects for production', async function () { +describe('kbn-build production', function() { + it('builds and copies projects for production', async function() { this.timeout(60 * 1000); const tmpDir = tempy.directory(); @@ -26,7 +26,7 @@ describe('kbn-build production', function () { cwd: fixturesPath, parents: true, nodir: true, - dot: true + dot: true, }); const projects = await getProjects(tmpDir, ['./packages/*']); @@ -34,14 +34,14 @@ describe('kbn-build production', function () { for (const project of projects.values()) { // This will both install dependencies and generate `yarn.lock` files await project.installDependencies({ - extraArgs: ['--silent', '--no-progress'] + extraArgs: ['--silent', '--no-progress'], }); } await buildProductionProjects({ kibanaRoot: tmpDir, buildRoot }); const files = await globby(['**/*', '!**/node_modules/**'], { - cwd: buildRoot + cwd: buildRoot, }); expect(files).to.eql([ @@ -52,7 +52,7 @@ describe('kbn-build production', function () { 'packages/foo/package.json', 'packages/foo/src/index.js', 'packages/foo/target/index.js', - 'packages/foo/yarn.lock' + 'packages/foo/yarn.lock', ]); }); }); diff --git a/packages/kbn-build/src/production/index.js b/packages/kbn-build/src/production/index.js index 3f4616f1603de39..bc069591e079e06 100644 --- a/packages/kbn-build/src/production/index.js +++ b/packages/kbn-build/src/production/index.js @@ -6,18 +6,18 @@ import { getProjectPaths } from '../config'; import { getProjects, buildProjectGraph, - topologicallyBatchProjects + topologicallyBatchProjects, } from '../utils/projects'; import { createProductionPackageJson, - writePackageJson + writePackageJson, } from '../utils/package_json'; import { isDirectory } from '../utils/fs'; export async function buildProductionProjects({ kibanaRoot, buildRoot }) { const projectPaths = getProjectPaths(kibanaRoot, { 'skip-kibana': true, - 'skip-kibana-extra': true + 'skip-kibana-extra': true, }); const projects = await getProductionProjects(kibanaRoot, projectPaths); @@ -81,7 +81,7 @@ async function copyToBuild(project, kibanaRoot, buildRoot) { cwd: project.path, parents: true, nodir: true, - dot: true + dot: true, }); const packageJson = project.json; diff --git a/packages/kbn-build/src/utils/child_process.js b/packages/kbn-build/src/utils/child_process.js index 2e9da91232c45d7..a9587d41a3b03db 100644 --- a/packages/kbn-build/src/utils/child_process.js +++ b/packages/kbn-build/src/utils/child_process.js @@ -16,7 +16,7 @@ function generateColors() { export function spawn(command, args, opts) { return execa(command, args, { ...opts, - stdio: 'inherit' + stdio: 'inherit', }); } @@ -25,14 +25,14 @@ const nextColor = generateColors(); export function spawnStreaming(command, args, opts, { prefix }) { const spawned = execa(command, args, { ...opts, - stdio: ['ignore', 'pipe', 'pipe'] + stdio: ['ignore', 'pipe', 'pipe'], }); const color = nextColor(); const prefixedStdout = logTransformer({ tag: `${color.bold(prefix)}:` }); const prefixedStderr = logTransformer({ tag: `${logSymbols.error} ${color.bold(prefix)}:`, - mergeMultiline: true + mergeMultiline: true, }); spawned.stdout.pipe(prefixedStdout).pipe(process.stdout); diff --git a/packages/kbn-build/src/utils/package_json.js b/packages/kbn-build/src/utils/package_json.js index 54fd06a51716b4a..cf094daba30f2f6 100644 --- a/packages/kbn-build/src/utils/package_json.js +++ b/packages/kbn-build/src/utils/package_json.js @@ -12,7 +12,7 @@ export function writePackageJson(path, json) { export const createProductionPackageJson = pkgJson => ({ ...pkgJson, - dependencies: transformDependencies(pkgJson.dependencies) + dependencies: transformDependencies(pkgJson.dependencies), }); /** diff --git a/packages/kbn-build/src/utils/project.js b/packages/kbn-build/src/utils/project.js index d7d4bd24a25ceb6..13cec4863ee50f2 100644 --- a/packages/kbn-build/src/utils/project.js +++ b/packages/kbn-build/src/utils/project.js @@ -4,7 +4,7 @@ import chalk from 'chalk'; import { installInDir, runScriptInPackage, - runScriptInPackageStreaming + runScriptInPackageStreaming, } from './scripts'; import { readPackageJson } from './package_json'; import { CliError } from './errors'; @@ -27,7 +27,7 @@ export class Project { this.allDependencies = { ...(this.json.devDependencies || {}), - ...(this.json.dependencies || {}) + ...(this.json.dependencies || {}), }; this.scripts = this.json.scripts || {}; @@ -53,7 +53,7 @@ export class Project { const meta = { package: `${this.name} (${this.packageJsonLocation})`, expected: `"${project.name}": "${expectedVersionInPackageJson}"`, - actual: `"${project.name}": "${versionInPackageJson}"` + actual: `"${project.name}": "${versionInPackageJson}"`, }; if (versionInPackageJson.startsWith(PREFIX)) { diff --git a/packages/kbn-build/src/utils/project.test.js b/packages/kbn-build/src/utils/project.test.js index 7a12e84da1ed61f..ddfb6288eeb38bf 100644 --- a/packages/kbn-build/src/utils/project.test.js +++ b/packages/kbn-build/src/utils/project.test.js @@ -9,7 +9,7 @@ const createProjectWith = (fields, path = '') => { name: 'kibana', version: '1.0.0', - ...fields + ...fields, }, join(rootPath, path) ); @@ -25,11 +25,11 @@ describe('fromPath', () => { test('fields', async () => { const kibana = createProjectWith({ scripts: { - test: 'jest' + test: 'jest', }, dependencies: { - foo: '1.2.3' - } + foo: '1.2.3', + }, }); expect(kibana.name).toBe('kibana'); @@ -45,13 +45,13 @@ describe('#ensureValidProjectDependency', () => { test('valid link: version', async () => { const root = createProjectWith({ dependencies: { - foo: 'link:packages/foo' - } + foo: 'link:packages/foo', + }, }); const foo = createProjectWith( { - name: 'foo' + name: 'foo', }, 'packages/foo' ); @@ -63,15 +63,15 @@ describe('#ensureValidProjectDependency', () => { const root = createProjectWith( { dependencies: { - foo: 'link:wrong/path' - } + foo: 'link:wrong/path', + }, }, rootPath ); const foo = createProjectWith( { - name: 'foo' + name: 'foo', }, 'packages/foo' ); @@ -85,15 +85,15 @@ describe('#ensureValidProjectDependency', () => { const root = createProjectWith( { dependencies: { - foo: '1.0.0' - } + foo: '1.0.0', + }, }, rootPath ); const foo = createProjectWith( { - name: 'foo' + name: 'foo', }, 'packages/foo' ); diff --git a/packages/kbn-build/src/utils/projects.js b/packages/kbn-build/src/utils/projects.js index 9a8bc67efa76e37..5cac3c36a5c4238 100644 --- a/packages/kbn-build/src/utils/projects.js +++ b/packages/kbn-build/src/utils/projects.js @@ -19,7 +19,7 @@ export async function getProjects(rootPath, projectsPaths) { // Do not match ** against multiple filenames // (This is only specified because we currently don't have a need for it.) - noglobstar: true + noglobstar: true, }; const projects = new Map(); @@ -36,7 +36,7 @@ export async function getProjects(rootPath, projectsPaths) { `There are multiple projects with the same name [${project.name}]`, { name: project.name, - paths: [project.path, projects.get(project.name).path] + paths: [project.path, projects.get(project.name).path], } ); } diff --git a/packages/kbn-build/src/utils/projects.test.js b/packages/kbn-build/src/utils/projects.test.js index d71effb40ae2593..06cbe5bf83f4d93 100644 --- a/packages/kbn-build/src/utils/projects.test.js +++ b/packages/kbn-build/src/utils/projects.test.js @@ -3,7 +3,7 @@ import { resolve } from 'path'; import { getProjects, buildProjectGraph, - topologicallyBatchProjects + topologicallyBatchProjects, } from './projects'; const rootPath = resolve(`${__dirname}/__fixtures__/kibana`); @@ -53,7 +53,7 @@ describe('#buildProjectGraph', () => { const projects = await getProjects(rootPath, [ '.', 'packages/*', - '../plugins/*' + '../plugins/*', ]); const graph = buildProjectGraph(projects); @@ -71,7 +71,7 @@ describe('#topologicallyBatchProjects', () => { const projects = await getProjects(rootPath, [ '.', 'packages/*', - '../plugins/*' + '../plugins/*', ]); const graph = buildProjectGraph(projects); diff --git a/packages/kbn-build/src/utils/scripts.js b/packages/kbn-build/src/utils/scripts.js index ad0c5ca6d2bcfd6..1afba5d0dcd81e8 100644 --- a/packages/kbn-build/src/utils/scripts.js +++ b/packages/kbn-build/src/utils/scripts.js @@ -9,13 +9,13 @@ export function installInDir(directory, extraArgs = []) { 'install', '--non-interactive', '--mutex file', - ...extraArgs + ...extraArgs, ]; // We pass the mutex flag to ensure only one instance of yarn runs at any // given time (e.g. to avoid conflicts). return spawn(yarnPath, options, { - cwd: directory + cwd: directory, }); } @@ -24,7 +24,7 @@ export function installInDir(directory, extraArgs = []) { */ export function runScriptInPackage(script, args, pkg) { const execOpts = { - cwd: pkg.path + cwd: pkg.path, }; return spawn(yarnPath, ['run', script, ...args], execOpts); @@ -35,10 +35,10 @@ export function runScriptInPackage(script, args, pkg) { */ export function runScriptInPackageStreaming(script, args, pkg) { const execOpts = { - cwd: pkg.path + cwd: pkg.path, }; return spawnStreaming(yarnPath, ['run', script, ...args], execOpts, { - prefix: pkg.name + prefix: pkg.name, }); }