feat(dev-infra): add release command for setting NPM dist tag (#38656)

Introduces a new command for `ng-dev release`, so that the NPM
dist tag can be set for all configured NPM packages. This command
can be useful in case a manual tag needs to be set, but it is
primarily used by the release tooling when a new stable version
is cut, and when the previous patch branch needs to be set as LTS
version through a `v{major}-lts` dist tag.

It is necessary to have this as a command so that the release tool
can execute it for old branches where other packages might have been
configured. This is similar to the separate `ng-dev build` command
that we created.

Note that we also added logic for spawning a process conveniently
with different "console output" modes. This will be useful for
other command invocations in the release tool and it's generally
better than directly using native `child_process` as that one doesn't
log to the dev-infra debug log file.

PR Close #38656
This commit is contained in:
Paul Gschwendtner
2020-09-09 14:56:58 +02:00
committed by Alex Rickabaugh
parent ea141f86d3
commit 3d9ebb4a52
7 changed files with 304 additions and 0 deletions

View File

@ -0,0 +1,24 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import * as semver from 'semver';
import {spawnWithDebugOutput} from '../../utils/child-process';
/**
* Sets the NPM tag to the specified version for the given package.
* @throws With the process log output if the tagging failed.
*/
export async function setNpmTagForPackage(
packageName: string, distTag: string, version: semver.SemVer, registryUrl: string|undefined) {
const args = ['dist-tag', 'add', `${packageName}@${version}`, distTag];
// If a custom registry URL has been specified, add the `--registry` flag.
if (registryUrl !== undefined) {
args.push('--registry', registryUrl);
}
await spawnWithDebugOutput('npm', args, {mode: 'silent'});
}