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

Adds a validator module to Bubblewrap #134

Merged
merged 7 commits into from
Apr 14, 2020

Conversation

andreban
Copy link
Member

@andreban andreban commented Apr 6, 2020

- Adds a validator module that validates PWAs for the Trusted Web
  Activity quality criteria.
- The module uses the PageSpeed Insights API to run and collect
  Lighthouse scoring information.
- Adds a `validate` command to `@bubblewrap/cli`.
README.md Outdated Show resolved Hide resolved
packages/cli/src/lib/cmds/validate.ts Outdated Show resolved Hide resolved
packages/validator/README.md Show resolved Hide resolved
packages/validator/src/lib/psi/PsiResult.ts Show resolved Hide resolved
packages/validator/src/lib/psi/PsiResult.ts Show resolved Hide resolved
packages/validator/src/lib/PwaValidator.ts Show resolved Hide resolved
packages/validator/src/lib/PwaValidator.ts Outdated Show resolved Hide resolved
packages/validator/src/lib/psi/PageSpeedInsights.ts Outdated Show resolved Hide resolved
- Cleans PSI results type for things we really need.
- Fixes typo in README.md
- validate produces more useful details
- build runs PWA Quality Checks
- a --skipPwaValidation flag was added to build
- Validation during the build step is now a warning.
- Checks for the response status on the PSI request and throws an
  error if it's not 200.
- Addresses review notes.
@andreban andreban requested a review from PEConn April 9, 2020 10:46
- **[bubblewrap/cli](./packages/cli):** a command-line version of Bubblewrap.
- **[bubblewrap/validator](./packages/validator):** library to validate the correctness and
Copy link
Collaborator

Choose a reason for hiding this comment

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

tiniest nit: could you say "a library to...", so that the sentence has the same form as the previous two bullet points?

Comment on lines 25 to 32
.then((result) => {
if (!result) {
process.exit(1);
}
})
.catch((err: Error) => {
log.error(err.message);
process.exit(1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not quite sure what you're doing here. Isn't this the last code to be called in the execution of the program? Why would you need to call process.exit() ? Is it just to make the return code 1?

I'm dubious about using process.exit in general since it's not obvious from the caller of this method that the entire program could terminate. Is there some way to make the method return the exit code - so 1 in the two cases you call process.exit in and 0 otherwise?

Copy link
Member Author

Choose a reason for hiding this comment

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

cli/src/index.ts is the entry point for the CLI application - a "main" method (TypeScript doesn't have a main). The reason it calls process.exit(1) is to signal an abnormal termination. In case the program is being invoked as part of a build pipeline, this signals that the CLI failed and the whole pipeline can be aborted.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we instead do:

const success = await cli.run(args)
    .then((result) => {
        return result;
    })
    .catch((error) => {
        // ...
        return false;
    });
process.exit(success ? 0 : 1);

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the code.

- Adds a comment to explain why process.exit(1) is used.
- Moves implementation to an async method instead of Promises and
  cleans-up the code.
@andreban andreban merged commit 61dcf3d into GoogleChromeLabs:master Apr 14, 2020
@andreban andreban added the enhancement New feature or request label Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants