aislop 0.2.1 → 0.3.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/README.md +3 -1
- package/dist/cli.js +669 -92
- package/dist/{engine-info-DFze-2GQ.js → engine-info-CXT2Q_Jy.js} +1 -1
- package/dist/{expo-doctor-CGXGLgMJ.js → expo-doctor-Cm5892Y8.js} +76 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2971 -2536
- package/dist/{json-Ci_gvHLS.js → json-C52xnH_4.js} +1 -1
- package/package.json +1 -1
- package/dist/expo-doctor-vDz4kh9-.js +0 -127
- package/dist/subprocess-99puEEGl.js +0 -59
package/package.json
CHANGED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { r as runSubprocess } from "./cli.js";
|
|
3
|
-
import { createRequire } from "node:module";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import fs from "node:fs";
|
|
6
|
-
|
|
7
|
-
//#region src/engines/lint/expo-doctor.ts
|
|
8
|
-
const esmRequire = createRequire(import.meta.url);
|
|
9
|
-
const ISSUE_PREFIX = "✖ ";
|
|
10
|
-
const resolveExpoDoctorScript = () => {
|
|
11
|
-
try {
|
|
12
|
-
const packageJsonPath = esmRequire.resolve("expo-doctor/package.json");
|
|
13
|
-
const pkg = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
14
|
-
const binRelativePath = typeof pkg.bin === "string" ? pkg.bin : pkg.bin?.["expo-doctor"];
|
|
15
|
-
if (!binRelativePath) return null;
|
|
16
|
-
return path.join(path.dirname(packageJsonPath), binRelativePath);
|
|
17
|
-
} catch {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
const toRuleSuffix = (title) => {
|
|
22
|
-
const slug = title.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
23
|
-
return slug.length > 0 ? slug : "issue";
|
|
24
|
-
};
|
|
25
|
-
const parseIssues = (output) => {
|
|
26
|
-
const lines = output.split("\n").map((line) => line.trimEnd());
|
|
27
|
-
const startIndex = lines.findIndex((line) => line.includes("Possible issues detected:"));
|
|
28
|
-
if (startIndex < 0) return [];
|
|
29
|
-
const issues = [];
|
|
30
|
-
let current = null;
|
|
31
|
-
let inAdvice = false;
|
|
32
|
-
for (let i = startIndex + 1; i < lines.length; i += 1) {
|
|
33
|
-
const line = lines[i].trim();
|
|
34
|
-
if (/^\d+\s+checks failed/.test(line)) break;
|
|
35
|
-
if (line.length === 0) continue;
|
|
36
|
-
if (line.startsWith(ISSUE_PREFIX)) {
|
|
37
|
-
if (current) issues.push(current);
|
|
38
|
-
current = {
|
|
39
|
-
title: line.slice(2).trim(),
|
|
40
|
-
details: [],
|
|
41
|
-
advice: []
|
|
42
|
-
};
|
|
43
|
-
inAdvice = false;
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
if (!current) continue;
|
|
47
|
-
if (line === "Advice:") {
|
|
48
|
-
inAdvice = true;
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
if (inAdvice) current.advice.push(line);
|
|
52
|
-
else current.details.push(line);
|
|
53
|
-
}
|
|
54
|
-
if (current) issues.push(current);
|
|
55
|
-
return issues;
|
|
56
|
-
};
|
|
57
|
-
const parseConfigError = (output) => {
|
|
58
|
-
const line = output.split("\n").find((candidate) => candidate.trim().startsWith("ConfigError:"));
|
|
59
|
-
return line ? line.trim() : null;
|
|
60
|
-
};
|
|
61
|
-
const toDiagnostics = (issues) => issues.map((issue) => {
|
|
62
|
-
const helpParts = [issue.details.join(" ").trim(), issue.advice.join(" ").trim()].filter((part) => part.length > 0);
|
|
63
|
-
return {
|
|
64
|
-
filePath: "package.json",
|
|
65
|
-
engine: "lint",
|
|
66
|
-
rule: `expo-doctor/${toRuleSuffix(issue.title)}`,
|
|
67
|
-
severity: "warning",
|
|
68
|
-
message: `Expo Doctor: ${issue.title}`,
|
|
69
|
-
help: helpParts.join(" "),
|
|
70
|
-
line: 0,
|
|
71
|
-
column: 0,
|
|
72
|
-
category: "Expo",
|
|
73
|
-
fixable: false
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
const runExpoDoctor = async (context) => {
|
|
77
|
-
const scriptPath = resolveExpoDoctorScript();
|
|
78
|
-
let stdout = "";
|
|
79
|
-
let stderr = "";
|
|
80
|
-
try {
|
|
81
|
-
if (scriptPath) {
|
|
82
|
-
const result = await runSubprocess(process.execPath, [
|
|
83
|
-
scriptPath,
|
|
84
|
-
context.rootDirectory,
|
|
85
|
-
"--verbose"
|
|
86
|
-
], {
|
|
87
|
-
cwd: context.rootDirectory,
|
|
88
|
-
timeout: 12e4
|
|
89
|
-
});
|
|
90
|
-
stdout = result.stdout;
|
|
91
|
-
stderr = result.stderr;
|
|
92
|
-
} else {
|
|
93
|
-
const result = await runSubprocess("npx", [
|
|
94
|
-
"--yes",
|
|
95
|
-
"expo-doctor",
|
|
96
|
-
context.rootDirectory,
|
|
97
|
-
"--verbose"
|
|
98
|
-
], {
|
|
99
|
-
cwd: context.rootDirectory,
|
|
100
|
-
timeout: 12e4
|
|
101
|
-
});
|
|
102
|
-
stdout = result.stdout;
|
|
103
|
-
stderr = result.stderr;
|
|
104
|
-
}
|
|
105
|
-
} catch {
|
|
106
|
-
return [];
|
|
107
|
-
}
|
|
108
|
-
const output = [stdout, stderr].filter(Boolean).join("\n");
|
|
109
|
-
if (!output) return [];
|
|
110
|
-
const configError = parseConfigError(output);
|
|
111
|
-
if (configError) return [{
|
|
112
|
-
filePath: "package.json",
|
|
113
|
-
engine: "lint",
|
|
114
|
-
rule: "expo-doctor/config-error",
|
|
115
|
-
severity: "warning",
|
|
116
|
-
message: configError,
|
|
117
|
-
help: "Install project dependencies, then re-run `aislop scan`.",
|
|
118
|
-
line: 0,
|
|
119
|
-
column: 0,
|
|
120
|
-
category: "Expo",
|
|
121
|
-
fixable: false
|
|
122
|
-
}];
|
|
123
|
-
return toDiagnostics(parseIssues(output));
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
//#endregion
|
|
127
|
-
export { runExpoDoctor };
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
|
|
3
|
-
//#region src/utils/subprocess.ts
|
|
4
|
-
const runSubprocess = (command, args, options = {}) => {
|
|
5
|
-
return new Promise((resolve, reject) => {
|
|
6
|
-
const child = spawn(command, args, {
|
|
7
|
-
cwd: options.cwd,
|
|
8
|
-
env: {
|
|
9
|
-
...process.env,
|
|
10
|
-
...options.env
|
|
11
|
-
},
|
|
12
|
-
stdio: [
|
|
13
|
-
"ignore",
|
|
14
|
-
"pipe",
|
|
15
|
-
"pipe"
|
|
16
|
-
],
|
|
17
|
-
windowsHide: true
|
|
18
|
-
});
|
|
19
|
-
const stdoutBuffers = [];
|
|
20
|
-
const stderrBuffers = [];
|
|
21
|
-
child.stdout?.on("data", (buffer) => stdoutBuffers.push(buffer));
|
|
22
|
-
child.stderr?.on("data", (buffer) => stderrBuffers.push(buffer));
|
|
23
|
-
let settled = false;
|
|
24
|
-
let timer;
|
|
25
|
-
const finalize = (callback) => {
|
|
26
|
-
if (settled) return;
|
|
27
|
-
settled = true;
|
|
28
|
-
if (timer) clearTimeout(timer);
|
|
29
|
-
callback();
|
|
30
|
-
};
|
|
31
|
-
if (options.timeout && options.timeout > 0) {
|
|
32
|
-
timer = setTimeout(() => {
|
|
33
|
-
child.kill("SIGTERM");
|
|
34
|
-
setTimeout(() => child.kill("SIGKILL"), 1e3).unref();
|
|
35
|
-
finalize(() => reject(/* @__PURE__ */ new Error(`Command timed out after ${options.timeout}ms: ${command}`)));
|
|
36
|
-
}, options.timeout);
|
|
37
|
-
timer.unref();
|
|
38
|
-
}
|
|
39
|
-
child.once("error", (error) => finalize(() => reject(/* @__PURE__ */ new Error(`Failed to run ${command}: ${error.message}`))));
|
|
40
|
-
child.once("close", (code) => {
|
|
41
|
-
finalize(() => resolve({
|
|
42
|
-
stdout: Buffer.concat(stdoutBuffers).toString("utf-8").trim(),
|
|
43
|
-
stderr: Buffer.concat(stderrBuffers).toString("utf-8").trim(),
|
|
44
|
-
exitCode: code
|
|
45
|
-
}));
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
const isToolInstalled = async (tool) => {
|
|
50
|
-
try {
|
|
51
|
-
const result = await runSubprocess("which", [tool]);
|
|
52
|
-
return result.exitCode === 0 && result.stdout.length > 0;
|
|
53
|
-
} catch {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
//#endregion
|
|
59
|
-
export { runSubprocess as n, isToolInstalled as t };
|