@coana-tech/cli 14.11.14 → 14.11.15

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.
package/cli.mjs CHANGED
@@ -205338,7 +205338,7 @@ var getNpmBin = once(async () => {
205338
205338
  return npmBin;
205339
205339
  });
205340
205340
  async function actuallyRunInstall(specificPackagesArgs = [], dir) {
205341
- const installationCommand = cmdt2`${await getNpmBin()} install -f --ignore-scripts --no-fund --no-audit ${specificPackagesArgs}`;
205341
+ const installationCommand = cmdt2`${await getNpmBin()} install -f --ignore-scripts --no-fund --no-audit --no-progress ${specificPackagesArgs}`;
205342
205342
  logger.info(`running installation command: ${installationCommand}`);
205343
205343
  return execAndLogOnFailure2(installationCommand, dir);
205344
205344
  }
@@ -205446,6 +205446,8 @@ var NpmFixingManager = class extends NpmEcosystemFixingManager {
205446
205446
  }
205447
205447
  }
205448
205448
  async finalizeFixes() {
205449
+ logger.info(`Adjusting lock file changes by running a npm install command`);
205450
+ await actuallyRunInstall(void 0, resolve9(this.rootDir, this.subprojectPath));
205449
205451
  }
205450
205452
  };
205451
205453
 
@@ -205454,7 +205456,16 @@ import { readFile as readFile12, writeFile as writeFile4 } from "fs/promises";
205454
205456
  import { resolve as resolve10 } from "path";
205455
205457
  var import_yaml = __toESM(require_dist10(), 1);
205456
205458
  var import_lockfile_file2 = __toESM(require_lib25(), 1);
205459
+ import { existsSync as existsSync9 } from "fs";
205457
205460
  var PnpmFixingManager = class extends NpmEcosystemFixingManager {
205461
+ pnpmMajorVersion;
205462
+ async getPnpmMajorVersion() {
205463
+ if (!this.pnpmMajorVersion) {
205464
+ const pnpmVersion = await runCommandResolveStdOut(cmdt`pnpm -v`);
205465
+ this.pnpmMajorVersion = parseInt(pnpmVersion.trim().split(".")[0]);
205466
+ }
205467
+ return this.pnpmMajorVersion;
205468
+ }
205458
205469
  async installSpecificPackages(workspacePath, isDev, packagesToInstall) {
205459
205470
  try {
205460
205471
  const isInstallingInRootOfWorkspace = workspacePath === "." && (await getWorkspacePathsFromPnpmLockFile(this.rootDir, false)).length > 1;
@@ -205473,7 +205484,7 @@ var PnpmFixingManager = class extends NpmEcosystemFixingManager {
205473
205484
  }
205474
205485
  }
205475
205486
  async actuallyRunInstall(specificPackagesCmd = [], workspacePath = ".") {
205476
- const installationCommand = cmdt`pnpm install --ignore-scripts ${specificPackagesCmd}`;
205487
+ const installationCommand = cmdt`pnpm install --ignore-scripts${await this.getPnpmMajorVersion() >= 9 && specificPackagesCmd.length === 0 ? "--no-frozen-lockfile" : ""} --config.confirmModulesPurge=false ${specificPackagesCmd}`;
205477
205488
  logger.info(`running installation command: ${installationCommand}`);
205478
205489
  await exec(installationCommand, resolve10(this.rootDir, this.subprojectPath, workspacePath));
205479
205490
  }
@@ -205556,6 +205567,11 @@ var PnpmFixingManager = class extends NpmEcosystemFixingManager {
205556
205567
  ])
205557
205568
  );
205558
205569
  const pnpmWorkspaceYamlFile = resolve10(this.rootDir, this.subprojectPath, "pnpm-workspace.yaml");
205570
+ if (!existsSync9(pnpmWorkspaceYamlFile)) {
205571
+ throw new Error(
205572
+ `pnpm-workspace.yaml could not be found in ${pnpmWorkspaceYamlFile}. The lockfile indicates that pnpm catalogs are used and they must be updated, which is not possible without a pnpm-workspace.yaml file`
205573
+ );
205574
+ }
205559
205575
  const yamlAST = await readYamlFile(pnpmWorkspaceYamlFile);
205560
205576
  fixCatalogVersions(yamlAST, catalogFixes);
205561
205577
  await writeYamlFile(yamlAST, pnpmWorkspaceYamlFile);
@@ -205567,7 +205583,7 @@ var PnpmFixingManager = class extends NpmEcosystemFixingManager {
205567
205583
  }
205568
205584
  }
205569
205585
  async finalizeFixes() {
205570
- const cmd = cmdt`pnpm install --ignore-scripts --fix-lockfile`;
205586
+ const cmd = cmdt`pnpm install --ignore-scripts --fix-lockfile --config.confirmModulesPurge=false `;
205571
205587
  logger.info(`Adjusting lock file changes by running '${cmd}'`);
205572
205588
  await exec(cmd, resolve10(this.rootDir, this.subprojectPath));
205573
205589
  }
@@ -205621,7 +205637,7 @@ import { resolve as resolve12 } from "path";
205621
205637
 
205622
205638
  // ../utils/src/package-utils.ts
205623
205639
  import { parse as parse2, join as join7, resolve as resolve11, normalize as normalize3, dirname as dirname4, basename as basename3, relative as relative4 } from "path";
205624
- import { existsSync as existsSync9, readFileSync as readFileSync2, readdirSync as readdirSync3, statSync as statSync3, writeFileSync as writeFileSync2 } from "fs";
205640
+ import { existsSync as existsSync10, readFileSync as readFileSync2, readdirSync as readdirSync3, statSync as statSync3, writeFileSync as writeFileSync2 } from "fs";
205625
205641
  function setFieldInPackageJson(workspaceRoot, field, value) {
205626
205642
  const packageJSONContentObj = getPackageJsonObject2(workspaceRoot);
205627
205643
  if (!packageJSONContentObj) return void 0;
@@ -205638,7 +205654,7 @@ function writePackageJsonContent(workspaceRoot, packageJsonContent) {
205638
205654
  }
205639
205655
  function getPackageJsonContent2(workspaceRoot) {
205640
205656
  const packageJsonPath = getPackageJSONPath2(workspaceRoot);
205641
- if (existsSync9(packageJsonPath)) return readFileSync2(packageJsonPath, "utf8");
205657
+ if (existsSync10(packageJsonPath)) return readFileSync2(packageJsonPath, "utf8");
205642
205658
  return void 0;
205643
205659
  }
205644
205660
  function getPackageJSONPath2(workspaceRoot) {
@@ -205771,9 +205787,10 @@ var YarnFixingManager = class extends NpmEcosystemFixingManager {
205771
205787
  logger.info(`Failed to install packages: ${installResult.error.message}`);
205772
205788
  logger.info(`stdout`, installResult.stdout);
205773
205789
  logger.info(`stderr`, installResult.stderr);
205774
- logger.info("yarn version", await runCommandResolveStdOut("yarn -v", installDir));
205790
+ logger.info("yarn version", await this.runYarnCommand(cmdt`yarn -v`, installDir));
205775
205791
  throw new Error(`Failed to install packages: ${installResult.error.message}`);
205776
205792
  }
205793
+ logger.info("Installation completed.");
205777
205794
  }
205778
205795
  async getYarnLockObj(filePath) {
205779
205796
  const fileString = await readFile13(filePath, "utf8");
@@ -205875,7 +205892,7 @@ var YarnFixingManager = class extends NpmEcosystemFixingManager {
205875
205892
 
205876
205893
  // ../fixing-management/src/fixing-management/npm/npm-ecosystem-socket-fixing-manager.ts
205877
205894
  import { dirname as dirname5, join as join8, relative as relative5 } from "path";
205878
- import { existsSync as existsSync10 } from "fs";
205895
+ import { existsSync as existsSync11 } from "fs";
205879
205896
  var NpmSocketUpgradeManager = class {
205880
205897
  constructor(rootDir) {
205881
205898
  this.rootDir = rootDir;
@@ -205909,7 +205926,13 @@ var NpmSocketUpgradeManager = class {
205909
205926
  workspaceToSubproject.set(join8(subprojectDir, workspace), subprojectDir);
205910
205927
  }
205911
205928
  }
205912
- const packageJsonFiles = artifact.manifestFiles?.filter((a4) => a4.file.endsWith("package.json"));
205929
+ const packageJsonFiles = artifact.manifestFiles?.filter((a4) => a4.file.endsWith("package.json")) ?? [];
205930
+ for (const lockFile of lockFiles ?? []) {
205931
+ const correspondingPackageJsonFile = join8(dirname5(lockFile.file), "package.json");
205932
+ if (!packageJsonFiles.some((p3) => p3.file === correspondingPackageJsonFile) && existsSync11(correspondingPackageJsonFile)) {
205933
+ packageJsonFiles.push({ file: correspondingPackageJsonFile });
205934
+ }
205935
+ }
205913
205936
  for (const packageJsonFile of packageJsonFiles ?? []) {
205914
205937
  const packageJsonDir = dirname5(packageJsonFile.file);
205915
205938
  const subprojectDir = workspaceToSubproject.get(packageJsonDir) ?? packageJsonDir;
@@ -205961,13 +205984,14 @@ function getFixingManagerFromPackageManager(packageManager, rootDir, subprojectP
205961
205984
  }
205962
205985
  }
205963
205986
  function getPackageMangerForDirectory(directory) {
205964
- if (existsSync10(join8(directory, "pnpm-lock.yaml")) || existsSync10(join8(directory, "pnpm-lock.yml"))) {
205987
+ if (existsSync11(join8(directory, "pnpm-lock.yaml")) || existsSync11(join8(directory, "pnpm-lock.yml"))) {
205965
205988
  return "PNPM";
205966
- } else if (existsSync10(join8(directory, "yarn.lock"))) {
205989
+ } else if (existsSync11(join8(directory, "yarn.lock"))) {
205967
205990
  return "YARN";
205968
- } else {
205991
+ } else if (existsSync11(join8(directory, "package-lock.json"))) {
205969
205992
  return "NPM";
205970
205993
  }
205994
+ throw new Error("Upgrading packages is currently only supported for NPM projects using a lock file.");
205971
205995
  }
205972
205996
 
205973
205997
  // ../fixing-management/src/fixing-management/npm/rush-fixing-manager.ts
@@ -206329,7 +206353,7 @@ async function applySocketUpgrades(ecosystem, rootDir, upgrades, artifacts) {
206329
206353
 
206330
206354
  // dist/cli-apply-fix.js
206331
206355
  var import_lodash12 = __toESM(require_lodash(), 1);
206332
- import { existsSync as existsSync15 } from "fs";
206356
+ import { existsSync as existsSync16 } from "fs";
206333
206357
 
206334
206358
  // ../other-modules-communicator/src/other-modules-communicator.ts
206335
206359
  import { execFileSync } from "child_process";
@@ -206346,7 +206370,7 @@ import { fileURLToPath as fileURLToPath3 } from "node:url";
206346
206370
  // ../utils/dist/file-utils.js
206347
206371
  var import_lodash5 = __toESM(require_lodash(), 1);
206348
206372
  var import_micromatch = __toESM(require_micromatch(), 1);
206349
- import { existsSync as existsSync11 } from "fs";
206373
+ import { existsSync as existsSync12 } from "fs";
206350
206374
  import { access as access2, cp, readdir as readdir3, stat as stat2 } from "fs/promises";
206351
206375
  import { basename as basename4, join as join11, relative as relative6, resolve as resolve13 } from "path";
206352
206376
  var { uniq } = import_lodash5.default;
@@ -207076,7 +207100,7 @@ async function detectVariantMaven(projectDir) {
207076
207100
  }
207077
207101
 
207078
207102
  // ../docker-management/src/maven/gradle-version-detector.ts
207079
- import { existsSync as existsSync12 } from "fs";
207103
+ import { existsSync as existsSync13 } from "fs";
207080
207104
  import { join as join13 } from "path";
207081
207105
  import { readFile as readFile15 } from "fs/promises";
207082
207106
  async function detectVariantGradle(projectDir) {
@@ -207084,7 +207108,7 @@ async function detectVariantGradle(projectDir) {
207084
207108
  }
207085
207109
  async function detect(projectDir) {
207086
207110
  const gradleWrapperPropertiesPath = join13(projectDir, "gradle", "wrapper", "gradle-wrapper.properties");
207087
- const gradleWrapperProperties = existsSync12(gradleWrapperPropertiesPath) ? (await readFile15(gradleWrapperPropertiesPath, "utf-8")).split("\n").map((line) => line.trim()).filter((line) => !line.startsWith("#")).filter((line) => line) : void 0;
207111
+ const gradleWrapperProperties = existsSync13(gradleWrapperPropertiesPath) ? (await readFile15(gradleWrapperPropertiesPath, "utf-8")).split("\n").map((line) => line.trim()).filter((line) => !line.startsWith("#")).filter((line) => line) : void 0;
207088
207112
  if (!gradleWrapperProperties) return void 0;
207089
207113
  const distributionUrlRegex = /.*gradle-(\d+(\.\d+(\.\d+)?)?)/;
207090
207114
  for (const prop2 of gradleWrapperProperties) {
@@ -207098,7 +207122,7 @@ async function detect(projectDir) {
207098
207122
  }
207099
207123
 
207100
207124
  // ../docker-management/src/maven/sbt-version-detector.ts
207101
- import { existsSync as existsSync13 } from "fs";
207125
+ import { existsSync as existsSync14 } from "fs";
207102
207126
  import { join as join14 } from "path";
207103
207127
  import { readFile as readFile16 } from "fs/promises";
207104
207128
  async function detectVariantSbt(projectDir) {
@@ -207106,7 +207130,7 @@ async function detectVariantSbt(projectDir) {
207106
207130
  }
207107
207131
  async function detect2(projectDir) {
207108
207132
  const sbtBuildPropertiesPath = join14(projectDir, "project", "build.properties");
207109
- const sbtBuildProperties = existsSync13(sbtBuildPropertiesPath) ? (await readFile16(sbtBuildPropertiesPath, "utf-8")).split("\n").map((line) => line.trim()).filter((line) => !line.startsWith("#")).filter((line) => line) : void 0;
207133
+ const sbtBuildProperties = existsSync14(sbtBuildPropertiesPath) ? (await readFile16(sbtBuildPropertiesPath, "utf-8")).split("\n").map((line) => line.trim()).filter((line) => !line.startsWith("#")).filter((line) => line) : void 0;
207110
207134
  if (!sbtBuildProperties) return void 0;
207111
207135
  for (const prop2 of sbtBuildProperties) {
207112
207136
  const [key, value] = prop2.split("=");
@@ -207227,7 +207251,7 @@ import { join as join17, posix as posix2, relative as relative8, sep as sep3 } f
207227
207251
  // ../utils/src/file-utils.ts
207228
207252
  var import_lodash8 = __toESM(require_lodash(), 1);
207229
207253
  var import_micromatch2 = __toESM(require_micromatch(), 1);
207230
- import { existsSync as existsSync14 } from "fs";
207254
+ import { existsSync as existsSync15 } from "fs";
207231
207255
  import { access as access3, cp as cp2, readdir as readdir4, stat as stat3 } from "fs/promises";
207232
207256
  import { basename as basename5, join as join15, relative as relative7, resolve as resolve16 } from "path";
207233
207257
  var { uniq: uniq2 } = import_lodash8.default;
@@ -208344,7 +208368,7 @@ async function verifyFixes(fixes, otherModulesCommunicator, rootPath) {
208344
208368
  if (pathsForEachFixIdData.length !== new Set(pathsForEachFixIdData).size) {
208345
208369
  throw new Error("Multiple fix IDs found for the same subproject, workspace and ecosystem");
208346
208370
  }
208347
- const subprojectsNotFound = uniq3(fixes.filter(({ vulnerabilityInstance: v }) => !existsSync15(resolve19(rootPath, v.subprojectPath))).map(({ vulnerabilityInstance: v }) => `${v.subprojectPath}:${v.ecosystem}`));
208371
+ const subprojectsNotFound = uniq3(fixes.filter(({ vulnerabilityInstance: v }) => !existsSync16(resolve19(rootPath, v.subprojectPath))).map(({ vulnerabilityInstance: v }) => `${v.subprojectPath}:${v.ecosystem}`));
208348
208372
  if (subprojectsNotFound.length > 0) {
208349
208373
  throw new Error(`Cannot find the following subprojects: ${subprojectsNotFound.join(", ")}`);
208350
208374
  }
@@ -209150,12 +209174,12 @@ import { readdir as readdir6 } from "fs/promises";
209150
209174
  import { join as join20, relative as relative9, resolve as resolve22 } from "path";
209151
209175
 
209152
209176
  // ../project-management/src/project-management/ecosystem-management/ecosystem-specs.ts
209153
- import { existsSync as existsSync17 } from "fs";
209177
+ import { existsSync as existsSync18 } from "fs";
209154
209178
  import { readdir as readdir5, readFile as readFile20 } from "fs/promises";
209155
209179
  import { join as join19, sep as sep4 } from "path";
209156
209180
 
209157
209181
  // ../utils/src/pip-utils.ts
209158
- import { existsSync as existsSync16 } from "fs";
209182
+ import { existsSync as existsSync17 } from "fs";
209159
209183
  import { readFile as readFile19 } from "fs/promises";
209160
209184
  import { resolve as resolve21 } from "path";
209161
209185
  import util4 from "util";
@@ -209252,7 +209276,7 @@ function getEcosystemSpecs(ecosystems) {
209252
209276
  }
209253
209277
  function packageManagerIfPackageJSONExistsAndValid(packageManager) {
209254
209278
  return async (projectDir) => {
209255
- if (!existsSync17(join19(projectDir, "package.json"))) return void 0;
209279
+ if (!existsSync18(join19(projectDir, "package.json"))) return void 0;
209256
209280
  const packageJSONPath = join19(projectDir, "package.json");
209257
209281
  try {
209258
209282
  JSON.parse(await readFile20(packageJSONPath, "utf-8"));
@@ -209927,16 +209951,16 @@ function isVulnChainWithParentsMap(v) {
209927
209951
  var DEFAULT_REPORT_FILENAME_BASE = "coana-report";
209928
209952
 
209929
209953
  // dist/internal/exclude-dirs-from-configuration-files.js
209930
- import { existsSync as existsSync18 } from "fs";
209954
+ import { existsSync as existsSync19 } from "fs";
209931
209955
  import { readFile as readFile21 } from "fs/promises";
209932
209956
  import { basename as basename6, resolve as resolve24 } from "path";
209933
209957
  var import_yaml2 = __toESM(require_dist11(), 1);
209934
209958
  async function inferExcludeDirsFromConfigurationFiles(rootWorkingDir) {
209935
209959
  const socketYmlConfigFile = resolve24(rootWorkingDir, "socket.yml");
209936
- if (existsSync18(socketYmlConfigFile))
209960
+ if (existsSync19(socketYmlConfigFile))
209937
209961
  return inferExcludeDirsFromSocketConfig(socketYmlConfigFile);
209938
209962
  const socketYamlConfigFile = resolve24(rootWorkingDir, "socket.yaml");
209939
- if (existsSync18(socketYamlConfigFile))
209963
+ if (existsSync19(socketYamlConfigFile))
209940
209964
  return inferExcludeDirsFromSocketConfig(socketYamlConfigFile);
209941
209965
  return void 0;
209942
209966
  }
@@ -224025,7 +224049,7 @@ var { root: root2 } = static_exports;
224025
224049
 
224026
224050
  // ../utils/src/maven-utils.ts
224027
224051
  var import_lodash14 = __toESM(require_lodash(), 1);
224028
- import { existsSync as existsSync19, readdirSync as readdirSync4, statSync as statSync4 } from "fs";
224052
+ import { existsSync as existsSync20, readdirSync as readdirSync4, statSync as statSync4 } from "fs";
224029
224053
  import { join as join21 } from "path";
224030
224054
  var { memoize: memoize3 } = import_lodash14.default;
224031
224055
  var memoizedParseShellArgs = memoize3(parseShellArgs);
@@ -225397,7 +225421,7 @@ async function onlineScan(dependencyTree, apiKey, timeout) {
225397
225421
  }
225398
225422
 
225399
225423
  // dist/version.js
225400
- var version2 = "14.11.14";
225424
+ var version2 = "14.11.15";
225401
225425
 
225402
225426
  // dist/cli-core.js
225403
225427
  var { mapValues, omit, partition, pick } = import_lodash15.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coana-tech/cli",
3
- "version": "14.11.14",
3
+ "version": "14.11.15",
4
4
  "description": "Coana CLI",
5
5
  "type": "module",
6
6
  "bin": {