diff --git a/desktop/package.json b/desktop/package.json index 65cc4f88f..ba4205482 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -187,6 +187,7 @@ "flow-bin": "0.123.0", "fs-extra": "^9.0.0", "glob": "^7.1.2", + "ignore": "^5.1.4", "invariant": "^2.2.4", "jest": "^25.1.0", "jest-environment-jsdom-sixteen": "^1.0.3", diff --git a/desktop/scripts/copy-package-with-dependencies.ts b/desktop/scripts/copy-package-with-dependencies.ts index 3a01113ae..0aa847461 100644 --- a/desktop/scripts/copy-package-with-dependencies.ts +++ b/desktop/scripts/copy-package-with-dependencies.ts @@ -9,6 +9,16 @@ import fs from 'fs-extra'; import path from 'path'; +import ignore from 'ignore'; + +const DEFAULT_BUILD_IGNORES = [ + '/node_modules', + 'README*', + 'LICENSE*', + '*.ts', + '*.ls', + 'Gruntfile*', +]; /** * This function copies package into the specified target dir with all its dependencies: @@ -39,10 +49,18 @@ async function copyPackageWithDependenciesRecursive( if ((await fs.stat(packageDir)).isSymbolicLink()) { packageDir = await fs.readlink(packageDir); } + const ignores = await fs + .readFile(path.join(packageDir, '.buildignore'), 'utf-8') + .then((l) => l.split('\n')) + .catch((_e) => []) + .then((l: Array) => ignore().add(DEFAULT_BUILD_IGNORES.concat(l))); await fs.copy(packageDir, targetDir, { dereference: true, recursive: true, - filter: (src) => !src.startsWith(path.join(packageDir, 'node_modules')), + filter: (src) => { + const relativePath = path.relative(packageDir, src); + return relativePath === '' || !ignores.ignores(relativePath); + }, }); const pkg = await fs.readJson(path.join(packageDir, 'package.json')); const dependencies = (pkg.dependencies ?? {}) as {[key: string]: string}; diff --git a/desktop/static/package.json b/desktop/static/package.json index b7ca09bd2..4dcd1cd80 100644 --- a/desktop/static/package.json +++ b/desktop/static/package.json @@ -13,12 +13,13 @@ "flipper-pkg-lib": "0.39.0", "mem": "^6.0.0", "mkdirp": "^1.0.0", - "p-map": "^4.0.0", "p-filter": "^2.1.0", + "p-map": "^4.0.0", "recursive-readdir": "^2.2.2", "uuid": "^7.0.1", + "ws": "^7.2.3", "xdg-basedir": "^4.0.0", - "yargs": "^15.3.1", - "ws": "^7.2.3" + "ignore": "^5.1.4", + "yargs": "^15.3.1" } }