fix(NA): get dll entries across platforms (#43224) (#43238)

* fix(NA): get dll entries across platforms

* chore(NA): some more improvements
This commit is contained in:
Tiago Costa 2019-08-14 04:46:26 +01:00 committed by GitHub
parent e7712a5f92
commit 22f0098819
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 7 deletions

View file

@ -39,8 +39,9 @@ module.exports = function(root) {
const kibanaExtraDir = resolve(root, '../../kibana');
const kibanaPluginsDir = resolve(root, '../../');
const isPluginOnKibanaExtra = pluginPackageJsonPath.includes(kibanaExtraDir);
const isPluginXpack = pkg.name === 'x-pack';
if (isPluginOnKibanaExtra) {
if (isPluginOnKibanaExtra && !isPluginXpack) {
console.warn(
`In the future we will disable ../kibana-extra/{pluginName}. You should move your plugin ${pkg.name} as soon as possible to ./plugins/{pluginName}`
);
@ -51,7 +52,7 @@ module.exports = function(root) {
return Object.assign(
{
root: root,
kibanaRoot: pkg.name === 'x-pack' ? resolve(root, '..') : kibanaRootWhenNotXpackPlugin,
kibanaRoot: isPluginXpack ? resolve(root, '..') : kibanaRootWhenNotXpackPlugin,
serverTestPatterns: ['server/**/__tests__/**/*.js'],
buildSourcePatterns: buildSourcePatterns,
skipInstallDependencies: false,

View file

@ -18,9 +18,10 @@
*/
import { deleteAll, isFileAccessible, read, write } from '../../lib';
import { dirname, sep, relative, resolve } from 'path';
import { dirname, relative, resolve } from 'path';
import pkgUp from 'pkg-up';
import globby from 'globby';
import normalizePosixPath from 'normalize-path';
function checkDllEntryAccess(entry, baseDir = '') {
const resolvedPath = baseDir ? resolve(baseDir, entry) : entry;
@ -48,7 +49,7 @@ export async function getDllEntries(manifestPath, whiteListedModules, baseDir =
// Only includes modules who are not in the white list of modules
// and that are node_modules
return modules.filter(entry => {
const isWhiteListed = whiteListedModules.some(nonEntry => entry.includes(`node_modules${sep}${nonEntry}${sep}`));
const isWhiteListed = whiteListedModules.some(nonEntry => normalizePosixPath(entry).includes(`node_modules/${nonEntry}`));
const isNodeModule = entry.includes('node_modules');
// NOTE: when using dynamic imports on webpack the entry paths could be created
@ -69,6 +70,7 @@ export async function cleanDllModuleFromEntryPath(logger, entryPath) {
const modulePkgPath = await pkgUp(entryPath);
const modulePkg = JSON.parse(await read(modulePkgPath));
const moduleDir = dirname(modulePkgPath);
const normalizedModuleDir = normalizePosixPath(moduleDir);
// Cancel the cleanup for this module as it
// was already done.
@ -93,9 +95,9 @@ export async function cleanDllModuleFromEntryPath(logger, entryPath) {
// until the following issue gets closed
// https://github.com/sindresorhus/globby/issues/87
const filesToDelete = await globby([
`${moduleDir}/**`,
`!${moduleDir}/**/*.+(css)`,
`!${moduleDir}/**/*.+(gif|ico|jpeg|jpg|tiff|tif|svg|png|webp)`,
`${normalizedModuleDir}/**`,
`!${normalizedModuleDir}/**/*.+(css)`,
`!${normalizedModuleDir}/**/*.+(gif|ico|jpeg|jpg|tiff|tif|svg|png|webp)`,
]);
await deleteAll(filesToDelete.filter(path => {