From 70e5be4c513e082bb789607b4cc3a695f5a0ce19 Mon Sep 17 00:00:00 2001 From: Tyler Smalley Date: Sun, 17 Mar 2019 22:46:01 -0700 Subject: [PATCH] Remove node_modules/x-pack Signed-off-by: Tyler Smalley --- packages/kbn-pm/dist/index.js | 2 +- .../production/build_production_projects.ts | 2 +- src/dev/build/tasks/clean_tasks.js | 202 ++++++++++-------- 3 files changed, 110 insertions(+), 96 deletions(-) diff --git a/packages/kbn-pm/dist/index.js b/packages/kbn-pm/dist/index.js index 3aca82fffb477f0..d0146ac4c571556 100644 --- a/packages/kbn-pm/dist/index.js +++ b/packages/kbn-pm/dist/index.js @@ -31901,7 +31901,7 @@ let copyToBuild = (() => { // We want the package to have the same relative location within the build const relativeProjectPath = (0, _path.relative)(kibanaRoot, project.path); const buildProjectPath = (0, _path.resolve)(buildRoot, relativeProjectPath); - yield (0, _cpy2.default)(['**/*'], buildProjectPath, { + yield (0, _cpy2.default)(['**/*', '!node_modules/**'], buildProjectPath, { cwd: project.getIntermediateBuildDirectory(), dot: true, nodir: true, diff --git a/packages/kbn-pm/src/production/build_production_projects.ts b/packages/kbn-pm/src/production/build_production_projects.ts index 6d4a4f816aae9d1..fd5c4107292fcee 100644 --- a/packages/kbn-pm/src/production/build_production_projects.ts +++ b/packages/kbn-pm/src/production/build_production_projects.ts @@ -122,7 +122,7 @@ async function copyToBuild(project: Project, kibanaRoot: string, buildRoot: stri const relativeProjectPath = relative(kibanaRoot, project.path); const buildProjectPath = resolve(buildRoot, relativeProjectPath); - await copy(['**/*'], buildProjectPath, { + await copy(['**/*', '!node_modules/**'], buildProjectPath, { cwd: project.getIntermediateBuildDirectory(), dot: true, nodir: true, diff --git a/src/dev/build/tasks/clean_tasks.js b/src/dev/build/tasks/clean_tasks.js index 0dac814d15dc10a..b100b322e517bfe 100644 --- a/src/dev/build/tasks/clean_tasks.js +++ b/src/dev/build/tasks/clean_tasks.js @@ -18,6 +18,7 @@ */ import minimatch from 'minimatch'; +import { existsSync } from 'fs'; import { deleteAll, deleteEmptyFolders, scanDelete } from '../lib'; @@ -69,103 +70,116 @@ export const CleanExtraFilesFromModulesTask = { minimatch.makeRe(pattern, { nocase: true }) ); + const regularExpressions = makeRegexps([ + // tests + '**/test', + '**/tests', + '**/__tests__', + '**/mocha.opts', + '**/*.test.js', + '**/*.snap', + '**/coverage', + + // docs + '**/doc', + '**/docs', + '**/CONTRIBUTING.md', + '**/Contributing.md', + '**/contributing.md', + '**/History.md', + '**/HISTORY.md', + '**/history.md', + '**/CHANGELOG.md', + '**/Changelog.md', + '**/changelog.md', + + // examples + '**/example', + '**/examples', + '**/demo', + '**/samples', + + // bins + '**/.bin', + + // linters + '**/.eslintrc', + '**/.eslintrc.js', + '**/.eslintrc.yml', + '**/.prettierrc', + '**/.jshintrc', + '**/.babelrc', + '**/.jscs.json', + '**/.lint', + + // hints + '**/*.flow', + '**/*.webidl', + '**/*.map', + '**/@types', + + // scripts + '**/*.sh', + '**/*.bat', + '**/*.exe', + '**/Gruntfile.js', + '**/gulpfile.js', + '**/Makefile', + + // untranspiled sources + '**/*.coffee', + '**/*.scss', + '**/*.sass', + '**/.ts', + '**/.tsx', + + // editors + '**/.editorconfig', + '**/.vscode', + + // git + '**/.gitattributes', + '**/.gitkeep', + '**/.gitempty', + '**/.gitmodules', + '**/.keep', + '**/.empty', + + // ci + '**/.travis.yml', + '**/.coveralls.yml', + '**/.instanbul.yml', + '**/appveyor.yml', + '**/.zuul.yml', + + // metadata + '**/package-lock.json', + '**/component.json', + '**/bower.json', + '**/yarn.lock', + + // misc + '**/.*ignore', + '**/.DS_Store', + '**/Dockerfile', + '**/docker-compose.yml', + ]); + log.info('Deleted %d files', await scanDelete({ directory: build.resolvePath('node_modules'), - regularExpressions: makeRegexps([ - // tests - '**/test', - '**/tests', - '**/__tests__', - '**/mocha.opts', - '**/*.test.js', - '**/*.snap', - '**/coverage', - - // docs - '**/doc', - '**/docs', - '**/CONTRIBUTING.md', - '**/Contributing.md', - '**/contributing.md', - '**/History.md', - '**/HISTORY.md', - '**/history.md', - '**/CHANGELOG.md', - '**/Changelog.md', - '**/changelog.md', - - // examples - '**/example', - '**/examples', - '**/demo', - '**/samples', - - // bins - '**/.bin', - - // linters - '**/.eslintrc', - '**/.eslintrc.js', - '**/.eslintrc.yml', - '**/.prettierrc', - '**/.jshintrc', - '**/.babelrc', - '**/.jscs.json', - '**/.lint', - - // hints - '**/*.flow', - '**/*.webidl', - '**/*.map', - '**/@types', - - // scripts - '**/*.sh', - '**/*.bat', - '**/*.exe', - '**/Gruntfile.js', - '**/gulpfile.js', - '**/Makefile', - - // untranspiled sources - '**/*.coffee', - '**/*.scss', - '**/*.sass', - '**/.ts', - '**/.tsx', - - // editors - '**/.editorconfig', - '**/.vscode', - - // git - '**/.gitattributes', - '**/.gitkeep', - '**/.gitempty', - '**/.gitmodules', - '**/.keep', - '**/.empty', - - // ci - '**/.travis.yml', - '**/.coveralls.yml', - '**/.instanbul.yml', - '**/appveyor.yml', - '**/.zuul.yml', - - // metadata - '**/package-lock.json', - '**/component.json', - '**/bower.json', - '**/yarn.lock', - - // misc - '**/.*ignore', - '**/.DS_Store', - '**/Dockerfile', - '**/docker-compose.yml' - ]) + regularExpressions })); + + log.info('Deleted %d files', await scanDelete({ + directory: build.resolvePath('x-pack/node_modules'), + regularExpressions + })); + + if (existsSync(build.resolvePath('node_modules/x-pack'))) { + await deleteAll([ + build.resolvePath('node_modules/x-pack') + ], log); + } }, };