5
5
const { exec} = require ( 'child-process-promise' ) ;
6
6
const { existsSync} = require ( 'fs' ) ;
7
7
const { join} = require ( 'path' ) ;
8
- const { logPromise} = require ( '../utils' ) ;
8
+ const { execRead , logPromise} = require ( '../utils' ) ;
9
9
const theme = require ( '../theme' ) ;
10
10
11
11
const run = async ( { cwd, local, packages, version} ) => {
@@ -31,7 +31,24 @@ const run = async ({cwd, local, packages, version}) => {
31
31
// Checkout canary release from NPM for all local packages
32
32
for ( let i = 0 ; i < packages . length ; i ++ ) {
33
33
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} ) ;
35
52
}
36
53
} ;
37
54
0 commit comments