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

Add CLI support to set Feature Flag values #9554

Merged
merged 4 commits into from
Mar 1, 2024

Conversation

marcins
Copy link
Contributor

@marcins marcins commented Feb 29, 2024

↪️ Pull Request

Follows up on #9551 and adds support to the CLI to pass featureFlags into InitialParcelOptions.

The approach to this is a single -F or --feature-flag flag that takes a name=value argument. Validation is done to ensure the name is a valid feature flag, and value matches the expected type - at the moment this is either string or boolean, though I'd expect boolean to be the most common.

💻 Examples

parcel build --feature-flag makeItFaster=true src/index.js

🚨 Test instructions

Manually tested to ensure that validation and setting the arguments in InitialParcelOptions works as expected.

✔️ PR Todo

  • Added/updated unit tests for this change
  • Filled out test instructions (In case there aren't any unit tests)
  • Included links to related issues/PRs

@marcins marcins changed the base branch from v2 to mszczepanski/add-feature-flag-system February 29, 2024 02:46
let [name, val] = value.split('=');
if (name in DEFAULT_FEATURE_FLAGS) {
let featureFlagValue;
console.log(typeof DEFAULT_FEATURE_FLAGS[name]);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, accidentally left this in.. 🤦

@@ -103,6 +104,30 @@ const commonOptions = {
},
[],
],
'-F, --feature-flag <name=value>': [
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Honestly prefer without the -F shorthand. People aren't going to type this by hand anyway so explicit is better.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also can you set multiple flags?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it might need to be --feature-flag <name=value...> as per this?

But the input would be like parcel build --feature-flag foo=true bar=false whereas I normally prefer parcel build --feature-flag foo=true --feature-flag bar=false but not sure how easy that would be

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The latter is what works out the box with commander (i.e. parcel build --feature-flag foo=true --feature-flag bar=false), that was my intention rather than being able to set multiple flags with one option (I would expect most of time time it'll be some sort of launcher script configuring these anyway, and if you're setting a flag by hand it's usually a single one.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect 👍

@marcins marcins merged commit 3c2b829 into v2 Mar 1, 2024
14 of 16 checks passed
@marcins marcins deleted the mszczepanski/feature-flags-cli branch March 1, 2024 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants