@@ -63,7 +63,7 @@ export class Base {
6363 commandArgs ,
6464 { cwd : cwdDir ? cwdDir : process . cwd ( ) }
6565 ) ;
66- const stderrWords = child . stderr ? _ . words ( child . stderr . toString ( ) ) . filter ( ( word :string ) => word ) : [ ] ;
66+ const stderrWords = child . stderr ? _ . words ( child . stderr . toString ( ) ) . filter ( ( word : string ) => word ) : [ ] ;
6767 if ( child . status === 1 || child . status === '1' || stderrWords . length > 0 ) {
6868 this . log ( 'commandRunner' ) . error ( 'status' , child . status ) ;
6969 this . log ( 'commandRunner' ) . error ( 'stderr' , child . stderr . toString ( ) ) ;
@@ -86,6 +86,7 @@ export class Base {
8686 }
8787 this . log ( 'clear' ) . debug ( folder ) ;
8888 const commandString = './node_modules/.bin/del-cli ' +
89+ path . resolve ( folder + '/src/package-lock.json' ) + ' ' +
8990 path . resolve ( folder + '/src/node_modules' ) + ' ' +
9091 path . resolve ( folder + '/dist' ) + ' ' +
9192 path . resolve ( folder + '/.tmp' ) + ' --force' ;
@@ -106,7 +107,7 @@ export class Base {
106107 folder = customOptions . srcFolder ;
107108 }
108109 this . log ( 'build' ) . debug ( folder ) ;
109-
110+
110111 const commandString = 'ng-packagr -p ' + folder + '/ng-package.json' ;
111112 if ( ! fsExtra . existsSync ( folder ) ) {
112113 this . log ( 'build' ) . debug ( commandString ) ;
@@ -118,12 +119,13 @@ export class Base {
118119 this . log ( 'build' ) . debug ( 'end' ) ;
119120 return result ;
120121 }
121- async link ( customOptions ?: { folder ?: string , srcFolder ?: string } ) {
122+ async link ( customOptions ?: { folder ?: string , srcFolder ?: string , rootPackagePath ?: string , distPackagePath ?: string } ) {
122123 this . log ( 'link' ) . debug ( 'start' ) ;
123124 const items = [
124125 await this . linkNpmClear ( customOptions ) ,
125126 await this . linkDist ( customOptions ) ,
126- await this . linkNpmClear ( customOptions )
127+ await this . linkNpmClear ( customOptions ) ,
128+ await this . updateDependencies ( customOptions ) ,
127129 ] ;
128130 this . log ( 'link' ) . debug ( 'end' ) ;
129131 return items . reduce ( ( all : boolean , current : boolean ) => { return all && current ; } , true ) ;
@@ -182,6 +184,8 @@ export class Base {
182184 }
183185 this . log ( 'linkNpmClear' ) . debug ( folder ) ;
184186 const commandString = './node_modules/.bin/del-cli ' +
187+ path . resolve ( folder + '/src/package-lock.json' ) + ' ' +
188+ path . resolve ( folder + '/dist/package-lock.json' ) + ' ' +
185189 path . resolve ( folder + '/src/node_modules' ) + ' ' +
186190 path . resolve ( folder + '/dist/node_modules' ) + ' --force' ;
187191 if ( ! fsExtra . existsSync ( folder ) ) {
@@ -222,6 +226,45 @@ export class Base {
222226 this . log ( 'changeVersion' ) . debug ( 'end' ) ;
223227 return await true ;
224228 }
229+ async updateDependencies ( customOptions ?: { rootPackagePath ?: string , distPackagePath ?: string } ) {
230+ this . log ( 'updateDependencies' ) . debug ( 'start' ) ;
231+ let rootPackagePath = path . resolve ( this . rootFolder + '/package.json' ) ;
232+ let distPackagePath = path . resolve ( this . folder + '/dist/package.json' ) ;
233+ if ( customOptions && customOptions . rootPackagePath ) {
234+ rootPackagePath = customOptions . rootPackagePath ;
235+ }
236+ if ( customOptions && customOptions . distPackagePath ) {
237+ distPackagePath = customOptions . distPackagePath ;
238+ }
239+
240+ let rootPackage : any = null ;
241+ let distPackage : any = null ;
242+
243+ if ( fsExtra . existsSync ( rootPackagePath ) ) {
244+ rootPackage = fsExtra . readJSONSync ( rootPackagePath ) ;
245+ }
246+ if ( fsExtra . existsSync ( distPackagePath ) ) {
247+ distPackage = fsExtra . readJSONSync ( distPackagePath ) ;
248+ }
249+ if ( rootPackage && distPackage ) {
250+ for ( let key in rootPackage ) {
251+ if ( key . toLowerCase ( ) . indexOf ( 'dependencies' ) !== - 1 ) {
252+ let dependencies = rootPackage [ key ] ;
253+ if ( distPackage [ key ] ) {
254+ for ( let devKey in dependencies ) {
255+ if ( distPackage [ key ] [ devKey ] === '*' ) {
256+ distPackage [ key ] [ devKey ] = dependencies [ devKey ] ;
257+ }
258+ }
259+ }
260+ }
261+ }
262+ fsExtra . writeJSONSync ( distPackagePath , distPackage , { spaces : 4 } ) ;
263+ this . log ( 'updateDependencies' ) . debug ( 'writeJSONSync' ) ;
264+ }
265+ this . log ( 'updateDependencies' ) . debug ( 'end' ) ;
266+ return await true ;
267+ }
225268 async extractTranslate ( customOptions ?: { srcFolder ?: string } ) {
226269 this . log ( 'extractTranslate' ) . debug ( 'start' ) ;
227270 let folder = path . resolve ( this . folder + '/src' ) ;
0 commit comments