55const { exec} = require ( 'child-process-promise' ) ;
66const { existsSync} = require ( 'fs' ) ;
77const { join} = require ( 'path' ) ;
8- const { logPromise} = require ( '../utils' ) ;
8+ const { execRead , logPromise} = require ( '../utils' ) ;
99const theme = require ( '../theme' ) ;
1010
1111const run = async ( { cwd, local, packages, version} ) => {
@@ -31,7 +31,24 @@ const run = async ({cwd, local, packages, version}) => {
3131 // Checkout canary release from NPM for all local packages
3232 for ( let i = 0 ; i < packages . length ; i ++ ) {
3333 const packageName = packages [ i ] ;
34- await exec ( `npm i ${ packageName } @${ version } ` , { cwd : nodeModulesPath } ) ;
34+
35+ // We previously used `npm install` for this,
36+ // but in addition to checking out a lot of transient dependencies that we don't care about–
37+ // the NPM client also added a lot of registry metadata to the package JSONs,
38+ // which we had to remove as a separate step before re-publishing.
39+ // It's easier for us to just download and extract the tarball.
40+ const url = await execRead (
41+ `npm view ${ packageName } @${ version } dist.tarball`
42+ ) ;
43+ const filePath = join ( nodeModulesPath , `${ packageName } .tgz` ) ;
44+ const packagePath = join ( nodeModulesPath , `${ packageName } ` ) ;
45+ const tempPackagePath = join ( nodeModulesPath , 'package' ) ;
46+
47+ // Download packages from NPM and extract them to the expected build locations.
48+ await exec ( `curl ${ url } > ${ filePath } ` , { cwd} ) ;
49+ await exec ( `tar -xvzf ${ filePath } -C ${ nodeModulesPath } ` , { cwd} ) ;
50+ await exec ( `mv ${ tempPackagePath } ${ packagePath } ` , { cwd} ) ;
51+ await exec ( `rm ${ filePath } ` , { cwd} ) ;
3552 }
3653} ;
3754
0 commit comments