@codacy/tools-sqlint-0 0.3.1 → 0.3.3

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
@@ -48,10 +48,23 @@ var patterns_default = [
48
48
  severityLevel: "High",
49
49
  title: "Enforce ANSI SQL Syntax Compliance",
50
50
  enabled: true,
51
+ languages: ["SQL", "PLSQL"],
51
52
  parameters: []
52
53
  }
53
54
  ];
54
55
 
56
+ // src/metadata.ts
57
+ var descriptor = {
58
+ id: "SQLint",
59
+ displayName: "SQLint",
60
+ preferredVersion: "0.2.1",
61
+ languages: ["SQL", "PLSQL"],
62
+ filePatterns: ["**/*.sql"],
63
+ supportedOS: ["linux", "darwin"],
64
+ supportedArch: ["x64", "arm64"],
65
+ supportedRunners: ["local", "container"]
66
+ };
67
+
55
68
  // src/adapter.ts
56
69
  var TOOL_ID = "SQLint";
57
70
  var ADAPTER_ID = "sqlint-0";
@@ -71,37 +84,6 @@ function ruleMetadata() {
71
84
  return PATTERN_META.get(UMBRELLA_PATTERN) ?? { category: "Compatibility", severity: "High" };
72
85
  }
73
86
  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
87
  async function resolveToolInvocation(ctx) {
106
88
  const gemPaths = (0, import_tooling.getGemPaths)(ctx.globalDir, ADAPTER_ID);
107
89
  const scriptPath = (0, import_tooling.resolveGemBinary)(gemPaths, "sqlint");
@@ -125,16 +107,9 @@ async function resolveToolInvocation(ctx) {
125
107
  return { binary: "sqlint", prefixArgs: [], rubyPath: rubyInfo?.path };
126
108
  }
127
109
  var adapter = {
128
- id: TOOL_ID,
129
- displayName: "SQLint",
130
- preferredVersion: SQLINT_VERSION,
110
+ ...descriptor,
131
111
  compatibleVersions: ">=0.2.0",
132
112
  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
113
  prerequisites: [
139
114
  {
140
115
  name: "Ruby",
@@ -301,13 +276,9 @@ var adapter = {
301
276
  const issues = [];
302
277
  const errors = [];
303
278
  if (ctx.targetFiles.length === 0) {
304
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
279
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, 0);
305
280
  }
306
281
  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
282
  const invocation = await resolveToolInvocation(ctx);
312
283
  const absoluteFiles = ctx.targetFiles.map((f) => import_path.default.resolve(ctx.repositoryRoot, f));
313
284
  const args = [...invocation.prefixArgs, ...absoluteFiles];
@@ -327,7 +298,7 @@ var adapter = {
327
298
  message: `sqlint exited with code ${exitCode}${stderr ? `: ${stderr.trim()}` : ""}`,
328
299
  level: "error"
329
300
  });
330
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
301
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
331
302
  }
332
303
  const output = stdout + (stderr || "");
333
304
  const outputLines = output.split("\n").filter((l) => l.trim());
@@ -348,7 +319,7 @@ var adapter = {
348
319
  }
349
320
  const absPath = import_path.default.resolve(ctx.repositoryRoot, filePath);
350
321
  if (!fileLineCache.has(absPath)) {
351
- fileLineCache.set(absPath, await readFileLines(absPath));
322
+ fileLineCache.set(absPath, await (0, import_tooling.readFileLines)(absPath));
352
323
  }
353
324
  const fileLines = fileLineCache.get(absPath);
354
325
  issues.push({
@@ -358,7 +329,7 @@ var adapter = {
358
329
  line,
359
330
  column,
360
331
  message,
361
- lineContent: getLineContent(fileLines, line),
332
+ lineContent: (0, import_tooling.getLineContent)(fileLines, line),
362
333
  multilineContent: (0, import_tooling.getMultilineContent)(fileLines, line, void 0),
363
334
  category: meta.category,
364
335
  severity: meta.severity
@@ -380,7 +351,7 @@ var adapter = {
380
351
  errorCount: errors.length,
381
352
  durationMs
382
353
  });
383
- return buildResult(startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
354
+ return (0, import_tooling.buildResult)(TOOL_ID, startedAt, /* @__PURE__ */ new Date(), issues, errors, ctx.targetFiles.length);
384
355
  }
385
356
  };
386
357
 
@@ -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.1",
3
+ "version": "0.3.3",
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.4.0"
11
+ "@codacy/tooling": "0.6.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",