@codacy/tools-shellcheck-0 0.13.0 → 0.15.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.
Files changed (2) hide show
  1. package/dist/index.js +65 -45
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -4501,7 +4501,11 @@ var PLATFORM_MAP = {
4501
4501
  "darwin-arm64": { suffix: "darwin.x86_64", format: "tar.xz" },
4502
4502
  "darwin-x64": { suffix: "darwin.x86_64", format: "tar.xz" },
4503
4503
  "linux-x64": { suffix: "linux.x86_64", format: "tar.xz" },
4504
- "linux-arm64": { suffix: "linux.aarch64", format: "tar.xz" }
4504
+ "linux-arm64": { suffix: "linux.aarch64", format: "tar.xz" },
4505
+ // Windows asset is `shellcheck-v{version}.zip` (no platform infix), with
4506
+ // `shellcheck.exe` at the archive root — so an empty `suffix` and no
4507
+ // strip-components (see install). Extracted via bsdtar.
4508
+ "win32-x64": { suffix: "", format: "zip" }
4505
4509
  };
4506
4510
  async function getVersionFromBinary(binaryPath) {
4507
4511
  try {
@@ -4516,7 +4520,7 @@ async function getVersionFromBinary(binaryPath) {
4516
4520
  }
4517
4521
  }
4518
4522
  async function resolveBinaryPath(ctx) {
4519
- const codacyBin = import_path.default.join(ctx.toolInstallDir, BINARY);
4523
+ const codacyBin = import_path.default.join(ctx.toolInstallDir, (0, import_tooling.exeName)(BINARY));
4520
4524
  const version = await getVersionFromBinary(codacyBin);
4521
4525
  if (version) return codacyBin;
4522
4526
  return BINARY;
@@ -4540,7 +4544,7 @@ var adapter = {
4540
4544
  */
4541
4545
  async checkAvailability(ctx) {
4542
4546
  ctx.logger.debug("Checking availability", { toolId: TOOL_ID });
4543
- const codacyBin = import_path.default.join(ctx.toolInstallDir, BINARY);
4547
+ const codacyBin = import_path.default.join(ctx.toolInstallDir, (0, import_tooling.exeName)(BINARY));
4544
4548
  const codacyVersion = await getVersionFromBinary(codacyBin);
4545
4549
  if (codacyVersion) {
4546
4550
  ctx.logger.debug("Found codacy-managed binary", {
@@ -4597,12 +4601,14 @@ var adapter = {
4597
4601
  };
4598
4602
  }
4599
4603
  const version = adapter.preferredVersion;
4600
- const url = `https://github.com/koalaman/shellcheck/releases/download/v${version}/shellcheck-v${version}.${platformInfo.suffix}.${platformInfo.format}`;
4601
- const destPath = import_path.default.join(ctx.toolInstallDir, BINARY);
4604
+ const assetName = platformInfo.suffix ? `shellcheck-v${version}.${platformInfo.suffix}.${platformInfo.format}` : `shellcheck-v${version}.${platformInfo.format}`;
4605
+ const url = `https://github.com/koalaman/shellcheck/releases/download/v${version}/${assetName}`;
4606
+ const destPath = import_path.default.join(ctx.toolInstallDir, (0, import_tooling.exeName)(BINARY));
4607
+ const stripComponents = platformInfo.suffix ? 1 : 0;
4602
4608
  try {
4603
4609
  ctx.logger.info(`Downloading shellcheck v${version} for ${platformKey}...`);
4604
- await (0, import_tooling.downloadAndExtract)(url, ctx.toolInstallDir, { stripComponents: 1 }, ctx.logger);
4605
- await import_promises.default.chmod(destPath, 493);
4610
+ await (0, import_tooling.downloadAndExtract)(url, ctx.toolInstallDir, { stripComponents }, ctx.logger);
4611
+ if (!import_tooling.IS_WINDOWS) await import_promises.default.chmod(destPath, 493);
4606
4612
  ctx.logger.info(`Installed shellcheck v${version} to ${destPath}`);
4607
4613
  return { success: true, installedPath: destPath, installedVersion: version };
4608
4614
  } catch (err) {
@@ -4677,37 +4683,60 @@ var adapter = {
4677
4683
  if (codacyConfig.useLocalConfigurationFile && codacyConfig.localConfigurationFile) {
4678
4684
  args.push("--rcfile", codacyConfig.localConfigurationFile);
4679
4685
  }
4680
- args.push(...absoluteFiles);
4686
+ const fileChunks = (0, import_tooling.chunkFilesForArgv)(absoluteFiles);
4681
4687
  try {
4682
- const { stdout, stderr, exitCode } = await (0, import_tooling.spawnTool)(binary, args, {
4683
- cwd: ctx.repositoryRoot,
4684
- logger: ctx.logger
4685
- });
4686
- if (exitCode >= 2) {
4687
- errors.push({
4688
- toolId: TOOL_ID,
4689
- phase: "toolInvoke",
4690
- kind: "NonZeroExit",
4691
- message: `shellcheck exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
4692
- level: "error"
4693
- });
4694
- return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
4695
- }
4696
- if (!stdout.trim()) {
4697
- return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
4698
- }
4699
- let findings;
4700
- try {
4701
- findings = JSON.parse(stdout);
4702
- } catch (err) {
4703
- errors.push({
4704
- toolId: TOOL_ID,
4705
- phase: "outputParse",
4706
- kind: "MalformedOutput",
4707
- message: `Failed to parse shellcheck JSON output: ${err instanceof Error ? err.message : String(err)}`,
4708
- level: "error"
4688
+ const findings = [];
4689
+ for (const chunk of fileChunks) {
4690
+ const { stdout, stderr, exitCode } = await (0, import_tooling.spawnTool)(binary, [...args, ...chunk], {
4691
+ cwd: ctx.repositoryRoot,
4692
+ logger: ctx.logger
4709
4693
  });
4710
- return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
4694
+ if (exitCode >= 2) {
4695
+ errors.push({
4696
+ toolId: TOOL_ID,
4697
+ phase: "toolInvoke",
4698
+ kind: "NonZeroExit",
4699
+ message: `shellcheck exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
4700
+ level: "error"
4701
+ });
4702
+ return (0, import_tooling.buildResult)(
4703
+ TOOL_ID,
4704
+ startedAt,
4705
+ /* @__PURE__ */ new Date(),
4706
+ issues,
4707
+ errors,
4708
+ ctx.targetFiles.length
4709
+ );
4710
+ }
4711
+ if (stderr.trim()) {
4712
+ errors.push({
4713
+ toolId: TOOL_ID,
4714
+ phase: "outputParse",
4715
+ kind: "ParseWarning",
4716
+ message: `shellcheck stderr: ${stderr.trim()}`,
4717
+ level: "warning"
4718
+ });
4719
+ }
4720
+ if (!stdout.trim()) continue;
4721
+ try {
4722
+ findings.push(...JSON.parse(stdout));
4723
+ } catch (err) {
4724
+ errors.push({
4725
+ toolId: TOOL_ID,
4726
+ phase: "outputParse",
4727
+ kind: "MalformedOutput",
4728
+ message: `Failed to parse shellcheck JSON output: ${err instanceof Error ? err.message : String(err)}`,
4729
+ level: "error"
4730
+ });
4731
+ return (0, import_tooling.buildResult)(
4732
+ TOOL_ID,
4733
+ startedAt,
4734
+ /* @__PURE__ */ new Date(),
4735
+ issues,
4736
+ errors,
4737
+ ctx.targetFiles.length
4738
+ );
4739
+ }
4711
4740
  }
4712
4741
  const enabledPatterns = new Set(codacyConfig.patterns.map((p) => p.patternId));
4713
4742
  const findingsByFile = /* @__PURE__ */ new Map();
@@ -4741,15 +4770,6 @@ var adapter = {
4741
4770
  });
4742
4771
  }
4743
4772
  }
4744
- if (stderr.trim()) {
4745
- errors.push({
4746
- toolId: TOOL_ID,
4747
- phase: "outputParse",
4748
- kind: "ParseWarning",
4749
- message: `shellcheck stderr: ${stderr.trim()}`,
4750
- level: "warning"
4751
- });
4752
- }
4753
4773
  } catch (err) {
4754
4774
  errors.push({
4755
4775
  toolId: TOOL_ID,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/tools-shellcheck-0",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "ShellCheck adapter — CLI-mode shell script linter",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,7 +8,7 @@
8
8
  "dist"
9
9
  ],
10
10
  "dependencies": {
11
- "@codacy/tooling": "0.13.0"
11
+ "@codacy/tooling": "0.15.0"
12
12
  },
13
13
  "license": "MIT",
14
14
  "author": "Codacy <support@codacy.com> (https://www.codacy.com)",