Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(NA): moving @elastic/datemath into bazel #94665

Merged
merged 35 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
195f51f
chore(NA): majority of the changes needed to build elastic-datemath w…
mistic Mar 5, 2021
52b6332
chore(NA): add missing bits on elastic-datemath package
mistic Mar 8, 2021
13d0e96
chore(NA): add missing build and watch scripts
mistic Mar 8, 2021
5e3cdeb
chore(NA): remove build scripts for elastic datemah
mistic Mar 8, 2021
45662bc
Merge remote-tracking branch 'upstream/master' into moving-elastic-da…
mistic Mar 15, 2021
9a43d6c
Merge remote-tracking branch 'upstream/master' into moving-elastic-da…
mistic Mar 16, 2021
6b90040
chore(NA): remove typo from build baze production projects logs
mistic Mar 16, 2021
d3f8cb3
chore(NA): force install on CI
mistic Mar 16, 2021
ec0597b
chore(NA): introduce custom preserve symlinks resolver for jest
mistic Mar 16, 2021
4980847
chore(NA): update jest integration snapshot
mistic Mar 16, 2021
e98e6ab
chore(NA): fix build for bazel packages
mistic Mar 16, 2021
32cad6d
chore(NA): correctly copy bazel built packages into final distributab…
mistic Mar 16, 2021
7af6606
chore(NA): update kbn pm dist
mistic Mar 16, 2021
61ef0d6
Merge branch 'master' into moving-elastic-datemath-into-bazel
kibanamachine Mar 16, 2021
bda8356
chore(NA): experimental new logic to handle bazel yarn rule rerun usi…
mistic Mar 17, 2021
8311f56
chore(NA): update snapshots
mistic Mar 17, 2021
dabe406
refact(NA): ensure yarn integrity exists into two methods
mistic Mar 17, 2021
230b90c
chore(NA): merge and solve conflicts with master
mistic Mar 17, 2021
a8b1bfc
Merge branch 'master' into moving-elastic-datemath-into-bazel
kibanamachine Mar 17, 2021
fba92ba
chore(NA): fix ts error
mistic Mar 18, 2021
5971c72
Merge branch 'moving-elastic-datemath-into-bazel' of github.com:misti…
mistic Mar 18, 2021
3c5628c
Merge remote-tracking branch 'upstream/master' into moving-elastic-da…
mistic Mar 18, 2021
47b6113
chore(NA): merge and solve conflicts with master
mistic Mar 18, 2021
87489e0
chore(NA): update snapshots
mistic Mar 18, 2021
b50db87
Merge remote-tracking branch 'upstream/master' into moving-elastic-da…
mistic Mar 22, 2021
7946b25
chore(NA): merge and solve conflicts with master
mistic Mar 31, 2021
b1bc3c1
chore(NA): update elastic-datemath build file to include ts_project rule
mistic Mar 31, 2021
f15204e
chore(NA): update basic optimization test snapshots
mistic Mar 31, 2021
d5ee22d
chore(NA): merge and solve conflicts with master
mistic Mar 31, 2021
8e40699
chore(NA): merge and solve conflicts cherry-pick from #96066
mistic Apr 1, 2021
33d5bf9
chore(NA): update package.json and yarn.lock file
mistic Apr 1, 2021
502d39e
chore(NA): update bazel/bin into bazel-bin on kbn-pm build bazel pack…
mistic Apr 1, 2021
fdc3533
Merge branch 'master' into moving-elastic-datemath-into-bazel
kibanamachine Apr 1, 2021
f7c99a4
chore(NA): merge and solve conflicts with master
mistic Apr 1, 2021
513708d
Merge branch 'moving-elastic-datemath-into-bazel' of github.com:misti…
mistic Apr 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bazelrc.common
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ test:debug --test_output=streamed --test_strategy=exclusive --test_timeout=9999
run:debug --define=VERBOSE_LOGS=1 -- --node_options=--inspect-brk
# The following option will change the build output of certain rules such as terser and may not be desirable in all cases
# It will also output both the repo cache and action cache to a folder inside the repo
build:debug --compilation_mode=dbg --show_result=1 --disk_cache=bazel/disk-cache --repository_cache=bazel/repository-cache
build:debug --compilation_mode=dbg --show_result=1

