66 * found in the LICENSE file at https://angular.io/license
77 */
88
9- // tslint:disable: no-implicit-dependencies
9+ // tslint:disable: no-implicit-dependencies we import @angular-devkit/core but
10+ // it is not in package.json, which is fine, this is just a script.
1011
1112import { logging } from '@angular-devkit/core' ;
1213import { execSync } from 'child_process' ;
1314import { packages , stableToExperimentalVersion } from '../lib/packages' ;
1415
1516interface DistTagOptions {
1617 /**
17- * Version must be specified in format d+.d+.d+ where d is a 0-9 digit.
18- * This must be a stable version with major version > 0.
19- * The script will automatically convert stable version to experimental.
18+ * The version of CLI packages published to NPM.
19+ * Version must begin with d+.d+.d+ where d is a 0-9 digit.
20+ * For example, `1.2.3`, `10.0.0-next.0`, or `10.0.0-rc.0`.
21+ * Since we publish both stable and experimental packages to NPM, the version
22+ * provided here must be a stable version with major version > 0.
23+ * The script will automatically convert stable version to experimental for
24+ * experimental packages.
2025 */
2126 version : string ;
2227 /**
2328 * Tag is usually "latest" or "next", but could also be "v10-lts" for example.
2429 */
2530 tag : string ;
31+ /**
32+ * If true, prints the help message.
33+ */
34+ help : boolean ;
2635}
2736
2837/**
2938 * This function adds a tag to all public packages in the CLI repo.
3039 */
3140export default function ( args : DistTagOptions , logger : logging . Logger ) {
41+ if ( args . help ) {
42+ logger . info ( `dist-tag adds a tag to all public packages in the CLI repo.
43+
44+ If the packages already have a tag associated with them, then dist-tag will
45+ retag the packages.
46+
47+ Usage:
48+ --version the version of CLI packages published to NPM.
49+ --tag the tag to add to CLI packages` ) ;
50+
51+ return ;
52+ }
3253 const { version, tag} = args ;
3354 if ( ! version || version . startsWith ( 'v' ) ) {
3455 throw new Error ( 'Version must be specified in format d+.d+.d+' ) ;
3556 }
3657 if ( version . startsWith ( '0' ) ) {
37- throw new Error ( 'Version must be "stable", with major version > 0' ) ;
58+ throw new Error ( `Major version must be > 0, did you mean ${ stableToExperimentalVersion ( version ) } ?` ) ;
3859 }
3960 if ( ! tag ) {
4061 throw new Error ( 'Tag must be non-empty, for example: latest, next, v10-lts, etc' ) ;
@@ -43,7 +64,7 @@ export default function(args: DistTagOptions, logger: logging.Logger) {
4364 for ( const { name, experimental} of publicPackages ) {
4465 const actualVersion = experimental ? stableToExperimentalVersion ( version ) : version ;
4566 // See https://docs.npmjs.com/cli/dist-tag for documentation
46- const cmd = `npm dist-tag add ${ name } @${ actualVersion } ${ tag } ` ;
67+ const cmd = `npm dist-tag add ' ${ name } @${ actualVersion } ' ' ${ tag } ' ` ;
4768 logger . debug ( cmd ) ; // print debug output by specifying --verbose
4869 const output = execSync ( cmd , { encoding : 'utf8' } ) ;
4970 logger . info ( output . trim ( ) ) ;
0 commit comments