@@ -2,43 +2,47 @@ const { execSync } = require('child_process');
2
2
const { readFileSync, symlinkSync, mkdirSync } = require ( 'fs' ) ;
3
3
const path = require ( 'path' ) ;
4
4
5
+ const version = require ( '../../package.json' ) . version ;
6
+
5
7
exports . pre = ( ) => {
6
8
if ( process . env . CLI_TEST ) {
7
9
console . error ( `CLI_TEST=1` ) ;
8
10
}
9
11
} ;
10
12
11
13
exports . post = ( ) => {
12
- const deps = [ '@aws-cdk/core' , '@aws-cdk/cx-api' , 'cdk8s' ] ;
13
- const devDeps = [ 'cdk8s-cli' , '@types/node' ] ;
14
-
15
- deps . forEach ( d => installDep ( d ) ) ;
16
- devDeps . forEach ( d => installDep ( d , true ) ) ;
14
+ installDeps ( [ '@aws-cdk/core' , '@aws-cdk/cx-api' , `cdk8s@^${ version } ` ] ) ;
15
+ installDeps ( [ `cdk8s-cli@^${ version } ` , '@types/node' ] , true ) ;
17
16
18
17
// build to make sure all is good
19
18
execSync ( 'yarn build' , { stdio : 'inherit' } ) ;
20
19
21
- console . log ( readFileSync ( './help.txt ' , 'utf-8' ) ) ;
20
+ console . log ( readFileSync ( './help' , 'utf-8' ) ) ;
22
21
} ;
23
22
24
- function installDep ( dep , isDev ) {
25
-
23
+ function installDeps ( deps , isDev ) {
26
24
// if we are in a CLI test, install the dependency from the local repo instead
27
25
// of from the public registry.
28
26
if ( process . env . CLI_TEST ) {
29
- installLocalDep ( dep ) ;
27
+ for ( const dep of deps ) {
28
+ installLocalDep ( dep ) ;
29
+ }
30
30
return ;
31
31
}
32
32
33
33
const devDep = isDev ? '-D' : '' ;
34
- execSync ( `yarn add ${ devDep } ${ dep } ` , { stdio : 'inherit' } ) ;
34
+ execSync ( `yarn add ${ devDep } ${ deps . join ( ' ' ) } ` , { stdio : 'inherit' } ) ;
35
35
}
36
36
37
- function installLocalDep ( dep ) {
37
+ function installLocalDep ( depWithVer ) {
38
+ const dep = depWithVer . split ( '@' ) [ 0 ] ;
39
+
38
40
const pkgfile = require . resolve ( `${ dep } /package.json` ) ;
39
41
const target = path . dirname ( pkgfile ) ;
40
42
const source = path . join ( 'node_modules' , dep ) ;
41
43
mkdirSync ( path . dirname ( source ) , { recursive : true } ) ;
44
+
45
+ console . error ( `symlinking: ${ source } => ${ target } ` ) ;
42
46
symlinkSync ( target , source ) ;
43
47
44
48
const pkg = JSON . parse ( readFileSync ( pkgfile , 'utf-8' ) ) ;
@@ -49,6 +53,7 @@ function installLocalDep(dep) {
49
53
const binsource = path . join ( localbin , program ) ;
50
54
const bintarget = path . join ( target , relpath ) ;
51
55
56
+ console . error ( `symlinking: ${ binsource } => ${ binsource } ` ) ;
52
57
symlinkSync ( bintarget , binsource ) ;
53
58
}
54
59
}
0 commit comments