6
6
* Side Public License, v 1.
7
7
*/
8
8
9
- import { sep } from 'path' ;
9
+ import { resolve , sep } from 'path' ;
10
10
import { linkProjectExecutables } from '../utils/link_project_executables' ;
11
11
import { log } from '../utils/log' ;
12
12
import { parallelizeBatches } from '../utils/parallelize' ;
@@ -17,7 +17,7 @@ import { getAllChecksums } from '../utils/project_checksums';
17
17
import { BootstrapCacheFile } from '../utils/bootstrap_cache_file' ;
18
18
import { readYarnLock } from '../utils/yarn_lock' ;
19
19
import { validateDependencies } from '../utils/validate_dependencies' ;
20
- import { installBazelTools , runBazel } from '../utils/bazel' ;
20
+ import { ensureYarnIntegrityFileExists , installBazelTools , runBazel } from '../utils/bazel' ;
21
21
22
22
export const BootstrapCommand : ICommand = {
23
23
description : 'Install dependencies and crosslink projects' ,
@@ -26,12 +26,36 @@ export const BootstrapCommand: ICommand = {
26
26
async run ( projects , projectGraph , { options, kbn, rootPath } ) {
27
27
const nonBazelProjectsOnly = await getNonBazelProjectsOnly ( projects ) ;
28
28
const batchedNonBazelProjects = topologicallyBatchProjects ( nonBazelProjectsOnly , projectGraph ) ;
29
- const kibanaProjectPath = projects . get ( 'kibana' ) ?. path ;
29
+ const kibanaProjectPath = projects . get ( 'kibana' ) ?. path || '' ;
30
+ const runOffline = options ?. offline === true ;
31
+ const forceInstall = ! ! options && options [ 'force-install' ] === true ;
32
+
33
+ // Ensure we have a `node_modules/.yarn-integrity` file as we depend on it
34
+ // for bazel to know it has to re-install the node_modules after a reset or a clean
35
+ await ensureYarnIntegrityFileExists ( resolve ( kibanaProjectPath , 'node_modules' ) ) ;
30
36
31
37
// Install bazel machinery tools if needed
32
38
await installBazelTools ( rootPath ) ;
33
39
34
- // Install monorepo npm dependencies
40
+ // Bootstrap process for Bazel packages
41
+ // Bazel is now managing dependencies so yarn install
42
+ // will happen as part of this
43
+ //
44
+ // NOTE: Bazel projects will be introduced incrementally
45
+ // And should begin from the ones with none dependencies forward.
46
+ // That way non bazel projects could depend on bazel projects but not the other way around
47
+ // That is only intended during the migration process while non Bazel projects are not removed at all.
48
+ //
49
+ // Until we have our first package build within Bazel we will always need to directly call the yarn rule
50
+ // otherwise yarn install won't trigger as we don't have any npm dependency within Bazel
51
+ // TODO: Change CLI default in order to not force install as soon as we have our first Bazel package being built
52
+ if ( forceInstall ) {
53
+ await runBazel ( [ 'run' , '@nodejs//:yarn' ] , runOffline ) ;
54
+ }
55
+
56
+ await runBazel ( [ 'build' , '//packages:build' ] , runOffline ) ;
57
+
58
+ // Install monorepo npm dependencies outside of the Bazel managed ones
35
59
for ( const batch of batchedNonBazelProjects ) {
36
60
for ( const project of batch ) {
37
61
const isExternalPlugin = project . path . includes ( `${ kibanaProjectPath } ${ sep } plugins` ) ;
@@ -40,12 +64,16 @@ export const BootstrapCommand: ICommand = {
40
64
continue ;
41
65
}
42
66
43
- if ( project . isSinglePackageJsonProject || isExternalPlugin ) {
67
+ if ( isExternalPlugin ) {
44
68
await project . installDependencies ( ) ;
45
69
continue ;
46
70
}
47
71
48
- if ( ! project . isEveryDependencyLocal ( ) && ! isExternalPlugin ) {
72
+ if (
73
+ ! project . isSinglePackageJsonProject &&
74
+ ! project . isEveryDependencyLocal ( ) &&
75
+ ! isExternalPlugin
76
+ ) {
49
77
throw new Error (
50
78
`[${ project . name } ] is not eligible to hold non local dependencies. Move the non local dependencies into the top level package.json.`
51
79
) ;
@@ -61,15 +89,9 @@ export const BootstrapCommand: ICommand = {
61
89
62
90
// Assure all kbn projects with bin defined scripts
63
91
// copy those scripts into the top level node_modules folder
64
- await linkProjectExecutables ( projects , projectGraph ) ;
65
-
66
- // Bootstrap process for Bazel packages
67
92
//
68
- // NOTE: Bazel projects will be introduced incrementally
69
- // And should begin from the ones with none dependencies forward.
70
- // That way non bazel projects could depend on bazel projects but not the other way around
71
- // That is only intended during the migration process while non Bazel projects are not removed at all.
72
- await runBazel ( [ 'build' , '//packages:build' ] ) ;
93
+ // NOTE: We don't probably need this anymore, is actually not being used
94
+ await linkProjectExecutables ( projects , projectGraph ) ;
73
95
74
96
// Bootstrap process for non Bazel packages
75
97
/**
0 commit comments