Skip to content

fix(@angular/cli): improve --prod deprecation warning #20818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions packages/angular/cli/models/architect-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export interface ArchitectCommandOptions extends BaseCommandOptions {
}

export abstract class ArchitectCommand<
T extends ArchitectCommandOptions = ArchitectCommandOptions
T extends ArchitectCommandOptions = ArchitectCommandOptions,
> extends Command<T> {
protected _architect!: Architect;
protected _architectHost!: WorkspaceNodeModulesArchitectHost;
Expand Down Expand Up @@ -238,7 +238,7 @@ export abstract class ArchitectCommand<
}

await this.reportAnalytics([this.description.name], {
...(((await this._architectHost.getOptionsForTarget(target)) as unknown) as T),
...((await this._architectHost.getOptionsForTarget(target)) as unknown as T),
...overrides,
});

Expand Down Expand Up @@ -344,11 +344,18 @@ export abstract class ArchitectCommand<
project = commandOptions.project;
target = this.target;
if (commandOptions.prod) {
// The --prod flag will always be the first configuration, available to be overwritten
// by following configurations.
const defaultConfig =
project &&
target &&
this.workspace?.projects.get(project)?.targets.get(target)?.defaultConfiguration;

this.logger.warn(
'Option "--prod" is deprecated: Use "--configuration production" instead.',
defaultConfig === 'production'
? 'Option "--prod" is deprecated: No need to use this option as this builder defaults to configuration "production".'
: 'Option "--prod" is deprecated: Use "--configuration production" instead.',
);
// The --prod flag will always be the first configuration, available to be overwritten
// by following configurations.
configuration = 'production';
}
if (commandOptions.configuration) {
Expand Down