-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[7.17] chore(NA): auto bootstrap after removing node modules manually (…
…#134961) (#134969) * chore(NA): auto bootstrap after removing node modules manually (#134961) * chore(NA): mechanism for autobootstrap when manually removing node_modules * fix(NA): check folders with isDirectory * fix(NA): check folders with isDirectory * fix(NA): check folders with isDirectory * docs(NA): update typo on code comment (cherry picked from commit 9a1e1d0) # Conflicts: # packages/kbn-pm/dist/index.js # packages/kbn-pm/src/commands/bootstrap.ts # packages/kbn-pm/src/utils/bazel/index.ts * update kbn/pm dist * refact(NA): missing comma Co-authored-by: spalger <[email protected]>
- Loading branch information
Showing
5 changed files
with
96 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { join, resolve } from 'path'; | ||
import { isDirectory, isFile, tryRealpath, unlink } from '../fs'; | ||
|
||
// yarn integrity file checker | ||
export async function removeYarnIntegrityFileIfExists(nodeModulesPath: string) { | ||
try { | ||
const nodeModulesRealPath = await tryRealpath(nodeModulesPath); | ||
const yarnIntegrityFilePath = join(nodeModulesRealPath, '.yarn-integrity'); | ||
|
||
// check if the file exists and delete it in that case | ||
if (await isFile(yarnIntegrityFilePath)) { | ||
await unlink(yarnIntegrityFilePath); | ||
} | ||
} catch { | ||
// no-op | ||
} | ||
} | ||
|
||
// yarn and bazel integration checkers | ||
async function areNodeModulesPresent(kbnRootPath: string) { | ||
try { | ||
return await isDirectory(resolve(kbnRootPath, 'node_modules')); | ||
} catch { | ||
return false; | ||
} | ||
} | ||
|
||
async function haveBazelFoldersBeenCreatedBefore(kbnRootPath: string) { | ||
try { | ||
return ( | ||
(await isDirectory(resolve(kbnRootPath, 'bazel-bin', 'packages'))) || | ||
(await isDirectory(resolve(kbnRootPath, 'bazel-kibana', 'packages'))) || | ||
(await isDirectory(resolve(kbnRootPath, 'bazel-out', 'host'))) | ||
); | ||
} catch { | ||
return false; | ||
} | ||
} | ||
|
||
export async function haveNodeModulesBeenManuallyDeleted(kbnRootPath: string) { | ||
return ( | ||
!(await areNodeModulesPresent(kbnRootPath)) && | ||
(await haveBazelFoldersBeenCreatedBefore(kbnRootPath)) | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.