snyk 1.1041.0 → 1.1043.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -193771,34 +193771,63 @@ function inspect(root, targetFile, options) {
193771
193771
  const isCoursierPresent = yield (0, plugin_search_1.isPluginInstalled)(root, targetFile, constants_1.sbtCoursierPluginName);
193772
193772
  const isSbtDependencyGraphPresent = yield (0, plugin_search_1.isPluginInstalled)(root, targetFile, constants_1.sbtDependencyGraphPluginName);
193773
193773
  const isNewSbtDependencyGraphPresent = yield (0, plugin_search_1.isPluginInstalled)(root, targetFile, constants_1.sbtDependencyGraphPluginNameNew);
193774
- Object.assign(options, { isCoursierPresent });
193775
- // in order to apply the pluginInspect, coursier should *not* be present and sbt-dependency-graph should be present
193776
- // we currently don't support the new notation of the sbt-dependency-graph which is 'addDependencyTreePlugin'
193777
- if (!isCoursierPresent && isSbtDependencyGraphPresent && !isNewSbtDependencyGraphPresent) {
193778
- debug('applying plugin inspect');
193779
- const res = yield pluginInspect(root, targetFile, options);
193780
- if (res) {
193781
- res.package.packageFormatVersion = packageFormatVersion;
193782
- return res;
193774
+ debug(`isCoursierPresent: ${isCoursierPresent}, isSbtDependencyGraphPresent: ${isSbtDependencyGraphPresent},
193775
+ isNewSbtDependencyGraphPresent: ${isNewSbtDependencyGraphPresent}`);
193776
+ // If coursier is present, use it because it gives different results to sbt dependencyTree
193777
+ let result;
193778
+ if (isCoursierPresent) {
193779
+ try {
193780
+ options.useCoursier = true;
193781
+ result = yield legacyInspect(root, targetFile, options);
193782
+ return result;
193783
193783
  }
193784
- else {
193785
- debug('coursier present = ' +
193786
- isCoursierPresent +
193787
- ', sbt-dependency-graph present = ' +
193788
- isSbtDependencyGraphPresent);
193789
- debug('Falling back to legacy inspect');
193790
- // tslint:disable-next-line:no-console
193791
- console.warn(buildHintMessage(options));
193784
+ catch (err) {
193785
+ debug('Coursier failed with error: ', err);
193792
193786
  }
193793
193787
  }
193794
- else {
193795
- if (isNewSbtDependencyGraphPresent) {
193796
- // tslint:disable-next-line:no-console
193797
- console.warn(buildNewSbtDepGraphWarning());
193788
+ // TODO:Legacy path creates a large output that can cause RangeError in bigger projects
193789
+ // We would prefer to use plugin inspect by default but currently it requires sbt-dep-graph plugin
193790
+ if (isSbtDependencyGraphPresent) {
193791
+ try {
193792
+ debug('Applying plugin inspect');
193793
+ result = yield pluginInspect(root, targetFile, options);
193798
193794
  }
193799
- debug('falling back to legacy inspect');
193795
+ catch (err) {
193796
+ debug('pluginInspect failed with error: ', err);
193797
+ }
193798
+ if (result) {
193799
+ result.package.packageFormatVersion = packageFormatVersion;
193800
+ return result;
193801
+ }
193802
+ }
193803
+ options.useCoursier = false;
193804
+ try {
193805
+ result = yield legacyInspect(root, targetFile, options);
193806
+ return result;
193800
193807
  }
193801
- const result = yield legacyInspect(root, targetFile, options);
193808
+ catch (err) {
193809
+ const hintMsg = buildHintMessage(options);
193810
+ err.message = err.message + '\n' + hintMsg;
193811
+ throw new Error(err);
193812
+ }
193813
+ });
193814
+ }
193815
+ exports.inspect = inspect;
193816
+ function legacyInspect(root, targetFile, options) {
193817
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
193818
+ const targetFilePath = path.dirname(path.resolve(root, targetFile));
193819
+ if (!fs.existsSync(targetFilePath)) {
193820
+ debug(`build.sbt not found at location: ${targetFilePath}. This may result in no dependencies`);
193821
+ }
193822
+ const useCoursier = options.useCoursier;
193823
+ const sbtArgs = buildArgs(options.args, useCoursier);
193824
+ debug(`running command: sbt ${sbtArgs.join(' ')}`);
193825
+ const result = {
193826
+ sbtOutput: yield subProcess.execute('sbt', sbtArgs, {
193827
+ cwd: targetFilePath,
193828
+ }),
193829
+ coursier: useCoursier,
193830
+ };
193802
193831
  const packageName = path.basename(root);
193803
193832
  const packageVersion = '0.0.0';
193804
193833
  const depTree = parser.parse(result.sbtOutput, packageName, packageVersion, result.coursier);
@@ -193812,44 +193841,6 @@ function inspect(root, targetFile, options) {
193812
193841
  };
193813
193842
  });
193814
193843
  }
193815
- exports.inspect = inspect;
193816
- function legacyInspect(root, targetFile, options) {
193817
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
193818
- const targetFilePath = path.dirname(path.resolve(root, targetFile));
193819
- if (!fs.existsSync(targetFilePath)) {
193820
- debug(`build.sbt not found at location: ${targetFilePath}. This may result in no dependencies`);
193821
- }
193822
- let useCoursier = options.isCoursierPresent;
193823
- const sbtArgs = buildArgs(options.args, useCoursier);
193824
- try {
193825
- return {
193826
- sbtOutput: yield subProcess.execute('sbt', sbtArgs, {
193827
- cwd: targetFilePath,
193828
- }),
193829
- coursier: useCoursier,
193830
- };
193831
- }
193832
- catch (error) {
193833
- if (useCoursier) {
193834
- // if we've tried coursier already, we'll fallback to dependency-graph
193835
- // in case we've failed to parse the files correctly #paranoid
193836
- useCoursier = false;
193837
- const sbtArgsNoCoursier = buildArgs(options.args, useCoursier);
193838
- return {
193839
- sbtOutput: yield subProcess.execute('sbt', sbtArgsNoCoursier, {
193840
- cwd: targetFilePath,
193841
- }),
193842
- coursier: useCoursier,
193843
- };
193844
- }
193845
- else {
193846
- // otherwise cascade the reject
193847
- error.message = error.message + buildHintMessage(options);
193848
- throw error;
193849
- }
193850
- }
193851
- });
193852
- }
193853
193844
  function injectSbtScript(sbtPluginPath, targetFolderPath) {
193854
193845
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
193855
193846
  try {
@@ -193889,6 +193880,7 @@ function generateSbtPluginPath(sbtVersion) {
193889
193880
  pluginName = 'SnykSbtPlugin-0.1x.scala';
193890
193881
  }
193891
193882
  if (/index.[tj]s$/.test(__filename)) {
193883
+ debug('Applying ', pluginName);
193892
193884
  return path.join(__dirname, `../scala/${pluginName}`);
193893
193885
  }
193894
193886
  else {
@@ -193907,6 +193899,7 @@ function pluginInspect(root, targetFile, options) {
193907
193899
  const packageVersion = '1.0.0';
193908
193900
  injectedScript = yield injectSbtScript(sbtPluginPath, targetFolderPath);
193909
193901
  debug('injectedScript.path: ' + injectedScript.path);
193902
+ debug('args passed to plugin inspect: ', sbtArgs.join(' '));
193910
193903
  const stdout = yield subProcess.execute('sbt', sbtArgs, {
193911
193904
  cwd: targetFolderPath,
193912
193905
  });
@@ -193963,7 +193956,7 @@ function buildHintMessage(options) {
193963
193956
  csArgs +
193964
193957
  ' executes successfully on this project.\n\n' +
193965
193958
  'For this project we guessed that you are using ' +
193966
- (options.isCoursierPresent ? 'sbt-coursier' : 'sbt-dependency-graph') +
193959
+ (options.useCoursier ? 'sbt-coursier' : 'sbt-dependency-graph') +
193967
193960
  '.\n\n' +
193968
193961
  'If the problem persists, collect the output of ' +
193969
193962
  dgArgs +
@@ -193989,14 +193982,6 @@ function buildArgs(sbtArgs, isCoursierProject, isOutputGraph) {
193989
193982
  return args;
193990
193983
  }
193991
193984
  exports.buildArgs = buildArgs;
193992
- function buildNewSbtDepGraphWarning() {
193993
- return ('\n\n' +
193994
- 'We currently do not support the new `addDependencyTreePlugin` annotation for the `sbt-dependency-graph` plugin\n' +
193995
- 'Instead, please add the following line to the plugins file: \n' +
193996
- 'addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1")\n' +
193997
- 'Further instructions can be found in ' +
193998
- 'https://tinyurl.com/2p9xa3p2\n\n');
193999
- }
194000
193985
  //# sourceMappingURL=index.js.map
194001
193986
 
194002
193987
  /***/ }),