@codacy/tools-sqlint-0 0.3.0 → 0.3.2

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/dist/index.js CHANGED
@@ -52,6 +52,18 @@ var patterns_default = [
52
52
  }
53
53
  ];
54
54
 
55
+ // src/metadata.ts
56
+ var descriptor = {
57
+ id: "SQLint",
58
+ displayName: "SQLint",
59
+ preferredVersion: "0.2.1",
60
+ languages: ["SQL", "PLSQL"],
61
+ filePatterns: ["**/*.sql"],
62
+ supportedOS: ["linux", "darwin"],
63
+ supportedArch: ["x64", "arm64"],
64
+ supportedRunners: ["local", "container"]
65
+ };
66
+
55
67
  // src/adapter.ts
56
68
  var TOOL_ID = "SQLint";
57
69
  var ADAPTER_ID = "sqlint-0";
@@ -71,37 +83,6 @@ function ruleMetadata() {
71
83
  return PATTERN_META.get(UMBRELLA_PATTERN) ?? { category: "Compatibility", severity: "High" };
72
84
  }
73
85
  var OUTPUT_LINE_REGEX = /^(.+?):(\d+):(\d+):(ERROR|WARNING)\s+(.+)$/;
74
- function getLineContent(lines, lineNumber) {
75
- return lines[lineNumber - 1] ?? "";
76
- }
77
- async function readFileLines(filePath) {
78
- try {
79
- const content = await import_promises.default.readFile(filePath, "utf-8");
80
- return content.split("\n");
81
- } catch {
82
- return [];
83
- }
84
- }
85
- function buildResult(startedAt, completedAt, issues, errors, filesAnalyzed) {
86
- const durationMs = completedAt.getTime() - startedAt.getTime();
87
- return {
88
- metadata: {
89
- startedAt: startedAt.toISOString(),
90
- completedAt: completedAt.toISOString(),
91
- durationMs
92
- },
93
- issues,
94
- errors,
95
- summary: {
96
- toolId: TOOL_ID,
97
- status: errors.some((e) => e.level === "error") ? "partial" : "success",
98
- issueCount: issues.length,
99
- errorCount: errors.length,
100
- durationMs,
101
- filesAnalyzed
102
- }
103
- };
104
- }
105
86
  async function resolveToolInvocation(ctx) {
106
87
  const gemPaths = (0, import_tooling.getGemPaths)(ctx.globalDir, ADAPTER_ID);
107
88
  const scriptPath = (0, import_tooling.resolveGemBinary)(gemPaths, "sqlint");
@@ -125,16 +106,9 @@ async function resolveToolInvocation(ctx) {
125
106
  return { binary: "sqlint", prefixArgs: [], rubyPath: rubyInfo?.path };
126
107
  }
127
108
  var adapter = {
128
- id: TOOL_ID,
129
- displayName: "SQLint",
130
- preferredVersion: SQLINT_VERSION,
109
+ ...descriptor,
131
110
  compatibleVersions: ">=0.2.0",
132
111
  website: "https://github.com/purcell/sqlint",
133
- languages: ["SQL", "PLSQL"],
134
- filePatterns: ["**/*.sql"],
135
- supportedOS: ["linux", "darwin"],
136
- supportedArch: ["x64", "arm64"],
137
- supportedRunners: ["local", "container"],
138
112
  prerequisites: [
139
113
  {
140
114
  name: "Ruby",
@@ -301,13 +275,9 @@ var adapter = {
301
275
  const issues = [];
302
276
  const errors = [];
303
277
  if (ctx.targetFiles.length === 0) {
304
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
278
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
305
279
  }
306
280
  const enabledPatterns = new Set(codacyConfig.patterns.map((p) => p.patternId));
307
- if (!codacyConfig.useLocalConfigurationFile && codacyConfig.patterns.length === 0) {
308
- ctx.logger.info("Skipping analysis: no patterns enabled", { toolId: TOOL_ID });
309
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
310
- }
311
281
  const invocation = await resolveToolInvocation(ctx);
312
282
  const absoluteFiles = ctx.targetFiles.map((f) => import_path.default.resolve(ctx.repositoryRoot, f));
313
283
  const args = [...invocation.prefixArgs, ...absoluteFiles];
@@ -327,7 +297,7 @@ var adapter = {
327
297
  message: `sqlint exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
328
298
  level: "error"
329
299
  });
330
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
300
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
331
301
  }
332
302
  const output = stdout + (stderr || "");
333
303
  const outputLines = output.split("\n").filter((l) => l.trim());
@@ -348,7 +318,7 @@ var adapter = {
348
318
  }
349
319
  const absPath = import_path.default.resolve(ctx.repositoryRoot, filePath);
350
320
  if (!fileLineCache.has(absPath)) {
351
- fileLineCache.set(absPath, await readFileLines(absPath));
321
+ fileLineCache.set(absPath, await (0, import_tooling.readFileLines)(absPath));
352
322
  }
353
323
  const fileLines = fileLineCache.get(absPath);
354
324
  issues.push({
@@ -358,7 +328,7 @@ var adapter = {
358
328
  line,
359
329
  column,
360
330
  message,
361
- lineContent: getLineContent(fileLines, line),
331
+ lineContent: (0, import_tooling.getLineContent)(fileLines, line),
362
332
  multilineContent: (0, import_tooling.getMultilineContent)(fileLines, line, void 0),
363
333
  category: meta.category,
364
334
  severity: meta.severity
@@ -380,7 +350,7 @@ var adapter = {
380
350
  errorCount: errors.length,
381
351
  durationMs
382
352
  });
383
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
353
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
384
354
  }
385
355
  };
386
356
 
@@ -0,0 +1,13 @@
1
+ import { AdapterDescriptor } from '@codacy/tooling';
2
+
3
+ /**
4
+ * Lightweight adapter descriptor for lazy loading.
5
+ *
6
+ * This module contains only plain-data metadata fields and has zero heavy
7
+ * imports (no patterns.json, no runtime utilities). The CLI imports this
8
+ * at startup for adapter registration without loading the full adapter module.
9
+ */
10
+
11
+ declare const descriptor: AdapterDescriptor;
12
+
13
+ export { descriptor };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/metadata.ts
21
+ var metadata_exports = {};
22
+ __export(metadata_exports, {
23
+ descriptor: () => descriptor
24
+ });
25
+ module.exports = __toCommonJS(metadata_exports);
26
+ var descriptor = {
27
+ id: "SQLint",
28
+ displayName: "SQLint",
29
+ preferredVersion: "0.2.1",
30
+ languages: ["SQL", "PLSQL"],
31
+ filePatterns: ["**/*.sql"],
32
+ supportedOS: ["linux", "darwin"],
33
+ supportedArch: ["x64", "arm64"],
34
+ supportedRunners: ["local", "container"]
35
+ };
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ descriptor
39
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/tools-sqlint-0",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "SQLint adapter — CLI-mode SQL syntax checker",
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.3.0"
11
+ "@codacy/tooling": "0.5.0"
12
12
  },
13
13
  "license": "MIT",
14
14
  "author": "Codacy <support@codacy.com> (https://www.codacy.com)",
@@ -21,8 +21,18 @@
21
21
  "engines": {
22
22
  "node": ">=20.0.0"
23
23
  },
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "default": "./dist/index.js"
28
+ },
29
+ "./metadata": {
30
+ "types": "./dist/metadata.d.ts",
31
+ "default": "./dist/metadata.js"
32
+ }
33
+ },
24
34
  "scripts": {
25
- "build": "tsup src/index.ts --format cjs --dts --clean",
35
+ "build": "tsup src/index.ts src/metadata.ts --format cjs --dts --clean",
26
36
  "test": "vitest run",
27
37
  "lint": "eslint src/",
28
38
  "clean": "rm -rf dist",