2020-09-09 08:37:38 -04:00
|
|
|
/**
|
|
|
|
* @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 {assertNoErrors, getConfig, NgDevConfig} from '../../utils/config';
|
|
|
|
|
|
|
|
/** Interface describing a built package. */
|
|
|
|
export interface BuiltPackage {
|
|
|
|
/** Name of the package. */
|
|
|
|
name: string;
|
|
|
|
/** Path to the package output directory. */
|
|
|
|
outputPath: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Configuration for staging and publishing a release. */
|
|
|
|
export interface ReleaseConfig {
|
|
|
|
/** Registry URL used for publishing release packages. Defaults to the NPM registry. */
|
|
|
|
publishRegistry?: string;
|
|
|
|
/** List of NPM packages that are published as part of this project. */
|
|
|
|
npmPackages: string[];
|
|
|
|
/** Builds release packages and returns a list of paths pointing to the output. */
|
2021-05-25 12:42:36 -04:00
|
|
|
buildPackages: (stampForRelease?: boolean) => Promise<BuiltPackage[]|null>;
|
2021-01-19 15:37:12 -05:00
|
|
|
/** The list of github labels to add to the release PRs. */
|
|
|
|
releasePrLabels?: string[];
|
2021-04-01 19:28:17 -04:00
|
|
|
/** Configuration for creating release notes during publishing. */
|
2021-04-19 14:58:32 -04:00
|
|
|
releaseNotes: ReleaseNotesConfig;
|
2021-04-01 19:28:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Configuration for creating release notes during publishing. */
|
|
|
|
export interface ReleaseNotesConfig {
|
|
|
|
/** Whether to prompt for and include a release title in the generated release notes. */
|
|
|
|
useReleaseTitle?: boolean;
|
|
|
|
/** List of commit scopes to disclude from generated release notes. */
|
|
|
|
hiddenScopes?: string[];
|
|
|
|
/**
|
|
|
|
* List of commit groups, either {npmScope}/{scope} or {scope}, to use for ordering.
|
|
|
|
*
|
|
|
|
* Each group for the release notes, will appear in the order provided in groupOrder and any other
|
|
|
|
* groups will appear after these groups, sorted by `Array.sort`'s default sorting order.
|
|
|
|
*/
|
|
|
|
groupOrder?: string[];
|
2020-09-09 08:37:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Configuration for releases in the dev-infra configuration. */
|
|
|
|
export type DevInfraReleaseConfig = NgDevConfig<{release: ReleaseConfig}>;
|
|
|
|
|
|
|
|
/** Retrieve and validate the config as `ReleaseConfig`. */
|
|
|
|
export function getReleaseConfig(config: Partial<DevInfraReleaseConfig> = getConfig()):
|
|
|
|
ReleaseConfig {
|
|
|
|
// List of errors encountered validating the config.
|
|
|
|
const errors: string[] = [];
|
|
|
|
|
|
|
|
if (config.release === undefined) {
|
|
|
|
errors.push(`No configuration defined for "release"`);
|
|
|
|
}
|
|
|
|
if (config.release?.npmPackages === undefined) {
|
|
|
|
errors.push(`No "npmPackages" configured for releasing.`);
|
|
|
|
}
|
|
|
|
if (config.release?.buildPackages === undefined) {
|
|
|
|
errors.push(`No "buildPackages" function configured for releasing.`);
|
|
|
|
}
|
2021-04-19 14:58:32 -04:00
|
|
|
if (config.release?.releaseNotes === undefined) {
|
|
|
|
errors.push(`No "releaseNotes" configured for releasing.`);
|
2020-09-09 08:37:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
assertNoErrors(errors);
|
|
|
|
return config.release!;
|
|
|
|
}
|