# Turn off legacy external runfiles
# This prevents accidentally depending on this feature, which Bazel will remove.
Expand Down
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# other packages builds and need to be included as inputs
exports_files(
[
"tsconfig.base.json",
"tsconfig.json",
"package.json"
],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"@elastic/apm-rum": "^5.6.1",
"@elastic/apm-rum-react": "^1.2.5",
"@elastic/charts": "26.1.0",
"@elastic/datemath": "link:packages/elastic-datemath",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath/npm_module",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I like this better than the build target name.

"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.4",
"@elastic/ems-client": "7.12.0",
"@elastic/eui": "31.10.0",
Expand Down Expand Up @@ -441,6 +441,7 @@
"@babel/traverse": "^7.12.12",
"@babel/types": "^7.12.12",
"@bazel/ibazel": "^0.14.0",
"@bazel/typescript": "^3.2.3",
"@cypress/snapshot": "^2.1.7",
"@cypress/webpack-preprocessor": "^5.5.0",
"@elastic/apm-rum": "^5.6.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
# targets so we can build them all at once
filegroup(
name = "build",
srcs = [],
srcs = [
"//packages/elastic-datemath:build"
],
)
3 changes: 2 additions & 1 deletion packages/elastic-datemath/.npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/index.test.js
/jest.config.js
/tsconfig.json
/__tests__
76 changes: 76 additions & 0 deletions packages/elastic-datemath/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library", "pkg_npm")

PKG_BASE_NAME = "elastic-datemath"
PKG_REQUIRE_NAME = "@elastic/datemath"

SOURCE_FILES = [
"src/index.ts",
]

SRCS = SOURCE_FILES

filegroup(
name = "srcs",
srcs = glob(SOURCE_FILES),
)

NPM_MODULE_EXTRA_FILES = [
"package.json",
"README.md",
]

SRC_DEPS = [
"@npm//moment",
]

TYPES_DEPS = [
"@npm//@types/node",
]

DEPS = SRC_DEPS + TYPES_DEPS

ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
],
)

ts_project(
name = "tsc",
srcs = SRCS,
deps = DEPS,
declaration = True,
declaration_map = True,
incremental = True,
out_dir = "target",
source_map = True,
root_dir = "src",
tsconfig = ":tsconfig",
)

js_library(
name = PKG_BASE_NAME,
srcs = [],
deps = [":tsc"] + DEPS,
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

pkg_npm(
name = "npm_module",
srcs = NPM_MODULE_EXTRA_FILES,
deps = [
":%s" % PKG_BASE_NAME,
]
)

filegroup(
name = "build",
srcs = [
":npm_module",
],
visibility = ["//visibility:public"],
)
5 changes: 2 additions & 3 deletions packages/elastic-datemath/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
"license": "Apache-2.0",
"main": "./target/index.js",
"types": "./target/index.d.ts",
"scripts": {
"build": "../../node_modules/.bin/tsc",
"kbn:bootstrap": "yarn build"
"peerDependencies": {
"moment": "^2.24.0"
}
}
4 changes: 2 additions & 2 deletions packages/elastic-datemath/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"incremental": false,
"outDir": "./target",
"declaration": true,
"declarationMap": true,
"outDir": "target",
"rootDir": "src",
"sourceMap": true,
"sourceRoot": "../../../../packages/elastic-datemath/src",
"types": [
Expand Down
69 changes: 53 additions & 16 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ async function run(argv) {
},
default: {
cache: true,
'force-install': true,
'force-install': false,
offline: false,
validate: true
},
Expand Down Expand Up @@ -8910,8 +8910,11 @@ const BootstrapCommand = {
const nonBazelProjectsOnly = await Object(_utils_projects__WEBPACK_IMPORTED_MODULE_4__["getNonBazelProjectsOnly"])(projects);
const batchedNonBazelProjects = Object(_utils_projects__WEBPACK_IMPORTED_MODULE_4__["topologicallyBatchProjects"])(nonBazelProjectsOnly, projectGraph);
const kibanaProjectPath = ((_projects$get = projects.get('kibana')) === null || _projects$get === void 0 ? void 0 : _projects$get.path) || '';
const runOffline = (options === null || options === void 0 ? void 0 : options.offline) === true;
const forceInstall = !!options && options['force-install'] === true; // Ensure we have a `node_modules/.yarn-integrity` file as we depend on it
const runOffline = (options === null || options === void 0 ? void 0 : options.offline) === true; // Force install is set in case a flag is passed or
// if the `.yarn-integrity` file is not found which
// will be indicated by the return of yarnIntegrityFileExists.

const forceInstall = !!options && options['force-install'] === true || !(await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["yarnIntegrityFileExists"])(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(kibanaProjectPath, 'node_modules'))); // Ensure we have a `node_modules/.yarn-integrity` file as we depend on it
// for bazel to know it has to re-install the node_modules after a reset or a clean

await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["ensureYarnIntegrityFileExists"])(Object(path__WEBPACK_IMPORTED_MODULE_0__["resolve"])(kibanaProjectPath, 'node_modules')); // Install bazel machinery tools if needed
Expand All @@ -8925,9 +8928,6 @@ const BootstrapCommand = {
// That way non bazel projects could depend on bazel projects but not the other way around
// That is only intended during the migration process while non Bazel projects are not removed at all.
//
// Until we have our first package build within Bazel we will always need to directly call the yarn rule
// otherwise yarn install won't trigger as we don't have any npm dependency within Bazel
// TODO: Change CLI default in order to not force install as soon as we have our first Bazel package being built

if (forceInstall) {
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["runBazel"])(['run', '@nodejs//:yarn'], runOffline);
Expand Down Expand Up @@ -9105,6 +9105,7 @@ __webpack_require__.r(__webpack_exports__);
/* 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; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tryRealpath", function() { return tryRealpath; });
/* harmony import */ var cmd_shim__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(132);
/* harmony import */ var cmd_shim__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(cmd_shim__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var del__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(143);
Expand Down Expand Up @@ -9137,6 +9138,7 @@ const symlink = Object(util__WEBPACK_IMPORTED_MODULE_5__["promisify"])(fs__WEBPA
const chmod = Object(util__WEBPACK_IMPORTED_MODULE_5__["promisify"])(fs__WEBPACK_IMPORTED_MODULE_2___default.a.chmod);
const cmdShim = Object(util__WEBPACK_IMPORTED_MODULE_5__["promisify"])(cmd_shim__WEBPACK_IMPORTED_MODULE_0___default.a);
const mkdir = Object(util__WEBPACK_IMPORTED_MODULE_5__["promisify"])(fs__WEBPACK_IMPORTED_MODULE_2___default.a.mkdir);
const realpathNative = Object(util__WEBPACK_IMPORTED_MODULE_5__["promisify"])(fs__WEBPACK_IMPORTED_MODULE_2___default.a.realpath.native);
const mkdirp = async path => await mkdir(path, {
recursive: true
});
Expand Down Expand Up @@ -9220,6 +9222,20 @@ async function forceCreate(src, dest, type) {
await symlink(src, dest, type);
}

async function tryRealpath(path) {
let calculatedPath = path;

try {
calculatedPath = await realpathNative(path);
} catch (error) {
if (error.code !== 'ENOENT') {
throw error;
}
}

return calculatedPath;
}

/***/ }),
/* 132 */
/***/ (function(module, exports, __webpack_require__) {
Expand Down Expand Up @@ -22981,11 +22997,11 @@ class Project {

ensureValidProjectDependency(project) {
const relativePathToProject = normalizePath(path__WEBPACK_IMPORTED_MODULE_1___default.a.relative(this.path, project.path));
const relativePathToProjectIfBazelPkg = normalizePath(path__WEBPACK_IMPORTED_MODULE_1___default.a.relative(this.path, `bazel-bin/packages/${path__WEBPACK_IMPORTED_MODULE_1___default.a.basename(project.path)}`));
const relativePathToProjectIfBazelPkg = normalizePath(path__WEBPACK_IMPORTED_MODULE_1___default.a.relative(this.path, `${__dirname}/../../../bazel-bin/packages/${path__WEBPACK_IMPORTED_MODULE_1___default.a.basename(project.path)}/npm_module`));
const versionInPackageJson = this.allDependencies[project.name];
const expectedVersionInPackageJson = `link:${relativePathToProject}`;
const expectedVersionInPackageJsonIfBazelPkg = `link:${relativePathToProjectIfBazelPkg}`; // TODO: after introduce bazel to build all the packages and completely remove the support for kbn packages
// do not allow child projects to hold dependencies
// do not allow child projects to hold dependencies, unless they are meant to be published externally

if (versionInPackageJson === expectedVersionInPackageJson || versionInPackageJson === expectedVersionInPackageJsonIfBazelPkg) {
return;
Expand Down Expand Up @@ -23170,7 +23186,7 @@ function transformDependencies(dependencies = {}) {
}

if (isBazelPackageDependency(depVersion)) {
newDeps[name] = depVersion.replace('link:bazel-bin/', 'file:');
newDeps[name] = depVersion.replace('link:bazel-bin/', 'file:').replace('/npm_module', '');
continue;
}

Expand Down Expand Up @@ -48065,8 +48081,10 @@ function addProjectToTree(tree, pathParts, project) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _ensure_yarn_integrity_exists__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(373);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ensureYarnIntegrityFileExists", function() { return _ensure_yarn_integrity_exists__WEBPACK_IMPORTED_MODULE_0__["ensureYarnIntegrityFileExists"]; });
/* harmony import */ var _yarn_integrity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(373);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "yarnIntegrityFileExists", function() { return _yarn_integrity__WEBPACK_IMPORTED_MODULE_0__["yarnIntegrityFileExists"]; });

/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ensureYarnIntegrityFileExists", function() { return _yarn_integrity__WEBPACK_IMPORTED_MODULE_0__["ensureYarnIntegrityFileExists"]; });

/* harmony import */ var _get_cache_folders__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(374);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "getBazelDiskCacheFolder", function() { return _get_cache_folders__WEBPACK_IMPORTED_MODULE_1__["getBazelDiskCacheFolder"]; });
Expand Down Expand Up @@ -48099,6 +48117,7 @@ __webpack_require__.r(__webpack_exports__);

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yarnIntegrityFileExists", function() { return yarnIntegrityFileExists; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ensureYarnIntegrityFileExists", function() { return ensureYarnIntegrityFileExists; });
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4);
/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__);
Expand All @@ -48112,9 +48131,27 @@ __webpack_require__.r(__webpack_exports__);
*/


async function yarnIntegrityFileExists(nodeModulesPath) {
try {
const nodeModulesRealPath = await Object(_fs__WEBPACK_IMPORTED_MODULE_1__["tryRealpath"])(nodeModulesPath);
const yarnIntegrityFilePath = Object(path__WEBPACK_IMPORTED_MODULE_0__["join"])(nodeModulesRealPath, '.yarn-integrity'); // check if the file already exists

if (await Object(_fs__WEBPACK_IMPORTED_MODULE_1__["isFile"])(yarnIntegrityFilePath)) {
return true;
}
} catch {// no-op
}

return false;
}
async function ensureYarnIntegrityFileExists(nodeModulesPath) {
try {
await Object(_fs__WEBPACK_IMPORTED_MODULE_1__["writeFile"])(Object(path__WEBPACK_IMPORTED_MODULE_0__["join"])(nodeModulesPath, '.yarn-integrity'), '', {
const nodeModulesRealPath = await Object(_fs__WEBPACK_IMPORTED_MODULE_1__["tryRealpath"])(nodeModulesPath);
const yarnIntegrityFilePath = Object(path__WEBPACK_IMPORTED_MODULE_0__["join"])(nodeModulesRealPath, '.yarn-integrity'); // ensure node_modules folder is created

await Object(_fs__WEBPACK_IMPORTED_MODULE_1__["mkdirp"])(nodeModulesRealPath); // write a blank file in case it doesn't exists

await Object(_fs__WEBPACK_IMPORTED_MODULE_1__["writeFile"])(yarnIntegrityFilePath, '', {
flag: 'wx'
});
} catch {// no-op
Expand Down Expand Up @@ -63656,7 +63693,7 @@ async function buildBazelProductionProjects({
const projectNames = [...projects.values()].map(project => project.name);
_utils_log__WEBPACK_IMPORTED_MODULE_6__["log"].info(`Preparing Bazel projects production build for [${projectNames.join(', ')}]`);
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_4__["runBazel"])(['build', '//packages:build']);
_utils_log__WEBPACK_IMPORTED_MODULE_6__["log"].info(`All Bazel projects production builds for [${projectNames.join(', ')}] are complete}]`);
_utils_log__WEBPACK_IMPORTED_MODULE_6__["log"].info(`All Bazel projects production builds for [${projectNames.join(', ')}] are complete`);

for (const project of projects.values()) {
await copyToBuild(project, kibanaRoot, buildRoot);
Expand All @@ -63680,7 +63717,7 @@ async function copyToBuild(project, kibanaRoot, buildRoot) {
const relativeProjectPath = Object(path__WEBPACK_IMPORTED_MODULE_2__["relative"])(kibanaRoot, project.path);
const buildProjectPath = Object(path__WEBPACK_IMPORTED_MODULE_2__["resolve"])(buildRoot, relativeProjectPath);
await cpy__WEBPACK_IMPORTED_MODULE_0___default()(['**/*'], buildProjectPath, {
cwd: Object(path__WEBPACK_IMPORTED_MODULE_2__["join"])(kibanaRoot, 'bazel', 'bin', 'packages', Object(path__WEBPACK_IMPORTED_MODULE_2__["basename"])(buildProjectPath), 'npm_module'),
cwd: Object(path__WEBPACK_IMPORTED_MODULE_2__["join"])(kibanaRoot, 'bazel-bin', 'packages', Object(path__WEBPACK_IMPORTED_MODULE_2__["basename"])(buildProjectPath), 'npm_module'),
dot: true,
onlyFiles: true,
parents: true
Expand All @@ -63702,12 +63739,12 @@ async function applyCorrectPermissions(project, kibanaRoot, buildRoot) {
const buildProjectPath = Object(path__WEBPACK_IMPORTED_MODULE_2__["resolve"])(buildRoot, relativeProjectPath);
const allPluginPaths = await globby__WEBPACK_IMPORTED_MODULE_1___default()([`**/*`], {
onlyFiles: false,
cwd: Object(path__WEBPACK_IMPORTED_MODULE_2__["join"])(kibanaRoot, 'bazel', 'bin', 'packages', Object(path__WEBPACK_IMPORTED_MODULE_2__["basename"])(buildProjectPath), 'npm_module'),
cwd: buildProjectPath,
dot: true
});

for (const pluginPath of allPluginPaths) {
const resolvedPluginPath = Object(path__WEBPACK_IMPORTED_MODULE_2__["resolve"])(buildRoot, pluginPath);
const resolvedPluginPath = Object(path__WEBPACK_IMPORTED_MODULE_2__["resolve"])(buildProjectPath, pluginPath);

if (await Object(_utils_fs__WEBPACK_IMPORTED_MODULE_5__["isFile"])(resolvedPluginPath)) {
await Object(_utils_fs__WEBPACK_IMPORTED_MODULE_5__["chmod"])(resolvedPluginPath, 0o644);
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export async function run(argv: string[]) {
},
default: {
cache: true,
'force-install': true,
'force-install': false,
offline: false,
validate: true,
},
Expand Down
18 changes: 13 additions & 5 deletions packages/kbn-pm/src/commands/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ import { getAllChecksums } from '../utils/project_checksums';
import { BootstrapCacheFile } from '../utils/bootstrap_cache_file';
import { readYarnLock } from '../utils/yarn_lock';
import { validateDependencies } from '../utils/validate_dependencies';
import { ensureYarnIntegrityFileExists, installBazelTools, runBazel } from '../utils/bazel';
import {
ensureYarnIntegrityFileExists,
installBazelTools,
runBazel,
yarnIntegrityFileExists,
} from '../utils/bazel';

export const BootstrapCommand: ICommand = {
description: 'Install dependencies and crosslink projects',
Expand All @@ -33,7 +38,13 @@ export const BootstrapCommand: ICommand = {
const batchedNonBazelProjects = topologicallyBatchProjects(nonBazelProjectsOnly, projectGraph);
const kibanaProjectPath = projects.get('kibana')?.path || '';
const runOffline = options?.offline === true;
const forceInstall = !!options && options['force-install'] === true;

// Force install is set in case a flag is passed or
// if the `.yarn-integrity` file is not found which
// will be indicated by the return of yarnIntegrityFileExists.
const forceInstall =
(!!options && options['force-install'] === true) ||
!(await yarnIntegrityFileExists(resolve(kibanaProjectPath, 'node_modules')));

// Ensure we have a `node_modules/.yarn-integrity` file as we depend on it
// for bazel to know it has to re-install the node_modules after a reset or a clean
Expand All @@ -51,9 +62,6 @@ export const BootstrapCommand: ICommand = {
// That way non bazel projects could depend on bazel projects but not the other way around
// That is only intended during the migration process while non Bazel projects are not removed at all.
//
// Until we have our first package build within Bazel we will always need to directly call the yarn rule
// otherwise yarn install won't trigger as we don't have any npm dependency within Bazel
// TODO: Change CLI default in order to not force install as soon as we have our first Bazel package being built
if (forceInstall) {
await runBazel(['run', '@nodejs//:yarn'], runOffline);
}
Expand Down
Loading