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: monitor all-sub-projecs #432

Merged
merged 2 commits into from
Apr 8, 2019
Merged

Conversation

kyegupov
Copy link
Contributor

@kyegupov kyegupov commented Apr 3, 2019

  • Ready for review
  • Follows CONTRIBUTING rules
  • Reviewed by Snyk internal team
  • Manually tested

What does this PR do?

Enables --all-sub-project flag for snyk monitor. Data for each sub-project aka depRoot is sent to the Registry separately.

--all-sub-project is incompatible with --project-name flag.

Where should the reviewer start?

monitor.ts

How should this be manually tested?

snyk monitor --all-sub-project on a gradle project with subprojs

What are the relevant tickets?

https://snyksec.atlassian.net/browse/BST-517
https://snyksec.atlassian.net/browse/BST-506

@kyegupov kyegupov force-pushed the feat/monitor-all-sub-projects branch 4 times, most recently from 6b1367e to 4d86d18 Compare April 3, 2019 15:45
@kyegupov kyegupov changed the title [WIP] ]feat: monitor all-sub-projecs [WIP] feat: monitor all-sub-projecs Apr 3, 2019
@kyegupov kyegupov force-pushed the feat/monitor-all-sub-projects branch 3 times, most recently from 53d9f0d to 9ed5f5e Compare April 3, 2019 16:31
@kyegupov kyegupov self-assigned this Apr 3, 2019
@kyegupov kyegupov requested a review from miiila April 3, 2019 16:51
@kyegupov kyegupov force-pushed the feat/monitor-all-sub-projects branch 3 times, most recently from 9bff0ff to f644bf7 Compare April 4, 2019 09:17
const pluginOptions = plugins.getPluginOptions(packageManager, options);

// TODO: the type should depend on multiDepRoots flag
const inspectResult: SingleDepRootResult|MultiDepRootsResult =
Copy link
Contributor

@miiila miiila Apr 4, 2019

Choose a reason for hiding this comment

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

Are we safe with removing try/catch here?

Could we move back to try/catch block rather than inline promise catch? My previouse sentence reveals it's not readable enough (for me :-)).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a Typescript reason for that. Added a documented promiseOrCleanup function do explain the intention.

// SingleDepRootResult is a legacy format understood by Registry, so we have to convert
// a MultiDepRootsResult to an array of these.

const perDepRootResults: SingleDepRootResult[] = (inspectResult as MultiDepRootsResult).depRoots
Copy link
Contributor

Choose a reason for hiding this comment

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

Understand the intention, however I'd prefer less type casting here and map outside of ternary operator for readability (YMMV). I don't have a better approach, will think about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Converted, made the code a bit more readable with a type guard.

for (const depRootDeps of perDepRootResults) {
// TODO(kyegupov): make snyk.monitor typed by converting src/lib/index.js to TS
const snykMonitor = snyk.monitor as any as (path, meta, depRootDeps) => Promise<any>;
const res = await snykMonitor(path, meta, depRootDeps)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same try/catch vs inline .catch suggestion

@kyegupov kyegupov changed the title [WIP] feat: monitor all-sub-projecs feat: monitor all-sub-projecs Apr 4, 2019
@kyegupov kyegupov force-pushed the feat/monitor-all-sub-projects branch from f644bf7 to d51b4a0 Compare April 4, 2019 10:44
@kyegupov kyegupov force-pushed the feat/monitor-all-sub-projects branch from d51b4a0 to d12167d Compare April 5, 2019 10:14
Copy link
Contributor

@miiila miiila left a comment

Choose a reason for hiding this comment

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

Approving, but please do not merge yet

@kyegupov
Copy link
Contributor Author

kyegupov commented Apr 5, 2019

(not merging because weekend 🍺 )

@kyegupov
Copy link
Contributor Author

kyegupov commented Apr 8, 2019

(restarting the CI build)

@kyegupov kyegupov merged commit 2731ed2 into master Apr 8, 2019
@kyegupov kyegupov deleted the feat/monitor-all-sub-projects branch April 8, 2019 12:44
@snyksec
Copy link

snyksec commented Apr 8, 2019

🎉 This PR is included in version 1.148.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants