Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Remove more files #19603

Merged
merged 2 commits into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/dev/build/lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ export async function deleteAll(log, patterns) {
assertAbsolute(pattern.startsWith('!') ? pattern.slice(1) : pattern);
}

const files = await del(patterns);
const files = await del(patterns, {
concurrency: 4
});
log.debug('Deleted %d files/directories', files.length);
log.verbose('Deleted:', longInspect(files));
}
Expand Down
120 changes: 102 additions & 18 deletions src/dev/build/tasks/clean_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,20 @@ export const CleanTask = {
};

export const CleanPackagesTask = {
description: 'Cleaning source for packages that are now installed in node_modules',
description:
'Cleaning source for packages that are now installed in node_modules',

async run(config, log, build) {
await deleteAll(log, [
build.resolvePath('packages'),
build.resolvePath('x-pack')
build.resolvePath('x-pack'),
]);
},
};

export const CleanTypescriptTask = {
description: 'Cleaning typescript source files that have been transpiled to JS',
description:
'Cleaning typescript source files that have been transpiled to JS',

async run(config, log, build) {
await deleteAll(log, [
Expand All @@ -57,13 +59,94 @@ export const CleanExtraFilesFromModulesTask = {
description: 'Cleaning tests, examples, docs, etc. from node_modules',

async run(config, log, build) {
await deleteAll(log, [
build.resolvePath('node_modules/**/test/**/*'),
build.resolvePath('node_modules/**/tests/**/*'),
build.resolvePath('node_modules/**/example/**/*'),
build.resolvePath('node_modules/**/examples/**/*'),
build.resolvePath('node_modules/**/.bin/**/*'),
]);
const deleteFromNodeModules = globs => {
return deleteAll(
log,
globs.map(p => build.resolvePath(`node_modules/**/${p}`))
);
};

const tests = [
'test',
'tests',
'__tests__',
'mocha.opts',
'*.test.js',
'*.snap',
'coverage',
];
const docs = [
'doc',
'docs',
'CONTRIBUTING.md',
'Contributing.md',
'contributing.md',
'History.md',
'HISTORY.md',
'history.md',
'CHANGELOG.md',
'Changelog.md',
'changelog.md',
];
const examples = ['example', 'examples', 'demo', 'samples'];
const bins = ['.bin'];
const linters = [
'.eslintrc',
'.eslintrc.js',
'.eslintrc.yml',
'.prettierrc',
'.jshintrc',
'.babelrc',
'.jscs.json',
'.lint',
];
const hints = ['*.flow', '*.webidl', '*.map'];
const scripts = [
'*.sh',
'*.bat',
'*.exe',
'Gruntfile.js',
'gulpfile.js',
'Makefile',
];
const transpiledSources = ['*.coffee', '*.scss', '*.sass'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The are the opposite of transpiled sources. They are untranspiled sources, or perhaps transpilable sources.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add .ts and .tsx to the mix since those can't be transpiled on the fly?

Copy link
Member Author

@jbudz jbudz Jun 19, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Updated both with 9190f60

const editors = ['.editorconfig', '.vscode'];
const git = [
'.gitattributes',
'.gitkeep',
'.gitempty',
'.gitmodules',
'.keep',
'.empty',
];
const ci = [
'.travis.yml',
'.coveralls.yml',
'.instanbul.yml',
'appveyor.yml',
'.zuul.yml',
];
const meta = [
'package-lock.json',
'component.json',
'bower.json',
'yarn.lock',
];
const misc = ['.*ignore', '.DS_Store', 'Dockerfile', 'docker-compose.yml'];

await deleteFromNodeModules(tests);
await deleteFromNodeModules(docs);
await deleteFromNodeModules(examples);
await deleteFromNodeModules(bins);
await deleteFromNodeModules(linters);
await deleteFromNodeModules(hints);
await deleteFromNodeModules(scripts);
await deleteFromNodeModules(transpiledSources);
await deleteFromNodeModules(editors);
await deleteFromNodeModules(git);
await deleteFromNodeModules(ci);
await deleteFromNodeModules(meta);
await deleteFromNodeModules(misc);
},
};

Expand All @@ -75,27 +158,29 @@ export const CleanExtraBinScriptsTask = {
if (platform.isWindows()) {
await deleteAll(log, [
build.resolvePathForPlatform(platform, 'bin', '*'),
`!${build.resolvePathForPlatform(platform, 'bin', '*.bat')}`
`!${build.resolvePathForPlatform(platform, 'bin', '*.bat')}`,
]);
} else {
await deleteAll(log, [
build.resolvePathForPlatform(platform, 'bin', '*.bat'),
]);
}
}
}
},
};

export const CleanExtraBrowsersTask = {
description: 'Cleaning extra browsers from platform-specific builds',

async run(config, log, build) {
const getBrowserPathsForPlatform = (platform) => {
const getBrowserPathsForPlatform = platform => {
const reportingDir = 'node_modules/x-pack/plugins/reporting';
const phantomDir = '.phantom';
const chromiumDir = '.chromium';
const phantomPath = p => build.resolvePathForPlatform(platform, reportingDir, phantomDir, p);
const chromiumPath = p => build.resolvePathForPlatform(platform, reportingDir, chromiumDir, p);
const phantomPath = p =>
build.resolvePathForPlatform(platform, reportingDir, phantomDir, p);
const chromiumPath = p =>
build.resolvePathForPlatform(platform, reportingDir, chromiumDir, p);
return platforms => {
const paths = [];
if (platforms.windows) {
Expand All @@ -119,12 +204,11 @@ export const CleanExtraBrowsersTask = {
const getBrowserPaths = getBrowserPathsForPlatform(platform);
if (platform.isWindows()) {
await deleteAll(log, getBrowserPaths({ linux: true, darwin: true }));
}
else if (platform.isMac()) {
} else if (platform.isMac()) {
await deleteAll(log, getBrowserPaths({ linux: true, windows: true }));
} else if (platform.isLinux()) {
await deleteAll(log, getBrowserPaths({ windows: true, darwin: true }));
}
}
}
},
};