From ba2dccc4f76f5da226adcaae9a4dbd132fa0d145 Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Thu, 31 May 2018 11:58:39 -0500 Subject: [PATCH 1/2] [build] Remove more files --- src/dev/build/lib/fs.js | 4 +- src/dev/build/tasks/clean_tasks.js | 120 ++++++++++++++++++++++++----- 2 files changed, 105 insertions(+), 19 deletions(-) diff --git a/src/dev/build/lib/fs.js b/src/dev/build/lib/fs.js index f17db1ae68761..1c19a68d7136a 100644 --- a/src/dev/build/lib/fs.js +++ b/src/dev/build/lib/fs.js @@ -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)); } diff --git a/src/dev/build/tasks/clean_tasks.js b/src/dev/build/tasks/clean_tasks.js index 9cb7bb4a82e25..541ad1ddfee68 100644 --- a/src/dev/build/tasks/clean_tasks.js +++ b/src/dev/build/tasks/clean_tasks.js @@ -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, [ @@ -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']; + 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); }, }; @@ -75,7 +158,7 @@ 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, [ @@ -83,19 +166,21 @@ export const CleanExtraBinScriptsTask = { ]); } } - } + }, }; 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) { @@ -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 })); } } - } + }, }; From 9190f60935f806f3ac1a75d3325f4a23117c291e Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Tue, 19 Jun 2018 09:38:22 -0500 Subject: [PATCH 2/2] rename, add ts and tsx --- src/dev/build/tasks/clean_tasks.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dev/build/tasks/clean_tasks.js b/src/dev/build/tasks/clean_tasks.js index 541ad1ddfee68..e2c861545e7fa 100644 --- a/src/dev/build/tasks/clean_tasks.js +++ b/src/dev/build/tasks/clean_tasks.js @@ -109,7 +109,7 @@ export const CleanExtraFilesFromModulesTask = { 'gulpfile.js', 'Makefile', ]; - const transpiledSources = ['*.coffee', '*.scss', '*.sass']; + const untranspiledSources = ['*.coffee', '*.scss', '*.sass', '.ts', '.tsx']; const editors = ['.editorconfig', '.vscode']; const git = [ '.gitattributes', @@ -141,7 +141,7 @@ export const CleanExtraFilesFromModulesTask = { await deleteFromNodeModules(linters); await deleteFromNodeModules(hints); await deleteFromNodeModules(scripts); - await deleteFromNodeModules(transpiledSources); + await deleteFromNodeModules(untranspiledSources); await deleteFromNodeModules(editors); await deleteFromNodeModules(git); await deleteFromNodeModules(ci);