@nikovirtala/adr 0.5.2 → 0.5.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/cli.js +3 -3
- package/dist/index.js +3 -3
- package/dist/{init-Bw0PZLnR.js → init-Cjx-E8x1.js} +208 -202
- package/dist/init-Cjx-E8x1.js.map +1 -0
- package/dist/{list-CnMSw8eA.js → list-qsuw1oAL.js} +2 -2
- package/dist/{list-CnMSw8eA.js.map → list-qsuw1oAL.js.map} +1 -1
- package/dist/{search-DDDuzVfg.js → search-DLUlAP11.js} +411 -383
- package/dist/search-DLUlAP11.js.map +1 -0
- package/dist/{server-CRmWjWqD.js → server-WidFQzlx.js} +3 -3
- package/dist/{server-CRmWjWqD.js.map → server-WidFQzlx.js.map} +1 -1
- package/package.json +2 -2
- package/dist/init-Bw0PZLnR.js.map +0 -1
- package/dist/search-DDDuzVfg.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-
|
|
1
|
+
{"version":3,"file":"list-qsuw1oAL.js","names":[],"sources":["../src/templates/list.ts"],"sourcesContent":["import {\n type Finding,\n lintTemplate,\n loadTemplates,\n parseTemplate,\n type Template,\n} from \"@nikovirtala/ledger\";\nimport { adrKind } from \"../kind.js\";\nimport type { DecisionsRead } from \"../log.js\";\nimport { BUILTIN_TEMPLATES } from \"./builtin.js\";\n\n/** `adr_templates` (and phase 4's `adr template list --json`): the templates a proposal can use. */\nexport interface TemplatesJson {\n readonly format: \"adr-templates/v1\";\n readonly root: string;\n /** `[log] default_template`. */\n readonly default: string;\n readonly templates: readonly {\n readonly name: string;\n readonly version: number;\n readonly source: \"repo\" | \"builtin\";\n /** `<root>/templates/<name>.md` for a repo template; `null` for a built-in one. */\n readonly path: string | null;\n readonly sections: readonly {\n readonly id: string;\n readonly heading: string;\n readonly required: boolean;\n readonly guidance: string | null;\n }[];\n }[];\n /** Why a repo template is left out: it doesn't parse or fails the template lint. */\n readonly findings: readonly Finding[];\n readonly notes: readonly string[];\n}\n\nconst lint = (t: Template) =>\n lintTemplate(t, { requireSections: adrKind.def.templates?.requireSections ?? [] });\n\n/**\n * The templates of `<root>/templates` that parse and pass the template lint, and the built-in\n * ones no repo template or file of the same name shadows (`adr new` copies those on first use),\n * sorted by name.\n */\nexport async function listTemplates(read: DecisionsRead): Promise<TemplatesJson> {\n const loaded = await loadTemplates(read.tree, `${read.root}/templates`);\n const findings: Finding[] = [...loaded.findings];\n const listed: { template: Template; source: \"repo\" | \"builtin\" }[] = [];\n for (const t of loaded.templates.values()) {\n const problems = lint(t);\n findings.push(...problems);\n if (problems.length === 0) listed.push({ template: t, source: \"repo\" });\n }\n for (const [name, text] of Object.entries(BUILTIN_TEMPLATES)) {\n // A repo file of that name shadows it even when broken: `adr new` would read the file.\n if (loaded.templates.has(name)) continue;\n if ((await read.tree.read(`${read.root}/templates/${name}.md`)) !== null) continue;\n const parsed = parseTemplate(text);\n if (parsed.ok) listed.push({ template: parsed.template, source: \"builtin\" });\n }\n listed.sort((a, b) => (a.template.name < b.template.name ? -1 : 1));\n return {\n format: \"adr-templates/v1\",\n root: read.root,\n default: read.adr.defaultTemplate,\n templates: listed.map(({ template: t, source }) => ({\n name: t.name,\n version: t.version,\n source,\n path: source === \"repo\" ? t.path : null,\n sections: t.sections.map((s) => ({\n id: s.id,\n heading: s.heading,\n required: s.required,\n guidance: s.guidance,\n })),\n })),\n findings: findings.map((f) => ({ ...f, kind: adrKind.name })),\n notes: read.notes,\n };\n}\n"],"mappings":";;;;AAmCA,MAAM,QAAQ,MACZ,aAAa,GAAG,EAAE,iBAAiB,QAAQ,IAAI,WAAW,mBAAmB,CAAC,EAAE,CAAC;;;;;;AAOnF,eAAsB,cAAc,MAA6C;CAC/E,MAAM,SAAS,MAAM,cAAc,KAAK,MAAM,GAAG,KAAK,KAAK,WAAW;CACtE,MAAM,WAAsB,CAAC,GAAG,OAAO,QAAQ;CAC/C,MAAM,SAA+D,CAAC;CACtE,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