mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
parent
648209981d
commit
ca2027889a
28 changed files with 467 additions and 286 deletions
|
@ -247,7 +247,6 @@
|
|||
"webpack-merge": "4.1.4",
|
||||
"whatwg-fetch": "^3.0.0",
|
||||
"wreck": "^14.0.2",
|
||||
"x-pack": "7.1.0",
|
||||
"yauzl": "2.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
199
packages/kbn-pm/dist/index.js
vendored
199
packages/kbn-pm/dist/index.js
vendored
|
@ -99,8 +99,17 @@ __webpack_require__.r(__webpack_exports__);
|
|||
|
||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "prepareExternalProjectDependencies", function() { return _production__WEBPACK_IMPORTED_MODULE_1__["prepareExternalProjectDependencies"]; });
|
||||
|
||||
/* harmony import */ var _utils_workspaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(131);
|
||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "copyWorkspacePackages", function() { return _utils_workspaces__WEBPACK_IMPORTED_MODULE_2__["copyWorkspacePackages"]; });
|
||||
/* harmony import */ var _utils_projects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(35);
|
||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getProjects", function() { return _utils_projects__WEBPACK_IMPORTED_MODULE_2__["getProjects"]; });
|
||||
|
||||
/* harmony import */ var _utils_project__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(53);
|
||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Project", function() { return _utils_project__WEBPACK_IMPORTED_MODULE_3__["Project"]; });
|
||||
|
||||
/* harmony import */ var _utils_workspaces__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(131);
|
||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "copyWorkspacePackages", function() { return _utils_workspaces__WEBPACK_IMPORTED_MODULE_4__["copyWorkspacePackages"]; });
|
||||
|
||||
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(132);
|
||||
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getProjectPaths", function() { return _config__WEBPACK_IMPORTED_MODULE_5__["getProjectPaths"]; });
|
||||
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
|
@ -124,6 +133,9 @@ __webpack_require__.r(__webpack_exports__);
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/***/ }),
|
||||
/* 1 */
|
||||
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
||||
|
@ -2646,6 +2658,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chmod", function() { return chmod; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "readFile", function() { return readFile; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mkdirp", function() { return mkdirp; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isSymlink", function() { return isSymlink; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isDirectory", function() { return isDirectory; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isFile", function() { return isFile; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createSymlink", function() { return createSymlink; });
|
||||
|
@ -2685,7 +2698,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||
|
||||
|
||||
|
||||
const stat = Object(util__WEBPACK_IMPORTED_MODULE_5__["promisify"])(fs__WEBPACK_IMPORTED_MODULE_1___default.a.stat);
|
||||
const lstat = Object(util__WEBPACK_IMPORTED_MODULE_5__["promisify"])(fs__WEBPACK_IMPORTED_MODULE_1___default.a.lstat);
|
||||
const readFile = Object(util__WEBPACK_IMPORTED_MODULE_5__["promisify"])(fs__WEBPACK_IMPORTED_MODULE_1___default.a.readFile);
|
||||
const symlink = Object(util__WEBPACK_IMPORTED_MODULE_5__["promisify"])(fs__WEBPACK_IMPORTED_MODULE_1___default.a.symlink);
|
||||
const chmod = Object(util__WEBPACK_IMPORTED_MODULE_5__["promisify"])(fs__WEBPACK_IMPORTED_MODULE_1___default.a.chmod);
|
||||
|
@ -2697,7 +2710,7 @@ const copyDirectory = Object(util__WEBPACK_IMPORTED_MODULE_5__["promisify"])(ncp
|
|||
|
||||
async function statTest(path, block) {
|
||||
try {
|
||||
return block((await stat(path)));
|
||||
return block((await lstat(path)));
|
||||
} catch (e) {
|
||||
if (e.code === 'ENOENT') {
|
||||
return false;
|
||||
|
@ -2707,11 +2720,19 @@ async function statTest(path, block) {
|
|||
}
|
||||
}
|
||||
/**
|
||||
* Test if a path points to a directory.
|
||||
* Test if a path points to a symlink.
|
||||
* @param path
|
||||
*/
|
||||
|
||||
|
||||
async function isSymlink(path) {
|
||||
return await statTest(path, stats => stats.isSymbolicLink());
|
||||
}
|
||||
/**
|
||||
* Test if a path points to a directory.
|
||||
* @param path
|
||||
*/
|
||||
|
||||
async function isDirectory(path) {
|
||||
return await statTest(path, stats => stats.isDirectory());
|
||||
}
|
||||
|
@ -7822,14 +7843,16 @@ __webpack_require__.r(__webpack_exports__);
|
|||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Project", function() { return Project; });
|
||||
/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
|
||||
/* harmony import */ var chalk__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(chalk__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16);
|
||||
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(29);
|
||||
/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(util__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(52);
|
||||
/* harmony import */ var _log__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(33);
|
||||
/* harmony import */ var _package_json__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(54);
|
||||
/* harmony import */ var _scripts__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(92);
|
||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(23);
|
||||
/* harmony import */ var fs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(16);
|
||||
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(29);
|
||||
/* harmony import */ var util__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(util__WEBPACK_IMPORTED_MODULE_3__);
|
||||
/* harmony import */ var _errors__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(52);
|
||||
/* harmony import */ var _log__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(33);
|
||||
/* harmony import */ var _package_json__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(54);
|
||||
/* harmony import */ var _scripts__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(92);
|
||||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
@ -7859,9 +7882,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|||
|
||||
|
||||
|
||||
|
||||
class Project {
|
||||
static async fromPath(path) {
|
||||
const pkgJson = await Object(_package_json__WEBPACK_IMPORTED_MODULE_5__["readPackageJson"])(path);
|
||||
const pkgJson = await Object(_package_json__WEBPACK_IMPORTED_MODULE_6__["readPackageJson"])(path);
|
||||
return new Project(pkgJson, path);
|
||||
}
|
||||
|
||||
|
@ -7890,9 +7914,9 @@ class Project {
|
|||
|
||||
this.json = Object.freeze(packageJson);
|
||||
this.path = projectPath;
|
||||
this.packageJsonLocation = Object(path__WEBPACK_IMPORTED_MODULE_1__["resolve"])(this.path, 'package.json');
|
||||
this.nodeModulesLocation = Object(path__WEBPACK_IMPORTED_MODULE_1__["resolve"])(this.path, 'node_modules');
|
||||
this.targetLocation = Object(path__WEBPACK_IMPORTED_MODULE_1__["resolve"])(this.path, 'target');
|
||||
this.packageJsonLocation = Object(path__WEBPACK_IMPORTED_MODULE_2__["resolve"])(this.path, 'package.json');
|
||||
this.nodeModulesLocation = Object(path__WEBPACK_IMPORTED_MODULE_2__["resolve"])(this.path, 'node_modules');
|
||||
this.targetLocation = Object(path__WEBPACK_IMPORTED_MODULE_2__["resolve"])(this.path, 'target');
|
||||
this.productionDependencies = this.json.dependencies || {};
|
||||
this.devDependencies = this.json.devDependencies || {};
|
||||
this.allDependencies = _objectSpread({}, this.devDependencies, this.productionDependencies);
|
||||
|
@ -7911,7 +7935,7 @@ class Project {
|
|||
if (dependentProjectIsInWorkspace) {
|
||||
expectedVersionInPackageJson = project.json.version;
|
||||
} else {
|
||||
const relativePathToProject = normalizePath(Object(path__WEBPACK_IMPORTED_MODULE_1__["relative"])(this.path, project.path));
|
||||
const relativePathToProject = normalizePath(Object(path__WEBPACK_IMPORTED_MODULE_2__["relative"])(this.path, project.path));
|
||||
expectedVersionInPackageJson = `link:${relativePathToProject}`;
|
||||
} // No issues!
|
||||
|
||||
|
@ -7922,15 +7946,15 @@ class Project {
|
|||
|
||||
let problemMsg;
|
||||
|
||||
if (Object(_package_json__WEBPACK_IMPORTED_MODULE_5__["isLinkDependency"])(versionInPackageJson) && dependentProjectIsInWorkspace) {
|
||||
if (Object(_package_json__WEBPACK_IMPORTED_MODULE_6__["isLinkDependency"])(versionInPackageJson) && dependentProjectIsInWorkspace) {
|
||||
problemMsg = `but should be using a workspace`;
|
||||
} else if (Object(_package_json__WEBPACK_IMPORTED_MODULE_5__["isLinkDependency"])(versionInPackageJson)) {
|
||||
} else if (Object(_package_json__WEBPACK_IMPORTED_MODULE_6__["isLinkDependency"])(versionInPackageJson)) {
|
||||
problemMsg = `using 'link:', but the path is wrong`;
|
||||
} else {
|
||||
problemMsg = `but it's not using the local package`;
|
||||
}
|
||||
|
||||
throw new _errors__WEBPACK_IMPORTED_MODULE_3__["CliError"](`[${this.name}] depends on [${project.name}] ${problemMsg}. Update its package.json to the expected value below.`, {
|
||||
throw new _errors__WEBPACK_IMPORTED_MODULE_4__["CliError"](`[${this.name}] depends on [${project.name}] ${problemMsg}. Update its package.json to the expected value below.`, {
|
||||
actual: `"${project.name}": "${versionInPackageJson}"`,
|
||||
expected: `"${project.name}": "${expectedVersionInPackageJson}"`,
|
||||
package: `${this.name} (${this.packageJsonLocation})`
|
||||
|
@ -7948,7 +7972,7 @@ class Project {
|
|||
|
||||
|
||||
getIntermediateBuildDirectory() {
|
||||
return Object(path__WEBPACK_IMPORTED_MODULE_1__["resolve"])(this.path, this.getBuildConfig().intermediateBuildDirectory || '.');
|
||||
return Object(path__WEBPACK_IMPORTED_MODULE_2__["resolve"])(this.path, this.getBuildConfig().intermediateBuildDirectory || '.');
|
||||
}
|
||||
|
||||
getCleanConfig() {
|
||||
|
@ -7968,7 +7992,7 @@ class Project {
|
|||
|
||||
if (typeof raw === 'string') {
|
||||
return {
|
||||
[this.name]: Object(path__WEBPACK_IMPORTED_MODULE_1__["resolve"])(this.path, raw)
|
||||
[this.name]: Object(path__WEBPACK_IMPORTED_MODULE_2__["resolve"])(this.path, raw)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -7976,25 +8000,25 @@ class Project {
|
|||
const binsConfig = {};
|
||||
|
||||
for (const binName of Object.keys(raw)) {
|
||||
binsConfig[binName] = Object(path__WEBPACK_IMPORTED_MODULE_1__["resolve"])(this.path, raw[binName]);
|
||||
binsConfig[binName] = Object(path__WEBPACK_IMPORTED_MODULE_2__["resolve"])(this.path, raw[binName]);
|
||||
}
|
||||
|
||||
return binsConfig;
|
||||
}
|
||||
|
||||
throw new _errors__WEBPACK_IMPORTED_MODULE_3__["CliError"](`[${this.name}] has an invalid "bin" field in its package.json, ` + `expected an object or a string`, {
|
||||
binConfig: Object(util__WEBPACK_IMPORTED_MODULE_2__["inspect"])(raw),
|
||||
throw new _errors__WEBPACK_IMPORTED_MODULE_4__["CliError"](`[${this.name}] has an invalid "bin" field in its package.json, ` + `expected an object or a string`, {
|
||||
binConfig: Object(util__WEBPACK_IMPORTED_MODULE_3__["inspect"])(raw),
|
||||
package: `${this.name} (${this.packageJsonLocation})`
|
||||
});
|
||||
}
|
||||
|
||||
async runScript(scriptName, args = []) {
|
||||
_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(`\n\nRunning script [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(scriptName)}] in [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(this.name)}]:\n`));
|
||||
return Object(_scripts__WEBPACK_IMPORTED_MODULE_6__["runScriptInPackage"])(scriptName, args, this);
|
||||
_log__WEBPACK_IMPORTED_MODULE_5__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(`\n\nRunning script [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(scriptName)}] in [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(this.name)}]:\n`));
|
||||
return Object(_scripts__WEBPACK_IMPORTED_MODULE_7__["runScriptInPackage"])(scriptName, args, this);
|
||||
}
|
||||
|
||||
runScriptStreaming(scriptName, args = []) {
|
||||
return Object(_scripts__WEBPACK_IMPORTED_MODULE_6__["runScriptInPackageStreaming"])(scriptName, args, this);
|
||||
return Object(_scripts__WEBPACK_IMPORTED_MODULE_7__["runScriptInPackageStreaming"])(scriptName, args, this);
|
||||
}
|
||||
|
||||
hasDependencies() {
|
||||
|
@ -8004,8 +8028,45 @@ class Project {
|
|||
async installDependencies({
|
||||
extraArgs
|
||||
}) {
|
||||
_log__WEBPACK_IMPORTED_MODULE_4__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(`\n\nInstalling dependencies in [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(this.name)}]:\n`));
|
||||
return Object(_scripts__WEBPACK_IMPORTED_MODULE_6__["installInDir"])(this.path, extraArgs);
|
||||
_log__WEBPACK_IMPORTED_MODULE_5__["log"].write(chalk__WEBPACK_IMPORTED_MODULE_0___default.a.bold(`\n\nInstalling dependencies in [${chalk__WEBPACK_IMPORTED_MODULE_0___default.a.green(this.name)}]:\n`));
|
||||
await Object(_scripts__WEBPACK_IMPORTED_MODULE_7__["installInDir"])(this.path, extraArgs);
|
||||
await this.removeExtraneousNodeModules();
|
||||
}
|
||||
/**
|
||||
* Yarn workspaces symlinks workspace projects to the root node_modules, even
|
||||
* when there is no depenency on the project. This results in unnecicary, and
|
||||
* often duplicated code in the build archives.
|
||||
*/
|
||||
|
||||
|
||||
async removeExtraneousNodeModules() {
|
||||
// this is only relevant for the root workspace
|
||||
if (!this.isWorkspaceRoot) {
|
||||
return;
|
||||
}
|
||||
|
||||
const workspacesInfo = await Object(_scripts__WEBPACK_IMPORTED_MODULE_7__["yarnWorkspacesInfo"])(this.path);
|
||||
const unusedWorkspaces = new Set(Object.keys(workspacesInfo)); // check for any cross-project dependency
|
||||
|
||||
for (const name of Object.keys(workspacesInfo)) {
|
||||
const workspace = workspacesInfo[name];
|
||||
workspace.workspaceDependencies.forEach(w => unusedWorkspaces.delete(w));
|
||||
}
|
||||
|
||||
unusedWorkspaces.forEach(name => {
|
||||
const {
|
||||
dependencies,
|
||||
devDependencies
|
||||
} = this.json;
|
||||
const nodeModulesPath = Object(path__WEBPACK_IMPORTED_MODULE_2__["resolve"])(this.nodeModulesLocation, name);
|
||||
const isDependency = dependencies && dependencies.hasOwnProperty(name);
|
||||
const isDevDependency = devDependencies && devDependencies.hasOwnProperty(name);
|
||||
|
||||
if (!isDependency && !isDevDependency && fs__WEBPACK_IMPORTED_MODULE_1___default.a.existsSync(nodeModulesPath)) {
|
||||
_log__WEBPACK_IMPORTED_MODULE_5__["log"].write(`No dependency on ${name}, removing link in node_modules`);
|
||||
fs__WEBPACK_IMPORTED_MODULE_1___default.a.unlinkSync(nodeModulesPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
} // We normalize all path separators to `/` in generated files
|
||||
|
@ -13451,6 +13512,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "installInDir", function() { return installInDir; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runScriptInPackage", function() { return runScriptInPackage; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runScriptInPackageStreaming", function() { return runScriptInPackageStreaming; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yarnWorkspacesInfo", function() { return yarnWorkspacesInfo; });
|
||||
/* harmony import */ var _child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(93);
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
|
@ -13505,6 +13567,14 @@ function runScriptInPackageStreaming(script, args, pkg) {
|
|||
prefix: pkg.name
|
||||
});
|
||||
}
|
||||
async function yarnWorkspacesInfo(directory) {
|
||||
const workspacesInfo = await Object(_child_process__WEBPACK_IMPORTED_MODULE_0__["spawn"])('yarn', ['workspaces', 'info', '--json'], {
|
||||
cwd: directory,
|
||||
stdio: 'pipe'
|
||||
});
|
||||
const stdout = JSON.parse(workspacesInfo.stdout);
|
||||
return JSON.parse(stdout.data);
|
||||
}
|
||||
|
||||
/***/ }),
|
||||
/* 93 */
|
||||
|
@ -13557,17 +13627,17 @@ function generateColors() {
|
|||
}
|
||||
|
||||
function spawn(command, args, opts) {
|
||||
return execa__WEBPACK_IMPORTED_MODULE_1___default()(command, args, _objectSpread({}, opts, {
|
||||
return execa__WEBPACK_IMPORTED_MODULE_1___default()(command, args, _objectSpread({
|
||||
stdio: 'inherit'
|
||||
}));
|
||||
}, opts));
|
||||
}
|
||||
const nextColor = generateColors();
|
||||
function spawnStreaming(command, args, opts, {
|
||||
prefix
|
||||
}) {
|
||||
const spawned = execa__WEBPACK_IMPORTED_MODULE_1___default()(command, args, _objectSpread({}, opts, {
|
||||
const spawned = execa__WEBPACK_IMPORTED_MODULE_1___default()(command, args, _objectSpread({
|
||||
stdio: ['ignore', 'pipe', 'pipe']
|
||||
}));
|
||||
}, opts));
|
||||
const color = nextColor();
|
||||
const prefixedStdout = strong_log_transformer__WEBPACK_IMPORTED_MODULE_3___default()({
|
||||
tag: `${color.bold(prefix)}:`
|
||||
|
@ -17423,10 +17493,16 @@ async function workspacePackagePaths(rootPath) {
|
|||
return workspaceProjectsPaths;
|
||||
}
|
||||
async function copyWorkspacePackages(rootPath) {
|
||||
const workspaceProjects = await getWorkspaceProjects(rootPath);
|
||||
const projectPaths = Object(_config__WEBPACK_IMPORTED_MODULE_3__["getProjectPaths"])(rootPath, {});
|
||||
const projects = await Object(_projects__WEBPACK_IMPORTED_MODULE_6__["getProjects"])(rootPath, projectPaths);
|
||||
|
||||
for (const project of projects.values()) {
|
||||
const dest = path__WEBPACK_IMPORTED_MODULE_1___default.a.resolve(rootPath, 'node_modules', project.name);
|
||||
|
||||
if ((await Object(_fs__WEBPACK_IMPORTED_MODULE_4__["isSymlink"])(dest)) === false) {
|
||||
continue;
|
||||
} // Remove the symlink
|
||||
|
||||
for (const project of workspaceProjects.values()) {
|
||||
const dest = path__WEBPACK_IMPORTED_MODULE_1___default.a.resolve(rootPath, 'node_modules', project.name); // Remove the symlink
|
||||
|
||||
await Object(_fs__WEBPACK_IMPORTED_MODULE_4__["unlink"])(dest); // Copy in the package
|
||||
|
||||
|
@ -17434,19 +17510,6 @@ async function copyWorkspacePackages(rootPath) {
|
|||
}
|
||||
}
|
||||
|
||||
async function getWorkspaceProjects(rootPath) {
|
||||
const projectPaths = Object(_config__WEBPACK_IMPORTED_MODULE_3__["getProjectPaths"])(rootPath, {});
|
||||
const projects = await Object(_projects__WEBPACK_IMPORTED_MODULE_6__["getProjects"])(rootPath, projectPaths);
|
||||
|
||||
for (const [key, project] of projects.entries()) {
|
||||
if (!project.isWorkspaceProject) {
|
||||
projects.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
return projects;
|
||||
}
|
||||
|
||||
function packagesFromGlobPattern({
|
||||
pattern,
|
||||
rootPath
|
||||
|
@ -17496,7 +17559,7 @@ __webpack_require__.r(__webpack_exports__);
|
|||
/**
|
||||
* Returns all the paths where plugins are located
|
||||
*/
|
||||
function getProjectPaths(rootPath, options) {
|
||||
function getProjectPaths(rootPath, options = {}) {
|
||||
const skipKibanaPlugins = Boolean(options['skip-kibana-plugins']);
|
||||
const ossOnly = Boolean(options.oss);
|
||||
const projectPaths = [rootPath, Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(rootPath, 'packages/*')]; // This is needed in order to install the dependencies for the declared
|
||||
|
@ -31713,9 +31776,10 @@ __webpack_require__.r(__webpack_exports__);
|
|||
|
||||
async function buildProductionProjects({
|
||||
kibanaRoot,
|
||||
buildRoots
|
||||
buildRoot,
|
||||
onlyOSS
|
||||
}) {
|
||||
const projects = await getProductionProjects(kibanaRoot);
|
||||
const projects = await getProductionProjects(kibanaRoot, onlyOSS);
|
||||
const projectGraph = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_7__["buildProjectGraph"])(projects);
|
||||
const batchedProjects = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_7__["topologicallyBatchProjects"])(projects, projectGraph);
|
||||
const projectNames = [...projects.values()].map(project => project.name);
|
||||
|
@ -31725,10 +31789,7 @@ async function buildProductionProjects({
|
|||
for (const project of batch) {
|
||||
await deleteTarget(project);
|
||||
await buildProject(project);
|
||||
|
||||
for (const buildRoot of buildRoots) {
|
||||
await copyToBuild(project, kibanaRoot, buildRoot);
|
||||
}
|
||||
await copyToBuild(project, kibanaRoot, buildRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31736,17 +31797,33 @@ async function buildProductionProjects({
|
|||
* Returns the subset of projects that should be built into the production
|
||||
* bundle. As we copy these into Kibana's `node_modules` during the build step,
|
||||
* and let Kibana's build process be responsible for installing dependencies,
|
||||
* we only include Kibana's transitive _production_ dependencies.
|
||||
* we only include Kibana's transitive _production_ dependencies. If onlyOSS
|
||||
* is supplied, we omit projects with build.oss in their package.json set to false.
|
||||
*/
|
||||
|
||||
async function getProductionProjects(rootPath) {
|
||||
async function getProductionProjects(rootPath, onlyOSS) {
|
||||
const projectPaths = Object(_config__WEBPACK_IMPORTED_MODULE_3__["getProjectPaths"])(rootPath, {});
|
||||
const projects = await Object(_utils_projects__WEBPACK_IMPORTED_MODULE_7__["getProjects"])(rootPath, projectPaths);
|
||||
const productionProjects = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_7__["includeTransitiveProjects"])([projects.get('kibana')], projects, {
|
||||
const projectsSubset = [projects.get('kibana')];
|
||||
|
||||
if (projects.has('x-pack')) {
|
||||
projectsSubset.push(projects.get('x-pack'));
|
||||
}
|
||||
|
||||
const productionProjects = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_7__["includeTransitiveProjects"])(projectsSubset, projects, {
|
||||
onlyProductionDependencies: true
|
||||
}); // We remove Kibana, as we're already building Kibana
|
||||
|
||||
productionProjects.delete('kibana');
|
||||
|
||||
if (onlyOSS) {
|
||||
productionProjects.forEach(project => {
|
||||
if (project.getBuildConfig().oss === false) {
|
||||
productionProjects.delete(project.json.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return productionProjects;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,12 +27,13 @@ import { linkProjectExecutables } from '../utils/link_project_executables';
|
|||
import { IPackageJson } from '../utils/package_json';
|
||||
import { Project } from '../utils/project';
|
||||
import { buildProjectGraph } from '../utils/projects';
|
||||
import { installInDir, runScriptInPackageStreaming } from '../utils/scripts';
|
||||
import { installInDir, runScriptInPackageStreaming, yarnWorkspacesInfo } from '../utils/scripts';
|
||||
import { BootstrapCommand } from './bootstrap';
|
||||
|
||||
const mockInstallInDir = installInDir as jest.Mock;
|
||||
const mockRunScriptInPackageStreaming = runScriptInPackageStreaming as jest.Mock;
|
||||
const mockLinkProjectExecutables = linkProjectExecutables as jest.Mock;
|
||||
const mockYarnWorkspacesInfo = yarnWorkspacesInfo as jest.Mock;
|
||||
|
||||
const createProject = (packageJson: IPackageJson, path = '.') => {
|
||||
const project = new Project(
|
||||
|
@ -57,6 +58,10 @@ const noop = () => {
|
|||
// noop
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
mockYarnWorkspacesInfo.mockResolvedValue({});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
jest.restoreAllMocks();
|
||||
|
|
|
@ -27,7 +27,7 @@ export interface IProjectPathOptions {
|
|||
/**
|
||||
* Returns all the paths where plugins are located
|
||||
*/
|
||||
export function getProjectPaths(rootPath: string, options: IProjectPathOptions) {
|
||||
export function getProjectPaths(rootPath: string, options: IProjectPathOptions = {}) {
|
||||
const skipKibanaPlugins = Boolean(options['skip-kibana-plugins']);
|
||||
const ossOnly = Boolean(options.oss);
|
||||
|
||||
|
|
|
@ -19,4 +19,7 @@
|
|||
|
||||
export { run } from './cli';
|
||||
export { buildProductionProjects, prepareExternalProjectDependencies } from './production';
|
||||
export { getProjects } from './utils/projects';
|
||||
export { Project } from './utils/project';
|
||||
export { copyWorkspacePackages } from './utils/workspaces';
|
||||
export { getProjectPaths } from './config';
|
||||
|
|
|
@ -35,12 +35,14 @@ import {
|
|||
|
||||
export async function buildProductionProjects({
|
||||
kibanaRoot,
|
||||
buildRoots,
|
||||
buildRoot,
|
||||
onlyOSS,
|
||||
}: {
|
||||
kibanaRoot: string;
|
||||
buildRoots: string[];
|
||||
buildRoot: string;
|
||||
onlyOSS?: boolean;
|
||||
}) {
|
||||
const projects = await getProductionProjects(kibanaRoot);
|
||||
const projects = await getProductionProjects(kibanaRoot, onlyOSS);
|
||||
const projectGraph = buildProjectGraph(projects);
|
||||
const batchedProjects = topologicallyBatchProjects(projects, projectGraph);
|
||||
|
||||
|
@ -51,9 +53,7 @@ export async function buildProductionProjects({
|
|||
for (const project of batch) {
|
||||
await deleteTarget(project);
|
||||
await buildProject(project);
|
||||
for (const buildRoot of buildRoots) {
|
||||
await copyToBuild(project, kibanaRoot, buildRoot);
|
||||
}
|
||||
await copyToBuild(project, kibanaRoot, buildRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -62,19 +62,33 @@ export async function buildProductionProjects({
|
|||
* Returns the subset of projects that should be built into the production
|
||||
* bundle. As we copy these into Kibana's `node_modules` during the build step,
|
||||
* and let Kibana's build process be responsible for installing dependencies,
|
||||
* we only include Kibana's transitive _production_ dependencies.
|
||||
* we only include Kibana's transitive _production_ dependencies. If onlyOSS
|
||||
* is supplied, we omit projects with build.oss in their package.json set to false.
|
||||
*/
|
||||
async function getProductionProjects(rootPath: string) {
|
||||
async function getProductionProjects(rootPath: string, onlyOSS?: boolean) {
|
||||
const projectPaths = getProjectPaths(rootPath, {});
|
||||
const projects = await getProjects(rootPath, projectPaths);
|
||||
const projectsSubset = [projects.get('kibana')!];
|
||||
|
||||
const productionProjects = includeTransitiveProjects([projects.get('kibana')!], projects, {
|
||||
if (projects.has('x-pack')) {
|
||||
projectsSubset.push(projects.get('x-pack')!);
|
||||
}
|
||||
|
||||
const productionProjects = includeTransitiveProjects(projectsSubset, projects, {
|
||||
onlyProductionDependencies: true,
|
||||
});
|
||||
|
||||
// We remove Kibana, as we're already building Kibana
|
||||
productionProjects.delete('kibana');
|
||||
|
||||
if (onlyOSS) {
|
||||
productionProjects.forEach(project => {
|
||||
if (project.getBuildConfig().oss === false) {
|
||||
productionProjects.delete(project.json.name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return productionProjects;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"main": "./target/index.js",
|
||||
"kibana": {
|
||||
"build": {
|
||||
"oss": false
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@elastic/bar": "link:../bar"
|
||||
},
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`kbn-pm production builds and copies only OSS projects for production 1`] = `
|
||||
Array [
|
||||
"packages/bar/package.json",
|
||||
"packages/bar/src/index.js",
|
||||
"packages/bar/target/index.js",
|
||||
"packages/bar/yarn.lock",
|
||||
"packages/baz/index.js",
|
||||
"packages/baz/package.json",
|
||||
"packages/quux/index.js",
|
||||
"packages/quux/package.json",
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`kbn-pm production builds and copies projects for production 1`] = `
|
||||
Array [
|
||||
"packages/bar/package.json",
|
||||
|
@ -53,6 +66,11 @@ Object {
|
|||
"@babel/preset-env": "^7.3.4",
|
||||
"moment": "2.20.1",
|
||||
},
|
||||
"kibana": Object {
|
||||
"build": Object {
|
||||
"oss": false,
|
||||
},
|
||||
},
|
||||
"main": "./target/index.js",
|
||||
"name": "@elastic/foo",
|
||||
"private": true,
|
||||
|
|
|
@ -27,31 +27,38 @@ import { getProjects } from '../../utils/projects';
|
|||
import { buildProductionProjects } from '../build_production_projects';
|
||||
|
||||
describe('kbn-pm production', () => {
|
||||
let tmpDir: string;
|
||||
let buildRoot: string;
|
||||
|
||||
const timeout = 1 * 60 * 1000;
|
||||
|
||||
beforeEach(async () => {
|
||||
tmpDir = tempy.directory();
|
||||
buildRoot = tempy.directory();
|
||||
const fixturesPath = resolve(__dirname, '__fixtures__');
|
||||
|
||||
// Copy all the test fixtures into a tmp dir, as we will be mutating them
|
||||
await copy(['**/*'], tmpDir, {
|
||||
cwd: fixturesPath,
|
||||
dot: true,
|
||||
nodir: true,
|
||||
parents: true,
|
||||
});
|
||||
|
||||
const projects = await getProjects(tmpDir, ['.', './packages/*']);
|
||||
|
||||
for (const project of projects.values()) {
|
||||
// This will both install dependencies and generate `yarn.lock` files
|
||||
await project.installDependencies({
|
||||
extraArgs: ['--silent', '--no-progress'],
|
||||
});
|
||||
}
|
||||
}, timeout);
|
||||
|
||||
test(
|
||||
'builds and copies projects for production',
|
||||
async () => {
|
||||
const tmpDir = tempy.directory();
|
||||
const buildRoot = tempy.directory();
|
||||
const fixturesPath = resolve(__dirname, '__fixtures__');
|
||||
|
||||
// Copy all the test fixtures into a tmp dir, as we will be mutating them
|
||||
await copy(['**/*'], tmpDir, {
|
||||
cwd: fixturesPath,
|
||||
dot: true,
|
||||
nodir: true,
|
||||
parents: true,
|
||||
});
|
||||
|
||||
const projects = await getProjects(tmpDir, ['.', './packages/*']);
|
||||
|
||||
for (const project of projects.values()) {
|
||||
// This will both install dependencies and generate `yarn.lock` files
|
||||
await project.installDependencies({
|
||||
extraArgs: ['--silent', '--no-progress'],
|
||||
});
|
||||
}
|
||||
|
||||
await buildProductionProjects({ kibanaRoot: tmpDir, buildRoots: [buildRoot] });
|
||||
await buildProductionProjects({ kibanaRoot: tmpDir, buildRoot });
|
||||
|
||||
const files = await globby(['**/*', '!**/node_modules/**'], {
|
||||
cwd: buildRoot,
|
||||
|
@ -65,6 +72,20 @@ describe('kbn-pm production', () => {
|
|||
}
|
||||
}
|
||||
},
|
||||
2 * 60 * 1000
|
||||
timeout
|
||||
);
|
||||
|
||||
test(
|
||||
'builds and copies only OSS projects for production',
|
||||
async () => {
|
||||
await buildProductionProjects({ kibanaRoot: tmpDir, buildRoot, onlyOSS: true });
|
||||
|
||||
const files = await globby(['**/*', '!**/node_modules/**'], {
|
||||
cwd: buildRoot,
|
||||
});
|
||||
|
||||
expect(files.sort()).toMatchSnapshot();
|
||||
},
|
||||
timeout
|
||||
);
|
||||
});
|
||||
|
|
|
@ -14,6 +14,7 @@ Object {
|
|||
"<repoRoot>/packages/kbn-pm/src/utils/bar/bin/bar.js",
|
||||
],
|
||||
],
|
||||
"isSymlink": Array [],
|
||||
"mkdirp": Array [],
|
||||
"readFile": Array [],
|
||||
"unlink": Array [],
|
||||
|
@ -54,6 +55,7 @@ Object {
|
|||
"<repoRoot>/packages/kbn-pm/src/utils/bar/bin/bar.js",
|
||||
],
|
||||
],
|
||||
"isSymlink": Array [],
|
||||
"mkdirp": Array [
|
||||
Array [
|
||||
"<repoRoot>/packages/kbn-pm/src/utils/foo/node_modules/.bin",
|
||||
|
|
|
@ -33,8 +33,8 @@ function generateColors() {
|
|||
|
||||
export function spawn(command: string, args: string[], opts: execa.Options) {
|
||||
return execa(command, args, {
|
||||
...opts,
|
||||
stdio: 'inherit',
|
||||
...opts,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -47,8 +47,8 @@ export function spawnStreaming(
|
|||
{ prefix }: { prefix: string }
|
||||
) {
|
||||
const spawned = execa(command, args, {
|
||||
...opts,
|
||||
stdio: ['ignore', 'pipe', 'pipe'],
|
||||
...opts,
|
||||
});
|
||||
|
||||
const color = nextColor();
|
||||
|
|
|
@ -24,7 +24,7 @@ import { ncp } from 'ncp';
|
|||
import { dirname, relative } from 'path';
|
||||
import { promisify } from 'util';
|
||||
|
||||
const stat = promisify(fs.stat);
|
||||
const lstat = promisify(fs.lstat);
|
||||
const readFile = promisify(fs.readFile);
|
||||
const symlink = promisify(fs.symlink);
|
||||
const chmod = promisify(fs.chmod);
|
||||
|
@ -37,7 +37,7 @@ export { chmod, readFile, mkdirp };
|
|||
|
||||
async function statTest(path: string, block: (stats: fs.Stats) => boolean) {
|
||||
try {
|
||||
return block(await stat(path));
|
||||
return block(await lstat(path));
|
||||
} catch (e) {
|
||||
if (e.code === 'ENOENT') {
|
||||
return false;
|
||||
|
@ -46,6 +46,14 @@ async function statTest(path: string, block: (stats: fs.Stats) => boolean) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a path points to a symlink.
|
||||
* @param path
|
||||
*/
|
||||
export async function isSymlink(path: string) {
|
||||
return await statTest(path, stats => stats.isSymbolicLink());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a path points to a directory.
|
||||
* @param path
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
import fs from 'fs';
|
||||
import { relative, resolve as resolvePath } from 'path';
|
||||
import { inspect } from 'util';
|
||||
|
||||
|
@ -30,11 +31,17 @@ import {
|
|||
isLinkDependency,
|
||||
readPackageJson,
|
||||
} from './package_json';
|
||||
import { installInDir, runScriptInPackage, runScriptInPackageStreaming } from './scripts';
|
||||
import {
|
||||
installInDir,
|
||||
runScriptInPackage,
|
||||
runScriptInPackageStreaming,
|
||||
yarnWorkspacesInfo,
|
||||
} from './scripts';
|
||||
|
||||
interface BuildConfig {
|
||||
skip?: boolean;
|
||||
intermediateBuildDirectory?: string;
|
||||
oss?: boolean;
|
||||
}
|
||||
|
||||
interface CleanConfig {
|
||||
|
@ -190,7 +197,41 @@ export class Project {
|
|||
|
||||
public async installDependencies({ extraArgs }: { extraArgs: string[] }) {
|
||||
log.write(chalk.bold(`\n\nInstalling dependencies in [${chalk.green(this.name)}]:\n`));
|
||||
return installInDir(this.path, extraArgs);
|
||||
await installInDir(this.path, extraArgs);
|
||||
await this.removeExtraneousNodeModules();
|
||||
}
|
||||
|
||||
/**
|
||||
* Yarn workspaces symlinks workspace projects to the root node_modules, even
|
||||
* when there is no depenency on the project. This results in unnecicary, and
|
||||
* often duplicated code in the build archives.
|
||||
*/
|
||||
public async removeExtraneousNodeModules() {
|
||||
// this is only relevant for the root workspace
|
||||
if (!this.isWorkspaceRoot) {
|
||||
return;
|
||||
}
|
||||
|
||||
const workspacesInfo = await yarnWorkspacesInfo(this.path);
|
||||
const unusedWorkspaces = new Set(Object.keys(workspacesInfo));
|
||||
|
||||
// check for any cross-project dependency
|
||||
for (const name of Object.keys(workspacesInfo)) {
|
||||
const workspace = workspacesInfo[name];
|
||||
workspace.workspaceDependencies.forEach(w => unusedWorkspaces.delete(w));
|
||||
}
|
||||
|
||||
unusedWorkspaces.forEach(name => {
|
||||
const { dependencies, devDependencies } = this.json;
|
||||
const nodeModulesPath = resolvePath(this.nodeModulesLocation, name);
|
||||
const isDependency = dependencies && dependencies.hasOwnProperty(name);
|
||||
const isDevDependency = devDependencies && devDependencies.hasOwnProperty(name);
|
||||
|
||||
if (!isDependency && !isDevDependency && fs.existsSync(nodeModulesPath)) {
|
||||
log.write(`No dependency on ${name}, removing link in node_modules`);
|
||||
fs.unlinkSync(nodeModulesPath);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,15 @@
|
|||
import { spawn, spawnStreaming } from './child_process';
|
||||
import { Project } from './project';
|
||||
|
||||
interface WorkspaceInfo {
|
||||
location: string;
|
||||
workspaceDependencies: string[];
|
||||
}
|
||||
|
||||
interface WorkspacesInfo {
|
||||
[s: string]: WorkspaceInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install all dependencies in the given directory
|
||||
*/
|
||||
|
@ -56,3 +65,13 @@ export function runScriptInPackageStreaming(script: string, args: string[], pkg:
|
|||
prefix: pkg.name,
|
||||
});
|
||||
}
|
||||
|
||||
export async function yarnWorkspacesInfo(directory: string): Promise<WorkspacesInfo> {
|
||||
const workspacesInfo = await spawn('yarn', ['workspaces', 'info', '--json'], {
|
||||
cwd: directory,
|
||||
stdio: 'pipe',
|
||||
});
|
||||
|
||||
const stdout = JSON.parse(workspacesInfo.stdout);
|
||||
return JSON.parse(stdout.data);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import path from 'path';
|
|||
import { promisify } from 'util';
|
||||
|
||||
import { getProjectPaths } from '../config';
|
||||
import { copyDirectory, unlink } from './fs';
|
||||
import { copyDirectory, isSymlink, unlink } from './fs';
|
||||
import { readPackageJson } from './package_json';
|
||||
import { getProjects } from './projects';
|
||||
|
||||
|
@ -56,29 +56,22 @@ export async function workspacePackagePaths(rootPath: string): Promise<string[]>
|
|||
}
|
||||
|
||||
export async function copyWorkspacePackages(rootPath: string): Promise<void> {
|
||||
const workspaceProjects = await getWorkspaceProjects(rootPath);
|
||||
|
||||
for (const project of workspaceProjects.values()) {
|
||||
const dest = path.resolve(rootPath, 'node_modules', project.name);
|
||||
|
||||
// Remove the symlink
|
||||
await unlink(dest);
|
||||
// Copy in the package
|
||||
await copyDirectory(project.path, dest);
|
||||
}
|
||||
}
|
||||
|
||||
async function getWorkspaceProjects(rootPath: string) {
|
||||
const projectPaths = getProjectPaths(rootPath, {});
|
||||
const projects = await getProjects(rootPath, projectPaths);
|
||||
|
||||
for (const [key, project] of projects.entries()) {
|
||||
if (!project.isWorkspaceProject) {
|
||||
projects.delete(key);
|
||||
}
|
||||
}
|
||||
for (const project of projects.values()) {
|
||||
const dest = path.resolve(rootPath, 'node_modules', project.name);
|
||||
|
||||
return projects;
|
||||
if ((await isSymlink(dest)) === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove the symlink
|
||||
await unlink(dest);
|
||||
|
||||
// Copy in the package
|
||||
await copyDirectory(project.path, dest);
|
||||
}
|
||||
}
|
||||
|
||||
function packagesFromGlobPattern({ pattern, rootPath }: { pattern: string; rootPath: string }) {
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import { statSync, lstatSync, realpathSync } from 'fs';
|
||||
import { statSync } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
|
||||
import { fromRoot } from '../../legacy/utils';
|
||||
import { fromRoot, IS_KIBANA_DISTRIBUTABLE } from '../../legacy/utils';
|
||||
import { getConfig } from '../../legacy/server/path';
|
||||
import { bootstrap } from '../../core/server';
|
||||
import { readKeystore } from './read_keystore';
|
||||
|
@ -41,17 +41,6 @@ function canRequire(path) {
|
|||
}
|
||||
}
|
||||
|
||||
function isSymlinkTo(link, dest) {
|
||||
try {
|
||||
const stat = lstatSync(link);
|
||||
return stat.isSymbolicLink() && realpathSync(link) === dest;
|
||||
} catch (error) {
|
||||
if (error.code !== 'ENOENT') {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const CLUSTER_MANAGER_PATH = resolve(__dirname, '../cluster/cluster_manager');
|
||||
const CAN_CLUSTER = canRequire(CLUSTER_MANAGER_PATH);
|
||||
|
||||
|
@ -60,10 +49,8 @@ const CAN_REPL = canRequire(REPL_PATH);
|
|||
|
||||
// xpack is installed in both dev and the distributable, it's optional if
|
||||
// install is a link to the source, not an actual install
|
||||
const XPACK_INSTALLED_DIR = resolve(__dirname, '../../../node_modules/x-pack');
|
||||
const XPACK_SOURCE_DIR = resolve(__dirname, '../../../x-pack');
|
||||
const XPACK_INSTALLED = canRequire(XPACK_INSTALLED_DIR);
|
||||
const XPACK_OPTIONAL = isSymlinkTo(XPACK_INSTALLED_DIR, XPACK_SOURCE_DIR);
|
||||
const XPACK_DIR = resolve(__dirname, '../../../x-pack');
|
||||
const XPACK_INSTALLED = canRequire(XPACK_DIR);
|
||||
|
||||
const pathCollector = function () {
|
||||
const paths = [];
|
||||
|
@ -127,8 +114,8 @@ function applyConfigOverrides(rawConfig, opts, extraCliOptions) {
|
|||
get('plugins.paths'),
|
||||
opts.pluginPath,
|
||||
|
||||
XPACK_INSTALLED && (!XPACK_OPTIONAL || !opts.oss)
|
||||
? [XPACK_INSTALLED_DIR]
|
||||
XPACK_INSTALLED && !opts.oss
|
||||
? [XPACK_DIR]
|
||||
: [],
|
||||
)));
|
||||
|
||||
|
@ -183,7 +170,7 @@ export default function (program) {
|
|||
command.option('--repl', 'Run the server with a REPL prompt and access to the server object');
|
||||
}
|
||||
|
||||
if (XPACK_OPTIONAL) {
|
||||
if (!IS_KIBANA_DISTRIBUTABLE) {
|
||||
command
|
||||
.option('--oss', 'Start Kibana without X-Pack');
|
||||
}
|
||||
|
@ -226,7 +213,7 @@ export default function (program) {
|
|||
},
|
||||
features: {
|
||||
isClusterModeSupported: CAN_CLUSTER,
|
||||
isOssModeSupported: XPACK_OPTIONAL,
|
||||
isOssModeSupported: !IS_KIBANA_DISTRIBUTABLE,
|
||||
isXPackInstalled: XPACK_INSTALLED,
|
||||
isReplModeSupported: CAN_REPL,
|
||||
},
|
||||
|
|
|
@ -17,15 +17,9 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
export function isOSS() {
|
||||
try {
|
||||
require.resolve('x-pack');
|
||||
return false;
|
||||
} catch (error) {
|
||||
if (error.code !== 'MODULE_NOT_FOUND') {
|
||||
throw error;
|
||||
}
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
return true;
|
||||
}
|
||||
export function isOSS() {
|
||||
return !fs.existsSync(path.resolve(__dirname, '../../../x-pack'));
|
||||
}
|
||||
|
|
|
@ -68,13 +68,13 @@ import { mkdirp } from '../lib';
|
|||
*/
|
||||
|
||||
export const BuildPackagesTask = {
|
||||
global: true,
|
||||
description: 'Building distributable versions of packages',
|
||||
async run(config, log, builds) {
|
||||
async run(config, log, build) {
|
||||
await mkdirp(config.resolveFromRepo('target'));
|
||||
await buildProductionProjects({
|
||||
kibanaRoot: config.resolveFromRepo(),
|
||||
buildRoots: builds.map(build => build.resolvePath()),
|
||||
buildRoot: build.resolvePath(),
|
||||
onlyOSS: build.isOss(),
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -40,12 +40,12 @@ export const CleanPackagesTask = {
|
|||
async run(config, log, build) {
|
||||
await deleteAll([
|
||||
build.resolvePath('packages'),
|
||||
build.resolvePath('x-pack'),
|
||||
build.resolvePath('yarn.lock'),
|
||||
], log);
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
export const CleanTypescriptTask = {
|
||||
description:
|
||||
'Cleaning typescript source files that have been transpiled to JS',
|
||||
|
@ -70,103 +70,112 @@ 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
|
||||
}));
|
||||
|
||||
if (!build.isOss()) {
|
||||
log.info('Deleted %d files', await scanDelete({
|
||||
directory: build.resolvePath('x-pack/node_modules'),
|
||||
regularExpressions
|
||||
}));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -194,7 +203,7 @@ export const CleanExtraBrowsersTask = {
|
|||
|
||||
async run(config, log, build) {
|
||||
const getBrowserPathsForPlatform = platform => {
|
||||
const reportingDir = 'node_modules/x-pack/plugins/reporting';
|
||||
const reportingDir = 'x-pack/plugins/reporting';
|
||||
const chromiumDir = '.chromium';
|
||||
const chromiumPath = p =>
|
||||
build.resolvePathForPlatform(platform, reportingDir, chromiumDir, p);
|
||||
|
|
|
@ -27,14 +27,7 @@ export const CreateArchivesSourcesTask = {
|
|||
// copy all files from generic build source directory into platform-specific build directory
|
||||
await scanCopy({
|
||||
source: build.resolvePath(),
|
||||
destination: build.resolvePathForPlatform(platform),
|
||||
filter: record => !(record.isDirectory && record.name === 'node_modules')
|
||||
});
|
||||
|
||||
await scanCopy({
|
||||
source: build.resolvePath('node_modules'),
|
||||
destination: build.resolvePathForPlatform(platform, 'node_modules'),
|
||||
time: new Date()
|
||||
destination: build.resolvePathForPlatform(platform)
|
||||
});
|
||||
|
||||
log.debug('Generic build source copied into', platform.getName(), 'specific build directory');
|
||||
|
|
|
@ -49,7 +49,6 @@ export const CreatePackageJsonTask = {
|
|||
};
|
||||
|
||||
if (build.isOss()) {
|
||||
delete newPkg.dependencies['x-pack'];
|
||||
newPkg.workspaces.packages = newPkg.workspaces.packages.filter(p => !p.startsWith('x-pack'));
|
||||
}
|
||||
|
||||
|
|
|
@ -17,18 +17,25 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { exec } from '../lib';
|
||||
import { Project } from '@kbn/pm';
|
||||
|
||||
export const InstallDependenciesTask = {
|
||||
description: 'Installing node_modules, including production builds of packages',
|
||||
|
||||
async run(config, log, build) {
|
||||
// We're using --no-bin-links to support systems that don't have symlinks.
|
||||
// This is commonly seen in shared folders on virtual machines
|
||||
const args = ['--production', '--ignore-optional', '--frozen-lockfile', '--no-bin-links', '--prefer-offline'];
|
||||
const project = await Project.fromPath(build.resolvePath());
|
||||
|
||||
await exec(log, 'yarn', args, {
|
||||
cwd: build.resolvePath(),
|
||||
await project.installDependencies({
|
||||
extraArgs: [
|
||||
'--production',
|
||||
'--ignore-optional',
|
||||
'--frozen-lockfile',
|
||||
'--prefer-offline',
|
||||
|
||||
// We're using --no-bin-links to support systems that don't have symlinks.
|
||||
// This is commonly seen in shared folders on virtual machines
|
||||
'--no-bin-links',
|
||||
]
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -38,7 +38,7 @@ export const CleanClientModulesOnDLLTask = {
|
|||
`${baseDir}/src/cli`,
|
||||
`${baseDir}/src/cli_keystore`,
|
||||
`${baseDir}/src/cli_plugin`,
|
||||
`${baseDir}/node_modules/x-pack`,
|
||||
`${baseDir}/x-pack`,
|
||||
...kbnWebpackLoaders.map(loader => `${baseDir}/node_modules/${loader}`)
|
||||
];
|
||||
const discoveredLegacyCorePluginEntries = await globby([
|
||||
|
|
|
@ -33,10 +33,7 @@ export async function buildSass({ log, kibanaDir }) {
|
|||
resolve(kibanaDir, 'src/legacy/core_plugins')
|
||||
];
|
||||
|
||||
const paths = [
|
||||
resolve(kibanaDir, 'x-pack'),
|
||||
resolve(kibanaDir, 'node_modules/x-pack')
|
||||
];
|
||||
const paths = [ resolve(kibanaDir, 'x-pack') ];
|
||||
|
||||
const { spec$ } = findPluginSpecs({ plugins: { scanDirs, paths } });
|
||||
const enabledPlugins = await spec$.pipe(toArray()).toPromise();
|
||||
|
|
|
@ -260,17 +260,6 @@ export class DllCompiler {
|
|||
notAllowedModules.push(module.resource);
|
||||
return;
|
||||
}
|
||||
|
||||
// Even when the reason for the module comes from
|
||||
// node_modules directory, assure it's not from
|
||||
// node_modules/x-pack source code but from a real node_module
|
||||
const dirs = reason.module.resource.split(path.sep);
|
||||
const nodeModuleName = dirs[dirs.lastIndexOf('node_modules') + 1];
|
||||
const inXpackSource = nodeModuleName === 'x-pack';
|
||||
|
||||
if (inXpackSource) {
|
||||
notAllowedModules.push(module.resource);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
},
|
||||
"kibana": {
|
||||
"build": {
|
||||
"intermediateBuildDirectory": "build/plugin/kibana/x-pack"
|
||||
"intermediateBuildDirectory": "build/plugin/kibana/x-pack",
|
||||
"oss": false
|
||||
}
|
||||
},
|
||||
"resolutions": {
|
||||
|
@ -29,6 +30,7 @@
|
|||
"@kbn/es": "1.0.0",
|
||||
"@kbn/expect": "1.0.0",
|
||||
"@kbn/plugin-helpers": "9.0.2",
|
||||
"@kbn/pm": "1.0.0",
|
||||
"@kbn/test": "1.0.0",
|
||||
"@storybook/addon-actions": "^5.0.5",
|
||||
"@storybook/addon-console": "^1.1.0",
|
||||
|
|
|
@ -41,7 +41,6 @@ export default (gulp, { buildTarget }) => {
|
|||
buildRoot
|
||||
);
|
||||
await del(resolve(buildRoot, 'x-pack'));
|
||||
//#
|
||||
|
||||
const log = new ToolingLog({
|
||||
level: 'info',
|
||||
|
|
|
@ -10,7 +10,7 @@ type Licenses = 'oss' | 'basic' | 'gold' | 'trial';
|
|||
|
||||
export const TestKbnServerConfig = {
|
||||
kbn: {
|
||||
plugins: { paths: [resolve(__dirname, '../../node_modules/x-pack')] },
|
||||
plugins: { paths: [resolve(__dirname, '../../x-pack')] },
|
||||
xpack: {
|
||||
monitoring: {
|
||||
tests: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue