@hawkeyexl/manni 2.12.1 → 4.0.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 +16 -12
- package/dist/{chunk-EM53FMKG.js → chunk-J3KIKNWZ.js} +25 -9
- package/dist/chunk-J3KIKNWZ.js.map +1 -0
- package/dist/{chunk-F6CE4LEJ.js → chunk-O7RMPQZ4.js} +5517 -1068
- package/dist/chunk-O7RMPQZ4.js.map +1 -0
- package/dist/chunk-YDUFTHBZ.js +13908 -0
- package/dist/chunk-YDUFTHBZ.js.map +1 -0
- package/dist/cli.js +348 -35
- package/dist/cli.js.map +1 -1
- package/dist/docmeta.js +2 -2
- package/dist/index.d.ts +1943 -467
- package/dist/index.js +112 -3
- package/dist/index.js.map +1 -1
- package/package.json +18 -3
- package/schemas/lint/config.json +73 -0
- package/schemas/lint/template.json +346 -0
- package/templates/lint/tgdp/concept.yaml +77 -0
- package/templates/lint/tgdp/how-to.yaml +64 -0
- package/templates/lint/tgdp/manifest.json +57 -0
- package/templates/lint/tgdp/readme.yaml +163 -0
- package/templates/lint/tgdp/reference.yaml +67 -0
- package/templates/lint/tgdp/release-notes.yaml +108 -0
- package/templates/lint/tgdp/troubleshooting.yaml +98 -0
- package/templates/lint/tgdp/tutorial.yaml +74 -0
- package/dist/chunk-7X4QMQX4.js +0 -6621
- package/dist/chunk-7X4QMQX4.js.map +0 -1
- package/dist/chunk-EM53FMKG.js.map +0 -1
- package/dist/chunk-F6CE4LEJ.js.map +0 -1
package/dist/cli.js
CHANGED
|
@@ -7,48 +7,65 @@ import {
|
|
|
7
7
|
readStdin,
|
|
8
8
|
reportConfig,
|
|
9
9
|
splitList
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-J3KIKNWZ.js";
|
|
11
11
|
import {
|
|
12
12
|
CiteError,
|
|
13
|
+
INFER_FORMATS,
|
|
13
14
|
KeyError,
|
|
15
|
+
LINT_JOBS,
|
|
16
|
+
LintError,
|
|
14
17
|
RULE_ID_PREFIX,
|
|
15
18
|
SEVERITIES,
|
|
16
19
|
SEVERITY_LIST,
|
|
20
|
+
TOOLS_BY_JOB,
|
|
17
21
|
asCiteError,
|
|
18
22
|
codeEndAt,
|
|
19
23
|
codeRegions,
|
|
20
24
|
errorSite,
|
|
21
25
|
findingMessage,
|
|
22
26
|
isCiteRule,
|
|
27
|
+
isInferFormat,
|
|
23
28
|
isSeverity,
|
|
29
|
+
loadConfig,
|
|
24
30
|
meetsSeverity,
|
|
31
|
+
rebaseConfig,
|
|
32
|
+
render,
|
|
25
33
|
renderCheckGithub,
|
|
26
34
|
renderCheckJson,
|
|
27
35
|
renderCheckPretty,
|
|
28
36
|
renderRemoveJson,
|
|
29
37
|
renderRemovePretty,
|
|
38
|
+
renderTemplates,
|
|
39
|
+
renderTools,
|
|
30
40
|
renderUpdateJson,
|
|
31
41
|
renderUpdatePretty,
|
|
42
|
+
resolveStructureTool,
|
|
32
43
|
runAdd,
|
|
33
44
|
runCheck,
|
|
34
45
|
runKeyRotate,
|
|
35
46
|
runKeySet,
|
|
47
|
+
runLint,
|
|
36
48
|
runRemove,
|
|
49
|
+
runTemplates,
|
|
50
|
+
runTemplatesInfer,
|
|
51
|
+
runTools,
|
|
37
52
|
runUpdate,
|
|
38
53
|
shortCommit,
|
|
39
54
|
shortLine,
|
|
40
55
|
shortPin,
|
|
41
56
|
shortSrc,
|
|
42
57
|
spellSource
|
|
43
|
-
} from "./chunk-
|
|
58
|
+
} from "./chunk-YDUFTHBZ.js";
|
|
44
59
|
import {
|
|
45
60
|
COMMON_FORMAT_LIST,
|
|
61
|
+
CONCEPT_FIELDS,
|
|
46
62
|
FAMILY_CONFIG_NAMES,
|
|
47
63
|
OMITTED_WHEN_CLEAN,
|
|
48
64
|
REPORT_FORMATS,
|
|
49
65
|
REPORT_FORMAT_LIST,
|
|
50
66
|
STDIN_LABEL,
|
|
51
67
|
STDIN_TOKEN,
|
|
68
|
+
TERM_RELATION_FIELDS,
|
|
52
69
|
ToolError,
|
|
53
70
|
assertNonEmpty,
|
|
54
71
|
errorMessage,
|
|
@@ -57,6 +74,7 @@ import {
|
|
|
57
74
|
extractorByName,
|
|
58
75
|
extractorForExtension,
|
|
59
76
|
fail,
|
|
77
|
+
fieldPointer,
|
|
60
78
|
findConfigFile,
|
|
61
79
|
gitignoreOptions,
|
|
62
80
|
isErrorSeverity,
|
|
@@ -69,6 +87,7 @@ import {
|
|
|
69
87
|
palette,
|
|
70
88
|
programName,
|
|
71
89
|
readConfigFile,
|
|
90
|
+
registerTermLabelSource,
|
|
72
91
|
renderJunit,
|
|
73
92
|
renderSarif,
|
|
74
93
|
resolveBaselineRequest,
|
|
@@ -79,11 +98,12 @@ import {
|
|
|
79
98
|
shouldColor,
|
|
80
99
|
splitPageArgument,
|
|
81
100
|
terminalConfirm,
|
|
82
|
-
valeConfigPath
|
|
83
|
-
|
|
101
|
+
valeConfigPath,
|
|
102
|
+
valueAt
|
|
103
|
+
} from "./chunk-O7RMPQZ4.js";
|
|
84
104
|
|
|
85
105
|
// src/cli.ts
|
|
86
|
-
import { Command as
|
|
106
|
+
import { Command as Command6 } from "commander";
|
|
87
107
|
|
|
88
108
|
// src/a11y/cli.ts
|
|
89
109
|
import { Command } from "commander";
|
|
@@ -838,7 +858,7 @@ var A11Y_FORMAT_LIST = A11Y_FORMATS.join(" | ");
|
|
|
838
858
|
function isA11yFormat(value) {
|
|
839
859
|
return A11Y_FORMATS.includes(value);
|
|
840
860
|
}
|
|
841
|
-
function
|
|
861
|
+
function render2(format, run, opts) {
|
|
842
862
|
switch (format) {
|
|
843
863
|
case "pretty":
|
|
844
864
|
return renderPretty(run, opts);
|
|
@@ -1089,7 +1109,7 @@ function buildProgram2() {
|
|
|
1089
1109
|
{ analyzer: createPlaywrightAnalyzer(), onProgress: progress.listener }
|
|
1090
1110
|
);
|
|
1091
1111
|
const color = resolveColor(parent, process.stdout);
|
|
1092
|
-
const text2 =
|
|
1112
|
+
const text2 = render2(format, run, { color, quiet: Boolean(options.quiet) });
|
|
1093
1113
|
if (text2.length > 0 || format !== "github") {
|
|
1094
1114
|
process.stdout.write(`${text2}
|
|
1095
1115
|
`);
|
|
@@ -1745,8 +1765,286 @@ function buildProgram4() {
|
|
|
1745
1765
|
return program;
|
|
1746
1766
|
}
|
|
1747
1767
|
|
|
1748
|
-
// src/
|
|
1768
|
+
// src/lint/cli.ts
|
|
1749
1769
|
import { Command as Command4 } from "commander";
|
|
1770
|
+
var LIST_FORMATS = /* @__PURE__ */ new Set(["pretty", "json"]);
|
|
1771
|
+
var TOOL_OPTIONS_GROUP = "Tool options:";
|
|
1772
|
+
function resolveColor2(program) {
|
|
1773
|
+
const noColor = program.opts().color === false;
|
|
1774
|
+
return shouldColor({ noColor, isTTY: process.stdout.isTTY });
|
|
1775
|
+
}
|
|
1776
|
+
function reportFormat(value) {
|
|
1777
|
+
const format = String(value);
|
|
1778
|
+
if (!isReportFormat(format)) {
|
|
1779
|
+
throw new LintError(
|
|
1780
|
+
`Unknown --format "${format}". Use ${REPORT_FORMAT_LIST}.`
|
|
1781
|
+
);
|
|
1782
|
+
}
|
|
1783
|
+
return format;
|
|
1784
|
+
}
|
|
1785
|
+
function omittedWhenClean(format) {
|
|
1786
|
+
return format !== "explain" && OMITTED_WHEN_CLEAN.has(format);
|
|
1787
|
+
}
|
|
1788
|
+
function listFormat(value) {
|
|
1789
|
+
const format = String(value);
|
|
1790
|
+
if (!LIST_FORMATS.has(format)) {
|
|
1791
|
+
throw new LintError(
|
|
1792
|
+
`Unknown --format "${format}". Use pretty or json.`
|
|
1793
|
+
);
|
|
1794
|
+
}
|
|
1795
|
+
return format;
|
|
1796
|
+
}
|
|
1797
|
+
function inferFormat(value) {
|
|
1798
|
+
const format = String(value);
|
|
1799
|
+
if (!isInferFormat(format)) {
|
|
1800
|
+
throw new LintError(`Unknown --format "${format}". Use yaml or json.`);
|
|
1801
|
+
}
|
|
1802
|
+
return format;
|
|
1803
|
+
}
|
|
1804
|
+
function assertStructureTool(value) {
|
|
1805
|
+
if (value === void 0) return;
|
|
1806
|
+
resolveStructureTool(value);
|
|
1807
|
+
}
|
|
1808
|
+
function withConfigOptions(command) {
|
|
1809
|
+
return command.option("-c, --config <path>", "path to a manni config file").option("--no-config", "ignore any discovered config file");
|
|
1810
|
+
}
|
|
1811
|
+
function optionValue(command, key) {
|
|
1812
|
+
for (let cmd = command; cmd !== null; cmd = cmd.parent ?? null) {
|
|
1813
|
+
if (cmd.getOptionValueSource(key) === "cli") return cmd.getOptionValue(key);
|
|
1814
|
+
}
|
|
1815
|
+
return command.getOptionValue(key);
|
|
1816
|
+
}
|
|
1817
|
+
function withInputOptions(command) {
|
|
1818
|
+
command.argument(
|
|
1819
|
+
"[paths...]",
|
|
1820
|
+
"files, directories, or globs to lint (use - for stdin)"
|
|
1821
|
+
).option(
|
|
1822
|
+
"--collection <name>",
|
|
1823
|
+
"configured collection to run over; repeatable",
|
|
1824
|
+
collect,
|
|
1825
|
+
[]
|
|
1826
|
+
).option("--ext <list>", "comma-separated extensions for directory walks").option("--exclude <glob>", "glob to exclude; repeatable", collect, []).option("--as <format>", "force an input format (e.g. markdown, mdx)").option(
|
|
1827
|
+
"-f, --format <format>",
|
|
1828
|
+
`output: ${REPORT_FORMATS.join(" | ")}`,
|
|
1829
|
+
"pretty"
|
|
1830
|
+
);
|
|
1831
|
+
return withConfigOptions(command).option("--allow-empty", "treat zero matched files as success").option("--no-gitignore", "lint files .gitignore covers");
|
|
1832
|
+
}
|
|
1833
|
+
function inputOptions(paths, options) {
|
|
1834
|
+
return {
|
|
1835
|
+
inputs: paths,
|
|
1836
|
+
collection: options.collection,
|
|
1837
|
+
...options.ext ? { exts: splitList(options.ext) } : {},
|
|
1838
|
+
exclude: options.exclude,
|
|
1839
|
+
...options.as === void 0 ? {} : { as: options.as },
|
|
1840
|
+
...configOption(options.config),
|
|
1841
|
+
// `undefined` rather than `false` when absent, so config still wins.
|
|
1842
|
+
...options.allowEmpty ? { allowEmpty: true } : {},
|
|
1843
|
+
respectGitignore: explicitFalse(options.gitignore),
|
|
1844
|
+
onNotice: notice
|
|
1845
|
+
};
|
|
1846
|
+
}
|
|
1847
|
+
function buildProgram5() {
|
|
1848
|
+
const program = new Command4();
|
|
1849
|
+
program.name("lint").description(
|
|
1850
|
+
"Validate document structure against doctype templates. Deterministic, CI-friendly."
|
|
1851
|
+
).version(package_default.version, "-V, --version").option("--no-color", "disable colored output").showHelpAfterError().exitOverride();
|
|
1852
|
+
const lint = async (paths, options, command, job = {}) => {
|
|
1853
|
+
const tool = job.tool;
|
|
1854
|
+
const format = reportFormat(options.format);
|
|
1855
|
+
const explain = tool?.explain === true;
|
|
1856
|
+
const stdinContent = paths.includes(STDIN_TOKEN) ? await readStdin() : void 0;
|
|
1857
|
+
const cwd = process.cwd();
|
|
1858
|
+
const run = await runLint({
|
|
1859
|
+
...inputOptions(paths, options),
|
|
1860
|
+
...tool?.tool === void 0 ? {} : { tool: tool.tool },
|
|
1861
|
+
...tool?.template === void 0 ? {} : { template: tool.template },
|
|
1862
|
+
...tool && tool.templates.length > 0 ? { templates: tool.templates } : {},
|
|
1863
|
+
...explain ? { explain: true } : {},
|
|
1864
|
+
...stdinContent === void 0 ? {} : { stdinContent },
|
|
1865
|
+
// Which config governed the run, said where a report cannot be parsed
|
|
1866
|
+
// around: discovery walks up to the project boundary, so an unexpected
|
|
1867
|
+
// ancestor config is the difference between a five-minute diagnosis and
|
|
1868
|
+
// an hour of confusion.
|
|
1869
|
+
onConfigLoaded: reportConfig(format === "pretty", cwd)
|
|
1870
|
+
});
|
|
1871
|
+
const color = resolveColor2(command.parent ?? command);
|
|
1872
|
+
const chosen = explain ? "explain" : format;
|
|
1873
|
+
const text2 = render(run, chosen, { color });
|
|
1874
|
+
if (text2.length > 0 || !omittedWhenClean(chosen)) {
|
|
1875
|
+
process.stdout.write(`${text2}
|
|
1876
|
+
`);
|
|
1877
|
+
}
|
|
1878
|
+
process.exitCode = explain ? 0 : run.summary.failed > 0 ? 1 : 0;
|
|
1879
|
+
};
|
|
1880
|
+
withInputOptions(
|
|
1881
|
+
program.command("check").description("Run every configured lint job over the given files/dirs/globs")
|
|
1882
|
+
).addHelpText(
|
|
1883
|
+
"after",
|
|
1884
|
+
[
|
|
1885
|
+
"",
|
|
1886
|
+
"Jobs: structure.",
|
|
1887
|
+
"",
|
|
1888
|
+
"Examples:",
|
|
1889
|
+
" manni lint check docs/ # every configured job",
|
|
1890
|
+
" manni lint check # targets from collections:",
|
|
1891
|
+
" manni lint check --collection guides",
|
|
1892
|
+
' manni lint check "**/*.md" -f github # CI annotations',
|
|
1893
|
+
" cat page.md | manni lint check - --as markdown"
|
|
1894
|
+
].join("\n")
|
|
1895
|
+
).action(async (paths, options, command) => {
|
|
1896
|
+
try {
|
|
1897
|
+
if (options.format === "pretty") {
|
|
1898
|
+
process.stderr.write(`Checked: ${LINT_JOBS.join(", ")}.
|
|
1899
|
+
`);
|
|
1900
|
+
}
|
|
1901
|
+
await lint(paths, options, command);
|
|
1902
|
+
} catch (err) {
|
|
1903
|
+
fail(err);
|
|
1904
|
+
}
|
|
1905
|
+
});
|
|
1906
|
+
const structure = withInputOptions(
|
|
1907
|
+
program.command("structure").description(
|
|
1908
|
+
"Lint document structure against doctype templates, routing each page by its `type`"
|
|
1909
|
+
)
|
|
1910
|
+
);
|
|
1911
|
+
structure.optionsGroup(TOOL_OPTIONS_GROUP).option(
|
|
1912
|
+
"--tool <name>",
|
|
1913
|
+
`tool that performs the job: ${TOOLS_BY_JOB.structure.join(", ")}`
|
|
1914
|
+
).option(
|
|
1915
|
+
"-t, --template <ref>",
|
|
1916
|
+
"apply this template to every file, overriding type routing"
|
|
1917
|
+
).option(
|
|
1918
|
+
"--templates <path>",
|
|
1919
|
+
"template file to route by: its `types:` win over built-ins; repeatable",
|
|
1920
|
+
collect,
|
|
1921
|
+
[]
|
|
1922
|
+
).option(
|
|
1923
|
+
"--explain",
|
|
1924
|
+
"print how each file's template was chosen, and lint nothing (always exits 0, unrouted pages included)"
|
|
1925
|
+
).addHelpText(
|
|
1926
|
+
"after",
|
|
1927
|
+
[
|
|
1928
|
+
"",
|
|
1929
|
+
"Examples:",
|
|
1930
|
+
" manni lint structure docs/ # route each page by its `type`",
|
|
1931
|
+
" manni lint structure docs/ --templates ./templates.yaml # add your own templates",
|
|
1932
|
+
" manni lint structure # targets from collections:",
|
|
1933
|
+
" manni lint structure docs/ --explain # show why each page routed where",
|
|
1934
|
+
" manni lint structure page.md -t tgdp:how-to:1.6 # force one template",
|
|
1935
|
+
' manni lint structure "**/*.md" -f github # CI annotations',
|
|
1936
|
+
" manni lint structure docs/ --exclude '**/drafts/**'",
|
|
1937
|
+
" cat page.md | manni lint structure - -t tgdp:how-to:1.6 --as markdown"
|
|
1938
|
+
].join("\n")
|
|
1939
|
+
).action(
|
|
1940
|
+
async (paths, options, command) => {
|
|
1941
|
+
try {
|
|
1942
|
+
assertStructureTool(options.tool);
|
|
1943
|
+
await lint(paths, options, command, { tool: options });
|
|
1944
|
+
} catch (err) {
|
|
1945
|
+
fail(err);
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
);
|
|
1949
|
+
const templates = program.command("templates").description("List the templates that can be applied, and the types they serve").option(
|
|
1950
|
+
"--templates <path>",
|
|
1951
|
+
"also list the templates in this file; repeatable",
|
|
1952
|
+
collect,
|
|
1953
|
+
[]
|
|
1954
|
+
);
|
|
1955
|
+
withConfigOptions(templates).option("-f, --format <format>", "output: pretty | json", "pretty").action(async (options, command) => {
|
|
1956
|
+
try {
|
|
1957
|
+
const format = listFormat(options.format);
|
|
1958
|
+
const { configPath, noConfig } = configOption(options.config);
|
|
1959
|
+
const found = noConfig ? null : await loadConfig(configPath);
|
|
1960
|
+
const info = await runTemplates({
|
|
1961
|
+
templates: options.templates.length > 0 ? options.templates : rebaseConfig(found).templates
|
|
1962
|
+
});
|
|
1963
|
+
const color = resolveColor2(command.parent ?? command);
|
|
1964
|
+
process.stdout.write(`${renderTemplates(info, format, { color })}
|
|
1965
|
+
`);
|
|
1966
|
+
} catch (err) {
|
|
1967
|
+
fail(err);
|
|
1968
|
+
}
|
|
1969
|
+
});
|
|
1970
|
+
const inferCommand = templates.command("infer").description("Write a first template from a page that already has the shape you want").argument("<page>", "one file to infer from (use - for stdin)").option("--as <format>", "force an input format (e.g. markdown, mdx)").option(
|
|
1971
|
+
"--name <name>",
|
|
1972
|
+
"name for the template; defaults to the page's `type`, else its filename"
|
|
1973
|
+
).option("-f, --format <format>", `output: ${INFER_FORMATS.join(" | ")}`, "yaml").option("-o, --out <path>", "write the template here instead of to stdout").option("--force", "overwrite the --out path");
|
|
1974
|
+
withConfigOptions(inferCommand).addHelpText(
|
|
1975
|
+
"after",
|
|
1976
|
+
[
|
|
1977
|
+
"",
|
|
1978
|
+
"Examples:",
|
|
1979
|
+
" manni lint templates infer docs/guides/install.md",
|
|
1980
|
+
" manni lint templates infer docs/guides/install.md --name how-to",
|
|
1981
|
+
" manni lint templates infer page.mdx -f json",
|
|
1982
|
+
" manni lint templates infer page.md -o ./templates.yaml",
|
|
1983
|
+
" manni lint templates infer page.md -o ./templates.yaml --force",
|
|
1984
|
+
" cat page.md | manni lint templates infer - --as markdown",
|
|
1985
|
+
"",
|
|
1986
|
+
"One page, and every rule it writes is exactly one occurrence: a single",
|
|
1987
|
+
"page cannot show what varies. Loosening a heading into a list or a",
|
|
1988
|
+
"pattern, setting `min: 0`, and adding a trailing rule with no heading",
|
|
1989
|
+
"for the sections that may follow are your edits to make."
|
|
1990
|
+
].join("\n")
|
|
1991
|
+
).action(
|
|
1992
|
+
async (page, options, command) => {
|
|
1993
|
+
try {
|
|
1994
|
+
const format = inferFormat(optionValue(command, "format"));
|
|
1995
|
+
const { configPath, noConfig } = configOption(
|
|
1996
|
+
optionValue(command, "config")
|
|
1997
|
+
);
|
|
1998
|
+
const stdinContent = page === STDIN_TOKEN ? await readStdin() : void 0;
|
|
1999
|
+
const result = await runTemplatesInfer({
|
|
2000
|
+
page,
|
|
2001
|
+
format,
|
|
2002
|
+
...options.as === void 0 ? {} : { as: options.as },
|
|
2003
|
+
...options.name === void 0 ? {} : { name: options.name },
|
|
2004
|
+
...options.out === void 0 ? {} : { out: options.out },
|
|
2005
|
+
...options.force === void 0 ? {} : { force: options.force },
|
|
2006
|
+
...configPath === void 0 ? {} : { configPath },
|
|
2007
|
+
...noConfig === void 0 ? {} : { noConfig },
|
|
2008
|
+
...stdinContent === void 0 ? {} : { stdinContent },
|
|
2009
|
+
// The template is the primary output, so with no --out it owns
|
|
2010
|
+
// stdout and the config line goes to stderr beside it. With --out
|
|
2011
|
+
// stdout is free, and the line still belongs on stderr: a reader
|
|
2012
|
+
// piping nothing is not a reason to move a diagnostic.
|
|
2013
|
+
onConfigLoaded: reportConfig(false, process.cwd())
|
|
2014
|
+
});
|
|
2015
|
+
if (result.written === void 0) {
|
|
2016
|
+
process.stdout.write(result.text);
|
|
2017
|
+
return;
|
|
2018
|
+
}
|
|
2019
|
+
process.stderr.write(
|
|
2020
|
+
`Wrote template "${result.name}" to ${result.written}
|
|
2021
|
+
`
|
|
2022
|
+
);
|
|
2023
|
+
} catch (err) {
|
|
2024
|
+
fail(err);
|
|
2025
|
+
}
|
|
2026
|
+
}
|
|
2027
|
+
);
|
|
2028
|
+
withConfigOptions(
|
|
2029
|
+
program.command("tools").description(
|
|
2030
|
+
"List the lint jobs, the tool that performs each, and what it reads"
|
|
2031
|
+
)
|
|
2032
|
+
).option("-f, --format <format>", "output: pretty | json", "pretty").action(async (options, command) => {
|
|
2033
|
+
try {
|
|
2034
|
+
const format = listFormat(options.format);
|
|
2035
|
+
const tools = await runTools(configOption(options.config));
|
|
2036
|
+
const color = resolveColor2(command.parent ?? command);
|
|
2037
|
+
process.stdout.write(`${renderTools(tools, format, { color })}
|
|
2038
|
+
`);
|
|
2039
|
+
} catch (err) {
|
|
2040
|
+
fail(err);
|
|
2041
|
+
}
|
|
2042
|
+
});
|
|
2043
|
+
return program;
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
// src/term/cli.ts
|
|
2047
|
+
import { Command as Command5 } from "commander";
|
|
1750
2048
|
|
|
1751
2049
|
// src/term/commands/check.ts
|
|
1752
2050
|
import { existsSync as existsSync2 } from "node:fs";
|
|
@@ -1996,7 +2294,7 @@ function foldValeSeverity(severity) {
|
|
|
1996
2294
|
}
|
|
1997
2295
|
|
|
1998
2296
|
// src/term/core/check.ts
|
|
1999
|
-
var REFERENCE_FIELDS =
|
|
2297
|
+
var REFERENCE_FIELDS = TERM_RELATION_FIELDS;
|
|
2000
2298
|
function checkTermSet(set, opts = {}) {
|
|
2001
2299
|
const levels = resolveSeverity(opts.severity);
|
|
2002
2300
|
const maxLength = opts.abstractMaxLength ?? DEFAULT_ABSTRACT_MAX_LENGTH;
|
|
@@ -3784,11 +4082,7 @@ function referencesOf(input) {
|
|
|
3784
4082
|
references2.push({ file: input.file, label, ...line === void 0 ? {} : { line } });
|
|
3785
4083
|
}
|
|
3786
4084
|
};
|
|
3787
|
-
add(input.metadata
|
|
3788
|
-
const graph = input.metadata["graph"];
|
|
3789
|
-
if (typeof graph === "object" && graph !== null && !Array.isArray(graph)) {
|
|
3790
|
-
add(graph["concepts"], "/graph/concepts");
|
|
3791
|
-
}
|
|
4085
|
+
for (const path of CONCEPT_FIELDS) add(valueAt(input.metadata, path), fieldPointer(path));
|
|
3792
4086
|
return references2;
|
|
3793
4087
|
}
|
|
3794
4088
|
function read7(input, readers, set) {
|
|
@@ -4701,9 +4995,9 @@ var INTERCHANGE_LABELS = {
|
|
|
4701
4995
|
};
|
|
4702
4996
|
function rendered(writers, format, construct) {
|
|
4703
4997
|
return writers.some((writer) => {
|
|
4704
|
-
const
|
|
4705
|
-
if (
|
|
4706
|
-
return writer.shapes.some((shape) =>
|
|
4998
|
+
const render3 = DOCUMENT_RENDERS[writer.format];
|
|
4999
|
+
if (render3?.input !== format) return false;
|
|
5000
|
+
return writer.shapes.some((shape) => render3.shapes[shape] === construct);
|
|
4707
5001
|
});
|
|
4708
5002
|
}
|
|
4709
5003
|
function listFormats(opts = {}) {
|
|
@@ -4996,7 +5290,7 @@ async function lintTermSet(set, opts = {}) {
|
|
|
4996
5290
|
}
|
|
4997
5291
|
|
|
4998
5292
|
// src/term/commands/lint.ts
|
|
4999
|
-
async function
|
|
5293
|
+
async function runLint2(opts) {
|
|
5000
5294
|
const { cwd, run, set } = await loadTerms(opts);
|
|
5001
5295
|
const valeConfig = valeConfigFor(run);
|
|
5002
5296
|
const findings = await lintTermSet(set, {
|
|
@@ -5018,7 +5312,7 @@ async function runLint(opts) {
|
|
|
5018
5312
|
}
|
|
5019
5313
|
|
|
5020
5314
|
// src/term/commands/list.ts
|
|
5021
|
-
var
|
|
5315
|
+
var LIST_FORMATS2 = ["pretty", "json", "csv"];
|
|
5022
5316
|
async function runList(opts) {
|
|
5023
5317
|
const { set } = await loadTerms(opts);
|
|
5024
5318
|
return { terms: set.terms, set };
|
|
@@ -5142,14 +5436,14 @@ async function runWrite(opts) {
|
|
|
5142
5436
|
const shape = format === "vale" || /[\\/]$/.test(opts.out ?? "") || isDirectory(targetPath) ? "directory" : "file";
|
|
5143
5437
|
const target = { path: targetPath, shape };
|
|
5144
5438
|
const existing = await existingFor(target);
|
|
5145
|
-
let
|
|
5439
|
+
let render3;
|
|
5146
5440
|
try {
|
|
5147
|
-
|
|
5441
|
+
render3 = writer.render(set.terms, target, { existing });
|
|
5148
5442
|
} catch (error) {
|
|
5149
5443
|
if (error instanceof TermError) throw relativized(error, [...existing.keys(), targetPath], cwd);
|
|
5150
5444
|
throw error;
|
|
5151
5445
|
}
|
|
5152
|
-
const changes = await applyChanges(
|
|
5446
|
+
const changes = await applyChanges(render3.files, render3.removals, existing, cwd, !check && !dryRun);
|
|
5153
5447
|
const shown = format === "vale" ? displayPath(join4(targetPath, STYLE2), cwd) : opts.out ?? displayPath(targetPath, cwd);
|
|
5154
5448
|
return {
|
|
5155
5449
|
mode: "render",
|
|
@@ -5158,11 +5452,11 @@ async function runWrite(opts) {
|
|
|
5158
5452
|
target: shown,
|
|
5159
5453
|
terms: set.terms.length,
|
|
5160
5454
|
changes,
|
|
5161
|
-
files:
|
|
5455
|
+
files: render3.files.map((file) => ({ path: displayPath(file.path, cwd), content: file.content })),
|
|
5162
5456
|
// A Vale style holds designations only, by design; its dropped definitions are not news.
|
|
5163
|
-
dropped: format === "vale" ? [] :
|
|
5457
|
+
dropped: format === "vale" ? [] : render3.dropped,
|
|
5164
5458
|
droppedFrom: droppedFrom(format, shape, readers),
|
|
5165
|
-
skipped:
|
|
5459
|
+
skipped: render3.skipped,
|
|
5166
5460
|
check,
|
|
5167
5461
|
dryRun,
|
|
5168
5462
|
...wiring === void 0 ? {} : { wiring }
|
|
@@ -5568,7 +5862,21 @@ function renderFormatsPretty(rows) {
|
|
|
5568
5862
|
).join("\n");
|
|
5569
5863
|
}
|
|
5570
5864
|
|
|
5865
|
+
// src/term/commands/labels.ts
|
|
5866
|
+
async function termLabels(request) {
|
|
5867
|
+
const run = await resolveTermRun({
|
|
5868
|
+
cwd: request.cwd,
|
|
5869
|
+
inputs: [],
|
|
5870
|
+
...request.configPath === void 0 ? {} : { configPath: request.configPath },
|
|
5871
|
+
...request.noConfig === true ? { noConfig: true } : {}
|
|
5872
|
+
});
|
|
5873
|
+
if (run.inputs.length === 0 && run.manifests.length === 0) return [];
|
|
5874
|
+
const set = await loadSet(run, { inputs: [], allowEmpty: true });
|
|
5875
|
+
return set.terms.map((term) => ({ label: term.record.label, id: term.id }));
|
|
5876
|
+
}
|
|
5877
|
+
|
|
5571
5878
|
// src/term/cli.ts
|
|
5879
|
+
registerTermLabelSource(termLabels);
|
|
5572
5880
|
function colorFor2(options) {
|
|
5573
5881
|
return shouldColor({ noColor: !options.color, isTTY: process.stdout.isTTY });
|
|
5574
5882
|
}
|
|
@@ -5615,12 +5923,12 @@ function renderFindings(report, format, options, references2) {
|
|
|
5615
5923
|
if (text2.length > 0 || !OMITTED_WHEN_CLEAN.has(format)) print(text2);
|
|
5616
5924
|
process.exitCode = report.summary.failed > 0 ? 1 : 0;
|
|
5617
5925
|
}
|
|
5618
|
-
function
|
|
5619
|
-
const program = new
|
|
5926
|
+
function buildProgram6() {
|
|
5927
|
+
const program = new Command5();
|
|
5620
5928
|
program.name("term").description("Check, lint and render a docset's terms and the references into them.").version(package_default.version, "-V, --version").showHelpAfterError("(add --help for usage)").exitOverride();
|
|
5621
5929
|
withInputs(
|
|
5622
5930
|
program.command("list").description("List the resolved entries").argument("[paths...]", "files, directories, or globs to read (use - for stdin)")
|
|
5623
|
-
).option("-f, --format <format>", `output: ${
|
|
5931
|
+
).option("-f, --format <format>", `output: ${LIST_FORMATS2.join(" | ")}`, "pretty").addHelpText(
|
|
5624
5932
|
"after",
|
|
5625
5933
|
[
|
|
5626
5934
|
"",
|
|
@@ -5631,7 +5939,7 @@ function buildProgram5() {
|
|
|
5631
5939
|
].join("\n")
|
|
5632
5940
|
).action(async (paths, options) => {
|
|
5633
5941
|
try {
|
|
5634
|
-
const format = formatChoice(options.format,
|
|
5942
|
+
const format = formatChoice(options.format, LIST_FORMATS2);
|
|
5635
5943
|
const { terms } = await runList(await coreOptions(paths, options));
|
|
5636
5944
|
print(format === "json" ? renderListJson(terms) : format === "csv" ? renderListCsv(terms) : renderListPretty(terms));
|
|
5637
5945
|
process.exitCode = 0;
|
|
@@ -5685,7 +5993,7 @@ function buildProgram5() {
|
|
|
5685
5993
|
).action(async (paths, options) => {
|
|
5686
5994
|
try {
|
|
5687
5995
|
const format = formatChoice(options.format, FINDING_FORMATS);
|
|
5688
|
-
const report = await
|
|
5996
|
+
const report = await runLint2(await coreOptions(paths, options));
|
|
5689
5997
|
renderFindings(report, format, options, false);
|
|
5690
5998
|
} catch (err) {
|
|
5691
5999
|
fail(err);
|
|
@@ -5734,12 +6042,12 @@ function buildProgram5() {
|
|
|
5734
6042
|
}
|
|
5735
6043
|
|
|
5736
6044
|
// src/cli.ts
|
|
5737
|
-
function
|
|
6045
|
+
function buildProgram7() {
|
|
5738
6046
|
const meta = buildProgram().name("meta").description(
|
|
5739
6047
|
"Validate, read, query and fill document metadata against JSON Schema"
|
|
5740
6048
|
);
|
|
5741
6049
|
const metaCommands = new Set(meta.commands.map((c) => c.name()));
|
|
5742
|
-
const program = new
|
|
6050
|
+
const program = new Command6();
|
|
5743
6051
|
program.name("manni").description("Tools for documentation that is meant to be checked.").version(package_default.version, "-V, --version").showHelpAfterError("(add --help for usage)").exitOverride().configureOutput({
|
|
5744
6052
|
outputError: (str, write) => {
|
|
5745
6053
|
write(str);
|
|
@@ -5765,15 +6073,20 @@ function buildProgram6() {
|
|
|
5765
6073
|
)
|
|
5766
6074
|
);
|
|
5767
6075
|
program.addCommand(
|
|
5768
|
-
buildProgram5().name("
|
|
6076
|
+
buildProgram5().name("lint").description(
|
|
6077
|
+
"Validate document structure against doctype templates, routed by a page's type"
|
|
6078
|
+
)
|
|
6079
|
+
);
|
|
6080
|
+
program.addCommand(
|
|
6081
|
+
buildProgram6().name("term").description("Check, lint and render a docset's terms and the references into them")
|
|
5769
6082
|
);
|
|
5770
6083
|
program.addCommand(
|
|
5771
6084
|
buildProgram4().name("key").description("Set and rotate the family key that encrypted values are encrypted with.")
|
|
5772
6085
|
);
|
|
5773
6086
|
return program;
|
|
5774
6087
|
}
|
|
5775
|
-
runIfMain(import.meta.url,
|
|
6088
|
+
runIfMain(import.meta.url, buildProgram7);
|
|
5776
6089
|
export {
|
|
5777
|
-
|
|
6090
|
+
buildProgram7 as buildProgram
|
|
5778
6091
|
};
|
|
5779
6092
|
//# sourceMappingURL=cli.js.map
|