Skip to content
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

feat(@angular/cli): handle string key/value pairs, e.g. --define #28362

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

jkrems
Copy link
Contributor

@jkrems jkrems commented Sep 6, 2024

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

The values of define can only be updated by changing the Angular config file.

Issue Number: #4318 (arguably)

What is the new behavior?

Defines can now be introduced or changed by passing them to the CLI, e.g.:

ng build --define "BUILD_TIME=$(date)"

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

The PR also moves addSchemaOptionsToCommand to be colocated with parseJsonSchemaToOptions. The two functions are tightly coupled and it makes unit testing the schema-to-yargs flow a lot easier.

@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: @angular/cli labels Sep 6, 2024
@jkrems jkrems added the target: minor This PR is targeted for the next minor release label Sep 6, 2024
@jkrems jkrems marked this pull request as draft September 6, 2024 18:41
@jkrems
Copy link
Contributor Author

jkrems commented Sep 6, 2024

Unfortunately it seems like this is currently still not properly triggering usage errors when invalid values are passed. Need to dig a bit more.

@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Sep 6, 2024
@jkrems jkrems marked this pull request as ready for review September 6, 2024 18:59
Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a couple of NITs.

@jkrems jkrems force-pushed the define-flag branch 4 times, most recently from 9727ff8 to 7c1c955 Compare September 9, 2024 17:08
Copy link
Collaborator

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, two minor optional nits.

@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 9, 2024
@jkrems
Copy link
Contributor Author

jkrems commented Sep 9, 2024

Thanks for the review!

@alan-agius4 alan-agius4 merged commit 201b60e into angular:main Sep 9, 2024
30 checks passed
@jkrems jkrems deleted the define-flag branch September 9, 2024 18:04
jkrems added a commit to jkrems/angular-cli that referenced this pull request Sep 11, 2024
We recently introduced the ability to pass object values from the
command line (angular#28362). @clydin noticed that the initial behavior
didn't work well for `--define`: It completely replaced all values
even if just one of multiple defines is specified.

This updates the architect to support merging of object options.
If both the base option (e.g. from `angular.json`) and the override
(e.g. from a CLI `--flag`) are objects, the objects are merged.

See: angular#28362
alan-agius4 pushed a commit that referenced this pull request Sep 12, 2024
We recently introduced the ability to pass object values from the
command line (#28362). @clydin noticed that the initial behavior
didn't work well for `--define`: It completely replaced all values
even if just one of multiple defines is specified.

This updates the architect to support merging of object options.
If both the base option (e.g. from `angular.json`) and the override
(e.g. from a CLI `--flag`) are objects, the objects are merged.

See: #28362
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: @angular/cli detected: feature PR contains a feature commit target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants