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

New feature proposal - Add link to opportunities #113

Merged
merged 37 commits into from
Sep 3, 2020
Merged

New feature proposal - Add link to opportunities #113

merged 37 commits into from
Sep 3, 2020

Conversation

JuanMaRuiz
Copy link
Contributor

@JuanMaRuiz JuanMaRuiz commented Mar 15, 2020

Hi @exterkamp! I was wondering if psi tool should show (on demand) some extra info as Page Speed Insights do.

Sometimes the information (or title) showed in the opportunities section is not enough. See issue #41.

So, here is my proposal. We could add the link to the opportunity so the user could navigate to the page from the terminal. If the user provides the option --links (no value needed) the link will be shown.

Here a few examples:

Default behaviour No --links options provide

no-links

With --links options
Here the display of the info looks different depending on the terminal. I have used terminal-link package. Here is the info about the support of this feature

with-link-supported-terminal

with-link-not-supported-terminal

Maybe the link could be shown in a different section an not as link of the opportunity field.

What do you think? Make sense for you this feature?

Best regards.

JuanMaRuiz and others added 30 commits October 26, 2019 17:11
- Removed call to api.
- Added test to options handler instead
- Merge branch 'feature-optimizing-test' of https://github.com/JuanMaRuiz/psi into feature-optimizing-test
- Removed api-response-test
Co-Authored-By: Shane Exterkamp <shaneexterkamp5@gmail.com>
Co-Authored-By: Shane Exterkamp <shaneexterkamp5@gmail.com>
* Update index file to use new api
* Update googleapis dependency
* Add new option to show links to information about opportunities
* Add test to cover new util that check the existence of url in a string
@JuanMaRuiz JuanMaRuiz changed the title New feature proposal - Add link to opportunities New feature proposal - Add link to opportunities :enhancement Mar 15, 2020
@JuanMaRuiz JuanMaRuiz changed the title New feature proposal - Add link to opportunities :enhancement New feature proposal - Add link to opportunities Mar 15, 2020
@exterkamp exterkamp self-assigned this Mar 16, 2020
@exterkamp exterkamp self-requested a review March 16, 2020 20:47
@JuanMaRuiz
Copy link
Contributor Author

Hi @exterkamp any advance on it?

Copy link
Collaborator

@exterkamp exterkamp left a comment

Choose a reason for hiding this comment

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

Review a long time coming, but overall this looks good! Just some small changes to make it air-tight!

cli.js Outdated Show resolved Hide resolved
test/string-utils.test.js Show resolved Hide resolved
@@ -0,0 +1,10 @@
const getLink = str => {
const containsLink = str.match(/\(https?:(.*)\)/);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems like it would be more readable with a named group...something like

\((?<url>https?:.*)\)

and then it could be return containsLink.groups.url

So that there doesn't need to be any replacing of the "( )"s.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much better. Many thanks. Done

Unfortunately named groups seem to be not supported in node 8 https://travis-ci.com/github/GoogleChromeLabs/psi/jobs/378505545.

Should I keep the original implementation due the support of this library for node 8? Any other option?

* Negative assertion on string-utils.test.
* More readable regexp with named groups.
* Fix typo in cli.js help
Copy link
Collaborator

@exterkamp exterkamp left a comment

Choose a reason for hiding this comment

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

These changes look good to me. But I think node 8 is still failing, or is stuck on a stale build. So once that is cleared up this is good to go!

@@ -0,0 +1,9 @@
const getLink = str => {
const containsLink = str.match(/\((?<url>https?:.*)\)/);
Copy link
Collaborator

@exterkamp exterkamp Sep 1, 2020

Choose a reason for hiding this comment

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

Argh. Node 8 doesn't support named capture groups ☹️

We should go back to numbered groups then I suppose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep 😢 it's not supported in node v8.

I have reverted the changes. Let me know if you prefer another approach.

@exterkamp exterkamp merged commit f59a309 into GoogleChromeLabs:master Sep 3, 2020
@JuanMaRuiz JuanMaRuiz deleted the add-link-to-opportunity-title branch September 4, 2020 03:53
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.

None yet

2 participants