@alint-js/cli 0.1.0 → 0.1.1
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/bin/index.mjs +1 -1
- package/dist/{cli-5-mYfGS0.mjs → cli-B_wKMxdx.mjs} +166 -115
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
package/dist/bin/index.mjs
CHANGED
|
@@ -16,7 +16,7 @@ import Gitignore from "gitignore-fs";
|
|
|
16
16
|
import { Minimatch, minimatch } from "minimatch";
|
|
17
17
|
import { errorMessageFrom as errorMessageFrom$1 } from "@moeru/std";
|
|
18
18
|
//#region package.json
|
|
19
|
-
var version = "0.1.
|
|
19
|
+
var version = "0.1.1";
|
|
20
20
|
//#endregion
|
|
21
21
|
//#region src/cli/output.ts
|
|
22
22
|
function escapeLineValue(value) {
|
|
@@ -1711,7 +1711,7 @@ function formatStylish(input, options = {}) {
|
|
|
1711
1711
|
function countCachedDiagnostics(diagnostics, severity) {
|
|
1712
1712
|
return diagnostics.filter((diagnostic) => diagnostic.severity === severity && diagnostic.cached === true).length;
|
|
1713
1713
|
}
|
|
1714
|
-
function countDiagnostics$
|
|
1714
|
+
function countDiagnostics$1(diagnostics, severity) {
|
|
1715
1715
|
return diagnostics.filter((diagnostic) => diagnostic.severity === severity).length;
|
|
1716
1716
|
}
|
|
1717
1717
|
function createStyle(color) {
|
|
@@ -1740,8 +1740,8 @@ function formatExecutionSummary(execution) {
|
|
|
1740
1740
|
return `${execution.cached}/${execution.planned} cached`;
|
|
1741
1741
|
}
|
|
1742
1742
|
function formatSummary(diagnostics, result, style) {
|
|
1743
|
-
const warnCount = countDiagnostics$
|
|
1744
|
-
const errorCount = countDiagnostics$
|
|
1743
|
+
const warnCount = countDiagnostics$1(diagnostics, "warn");
|
|
1744
|
+
const errorCount = countDiagnostics$1(diagnostics, "error");
|
|
1745
1745
|
const cachedWarnCount = countCachedDiagnostics(diagnostics, "warn");
|
|
1746
1746
|
const cachedErrorCount = countCachedDiagnostics(diagnostics, "error");
|
|
1747
1747
|
const tokens = result === void 0 ? void 0 : formatTokenSummary(result);
|
|
@@ -1779,19 +1779,18 @@ function createPlainProgressReporter(options) {
|
|
|
1779
1779
|
const target = payload.job.target.name ? `${payload.job.target.kind} ${payload.job.target.name}` : payload.job.target.kind;
|
|
1780
1780
|
writeLine(`scan ${payload.job.inputPath} > ${target} > ${payload.job.ruleId}`);
|
|
1781
1781
|
},
|
|
1782
|
+
onPrepareEnd: ({ filesTotal }) => writeLine(`alint prepared: ${filesTotal} files`),
|
|
1783
|
+
onPrepareStart: () => writeLine("alint preparing"),
|
|
1782
1784
|
onRunEnd: (payload) => {
|
|
1783
|
-
const warnCount = countDiagnostics
|
|
1784
|
-
const errorCount = countDiagnostics
|
|
1785
|
+
const warnCount = countDiagnostics(payload.diagnostics, "warn");
|
|
1786
|
+
const errorCount = countDiagnostics(payload.diagnostics, "error");
|
|
1785
1787
|
const state = payload.execution.failed > 0 ? "failed" : "finished";
|
|
1786
1788
|
const { cached, cancelled, completed, failed, skipped } = payload.execution;
|
|
1787
1789
|
writeLine(`alint ${state}: ${warnCount} warn, ${errorCount} error, ${payload.usage.totalTokens} tokens, ${completed} completed, ${cached} cached, ${failed} failed, ${cancelled} cancelled, ${skipped} skipped`);
|
|
1788
|
-
},
|
|
1789
|
-
onRunStart: (payload) => {
|
|
1790
|
-
writeLine(`alint started: ${payload.jobsTotal} queued jobs`);
|
|
1791
1790
|
}
|
|
1792
1791
|
};
|
|
1793
1792
|
}
|
|
1794
|
-
function countDiagnostics
|
|
1793
|
+
function countDiagnostics(diagnostics, severity) {
|
|
1795
1794
|
return diagnostics.filter((diagnostic) => diagnostic.severity === severity).length;
|
|
1796
1795
|
}
|
|
1797
1796
|
//#endregion
|
|
@@ -1837,35 +1836,48 @@ function createSummaryProgressReporter(options) {
|
|
|
1837
1836
|
const state = createInitialState();
|
|
1838
1837
|
return {
|
|
1839
1838
|
getRows: () => createRows(state, options, now()),
|
|
1840
|
-
onDiagnostic: ({ diagnostic }) => {
|
|
1841
|
-
state
|
|
1839
|
+
onDiagnostic: ({ diagnostic, progress }) => {
|
|
1840
|
+
updateProgress(state, progress);
|
|
1841
|
+
if (diagnostic.severity === "warn") state.warnCount += 1;
|
|
1842
|
+
else state.errorCount += 1;
|
|
1843
|
+
},
|
|
1844
|
+
onExecuteEnd: ({ progress }) => {
|
|
1845
|
+
updateProgress(state, progress);
|
|
1842
1846
|
},
|
|
1847
|
+
onExecuteStart: ({ progress, startedAt }) => {
|
|
1848
|
+
updateProgress(state, progress);
|
|
1849
|
+
state.runStartedAt = startedAt ?? state.runStartedAt ?? now();
|
|
1850
|
+
},
|
|
1851
|
+
onFileReady: ({ progress }) => updateProgress(state, progress),
|
|
1843
1852
|
onJobEnd: (payload) => {
|
|
1844
|
-
|
|
1845
|
-
|
|
1853
|
+
updateProgress(state, payload.progress);
|
|
1854
|
+
const current = state.activeJobs.get(payload.job.id);
|
|
1855
|
+
const group = state.ruleGroups.get(payload.job.ruleId);
|
|
1856
|
+
if (!group) throw new Error(`Cannot finish unqueued progress job "${payload.job.id}".`);
|
|
1857
|
+
group[payload.state] += 1;
|
|
1858
|
+
if (payload.endedAt !== void 0 && current?.startedAt !== void 0 && payload.state !== "cached") group.terminalDurationMs += Math.max(payload.endedAt - current.startedAt, 0);
|
|
1859
|
+
if (payload.state === "cached") {
|
|
1846
1860
|
const cachedTokens = state.jobTokens.get(payload.job.id) ?? 0;
|
|
1847
1861
|
state.totalTokens = Math.max(state.totalTokens - cachedTokens, 0);
|
|
1848
1862
|
state.cachedTokens += cachedTokens;
|
|
1849
1863
|
}
|
|
1850
|
-
state.
|
|
1851
|
-
|
|
1852
|
-
job: payload.job,
|
|
1853
|
-
retry: current?.retry,
|
|
1854
|
-
startedAt: payload.startedAt ?? current?.startedAt,
|
|
1855
|
-
state: payload.state
|
|
1856
|
-
});
|
|
1857
|
-
transition(state.execution, "running", payload.state);
|
|
1864
|
+
state.activeJobs.delete(payload.job.id);
|
|
1865
|
+
state.jobTokens.delete(payload.job.id);
|
|
1858
1866
|
},
|
|
1859
|
-
onJobQueued: ({ job }) => {
|
|
1860
|
-
state
|
|
1867
|
+
onJobQueued: ({ job, progress }) => {
|
|
1868
|
+
updateProgress(state, progress);
|
|
1869
|
+
const group = state.ruleGroups.get(job.ruleId) ?? createRuleGroup(job);
|
|
1870
|
+
group.planned += 1;
|
|
1871
|
+
state.ruleGroups.set(job.ruleId, group);
|
|
1872
|
+
state.activeJobs.set(job.id, {
|
|
1861
1873
|
job,
|
|
1862
1874
|
state: "queued"
|
|
1863
1875
|
});
|
|
1864
|
-
state.execution.queued += 1;
|
|
1865
1876
|
},
|
|
1866
1877
|
onJobRetry: (payload) => {
|
|
1867
|
-
|
|
1868
|
-
state.
|
|
1878
|
+
updateProgress(state, payload.progress);
|
|
1879
|
+
const current = state.activeJobs.get(payload.job.id);
|
|
1880
|
+
state.activeJobs.set(payload.job.id, {
|
|
1869
1881
|
job: payload.job,
|
|
1870
1882
|
retry: {
|
|
1871
1883
|
attempt: payload.attempt,
|
|
@@ -1877,51 +1889,39 @@ function createSummaryProgressReporter(options) {
|
|
|
1877
1889
|
});
|
|
1878
1890
|
},
|
|
1879
1891
|
onJobStart: (payload) => {
|
|
1880
|
-
state
|
|
1892
|
+
updateProgress(state, payload.progress);
|
|
1893
|
+
state.activeJobs.set(payload.job.id, {
|
|
1881
1894
|
job: payload.job,
|
|
1882
1895
|
startedAt: payload.startedAt ?? now(),
|
|
1883
1896
|
state: "running"
|
|
1884
1897
|
});
|
|
1885
|
-
transition(state.execution, "queued", "running");
|
|
1886
|
-
},
|
|
1887
|
-
onRunEnd: (payload) => {
|
|
1888
|
-
state.diagnostics = [...payload.diagnostics];
|
|
1889
|
-
state.execution = { ...payload.execution };
|
|
1890
|
-
state.totalTokens = payload.usage.totalTokens;
|
|
1891
|
-
state.cachedTokens = payload.usage.cached?.totalTokens ?? 0;
|
|
1892
|
-
state.runStartedAt = payload.startedAt ?? state.runStartedAt;
|
|
1893
1898
|
},
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
* -> `ProgressReporter.onRunStart`
|
|
1901
|
-
* -> `createRenderingProgressReporter(...).onRunStart`
|
|
1902
|
-
* -> `SummaryProgressReporter.onRunStart` (this handler)
|
|
1903
|
-
*
|
|
1904
|
-
* Upstream:
|
|
1905
|
-
* - `createRenderingProgressReporter(...).onRunStart`
|
|
1906
|
-
*
|
|
1907
|
-
* Downstream:
|
|
1908
|
-
* - Resets `state.animationTick` and run data consumed by {@link createRows}.
|
|
1909
|
-
*/
|
|
1910
|
-
onRunStart: ({ jobsTotal, startedAt }) => {
|
|
1911
|
-
state.diagnostics = [];
|
|
1912
|
-
state.execution = createCounts(jobsTotal);
|
|
1913
|
-
state.jobs.clear();
|
|
1899
|
+
onPrepareStart: ({ startedAt }) => {
|
|
1900
|
+
state.activeJobs.clear();
|
|
1901
|
+
state.errorCount = 0;
|
|
1902
|
+
state.execution = createCounts();
|
|
1903
|
+
state.progress = createProgress();
|
|
1904
|
+
state.ruleGroups.clear();
|
|
1914
1905
|
state.runStartedAt = startedAt ?? now();
|
|
1915
1906
|
state.animationTick = 0;
|
|
1916
1907
|
state.cachedTokens = 0;
|
|
1917
1908
|
state.jobTokens.clear();
|
|
1918
1909
|
state.totalTokens = 0;
|
|
1910
|
+
state.warnCount = 0;
|
|
1911
|
+
},
|
|
1912
|
+
onRunEnd: (payload) => {
|
|
1913
|
+
state.warnCount = payload.diagnostics.filter((diagnostic) => diagnostic.severity === "warn").length;
|
|
1914
|
+
state.errorCount = payload.diagnostics.length - state.warnCount;
|
|
1915
|
+
updateProgress(state, payload.progress);
|
|
1916
|
+
state.totalTokens = payload.usage.totalTokens;
|
|
1917
|
+
state.cachedTokens = payload.usage.cached?.totalTokens ?? 0;
|
|
1918
|
+
state.runStartedAt = payload.startedAt ?? state.runStartedAt;
|
|
1919
1919
|
},
|
|
1920
|
-
onUsage: ({ job, record }) => {
|
|
1920
|
+
onUsage: ({ job, progress, record }) => {
|
|
1921
|
+
updateProgress(state, progress);
|
|
1921
1922
|
if (record.totalTokens != null && Number.isFinite(record.totalTokens)) {
|
|
1922
1923
|
state.jobTokens.set(job.id, (state.jobTokens.get(job.id) ?? 0) + record.totalTokens);
|
|
1923
|
-
|
|
1924
|
-
else state.totalTokens += record.totalTokens;
|
|
1924
|
+
state.totalTokens += record.totalTokens;
|
|
1925
1925
|
}
|
|
1926
1926
|
},
|
|
1927
1927
|
/**
|
|
@@ -1966,9 +1966,6 @@ function completeGraphemeBoundary(input, maximumIndex) {
|
|
|
1966
1966
|
}
|
|
1967
1967
|
return boundary;
|
|
1968
1968
|
}
|
|
1969
|
-
function countDiagnostics(diagnostics, severity) {
|
|
1970
|
-
return diagnostics.filter((diagnostic) => diagnostic.severity === severity).length;
|
|
1971
|
-
}
|
|
1972
1969
|
function createCounts(planned = 0) {
|
|
1973
1970
|
return {
|
|
1974
1971
|
cached: 0,
|
|
@@ -1983,19 +1980,30 @@ function createCounts(planned = 0) {
|
|
|
1983
1980
|
}
|
|
1984
1981
|
function createInitialState() {
|
|
1985
1982
|
return {
|
|
1983
|
+
activeJobs: /* @__PURE__ */ new Map(),
|
|
1986
1984
|
animationTick: 0,
|
|
1987
1985
|
cachedTokens: 0,
|
|
1988
|
-
|
|
1986
|
+
errorCount: 0,
|
|
1989
1987
|
execution: createCounts(),
|
|
1990
|
-
jobs: /* @__PURE__ */ new Map(),
|
|
1991
1988
|
jobTokens: /* @__PURE__ */ new Map(),
|
|
1992
|
-
|
|
1989
|
+
progress: createProgress(),
|
|
1990
|
+
ruleGroups: /* @__PURE__ */ new Map(),
|
|
1991
|
+
totalTokens: 0,
|
|
1992
|
+
warnCount: 0
|
|
1993
|
+
};
|
|
1994
|
+
}
|
|
1995
|
+
function createProgress() {
|
|
1996
|
+
return {
|
|
1997
|
+
execution: createCounts(),
|
|
1998
|
+
filesTotal: 0,
|
|
1999
|
+
final: false,
|
|
2000
|
+
jobsCompleted: 0,
|
|
2001
|
+
jobsStarted: 0,
|
|
2002
|
+
jobsTotal: 0
|
|
1993
2003
|
};
|
|
1994
2004
|
}
|
|
1995
2005
|
function createRows(state, options, now) {
|
|
1996
2006
|
if (options.rows !== void 0 && options.rows <= 0) return [];
|
|
1997
|
-
const warnCount = countDiagnostics(state.diagnostics, "warn");
|
|
1998
|
-
const errorCount = countDiagnostics(state.diagnostics, "error");
|
|
1999
2007
|
const groups = createRuleGroups(state);
|
|
2000
2008
|
const footerRows = options.rows === void 0 ? 3 : Math.min(options.rows, 3);
|
|
2001
2009
|
const separatorRows = options.rows === void 0 || options.rows - footerRows > 1 ? 1 : 0;
|
|
@@ -2005,34 +2013,27 @@ function createRows(state, options, now) {
|
|
|
2005
2013
|
const visibleFooters = options.rows === void 0 ? footer : footer.slice(0, Math.max(options.rows - visible.length - actualSeparatorRows, 0));
|
|
2006
2014
|
if (actualSeparatorRows === 1) visible.push("");
|
|
2007
2015
|
visible.push(...visibleFooters);
|
|
2008
|
-
return options.color ? visible.map((row) => styleRow(row, state, warnCount, errorCount, options)) : visible;
|
|
2016
|
+
return options.color ? visible.map((row) => styleRow(row, state, state.warnCount, state.errorCount, options)) : visible;
|
|
2017
|
+
}
|
|
2018
|
+
function createRuleGroup(job) {
|
|
2019
|
+
return {
|
|
2020
|
+
cached: 0,
|
|
2021
|
+
cancelled: 0,
|
|
2022
|
+
completed: 0,
|
|
2023
|
+
failed: 0,
|
|
2024
|
+
firstJobIndex: job.index,
|
|
2025
|
+
planned: 0,
|
|
2026
|
+
ruleId: job.ruleId,
|
|
2027
|
+
skipped: 0,
|
|
2028
|
+
terminalDurationMs: 0
|
|
2029
|
+
};
|
|
2009
2030
|
}
|
|
2010
2031
|
function createRuleGroups(state) {
|
|
2011
|
-
const groups =
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
completed: 0,
|
|
2017
|
-
failed: 0,
|
|
2018
|
-
firstJobIndex: job.job.index,
|
|
2019
|
-
jobs: [],
|
|
2020
|
-
planned: 0,
|
|
2021
|
-
ruleId: job.job.ruleId,
|
|
2022
|
-
skipped: 0,
|
|
2023
|
-
terminalDurationMs: 0
|
|
2024
|
-
};
|
|
2025
|
-
group.firstJobIndex = Math.min(group.firstJobIndex, job.job.index);
|
|
2026
|
-
group.jobs.push(job);
|
|
2027
|
-
group.planned = Math.max(group.planned, job.job.ruleTotal);
|
|
2028
|
-
if (job.state === "cached") group.cached += 1;
|
|
2029
|
-
if (job.state === "cancelled") group.cancelled += 1;
|
|
2030
|
-
if (job.state === "completed") group.completed += 1;
|
|
2031
|
-
if (job.state === "failed") group.failed += 1;
|
|
2032
|
-
if (job.state === "skipped") group.skipped += 1;
|
|
2033
|
-
if (job.endedAt !== void 0 && job.startedAt !== void 0 && job.state !== "cached") group.terminalDurationMs += Math.max(job.endedAt - job.startedAt, 0);
|
|
2034
|
-
groups.set(group.ruleId, group);
|
|
2035
|
-
}
|
|
2032
|
+
const groups = new Map([...state.ruleGroups].map(([ruleId, group]) => [ruleId, {
|
|
2033
|
+
...group,
|
|
2034
|
+
jobs: []
|
|
2035
|
+
}]));
|
|
2036
|
+
for (const job of state.activeJobs.values()) groups.get(job.job.ruleId)?.jobs.push(job);
|
|
2036
2037
|
return [...groups.values()].sort(compareRuleGroups);
|
|
2037
2038
|
}
|
|
2038
2039
|
function estimateEta(durationMs, terminal, planned) {
|
|
@@ -2097,11 +2098,12 @@ function formatDuration(ms) {
|
|
|
2097
2098
|
function formatFooters(state, options, now) {
|
|
2098
2099
|
const terminal = terminalCount(state.execution);
|
|
2099
2100
|
const elapsed = state.runStartedAt === void 0 ? 0 : now - state.runStartedAt;
|
|
2100
|
-
const progressBar = formatMiniBarSegment(terminal, state.execution.planned, state.animationTick, options);
|
|
2101
|
-
const eta = estimateEta(elapsed, terminal, state.execution.planned);
|
|
2102
|
-
const projectedTokens = terminal > 0 && state.execution.planned > 0 ? Math.ceil((state.totalTokens + state.cachedTokens) * state.execution.planned / terminal) : void 0;
|
|
2101
|
+
const progressBar = state.progress.final ? formatMiniBarSegment(terminal, state.execution.planned, state.animationTick, options) : "";
|
|
2102
|
+
const eta = state.progress.final ? estimateEta(elapsed, terminal, state.execution.planned) : "eta ?";
|
|
2103
|
+
const projectedTokens = state.progress.final && terminal > 0 && state.execution.planned > 0 ? Math.ceil((state.totalTokens + state.cachedTokens) * state.execution.planned / terminal) : void 0;
|
|
2104
|
+
const discovering = state.progress.final ? "" : " jobs (discovering)";
|
|
2103
2105
|
return [
|
|
2104
|
-
fitRow(`${terminal}/${state.execution.planned}${progressBar} ${formatDuration(elapsed)} -> ${eta === "eta ?" ? "~?" : eta.replace("eta ", "")}`, options.columns),
|
|
2106
|
+
fitRow(`${terminal}/${state.execution.planned}${discovering}${progressBar} ${formatDuration(elapsed)} -> ${eta === "eta ?" ? "~?" : eta.replace("eta ", "")}`, options.columns),
|
|
2105
2107
|
fitRow(`${state.execution.running} concurrency / ${state.execution.queued} queued / ${state.execution.cached} cached / ${state.execution.failed} failed`, options.columns),
|
|
2106
2108
|
fitRow(`${state.totalTokens.toLocaleString("en-US")} tokens (${state.cachedTokens.toLocaleString("en-US")} cached) -> ${projectedTokens === void 0 ? "~?" : `~${projectedTokens.toLocaleString("en-US")} tokens`}`, options.columns)
|
|
2107
2109
|
];
|
|
@@ -2143,9 +2145,12 @@ function styleRow(row, state, warnCount, errorCount, options) {
|
|
|
2143
2145
|
function terminalCount(counts) {
|
|
2144
2146
|
return counts.completed + counts.failed + counts.cached + counts.skipped + counts.cancelled;
|
|
2145
2147
|
}
|
|
2146
|
-
function
|
|
2147
|
-
|
|
2148
|
-
|
|
2148
|
+
function updateProgress(state, progress) {
|
|
2149
|
+
state.execution = { ...progress.execution };
|
|
2150
|
+
state.progress = {
|
|
2151
|
+
...progress,
|
|
2152
|
+
execution: { ...progress.execution }
|
|
2153
|
+
};
|
|
2149
2154
|
}
|
|
2150
2155
|
//#endregion
|
|
2151
2156
|
//#region src/cli/reporters/progress/tty.ts
|
|
@@ -2235,6 +2240,18 @@ function createRenderingProgressReporter(summary, renderer) {
|
|
|
2235
2240
|
summary.onDiagnostic?.(payload);
|
|
2236
2241
|
renderer.render();
|
|
2237
2242
|
},
|
|
2243
|
+
onExecuteEnd: (payload) => {
|
|
2244
|
+
summary.onExecuteEnd?.(payload);
|
|
2245
|
+
renderer.render();
|
|
2246
|
+
},
|
|
2247
|
+
onExecuteStart: (payload) => {
|
|
2248
|
+
summary.onExecuteStart?.(payload);
|
|
2249
|
+
renderer.render();
|
|
2250
|
+
},
|
|
2251
|
+
onFileReady: (payload) => {
|
|
2252
|
+
summary.onFileReady?.(payload);
|
|
2253
|
+
renderer.render();
|
|
2254
|
+
},
|
|
2238
2255
|
onJobEnd: (payload) => {
|
|
2239
2256
|
summary.onJobEnd?.(payload);
|
|
2240
2257
|
renderer.render();
|
|
@@ -2251,14 +2268,18 @@ function createRenderingProgressReporter(summary, renderer) {
|
|
|
2251
2268
|
summary.onJobStart?.(payload);
|
|
2252
2269
|
renderer.render();
|
|
2253
2270
|
},
|
|
2254
|
-
|
|
2255
|
-
summary.
|
|
2271
|
+
onPrepareEnd: (payload) => {
|
|
2272
|
+
summary.onPrepareEnd?.(payload);
|
|
2256
2273
|
renderer.render();
|
|
2257
2274
|
},
|
|
2258
|
-
|
|
2259
|
-
summary.
|
|
2275
|
+
onPrepareStart: (payload) => {
|
|
2276
|
+
summary.onPrepareStart?.(payload);
|
|
2260
2277
|
renderer.start();
|
|
2261
2278
|
},
|
|
2279
|
+
onRunEnd: (payload) => {
|
|
2280
|
+
summary.onRunEnd?.(payload);
|
|
2281
|
+
renderer.render();
|
|
2282
|
+
},
|
|
2262
2283
|
onUsage: (payload) => {
|
|
2263
2284
|
summary.onUsage?.(payload);
|
|
2264
2285
|
renderer.render();
|
|
@@ -2446,13 +2467,21 @@ function formatCancelledError(error, color) {
|
|
|
2446
2467
|
}
|
|
2447
2468
|
function formatRunError(error, color) {
|
|
2448
2469
|
const label = color ? colors$1.red("error") : "error";
|
|
2449
|
-
const
|
|
2470
|
+
const fileFailures = error.failures.filter((failure) => "file" in failure);
|
|
2471
|
+
const groups = groupFailuresByRule(error.failures.filter((failure) => "job" in failure));
|
|
2450
2472
|
return [
|
|
2451
2473
|
`${label} ${error.message}`,
|
|
2452
2474
|
"",
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2475
|
+
...fileFailures.length > 0 ? [
|
|
2476
|
+
`Failed Files ${fileFailures.length}`,
|
|
2477
|
+
"",
|
|
2478
|
+
...formatFileFailures(fileFailures, color)
|
|
2479
|
+
] : [],
|
|
2480
|
+
...groups.length > 0 ? [
|
|
2481
|
+
`Failed Rules ${groups.length}`,
|
|
2482
|
+
"",
|
|
2483
|
+
...formatFailureGroups(groups, color)
|
|
2484
|
+
] : []
|
|
2456
2485
|
].join("\n");
|
|
2457
2486
|
}
|
|
2458
2487
|
function formatFailureGroups(groups, color) {
|
|
@@ -2461,7 +2490,7 @@ function formatFailureGroups(groups, color) {
|
|
|
2461
2490
|
const failLabel = color ? colors$1.bgRed(colors$1.bold(" FAIL ")) : "FAIL";
|
|
2462
2491
|
const targetLabel = group.length === 1 ? "target" : "targets";
|
|
2463
2492
|
lines.push(`${failLabel} ${ruleId} ${group.length} ${targetLabel}`);
|
|
2464
|
-
for (const failure of group
|
|
2493
|
+
for (const failure of group) {
|
|
2465
2494
|
lines.push(` ${formatTarget(failure)}`);
|
|
2466
2495
|
lines.push(` [${failure.kind}] ${failure.message}`);
|
|
2467
2496
|
}
|
|
@@ -2469,6 +2498,16 @@ function formatFailureGroups(groups, color) {
|
|
|
2469
2498
|
}
|
|
2470
2499
|
return lines;
|
|
2471
2500
|
}
|
|
2501
|
+
function formatFileFailures(failures, color) {
|
|
2502
|
+
const lines = [];
|
|
2503
|
+
for (const failure of failures) {
|
|
2504
|
+
const failLabel = color ? colors$1.bgRed(colors$1.bold(" FAIL ")) : "FAIL";
|
|
2505
|
+
lines.push(`${failLabel} ${failure.file.path}`);
|
|
2506
|
+
lines.push(` [${failure.kind}] ${failure.message}`);
|
|
2507
|
+
lines.push("");
|
|
2508
|
+
}
|
|
2509
|
+
return lines;
|
|
2510
|
+
}
|
|
2472
2511
|
function formatTarget(failure) {
|
|
2473
2512
|
const target = failure.job.target.name ? `${failure.job.target.kind} ${failure.job.target.name}` : failure.job.target.kind;
|
|
2474
2513
|
return `${failure.job.inputPath} > ${target}`;
|
|
@@ -2904,6 +2943,9 @@ function createStatsCollector() {
|
|
|
2904
2943
|
counts,
|
|
2905
2944
|
durationMs: () => startedAt !== void 0 && endedAt !== void 0 ? endedAt - startedAt : void 0,
|
|
2906
2945
|
reporter: {
|
|
2946
|
+
onPrepareStart: (payload) => {
|
|
2947
|
+
startedAt = payload.startedAt;
|
|
2948
|
+
},
|
|
2907
2949
|
onRunEnd: (payload) => {
|
|
2908
2950
|
counts.cached = payload.execution.cached;
|
|
2909
2951
|
counts.cancelled = payload.execution.cancelled;
|
|
@@ -2911,9 +2953,6 @@ function createStatsCollector() {
|
|
|
2911
2953
|
counts.failed = payload.execution.failed;
|
|
2912
2954
|
counts.planned = payload.execution.planned;
|
|
2913
2955
|
endedAt = payload.endedAt;
|
|
2914
|
-
},
|
|
2915
|
-
onRunStart: (payload) => {
|
|
2916
|
-
startedAt = payload.startedAt;
|
|
2917
2956
|
}
|
|
2918
2957
|
}
|
|
2919
2958
|
};
|
|
@@ -2947,6 +2986,15 @@ function mergeProgressReporters(base, extra) {
|
|
|
2947
2986
|
onDiagnostic: (payload) => {
|
|
2948
2987
|
deliverBoth((reporter) => reporter.onDiagnostic?.(payload));
|
|
2949
2988
|
},
|
|
2989
|
+
onExecuteEnd: (payload) => {
|
|
2990
|
+
deliverBoth((reporter) => reporter.onExecuteEnd?.(payload));
|
|
2991
|
+
},
|
|
2992
|
+
onExecuteStart: (payload) => {
|
|
2993
|
+
deliverBoth((reporter) => reporter.onExecuteStart?.(payload));
|
|
2994
|
+
},
|
|
2995
|
+
onFileReady: (payload) => {
|
|
2996
|
+
deliverBoth((reporter) => reporter.onFileReady?.(payload));
|
|
2997
|
+
},
|
|
2950
2998
|
onJobEnd: (payload) => {
|
|
2951
2999
|
deliverBoth((reporter) => reporter.onJobEnd?.(payload));
|
|
2952
3000
|
},
|
|
@@ -2959,13 +3007,16 @@ function mergeProgressReporters(base, extra) {
|
|
|
2959
3007
|
onJobStart: (payload) => {
|
|
2960
3008
|
deliverBoth((reporter) => reporter.onJobStart?.(payload));
|
|
2961
3009
|
},
|
|
3010
|
+
onPrepareEnd: (payload) => {
|
|
3011
|
+
deliverBoth((reporter) => reporter.onPrepareEnd?.(payload));
|
|
3012
|
+
},
|
|
3013
|
+
onPrepareStart: (payload) => {
|
|
3014
|
+
deliverBoth((reporter) => reporter.onPrepareStart?.(payload));
|
|
3015
|
+
},
|
|
2962
3016
|
onRunEnd: (payload) => {
|
|
2963
3017
|
deliverBoth((reporter) => reporter.onRunEnd?.(payload));
|
|
2964
3018
|
if (firstFailure) throw firstFailure;
|
|
2965
3019
|
},
|
|
2966
|
-
onRunStart: (payload) => {
|
|
2967
|
-
deliverBoth((reporter) => reporter.onRunStart?.(payload));
|
|
2968
|
-
},
|
|
2969
3020
|
onUsage: (payload) => {
|
|
2970
3021
|
deliverBoth((reporter) => reporter.onUsage?.(payload));
|
|
2971
3022
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as formatJson, n as formatDiagnostics, r as formatStylish, t as executeCli } from "./cli-
|
|
1
|
+
import { i as formatJson, n as formatDiagnostics, r as formatStylish, t as executeCli } from "./cli-B_wKMxdx.mjs";
|
|
2
2
|
import { ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated } from "@alint-js/config";
|
|
3
3
|
import { defineConfig } from "@alint-js/core";
|
|
4
4
|
export { defineConfig, executeCli, formatDiagnostics, formatJson, formatStylish, ignorePatternsAIAgents, ignorePatternsBuildOutputs, ignorePatternsCaches, ignorePatternsCommon, ignorePatternsEslintDefaults, ignorePatternsGenerated };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alint-js/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.mts",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"pathe": "^2.0.3",
|
|
28
28
|
"table": "^6.9.0",
|
|
29
29
|
"tinyrainbow": "^3.1.0",
|
|
30
|
-
"@alint-js/
|
|
31
|
-
"@alint-js/
|
|
30
|
+
"@alint-js/core": "0.1.1",
|
|
31
|
+
"@alint-js/config": "0.1.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@pnpm/find-workspace-dir": "^1000.1.5",
|