Skip to content

Commit 8c1614a

Browse files
authored
Tidy up NPM checkout process (#14631)
1 parent 177fb76 commit 8c1614a

File tree

3 files changed

+19
-35
lines changed

3 files changed

+19
-35
lines changed

scripts/release/prepare-stable-commands/check-out-packages.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
const {exec} = require('child-process-promise');
66
const {existsSync} = require('fs');
77
const {join} = require('path');
8-
const {logPromise} = require('../utils');
8+
const {execRead, logPromise} = require('../utils');
99
const theme = require('../theme');
1010

1111
const 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

scripts/release/prepare-stable-commands/prune-package-registry-metadata.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

scripts/release/prepare-stable.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const confirmStableVersionNumbers = require('./prepare-stable-commands/confirm-s
1010
const guessStableVersionNumbers = require('./prepare-stable-commands/guess-stable-version-numbers');
1111
const parseParams = require('./prepare-stable-commands/parse-params');
1212
const printPrereleaseSummary = require('./shared-commands/print-prerelease-summary');
13-
const prunePackageRegistryMetadata = require('./prepare-stable-commands/prune-package-registry-metadata');
1413
const testPackagingFixture = require('./shared-commands/test-packaging-fixture');
1514
const testTracingFixture = require('./shared-commands/test-tracing-fixture');
1615
const updateStableVersionNumbers = require('./prepare-stable-commands/update-stable-version-numbers');
@@ -29,7 +28,6 @@ const run = async () => {
2928
await checkOutPackages(params);
3029
await guessStableVersionNumbers(params, versionsMap);
3130
await confirmStableVersionNumbers(params, versionsMap);
32-
await prunePackageRegistryMetadata(params);
3331
await updateStableVersionNumbers(params, versionsMap);
3432

3533
if (!params.skipTests) {

0 commit comments

Comments
 (0)