Skip to content

Commit

Permalink
Run Prettier on @kbn/build
Browse files Browse the repository at this point in the history
  • Loading branch information
kimjoar committed Feb 5, 2018
1 parent 0aedaa7 commit a68adaa
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 42 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
// Enable Prettier
{
files: [
'packages/kbn-build/src/**/*.js',
],
plugins: [
'prettier',
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-build/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export async function run(argv) {

const options = getopts(argv, {
alias: {
h: 'help'
}
h: 'help',
},
});

const args = options._;
Expand Down
12 changes: 6 additions & 6 deletions packages/kbn-build/src/production/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -26,22 +26,22 @@ describe('kbn-build production', function () {
cwd: fixturesPath,
parents: true,
nodir: true,
dot: true
dot: true,
});

const projects = await getProjects(tmpDir, ['./packages/*']);

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([
Expand All @@ -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',
]);
});
});
8 changes: 4 additions & 4 deletions packages/kbn-build/src/production/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions packages/kbn-build/src/utils/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function generateColors() {
export function spawn(command, args, opts) {
return execa(command, args, {
...opts,
stdio: 'inherit'
stdio: 'inherit',
});
}

Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-build/src/utils/package_json.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function writePackageJson(path, json) {

export const createProductionPackageJson = pkgJson => ({
...pkgJson,
dependencies: transformDependencies(pkgJson.dependencies)
dependencies: transformDependencies(pkgJson.dependencies),
});

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/kbn-build/src/utils/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import chalk from 'chalk';
import {
installInDir,
runScriptInPackage,
runScriptInPackageStreaming
runScriptInPackageStreaming,
} from './scripts';
import { readPackageJson } from './package_json';
import { CliError } from './errors';
Expand All @@ -27,7 +27,7 @@ export class Project {

this.allDependencies = {
...(this.json.devDependencies || {}),
...(this.json.dependencies || {})
...(this.json.dependencies || {}),
};

this.scripts = this.json.scripts || {};
Expand All @@ -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)) {
Expand Down
26 changes: 13 additions & 13 deletions packages/kbn-build/src/utils/project.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const createProjectWith = (fields, path = '') =>
{
name: 'kibana',
version: '1.0.0',
...fields
...fields,
},
join(rootPath, path)
);
Expand All @@ -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');
Expand All @@ -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'
);
Expand All @@ -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'
);
Expand All @@ -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'
);
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-build/src/utils/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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],
}
);
}
Expand Down
6 changes: 3 additions & 3 deletions packages/kbn-build/src/utils/projects.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { resolve } from 'path';
import {
getProjects,
buildProjectGraph,
topologicallyBatchProjects
topologicallyBatchProjects,
} from './projects';

const rootPath = resolve(`${__dirname}/__fixtures__/kibana`);
Expand Down Expand Up @@ -53,7 +53,7 @@ describe('#buildProjectGraph', () => {
const projects = await getProjects(rootPath, [
'.',
'packages/*',
'../plugins/*'
'../plugins/*',
]);
const graph = buildProjectGraph(projects);

Expand All @@ -71,7 +71,7 @@ describe('#topologicallyBatchProjects', () => {
const projects = await getProjects(rootPath, [
'.',
'packages/*',
'../plugins/*'
'../plugins/*',
]);
const graph = buildProjectGraph(projects);

Expand Down
10 changes: 5 additions & 5 deletions packages/kbn-build/src/utils/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}

Expand All @@ -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);
Expand All @@ -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,
});
}

0 comments on commit a68adaa

Please sign in to comment.