@wrongstack/plugins 0.291.2 → 0.292.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.
- package/dist/duplicate-code-detector/index.d.ts.map +1 -1
- package/dist/duplicate-code-detector.js +35 -18
- package/dist/format-on-save/index.d.ts.map +1 -1
- package/dist/format-on-save.js +65 -27
- package/dist/git-autocommit/index.d.ts.map +1 -1
- package/dist/git-autocommit.js +54 -42
- package/dist/index.js +529 -310
- package/dist/notify-hub/index.d.ts +0 -39
- package/dist/notify-hub/index.d.ts.map +1 -1
- package/dist/notify-hub/webhook-channel.d.ts +56 -0
- package/dist/notify-hub/webhook-channel.d.ts.map +1 -0
- package/dist/notify-hub.js +241 -102
- package/dist/shell-check/index.d.ts.map +1 -1
- package/dist/shell-check.js +60 -36
- package/dist/spec-linker.js +529 -310
- package/dist/type-gate/index.d.ts.map +1 -1
- package/dist/type-gate.js +12 -23
- package/package.json +3 -3
package/dist/shell-check.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/shell-check/index.ts
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
|
+
import { readdir } from "node:fs/promises";
|
|
4
4
|
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
5
5
|
var API_VERSION = "^0.1.10";
|
|
6
6
|
function withinProject(p) {
|
|
@@ -21,15 +21,23 @@ var state = {
|
|
|
21
21
|
/** Most recent run summary, surfaced by health(). */
|
|
22
22
|
lastRun: null
|
|
23
23
|
};
|
|
24
|
-
function runShellCheck(files, severity, cwd) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
async function runShellCheck(files, severity, cwd) {
|
|
25
|
+
try {
|
|
26
|
+
await new Promise((resolvePromise, rejectPromise) => {
|
|
27
|
+
execFile(
|
|
28
|
+
"shellcheck",
|
|
29
|
+
["--version"],
|
|
30
|
+
{ encoding: "utf-8", windowsHide: true },
|
|
31
|
+
(err) => {
|
|
32
|
+
if (err) rejectPromise(err);
|
|
33
|
+
else resolvePromise();
|
|
34
|
+
}
|
|
31
35
|
);
|
|
32
|
-
}
|
|
36
|
+
});
|
|
37
|
+
} catch {
|
|
38
|
+
throw new Error(
|
|
39
|
+
"shellcheck is not installed. Install via: apt install shellcheck / brew install shellcheck"
|
|
40
|
+
);
|
|
33
41
|
}
|
|
34
42
|
const levelMap = {
|
|
35
43
|
error: "error",
|
|
@@ -41,20 +49,34 @@ function runShellCheck(files, severity, cwd) {
|
|
|
41
49
|
const args = ["-f", "json", "-S", severityFlag, ...files];
|
|
42
50
|
let raw;
|
|
43
51
|
try {
|
|
44
|
-
raw =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
raw = await new Promise((resolvePromise, rejectPromise) => {
|
|
53
|
+
execFile(
|
|
54
|
+
"shellcheck",
|
|
55
|
+
args,
|
|
56
|
+
{
|
|
57
|
+
encoding: "utf-8",
|
|
58
|
+
cwd,
|
|
59
|
+
windowsHide: true,
|
|
60
|
+
timeout: 6e4,
|
|
61
|
+
maxBuffer: 16 * 1024 * 1024
|
|
62
|
+
},
|
|
63
|
+
(err, stdout, stderr) => {
|
|
64
|
+
if (err) {
|
|
65
|
+
const e = err;
|
|
66
|
+
const diagnostic = stdout || e.stdout?.toString() || stderr || e.stderr?.toString() || "";
|
|
67
|
+
if (diagnostic.trim()) {
|
|
68
|
+
resolvePromise(diagnostic);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
rejectPromise(err);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
resolvePromise(stdout);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
50
77
|
});
|
|
51
|
-
} catch
|
|
52
|
-
|
|
53
|
-
if (e.stderr && !e.stderr.includes("shellcheck")) {
|
|
54
|
-
raw = e.stderr;
|
|
55
|
-
} else {
|
|
56
|
-
return [];
|
|
57
|
-
}
|
|
78
|
+
} catch {
|
|
79
|
+
return [];
|
|
58
80
|
}
|
|
59
81
|
if (!raw.trim()) return [];
|
|
60
82
|
try {
|
|
@@ -71,21 +93,23 @@ function runShellCheck(files, severity, cwd) {
|
|
|
71
93
|
return [];
|
|
72
94
|
}
|
|
73
95
|
}
|
|
74
|
-
function findShellFiles(dir, pattern) {
|
|
96
|
+
async function findShellFiles(dir, pattern) {
|
|
75
97
|
const results = [];
|
|
98
|
+
let entries;
|
|
76
99
|
try {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
100
|
+
entries = await readdir(dir, { withFileTypes: true });
|
|
101
|
+
} catch {
|
|
102
|
+
return results;
|
|
103
|
+
}
|
|
104
|
+
for (const entry of entries) {
|
|
105
|
+
const full = join(dir, entry.name);
|
|
106
|
+
if (entry.isDirectory() && entry.name !== "node_modules" && entry.name !== ".git") {
|
|
107
|
+
results.push(...await findShellFiles(full, pattern));
|
|
108
|
+
} else if (entry.isFile() && (entry.name.endsWith(".sh") || entry.name === "Dockerfile")) {
|
|
109
|
+
if (!pattern || entry.name.includes(pattern)) {
|
|
110
|
+
results.push(full);
|
|
86
111
|
}
|
|
87
112
|
}
|
|
88
|
-
} catch {
|
|
89
113
|
}
|
|
90
114
|
return results;
|
|
91
115
|
}
|
|
@@ -186,7 +210,7 @@ var plugin = {
|
|
|
186
210
|
if (files && files.length > 0) {
|
|
187
211
|
checkFiles = files;
|
|
188
212
|
} else {
|
|
189
|
-
checkFiles = findShellFiles(directory, pattern);
|
|
213
|
+
checkFiles = await findShellFiles(directory, pattern);
|
|
190
214
|
scannedDirectories = true;
|
|
191
215
|
}
|
|
192
216
|
if (checkFiles.length === 0) {
|
|
@@ -207,7 +231,7 @@ var plugin = {
|
|
|
207
231
|
}
|
|
208
232
|
let issues;
|
|
209
233
|
try {
|
|
210
|
-
issues = runShellCheck(checkFiles, severity);
|
|
234
|
+
issues = await runShellCheck(checkFiles, severity);
|
|
211
235
|
} catch (err) {
|
|
212
236
|
const msg = err instanceof Error ? err.message : String(err);
|
|
213
237
|
return { ok: false, error: msg, issues: [], filesScanned: 0 };
|