@socketsecurity/cli-with-sentry 0.15.15 → 0.15.16

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.
Files changed (26) hide show
  1. package/dist/.config/tsconfig.dts.tsbuildinfo +1 -1
  2. package/dist/cli.js +666 -557
  3. package/dist/cli.js.map +1 -1
  4. package/dist/constants.js +3 -3
  5. package/dist/constants.js.map +1 -1
  6. package/dist/types/commands/fix/npm-fix.d.mts.map +1 -1
  7. package/dist/types/commands/fix/open-pr.d.mts.map +1 -1
  8. package/dist/types/commands/fix/pnpm-fix.d.mts.map +1 -1
  9. package/dist/types/commands/manifest/cmd-manifest-auto.d.mts.map +1 -1
  10. package/dist/types/commands/manifest/detect-manifest-actions.d.mts +7 -0
  11. package/dist/types/commands/manifest/detect-manifest-actions.d.mts.map +1 -0
  12. package/dist/types/commands/repos/cmd-repos-list.d.mts.map +1 -1
  13. package/dist/types/commands/repos/fetch-list-all-repos.d.mts +8 -0
  14. package/dist/types/commands/repos/fetch-list-all-repos.d.mts.map +1 -0
  15. package/dist/types/commands/repos/handle-list-repos.d.mts +3 -2
  16. package/dist/types/commands/repos/handle-list-repos.d.mts.map +1 -1
  17. package/dist/types/commands/repos/output-list-repos.d.mts +1 -1
  18. package/dist/types/commands/repos/output-list-repos.d.mts.map +1 -1
  19. package/dist/types/commands/scan/cmd-scan-create.d.mts.map +1 -1
  20. package/external/@socketsecurity/registry/lib/logger.d.ts +6 -1
  21. package/external/@socketsecurity/registry/lib/logger.js +39 -3
  22. package/external/@socketsecurity/registry/lib/spinner.js +13 -2
  23. package/external/@socketsecurity/registry/lib/strings.d.ts +7 -2
  24. package/external/@socketsecurity/registry/lib/strings.js +6 -0
  25. package/external/@socketsecurity/registry/package.json +1 -1
  26. package/package.json +3 -2
package/dist/cli.js CHANGED
@@ -3516,7 +3516,7 @@ async function enablePrAutoMerge({
3516
3516
  if (error instanceof vendor.GraphqlResponseError && error.errors) {
3517
3517
  const details = error.errors.map(({
3518
3518
  message
3519
- }) => ` - ${message.trim()}`).join('\n');
3519
+ }) => ` - ${message.trim()}`).join('\n').trim();
3520
3520
  message += `:\n${details}`;
3521
3521
  }
3522
3522
  logger.logger.error(message);
@@ -3686,11 +3686,18 @@ async function npmFix(pkgEnvDetails, {
3686
3686
  // Calling arb.reify() creates the arb.diff object, nulls-out arb.idealTree,
3687
3687
  // and populates arb.actualTree.
3688
3688
  let actualTree = await arb.reify();
3689
- const alertsMap = purls.length ? await utils.getAlertsMapFromPurls(purls, getAlertMapOptions({
3690
- limit
3691
- })) : await shadowInject.getAlertsMapFromArborist(arb, getAlertMapOptions({
3692
- limit
3693
- }));
3689
+ let alertsMap;
3690
+ try {
3691
+ alertsMap = purls.length ? await utils.getAlertsMapFromPurls(purls, getAlertMapOptions({
3692
+ limit
3693
+ })) : await shadowInject.getAlertsMapFromArborist(arb, getAlertMapOptions({
3694
+ limit
3695
+ }));
3696
+ } catch (e) {
3697
+ spinner?.stop();
3698
+ logger.logger.error(e?.message || 'Unknown Socket batch PURL API error');
3699
+ return;
3700
+ }
3694
3701
  const infoByPkgName = utils.getCveInfoFromAlertsMap(alertsMap, {
3695
3702
  limit
3696
3703
  });
@@ -3842,11 +3849,12 @@ async function npmFix(pkgEnvDetails, {
3842
3849
  stdio: 'ignore'
3843
3850
  });
3844
3851
  }
3845
- spinner?.successAndStop(`Fixed ${name} in ${workspaceName}`);
3852
+ spinner?.success(`Fixed ${name} in ${workspaceName}`);
3846
3853
  } catch (e) {
3847
3854
  errored = true;
3848
3855
  error = e;
3849
3856
  }
