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: colorize values of params #743

Merged
merged 25 commits into from
Oct 31, 2019
Merged

Conversation

lag-of-death
Copy link
Contributor

@lag-of-death lag-of-death commented Oct 25, 2019

Closes #696

Checklist

  • Tests have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce?

feature

What is the current behavior? What is the new behavior?

Currently, values for params are in the same color the whole path is.
Now, the values are in bold and colored.

Does this PR introduce a breaking change?

No.

colored_params

Copy link
Contributor

@philsturgeon philsturgeon left a comment

Choose a reason for hiding this comment

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

Great idea, this is much better. Thanks for posting a screenshot too!

@XVincentX
Copy link
Contributor

Looks very promising! I'll take a look at the code tomorrow.

Copy link
Contributor

@karol-maciaszek karol-maciaszek left a comment

Choose a reason for hiding this comment

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

Good work, couple comments added 👍

packages/cli/src/util/colorizer.ts Outdated Show resolved Hide resolved
packages/cli/src/util/createServer.ts Outdated Show resolved Hide resolved
packages/cli/src/util/paths.ts Outdated Show resolved Hide resolved
packages/cli/src/util/paths.ts Show resolved Hide resolved
packages/cli/src/util/createServer.ts Show resolved Hide resolved
packages/cli/src/util/colorizer.ts Outdated Show resolved Hide resolved
@lag-of-death
Copy link
Contributor Author

lag-of-death commented Oct 28, 2019

@StefanDywersant, I've addressed the feedback. Colorizing is now optional as transformValues now defaults to _.identity. Also, _.uniq was removed completely, it must have been a left-over. Do you think this version is OK, or you'd rather see some more changes? Also, what about #743 (comment) ?

Copy link
Contributor

@XVincentX XVincentX left a comment

Choose a reason for hiding this comment

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

I've dropped some comments but in general looks good.

I wish we could be a little bit smarter and try to modify the parameters as we construct the URLs, but unfortunately no URI Template library will allow us to do that. I guess we will have to go with what we have.

packages/cli/src/util/createServer.ts Show resolved Hide resolved
packages/cli/src/util/paths.ts Show resolved Hide resolved
packages/cli/src/util/colorizer.ts Outdated Show resolved Hide resolved
packages/cli/src/util/colorizer.ts Outdated Show resolved Hide resolved
packages/cli/src/util/colorizer.ts Outdated Show resolved Hide resolved
packages/cli/src/util/colorizer.ts Outdated Show resolved Hide resolved
@lag-of-death lag-of-death requested review from karol-maciaszek and XVincentX and removed request for karol-maciaszek October 29, 2019 10:47
transform: (aString: string) => string
): string => {
return path.replace(taggedParamsValues, transform('$2'));
}).bind({}, new RegExp(`(${PRE_PARAM_VALUE_TAG},)(.*?)(,${POST_PARAM_VALUE_TAG})`, 'gm'));
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm maybe instead of binding you can just create the RegEx ahead of the time as a constant and use it in there — this should improve the readability.

Copy link
Contributor

@karol-maciaszek karol-maciaszek left a comment

Choose a reason for hiding this comment

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

This is a super nice feature which will make people happier, good job!

I believe there might be a problem with complex styles and explode usage. Please see the comment. Also, it would be good to add a single end2end test at create server level to ensure that the whole solution works.

packages/cli/src/util/createServer.ts Show resolved Hide resolved
packages/cli/src/util/colorizer.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@XVincentX XVincentX left a comment

Choose a reason for hiding this comment

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

This is ok, but the final approval goes to @StefanDywersant

docs/guides/cli.md Outdated Show resolved Hide resolved
examples/test.yaml Outdated Show resolved Hide resolved
packages/cli/src/util/colorizer.ts Outdated Show resolved Hide resolved
packages/cli/src/util/__tests__/colorizer.spec.ts Outdated Show resolved Hide resolved
lag-of-death and others added 3 commits October 31, 2019 10:11
Co-Authored-By: Vincenzo Chianese <vincenz.chianese@icloud.com>
Copy link
Contributor

@karol-maciaszek karol-maciaszek left a comment

Choose a reason for hiding this comment

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

I've tested locally the colorizing feature and it is cool, helpful and works perfectly!

Screen Shot 2019-10-31 at 11 30 41

I've added a few minor comments which, most of them you can just apply and let's merge this!
Again, a very good job @lag-of-death!

docs/guides/cli.md Outdated Show resolved Hide resolved
packages/cli/src/util/colorizer.ts Outdated Show resolved Hide resolved
packages/cli/src/util/createServer.ts Outdated Show resolved Hide resolved
packages/cli/src/util/colorizer.ts Outdated Show resolved Hide resolved
packages/cli/src/util/colorizer.ts Outdated Show resolved Hide resolved
packages/cli/src/util/__tests__/colorizer.spec.ts Outdated Show resolved Hide resolved
packages/cli/src/util/__tests__/colorizer.spec.ts Outdated Show resolved Hide resolved
packages/cli/src/util/__tests__/colorizer.spec.ts Outdated Show resolved Hide resolved
packages/cli/src/util/__tests__/colorizer.spec.ts Outdated Show resolved Hide resolved
packages/cli/src/util/__tests__/colorizer.spec.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@karol-maciaszek karol-maciaszek left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Please go ahead and merge it! (I won't take the pleasure of hitting the green button from you like our captain does).

@lag-of-death lag-of-death merged commit 47e47aa into master Oct 31, 2019
@lag-of-death lag-of-death deleted the feature/colorize-params-values branch October 31, 2019 11:27
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.

Colorized parameters in operation examples
4 participants