fix(NA): use a single step for yarn kbn bootstrap (#128657) (#128673)

* fix(NA): use a single step for yarn kbn bootstrap

* chore(NA): additional error message to warn around new integration

* chore(NA): additional error message to warn around new integration

(cherry picked from commit 7f4735f4d3)

# Conflicts:
#	packages/kbn-pm/dist/index.js
This commit is contained in:
Tiago Costa 2022-03-29 02:11:57 +01:00 committed by GitHub
parent 5938222194
commit 43c67cfe08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 47 deletions

View file

@ -15,7 +15,7 @@ if ! yarn kbn bootstrap; then
rm -rf node_modules
echo "--- yarn install and bootstrap, attempt 2"
yarn kbn bootstrap
yarn kbn bootstrap --force-install
fi
if [[ "$DISABLE_BOOTSTRAP_VALIDATION" != "true" ]]; then

View file

@ -8908,10 +8908,9 @@ const BootstrapCommand = {
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 reporter = _kbn_dev_utils_ci_stats_reporter__WEBPACK_IMPORTED_MODULE_1__["CiStatsReporter"].fromEnv(_utils_log__WEBPACK_IMPORTED_MODULE_2__["log"]);
const timings = []; // Force install is set in case a flag is passed into yarn kbn bootstrap or if the `.yarn-integrity`
// file is not found which will be indicated by the return of yarnIntegrityFileExists.
const timings = []; // Force install is set in case a flag is passed into yarn kbn bootstrap
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'))); // Install bazel machinery tools if needed
const forceInstall = !!options && options['force-install'] === true; // Install bazel machinery tools if needed
await Object(_utils_bazel__WEBPACK_IMPORTED_MODULE_9__["installBazelTools"])(rootPath); // Setup remote cache settings in .bazelrc.cache if needed
@ -52635,8 +52634,6 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var _yarn_integrity__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(527);
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "removeYarnIntegrityFileIfExists", function() { return _yarn_integrity__WEBPACK_IMPORTED_MODULE_3__["removeYarnIntegrityFileIfExists"]; });
/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "yarnIntegrityFileExists", function() { return _yarn_integrity__WEBPACK_IMPORTED_MODULE_3__["yarnIntegrityFileExists"]; });
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
@ -52862,6 +52859,7 @@ async function runBazelCommandWithRunner(bazelCommandRunner, bazelArgs, offline
try {
await bazelProc;
} catch {
_log__WEBPACK_IMPORTED_MODULE_5__["log"].error('HINT: If experiencing problems with node_modules try `yarn kbn bootstrap --force-install` or as last resort `yarn kbn reset && yarn kbn bootstrap`');
throw new _errors__WEBPACK_IMPORTED_MODULE_6__["CliError"](`The bazel command that was running failed to complete.`);
}
@ -59069,7 +59067,6 @@ function observeReadable(readable) {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeYarnIntegrityFileIfExists", function() { return removeYarnIntegrityFileIfExists; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yarnIntegrityFileExists", function() { return yarnIntegrityFileExists; });
/* 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__);
/* harmony import */ var _fs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(231);
@ -59093,19 +59090,6 @@ async function removeYarnIntegrityFileIfExists(nodeModulesPath) {
} catch {// no-op
}
}
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;
}
/***/ }),
/* 528 */

View file

@ -17,12 +17,7 @@ import { ICommand } from './';
import { readYarnLock } from '../utils/yarn_lock';
import { sortPackageJson } from '../utils/sort_package_json';
import { validateDependencies } from '../utils/validate_dependencies';
import {
installBazelTools,
removeYarnIntegrityFileIfExists,
runBazel,
yarnIntegrityFileExists,
} from '../utils/bazel';
import { installBazelTools, removeYarnIntegrityFileIfExists, runBazel } from '../utils/bazel';
import { setupRemoteCache } from '../utils/bazel/setup_remote_cache';
export const BootstrapCommand: ICommand = {
@ -42,11 +37,8 @@ export const BootstrapCommand: ICommand = {
const reporter = CiStatsReporter.fromEnv(log);
const timings = [];
// Force install is set in case a flag is passed into yarn kbn bootstrap 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')));
// Force install is set in case a flag is passed into yarn kbn bootstrap
const forceInstall = !!options && options['force-install'] === true;
// Install bazel machinery tools if needed
await installBazelTools(rootPath);

View file

@ -52,6 +52,9 @@ async function runBazelCommandWithRunner(
try {
await bazelProc;
} catch {
log.error(
'HINT: If experiencing problems with node_modules try `yarn kbn bootstrap --force-install` or as last resort `yarn kbn reset && yarn kbn bootstrap`'
);
throw new CliError(`The bazel command that was running failed to complete.`);
}
await bazelLogs$.toPromise();

View file

@ -22,19 +22,3 @@ export async function removeYarnIntegrityFileIfExists(nodeModulesPath: string) {
// no-op
}
}
export async function yarnIntegrityFileExists(nodeModulesPath: string) {
try {
const nodeModulesRealPath = await tryRealpath(nodeModulesPath);
const yarnIntegrityFilePath = join(nodeModulesRealPath, '.yarn-integrity');
// check if the file already exists
if (await isFile(yarnIntegrityFilePath)) {
return true;
}
} catch {
// no-op
}
return false;
}