feat(dev-infra): add support for determining if builds should be stamped (#42319)
Add support for the build process to determine if the generated builds should be stamped for release. PR Close #42319
This commit is contained in:
parent
9f50495f28
commit
f424aa3f0f
|
@ -704,15 +704,15 @@ function getReleaseConfig(config = getConfig()) {
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
// Start the release package building.
|
||||
main();
|
||||
main(process.argv[2] === 'true');
|
||||
/** Main function for building the release packages. */
|
||||
function main() {
|
||||
function main(stampForRelease) {
|
||||
return tslib.__awaiter(this, void 0, void 0, function* () {
|
||||
if (process.send === undefined) {
|
||||
throw Error('This script needs to be invoked as a NodeJS worker.');
|
||||
}
|
||||
const config = getReleaseConfig();
|
||||
const builtPackages = yield config.buildPackages();
|
||||
const builtPackages = yield config.buildPackages(stampForRelease);
|
||||
// Transfer the built packages back to the parent process.
|
||||
process.send(builtPackages);
|
||||
});
|
||||
|
|
|
@ -16,16 +16,16 @@
|
|||
import {getReleaseConfig} from '../config/index';
|
||||
|
||||
// Start the release package building.
|
||||
main();
|
||||
main(process.argv[2] === 'true');
|
||||
|
||||
/** Main function for building the release packages. */
|
||||
async function main() {
|
||||
async function main(stampForRelease: boolean) {
|
||||
if (process.send === undefined) {
|
||||
throw Error('This script needs to be invoked as a NodeJS worker.');
|
||||
}
|
||||
|
||||
const config = getReleaseConfig();
|
||||
const builtPackages = await config.buildPackages();
|
||||
const builtPackages = await config.buildPackages(stampForRelease);
|
||||
|
||||
// Transfer the built packages back to the parent process.
|
||||
process.send(builtPackages);
|
||||
|
|
|
@ -33,7 +33,7 @@ describe('ng-dev release build', () => {
|
|||
async function invokeBuild({json}: {json?: boolean} = {}) {
|
||||
spyOn(releaseConfig, 'getReleaseConfig')
|
||||
.and.returnValue({npmPackages, buildPackages, releaseNotes: {}});
|
||||
await ReleaseBuildCommandModule.handler({json: !!json, $0: '', _: []});
|
||||
await ReleaseBuildCommandModule.handler({json: !!json, stampForRelease: true, $0: '', _: []});
|
||||
}
|
||||
|
||||
it('should invoke configured build packages function', async () => {
|
||||
|
|
|
@ -17,21 +17,28 @@ import {buildReleaseOutput} from './index';
|
|||
/** Command line options for building a release. */
|
||||
export interface ReleaseBuildOptions {
|
||||
json: boolean;
|
||||
stampForRelease: boolean;
|
||||
}
|
||||
|
||||
/** Yargs command builder for configuring the `ng-dev release build` command. */
|
||||
function builder(argv: Argv): Argv<ReleaseBuildOptions> {
|
||||
return argv.option('json', {
|
||||
type: 'boolean',
|
||||
description: 'Whether the built packages should be printed to stdout as JSON.',
|
||||
default: false,
|
||||
});
|
||||
return argv
|
||||
.option('json', {
|
||||
type: 'boolean',
|
||||
description: 'Whether the built packages should be printed to stdout as JSON.',
|
||||
default: false,
|
||||
})
|
||||
.option('stampForRelease', {
|
||||
type: 'boolean',
|
||||
description: 'Whether the built packages should be stamped for release.',
|
||||
default: false,
|
||||
});
|
||||
}
|
||||
|
||||
/** Yargs command handler for building a release. */
|
||||
async function handler(args: Arguments<ReleaseBuildOptions>) {
|
||||
const {npmPackages} = getReleaseConfig();
|
||||
let builtPackages = await buildReleaseOutput();
|
||||
let builtPackages = await buildReleaseOutput(args.stampForRelease);
|
||||
|
||||
// If package building failed, print an error and exit with an error code.
|
||||
if (builtPackages === null) {
|
||||
|
|
|
@ -16,9 +16,10 @@ import {BuiltPackage} from '../config/index';
|
|||
* pollute the stdout in such cases, we launch a child process for building the release packages
|
||||
* and redirect all stdout output to the stderr channel (which can be read in the terminal).
|
||||
*/
|
||||
export async function buildReleaseOutput(): Promise<BuiltPackage[]|null> {
|
||||
export async function buildReleaseOutput(stampForRelease: boolean = false):
|
||||
Promise<BuiltPackage[]|null> {
|
||||
return new Promise(resolve => {
|
||||
const buildProcess = fork(require.resolve('./build-worker'), [], {
|
||||
const buildProcess = fork(require.resolve('./build-worker'), [`${stampForRelease}`], {
|
||||
// The stdio option is set to redirect any "stdout" output directly to the "stderr" file
|
||||
// descriptor. An additional "ipc" file descriptor is created to support communication with
|
||||
// the build process. https://nodejs.org/api/child_process.html#child_process_options_stdio.
|
||||
|
|
|
@ -23,7 +23,7 @@ export interface ReleaseConfig {
|
|||
/** 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. */
|
||||
buildPackages: () => Promise<BuiltPackage[]|null>;
|
||||
buildPackages: (stampForRelease?: boolean) => Promise<BuiltPackage[]|null>;
|
||||
/** The list of github labels to add to the release PRs. */
|
||||
releasePrLabels?: string[];
|
||||
/** Configuration for creating release notes during publishing. */
|
||||
|
|
Loading…
Reference in New Issue