-
Notifications
You must be signed in to change notification settings - Fork 572
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
Lockfile autodetection for test, wizard, protect and monitor #228
Conversation
97535e1
to
5a32fd3
Compare
WORK IN PROGRESS |
5a32fd3
to
aca149e
Compare
ddc11cc
to
e2e8484
Compare
if (!nodeModulesExist) { | ||
// throw a custom error | ||
throw new Error( | ||
'Missing node_modules folder: we can\'t patch without having installed packages.' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test can now be performed without node_modules so change the wording to better reflect why we need node_modules during wizard for all node lockfiles & non lockfiles project types
if (isLockFileBased) { | ||
// we need to trigger a lockfile update after adding snyk | ||
// as a dep | ||
return protect.update(['snyk'], live, packageManager); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a project is lockfile based we need to also update the lockfile after adding in snyk as a dep, without this the files go out of sync and fail a re-test on monitor command
@@ -10,6 +10,7 @@ var chalk = require('chalk'); | |||
|
|||
var DETECTABLE_FILES = [ | |||
'yarn.lock', | |||
'package-lock.json', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change order to ensure lockfile based projects get processed as suck
e2e8484
to
f398253
Compare
// but not the latest node-lockfile-parser | ||
// HACK: if yarn set traverseNodeModules option to | ||
// bypass lockfile test for wizard | ||
options.traverseNodeModules = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fallback for yarn projects where we currently do not support traversing node_modules with the new lockfile-parser
// but not the latest node-lockfile-parser | ||
// HACK: if yarn set traverseNodeModules option to | ||
// bypass lockfile test for wizard | ||
if (targetFile.endsWith('yarn.lock')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fallback for yarn projects where we currently do not support traversing node_modules with the new lockfile-parser
Great job, waiting for tests to pass before final approvement. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a small comment for now :-)
src/cli/commands/protect/wizard.js
Outdated
return snyk.test(cwd, options).then(function (res) { | ||
if (alerts.hasAlert('tests-reached') && res.isPrivate) { | ||
return; | ||
var intro = __dirname + '/../../../../help/wizard-intro.txt'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- var
+ const
d41a593
to
81f337e
Compare
Lockfile autodetection functionality wuth fall back for yarn.lock files on node < 6 && yarn//lock wizard flow.
🎉 This PR is included in version 1.102.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What does this PR do?
node_module
traversal as fall back for package.json & shrinkwrap projectsThe state of NPM lockfile support in this pr:
package.json
&package-lock.json
will be tested via the new lockfile parser lib forsnyk protect
,test
,monitor
The state of Yarn lockfile support in this pr:
package.json
&yarn.lock
will be tested via the new lockfile parser lib forsnyk test
,monitor
package.json
&yarn.lock
will be tested via the oldnode_modules
traversal lib (resolve-deps
) forsnyk protect
andwizard
package.json
&yarn.lock
on node@4 will be tested via the oldnode_modules
traversal lib (resolve-deps
) for allsnyk
commands. Yarn parser lib we use is not compatible with node@4Where should the reviewer start?
How should this be manually tested?
What are the relevant tickets?
https://snyksec.atlassian.net/browse/SC-6240
https://snyksec.atlassian.net/browse/SC-6277