snyk 1.1069.0 → 1.1071.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.
@@ -196409,7 +196409,6 @@ exports.sbtDependencyGraphPluginNameNew = 'addDependencyTreePlugin';
196409
196409
 
196410
196410
  Object.defineProperty(exports, "__esModule", ({ value: true }));
196411
196411
  exports.buildArgs = exports.inspect = void 0;
196412
- const tslib_1 = __webpack_require__(70655);
196413
196412
  const path = __webpack_require__(85622);
196414
196413
  const fs = __webpack_require__(35747);
196415
196414
  const semver = __webpack_require__(36625);
@@ -196424,113 +196423,107 @@ const version_1 = __webpack_require__(16478);
196424
196423
  const tmp = __webpack_require__(15743);
196425
196424
  tmp.setGracefulCleanup();
196426
196425
  const packageFormatVersion = 'mvn:0.0.1';
196427
- function inspect(root, targetFile, options) {
196428
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
196429
- if (!options) {
196430
- options = { dev: false };
196431
- }
196432
- const isCoursierPresent = yield (0, plugin_search_1.isPluginInstalled)(root, targetFile, constants_1.sbtCoursierPluginName);
196433
- const isSbtDependencyGraphPresent = yield (0, plugin_search_1.isPluginInstalled)(root, targetFile, constants_1.sbtDependencyGraphPluginName);
196434
- const isNewSbtDependencyGraphPresent = yield (0, plugin_search_1.isPluginInstalled)(root, targetFile, constants_1.sbtDependencyGraphPluginNameNew);
196435
- debug(`isCoursierPresent: ${isCoursierPresent}, isSbtDependencyGraphPresent: ${isSbtDependencyGraphPresent},
196426
+ async function inspect(root, targetFile, options) {
196427
+ if (!options) {
196428
+ options = { dev: false };
196429
+ }
196430
+ const isCoursierPresent = await (0, plugin_search_1.isPluginInstalled)(root, targetFile, constants_1.sbtCoursierPluginName);
196431
+ const isSbtDependencyGraphPresent = await (0, plugin_search_1.isPluginInstalled)(root, targetFile, constants_1.sbtDependencyGraphPluginName);
196432
+ const isNewSbtDependencyGraphPresent = await (0, plugin_search_1.isPluginInstalled)(root, targetFile, constants_1.sbtDependencyGraphPluginNameNew);
196433
+ debug(`isCoursierPresent: ${isCoursierPresent}, isSbtDependencyGraphPresent: ${isSbtDependencyGraphPresent},
196436
196434
  isNewSbtDependencyGraphPresent: ${isNewSbtDependencyGraphPresent}`);
196437
- // If coursier is present, use it because it gives different results to sbt dependencyTree
196438
- let result;
196439
- if (isCoursierPresent) {
196440
- try {
196441
- options.useCoursier = true;
196442
- result = yield legacyInspect(root, targetFile, options);
196443
- return result;
196444
- }
196445
- catch (err) {
196446
- debug('Coursier failed with error: ', err);
196447
- }
196435
+ // If coursier is present, use it because it gives different results to sbt dependencyTree
196436
+ let result;
196437
+ if (isCoursierPresent) {
196438
+ try {
196439
+ options.useCoursier = true;
196440
+ result = await legacyInspect(root, targetFile, options);
196441
+ return result;
196448
196442
  }
196449
- // TODO:Legacy path creates a large output that can cause RangeError in bigger projects
196450
- // We would prefer to use plugin inspect by default but currently it requires sbt-dep-graph plugin
196451
- if (isSbtDependencyGraphPresent) {
196452
- try {
196453
- debug('Applying plugin inspect');
196454
- result = yield pluginInspect(root, targetFile, options);
196455
- }
196456
- catch (err) {
196457
- debug('pluginInspect failed with error: ', err);
196458
- }
196459
- if (result) {
196460
- result.package.packageFormatVersion = packageFormatVersion;
196461
- return result;
196462
- }
196443
+ catch (err) {
196444
+ debug('Coursier failed with error: ', err);
196463
196445
  }
196464
- options.useCoursier = false;
196446
+ }
196447
+ // TODO:Legacy path creates a large output that can cause RangeError in bigger projects
196448
+ // We would prefer to use plugin inspect by default but currently it requires sbt-dep-graph plugin
196449
+ if (isSbtDependencyGraphPresent) {
196465
196450
  try {
196466
- result = yield legacyInspect(root, targetFile, options);
196467
- return result;
196451
+ debug('Applying plugin inspect');
196452
+ result = await pluginInspect(root, targetFile, options);
196468
196453
  }
196469
196454
  catch (err) {
196470
- const hintMsg = buildHintMessage(options);
196471
- err.message = err.message + '\n' + hintMsg;
196472
- throw new Error(err);
196455
+ debug('pluginInspect failed with error: ', err);
196473
196456
  }
196474
- });
196457
+ if (result) {
196458
+ result.package.packageFormatVersion = packageFormatVersion;
196459
+ return result;
196460
+ }
196461
+ }
196462
+ options.useCoursier = false;
196463
+ try {
196464
+ result = await legacyInspect(root, targetFile, options);
196465
+ return result;
196466
+ }
196467
+ catch (err) {
196468
+ const hintMsg = buildHintMessage(options);
196469
+ err.message = err.message + '\n' + hintMsg;
196470
+ throw new Error(err);
196471
+ }
196475
196472
  }
196476
196473
  exports.inspect = inspect;
196477
- function legacyInspect(root, targetFile, options) {
196478
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
196479
- const targetFilePath = path.dirname(path.resolve(root, targetFile));
196480
- if (!fs.existsSync(targetFilePath)) {
196481
- debug(`build.sbt not found at location: ${targetFilePath}. This may result in no dependencies`);
196482
- }
196483
- const useCoursier = options.useCoursier;
196484
- const sbtArgs = buildArgs(options.args, useCoursier);
196485
- debug(`running command: sbt ${sbtArgs.join(' ')}`);
196486
- const result = {
196487
- sbtOutput: yield subProcess.execute('sbt', sbtArgs, {
196488
- cwd: targetFilePath,
196489
- }),
196490
- coursier: useCoursier,
196491
- };
196492
- const packageName = path.basename(root);
196493
- const packageVersion = '0.0.0';
196494
- const depTree = parser.parse(result.sbtOutput, packageName, packageVersion, result.coursier);
196495
- depTree.packageFormatVersion = packageFormatVersion;
196496
- return {
196497
- plugin: {
196498
- name: 'bundled:sbt',
196499
- runtime: 'unknown',
196500
- },
196501
- package: depTree,
196502
- };
196503
- });
196474
+ async function legacyInspect(root, targetFile, options) {
196475
+ const targetFilePath = path.dirname(path.resolve(root, targetFile));
196476
+ if (!fs.existsSync(targetFilePath)) {
196477
+ debug(`build.sbt not found at location: ${targetFilePath}. This may result in no dependencies`);
196478
+ }
196479
+ const useCoursier = options.useCoursier;
196480
+ const sbtArgs = buildArgs(options.args, useCoursier);
196481
+ debug(`running command: sbt ${sbtArgs.join(' ')}`);
196482
+ const result = {
196483
+ sbtOutput: await subProcess.execute('sbt', sbtArgs, {
196484
+ cwd: targetFilePath,
196485
+ }),
196486
+ coursier: useCoursier,
196487
+ };
196488
+ const packageName = path.basename(root);
196489
+ const packageVersion = '0.0.0';
196490
+ const depTree = parser.parse(result.sbtOutput, packageName, packageVersion, result.coursier);
196491
+ depTree.packageFormatVersion = packageFormatVersion;
196492
+ return {
196493
+ plugin: {
196494
+ name: 'bundled:sbt',
196495
+ runtime: 'unknown',
196496
+ },
196497
+ package: depTree,
196498
+ };
196504
196499
  }
196505
- function injectSbtScript(sbtPluginPath, targetFolderPath) {
196506
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
196507
- try {
196508
- // We could be running from a bundled CLI generated by `pkg`.
196509
- // The Node filesystem in that case is not real: https://github.com/zeit/pkg#snapshot-filesystem
196510
- // Copying the injectable script into a temp file.
196511
- let projectFolderPath = path.resolve(targetFolderPath, 'project/');
196512
- debug(`injectSbtScript: injecting snyk sbt plugin "${sbtPluginPath}" in "${projectFolderPath}"`);
196513
- if (!fs.existsSync(projectFolderPath)) {
196514
- debug(`injectSbtScript: "${projectFolderPath}" does not exist`);
196515
- projectFolderPath = path.resolve(targetFolderPath, '..', 'project/');
196516
- debug(`injectSbtScript: will try "${projectFolderPath}"`);
196517
- }
196518
- const tmpSbtPlugin = tmp.fileSync({
196519
- postfix: '-SnykSbtPlugin.scala',
196520
- dir: projectFolderPath,
196521
- });
196522
- fs.createReadStream(sbtPluginPath).pipe(fs.createWriteStream(tmpSbtPlugin.name));
196523
- debug(`successfully injected plugin at "${tmpSbtPlugin.name}"`);
196524
- return { path: tmpSbtPlugin.name, remove: tmpSbtPlugin.removeCallback };
196525
- }
196526
- catch (error) {
196527
- error.message =
196528
- error.message +
196529
- '\n\n' +
196530
- 'Failed to create a temporary file to host Snyk script for SBT build analysis.';
196531
- throw error;
196532
- }
196533
- });
196500
+ async function injectSbtScript(sbtPluginPath, targetFolderPath) {
196501
+ try {
196502
+ // We could be running from a bundled CLI generated by `pkg`.
196503
+ // The Node filesystem in that case is not real: https://github.com/zeit/pkg#snapshot-filesystem
196504
+ // Copying the injectable script into a temp file.
196505
+ let projectFolderPath = path.resolve(targetFolderPath, 'project/');
196506
+ debug(`injectSbtScript: injecting snyk sbt plugin "${sbtPluginPath}" in "${projectFolderPath}"`);
196507
+ if (!fs.existsSync(projectFolderPath)) {
196508
+ debug(`injectSbtScript: "${projectFolderPath}" does not exist`);
196509
+ projectFolderPath = path.resolve(targetFolderPath, '..', 'project/');
196510
+ debug(`injectSbtScript: will try "${projectFolderPath}"`);
196511
+ }
196512
+ const tmpSbtPlugin = tmp.fileSync({
196513
+ postfix: '-SnykSbtPlugin.scala',
196514
+ dir: projectFolderPath,
196515
+ });
196516
+ fs.createReadStream(sbtPluginPath).pipe(fs.createWriteStream(tmpSbtPlugin.name));
196517
+ debug(`successfully injected plugin at "${tmpSbtPlugin.name}"`);
196518
+ return { path: tmpSbtPlugin.name, remove: tmpSbtPlugin.removeCallback };
196519
+ }
196520
+ catch (error) {
196521
+ error.message =
196522
+ error.message +
196523
+ '\n\n' +
196524
+ 'Failed to create a temporary file to host Snyk script for SBT build analysis.';
196525
+ throw error;
196526
+ }
196534
196527
  }
196535
196528
  function generateSbtPluginPath(sbtVersion) {
196536
196529
  let pluginName = 'SnykSbtPlugin-1.2x.scala';
@@ -196548,59 +196541,57 @@ function generateSbtPluginPath(sbtVersion) {
196548
196541
  throw new Error(`Cannot locate ${pluginName} script`);
196549
196542
  }
196550
196543
  }
196551
- function pluginInspect(root, targetFile, options) {
196552
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
196553
- let injectedScript;
196554
- try {
196555
- const targetFolderPath = path.dirname(path.resolve(root, targetFile));
196556
- const sbtArgs = buildArgs(options.args, false, true);
196557
- const sbtVersion = yield (0, version_1.getSbtVersion)(root, targetFile);
196558
- const sbtPluginPath = generateSbtPluginPath(sbtVersion);
196559
- const packageName = path.basename(root);
196560
- const packageVersion = '1.0.0';
196561
- injectedScript = yield injectSbtScript(sbtPluginPath, targetFolderPath);
196562
- debug('injectedScript.path: ' + injectedScript.path);
196563
- debug('args passed to plugin inspect: ', sbtArgs.join(' '));
196564
- const stdout = yield subProcess.execute('sbt', sbtArgs, {
196565
- cwd: targetFolderPath,
196566
- });
196567
- return {
196568
- plugin: {
196569
- name: 'snyk:sbt',
196570
- runtime: 'unknown',
196571
- meta: {
196572
- versionBuildInfo: {
196573
- metaBuildVersion: {
196574
- sbtVersion,
196575
- },
196544
+ async function pluginInspect(root, targetFile, options) {
196545
+ let injectedScript;
196546
+ try {
196547
+ const targetFolderPath = path.dirname(path.resolve(root, targetFile));
196548
+ const sbtArgs = buildArgs(options.args, false, true);
196549
+ const sbtVersion = await (0, version_1.getSbtVersion)(root, targetFile);
196550
+ const sbtPluginPath = generateSbtPluginPath(sbtVersion);
196551
+ const packageName = path.basename(root);
196552
+ const packageVersion = '1.0.0';
196553
+ injectedScript = await injectSbtScript(sbtPluginPath, targetFolderPath);
196554
+ debug('injectedScript.path: ' + injectedScript.path);
196555
+ debug('args passed to plugin inspect: ', sbtArgs.join(' '));
196556
+ const stdout = await subProcess.execute('sbt', sbtArgs, {
196557
+ cwd: targetFolderPath,
196558
+ });
196559
+ return {
196560
+ plugin: {
196561
+ name: 'snyk:sbt',
196562
+ runtime: 'unknown',
196563
+ meta: {
196564
+ versionBuildInfo: {
196565
+ metaBuildVersion: {
196566
+ sbtVersion,
196576
196567
  },
196577
196568
  },
196578
196569
  },
196579
- package: parser.parseSbtPluginResults(stdout, packageName, packageVersion),
196580
- };
196581
- }
196582
- catch (error) {
196583
- debug('Failed to produce dependency tree with custom snyk plugin due to error: ' +
196584
- error.message);
196585
- return null;
196586
- }
196587
- finally {
196588
- // in case of subProcess.execute failing, perform cleanup here, as putting it after `getInjectScriptPath` might
196589
- // not be executed because of `sbt` failing
196590
- if (injectedScript && injectedScript.remove) {
196591
- try {
196592
- injectedScript.remove();
196593
- debug(`Removed the snyk sbt plugin at '${injectedScript.path}'`);
196594
- }
196595
- catch (error) {
196596
- // NOTE(alexmu): we don't want to kill the whole run because we can still fall back to the legacy
196597
- // method, but at least tell the user to clean up after the CLI :(.
196598
- // tslint:disable-next-line:no-console
196599
- console.warn(`Failed to remove the snyk sbt plugin file at '${injectedScript.path}'`);
196600
- }
196570
+ },
196571
+ package: parser.parseSbtPluginResults(stdout, packageName, packageVersion),
196572
+ };
196573
+ }
196574
+ catch (error) {
196575
+ debug('Failed to produce dependency tree with custom snyk plugin due to error: ' +
196576
+ error.message);
196577
+ return null;
196578
+ }
196579
+ finally {
196580
+ // in case of subProcess.execute failing, perform cleanup here, as putting it after `getInjectScriptPath` might
196581
+ // not be executed because of `sbt` failing
196582
+ if (injectedScript && injectedScript.remove) {
196583
+ try {
196584
+ injectedScript.remove();
196585
+ debug(`Removed the snyk sbt plugin at '${injectedScript.path}'`);
196586
+ }
196587
+ catch (error) {
196588
+ // NOTE(alexmu): we don't want to kill the whole run because we can still fall back to the legacy
196589
+ // method, but at least tell the user to clean up after the CLI :(.
196590
+ // tslint:disable-next-line:no-console
196591
+ console.warn(`Failed to remove the snyk sbt plugin file at '${injectedScript.path}'`);
196601
196592
  }
196602
196593
  }
196603
- });
196594
+ }
196604
196595
  }
196605
196596
  function buildHintMessage(options) {
196606
196597
  const dgArgs = '`sbt ' + buildArgs(options.args, false).join(' ') + '`';
@@ -196729,7 +196720,6 @@ function walkInTree(toNode, fromNode) {
196729
196720
  delete toNode.parent;
196730
196721
  }
196731
196722
  function getPackageNameAndVersion(packageDependency) {
196732
- let splited;
196733
196723
  let version;
196734
196724
  let app;
196735
196725
  if (packageDependency.indexOf('(evicted by:') > -1) {
@@ -196738,7 +196728,7 @@ function getPackageNameAndVersion(packageDependency) {
196738
196728
  if (packageDependency.indexOf('->') > -1) {
196739
196729
  return null;
196740
196730
  }
196741
- splited = packageDependency.split(':');
196731
+ const splited = packageDependency.split(':');
196742
196732
  version = splited[splited.length - 1];
196743
196733
  app = splited[0] + ':' + splited[1];
196744
196734
  app = app.split('\t').join('');
@@ -196851,8 +196841,7 @@ function parseSbtPluginResults(sbtOutput, packageName, packageVersion) {
196851
196841
  exports.parseSbtPluginResults = parseSbtPluginResults;
196852
196842
  const PRODUCTION_SCOPES = ['compile', 'runtime', 'provided'];
196853
196843
  function parseSbtPluginProjectResultToDepTree(projectKey, sbtProjectOutput) {
196854
- const pkgs = Object.keys(sbtProjectOutput.modules)
196855
- .filter((module) => {
196844
+ const pkgs = Object.keys(sbtProjectOutput.modules).filter((module) => {
196856
196845
  return sbtProjectOutput.modules[module].configurations.some((c) => PRODUCTION_SCOPES.includes(c));
196857
196846
  });
196858
196847
  const getDependenciesFor = (name) => {
@@ -196864,7 +196853,8 @@ function parseSbtPluginProjectResultToDepTree(projectKey, sbtProjectOutput) {
196864
196853
  }
196865
196854
  const dependencies = {};
196866
196855
  for (const subDepName of sbtProjectOutput.dependencies[name]) {
196867
- if (pkgs.indexOf(subDepName) > -1) { // dependency is in production configuration
196856
+ if (pkgs.indexOf(subDepName) > -1) {
196857
+ // dependency is in production configuration
196868
196858
  dependencies[subDepName] = getDependenciesFor(subDepName);
196869
196859
  }
196870
196860
  }
@@ -196887,44 +196877,38 @@ function parseSbtPluginProjectResultToDepTree(projectKey, sbtProjectOutput) {
196887
196877
 
196888
196878
  Object.defineProperty(exports, "__esModule", ({ value: true }));
196889
196879
  exports.isPluginInstalled = void 0;
196890
- const tslib_1 = __webpack_require__(70655);
196891
196880
  const path = __webpack_require__(85622);
196892
196881
  const fs = __webpack_require__(35747);
196893
196882
  const os = __webpack_require__(12087);
196894
196883
  const semver = __webpack_require__(36625);
196895
196884
  const version_1 = __webpack_require__(16478);
196896
- function isPluginInstalled(root, targetFile, plugin) {
196897
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
196898
- const searchGlobally = yield searchGlobalFiles(root, targetFile, plugin);
196899
- return searchGlobally || searchProjectFiles(root, targetFile, plugin);
196900
- });
196885
+ async function isPluginInstalled(root, targetFile, plugin) {
196886
+ const searchGlobally = await searchGlobalFiles(root, targetFile, plugin);
196887
+ return searchGlobally || searchProjectFiles(root, targetFile, plugin);
196901
196888
  }
196902
196889
  exports.isPluginInstalled = isPluginInstalled;
196903
196890
  // search project and project/project relative to the root
196904
196891
  function searchProjectFiles(root, targetFile, plugin) {
196905
196892
  const basePath = path.dirname(path.resolve(root, targetFile));
196906
- const sbtFileList = sbtFiles(path.join(basePath, 'project'))
196907
- .concat(sbtFiles(path.join(basePath, 'project', 'project')));
196893
+ const sbtFileList = sbtFiles(path.join(basePath, 'project')).concat(sbtFiles(path.join(basePath, 'project', 'project')));
196908
196894
  const searchResults = sbtFileList.map((file) => {
196909
196895
  return searchWithFs(file, plugin);
196910
196896
  });
196911
196897
  return searchResults.filter(Boolean).length > 0;
196912
196898
  }
196913
196899
  // search globally installed plugins (~/.sbt)
196914
- function searchGlobalFiles(root, targetFile, plugin) {
196915
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
196916
- const homedir = os.homedir();
196917
- const sbtVersion = yield (0, version_1.getSbtVersion)(root, targetFile);
196918
- // https://www.scala-sbt.org/1.x/docs/Using-Plugins.html#Global+plugins
196919
- const pluginsPath = semver.lt(sbtVersion, '1.0.0') ?
196920
- path.join(homedir, '.sbt', '0.13', 'plugins') :
196921
- path.join(homedir, '.sbt', '1.0', 'plugins');
196922
- const sbtFileList = sbtFiles(pluginsPath);
196923
- const searchResults = sbtFileList.map((file) => {
196924
- return searchWithFs(file, plugin);
196925
- });
196926
- return searchResults.filter(Boolean).length > 0;
196900
+ async function searchGlobalFiles(root, targetFile, plugin) {
196901
+ const homedir = os.homedir();
196902
+ const sbtVersion = await (0, version_1.getSbtVersion)(root, targetFile);
196903
+ // https://www.scala-sbt.org/1.x/docs/Using-Plugins.html#Global+plugins
196904
+ const pluginsPath = semver.lt(sbtVersion, '1.0.0')
196905
+ ? path.join(homedir, '.sbt', '0.13', 'plugins')
196906
+ : path.join(homedir, '.sbt', '1.0', 'plugins');
196907
+ const sbtFileList = sbtFiles(pluginsPath);
196908
+ const searchResults = sbtFileList.map((file) => {
196909
+ return searchWithFs(file, plugin);
196927
196910
  });
196911
+ return searchResults.filter(Boolean).length > 0;
196928
196912
  }
196929
196913
  // provide a list of .sbt files in the specified directory
196930
196914
  function sbtFiles(basePath) {
@@ -196996,7 +196980,10 @@ const execute = (command, args, options) => {
196996
196980
  });
196997
196981
  proc.stderr.on('data', (data) => {
196998
196982
  out.stderr = out.stderr + data;
196999
- data.toString().split('\n').forEach((str) => {
196983
+ data
196984
+ .toString()
196985
+ .split('\n')
196986
+ .forEach((str) => {
197000
196987
  debugLogging(str);
197001
196988
  });
197002
196989
  });
@@ -197019,7 +197006,9 @@ const execute = (command, args, options) => {
197019
197006
  exports.execute = execute;
197020
197007
  function kill(id, out) {
197021
197008
  return () => {
197022
- out.stderr = out.stderr + 'Process timed out. To set longer timeout run with `PROC_TIMEOUT=value_in_ms`\n';
197009
+ out.stderr =
197010
+ out.stderr +
197011
+ 'Process timed out. To set longer timeout run with `PROC_TIMEOUT=value_in_ms`\n';
197023
197012
  return treeKill(id);
197024
197013
  };
197025
197014
  }
@@ -197030,8 +197019,6 @@ function kill(id, out) {
197030
197019
  /***/ 856:
197031
197020
  /***/ ((__unused_webpack_module, exports) => {
197032
197021
 
197033
- "use strict";
197034
-
197035
197022
  exports.parse = (lines) => {
197036
197023
  function addHiddenProperties(scope, props) {
197037
197024
  for (const p of Object.keys(props)) {
@@ -197057,7 +197044,7 @@ exports.parse = (lines) => {
197057
197044
  let count = 0;
197058
197045
  for (const i of Object.keys(line)) {
197059
197046
  const ch = line[i];
197060
- if ((ch === '\t')) {
197047
+ if (ch === '\t') {
197061
197048
  count += 1;
197062
197049
  }
197063
197050
  else if (/[^\s]/.test(ch)) {
@@ -197117,61 +197104,59 @@ exports.toJSON = (tree) => {
197117
197104
 
197118
197105
  Object.defineProperty(exports, "__esModule", ({ value: true }));
197119
197106
  exports.getSbtVersion = void 0;
197120
- const tslib_1 = __webpack_require__(70655);
197121
197107
  const fs = __webpack_require__(35747);
197122
197108
  const path = __webpack_require__(85622);
197123
197109
  const subProcess = __webpack_require__(98262);
197124
197110
  const debugModule = __webpack_require__(15158);
197125
197111
  const debug = debugModule('snyk-sbt-plugin');
197126
- function getSbtVersion(root, targetFile) {
197127
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
197128
- try {
197129
- let buildPropsPath = path.join(root, path.dirname(targetFile), 'project/build.properties');
197130
- debug(`getSbtVersion: buildPropsPath=${buildPropsPath}`);
197131
- if (!fs.existsSync(buildPropsPath)) {
197132
- // NOTE(alexmu): We've seen this fail with the wrong path.
197133
- // If the path we derived above doesn't exist, we try to build a more sensible one.
197134
- // targetFile could be a path, so we need to call resolve()
197135
- debug(`getSbtVersion: "${buildPropsPath}" doesn't exist`);
197136
- const resolvedPath = path.resolve(root, targetFile);
197137
- const targetFilePath = path.dirname(resolvedPath);
197138
- buildPropsPath = path.resolve(targetFilePath, 'project/build.properties');
197139
- }
197140
- if (!fs.existsSync(buildPropsPath)) {
197141
- // NOTE(alexmu): Some projects don't have proper subproject structures,
197142
- // e.g. don't have a project/ subfolder. This breaks snyk's assumptions
197143
- // so we try to work around it here.
197144
- debug(`getSbtVersion: "${buildPropsPath}" does not exist`);
197145
- const resolvedPath = path.resolve(root, '..', targetFile);
197146
- const targetFilePath = path.dirname(resolvedPath);
197147
- buildPropsPath = path.resolve(targetFilePath, 'project/build.properties');
197148
- debug(`getSbtVersion: will try "${buildPropsPath}"`);
197149
- }
197150
- return fs
197151
- .readFileSync(buildPropsPath, 'utf-8')
197152
- .split('\n') // split into lines
197153
- .find((line) => !!line.match(/sbt\.version\s*=/)) // locate version line
197154
- .split(/=\s*/)[1]
197155
- .trim(); // return only the version
197156
- }
197157
- catch (err) {
197158
- debug('Failed to get sbt version from project/build.properties: ' + err.message);
197159
- }
197160
- try {
197161
- const stdout = yield subProcess.execute('sbt', ['--version'], {});
197162
- return stdout.split('\n')
197163
- .find((line) => !!line.match(/sbt script version/))
197164
- .split(':')[1]
197165
- .trim();
197166
- }
197167
- catch (err) {
197168
- debug('Failed to get sbt version sbt --version' + err.message);
197112
+ async function getSbtVersion(root, targetFile) {
197113
+ try {
197114
+ let buildPropsPath = path.join(root, path.dirname(targetFile), 'project/build.properties');
197115
+ debug(`getSbtVersion: buildPropsPath=${buildPropsPath}`);
197116
+ if (!fs.existsSync(buildPropsPath)) {
197117
+ // NOTE(alexmu): We've seen this fail with the wrong path.
197118
+ // If the path we derived above doesn't exist, we try to build a more sensible one.
197119
+ // targetFile could be a path, so we need to call resolve()
197120
+ debug(`getSbtVersion: "${buildPropsPath}" doesn't exist`);
197121
+ const resolvedPath = path.resolve(root, targetFile);
197122
+ const targetFilePath = path.dirname(resolvedPath);
197123
+ buildPropsPath = path.resolve(targetFilePath, 'project/build.properties');
197124
+ }
197125
+ if (!fs.existsSync(buildPropsPath)) {
197126
+ // NOTE(alexmu): Some projects don't have proper subproject structures,
197127
+ // e.g. don't have a project/ subfolder. This breaks snyk's assumptions
197128
+ // so we try to work around it here.
197129
+ debug(`getSbtVersion: "${buildPropsPath}" does not exist`);
197130
+ const resolvedPath = path.resolve(root, '..', targetFile);
197131
+ const targetFilePath = path.dirname(resolvedPath);
197132
+ buildPropsPath = path.resolve(targetFilePath, 'project/build.properties');
197133
+ debug(`getSbtVersion: will try "${buildPropsPath}"`);
197169
197134
  }
197170
- // should never get here, but if it does
197171
- // assume sbt 1.0.0 for the purposes of copying the correct scala script and global plugin search
197172
- debug('Assuming sbt version is 1.0.0');
197173
- return '1.0.0';
197174
- });
197135
+ return fs
197136
+ .readFileSync(buildPropsPath, 'utf-8')
197137
+ .split('\n') // split into lines
197138
+ .find((line) => !!line.match(/sbt\.version\s*=/)) // locate version line
197139
+ .split(/=\s*/)[1]
197140
+ .trim(); // return only the version
197141
+ }
197142
+ catch (err) {
197143
+ debug('Failed to get sbt version from project/build.properties: ' + err.message);
197144
+ }
197145
+ try {
197146
+ const stdout = await subProcess.execute('sbt', ['--version'], {});
197147
+ return stdout
197148
+ .split('\n')
197149
+ .find((line) => !!line.match(/sbt script version/))
197150
+ .split(':')[1]
197151
+ .trim();
197152
+ }
197153
+ catch (err) {
197154
+ debug('Failed to get sbt version sbt --version' + err.message);
197155
+ }
197156
+ // should never get here, but if it does
197157
+ // assume sbt 1.0.0 for the purposes of copying the correct scala script and global plugin search
197158
+ debug('Assuming sbt version is 1.0.0');
197159
+ return '1.0.0';
197175
197160
  }
197176
197161
  exports.getSbtVersion = getSbtVersion;
197177
197162
  //# sourceMappingURL=version.js.map