3857
+ spinner?.stop();
3850
3858
  if (!errored && isCi) {
3851
3859
  const branch = getSocketBranchName(oldPurl, newVersion, workspaceName);
3852
3860
  try {
@@ -3912,10 +3920,14 @@ async function npmFix(pkgEnvDetails, {
3912
3920
  const {
3913
3921
  data
3914
3922
  } = prResponse;
3915
- logger.logger.info(`Opened PR #${data.number}.`);
3923
+ logger.logger.success(`Opened PR #${data.number}.`);
3916
3924
  if (autoMerge) {
3925
+ logger.logger.indent();
3926
+ spinner?.indent();
3917
3927
  // eslint-disable-next-line no-await-in-loop
3918
3928
  await enablePrAutoMerge(data);
3929
+ logger.logger.dedent();
3930
+ spinner?.dedent();
3919
3931
  }
3920
3932
  }
3921
3933
  } catch (e) {
@@ -3933,6 +3945,7 @@ async function npmFix(pkgEnvDetails, {
3933
3945
  }
3934
3946
  if (errored) {
3935
3947
  if (!isCi) {
3948
+ spinner?.start();
3936
3949
  editablePkgJson.update(revertData);
3937
3950
  // eslint-disable-next-line no-await-in-loop
3938
3951
  await Promise.all([utils.removeNodeModules(cwd), editablePkgJson.save({
@@ -3942,8 +3955,9 @@ async function npmFix(pkgEnvDetails, {
3942
3955
  actualTree = await install$1(arb, {
3943
3956
  cwd
3944
3957
  });
3958
+ spinner?.stop();
3945
3959
  }
3946
- spinner?.failAndStop(`Update failed for ${oldId} in ${workspaceName}`, error);
3960
+ logger.logger.fail(`Update failed for ${oldId} in ${workspaceName}`, error);
3947
3961
  }
3948
3962
  if (++count >= limit) {
3949
3963
  logger.logger.dedent();
@@ -3953,14 +3967,14 @@ async function npmFix(pkgEnvDetails, {
3953
3967
  }
3954
3968
  }
3955
3969
  if (!isLastPkgJsonPath && logger.logger.logCallCount > workspaceLogCallCount) {
3956
- logger.logger.log('');
3970
+ logger.logger.logNewline();
3957
3971
  }
3958
3972
  }
3959
3973
  for (const warningText of warningsForAfter) {
3960
3974
  logger.logger.warn(warningText);
3961
3975
  }
3962
3976
  if (!isLastInfoEntry) {
3963
- logger.logger.log('');
3977
+ logger.logger.logNewline();
3964
3978
  }
3965
3979
  logger.logger.dedent();
3966
3980
  spinner?.dedent();
@@ -4057,11 +4071,18 @@ async function pnpmFix(pkgEnvDetails, {
4057
4071
  logger.logger.error('Required pnpm-lock.yaml not found.');
4058
4072
  return;
4059
4073
  }
4060
- const alertsMap = purls.length ? await utils.getAlertsMapFromPurls(purls, getAlertMapOptions({
4061
- limit
4062
- })) : await utils.getAlertsMapFromPnpmLockfile(lockfile, getAlertMapOptions({
4063
- limit
4064
- }));
4074
+ let alertsMap;
4075
+ try {
4076
+ alertsMap = purls.length ? await utils.getAlertsMapFromPurls(purls, getAlertMapOptions({
4077
+ limit
4078
+ })) : await utils.getAlertsMapFromPnpmLockfile(lockfile, getAlertMapOptions({
4079
+ limit
4080
+ }));
4081
+ } catch (e) {
4082
+ spinner?.stop();
4083
+ logger.logger.error(e?.message || 'Unknown Socket batch PURL API error');
4084
+ return;
4085
+ }
4065
4086
  const infoByPkgName = utils.getCveInfoFromAlertsMap(alertsMap, {
4066
4087
  limit
4067
4088
  });
@@ -4248,12 +4269,12 @@ async function pnpmFix(pkgEnvDetails, {
4248
4269
  stdio: 'ignore'
4249
4270
  });
4250
4271
  }
4251
- spinner?.successAndStop(`Fixed ${name} in ${workspaceName}`);
4272
+ spinner?.success(`Fixed ${name} in ${workspaceName}`);
4252
4273
  } catch (e) {
4253
4274
  error = e;
4254
4275
  errored = true;
4255
- spinner?.stop();
4256
4276
  }
4277
+ spinner?.stop();
4257
4278
  if (!errored && isCi) {
4258
4279
  const branch = getSocketBranchName(oldPurl, newVersion, workspaceName);
4259
4280
  try {
@@ -4322,10 +4343,14 @@ async function pnpmFix(pkgEnvDetails, {
4322
4343
  const {
4323
4344
  data
4324
4345
  } = prResponse;
4325
- logger.logger.info(`Opened PR #${data.number}.`);
4346
+ logger.logger.success(`Opened PR #${data.number}.`);
4326
4347
  if (autoMerge) {
4348
+ logger.logger.indent();
4349
+ spinner?.indent();
4327
4350
  // eslint-disable-next-line no-await-in-loop
4328
4351
  await enablePrAutoMerge(data);
4352
+ logger.logger.dedent();
4353
+ spinner?.dedent();
4329
4354
  }
4330
4355
  }
4331
4356
  } catch (e) {
@@ -4344,6 +4369,7 @@ async function pnpmFix(pkgEnvDetails, {
4344
4369
  }
4345
4370
  if (errored) {
4346
4371
  if (!isCi) {
4372
+ spinner?.start();
4347
4373
  editablePkgJson.update(revertData);
4348
4374
  // eslint-disable-next-line no-await-in-loop
4349
4375
  await Promise.all([utils.removeNodeModules(cwd), editablePkgJson.save({
@@ -4354,8 +4380,9 @@ async function pnpmFix(pkgEnvDetails, {
4354
4380
  cwd,
4355
4381
  spinner
4356
4382
  });
4383
+ spinner?.stop();
4357
4384
  }
4358
- spinner?.failAndStop(`Update failed for ${oldId} in ${workspaceName}`, error);
4385
+ logger.logger.fail(`Update failed for ${oldId} in ${workspaceName}`, error);
4359
4386
  }
4360
4387
  if (++count >= limit) {
4361
4388
  logger.logger.dedent();
@@ -4365,14 +4392,14 @@ async function pnpmFix(pkgEnvDetails, {
4365
4392
  }
4366
4393
  }
4367
4394
  if (!isLastPkgJsonPath && logger.logger.logCallCount > workspaceLogCallCount) {
4368
- logger.logger.log('');
4395
+ logger.logger.logNewline();
4369
4396
  }
4370
4397
  }
4371
4398
  for (const warningText of warningsForAfter) {
4372
4399
  logger.logger.warn(warningText);
4373
4400
  }
4374
4401
  if (!isLastInfoEntry) {
4375
- logger.logger.log('');
4402
+ logger.logger.logNewline();
4376
4403
  }
4377
4404
  logger.logger.dedent();
4378
4405
  spinner?.dedent();
@@ -5153,6 +5180,247 @@ async function run$z(argv, importMeta, {
5153
5180
  attemptLogout();
5154
5181
  }
5155
5182
 
5183
+ async function convertGradleToMaven(target, bin, cwd, verbose, gradleOpts) {
5184
+ // TODO: impl json/md
5185
+ if (verbose) {
5186
+ logger.logger.log('[VERBOSE] Resolving:', [cwd, bin]);
5187
+ }
5188
+ const rbin = path.resolve(cwd, bin);
5189
+ if (verbose) {
5190
+ logger.logger.log('[VERBOSE] Resolving:', [cwd, target]);
5191
+ }
5192
+ const rtarget = path.resolve(cwd, target);
5193
+ const binExists = fs$1.existsSync(rbin);
5194
+ const targetExists = fs$1.existsSync(rtarget);
5195
+ logger.logger.group('gradle2maven:');
5196
+ if (verbose || debug.isDebug()) {
5197
+ logger.logger.log(`[VERBOSE] - Absolute bin path: \`${rbin}\` (${binExists ? 'found' : vendor.yoctocolorsCjsExports.red('not found!')})`);
5198
+ logger.logger.log(`[VERBOSE] - Absolute target path: \`${rtarget}\` (${targetExists ? 'found' : vendor.yoctocolorsCjsExports.red('not found!')})`);
5199
+ } else {
5200
+ logger.logger.log(`- executing: \`${rbin}\``);
5201
+ if (!binExists) {
5202
+ logger.logger.warn('Warning: It appears the executable could not be found at this location. An error might be printed later because of that.');
5203
+ }
5204
+ logger.logger.log(`- src dir: \`${rtarget}\``);
5205
+ if (!targetExists) {
5206
+ logger.logger.warn('Warning: It appears the src dir could not be found at this location. An error might be printed later because of that.');
5207
+ }
5208
+ }
5209
+ logger.logger.groupEnd();
5210
+ try {
5211
+ // Run gradlew with the init script we provide which should yield zero or more
5212
+ // pom files. We have to figure out where to store those pom files such that
5213
+ // we can upload them and predict them through the GitHub API. We could do a
5214
+ // .socket folder. We could do a socket.pom.gz with all the poms, although
5215
+ // I'd prefer something plain-text if it is to be committed.
5216
+
5217
+ // Note: init.gradle will be exported by .config/rollup.dist.config.mjs
5218
+ const initLocation = path.join(constants.distPath, 'init.gradle');
5219
+ const commandArgs = ['--init-script', initLocation, ...gradleOpts, 'pom'];
5220
+ if (verbose) {
5221
+ logger.logger.log('[VERBOSE] Executing:', [bin], ', args:', commandArgs);
5222
+ }
5223
+ logger.logger.log(`Converting gradle to maven from \`${bin}\` on \`${target}\` ...`);
5224
+ const output = await execGradleWithSpinner(rbin, commandArgs, rtarget, cwd);
5225
+ if (verbose) {
5226
+ logger.logger.group('[VERBOSE] gradle stdout:');
5227
+ logger.logger.log(output);
5228
+ logger.logger.groupEnd();
5229
+ }
5230
+ if (output.code !== 0) {
5231
+ process.exitCode = 1;
5232
+ logger.logger.fail(`Gradle exited with exit code ${output.code}`);
5233
+ // (In verbose mode, stderr was printed above, no need to repeat it)
5234
+ if (!verbose) {
5235
+ logger.logger.group('stderr:');
5236
+ logger.logger.error(output.stderr);
5237
+ logger.logger.groupEnd();
5238
+ }
5239
+ return;
5240
+ }
5241
+ logger.logger.success('Executed gradle successfully');
5242
+ logger.logger.log('Reported exports:');
5243
+ output.stdout.replace(/^POM file copied to: (.*)/gm, (_all, fn) => {
5244
+ logger.logger.log('- ', fn);
5245
+ return fn;
5246
+ });
5247
+ logger.logger.log('');
5248
+ logger.logger.log('Next step is to generate a Scan by running the `socket scan create` command on the same directory');
5249
+ } catch (e) {
5250
+ process.exitCode = 1;
5251
+ logger.logger.fail('There was an unexpected error while generating manifests' + (verbose ? '' : ' (use --verbose for details)'));
5252
+ if (verbose) {
5253
+ logger.logger.group('[VERBOSE] error:');
5254
+ logger.logger.log(e);
5255
+ logger.logger.groupEnd();
5256
+ }
5257
+ }
5258
+ }
5259
+ async function execGradleWithSpinner(bin, commandArgs, target, cwd) {
5260
+ // Lazily access constants.spinner.
5261
+ const {
5262
+ spinner
5263
+ } = constants;
5264
+ let pass = false;
5265
+ try {
5266
+ spinner.start(`Running gradlew... (this can take a while, it depends on how long gradlew has to run)`);
5267
+ const output = await spawn.spawn(bin, commandArgs, {
5268
+ // We can pipe the output through to have the user see the result
5269
+ // of running gradlew, but then we can't (easily) gather the output
5270
+ // to discover the generated files... probably a flag we should allow?
5271
+ // stdio: isDebug() ? 'inherit' : undefined,
5272
+ cwd: target || cwd
5273
+ });
5274
+ pass = true;
5275
+ const {
5276
+ code,
5277
+ stderr,
5278
+ stdout
5279
+ } = output;
5280
+ return {
5281
+ code,
5282
+ stdout,
5283
+ stderr
5284
+ };
5285
+ } finally {
5286
+ if (pass) {
5287
+ spinner.successAndStop('Completed gradlew execution');
5288
+ } else {
5289
+ spinner.failAndStop('There was an error while trying to run gradlew.');
5290
+ }
5291
+ }
5292
+ }
5293
+
5294
+ async function convertSbtToMaven(target, bin, out, verbose, sbtOpts) {
5295
+ // TODO: impl json/md
5296
+
5297
+ // Lazily access constants.spinner.
5298
+ const {
5299
+ spinner
5300
+ } = constants;
5301
+ const rbin = path.resolve(bin);
5302
+ const rtarget = path.resolve(target);
5303
+ if (verbose) {
5304
+ logger.logger.group('sbt2maven:');
5305
+ logger.logger.log(`[VERBOSE] - Absolute bin path: \`${rbin}\``);
5306
+ logger.logger.log(`[VERBOSE] - Absolute target path: \`${rtarget}\``);
5307
+ // logger.log(`[VERBOSE] - Absolute out path: \`${rout}\``)
5308
+ logger.logger.groupEnd();
5309
+ } else {
5310
+ logger.logger.group('sbt2maven:');
5311
+ logger.logger.log(`- executing: \`${bin}\``);
5312
+ logger.logger.log(`- src dir: \`${target}\``);
5313
+ // logger.log(`- dst dir: \`${out}\``)
5314
+ logger.logger.groupEnd();
5315
+ }
5316
+ try {
5317
+ spinner.start(`Converting sbt to maven from \`${bin}\` on \`${target}\`...`);
5318
+
5319
+ // Run sbt with the init script we provide which should yield zero or more
5320
+ // pom files. We have to figure out where to store those pom files such that
5321
+ // we can upload them and predict them through the GitHub API. We could do a
5322
+ // .socket folder. We could do a socket.pom.gz with all the poms, although
5323
+ // I'd prefer something plain-text if it is to be committed.
5324
+ const output = await spawn.spawn(bin, ['makePom'].concat(sbtOpts), {
5325
+ cwd: target || '.'
5326
+ });
5327
+ spinner.stop();
5328
+ if (verbose) {
5329
+ logger.logger.group('[VERBOSE] sbt stdout:');
5330
+ logger.logger.log(output);
5331
+ logger.logger.groupEnd();
5332
+ }
5333
+ if (output.stderr) {
5334
+ process.exitCode = 1;
5335
+ logger.logger.fail('There were errors while running sbt');
5336
+ // (In verbose mode, stderr was printed above, no need to repeat it)
5337
+ if (!verbose) {
5338
+ logger.logger.group('[VERBOSE] stderr:');
5339
+ logger.logger.error(output.stderr);
5340
+ logger.logger.groupEnd();
5341
+ }
5342
+ return;
5343
+ }
5344
+ const poms = [];
5345
+ output.stdout.replace(/Wrote (.*?.pom)\n/g, (_all, fn) => {
5346
+ poms.push(fn);
5347
+ return fn;
5348
+ });
5349
+ if (!poms.length) {
5350
+ process.exitCode = 1;
5351
+ logger.logger.fail('There were no errors from sbt but it seems to not have generated any poms either');
5352
+ return;
5353
+ }
5354
+ // Move the pom file to ...? initial cwd? loc will be an absolute path, or dump to stdout
5355
+ // TODO: what to do with multiple output files? Do we want to dump them to stdout? Raw or with separators or ?
5356
+ // TODO: maybe we can add an option to target a specific file to dump to stdout
5357
+ if (out === '-' && poms.length === 1) {
5358
+ logger.logger.log('Result:\n```');
5359
+ logger.logger.log(await utils.safeReadFile(poms[0]));
5360
+ logger.logger.log('```');
5361
+ logger.logger.success(`OK`);
5362
+ } else if (out === '-') {
5363
+ process.exitCode = 1;
5364
+ logger.logger.fail('Requested out target was stdout but there are multiple generated files');
5365
+ poms.forEach(fn => logger.logger.error('-', fn));
5366
+ logger.logger.info('Exiting now...');
5367
+ return;
5368
+ } else {
5369
+ // if (verbose) {
5370
+ // logger.log(
5371
+ // `Moving manifest file from \`${loc.replace(/^\/home\/[^/]*?\//, '~/')}\` to \`${out}\``
5372
+ // )
5373
+ // } else {
5374
+ // logger.log('Moving output pom file')
5375
+ // }
5376
+ // TODO: do we prefer fs-extra? renaming can be gnarly on windows and fs-extra's version is better
5377
+ // await renamep(loc, out)
5378
+ logger.logger.success(`Generated ${poms.length} pom files`);
5379
+ poms.forEach(fn => logger.logger.log('-', fn));
5380
+ logger.logger.success(`OK`);
5381
+ }
5382
+ } catch (e) {
5383
+ process.exitCode = 1;
5384
+ spinner.stop();
5385
+ logger.logger.fail('There was an unexpected error while running this' + (verbose ? '' : ' (use --verbose for details)'));
5386
+ if (verbose) {
5387
+ logger.logger.group('[VERBOSE] error:');
5388
+ logger.logger.log(e);
5389
+ logger.logger.groupEnd();
5390
+ }
5391
+ }
5392
+ }
5393
+
5394
+ // The point here is to attempt to detect the various supported manifest files
5395
+ // the CLI can generate. This would be environments that we can't do server side
5396
+
5397
+ async function detectManifestActions(cwd = process.cwd()) {
5398
+ const output = {
5399
+ cdxgen: false,
5400
+ // TODO
5401
+ conda: false,
5402
+ gradle: false,
5403
+ sbt: false
5404
+ };
5405
+ if (fs$1.existsSync(path.join(cwd, 'build.sbt'))) {
5406
+ debug.debugLog('Detected a Scala sbt build, running default Scala generator...');
5407
+ output.sbt = true;
5408
+ }
5409
+ if (fs$1.existsSync(path.join(cwd, 'gradlew'))) {
5410
+ debug.debugLog('Detected a gradle build, running default gradle generator...');
5411
+ output.gradle = true;
5412
+ }
5413
+ const envyml = path.join(cwd, 'environment.yml');
5414
+ const hasEnvyml = fs$1.existsSync(envyml);
5415
+ const envyaml = path.join(cwd, 'environment.yaml');
5416
+ const hasEnvyaml = !hasEnvyml && fs$1.existsSync(envyaml);
5417
+ if (hasEnvyml || hasEnvyaml) {
5418
+ debug.debugLog('Detected an environment.yml file, running default Conda generator...');
5419
+ output.conda = true;
5420
+ }
5421
+ return output;
5422
+ }
5423
+
5156
5424
  async function convertCondaToRequirements(target, cwd, verbose) {
5157
5425
  let contents;
5158
5426
  if (target === '-') {
@@ -5331,24 +5599,117 @@ const {
5331
5599
  DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$v
5332
5600
  } = constants;
5333
5601
  const config$y = {
5334
- commandName: 'conda',
5335
- description: '[beta] Convert a Conda environment.yml file to a python requirements.txt',
5602
+ commandName: 'auto',
5603
+ description: 'Auto-detect build and attempt to generate manifest file',
5336
5604
  hidden: false,
5337
5605
  flags: {
5338
5606
  ...utils.commonFlags,
5339
- ...utils.outputFlags,
5340
5607
  cwd: {
5341
5608
  type: 'string',
5342
5609
  description: 'Set the cwd, defaults to process.cwd()'
5343
5610
  },
5344
- out: {
5345
- type: 'string',
5346
- default: '-',
5347
- description: 'Output target (use `-` or omit to print to stdout)'
5348
- },
5349
5611
  verbose: {
5350
5612
  type: 'boolean',
5351
- description: 'Print debug messages'
5613
+ default: false,
5614
+ description: 'Enable debug output, may help when running into errors'
5615
+ }
5616
+ },
5617
+ help: (command, config) => `
5618
+ Usage
5619
+ $ ${command}
5620
+
5621
+ Options
5622
+ ${utils.getFlagListOutput(config.flags, 6)}
5623
+
5624
+ Tries to figure out what language your current repo uses. If it finds a
5625
+ supported case then it will try to generate the manifest file for that
5626
+ language with the default or detected settings.
5627
+ `
5628
+ };
5629
+ const cmdManifestAuto = {
5630
+ description: config$y.description,
5631
+ hidden: config$y.hidden,
5632
+ run: run$y
5633
+ };
5634
+ async function run$y(argv, importMeta, {
5635
+ parentName
5636
+ }) {
5637
+ const cli = utils.meowOrExit({
5638
+ argv,
5639
+ config: config$y,
5640
+ importMeta,
5641
+ parentName
5642
+ });
5643
+ const {
5644
+ cwd: cwdFlag,
5645
+ json,
5646
+ markdown,
5647
+ verbose: verboseFlag
5648
+ } = cli.flags;
5649
+ const outputKind = utils.getOutputKind(json, markdown); // TODO: impl json/md further
5650
+ const cwd = String(cwdFlag || process.cwd());
5651
+ const verbose = !!verboseFlag;
5652
+ if (verbose) {
5653
+ logger.logger.group('- ', parentName, config$y.commandName, ':');
5654
+ logger.logger.group('- flags:', cli.flags);
5655
+ logger.logger.groupEnd();
5656
+ logger.logger.log('- input:', cli.input);
5657
+ logger.logger.log('- cwd:', cwd);
5658
+ logger.logger.groupEnd();
5659
+ }
5660
+ const result = await detectManifestActions(String(cwd));
5661
+ debug.debugLog(result);
5662
+ if (cli.flags['dryRun']) {
5663
+ logger.logger.log(DRY_RUN_BAILING_NOW$v);
5664
+ return;
5665
+ }
5666
+ const found = Object.values(result).reduce((sum, now) => now ? sum + 1 : sum, 0);
5667
+ if (!found) {
5668
+ logger.logger.fail(' Was unable to discover any targets for which we can generate manifest files...');
5669
+ logger.logger.log('');
5670
+ logger.logger.log('- Make sure this script would work with your target build (see `socket manifest --help` for your target).');
5671
+ logger.logger.log('- Make sure to run it from the correct dir (use --cwd to target another dir)');
5672
+ logger.logger.log('- Make sure the necessary build tools are available (`PATH`)');
5673
+ process.exitCode = 1;
5674
+ return;
5675
+ }
5676
+ if (result.sbt) {
5677
+ logger.logger.log('Detected a Scala sbt build, generating pom files with sbt...');
5678
+ await convertSbtToMaven(cwd, 'sbt', './socket.sbt.pom.xml', verbose, []);
5679
+ }
5680
+ if (result.gradle) {
5681
+ logger.logger.log('Detected a gradle build (Gradle, Kotlin, Scala), running default gradle generator...');
5682
+ await convertGradleToMaven(cwd, path.join(cwd, 'gradlew'), cwd, verbose, []);
5683
+ }
5684
+ if (result.conda) {
5685
+ logger.logger.log('Detected an environment.yml file, running default Conda generator...');
5686
+ await handleManifestConda(cwd, '', outputKind, cwd, verbose);
5687
+ }
5688
+ logger.logger.success(`Finished. Should have attempted to generate manifest files for ${found} targets.`);
5689
+ }
5690
+
5691
+ const {
5692
+ DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$u
5693
+ } = constants;
5694
+ const config$x = {
5695
+ commandName: 'conda',
5696
+ description: '[beta] Convert a Conda environment.yml file to a python requirements.txt',
5697
+ hidden: false,
5698
+ flags: {
5699
+ ...utils.commonFlags,
5700
+ ...utils.outputFlags,
5701
+ cwd: {
5702
+ type: 'string',
5703
+ description: 'Set the cwd, defaults to process.cwd()'
5704
+ },
5705
+ out: {
5706
+ type: 'string',
5707
+ default: '-',
5708
+ description: 'Output target (use `-` or omit to print to stdout)'
5709
+ },
5710
+ verbose: {
5711
+ type: 'boolean',
5712
+ description: 'Print debug messages'
5352
5713
  }
5353
5714
  },
5354
5715
  help: (command, config) => `
@@ -5373,16 +5734,16 @@ const config$y = {
5373
5734
  `
5374
5735
  };
5375
5736
  const cmdManifestConda = {
5376
- description: config$y.description,
5377
- hidden: config$y.hidden,
5378
- run: run$y
5737
+ description: config$x.description,
5738
+ hidden: config$x.hidden,
5739
+ run: run$x
5379
5740
  };
5380
- async function run$y(argv, importMeta, {
5741
+ async function run$x(argv, importMeta, {
5381
5742
  parentName
5382
5743
  }) {
5383
5744
  const cli = utils.meowOrExit({
5384
5745
  argv,
5385
- config: config$y,
5746
+ config: config$x,
5386
5747
  importMeta,
5387
5748
  parentName
5388
5749
  });
@@ -5397,7 +5758,7 @@ async function run$y(argv, importMeta, {
5397
5758
 
5398
5759
  const [target = ''] = cli.input;
5399
5760
  if (verbose) {
5400
- logger.logger.group('- ', parentName, config$y.commandName, ':');
5761
+ logger.logger.group('- ', parentName, config$x.commandName, ':');
5401
5762
  logger.logger.group('- flags:', cli.flags);
5402
5763
  logger.logger.groupEnd();
5403
5764
  logger.logger.log('- target:', target);
@@ -5427,127 +5788,16 @@ async function run$y(argv, importMeta, {
5427
5788
  }
5428
5789
  logger.logger.warn('Warning: This will approximate your Conda dependencies using PyPI. We do not yet officially support Conda. Use at your own risk.');
5429
5790
  if (cli.flags['dryRun']) {
5430
- logger.logger.log(DRY_RUN_BAILING_NOW$v);
5791
+ logger.logger.log(DRY_RUN_BAILING_NOW$u);
5431
5792
  return;
5432
5793
  }
5433
5794
  await handleManifestConda(target, String(out || ''), json ? 'json' : markdown ? 'markdown' : 'text', String(cwd), Boolean(verbose));
5434
5795
  }
5435
5796
 
5436
- async function convertGradleToMaven(target, bin, cwd, verbose, gradleOpts) {
5437
- // TODO: impl json/md
5438
- if (verbose) {
5439
- logger.logger.log('[VERBOSE] Resolving:', [cwd, bin]);
5440
- }
5441
- const rbin = path.resolve(cwd, bin);
5442
- if (verbose) {
5443
- logger.logger.log('[VERBOSE] Resolving:', [cwd, target]);
5444
- }
5445
- const rtarget = path.resolve(cwd, target);
5446
- const binExists = fs$1.existsSync(rbin);
5447
- const targetExists = fs$1.existsSync(rtarget);
5448
- logger.logger.group('gradle2maven:');
5449
- if (verbose || debug.isDebug()) {
5450
- logger.logger.log(`[VERBOSE] - Absolute bin path: \`${rbin}\` (${binExists ? 'found' : vendor.yoctocolorsCjsExports.red('not found!')})`);
5451
- logger.logger.log(`[VERBOSE] - Absolute target path: \`${rtarget}\` (${targetExists ? 'found' : vendor.yoctocolorsCjsExports.red('not found!')})`);
5452
- } else {
5453
- logger.logger.log(`- executing: \`${rbin}\``);
5454
- if (!binExists) {
5455
- logger.logger.warn('Warning: It appears the executable could not be found at this location. An error might be printed later because of that.');
5456
- }
5457
- logger.logger.log(`- src dir: \`${rtarget}\``);
5458
- if (!targetExists) {
5459
- logger.logger.warn('Warning: It appears the src dir could not be found at this location. An error might be printed later because of that.');
5460
- }
5461
- }
5462
- logger.logger.groupEnd();
5463
- try {
5464
- // Run gradlew with the init script we provide which should yield zero or more
5465
- // pom files. We have to figure out where to store those pom files such that
5466
- // we can upload them and predict them through the GitHub API. We could do a
5467
- // .socket folder. We could do a socket.pom.gz with all the poms, although
5468
- // I'd prefer something plain-text if it is to be committed.
5469
-
5470
- // Note: init.gradle will be exported by .config/rollup.dist.config.mjs
5471
- const initLocation = path.join(constants.distPath, 'init.gradle');
5472
- const commandArgs = ['--init-script', initLocation, ...gradleOpts, 'pom'];
5473
- if (verbose) {
5474
- logger.logger.log('[VERBOSE] Executing:', [bin], ', args:', commandArgs);
5475
- }
5476
- logger.logger.log(`Converting gradle to maven from \`${bin}\` on \`${target}\` ...`);
5477
- const output = await execGradleWithSpinner(rbin, commandArgs, rtarget, cwd);
5478
- if (verbose) {
5479
- logger.logger.group('[VERBOSE] gradle stdout:');
5480
- logger.logger.log(output);
5481
- logger.logger.groupEnd();
5482
- }
5483
- if (output.code !== 0) {
5484
- process.exitCode = 1;
5485
- logger.logger.fail(`Gradle exited with exit code ${output.code}`);
5486
- // (In verbose mode, stderr was printed above, no need to repeat it)
5487
- if (!verbose) {
5488
- logger.logger.group('stderr:');
5489
- logger.logger.error(output.stderr);
5490
- logger.logger.groupEnd();
5491
- }
5492
- return;
5493
- }
5494
- logger.logger.success('Executed gradle successfully');
5495
- logger.logger.log('Reported exports:');
5496
- output.stdout.replace(/^POM file copied to: (.*)/gm, (_all, fn) => {
5497
- logger.logger.log('- ', fn);
5498
- return fn;
5499
- });
5500
- logger.logger.log('');
5501
- logger.logger.log('Next step is to generate a Scan by running the `socket scan create` command on the same directory');
5502
- } catch (e) {
5503
- process.exitCode = 1;
5504
- logger.logger.fail('There was an unexpected error while generating manifests' + (verbose ? '' : ' (use --verbose for details)'));
5505
- if (verbose) {
5506
- logger.logger.group('[VERBOSE] error:');
5507
- logger.logger.log(e);
5508
- logger.logger.groupEnd();
5509
- }
5510
- }
5511
- }
5512
- async function execGradleWithSpinner(bin, commandArgs, target, cwd) {
5513
- // Lazily access constants.spinner.
5514
- const {
5515
- spinner
5516
- } = constants;
5517
- let pass = false;
5518
- try {
5519
- spinner.start(`Running gradlew... (this can take a while, it depends on how long gradlew has to run)`);
5520
- const output = await spawn.spawn(bin, commandArgs, {
5521
- // We can pipe the output through to have the user see the result
5522
- // of running gradlew, but then we can't (easily) gather the output
5523
- // to discover the generated files... probably a flag we should allow?
5524
- // stdio: isDebug() ? 'inherit' : undefined,
5525
- cwd: target || cwd
5526
- });
5527
- pass = true;
5528
- const {
5529
- code,
5530
- stderr,
5531
- stdout
5532
- } = output;
5533
- return {
5534
- code,
5535
- stdout,
5536
- stderr
5537
- };
5538
- } finally {
5539
- if (pass) {
5540
- spinner.successAndStop('Completed gradlew execution');
5541
- } else {
5542
- spinner.failAndStop('There was an error while trying to run gradlew.');
5543
- }
5544
- }
5545
- }
5546
-
5547
5797
  const {
5548
- DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$u
5798
+ DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$t
5549
5799
  } = constants;
5550
- const config$x = {
5800
+ const config$w = {
5551
5801
  commandName: 'gradle',
5552
5802
  description: '[beta] Use Gradle to generate a manifest file (`pom.xml`) for a Gradle/Java/Kotlin/etc project',
5553
5803
  hidden: false,
@@ -5610,16 +5860,16 @@ const config$x = {
5610
5860
  `
5611
5861
  };
5612
5862
  const cmdManifestGradle = {
5613
- description: config$x.description,
5614
- hidden: config$x.hidden,
5615
- run: run$x
5863
+ description: config$w.description,
5864
+ hidden: config$w.hidden,
5865
+ run: run$w
5616
5866
  };
5617
- async function run$x(argv, importMeta, {
5867
+ async function run$w(argv, importMeta, {
5618
5868
  parentName
5619
5869
  }) {
5620
5870
  const cli = utils.meowOrExit({
5621
5871
  argv,
5622
- config: config$x,
5872
+ config: config$w,
5623
5873
  importMeta,
5624
5874
  parentName
5625
5875
  });
@@ -5631,7 +5881,7 @@ async function run$x(argv, importMeta, {
5631
5881
  const outputKind = utils.getOutputKind(json, markdown); // TODO: impl json/md further
5632
5882
 
5633
5883
  if (verbose) {
5634
- logger.logger.group('- ', parentName, config$x.commandName, ':');
5884
+ logger.logger.group('- ', parentName, config$w.commandName, ':');
5635
5885
  logger.logger.group('- flags:', cli.flags);
5636
5886
  logger.logger.groupEnd();
5637
5887
  logger.logger.log('- input:', cli.input);
@@ -5673,143 +5923,44 @@ async function run$x(argv, importMeta, {
5673
5923
  gradleOpts = cli.flags['gradleOpts'].split(' ').map(s => s.trim()).filter(Boolean);
5674
5924
  }
5675
5925
  if (cli.flags['dryRun']) {
5676
- logger.logger.log(DRY_RUN_BAILING_NOW$u);
5926
+ logger.logger.log(DRY_RUN_BAILING_NOW$t);
5677
5927
  return;
5678
5928
  }
5679
5929
  await convertGradleToMaven(target, String(bin), String(cwd), verbose, gradleOpts);
5680
5930
  }
5681
5931
 
5682
- async function convertSbtToMaven(target, bin, out, verbose, sbtOpts) {
5683
- // TODO: impl json/md
5684
-
5685
- // Lazily access constants.spinner.
5686
- const {
5687
- spinner
5688
- } = constants;
5689
- const rbin = path.resolve(bin);
5690
- const rtarget = path.resolve(target);
5691
- if (verbose) {
5692
- logger.logger.group('sbt2maven:');
5693
- logger.logger.log(`[VERBOSE] - Absolute bin path: \`${rbin}\``);
5694
- logger.logger.log(`[VERBOSE] - Absolute target path: \`${rtarget}\``);
5695
- // logger.log(`[VERBOSE] - Absolute out path: \`${rout}\``)
5696
- logger.logger.groupEnd();
5697
- } else {
5698
- logger.logger.group('sbt2maven:');
5699
- logger.logger.log(`- executing: \`${bin}\``);
5700
- logger.logger.log(`- src dir: \`${target}\``);
5701
- // logger.log(`- dst dir: \`${out}\``)
5702
- logger.logger.groupEnd();
5703
- }
5704
- try {
5705
- spinner.start(`Converting sbt to maven from \`${bin}\` on \`${target}\`...`);
5706
-
5707
- // Run sbt with the init script we provide which should yield zero or more
5708
- // pom files. We have to figure out where to store those pom files such that
5709
- // we can upload them and predict them through the GitHub API. We could do a
5710
- // .socket folder. We could do a socket.pom.gz with all the poms, although
5711
- // I'd prefer something plain-text if it is to be committed.
5712
- const output = await spawn.spawn(bin, ['makePom'].concat(sbtOpts), {
5713
- cwd: target || '.'
5714
- });
5715
- spinner.stop();
5716
- if (verbose) {
5717
- logger.logger.group('[VERBOSE] sbt stdout:');
5718
- logger.logger.log(output);
5719
- logger.logger.groupEnd();
5720
- }
5721
- if (output.stderr) {
5722
- process.exitCode = 1;
5723
- logger.logger.fail('There were errors while running sbt');
5724
- // (In verbose mode, stderr was printed above, no need to repeat it)
5725
- if (!verbose) {
5726
- logger.logger.group('[VERBOSE] stderr:');
5727
- logger.logger.error(output.stderr);
5728
- logger.logger.groupEnd();
5729
- }
5730
- return;
5731
- }
5732
- const poms = [];
5733
- output.stdout.replace(/Wrote (.*?.pom)\n/g, (_all, fn) => {
5734
- poms.push(fn);
5735
- return fn;
5736
- });
5737
- if (!poms.length) {
5738
- process.exitCode = 1;
5739
- logger.logger.fail('There were no errors from sbt but it seems to not have generated any poms either');
5740
- return;
5741
- }
5742
- // Move the pom file to ...? initial cwd? loc will be an absolute path, or dump to stdout
5743
- // TODO: what to do with multiple output files? Do we want to dump them to stdout? Raw or with separators or ?
5744
- // TODO: maybe we can add an option to target a specific file to dump to stdout
5745
- if (out === '-' && poms.length === 1) {
5746
- logger.logger.log('Result:\n```');
5747
- logger.logger.log(await utils.safeReadFile(poms[0]));
5748
- logger.logger.log('```');
5749
- logger.logger.success(`OK`);
5750
- } else if (out === '-') {
5751
- process.exitCode = 1;
5752
- logger.logger.fail('Requested out target was stdout but there are multiple generated files');
5753
- poms.forEach(fn => logger.logger.error('-', fn));
5754
- logger.logger.info('Exiting now...');
5755
- return;
5756
- } else {
5757
- // if (verbose) {
5758
- // logger.log(
5759
- // `Moving manifest file from \`${loc.replace(/^\/home\/[^/]*?\//, '~/')}\` to \`${out}\``
5760
- // )
5761
- // } else {
5762
- // logger.log('Moving output pom file')
5763
- // }
5764
- // TODO: do we prefer fs-extra? renaming can be gnarly on windows and fs-extra's version is better
5765
- // await renamep(loc, out)
5766
- logger.logger.success(`Generated ${poms.length} pom files`);
5767
- poms.forEach(fn => logger.logger.log('-', fn));
5768
- logger.logger.success(`OK`);
5769
- }
5770
- } catch (e) {
5771
- process.exitCode = 1;
5772
- spinner.stop();
5773
- logger.logger.fail('There was an unexpected error while running this' + (verbose ? '' : ' (use --verbose for details)'));
5774
- if (verbose) {
5775
- logger.logger.group('[VERBOSE] error:');
5776
- logger.logger.log(e);
5777
- logger.logger.groupEnd();
5778
- }
5779
- }
5780
- }
5781
-
5782
5932
  const {
5783
- DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$t
5933
+ DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$s
5784
5934
  } = constants;
5785
- const config$w = {
5786
- commandName: 'scala',
5787
- description: "[beta] Generate a manifest file (`pom.xml`) from Scala's `build.sbt` file",
5935
+
5936
+ // TODO: we may want to dedupe some pieces for all gradle languages. I think it
5937
+ // makes sense to have separate commands for them and I think it makes
5938
+ // sense for the help panels to note the requested language, rather than
5939
+ // `socket manifest kotlin` to print help screens with `gradle` as the
5940
+ // command. Room for improvement.
5941
+ const config$v = {
5942
+ commandName: 'kotlin',
5943
+ description: '[beta] Use Gradle to generate a manifest file (`pom.xml`) for a Kotlin project',
5788
5944
  hidden: false,
5789
5945
  flags: {
5790
5946
  ...utils.commonFlags,
5791
5947
  bin: {
5792
5948
  type: 'string',
5793
- default: 'sbt',
5794
- description: 'Location of sbt binary to use'
5949
+ description: 'Location of gradlew binary to use, default: CWD/gradlew'
5795
5950
  },
5796
5951
  cwd: {
5797
5952
  type: 'string',
5798
5953
  description: 'Set the cwd, defaults to process.cwd()'
5799
5954
  },
5800
- out: {
5955
+ gradleOpts: {
5801
5956
  type: 'string',
5802
- default: './socket.pom.xml',
5803
- description: 'Path of output file; where to store the resulting manifest, see also --stdout'
5804
- },
5805
- stdout: {
5806
- type: 'boolean',
5807
- description: 'Print resulting pom.xml to stdout (supersedes --out)'
5957
+ default: '',
5958
+ description: 'Additional options to pass on to ./gradlew, see `./gradlew --help`'
5808
5959
  },
5809
- sbtOpts: {
5960
+ task: {
5810
5961
  type: 'string',
5811
- default: '',
5812
- description: 'Additional options to pass on to sbt, as per `sbt --help`'
5962
+ default: 'all',
5963
+ description: 'Task to target. By default targets all'
5813
5964
  },
5814
5965
  verbose: {
5815
5966
  type: 'boolean',
@@ -5818,153 +5969,38 @@ const config$w = {
5818
5969
  },
5819
5970
  help: (command, config) => `
5820
5971
  Usage
5821
- $ ${command} [--bin=path/to/sbt/binary] [--out=path/to/result] FILE|DIR
5972
+ $ ${command} [--bin=path/to/gradle/binary] [--out=path/to/result] DIR
5822
5973
 
5823
5974
  Options
5824
5975
  ${utils.getFlagListOutput(config.flags, 6)}
5825
5976
 
5826
- Uses \`sbt makePom\` to generate a \`pom.xml\` from your \`build.sbt\` file.
5827
- This xml file is the dependency manifest (like a package.json
5828
- for Node.js or requirements.txt for PyPi), but specifically for Scala.
5829
-
5830
- There are some caveats with \`build.sbt\` to \`pom.xml\` conversion:
5831
-
5832
- - the xml is exported as socket.pom.xml as to not confuse existing build tools
5833
- but it will first hit your /target/sbt<version> folder (as a different name)
5834
-
5835
- - the pom.xml format (standard by Scala) does not support certain sbt features
5836
- - \`excludeAll()\`, \`dependencyOverrides\`, \`force()\`, \`relativePath\`
5837
- - For details: https://www.scala-sbt.org/1.x/docs/Library-Management.html
5838
-
5839
- - it uses your sbt settings and local configuration verbatim
5840
-
5841
- - it can only export one target per run, so if you have multiple targets like
5842
- development and production, you must run them separately.
5843
-
5844
- You can optionally configure the path to the \`sbt\` bin to invoke.
5845
-
5846
- Support is beta. Please report issues or give us feedback on what's missing.
5847
-
5848
- This is only for SBT. If your Scala setup uses gradle, please see the help
5849
- sections for \`socket manifest gradle\` or \`socket cdxgen\`.
5850
-
5851
- Examples
5852
-
5853
- $ ${command} ./build.sbt
5854
- $ ${command} --bin=/usr/bin/sbt ./build.sbt
5855
- `
5856
- };
5857
- const cmdManifestScala = {
5858
- description: config$w.description,
5859
- hidden: config$w.hidden,
5860
- run: run$w
5861
- };
5862
- async function run$w(argv, importMeta, {
5863
- parentName
5864
- }) {
5865
- const cli = utils.meowOrExit({
5866
- argv,
5867
- config: config$w,
5868
- importMeta,
5869
- parentName
5870
- });
5871
- const verbose = Boolean(cli.flags['verbose']);
5872
- const {
5873
- json,
5874
- markdown
5875
- } = cli.flags;
5876
- const outputKind = utils.getOutputKind(json, markdown); // TODO: impl json/md further
5877
-
5878
- if (verbose) {
5879
- logger.logger.group('- ', parentName, config$w.commandName, ':');
5880
- logger.logger.group('- flags:', cli.flags);
5881
- logger.logger.groupEnd();
5882
- logger.logger.log('- input:', cli.input);
5883
- logger.logger.groupEnd();
5884
- }
5885
- const [target = ''] = cli.input;
5977
+ Uses gradle, preferably through your local project \`gradlew\`, to generate a
5978
+ \`pom.xml\` file for each task. If you have no \`gradlew\` you can try the
5979
+ global \`gradle\` binary but that may not work (hard to predict).
5886
5980
 
5887
- // TODO: I'm not sure it's feasible to parse source file from stdin. We could
5888
- // try, store contents in a file in some folder, target that folder... what
5889
- // would the file name be?
5981
+ The \`pom.xml\` is a manifest file similar to \`package.json\` for npm or
5982
+ or requirements.txt for PyPi), but specifically for Maven, which is Java's
5983
+ dependency repository. Languages like Kotlin and Scala piggy back on it too.
5890
5984
 
5891
- const wasValidInput = utils.checkCommandInput(outputKind, {
5892
- test: !!target && target !== '-',
5893
- message: 'The DIR arg is required',
5894
- pass: 'ok',
5895
- fail: target === '-' ? 'stdin is not supported' : 'missing'
5896
- }, {
5897
- nook: true,
5898
- test: cli.input.length <= 1,
5899
- message: 'Can only accept one DIR (make sure to escape spaces!)',
5900
- pass: 'ok',
5901
- fail: 'received ' + cli.input.length
5902
- });
5903
- if (!wasValidInput) {
5904
- return;
5905
- }
5906
- let bin = 'sbt';
5907
- if (cli.flags['bin']) {
5908
- bin = cli.flags['bin'];
5909
- }
5910
- let out = './socket.pom.xml';
5911
- if (cli.flags['out']) {
5912
- out = cli.flags['out'];
5913
- }
5914
- if (cli.flags['stdout']) {
5915
- out = '-';
5916
- }
5917
- if (verbose) {
5918
- logger.logger.group();
5919
- logger.logger.log('- target:', target);
5920
- logger.logger.log('- gradle bin:', bin);
5921
- logger.logger.log('- out:', out);
5922
- logger.logger.groupEnd();
5923
- }
5924
- let sbtOpts = [];
5925
- if (cli.flags['sbtOpts']) {
5926
- sbtOpts = cli.flags['sbtOpts'].split(' ').map(s => s.trim()).filter(Boolean);
5927
- }
5928
- if (cli.flags['dryRun']) {
5929
- logger.logger.log(DRY_RUN_BAILING_NOW$t);
5930
- return;
5931
- }
5932
- await convertSbtToMaven(target, bin, out, verbose, sbtOpts);
5933
- }
5985
+ There are some caveats with the gradle to \`pom.xml\` conversion:
5934
5986
 
5935
- const {
5936
- DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$s
5937
- } = constants;
5938
- const config$v = {
5939
- commandName: 'auto',
5940
- description: 'Auto-detect build and attempt to generate manifest file',
5941
- hidden: false,
5942
- flags: {
5943
- ...utils.commonFlags,
5944
- cwd: {
5945
- type: 'string',
5946
- description: 'Set the cwd, defaults to process.cwd()'
5947
- },
5948
- verbose: {
5949
- type: 'boolean',
5950
- default: false,
5951
- description: 'Enable debug output, may help when running into errors'
5952
- }
5953
- // TODO: support output flags
5954
- },
5955
- help: (command, config) => `
5956
- Usage
5957
- $ ${command}
5987
+ - each task will generate its own xml file and by default it generates one xml
5988
+ for every task. (This may be a good thing!)
5958
5989
 
5959
- Options
5960
- ${utils.getFlagListOutput(config.flags, 6)}
5990
+ - it's possible certain features don't translate well into the xml. If you
5991
+ think something is missing that could be supported please reach out.
5961
5992
 
5962
- Tries to figure out what language your current repo uses. If it finds a
5963
- supported case then it will try to generate the manifest file for that
5964
- language with the default or detected settings.
5993
+ - it works with your \`gradlew\` from your repo and local settings and config
5994
+
5995
+ Support is beta. Please report issues or give us feedback on what's missing.
5996
+
5997
+ Examples
5998
+
5999
+ $ ${command} .
6000
+ $ ${command} --bin=../gradlew .
5965
6001
  `
5966
6002
  };
5967
- const cmdManifestAuto = {
6003
+ const cmdManifestKotlin = {
5968
6004
  description: config$v.description,
5969
6005
  hidden: config$v.hidden,
5970
6006
  run: run$v
@@ -5978,127 +6014,93 @@ async function run$v(argv, importMeta, {
5978
6014
  importMeta,
5979
6015
  parentName
5980
6016
  });
5981
- const verbose = !!cli.flags['verbose'];
5982
- const cwd = cli.flags['cwd'] ?? process.cwd();
5983
- // TODO: impl json/md
6017
+ const verbose = Boolean(cli.flags['verbose']);
6018
+ const {
6019
+ json,
6020
+ markdown
6021
+ } = cli.flags;
6022
+ const outputKind = utils.getOutputKind(json, markdown); // TODO: impl json/md further
5984
6023
 
5985
6024
  if (verbose) {
5986
6025
  logger.logger.group('- ', parentName, config$v.commandName, ':');
5987
6026
  logger.logger.group('- flags:', cli.flags);
5988
6027
  logger.logger.groupEnd();
5989
6028
  logger.logger.log('- input:', cli.input);
5990
- logger.logger.log('- cwd:', cwd);
5991
6029
  logger.logger.groupEnd();
5992
6030
  }
5993
- const subArgs = [];
5994
- if (verbose) {
5995
- subArgs.push('--verbose');
5996
- }
5997
- const dir = cwd;
5998
- if (fs$1.existsSync(path.join(dir, 'build.sbt'))) {
5999
- logger.logger.log('Detected a Scala sbt build, running default Scala generator...');
6000
- if (cwd) {
6001
- subArgs.push('--cwd', cwd);
6002
- }
6003
- subArgs.push(dir);
6004
- if (cli.flags['dryRun']) {
6005
- logger.logger.log(DRY_RUN_BAILING_NOW$s);
6006
- return;
6007
- }
6008
- await cmdManifestScala.run(subArgs, importMeta, {
6009
- parentName
6010
- });
6031
+ const [target = ''] = cli.input;
6032
+
6033
+ // TODO: I'm not sure it's feasible to parse source file from stdin. We could
6034
+ // try, store contents in a file in some folder, target that folder... what
6035
+ // would the file name be?
6036
+
6037
+ const wasValidInput = utils.checkCommandInput(outputKind, {
6038
+ test: !!target && target !== '-',
6039
+ message: 'The DIR arg is required',
6040
+ pass: 'ok',
6041
+ fail: target === '-' ? 'stdin is not supported' : 'missing'
6042
+ }, {
6043
+ nook: true,
6044
+ test: cli.input.length <= 1,
6045
+ message: 'Can only accept one DIR (make sure to escape spaces!)',
6046
+ pass: 'ok',
6047
+ fail: 'received ' + cli.input.length
6048
+ });
6049
+ if (!wasValidInput) {
6011
6050
  return;
6012
6051
  }
6013
- if (fs$1.existsSync(path.join(dir, 'gradlew'))) {
6014
- logger.logger.log('Detected a gradle build, running default gradle generator...');
6015
- if (cwd) {
6016
- // This command takes the cwd as first arg.
6017
- subArgs.push(cwd);
6018
- }
6019
- if (cli.flags['dryRun']) {
6020
- logger.logger.log(DRY_RUN_BAILING_NOW$s);
6021
- return;
6022
- }
6023
- await cmdManifestGradle.run(subArgs, importMeta, {
6024
- parentName
6025
- });
6026
- return;
6052
+ const {
6053
+ bin = path.join(target, 'gradlew'),
6054
+ cwd = process.cwd()
6055
+ } = cli.flags;
6056
+ if (verbose) {
6057
+ logger.logger.group();
6058
+ logger.logger.log('- target:', target);
6059
+ logger.logger.log('- gradle bin:', bin);
6060
+ logger.logger.groupEnd();
6027
6061
  }
6028
- const envyml = path.join(dir, 'environment.yml');
6029
- const hasEnvyml = fs$1.existsSync(envyml);
6030
- const envyaml = path.join(dir, 'environment.yaml');
6031
- const hasEnvyaml = !hasEnvyml && fs$1.existsSync(envyaml);
6032
- if (hasEnvyml || hasEnvyaml) {
6033
- logger.logger.log('Detected an environment.yml file, running default Conda generator...');
6034
- // This command takes the TARGET as first arg.
6035
- subArgs.push(hasEnvyml ? envyml : hasEnvyaml ? envyaml : '');
6036
- if (cli.flags['dryRun']) {
6037
- logger.logger.log(DRY_RUN_BAILING_NOW$s);
6038
- return;
6039
- }
6040
- await cmdManifestConda.run(subArgs, importMeta, {
6041
- parentName
6042
- });
6043
- return;
6062
+ let gradleOpts = [];
6063
+ if (cli.flags['gradleOpts']) {
6064
+ gradleOpts = cli.flags['gradleOpts'].split(' ').map(s => s.trim()).filter(Boolean);
6044
6065
  }
6045
6066
  if (cli.flags['dryRun']) {
6046
6067
  logger.logger.log(DRY_RUN_BAILING_NOW$s);
6047
6068
  return;
6048
6069
  }
6049
-
6050
- // Show new help screen and exit.
6051
- vendor.meow(`
6052
- $ ${parentName} ${config$v.commandName}
6053
-
6054
- Unfortunately this script did not discover a supported language in the
6055
- current folder.
6056
-
6057
- - Make sure this script would work with your target build
6058
- - Make sure to run it from the correct folder
6059
- - Make sure the necessary build tools are available (\`PATH\`)
6060
-
6061
- If that doesn't work, see \`${parentName} <lang> --help\` for config details for
6062
- your target language.
6063
- `, {
6064
- argv: [],
6065
- description: config$v.description,
6066
- importMeta
6067
- }).showHelp();
6070
+ await convertGradleToMaven(target, String(bin), String(cwd), verbose, gradleOpts);
6068
6071
  }
6069
6072
 
6070
6073
  const {
6071
6074
  DRY_RUN_BAILING_NOW: DRY_RUN_BAILING_NOW$r
6072
6075
  } = constants;
6073
-
6074
- // TODO: we may want to dedupe some pieces for all gradle languages. I think it
6075
- // makes sense to have separate commands for them and I think it makes
6076
- // sense for the help panels to note the requested language, rather than
6077
- // `socket manifest kotlin` to print help screens with `gradle` as the
6078
- // command. Room for improvement.
6079
6076
  const config$u = {
6080
- commandName: 'kotlin',
6081
- description: '[beta] Use Gradle to generate a manifest file (`pom.xml`) for a Kotlin project',
6077
+ commandName: 'scala',
6078
+ description: "[beta] Generate a manifest file (`pom.xml`) from Scala's `build.sbt` file",
6082
6079
  hidden: false,
6083
6080
  flags: {
6084
6081
  ...utils.commonFlags,
6085
6082
  bin: {
6086
6083
  type: 'string',
6087
- description: 'Location of gradlew binary to use, default: CWD/gradlew'
6084
+ default: 'sbt',
6085
+ description: 'Location of sbt binary to use'
6088
6086
  },
6089
6087
  cwd: {
6090
6088
  type: 'string',
6091
6089
  description: 'Set the cwd, defaults to process.cwd()'
6092
6090
  },
6093
- gradleOpts: {
6091
+ out: {
6094
6092
  type: 'string',
6095
- default: '',
6096
- description: 'Additional options to pass on to ./gradlew, see `./gradlew --help`'
6093
+ default: './socket.pom.xml',
6094
+ description: 'Path of output file; where to store the resulting manifest, see also --stdout'
6097
6095
  },
6098
- task: {
6096
+ stdout: {
6097
+ type: 'boolean',
6098
+ description: 'Print resulting pom.xml to stdout (supersedes --out)'
6099
+ },
6100
+ sbtOpts: {
6099
6101
  type: 'string',
6100
- default: 'all',
6101
- description: 'Task to target. By default targets all'
6102
+ default: '',
6103
+ description: 'Additional options to pass on to sbt, as per `sbt --help`'
6102
6104
  },
6103
6105
  verbose: {
6104
6106
  type: 'boolean',
@@ -6107,38 +6109,43 @@ const config$u = {
6107
6109
  },
6108
6110
  help: (command, config) => `
6109
6111
  Usage
6110
- $ ${command} [--bin=path/to/gradle/binary] [--out=path/to/result] DIR
6112
+ $ ${command} [--bin=path/to/sbt/binary] [--out=path/to/result] FILE|DIR
6111
6113
 
6112
6114
  Options
6113
6115
  ${utils.getFlagListOutput(config.flags, 6)}
6114
6116
 
6115
- Uses gradle, preferably through your local project \`gradlew\`, to generate a
6116
- \`pom.xml\` file for each task. If you have no \`gradlew\` you can try the
6117
- global \`gradle\` binary but that may not work (hard to predict).
6117
+ Uses \`sbt makePom\` to generate a \`pom.xml\` from your \`build.sbt\` file.
6118
+ This xml file is the dependency manifest (like a package.json
6119
+ for Node.js or requirements.txt for PyPi), but specifically for Scala.
6118
6120
 
6119
- The \`pom.xml\` is a manifest file similar to \`package.json\` for npm or
6120
- or requirements.txt for PyPi), but specifically for Maven, which is Java's
6121
- dependency repository. Languages like Kotlin and Scala piggy back on it too.
6121
+ There are some caveats with \`build.sbt\` to \`pom.xml\` conversion:
6122
6122
 
6123
- There are some caveats with the gradle to \`pom.xml\` conversion:
6123
+ - the xml is exported as socket.pom.xml as to not confuse existing build tools
6124
+ but it will first hit your /target/sbt<version> folder (as a different name)
6124
6125
 
6125
- - each task will generate its own xml file and by default it generates one xml
6126
- for every task. (This may be a good thing!)
6126
+ - the pom.xml format (standard by Scala) does not support certain sbt features
6127
+ - \`excludeAll()\`, \`dependencyOverrides\`, \`force()\`, \`relativePath\`
6128
+ - For details: https://www.scala-sbt.org/1.x/docs/Library-Management.html
6127
6129
 
6128
- - it's possible certain features don't translate well into the xml. If you
6129
- think something is missing that could be supported please reach out.
6130
+ - it uses your sbt settings and local configuration verbatim
6130
6131
 
6131
- - it works with your \`gradlew\` from your repo and local settings and config
6132
+ - it can only export one target per run, so if you have multiple targets like
6133
+ development and production, you must run them separately.
6134
+
6135
+ You can optionally configure the path to the \`sbt\` bin to invoke.
6132
6136
 
6133
6137
  Support is beta. Please report issues or give us feedback on what's missing.
6134
6138
 
6139
+ This is only for SBT. If your Scala setup uses gradle, please see the help
6140
+ sections for \`socket manifest gradle\` or \`socket cdxgen\`.
6141
+
6135
6142
  Examples
6136
6143
 
6137
- $ ${command} .
6138
- $ ${command} --bin=../gradlew .
6144
+ $ ${command} ./build.sbt
6145
+ $ ${command} --bin=/usr/bin/sbt ./build.sbt
6139
6146
  `
6140
6147
  };
6141
- const cmdManifestKotlin = {
6148
+ const cmdManifestScala = {
6142
6149
  description: config$u.description,
6143
6150
  hidden: config$u.hidden,
6144
6151
  run: run$u
@@ -6187,25 +6194,33 @@ async function run$u(argv, importMeta, {
6187
6194
  if (!wasValidInput) {
6188
6195
  return;
6189
6196
  }
6190
- const {
6191
- bin = path.join(target, 'gradlew'),
6192
- cwd = process.cwd()
6193
- } = cli.flags;
6197
+ let bin = 'sbt';
6198
+ if (cli.flags['bin']) {
6199
+ bin = cli.flags['bin'];
6200
+ }
6201
+ let out = './socket.pom.xml';
6202
+ if (cli.flags['out']) {
6203
+ out = cli.flags['out'];
6204
+ }
6205
+ if (cli.flags['stdout']) {
6206
+ out = '-';
6207
+ }
6194
6208
  if (verbose) {
6195
6209
  logger.logger.group();
6196
6210
  logger.logger.log('- target:', target);
6197
6211
  logger.logger.log('- gradle bin:', bin);
6212
+ logger.logger.log('- out:', out);
6198
6213
  logger.logger.groupEnd();
6199
6214
  }
6200
- let gradleOpts = [];
6201
- if (cli.flags['gradleOpts']) {
6202
- gradleOpts = cli.flags['gradleOpts'].split(' ').map(s => s.trim()).filter(Boolean);
6215
+ let sbtOpts = [];
6216
+ if (cli.flags['sbtOpts']) {
6217
+ sbtOpts = cli.flags['sbtOpts'].split(' ').map(s => s.trim()).filter(Boolean);
6203
6218
  }
6204
6219
  if (cli.flags['dryRun']) {
6205
6220
  logger.logger.log(DRY_RUN_BAILING_NOW$r);
6206
6221
  return;
6207
6222
  }
6208
- await convertGradleToMaven(target, String(bin), String(cwd), verbose, gradleOpts);
6223
+ await convertSbtToMaven(target, bin, out, verbose, sbtOpts);
6209
6224
  }
6210
6225
 
6211
6226
  const config$t = {
@@ -8743,6 +8758,50 @@ async function run$d(argv, importMeta, {
8743
8758
  await handleDeleteRepo(orgSlug, repoName, outputKind);
8744
8759
  }
8745
8760
 
8761
+ async function fetchListAllRepos({
8762
+ direction,
8763
+ orgSlug,
8764
+ sort
8765
+ }) {
8766
+ const sockSdkResult = await utils.setupSdk();
8767
+ if (!sockSdkResult.ok) {
8768
+ return sockSdkResult;
8769
+ }
8770
+ const sockSdk = sockSdkResult.data;
8771
+ const rows = [];
8772
+ let protection = 0;
8773
+ let nextPage = 0;
8774
+ while (nextPage >= 0) {
8775
+ if (++protection > 100) {
8776
+ return {
8777
+ ok: false,
8778
+ message: 'Infinite loop detected',
8779
+ cause: `Either there are over 100 pages of results or the fetch has run into an infinite loop. Breaking it off now. nextPage=${nextPage}`
8780
+ };
8781
+ }
8782
+ // eslint-disable-next-line no-await-in-loop
8783
+ const result = await utils.handleApiCall(sockSdk.getOrgRepoList(orgSlug, {
8784
+ sort,
8785
+ direction,
8786
+ per_page: String(100),
8787
+ // max
8788
+ page: String(nextPage)
8789
+ }), 'list of repositories');
8790
+ if (!result.ok) {
8791
+ return result;
8792
+ }
8793
+ result.data.results.forEach(row => rows.push(row));
8794
+ nextPage = result.data.nextPage ?? -1;
8795
+ }
8796
+ return {
8797
+ ok: true,
8798
+ data: {
8799
+ results: rows,
8800
+ nextPage: null
8801
+ }
8802
+ };
8803
+ }
8804
+
8746
8805
  async function fetchListRepos({
8747
8806
  direction,
8748
8807
  orgSlug,
@@ -8764,18 +8823,33 @@ async function fetchListRepos({
8764
8823
  }
8765
8824
 
8766
8825
  // @ts-ignore
8767
- async function outputListRepos(result, outputKind) {
8826
+ async function outputListRepos(result, outputKind, page, nextPage, sort, perPage, direction) {
8768
8827
  if (!result.ok) {
8769
8828
  process.exitCode = result.code ?? 1;
8770
8829
  }
8771
8830
  if (outputKind === 'json') {
8772
- logger.logger.log(utils.serializeResultJson(result));
8831
+ if (result.ok) {
8832
+ logger.logger.log(utils.serializeResultJson({
8833
+ ok: true,
8834
+ data: {
8835
+ data: result.data,
8836
+ direction,
8837
+ nextPage: nextPage ?? 0,
8838
+ page,
8839
+ perPage,
8840
+ sort
8841
+ }
8842
+ }));
8843
+ } else {
8844
+ logger.logger.log(utils.serializeResultJson(result));
8845
+ }
8773
8846
  return;
8774
8847
  }
8775
8848
  if (!result.ok) {
8776
8849
  logger.logger.fail(utils.failMsgWithBadge(result.message, result.cause));
8777
8850
  return;
8778
8851
  }
8852
+ logger.logger.log(`Result page: ${page}, results per page: ${perPage === Infinity ? 'all' : perPage}, sorted by: ${sort}, direction: ${direction}`);
8779
8853
  const options = {
8780
8854
  columns: [{
8781
8855
  field: 'id',
@@ -8795,9 +8869,18 @@ async function outputListRepos(result, outputKind) {
8795
8869
  }]
8796
8870
  };
8797
8871
  logger.logger.log(vendor.srcExports(options, result.data.results));
8872
+ if (nextPage) {
8873
+ logger.logger.info(`This is page ${page}. Server indicated there are more results available on page ${nextPage}...`);
8874
+ logger.logger.info(`(Hint: you can use \`socket repos list --page ${nextPage}\`)`);
8875
+ } else if (perPage === Infinity) {
8876
+ logger.logger.info(`This should be the entire list available on the server.`);
8877
+ } else {
8878
+ logger.logger.info(`This is page ${page}. Server indicated this is the last page with results.`);
8879
+ }
8798
8880
  }
8799
8881
 
8800
8882
  async function handleListRepos({
8883
+ all,
8801
8884
  direction,
8802
8885
  orgSlug,
8803
8886
  outputKind,
@@ -8805,14 +8888,28 @@ async function handleListRepos({
8805
8888
  per_page,
8806
8889
  sort
8807
8890
  }) {
8808
- const data = await fetchListRepos({
8809
- direction,
8810
- orgSlug,
8811
- page,
8812
- per_page,
8813
- sort
8814
- });
8815
- await outputListRepos(data, outputKind);
8891
+ if (all) {
8892
+ const data = await fetchListAllRepos({
8893
+ direction,
8894
+ orgSlug,
8895
+ sort
8896
+ });
8897
+ await outputListRepos(data, outputKind, 0, 0, sort, Infinity, direction);
8898
+ } else {
8899
+ const data = await fetchListRepos({
8900
+ direction,
8901
+ orgSlug,
8902
+ page,
8903
+ per_page,
8904
+ sort
8905
+ });
8906
+ if (!data.ok) {
8907
+ await outputListRepos(data, outputKind, 0, 0, '', 0, direction);
8908
+ } else {
8909
+ // Note: nextPage defaults to 0, is null when there's no next page
8910
+ await outputListRepos(data, outputKind, page, data.data.nextPage, sort, per_page, direction);
8911
+ }
8912
+ }
8816
8913
  }
8817
8914
 
8818
8915
  const {
@@ -8825,11 +8922,10 @@ const config$c = {
8825
8922
  flags: {
8826
8923
  ...utils.commonFlags,
8827
8924
  ...utils.outputFlags,
8828
- sort: {
8829
- type: 'string',
8830
- shortFlag: 's',
8831
- default: 'created_at',
8832
- description: 'Sorting option'
8925
+ all: {
8926
+ type: 'boolean',
8927
+ default: false,
8928
+ description: 'By default view shows the last n repos. This flag allows you to fetch the entire list. Will ignore --page and --perPage.'
8833
8929
  },
8834
8930
  direction: {
8835
8931
  type: 'string',
@@ -8856,6 +8952,12 @@ const config$c = {
8856
8952
  shortFlag: 'p',
8857
8953
  default: 1,
8858
8954
  description: 'Page number'
8955
+ },
8956
+ sort: {
8957
+ type: 'string',
8958
+ shortFlag: 's',
8959
+ default: 'created_at',
8960
+ description: 'Sorting option'
8859
8961
  }
8860
8962
  },
8861
8963
  help: (command, config) => `
@@ -8888,15 +8990,15 @@ async function run$c(argv, importMeta, {
8888
8990
  parentName
8889
8991
  });
8890
8992
  const {
8891
- json,
8892
- markdown
8893
- } = cli.flags;
8894
- const outputKind = utils.getOutputKind(json, markdown);
8895
- const {
8993
+ all,
8994
+ direction = 'desc',
8896
8995
  dryRun,
8897
8996
  interactive,
8997
+ json,
8998
+ markdown,
8898
8999
  org: orgFlag
8899
9000
  } = cli.flags;
9001
+ const outputKind = utils.getOutputKind(json, markdown);
8900
9002
  const [orgSlug] = await utils.determineOrgSlug(String(orgFlag || ''), cli.input[0] || '', !!interactive, !!dryRun);
8901
9003
  const hasApiToken = utils.hasDefaultToken();
8902
9004
  const wasValidInput = utils.checkCommandInput(outputKind, {
@@ -8917,6 +9019,12 @@ async function run$c(argv, importMeta, {
8917
9019
  message: 'You need to be logged in to use this command. See `socket login`.',
8918
9020
  pass: 'ok',
8919
9021
  fail: 'missing API token'
9022
+ }, {
9023
+ nook: true,
9024
+ test: direction === 'asc' || direction === 'desc',
9025
+ message: 'The --direction value must be "asc" or "desc"',
9026
+ pass: 'ok',
9027
+ fail: 'unexpected value'
8920
9028
  });
8921
9029
  if (!wasValidInput) {
8922
9030
  return;
@@ -8926,7 +9034,8 @@ async function run$c(argv, importMeta, {
8926
9034
  return;
8927
9035
  }
8928
9036
  await handleListRepos({
8929
- direction: cli.flags['direction'] === 'asc' ? 'asc' : 'desc',
9037
+ all: Boolean(all),
9038
+ direction: direction === 'asc' ? 'asc' : 'desc',
8930
9039
  orgSlug,
8931
9040
  outputKind,
8932
9041
  page: Number(cli.flags['page']) || 1,
@@ -9374,11 +9483,6 @@ const config$9 = {
9374
9483
  default: true,
9375
9484
  description: 'Allow for interactive elements, asking for input. Use --no-interactive to prevent any input questions, defaulting them to cancel/no.'
9376
9485
  },
9377
- pendingHead: {
9378
- type: 'boolean',
9379
- default: true,
9380
- description: 'Designate this full-scan as the latest scan of a given branch. This must be set to have it show up in the dashboard.'
9381
- },
9382
9486
  pullRequest: {
9383
9487
  type: 'number',
9384
9488
  shortFlag: 'pr',
@@ -9404,11 +9508,17 @@ const config$9 = {
9404
9508
  default: false,
9405
9509
  description: 'Wait for the scan creation to complete, then basically run `socket scan report` on it'
9406
9510
  },
9511
+ setAsAlertsPage: {
9512
+ type: 'boolean',
9513
+ default: true,
9514
+ aliases: ['pendingHead'],
9515
+ description: 'When true and if this is the "default branch" then this Scan will be the one reflected on your alerts page. See help for details. Defaults to true.'
9516
+ },
9407
9517
  tmp: {
9408
9518
  type: 'boolean',
9409
9519
  shortFlag: 't',
9410
9520
  default: false,
9411
- description: 'Set the visibility (true/false) of the scan in your dashboard. Can not be used when --pendingHead is set.'
9521
+ description: 'Set the visibility (true/false) of the scan in your dashboard.'
9412
9522
  }
9413
9523
  },
9414
9524
  // TODO: your project's "socket.yml" file's "projectIgnorePaths"
@@ -9440,8 +9550,12 @@ const config$9 = {
9440
9550
  Note: for a first run you probably want to set --defaultBranch to indicate
9441
9551
  the default branch name, like "main" or "master".
9442
9552
 
9443
- Note: --pendingHead is enabled by default and makes a scan show up in your
9444
- dashboard. You can use \`--no-pendingHead\` to have it not show up.
9553
+ The "alerts page" (https://socket.dev/dashboard/org/YOURORG/alerts) will show
9554
+ the results from the last scan designated as the "pending head" on the branch
9555
+ configured on Socket to be the "default branch". When creating a scan the
9556
+ --setAsAlertsPage flag will default to true to update this. You can prevent
9557
+ this by using --no-setAsAlertsPage. This flag is ignored for any branch that
9558
+ is not designated as the "default branch". It is disabled when using --tmp.
9445
9559
 
9446
9560
  Options
9447
9561
  ${utils.getFlagListOutput(config.flags, 6)}
@@ -9477,14 +9591,15 @@ async function run$9(argv, importMeta, {
9477
9591
  json,
9478
9592
  markdown,
9479
9593
  org: orgFlag,
9480
- pendingHead,
9481
9594
  pullRequest,
9482
9595
  readOnly,
9483
9596
  repo: repoName = 'socket-default-repository',
9484
9597
  report,
9598
+ setAsAlertsPage: pendingHeadFlag,
9485
9599
  tmp
9486
9600
  } = cli.flags;
9487
9601
  const outputKind = utils.getOutputKind(json, markdown);
9602
+ const pendingHead = tmp ? false : pendingHeadFlag;
9488
9603
  let [orgSlug, defaultOrgSlug] = await utils.determineOrgSlug(String(orgFlag || ''), cli.input[0] || '', interactive, dryRun);
9489
9604
  if (!defaultOrgSlug) {
9490
9605
  // Tmp. just for TS. will drop this later.
@@ -9548,12 +9663,6 @@ async function run$9(argv, importMeta, {
9548
9663
  message: 'This command requires an API token for access',
9549
9664
  pass: 'ok',
9550
9665
  fail: 'missing (try `socket login`)'
9551
- }, {
9552
- nook: true,
9553
- test: !pendingHead || !tmp,
9554
- message: 'Can not use --pendingHead and --tmp at the same time',
9555
- pass: 'ok',
9556
- fail: 'remove at least one flag'
9557
9666
  }, {
9558
9667
  nook: true,
9559
9668
  test: !pendingHead || !!branchName,
@@ -11597,5 +11706,5 @@ void (async () => {
11597
11706
  await utils.captureException(e);
11598
11707
  }
11599
11708
  })();
11600
- //# debugId=8c291e79-2d0e-444d-af3a-8be88558aeff
11709
+ //# debugId=58ee5340-de19-42ee-8faf-fef7b5047b56
11601
11710
  //# sourceMappingURL=cli.js.map