mdat 0.6.11 → 0.6.13
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/bin/cli.js
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{defaultLoaders as
|
|
3
|
-
${JSON.stringify(t,void 0,2)}`)}function
|
|
4
|
-
${JSON.stringify(t,void 0,2)}`)}var ee;async function
|
|
5
|
-
`)},order:3}};import{globby as
|
|
2
|
+
var wt="0.6.13";import{defaultLoaders as Dn}from"cosmiconfig";function Ee(t,e){let n=Dn[".json"],i=n(t,e);return bt(i)}function bt(t,e="",n={}){for(let[i,o]of Object.entries(t)){let r=e?`${e}.${i}`:i;typeof o=="object"&&o!==null&&!Array.isArray(o)?bt(o,r,n):o===null?n[r]="null":n[r]=o.toString()}return n}import _n from"node:fs";import O from"node:path";import{packageUp as In}from"package-up";import{isFileSync as Ct}from"path-type";import jn from"untildify";function Fn(t,e){let n=e===0?1:Math.floor(Math.log10(Math.abs(e))+1);return t.toString().padStart(n,"0")}function Ot(t,e,n,i){let o=[];for(let[r,s]of t.entries()){let a=n&&t.length>1?`-${Fn(r+1,t.length+1)}`:"",d=Un(s,e,n,i,a);o.push(d)}return o}function Un(t,e,n,i,o=""){let r=kt(t),s=e?kt(e):void 0;if(!Ct(r))throw new Error(`Input file not found: "${r}"`);if(s){if(Ct(s))throw new Error(`Output path must be a directory, received a file path: "${s}"`);_n.mkdirSync(s,{recursive:!0})}let a=n?O.basename(n,O.extname(n)):O.basename(r,O.extname(r)),d=`.${i??(n&&O.extname(n)!==""?O.extname(n):O.extname(t)===""?"":O.extname(t))}`,m=`${a}${o}${d}`,c=s??O.dirname(r);return{input:r,name:m,output:c}}function kt(t){return jn(t)}async function X(){return In()}function Q(t){return t==null?[]:Array.isArray(t)?t:[t]}import Pt from"chalk";import{cosmiconfig as Rt}from"cosmiconfig";import{TypeScriptLoader as xt}from"cosmiconfig-typescript-loader";import Vn from"node:fs/promises";import Et from"node:path";import Jn from"plur";import{readPackage as Bn}from"read-pkg";import{deepMergeDefined as Le,log as b,optionsSchema as Hn,rulesSchema as zn}from"remark-mdat";import{z as Te}from"zod";var St=Hn.merge(Te.object({assetsPath:Te.string().optional(),packageFile:Te.string().optional()})).describe("Config Extension");async function E(t){let{additionalConfig:e,additionalRules:n,searchFrom:i}=t??{},o={addMetaComment:!1,assetsPath:"./assets",closingPrefix:"/",keywordPrefix:"",metaCommentIdentifier:"+",packageFile:await X(),rules:{mdat:"Powered by the Markdown Autophagic Template system: [mdat](https://github.com/kitschpatrol/mdat)."}},r=Rt("mdat",{loaders:{".ts":xt({esmResolve:!0})}}),s=await r.search(i);if(s){let{config:a,filepath:d}=s;b.info(`Using config from "${d}"`);let m=vt(a,St);m&&(o=Le(o,m))}if(e!==void 0){let a=Array.isArray(e)?e:[e];for(let d of a){let m;if(typeof d=="string"){let l=await r.load(d);if(l==null)continue;let{config:g,filepath:y}=l;b.info(`Loaded additional config from "${y}"`),m=g}else m=d;if(m===void 0)continue;b.info("Merging configuration object");let c=vt(m,St);c!==void 0&&(o=Le(o,c))}}if(n!==void 0){let a=Array.isArray(n)?n:[n],d=Rt("mdat",{loaders:{".json":Ee,".ts":xt({esmResolve:!0})}});for(let m of a){let c;if(typeof m=="string"){let g;if(Et.basename(m).endsWith("package.json")){let _=await Vn.readFile(m,"utf8");g={config:Ee(m,_),filepath:m}}else g=await d.load(m);if(g==null)continue;let{config:y,filepath:w}=g;b.info(`Loaded additional config from "${w}"`),c=y}else c=m;if(c===void 0)continue;b.info("Merging rules into configuration object");let l=qn(c,zn);l!==void 0&&(o=Le(o,l))}}if(o.rules){let a=Object.keys(o.rules).sort().map(d=>`"${Pt.bold.green(d)}"`);b.info(`Loaded ${Pt.bold(a.length)} mdat comment expansion ${Jn("rule",a.length)}:`);for(let d of a)b.info(` ${d}`)}else b.error("No rules loaded from additional configurations or rules, using default.");return ee=o,o}function qn(t,e){if(e.safeParse(t).success)return{rules:t};b.error(`Rules object has the wrong shape. Ignoring and using default configuration:
|
|
3
|
+
${JSON.stringify(t,void 0,2)}`)}function vt(t,e){if(e.safeParse(t).success)return t;b.error(`Config object has the wrong shape. Ignoring and using default configuration:
|
|
4
|
+
${JSON.stringify(t,void 0,2)}`)}var ee;async function k(){return ee===void 0&&(b.warn("getConfig(): config was undefined"),ee??=await E()),ee}var Ae;async function h(){let{packageFile:t}=await k();if(t===void 0)throw new Error("No packageFile found or set in config");if(Ae??=await Bn({cwd:Et.dirname(t)}),Ae===void 0)throw new Error("No package.json found");return Ae}import{remark as $e}from"remark";import Ne from"remark-gfm";import{mdatCheck as Gn,mdatClean as Lt,mdatExpand as Kn,mdatSplit as Tt}from"remark-mdat";import{read as Wn}from"to-vfile";import{VFile as Li}from"vfile";async function R(t,e,n,i,o,r,s){let a=await e({additionalConfig:r,additionalRules:s});r=a;let d=Q(t),m=Ot(d,o,i,"md"),c=[],l=n(a);for(let{input:g,name:y,output:w}of m){let _=await Wn(g),Z=await l.process(_);Z.dirname=w,Z.basename=y,c.push(Z)}return c}function te(t){return $e().use({settings:{bullet:"-",emphasis:"_"}}).use(Ne).use(()=>async function(n,i){Tt(n,i),Lt(n,i,t),await Kn(n,i,t)})}function ne(t){return $e().use({settings:{bullet:"-",emphasis:"_"}}).use(Ne).use(()=>function(n,i){Tt(n,i),Lt(n,i,t)})}function oe(t){return $e().use({settings:{bullet:"-",emphasis:"_"}}).use(Ne).use(()=>async function(n,i){await Gn(n,i,{...t,paranoid:!1})})}async function At(t,e,n,i,o){return R(t,E,te,e,n,i,o)}async function $t(t,e,n,i,o){return R(t,E,oe,e,n,i,o)}async function Nt(t,e,n,i,o){return R(t,E,ne,e,n,i,o)}import{z as L}from"zod";var ie={badges:{async content(t){let e=L.object({custom:L.record(L.object({image:L.string(),link:L.string()})).optional(),npm:L.array(L.string()).optional()}).optional().parse(t),n=await h(),{name:i}=n,o=[];if(!n.private&&n.publishConfig?.access==="public"&&o.push(`[](https://npmjs.com/package/${i})`),e?.npm!==void 0)for(let s of e.npm)o.push(`[](https://npmjs.com/package/${s})`);let{license:r}=n;if(r!==void 0&&o.push(`[](https://opensource.org/licenses/${r})`),e?.custom!==void 0)for(let[s,{image:a,link:d}]of Object.entries(e.custom))o.push(`[](${d})`);return o.join(`
|
|
5
|
+
`)},order:3}};import{globby as Zn}from"globby";import re from"node:path";import{isFile as Xn}from"path-type";import{readPackage as Qn}from"read-pkg";import{z as Me}from"zod";var se={banner:{async content(t){let e=Me.object({alt:Me.string().optional(),src:Me.string().optional()}).optional().parse(t),{assetsPath:n,packageFile:i}=await k();if(i===void 0)throw new Error("No package.json found");let o=e?.src??await Mt(n)??await Mt();if(o===void 0)throw new Error("Banner image not found at any typical location, consider adding something at ./assets/banner.webp");if(!Dt(o)&&!await Xn(o))throw new Error(`Banner image not found at "${o}"`);let r=e?.alt??`${(await Qn({cwd:re.dirname(i)})).name} banner`;if(r===void 0||r==="undefined banner")throw new Error("Banner image alt text not available");return``},order:2}};async function Mt(t){let{packageFile:e}=await k();if(e===void 0)throw new Error("No package.json found");let n=re.dirname(e),i=t===void 0?[".","assets","media","readme-assets","readme-media","readme","images",".github/assets"]:[t],o=["banner","cover","demo","header","hero","image","logo","overview","readme","screenshot","screenshots","splash"],r=["png","gif","jpg","jpeg","svg","webp"],s=await Zn(i.map(a=>re.join(n,a)),{deep:1,expandDirectories:{extensions:r,files:o}});if(s.length>0)return re.relative(process.cwd(),s[0])}function Dt(t,e=!0){if(typeof t!="string")throw new TypeError("Expected a string");if(t=t.trim(),t.includes(" "))return!1;try{return new URL(t),!0}catch{return e?Dt(`https://${t}`,!1):!1}}function _t(t,e=Number.MAX_SAFE_INTEGER){let n=[],i=eo(t,e);return n.push(to(i)),n.push(no(t,i)),i.hasMultipleSubcommands&&i.canRecurse&&n.push(oo(i.fullCommandName)),i.defaultCommand?.commandName!==void 0&&n.push(io(i)),n.push(ro(t,i)),t.positionals&&!i.commandsOnly&&n.push(De(["Positional Argument","Description","Type","Default"],t.positionals.map(o=>[o.arguments?[o.arguments.map(r=>`\`${r}\``)].join(" "):"",`${o.description??""}${o.required?" _(Required.)_":" _(Optional.)_"}`,o.type?`\`${o.type}\``:"",o.defaultValue?o.defaultValue.includes(" ")?o.defaultValue:`\`${o.defaultValue}\``:""]))),t.commands&&n.push(De(["Command","Argument","Description"],t.commands.map(o=>[`\`${o.commandName??(o.default?"[default]":"")}\``,o.arguments?o.arguments?.map(r=>`\`${r}\``).join(" "):"",`${o.description??""}${o.default?" _(Default command.)_":""}`]))),t.options&&!i.commandsOnly&&n.push(De(["Option","Alias","Argument","Description","Type","Default"],t.options.map(o=>[o.flags?o.flags.map(r=>`\`${r}\``).join(" "):"",o.aliases?o.aliases.map(r=>`\`${r}\``).join(" "):"",o.arguments?o.arguments.map(r=>`\`${r}\``).join(" "):"",o.description??"",o.type?`\`${o.type}\``:"",o.defaultValue?o.defaultValue.includes(" ")?o.defaultValue:`\`${o.defaultValue}\``:""]))),i.canRecurse&&i.hasMultipleSubcommands&&n.push("_See the sections below for more information on each subcommand._"),n.join(`
|
|
6
6
|
|
|
7
|
-
`)}function
|
|
7
|
+
`)}function eo(t,e){let n=t.subcommandName===void 0,i=t.commands?t.commands.length>1:!1,o=e>1,r=t.commands?.find(m=>m.default),s=t.commands?.find(m=>m.commandName===void 0),a=`${t.commandName}${t.subcommandName?` ${t.subcommandName}`:""}`,d=o&&i&&r?.commandName!==void 0;return{canRecurse:o,commandsOnly:d,defaultCommand:r,fullCommandName:a,hasMultipleSubcommands:i,isTopLevel:n,topLevelCommand:s}}function to(t){return`#### ${t.isTopLevel?"Command":"Subcommand"}: \`${t.fullCommandName}\``}function no(t,e){return e.isTopLevel&&e.topLevelCommand?.description?(t.commands=t.commands?.filter(n=>n!==e.topLevelCommand),e.topLevelCommand.description):t.description??""}function oo(t){return`This section lists top-level commands for \`${t}\`.`}function io(t){return`If no command is provided, \`${t.defaultCommand?.parentCommandName} ${t.defaultCommand?.commandName}\` is run by default.`}function ro(t,e){let n=e.topLevelCommand?.arguments?` ${e.topLevelCommand.arguments.join(" ")}`:`${t.arguments?` ${t.arguments.join(" ")}`:""}`;return`Usage:
|
|
8
8
|
|
|
9
9
|
\`\`\`txt
|
|
10
10
|
${e.fullCommandName}${n}
|
|
11
|
-
\`\`\``}function
|
|
12
|
-
`,
|
|
13
|
-
`;for(let
|
|
14
|
-
`;return
|
|
11
|
+
\`\`\``}function De(t,e){let n=so(e);t=t.filter((o,r)=>!n.includes(r)),e=e.map(o=>o.filter((r,s)=>!n.includes(s)));let i="";i+=`| ${t.join(" | ")} |
|
|
12
|
+
`,i+=`| ${t.map(()=>"---").join(" | ")} |
|
|
13
|
+
`;for(let o of e)i+=`| ${o.join(" | ")} |
|
|
14
|
+
`;return i}function so(t){let e=[],n=t[0]?.length||0;for(let i=0;i<n;i++){let o=!0;for(let r of t)if(r[i]!==""){o=!1;break}o&&e.push(i)}return e}import{CstParser as ao,Lexer as P,createToken as f}from"chevrotain";var me=f({name:"flag",pattern:/--[\w-_]+/}),je=f({longer_alt:me,name:"alias",pattern:/-[A-Za-z]/}),It=f({group:P.SKIPPED,name:"comma",pattern:/,/}),jt=f({group:P.SKIPPED,name:"dollar",pattern:/\$/}),ae=f({group:P.SKIPPED,name:"whiteSpace",pattern:/ /}),Ft=f({group:P.SKIPPED,name:"newLine",pattern:/\n/}),Fe=f({name:"word",pattern:/\S+/}),H=f({name:"argument",pattern:/(<\S+>|\[.+])/}),Ue=f({name:"programDescription",pattern:/\w.+(?=\n\n {2}Usage)/}),Ut=f({group:P.SKIPPED,name:"startUsage",pattern:/ {2}Usage\n/,push_mode:"USAGE_MODE"}),Vt=f({group:P.SKIPPED,name:"endUsage",pattern:/\n/,pop_mode:!0}),Ve=f({name:"startOptions",pattern:/ {2}Options\n/,push_mode:"OPTIONS_MODE"}),Je=f({name:"startRow",pattern:/ {4}/,push_mode:"ROW_MODE"}),Be=f({name:"rowDescription",pattern:/\w.+/}),Jt=f({group:P.SKIPPED,name:"endRow",pattern:/\n/,pop_mode:!0}),Bt=f({group:P.SKIPPED,name:"endOptions",pattern:/\n/,pop_mode:!0}),mo=new P({defaultMode:"DEFAULT_MODE",modes:{DEFAULT_MODE:[Ut,Ve,Ue,Ft,ae],OPTIONS_MODE:[Bt,Je],ROW_MODE:[Jt,je,me,It,H,Be,ae],USAGE_MODE:[Vt,jt,H,Fe,ae]}}),co=[me,je,It,jt,ae,Ft,Fe,H,Ue,Ut,Vt,Ve,Je,Be,Jt,Bt],_e=class extends ao{programHelp=this.RULE("programHelp",()=>{this.CONSUME(Ue,{LABEL:"description"}),this.AT_LEAST_ONE(()=>{this.CONSUME(Fe,{LABEL:"commandName"})}),this.MANY(()=>{this.CONSUME(H)}),this.OPTION(()=>{this.SUBRULE(this.optionsSection)})});optionsSection=this.RULE("optionsSection",()=>{this.CONSUME(Ve),this.MANY(()=>{this.SUBRULE(this.sectionRow)})});sectionRow=this.RULE("sectionRow",()=>{this.CONSUME(Je),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(H)},{ALT:()=>this.CONSUME(je)},{ALT:()=>this.CONSUME(me)},{ALT:()=>this.CONSUME(Be,{LABEL:"description"})}])})});constructor(){super(co),this.performSelfAnalysis()}},B=new _e,Ie=class extends B.getBaseCstVisitorConstructor(){constructor(){super(),this.validateVisitor()}programHelp(e){let{command:n,subcommand:i}=de(this.getString(e.commandName));return{arguments:this.getArray(e.argument),commandName:n,description:this.getString(e.description),options:e.optionsSection?this.visit(e.optionsSection):void 0,subcommandName:i}}optionsSection(e){return e.sectionRow.map(n=>this.visit(n))}sectionRow(e){return{aliases:this.getArray(e.alias),arguments:this.getArray(e.argument),description:this.getString(e.description,!0),flags:this.getArray(e.flag)}}getString(e,n=!1){if(e!==void 0)return e.map(i=>n?this.clean(i.image):i.image).join(" ")}getArray(e){if(e!==void 0)return e.map(n=>n.image)}clean(e){return e.replaceAll(/^[\s[]*(default:)?\s*|[\s\]]*$/g,"")}},po=new Ie;function Ht(t){let e=mo.tokenize(t);if(e.errors.length>0)throw new Error(`Errors lexing CLI command: ${JSON.stringify(e.errors,void 0,2)}`);B.input=e.tokens;let n=B.programHelp();if(B.errors.length>0)throw new Error(`Errors parsing CLI command help text: ${JSON.stringify(B.errors,void 0,2)}`);let i;try{i=po.visit(n)}catch(o){if(o instanceof Error)throw new TypeError(`Errors visiting CLI command help text: ${String(o)}`)}if(i===void 0)throw new Error("Could not parse help string");return i}import{CstParser as lo,Lexer as T,createToken as p}from"chevrotain";var Ge=p({name:"flag",pattern:/--[\w-_]+/}),Ke=p({name:"alias",pattern:/-[A-Za-z]/}),zt=p({group:T.SKIPPED,name:"comma",pattern:/,/}),I=p({name:"word",pattern:/\S+/}),q=p({name:"argument",pattern:/<\S+>|\[\S+]/}),We=p({name:"type",pattern:/\[(boolean|string|array)]/}),Ye=p({name:"defaultInfo",pattern:/\[default]/}),Ze=p({name:"required",pattern:/\[required]/}),Xe=p({name:"defaultInfoDescription",pattern:/\[default:\s.+?]/}),Qe=p({name:"choices",pattern:/\[choices:\s.+?]/}),He=p({group:T.SKIPPED,name:"whiteSpace",pattern:/\s/}),qt=p({group:T.SKIPPED,name:"startProgramDescription",pattern:/\n\n/,push_mode:"PROGRAM_DESCRIPTION_MODE"}),et=p({name:"programDescription",pattern:/.+/}),Gt=p({group:T.SKIPPED,name:"endProgramDescription",pattern:/\n\n/,pop_mode:!0}),tt=p({name:"startOptionsSection",pattern:/Options:?\n/,push_mode:"SECTION_MODE"}),nt=p({name:"startPositionalsSection",pattern:/Positionals:\n/,push_mode:"SECTION_MODE"}),ot=p({name:"startCommandsSection",pattern:/Commands:\n/,push_mode:"SECTION_MODE"}),it=p({name:"startRow",pattern:/ {2,}/,push_mode:"ROW_MODE"}),rt=p({name:"rowDescription",pattern:/ {2}\w.+ {2}/}),st=p({name:"rowDescriptionTerminal",pattern:/ {2}\w.+/}),Kt=p({group:T.SKIPPED,name:"endRow",pattern:/\n/,pop_mode:!0}),Wt=p({group:T.SKIPPED,name:"endSection",pattern:/\n+/,pop_mode:!0}),uo=new T({defaultMode:"DEFAULT_MODE",modes:{DEFAULT_MODE:[tt,nt,ot,qt,q,I,He],PROGRAM_DESCRIPTION_MODE:[Gt,et],ROW_MODE:[Kt,zt,We,rt,st,Xe,Ye,Ze,Qe,Ge,Ke,q,I,He],SECTION_MODE:[it,Wt]}}),fo=[Ge,Ke,zt,I,q,We,Ye,Ze,Xe,Qe,He,qt,et,Gt,tt,nt,ot,it,rt,st,Kt,Wt],ze=class extends lo{programHelp=this.RULE("programHelp",()=>{this.AT_LEAST_ONE(()=>{this.CONSUME(I,{LABEL:"commandName"})}),this.MANY1(()=>{this.CONSUME(q)}),this.OPTION(()=>{this.CONSUME(et,{LABEL:"description"})}),this.OPTION1(()=>{this.SUBRULE(this.commandsSection)}),this.OPTION2(()=>{this.SUBRULE(this.positionalsSection)}),this.OPTION3(()=>{this.SUBRULE(this.optionsSection)})});positionalsSection=this.RULE("positionalsSection",()=>{this.CONSUME(nt),this.MANY(()=>{this.SUBRULE(this.sectionRow)})});commandsSection=this.RULE("commandsSection",()=>{this.CONSUME(ot),this.MANY1(()=>{this.SUBRULE1(this.sectionRow)})});optionsSection=this.RULE("optionsSection",()=>{this.CONSUME(tt),this.MANY2(()=>{this.SUBRULE2(this.sectionRow)})});sectionRow=this.RULE("sectionRow",()=>{this.CONSUME(it),this.OPTION(()=>{this.CONSUME(I,{LABEL:"parentCommandName"})}),this.MANY(()=>{this.CONSUME1(I,{LABEL:"commandName"})}),this.MANY1(()=>{this.OR([{ALT:()=>this.CONSUME(q)},{ALT:()=>this.CONSUME(Ke)},{ALT:()=>this.CONSUME(Ge)},{ALT:()=>this.CONSUME(rt,{LABEL:"description"})},{ALT:()=>this.CONSUME(st,{LABEL:"description"})},{ALT:()=>this.CONSUME(We)},{ALT:()=>this.CONSUME(Ze)},{ALT:()=>this.CONSUME(Xe)},{ALT:()=>this.CONSUME(Ye)},{ALT:()=>this.CONSUME(Qe)}])})});constructor(){super(fo),this.performSelfAnalysis()}},z=new ze,qe=class extends z.getBaseCstVisitorConstructor(){constructor(){super(),this.validateVisitor()}programHelp(e){let{command:n,subcommand:i}=de(this.getString(e.commandName));return{arguments:this.getArray(e.argument),commandName:n,commands:e.commandsSection?this.visit(e.commandsSection):void 0,description:this.getString(e.description),options:e.optionsSection?this.visit(e.optionsSection):void 0,positionals:e.positionalsSection?this.visit(e.positionalsSection):void 0,subcommandName:i}}positionalsSection(e){return e.sectionRow.map(n=>this.positionalParentCommandToArguments(this.visit(n)))}commandsSection(e){return e.sectionRow.map(n=>this.visit(n))}optionsSection(e){return e.sectionRow.map(n=>this.visit(n))}sectionRow(e){return{aliases:this.getArray(e.alias),arguments:this.getArray(e.argument),choices:this.splitChoices(this.getString(e.choices)),commandName:this.getString(e.commandName),default:e.defaultInfo?!0:void 0,defaultValue:this.getString(e.defaultInfoDescription,!0),description:this.getString(e.description,!0),flags:this.getArray(e.flag),parentCommandName:this.getString(e.parentCommandName),required:e.required?!0:void 0,type:this.getString(e.type,!0)}}positionalParentCommandToArguments(e){let{arguments:n,parentCommandName:i,...o}=e;return i===void 0?e:{arguments:[i,...n??[]],...o}}getString(e,n=!1){if(e!==void 0)return e.map(i=>n?this.clean(i.image):i.image).join(" ")}getArray(e){if(e!==void 0)return e.map(n=>n.image)}clean(e){return e.replaceAll(/^[\s[]*(default:)?\s*|[\s\]]*$/g,"")}splitChoices(e){if(e!==void 0)return this.clean(e.replaceAll(/^\[choices:\s/g,"")).split(", ")}},go=new qe;function Yt(t){let e=uo.tokenize(t);if(e.errors.length>0)throw new Error(`Errors lexing CLI command: ${JSON.stringify(e.errors,void 0,2)}`);z.input=e.tokens;let n=z.programHelp();if(z.errors.length>0)throw new Error(`Errors parsing CLI command help text: ${JSON.stringify(z.errors,void 0,2)}`);let i;try{i=go.visit(n)}catch(o){if(o instanceof Error)throw new TypeError(`Errors visiting CLI command help text: ${String(o)}`)}if(i===void 0)throw new Error("Could not parse help string");return i}var Zt={meow:Ht,yargs:Yt};function de(t){if(t===void 0)throw new Error('Could not find "commandName" entry in help');let e=t.split(" ");if(e.length===0&&t===void 0)throw new Error('Could not find "commandName" entry in help');if(e.length===1)return{command:e[0],subcommand:void 0};let n=e.at(-1);return{command:e.slice(0,-1).join(" "),subcommand:n}}import{log as at}from"remark-mdat";function Xt(t){for(let[e,n]of Object.entries(Zt)){at.info(`Trying to parse help string with ${e} parser...`);try{return n(t)}catch(i){i instanceof Error&&at.info(`Error in "${e}" parser: ${String(i)}`);continue}}at.error("Could not parse help string with any parser")}import{execaCommand as ho}from"execa";import{log as Qt}from"remark-mdat";async function mt(t,e="--help",n){let i=`${t} ${e}`,o=await bo(i),r=Xt(o);return r===void 0?(Qt.warn("Falling back to basic cli help text output."),wo(o)):yo(t,e,n??Number.MAX_SAFE_INTEGER,r)}async function yo(t,e,n,i){if(n<=0)return Qt.info("Max CLI command help depth reached, stopping recursion"),"";let o=_t(i,n),r=t.split(" ")[0];if(i.commands)for(let s of i.commands){if(!s.parentCommandName||!s.commandName)continue;let a=await mt(`${r} ${s.commandName}`,e,n-1);if(a==="")return o;o+=`
|
|
15
15
|
|
|
16
|
-
${a}`}return
|
|
16
|
+
${a}`}return o}function wo(t){return`\`\`\`txt
|
|
17
17
|
${t}
|
|
18
|
-
\`\`\``}async function
|
|
18
|
+
\`\`\``}async function bo(t){let e;try{let{stderr:n,stdout:i}=await ho(t);e=i,(e===void 0||e==="")&&(e=n)}catch(n){if(n instanceof Error)throw new TypeError(`Error running CLI help command: "${t}"
|
|
19
19
|
${n.message}
|
|
20
20
|
`)}if(e===void 0||e==="")throw new Error(`No result from running CLI help command: "${t}"
|
|
21
|
-
`);return e}import{isExecutable as
|
|
22
|
-
${
|
|
23
|
-
\`\`\``}}};var
|
|
24
|
-
[Issues](${e}) and pull requests are welcome.`},order:15}};var
|
|
25
|
-
[${n}](license.txt) \xA9 ${e.name}`},order:16}};import{getSoleRule as
|
|
21
|
+
`);return e}import{isExecutable as Co}from"is-executable";import ko from"node:path";import{log as Oo}from"remark-mdat";import Po from"which";async function en(t){return t??=await Ro(),So(t)}async function Ro(){let t=await h();if(t?.bin){let e=typeof t.bin=="string"?t.bin:String(Object.values(t.bin).at(0));if(xo(e))return Oo.info(`Inferred <!-- cli-help --> command to run from package.json: ${e}`),e}throw new Error(`Could not infer which command to run for the <!-- cli-help --> rule. Please pass a "cliCommand" option to the expansion comment, e.g. <!-- cli-help {cliCommand: './dist/bin.js'} -->`)}function xo(t){let e=ko.parse(t);return e.root!==""||e.dir!==""}async function So(t){let e=await Po(t,{nothrow:!0})??void 0;if(e===null&&(e=await vo(t)??void 0),e!==void 0&&await Co(e))return e;throw new Error(`The cli-help rule noticed that "${e}" is not executable.`)}async function vo(t){return(await h())?.bin?.[t]??void 0}import{z as ce}from"zod";var pe={"cli-help":{async content(t){let e=ce.object({cliCommand:ce.string().optional(),depth:ce.number().optional(),helpFlag:ce.string().optional()}).optional().parse(t),n=await en(e?.cliCommand);return mt(n,e?.helpFlag,e?.depth)}}};import{getSoleRule as Eo}from"remark-mdat";var tn={cli:Eo(pe)};import Lo from"node:fs/promises";import nn from"node:path";import{z as dt}from"zod";var on={code:{async content(t){let e=dt.object({file:dt.string(),language:dt.string().optional()}).parse(t),n=nn.extname(e.file)??"",i=await Lo.readFile(nn.join(process.cwd(),e.file),"utf8");return`\`\`\`${n}
|
|
22
|
+
${i}
|
|
23
|
+
\`\`\``}}};var le={contributing:{async content(){let e=(await h())?.bugs?.url;if(e===void 0)throw new Error('Could not find "bugs.url" entry in package.json');return`## Contributing
|
|
24
|
+
[Issues](${e}) and pull requests are welcome.`},order:15}};var ue={description:{async content(){let t=await h();if(t.description===void 0)throw new Error('Could not find "description" entry in package.json');return`**${t.description}**`},order:4}};var fe={license:{async content(){let t=await h(),{author:e,license:n}=t;if(e?.name===void 0)throw new Error('Could not find "author.name" entry in package.json');if(n===void 0)throw new Error('Could not find "license" entry in package.json');return`## License
|
|
25
|
+
[${n}](license.txt) \xA9 ${e.name}`},order:16}};import{getSoleRule as rn}from"remark-mdat";var sn={footer:{content:[rn(le),rn(fe)],order:17}};import{getSoleRule as To}from"remark-mdat";var ge={"short-description":To(ue)};import{z as he}from"zod";var ye={title:{applicationOrder:2,async content(t){let{postfix:e,prefix:n,titleCase:i}=he.object({postfix:he.string().optional().default(""),prefix:he.string().optional().default(""),titleCase:he.boolean().optional().default(!1)}).parse(t??{}),{name:o}=await h();return`# ${n}${i?Ao(o):o}${e}`},order:1}};function Ao(t){return t.split(/[ _-]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}import{getSoleRule as we}from"remark-mdat";var an={header:{applicationOrder:2,content:[we(ye),we(se),we(ie),we(ge)],order:1}};import{toc as $o}from"mdast-util-toc";import{remark as No}from"remark";import Mo from"remark-gfm";import{z as x}from"zod";var be={"table-of-contents":{applicationOrder:1,async content(t,e){let n=x.object({depth:x.union([x.literal(1),x.literal(2),x.literal(3),x.literal(4),x.literal(5),x.literal(6)]).optional()}).optional().parse(t),i=$o(e,{heading:null,maxDepth:n?.depth??3,tight:!0}),o="## Table of contents";if(i.map===void 0)throw new Error("Could not generate table of contents");let r={children:i.map.children,type:"root"},s=No().use(Mo).stringify(r).replaceAll(`
|
|
26
26
|
|
|
27
27
|
`,`
|
|
28
|
-
`);return[
|
|
29
|
-
`)},order:6}};import{tldrawToImage as
|
|
30
|
-
<source media="(prefers-color-scheme: dark)" srcset="${C.relative(
|
|
28
|
+
`);return[o,s].join(`
|
|
29
|
+
`)},order:6}};import{tldrawToImage as mn}from"@kitschpatrol/tldraw-cli";import Do from"node:crypto";import j from"node:fs/promises";import C from"node:path";import{isFile as ct}from"path-type";import{z as pt}from"zod";var ln={tldraw:{async content(t){let{alt:e="tldraw diagram",src:n}=pt.object({alt:pt.string().optional(),src:pt.string()}).parse(t),{assetsPath:i}=await k();if(i===void 0)throw new Error("No assets path found");await j.mkdir(i,{recursive:!0});let o=await ct(n)?await cn(n):void 0;if(o!==void 0){let m=C.basename(n,C.extname(n)),c=C.join(i,`${m}-${o}-light.svg`),l=C.join(i,`${m}-${o}-dark.svg`);if(await ct(c)&&await ct(l))return dn(c,l,e)}let[r]=await mn(n,{dark:!1,format:"svg",output:i,transparent:!0});o??=await cn(r);let s=`${pn(r)}-${o}-light.svg`;await j.rename(r,s);let[a]=await mn(n,{dark:!0,format:"svg",output:i,transparent:!0}),d=`${pn(a)}-${o}-dark.svg`;if(await j.rename(a,d),o!==void 0){let m=C.basename(d),c=C.basename(s),l=c.replace(`${o}-light.svg`,""),g=await j.readdir(i);for(let y of g){let w=C.basename(y);w!==m&&w!==c&&w.startsWith(l)&&w.endsWith(".svg")&&await j.rm(C.join(i,w))}}return dn(s,d,e)}}};async function dn(t,e,n){let{packageFile:i}=await k();if(i===void 0)throw new Error("No package file found");let o=C.dirname(i),r=C.relative(o,t);return`<picture>
|
|
30
|
+
<source media="(prefers-color-scheme: dark)" srcset="${C.relative(o,e)}">
|
|
31
31
|
<source media="(prefers-color-scheme: light)" srcset="${r}">
|
|
32
32
|
<img alt="${n}" src="${r}">
|
|
33
|
-
</picture>`}async function
|
|
33
|
+
</picture>`}async function cn(t){let e=await j.readFile(t),n=Do.createHash("sha1");return n.update(e),n.digest("hex").slice(0,8)}function pn(t){return t.replace(/\.[^./]+$/,"")}import{getSoleRule as _o}from"remark-mdat";var un={toc:_o(be)};var fn={...ie,...se,...tn,...pe,...on,...le,...ue,...sn,...an,...fe,...ge,...be,...ye,...ln,...un};async function Ce(t){let e={addMetaComment:!0,rules:fn},{additionalConfig:n=[],...i}=t??{},o=Array.isArray(n)?n:[n],r=await E({additionalConfig:[e,...o],...i});if(r.packageFile===void 0)throw new Error("Package file path is required in `mdat readme` config");return r}import{findUp as Io}from"find-up";import{packageDirectory as jo}from"pkg-dir";import{log as gn}from"remark-mdat";async function lt(){gn.info("Searching for package directory...");let t=await jo()??process.cwd(),e=await Io("readme.md",{stopAt:t,type:"file"});if(e!==void 0)return gn.info(`Found closest readme at "${e}"`),e}async function ke(){let t=await lt();if(t===void 0)throw new Error("No readme found");return t}async function Oe(t,e,n,i,o){return t??=await ke(),R(t,Ce,te,e,n,i,o)}async function hn(t,e,n,i,o){return t??=await ke(),R(t,Ce,oe,e,n,i,o)}async function yn(t,e,n,i,o){return t??=await ke(),R(t,Ce,ne,e,n,i,o)}var wn=`<!-- header -->
|
|
34
34
|
|
|
35
35
|
<!-- table-of-contents -->
|
|
36
36
|
|
|
@@ -75,7 +75,7 @@ _List maintainer(s) for a repository, along with one way of contacting them (e.g
|
|
|
75
75
|
_State anyone or anything that significantly helped with the development of your project. State public contact hyper-links if applicable._
|
|
76
76
|
|
|
77
77
|
<!-- footer -->
|
|
78
|
-
`;var
|
|
78
|
+
`;var bn=`<!-- title -->
|
|
79
79
|
|
|
80
80
|
<!-- banner -->
|
|
81
81
|
|
|
@@ -128,7 +128,7 @@ _State anyone or anything that significantly helped with the development of your
|
|
|
128
128
|
<!-- contributing -->
|
|
129
129
|
|
|
130
130
|
<!-- license -->
|
|
131
|
-
`;var
|
|
131
|
+
`;var Cn=`<!-- header -->
|
|
132
132
|
|
|
133
133
|
## Install
|
|
134
134
|
|
|
@@ -144,7 +144,7 @@ Consider using the <!-- code { src: "path/to/example.ts" } --> comment as well.
|
|
|
144
144
|
\`\`\`
|
|
145
145
|
|
|
146
146
|
<!-- footer -->
|
|
147
|
-
`;var
|
|
147
|
+
`;var kn=`<!-- title -->
|
|
148
148
|
|
|
149
149
|
<!-- short-description -->
|
|
150
150
|
|
|
@@ -166,7 +166,7 @@ Consider using the <!-- code { src: "path/to/example.ts" } --> comment as well.
|
|
|
166
166
|
<!-- contributing -->
|
|
167
167
|
|
|
168
168
|
<!-- license -->
|
|
169
|
-
`;var
|
|
169
|
+
`;var On=`<!-- header -->
|
|
170
170
|
|
|
171
171
|
_Long description goes here._
|
|
172
172
|
|
|
@@ -300,4 +300,4 @@ _State anyone or anything that significantly helped with the development of your
|
|
|
300
300
|
<!-- contributing -->
|
|
301
301
|
|
|
302
302
|
<!-- license -->
|
|
303
|
-
`;var A={"MDAT Readme":{content:{compound:hn,explicit:yn},description:"The house style. An expansive starting point. Prune to your context and taste.",exampleLink:"https://github.com/kitschpatrol/mdat/blob/main/readme.md"},"Standard Readme Basic":{content:{compound:wn,explicit:bn},description:'Includes only the "required" sections from the Standard Readme specification.',exampleLink:"https://github.com/RichardLitt/standard-readme/blob/main/example-readmes/minimal-readme.md"},"Standard Readme Full":{content:{compound:Cn,explicit:Pn},description:"Includes all sections from the Standard Readme specification.",exampleLink:"https://github.com/RichardLitt/standard-readme/blob/main/example-readmes/maximal-readme.md"}};import{confirm as Rn,group as Vo,intro as Bo,note as On,outro as Jo,select as lt}from"@clack/prompts";import k from"chalk";import Ho from"node:fs/promises";import Re from"node:path";import{deepMergeDefined as zo}from"remark-mdat";import{write as qo}from"to-vfile";async function Sn(){let t=await pt(),e=await X();return{packageDirectory:e===void 0?void 0:Re.dirname(Re.resolve(e)),readmePath:t}}async function xn(){let{packageDirectory:t,readmePath:e}=await Sn(),n=Re.resolve(process.cwd());Bo(`Running ${k.bold("mdat readme init")} interactively`);let o=await Vo({overwrite:async()=>e===void 0||await Rn({message:`Found an existing readme at "${k.blue(e)}". Do you want to overwrite it?`,active:"Overwrite",inactive:"Exit"})?!0:(()=>{throw new Error("`mdat readme init` was cancelled to avoid an overwrite - no changes were made")})(),output:async()=>t!==void 0&&t!==n?lt({initialValue:t,message:"There's a root package directory nearby, do you want to create the readme there instead of the current directory?",options:[{label:`Create in the current package root: "${k.blue(t)}"`,value:t},{label:`Create in current working directory: "${k.blue(n)}"`,value:n}]}):n,template:async()=>lt({message:"Which template would you like to use?",options:Ko()}),compound:async()=>lt({message:'Do you want to use "compound comments" where possible, which combine several expansions into a single comment block?',options:[{label:`Yes: Combine things like ${k.green("<!-- title -->")} and ${k.green("<!-- badges -->")} in a single ${k.green("<!-- header -->")} comment.`,value:!0},{label:"No: Use individual MDAT expansion comments for each section.",value:!1}]}),expand:async()=>t===void 0?!1:Rn({initialValue:!0,message:"Do you want to run `mdat readme` now to expand the template with content from your package.json?"})},{onCancel(){throw new Error("`mdat readme init` was cancelled - no changes were made")}}),i=await ut(o);return t===void 0&&On("No package.json was found. Once you've created one, you can run `mdat readme` to expand the template with content from your package.json."),On(`Readme created: "${k.bold.blue(i)}"`),Jo("Done!"),i}async function ut(t){let{packageDirectory:e}=await Sn(),n=zo({compound:!0,output:e??process.cwd(),overwrite:!0,expand:e!==void 0,template:Object.keys(A)[0]},t??{}),o=Go(n.template,n.compound),i=Re.join(n.output,"readme.md");await Ho.writeFile(i,o,"utf8");let[r]=await Pe(i);return await qo(r),i}function Go(t,e){let o=A[t].content[e?"compound":"explicit"];if(o===void 0||o==="")throw new Error(`No template found for "${t}"`);return o}function Ko(){return Object.entries(A).map(([t,e])=>({label:t,hint:e.description,value:t}))}var $={config:{defaultDescription:"Configuration is loaded if found from the usual places, or defaults are used.",description:"Path(s) to files containing MDAT configuration.",string:!0,type:"array"}},G={meta:{alias:"m",description:"Embed an extra comment at the top of the generated Markdown warning editors that certain sections of the document have been generated dynamically.",type:"boolean"}},K={name:{alias:"n",defaultDescription:"Same name as input file. Overwrites the input file.",description:"Output file name.",type:"string"}},F={output:{alias:"o",defaultDescription:"Same directory as input file.",description:"Output file directory.",type:"string"}},N={prefix:{description:"Require a string prefix before all comments to be considered for expansion. Useful if you have a bunch of non-MDAT comments in your Markdown file, or if you're willing to trade some verbosity for safety.",type:"string"}},W={print:{description:"Print the expanded Markdown to stdout instead of saving to a file. Ignores `--output` and `--name` options.",type:"boolean"}},Y={rules:{alias:"r",description:"Path(s) to files containing MDAT comment expansion rules.",string:!0,type:"array"}},E={verbose:{describe:"Enable verbose logging. All verbose logs and prefixed with their log level and are printed to stderr for ease of redirection.",type:"boolean"}},Oe=["files",{array:!0,demandOption:!0,describe:"Markdown file(s) with MDAT placeholder comments.",type:"string"}];var ft={package:{defaultDescription:"The closest package.json file is used by default.",description:"Path to the package.json file to use to populate the readme.",string:!0}},gt={assets:{defaultDescription:"./assets",description:"Path to find and save readme-related assets.",string:!0}},kn={interactive:{alias:"i",default:!0,description:"Run the guided interactive `init` process. Set explicitly to `false` to use default values and skip the prompt.",type:"boolean"}},En={overwrite:{default:!1,defaultDescription:"`false`, if an existing readme is found, don't touch it.",description:"Replace an existing readme file if one is found.",type:"boolean"}},Ln={expand:{alias:"e",default:!0,description:"Automatically run `mdat readme` immediately after creating the readme template.",type:"boolean"}},Tn={template:{alias:"t",choices:Object.keys(A),default:Object.keys(A)[0],description:"Specify a template to use for the new readme.",type:"string"}},vn={compound:{alias:"c",default:!0,description:"Use compound comment version of the template to replace several individual comment placeholders where possible. This combines things like `<!-- title -->`, `<!-- badges -->`, etc. in a single `<!-- header -->` comment. It's less clutter when you're editing, but it's also less explicit. The final readme.md output is identical.",type:"boolean"}},Se=["files",{array:!0,demandOption:!1,describe:"Readme file(s) with MDAT placeholder comments. If not provided, the closest readme.md file is used.",type:"string"}];import ht from"chalk";import M from"pretty-ms";import{getMdatReports as Wo,log as u,reporterMdat as U}from"remark-mdat";import{write as xe}from"to-vfile";import Yo from"yargs";import{hideBin as Zo}from"yargs/helpers";var D=performance.now(),An=Yo(Zo(process.argv));try{await An.scriptName("mdat").usage("$0 [command]","Work with MDAT placeholder comments in any Markdown file.").command(["$0 <files..> [options]","expand <files..> [options]"],"Expand MDAT placeholder comments.",t=>t.positional(...Oe).option($).option(Y).option(F).option(K).option(G).option(N).option(W).option(E),async({config:t,files:e,meta:n,name:o,output:i,prefix:r,print:s,rules:a,verbose:d})=>{u.verbose=d??!1,ke({name:o,output:i,print:s});let m=V(t,{addMetaComment:n,keywordPrefix:r}),c=await Tt(e,o,i,m,a);for(let p of c)s?process.stdout.write(p.toString()):await xe(p);U(c),u.info(`Expanded comments in ${M(performance.now()-D)}.`),process.exitCode=B(c)}).command("check <files..> [options]","Validate a Markdown file containing MDAT placeholder comments.",t=>t.positional(...Oe).option($).option(Y).option(G).option(N).option(E),async({config:t,files:e,meta:n,prefix:o,rules:i,verbose:r})=>{u.verbose=r??!1;let s=V(t,{addMetaComment:n,keywordPrefix:o}),a=await vt(e,void 0,void 0,s,i);U(a),u.info(`Checked comments in ${M(performance.now()-D)}.`),process.exitCode=B(a)}).command("collapse <files..> [options]","Collapse MDAT placeholder comments.",t=>t.positional(...Oe).option($).option(F).option(K).option(N).option(W).option(E),async({config:t,files:e,name:n,output:o,prefix:i,print:r,verbose:s})=>{u.verbose=s??!1,ke({name:n,output:o,print:r});let a=V(t,{keywordPrefix:i}),d=await At(e,void 0,void 0,a);for(let m of d)r?process.stdout.write(m.toString()):await xe(m);U(d),u.info(`Cleaned comments in ${M(performance.now()-D)}.`),process.exitCode=B(d)}).command("readme [command]","Work with MDAT comments in your readme.md.",t=>t.command(["$0 [files..] [options]","expand [files..] [options]"],"Expand MDAT comment placeholders in your readme.md using a collection of helpful built-in expansion rules.",e=>e.positional(...Se).option($).option(Y).option(F).option(K).option(ft).option(gt).option(N).option(G).option(W).option(E),async({assets:e,config:n,files:o,meta:i,name:r,output:s,package:a,prefix:d,print:m,rules:c,verbose:p})=>{u.verbose=p??!1,ke({name:r,output:s,print:m});let g=V(n,{addMetaComment:i,assetsPath:e,keywordPrefix:d,packageFile:a}),y=await Pe(o,r,s,g,c);for(let _ of y)m?process.stdout.write(_.toString()):await xe(_);U(y);let{packageFile:w}=await P();u.info(`Pulled package metadata from: ${ht.bold.blue(w)}`),u.info(`Expanded readme(s) in ${M(performance.now()-D)}.`),process.exitCode=B(y)}).command("check [files..] [options]","Validate MDAT placeholder comments in your readme.md.",e=>e.positional(...Se).option($).option(Y).option(ft).option(gt).option(N).option(G).option(E),async({assets:e,config:n,files:o,meta:i,package:r,prefix:s,rules:a,verbose:d})=>{u.verbose=d??!1;let m=V(n,{addMetaComment:i,assetsPath:e,keywordPrefix:s,packageFile:r}),c=await fn(o,void 0,void 0,m,a);U(c);let{packageFile:p}=await P();u.info(`Pulled package metadata from: ${ht.bold.blue(p)}`),u.info(`Checked readme(s) in ${M(performance.now()-D)}.`),process.exitCode=B(c)}).command("collapse [files..] [options]","Collapse MDAT placeholder comments in your readme.md.",e=>e.positional(...Se).option(F).option(K).option(W).option($).option(N).option(E),async({config:e,files:n,name:o,output:i,prefix:r,print:s,verbose:a})=>{u.verbose=a??!1,ke({name:o,output:i,print:s});let d=V(e,{keywordPrefix:r}),m=await gn(n,void 0,void 0,d);for(let c of m)s?process.stdout.write(c.toString()):await xe(c);U(m),u.info(`Cleaned readme(s) in ${M(performance.now()-D)}.`),process.exitCode=B(m)}).command("init [options]","Interactively create a new readme.md file with sensible default MDAT comment placeholders.",e=>e.option(kn).option(En).option(F).option(Ln).option(Tn).option(vn).option(E),async({compound:e,expand:n,interactive:o,output:i,overwrite:r,template:s,verbose:a})=>{if(u.verbose=a??!1,o)await xn();else{let d=await ut({compound:e,expand:n,output:i,overwrite:r,template:s});u.info(`Created readme at "${ht.blue(d)}" in ${M(performance.now()-D)}.`)}process.exitCode=0}),()=>{u.error("Root MDAT readme command should be unreachable.")}).help().alias("h","help").version().alias("v","version").wrap(process.stdout.isTTY?Math.min(120,An.terminalWidth()):0).fail(!1).parse()}catch(t){t instanceof Error&&u.error(t.message),process.exitCode=1}function ke(t){t.print&&t.output&&u.warn("Ignoring --output option because --print is set"),t.print&&t.name&&u.warn("Ignoring --name option because --print is set")}function V(t,e){return[...Q(t),e]}function B(t){return Wo(t).reduce((o,i)=>o+i.errors.length,0)>0?1:0}
|
|
303
|
+
`;var A={"MDAT Readme":{content:{compound:wn,explicit:bn},description:"The house style. An expansive starting point. Prune to your context and taste.",exampleLink:"https://github.com/kitschpatrol/mdat/blob/main/readme.md"},"Standard Readme Basic":{content:{compound:Cn,explicit:kn},description:'Includes only the "required" sections from the Standard Readme specification.',exampleLink:"https://github.com/RichardLitt/standard-readme/blob/main/example-readmes/minimal-readme.md"},"Standard Readme Full":{content:{compound:On,explicit:Pn},description:"Includes all sections from the Standard Readme specification.",exampleLink:"https://github.com/RichardLitt/standard-readme/blob/main/example-readmes/maximal-readme.md"}};import{confirm as Rn,group as zo,intro as qo,note as xn,outro as Go,select as ut}from"@clack/prompts";import S from"chalk";import Ko from"node:fs/promises";import Pe from"node:path";import{deepMergeDefined as Wo}from"remark-mdat";import{write as Yo}from"to-vfile";async function Sn(){let t=await lt(),e=await X();return{packageDirectory:e===void 0?void 0:Pe.dirname(Pe.resolve(e)),readmePath:t}}async function vn(){let{packageDirectory:t,readmePath:e}=await Sn(),n=Pe.resolve(process.cwd());qo(`Running ${S.bold("mdat readme init")} interactively`);let i=await zo({overwrite:async()=>e===void 0||await Rn({message:`Found an existing readme at "${S.blue(e)}". Do you want to overwrite it?`,active:"Overwrite",inactive:"Exit"})?!0:(()=>{throw new Error("`mdat readme init` was cancelled to avoid an overwrite - no changes were made")})(),output:async()=>t!==void 0&&t!==n?ut({initialValue:t,message:"There's a root package directory nearby, do you want to create the readme there instead of the current directory?",options:[{label:`Create in the current package root: "${S.blue(t)}"`,value:t},{label:`Create in current working directory: "${S.blue(n)}"`,value:n}]}):n,template:async()=>ut({message:"Which template would you like to use?",options:Xo()}),compound:async()=>ut({message:'Do you want to use "compound comments" where possible, which combine several expansions into a single comment block?',options:[{label:`Yes: Combine things like ${S.green("<!-- title -->")} and ${S.green("<!-- badges -->")} in a single ${S.green("<!-- header -->")} comment.`,value:!0},{label:"No: Use individual MDAT expansion comments for each section.",value:!1}]}),expand:async()=>t===void 0?!1:Rn({initialValue:!0,message:"Do you want to run `mdat readme` now to expand the template with content from your package.json?"})},{onCancel(){throw new Error("`mdat readme init` was cancelled - no changes were made")}}),o=await ft(i);return t===void 0&&xn("No package.json was found. Once you've created one, you can run `mdat readme` to expand the template with content from your package.json."),xn(`Readme created: "${S.bold.blue(o)}"`),Go("Done!"),o}async function ft(t){let{packageDirectory:e}=await Sn(),n=Wo({compound:!0,output:e??process.cwd(),overwrite:!0,expand:e!==void 0,template:Object.keys(A)[0]},t??{}),i=Zo(n.template,n.compound),o=Pe.join(n.output,"readme.md");await Ko.writeFile(o,i,"utf8");let[r]=await Oe(o);return await Yo(r),o}function Zo(t,e){let i=A[t].content[e?"compound":"explicit"];if(i===void 0||i==="")throw new Error(`No template found for "${t}"`);return i}function Xo(){return Object.entries(A).map(([t,e])=>({label:t,hint:e.description,value:t}))}var $={config:{defaultDescription:"Configuration is loaded if found from the usual places, or defaults are used.",description:"Path(s) to files containing MDAT configuration.",string:!0,type:"array"}},G={meta:{alias:"m",description:"Embed an extra comment at the top of the generated Markdown warning editors that certain sections of the document have been generated dynamically.",type:"boolean"}},K={name:{alias:"n",defaultDescription:"Same name as input file. Overwrites the input file.",description:"Output file name.",type:"string"}},F={output:{alias:"o",defaultDescription:"Same directory as input file.",description:"Output file directory.",type:"string"}},N={prefix:{description:"Require a string prefix before all comments to be considered for expansion. Useful if you have a bunch of non-MDAT comments in your Markdown file, or if you're willing to trade some verbosity for safety.",type:"string"}},W={print:{description:"Print the expanded Markdown to stdout instead of saving to a file. Ignores `--output` and `--name` options.",type:"boolean"}},Y={rules:{alias:"r",description:"Path(s) to files containing MDAT comment expansion rules.",string:!0,type:"array"}},v={verbose:{describe:"Enable verbose logging. All verbose logs and prefixed with their log level and are printed to stderr for ease of redirection.",type:"boolean"}},Re=["files",{array:!0,demandOption:!0,describe:"Markdown file(s) with MDAT placeholder comments.",type:"string"}];var gt={package:{defaultDescription:"The closest package.json file is used by default.",description:"Path to the package.json file to use to populate the readme.",string:!0}},ht={assets:{defaultDescription:"./assets",description:"Path to find and save readme-related assets.",string:!0}},En={interactive:{alias:"i",default:!0,description:"Run the guided interactive `init` process. Set explicitly to `false` to use default values and skip the prompt.",type:"boolean"}},Ln={overwrite:{default:!1,defaultDescription:"`false`, if an existing readme is found, don't touch it.",description:"Replace an existing readme file if one is found.",type:"boolean"}},Tn={expand:{alias:"e",default:!0,description:"Automatically run `mdat readme` immediately after creating the readme template.",type:"boolean"}},An={template:{alias:"t",choices:Object.keys(A),default:Object.keys(A)[0],description:"Specify a template to use for the new readme.",type:"string"}},$n={compound:{alias:"c",default:!0,description:"Use compound comment version of the template to replace several individual comment placeholders where possible. This combines things like `<!-- title -->`, `<!-- badges -->`, etc. in a single `<!-- header -->` comment. It's less clutter when you're editing, but it's also less explicit. The final readme.md output is identical.",type:"boolean"}},xe=["files",{array:!0,demandOption:!1,describe:"Readme file(s) with MDAT placeholder comments. If not provided, the closest readme.md file is used.",type:"string"}];import yt from"chalk";import M from"pretty-ms";import{getMdatReports as Qo,log as u,reporterMdat as U}from"remark-mdat";import{write as Se}from"to-vfile";import ei from"yargs";import{hideBin as ti}from"yargs/helpers";var D=performance.now(),Nn=ei(ti(process.argv));try{await Nn.scriptName("mdat").usage("$0 [command]","Work with MDAT placeholder comments in any Markdown file.").command(["$0 <files..> [options]","expand <files..> [options]"],"Expand MDAT placeholder comments.",t=>t.positional(...Re).option($).option(Y).option(F).option(K).option(G).option(N).option(W).option(v),async({config:t,files:e,meta:n,name:i,output:o,prefix:r,print:s,rules:a,verbose:d})=>{u.verbose=d??!1,ve({name:i,output:o,print:s});let m=V(t,{addMetaComment:n,keywordPrefix:r}),c=await At(e,i,o,m,a);for(let l of c)s?process.stdout.write(l.toString()):await Se(l);U(c),u.info(`Expanded comments in ${M(performance.now()-D)}.`),process.exitCode=J(c)}).command("check <files..> [options]","Validate a Markdown file containing MDAT placeholder comments.",t=>t.positional(...Re).option($).option(Y).option(G).option(N).option(v),async({config:t,files:e,meta:n,prefix:i,rules:o,verbose:r})=>{u.verbose=r??!1;let s=V(t,{addMetaComment:n,keywordPrefix:i}),a=await $t(e,void 0,void 0,s,o);U(a),u.info(`Checked comments in ${M(performance.now()-D)}.`),process.exitCode=J(a)}).command("collapse <files..> [options]","Collapse MDAT placeholder comments.",t=>t.positional(...Re).option($).option(F).option(K).option(N).option(W).option(v),async({config:t,files:e,name:n,output:i,prefix:o,print:r,verbose:s})=>{u.verbose=s??!1,ve({name:n,output:i,print:r});let a=V(t,{keywordPrefix:o}),d=await Nt(e,void 0,void 0,a);for(let m of d)r?process.stdout.write(m.toString()):await Se(m);U(d),u.info(`Cleaned comments in ${M(performance.now()-D)}.`),process.exitCode=J(d)}).command("readme [command]","Work with MDAT comments in your readme.md.",t=>t.command(["$0 [files..] [options]","expand [files..] [options]"],"Expand MDAT comment placeholders in your readme.md using a collection of helpful built-in expansion rules.",e=>e.positional(...xe).option($).option(Y).option(F).option(K).option(gt).option(ht).option(N).option(G).option(W).option(v),async({assets:e,config:n,files:i,meta:o,name:r,output:s,package:a,prefix:d,print:m,rules:c,verbose:l})=>{u.verbose=l??!1,ve({name:r,output:s,print:m});let g=V(n,{addMetaComment:o,assetsPath:e,keywordPrefix:d,packageFile:a}),y=await Oe(i,r,s,g,c);for(let _ of y)m?process.stdout.write(_.toString()):await Se(_);U(y);let{packageFile:w}=await k();u.info(`Pulled package metadata from: ${yt.bold.blue(w)}`),u.info(`Expanded readme(s) in ${M(performance.now()-D)}.`),process.exitCode=J(y)}).command("check [files..] [options]","Validate MDAT placeholder comments in your readme.md.",e=>e.positional(...xe).option($).option(Y).option(gt).option(ht).option(N).option(G).option(v),async({assets:e,config:n,files:i,meta:o,package:r,prefix:s,rules:a,verbose:d})=>{u.verbose=d??!1;let m=V(n,{addMetaComment:o,assetsPath:e,keywordPrefix:s,packageFile:r}),c=await hn(i,void 0,void 0,m,a);U(c);let{packageFile:l}=await k();u.info(`Pulled package metadata from: ${yt.bold.blue(l)}`),u.info(`Checked readme(s) in ${M(performance.now()-D)}.`),process.exitCode=J(c)}).command("collapse [files..] [options]","Collapse MDAT placeholder comments in your readme.md.",e=>e.positional(...xe).option(F).option(K).option(W).option($).option(N).option(v),async({config:e,files:n,name:i,output:o,prefix:r,print:s,verbose:a})=>{u.verbose=a??!1,ve({name:i,output:o,print:s});let d=V(e,{keywordPrefix:r}),m=await yn(n,void 0,void 0,d);for(let c of m)s?process.stdout.write(c.toString()):await Se(c);U(m),u.info(`Cleaned readme(s) in ${M(performance.now()-D)}.`),process.exitCode=J(m)}).command("init [options]","Interactively create a new readme.md file with sensible default MDAT comment placeholders.",e=>e.option(En).option(Ln).option(F).option(Tn).option(An).option($n).option(v),async({compound:e,expand:n,interactive:i,output:o,overwrite:r,template:s,verbose:a})=>{if(u.verbose=a??!1,i)await vn();else{let d=await ft({compound:e,expand:n,output:o,overwrite:r,template:s});u.info(`Created readme at "${yt.blue(d)}" in ${M(performance.now()-D)}.`)}process.exitCode=0}),()=>{u.error("Root MDAT readme command should be unreachable.")}).help().alias("h","help").version(wt).alias("v","version").wrap(process.stdout.isTTY?Math.min(120,Nn.terminalWidth()):0).fail(!1).parse()}catch(t){t instanceof Error&&u.error(t.message),process.exitCode=1}function ve(t){t.print&&t.output&&u.warn("Ignoring --output option because --print is set"),t.print&&t.name&&u.warn("Ignoring --name option because --print is set")}function V(t,e){return[...Q(t),e]}function J(t){return Qo(t).reduce((i,o)=>i+o.errors.length,0)>0?1:0}
|
package/dist/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import{defaultLoaders as Ut}from"cosmiconfig";function
|
|
2
|
-
${JSON.stringify(t,void 0,2)}`)}function
|
|
3
|
-
${JSON.stringify(t,void 0,2)}`)}var V;async function
|
|
4
|
-
`)},order:3}};import{globby as
|
|
1
|
+
import{defaultLoaders as Ut}from"cosmiconfig";function se(t,e){let n=Ut[".json"],r=n(t,e);return Be(r)}function Be(t,e="",n={}){for(let[r,o]of Object.entries(t)){let i=e?`${e}.${r}`:r;typeof o=="object"&&o!==null&&!Array.isArray(o)?Be(o,i,n):o===null?n[i]="null":n[i]=o.toString()}return n}import It from"node:fs";import P from"node:path";import{packageUp as _t}from"package-up";import{isFileSync as He}from"path-type";import Vt from"untildify";function Jt(t,e){let n=e===0?1:Math.floor(Math.log10(Math.abs(e))+1);return t.toString().padStart(n,"0")}function Ke(t,e,n,r){let o=[];for(let[i,s]of t.entries()){let a=n&&t.length>1?`-${Jt(i+1,t.length+1)}`:"",d=Bt(s,e,n,r,a);o.push(d)}return o}function Bt(t,e,n,r,o=""){let i=ze(t),s=e?ze(e):void 0;if(!He(i))throw new Error(`Input file not found: "${i}"`);if(s){if(He(s))throw new Error(`Output path must be a directory, received a file path: "${s}"`);It.mkdirSync(s,{recursive:!0})}let a=n?P.basename(n,P.extname(n)):P.basename(i,P.extname(i)),d=`.${r??(n&&P.extname(n)!==""?P.extname(n):P.extname(t)===""?"":P.extname(t))}`,m=`${a}${o}${d}`,p=s??P.dirname(i);return{input:i,name:m,output:p}}function ze(t){return Vt(t)}async function Ge(){return _t()}function qe(t){return t==null?[]:Array.isArray(t)?t:[t]}import Ye from"chalk";import{cosmiconfig as We}from"cosmiconfig";import{TypeScriptLoader as Ze}from"cosmiconfig-typescript-loader";import Ht from"node:fs/promises";import et from"node:path";import zt from"plur";import{readPackage as Kt}from"read-pkg";import{deepMergeDefined as _,log as h,optionsSchema as Gt,rulesSchema as qt}from"remark-mdat";import{z as ae}from"zod";var Xe=Gt.merge(ae.object({assetsPath:ae.string().optional(),packageFile:ae.string().optional()})).describe("Config Extension");async function y(t){let{additionalConfig:e,additionalRules:n,searchFrom:r}=t??{},o={addMetaComment:!1,assetsPath:"./assets",closingPrefix:"/",keywordPrefix:"",metaCommentIdentifier:"+",packageFile:await Ge(),rules:{mdat:"Powered by the Markdown Autophagic Template system: [mdat](https://github.com/kitschpatrol/mdat)."}},i=We("mdat",{loaders:{".ts":Ze({esmResolve:!0})}}),s=await i.search(r);if(s){let{config:a,filepath:d}=s;h.info(`Using config from "${d}"`);let m=Qe(a,Xe);m&&(o=_(o,m))}if(e!==void 0){let a=Array.isArray(e)?e:[e];for(let d of a){let m;if(typeof d=="string"){let u=await i.load(d);if(u==null)continue;let{config:g,filepath:L}=u;h.info(`Loaded additional config from "${L}"`),m=g}else m=d;if(m===void 0)continue;h.info("Merging configuration object");let p=Qe(m,Xe);p!==void 0&&(o=_(o,p))}}if(n!==void 0){let a=Array.isArray(n)?n:[n],d=We("mdat",{loaders:{".json":se,".ts":Ze({esmResolve:!0})}});for(let m of a){let p;if(typeof m=="string"){let g;if(et.basename(m).endsWith("package.json")){let ie=await Ht.readFile(m,"utf8");g={config:se(m,ie),filepath:m}}else g=await d.load(m);if(g==null)continue;let{config:L,filepath:w}=g;h.info(`Loaded additional config from "${w}"`),p=L}else p=m;if(p===void 0)continue;h.info("Merging rules into configuration object");let u=Yt(p,qt);u!==void 0&&(o=_(o,u))}}if(o.rules){let a=Object.keys(o.rules).sort().map(d=>`"${Ye.bold.green(d)}"`);h.info(`Loaded ${Ye.bold(a.length)} mdat comment expansion ${zt("rule",a.length)}:`);for(let d of a)h.info(` ${d}`)}else h.error("No rules loaded from additional configurations or rules, using default.");return V=o,o}function Yt(t,e){if(e.safeParse(t).success)return{rules:t};h.error(`Rules object has the wrong shape. Ignoring and using default configuration:
|
|
2
|
+
${JSON.stringify(t,void 0,2)}`)}function Qe(t,e){if(e.safeParse(t).success)return t;h.error(`Config object has the wrong shape. Ignoring and using default configuration:
|
|
3
|
+
${JSON.stringify(t,void 0,2)}`)}var V;async function O(){return V===void 0&&(h.warn("getConfig(): config was undefined"),V??=await y()),V}var me;async function l(){let{packageFile:t}=await O();if(t===void 0)throw new Error("No packageFile found or set in config");if(me??=await Kt({cwd:et.dirname(t)}),me===void 0)throw new Error("No package.json found");return me}function Wt(t,e){return _(t,e)}import{remark as de}from"remark";import ce from"remark-gfm";import{mdatCheck as Zt,mdatClean as tt,mdatExpand as Xt,mdatSplit as nt}from"remark-mdat";import{read as Qt}from"to-vfile";import{VFile as en}from"vfile";async function R(t,e,n,r,o,i,s){let a=await e({additionalConfig:i,additionalRules:s});i=a;let d=qe(t),m=Ke(d,o,r,"md"),p=[],u=n(a);for(let{input:g,name:L,output:w}of m){let ie=await Qt(g),I=await u.process(ie);I.dirname=w,I.basename=L,p.push(I)}return p}async function b(t,e,n,r,o){let i=await e({additionalConfig:r,additionalRules:o});return r=i,n(i).process(new en(t))}function x(t){return de().use({settings:{bullet:"-",emphasis:"_"}}).use(ce).use(()=>async function(n,r){nt(n,r),tt(n,r,t),await Xt(n,r,t)})}function M(t){return de().use({settings:{bullet:"-",emphasis:"_"}}).use(ce).use(()=>function(n,r){nt(n,r),tt(n,r,t)})}function $(t){return de().use({settings:{bullet:"-",emphasis:"_"}}).use(ce).use(()=>async function(n,r){await Zt(n,r,{...t,paranoid:!1})})}async function tn(t,e,n,r,o){return R(t,y,x,e,n,r,o)}async function nn(t,e,n){return b(t,y,x,e,n)}async function on(t,e,n,r,o){return R(t,y,$,e,n,r,o)}async function rn(t,e,n){return b(t,y,$,e,n)}async function sn(t,e,n,r,o){return R(t,y,M,e,n,r,o)}async function an(t,e,n){return b(t,y,M,e,n)}import{z as k}from"zod";var J={badges:{async content(t){let e=k.object({custom:k.record(k.object({image:k.string(),link:k.string()})).optional(),npm:k.array(k.string()).optional()}).optional().parse(t),n=await l(),{name:r}=n,o=[];if(!n.private&&n.publishConfig?.access==="public"&&o.push(`[](https://npmjs.com/package/${r})`),e?.npm!==void 0)for(let s of e.npm)o.push(`[](https://npmjs.com/package/${s})`);let{license:i}=n;if(i!==void 0&&o.push(`[](https://opensource.org/licenses/${i})`),e?.custom!==void 0)for(let[s,{image:a,link:d}]of Object.entries(e.custom))o.push(`[](${d})`);return o.join(`
|
|
4
|
+
`)},order:3}};import{globby as mn}from"globby";import B from"node:path";import{isFile as dn}from"path-type";import{readPackage as cn}from"read-pkg";import{z as pe}from"zod";var H={banner:{async content(t){let e=pe.object({alt:pe.string().optional(),src:pe.string().optional()}).optional().parse(t),{assetsPath:n,packageFile:r}=await O();if(r===void 0)throw new Error("No package.json found");let o=e?.src??await ot(n)??await ot();if(o===void 0)throw new Error("Banner image not found at any typical location, consider adding something at ./assets/banner.webp");if(!rt(o)&&!await dn(o))throw new Error(`Banner image not found at "${o}"`);let i=e?.alt??`${(await cn({cwd:B.dirname(r)})).name} banner`;if(i===void 0||i==="undefined banner")throw new Error("Banner image alt text not available");return``},order:2}};async function ot(t){let{packageFile:e}=await O();if(e===void 0)throw new Error("No package.json found");let n=B.dirname(e),r=t===void 0?[".","assets","media","readme-assets","readme-media","readme","images",".github/assets"]:[t],o=["banner","cover","demo","header","hero","image","logo","overview","readme","screenshot","screenshots","splash"],i=["png","gif","jpg","jpeg","svg","webp"],s=await mn(r.map(a=>B.join(n,a)),{deep:1,expandDirectories:{extensions:i,files:o}});if(s.length>0)return B.relative(process.cwd(),s[0])}function rt(t,e=!0){if(typeof t!="string")throw new TypeError("Expected a string");if(t=t.trim(),t.includes(" "))return!1;try{return new URL(t),!0}catch{return e?rt(`https://${t}`,!1):!1}}function it(t,e=Number.MAX_SAFE_INTEGER){let n=[],r=pn(t,e);return n.push(fn(r)),n.push(un(t,r)),r.hasMultipleSubcommands&&r.canRecurse&&n.push(ln(r.fullCommandName)),r.defaultCommand?.commandName!==void 0&&n.push(gn(r)),n.push(hn(t,r)),t.positionals&&!r.commandsOnly&&n.push(fe(["Positional Argument","Description","Type","Default"],t.positionals.map(o=>[o.arguments?[o.arguments.map(i=>`\`${i}\``)].join(" "):"",`${o.description??""}${o.required?" _(Required.)_":" _(Optional.)_"}`,o.type?`\`${o.type}\``:"",o.defaultValue?o.defaultValue.includes(" ")?o.defaultValue:`\`${o.defaultValue}\``:""]))),t.commands&&n.push(fe(["Command","Argument","Description"],t.commands.map(o=>[`\`${o.commandName??(o.default?"[default]":"")}\``,o.arguments?o.arguments?.map(i=>`\`${i}\``).join(" "):"",`${o.description??""}${o.default?" _(Default command.)_":""}`]))),t.options&&!r.commandsOnly&&n.push(fe(["Option","Alias","Argument","Description","Type","Default"],t.options.map(o=>[o.flags?o.flags.map(i=>`\`${i}\``).join(" "):"",o.aliases?o.aliases.map(i=>`\`${i}\``).join(" "):"",o.arguments?o.arguments.map(i=>`\`${i}\``).join(" "):"",o.description??"",o.type?`\`${o.type}\``:"",o.defaultValue?o.defaultValue.includes(" ")?o.defaultValue:`\`${o.defaultValue}\``:""]))),r.canRecurse&&r.hasMultipleSubcommands&&n.push("_See the sections below for more information on each subcommand._"),n.join(`
|
|
5
5
|
|
|
6
|
-
`)}function
|
|
6
|
+
`)}function pn(t,e){let n=t.subcommandName===void 0,r=t.commands?t.commands.length>1:!1,o=e>1,i=t.commands?.find(m=>m.default),s=t.commands?.find(m=>m.commandName===void 0),a=`${t.commandName}${t.subcommandName?` ${t.subcommandName}`:""}`,d=o&&r&&i?.commandName!==void 0;return{canRecurse:o,commandsOnly:d,defaultCommand:i,fullCommandName:a,hasMultipleSubcommands:r,isTopLevel:n,topLevelCommand:s}}function fn(t){return`#### ${t.isTopLevel?"Command":"Subcommand"}: \`${t.fullCommandName}\``}function un(t,e){return e.isTopLevel&&e.topLevelCommand?.description?(t.commands=t.commands?.filter(n=>n!==e.topLevelCommand),e.topLevelCommand.description):t.description??""}function ln(t){return`This section lists top-level commands for \`${t}\`.`}function gn(t){return`If no command is provided, \`${t.defaultCommand?.parentCommandName} ${t.defaultCommand?.commandName}\` is run by default.`}function hn(t,e){let n=e.topLevelCommand?.arguments?` ${e.topLevelCommand.arguments.join(" ")}`:`${t.arguments?` ${t.arguments.join(" ")}`:""}`;return`Usage:
|
|
7
7
|
|
|
8
8
|
\`\`\`txt
|
|
9
9
|
${e.fullCommandName}${n}
|
|
10
|
-
\`\`\``}function
|
|
11
|
-
`,
|
|
12
|
-
`;for(let
|
|
13
|
-
`;return
|
|
10
|
+
\`\`\``}function fe(t,e){let n=yn(e);t=t.filter((o,i)=>!n.includes(i)),e=e.map(o=>o.filter((i,s)=>!n.includes(s)));let r="";r+=`| ${t.join(" | ")} |
|
|
11
|
+
`,r+=`| ${t.map(()=>"---").join(" | ")} |
|
|
12
|
+
`;for(let o of e)r+=`| ${o.join(" | ")} |
|
|
13
|
+
`;return r}function yn(t){let e=[],n=t[0]?.length||0;for(let r=0;r<n;r++){let o=!0;for(let i of t)if(i[r]!==""){o=!1;break}o&&e.push(r)}return e}import{CstParser as Cn,Lexer as S,createToken as f}from"chevrotain";var K=f({name:"flag",pattern:/--[\w-_]+/}),ge=f({longer_alt:K,name:"alias",pattern:/-[A-Za-z]/}),st=f({group:S.SKIPPED,name:"comma",pattern:/,/}),at=f({group:S.SKIPPED,name:"dollar",pattern:/\$/}),z=f({group:S.SKIPPED,name:"whiteSpace",pattern:/ /}),mt=f({group:S.SKIPPED,name:"newLine",pattern:/\n/}),he=f({name:"word",pattern:/\S+/}),j=f({name:"argument",pattern:/(<\S+>|\[.+])/}),ye=f({name:"programDescription",pattern:/\w.+(?=\n\n {2}Usage)/}),dt=f({group:S.SKIPPED,name:"startUsage",pattern:/ {2}Usage\n/,push_mode:"USAGE_MODE"}),ct=f({group:S.SKIPPED,name:"endUsage",pattern:/\n/,pop_mode:!0}),Ce=f({name:"startOptions",pattern:/ {2}Options\n/,push_mode:"OPTIONS_MODE"}),we=f({name:"startRow",pattern:/ {4}/,push_mode:"ROW_MODE"}),Pe=f({name:"rowDescription",pattern:/\w.+/}),pt=f({group:S.SKIPPED,name:"endRow",pattern:/\n/,pop_mode:!0}),ft=f({group:S.SKIPPED,name:"endOptions",pattern:/\n/,pop_mode:!0}),wn=new S({defaultMode:"DEFAULT_MODE",modes:{DEFAULT_MODE:[dt,Ce,ye,mt,z],OPTIONS_MODE:[ft,we],ROW_MODE:[pt,ge,K,st,j,Pe,z],USAGE_MODE:[ct,at,j,he,z]}}),Pn=[K,ge,st,at,z,mt,he,j,ye,dt,ct,Ce,we,Pe,pt,ft],ue=class extends Cn{programHelp=this.RULE("programHelp",()=>{this.CONSUME(ye,{LABEL:"description"}),this.AT_LEAST_ONE(()=>{this.CONSUME(he,{LABEL:"commandName"})}),this.MANY(()=>{this.CONSUME(j)}),this.OPTION(()=>{this.SUBRULE(this.optionsSection)})});optionsSection=this.RULE("optionsSection",()=>{this.CONSUME(Ce),this.MANY(()=>{this.SUBRULE(this.sectionRow)})});sectionRow=this.RULE("sectionRow",()=>{this.CONSUME(we),this.MANY(()=>{this.OR([{ALT:()=>this.CONSUME(j)},{ALT:()=>this.CONSUME(ge)},{ALT:()=>this.CONSUME(K)},{ALT:()=>this.CONSUME(Pe,{LABEL:"description"})}])})});constructor(){super(Pn),this.performSelfAnalysis()}},F=new ue,le=class extends F.getBaseCstVisitorConstructor(){constructor(){super(),this.validateVisitor()}programHelp(e){let{command:n,subcommand:r}=G(this.getString(e.commandName));return{arguments:this.getArray(e.argument),commandName:n,description:this.getString(e.description),options:e.optionsSection?this.visit(e.optionsSection):void 0,subcommandName:r}}optionsSection(e){return e.sectionRow.map(n=>this.visit(n))}sectionRow(e){return{aliases:this.getArray(e.alias),arguments:this.getArray(e.argument),description:this.getString(e.description,!0),flags:this.getArray(e.flag)}}getString(e,n=!1){if(e!==void 0)return e.map(r=>n?this.clean(r.image):r.image).join(" ")}getArray(e){if(e!==void 0)return e.map(n=>n.image)}clean(e){return e.replaceAll(/^[\s[]*(default:)?\s*|[\s\]]*$/g,"")}},Sn=new le;function ut(t){let e=wn.tokenize(t);if(e.errors.length>0)throw new Error(`Errors lexing CLI command: ${JSON.stringify(e.errors,void 0,2)}`);F.input=e.tokens;let n=F.programHelp();if(F.errors.length>0)throw new Error(`Errors parsing CLI command help text: ${JSON.stringify(F.errors,void 0,2)}`);let r;try{r=Sn.visit(n)}catch(o){if(o instanceof Error)throw new TypeError(`Errors visiting CLI command help text: ${String(o)}`)}if(r===void 0)throw new Error("Could not parse help string");return r}import{CstParser as Rn,Lexer as N,createToken as c}from"chevrotain";var Le=c({name:"flag",pattern:/--[\w-_]+/}),Oe=c({name:"alias",pattern:/-[A-Za-z]/}),lt=c({group:N.SKIPPED,name:"comma",pattern:/,/}),A=c({name:"word",pattern:/\S+/}),U=c({name:"argument",pattern:/<\S+>|\[\S+]/}),be=c({name:"type",pattern:/\[(boolean|string|array)]/}),ke=c({name:"defaultInfo",pattern:/\[default]/}),Ne=c({name:"required",pattern:/\[required]/}),Te=c({name:"defaultInfoDescription",pattern:/\[default:\s.+?]/}),xe=c({name:"choices",pattern:/\[choices:\s.+?]/}),Se=c({group:N.SKIPPED,name:"whiteSpace",pattern:/\s/}),gt=c({group:N.SKIPPED,name:"startProgramDescription",pattern:/\n\n/,push_mode:"PROGRAM_DESCRIPTION_MODE"}),$e=c({name:"programDescription",pattern:/.+/}),ht=c({group:N.SKIPPED,name:"endProgramDescription",pattern:/\n\n/,pop_mode:!0}),Ae=c({name:"startOptionsSection",pattern:/Options:?\n/,push_mode:"SECTION_MODE"}),ve=c({name:"startPositionalsSection",pattern:/Positionals:\n/,push_mode:"SECTION_MODE"}),Me=c({name:"startCommandsSection",pattern:/Commands:\n/,push_mode:"SECTION_MODE"}),Fe=c({name:"startRow",pattern:/ {2,}/,push_mode:"ROW_MODE"}),je=c({name:"rowDescription",pattern:/ {2}\w.+ {2}/}),De=c({name:"rowDescriptionTerminal",pattern:/ {2}\w.+/}),yt=c({group:N.SKIPPED,name:"endRow",pattern:/\n/,pop_mode:!0}),Ct=c({group:N.SKIPPED,name:"endSection",pattern:/\n+/,pop_mode:!0}),En=new N({defaultMode:"DEFAULT_MODE",modes:{DEFAULT_MODE:[Ae,ve,Me,gt,U,A,Se],PROGRAM_DESCRIPTION_MODE:[ht,$e],ROW_MODE:[yt,lt,be,je,De,Te,ke,Ne,xe,Le,Oe,U,A,Se],SECTION_MODE:[Fe,Ct]}}),Ln=[Le,Oe,lt,A,U,be,ke,Ne,Te,xe,Se,gt,$e,ht,Ae,ve,Me,Fe,je,De,yt,Ct],Re=class extends Rn{programHelp=this.RULE("programHelp",()=>{this.AT_LEAST_ONE(()=>{this.CONSUME(A,{LABEL:"commandName"})}),this.MANY1(()=>{this.CONSUME(U)}),this.OPTION(()=>{this.CONSUME($e,{LABEL:"description"})}),this.OPTION1(()=>{this.SUBRULE(this.commandsSection)}),this.OPTION2(()=>{this.SUBRULE(this.positionalsSection)}),this.OPTION3(()=>{this.SUBRULE(this.optionsSection)})});positionalsSection=this.RULE("positionalsSection",()=>{this.CONSUME(ve),this.MANY(()=>{this.SUBRULE(this.sectionRow)})});commandsSection=this.RULE("commandsSection",()=>{this.CONSUME(Me),this.MANY1(()=>{this.SUBRULE1(this.sectionRow)})});optionsSection=this.RULE("optionsSection",()=>{this.CONSUME(Ae),this.MANY2(()=>{this.SUBRULE2(this.sectionRow)})});sectionRow=this.RULE("sectionRow",()=>{this.CONSUME(Fe),this.OPTION(()=>{this.CONSUME(A,{LABEL:"parentCommandName"})}),this.MANY(()=>{this.CONSUME1(A,{LABEL:"commandName"})}),this.MANY1(()=>{this.OR([{ALT:()=>this.CONSUME(U)},{ALT:()=>this.CONSUME(Oe)},{ALT:()=>this.CONSUME(Le)},{ALT:()=>this.CONSUME(je,{LABEL:"description"})},{ALT:()=>this.CONSUME(De,{LABEL:"description"})},{ALT:()=>this.CONSUME(be)},{ALT:()=>this.CONSUME(Ne)},{ALT:()=>this.CONSUME(Te)},{ALT:()=>this.CONSUME(ke)},{ALT:()=>this.CONSUME(xe)}])})});constructor(){super(Ln),this.performSelfAnalysis()}},D=new Re,Ee=class extends D.getBaseCstVisitorConstructor(){constructor(){super(),this.validateVisitor()}programHelp(e){let{command:n,subcommand:r}=G(this.getString(e.commandName));return{arguments:this.getArray(e.argument),commandName:n,commands:e.commandsSection?this.visit(e.commandsSection):void 0,description:this.getString(e.description),options:e.optionsSection?this.visit(e.optionsSection):void 0,positionals:e.positionalsSection?this.visit(e.positionalsSection):void 0,subcommandName:r}}positionalsSection(e){return e.sectionRow.map(n=>this.positionalParentCommandToArguments(this.visit(n)))}commandsSection(e){return e.sectionRow.map(n=>this.visit(n))}optionsSection(e){return e.sectionRow.map(n=>this.visit(n))}sectionRow(e){return{aliases:this.getArray(e.alias),arguments:this.getArray(e.argument),choices:this.splitChoices(this.getString(e.choices)),commandName:this.getString(e.commandName),default:e.defaultInfo?!0:void 0,defaultValue:this.getString(e.defaultInfoDescription,!0),description:this.getString(e.description,!0),flags:this.getArray(e.flag),parentCommandName:this.getString(e.parentCommandName),required:e.required?!0:void 0,type:this.getString(e.type,!0)}}positionalParentCommandToArguments(e){let{arguments:n,parentCommandName:r,...o}=e;return r===void 0?e:{arguments:[r,...n??[]],...o}}getString(e,n=!1){if(e!==void 0)return e.map(r=>n?this.clean(r.image):r.image).join(" ")}getArray(e){if(e!==void 0)return e.map(n=>n.image)}clean(e){return e.replaceAll(/^[\s[]*(default:)?\s*|[\s\]]*$/g,"")}splitChoices(e){if(e!==void 0)return this.clean(e.replaceAll(/^\[choices:\s/g,"")).split(", ")}},On=new Ee;function wt(t){let e=En.tokenize(t);if(e.errors.length>0)throw new Error(`Errors lexing CLI command: ${JSON.stringify(e.errors,void 0,2)}`);D.input=e.tokens;let n=D.programHelp();if(D.errors.length>0)throw new Error(`Errors parsing CLI command help text: ${JSON.stringify(D.errors,void 0,2)}`);let r;try{r=On.visit(n)}catch(o){if(o instanceof Error)throw new TypeError(`Errors visiting CLI command help text: ${String(o)}`)}if(r===void 0)throw new Error("Could not parse help string");return r}var Pt={meow:ut,yargs:wt};function G(t){if(t===void 0)throw new Error('Could not find "commandName" entry in help');let e=t.split(" ");if(e.length===0&&t===void 0)throw new Error('Could not find "commandName" entry in help');if(e.length===1)return{command:e[0],subcommand:void 0};let n=e.at(-1);return{command:e.slice(0,-1).join(" "),subcommand:n}}import{log as Ue}from"remark-mdat";function St(t){for(let[e,n]of Object.entries(Pt)){Ue.info(`Trying to parse help string with ${e} parser...`);try{return n(t)}catch(r){r instanceof Error&&Ue.info(`Error in "${e}" parser: ${String(r)}`);continue}}Ue.error("Could not parse help string with any parser")}import{execaCommand as bn}from"execa";import{log as Rt}from"remark-mdat";async function Ie(t,e="--help",n){let r=`${t} ${e}`,o=await Tn(r),i=St(o);return i===void 0?(Rt.warn("Falling back to basic cli help text output."),Nn(o)):kn(t,e,n??Number.MAX_SAFE_INTEGER,i)}async function kn(t,e,n,r){if(n<=0)return Rt.info("Max CLI command help depth reached, stopping recursion"),"";let o=it(r,n),i=t.split(" ")[0];if(r.commands)for(let s of r.commands){if(!s.parentCommandName||!s.commandName)continue;let a=await Ie(`${i} ${s.commandName}`,e,n-1);if(a==="")return o;o+=`
|
|
14
14
|
|
|
15
|
-
${a}`}return
|
|
15
|
+
${a}`}return o}function Nn(t){return`\`\`\`txt
|
|
16
16
|
${t}
|
|
17
|
-
\`\`\``}async function
|
|
17
|
+
\`\`\``}async function Tn(t){let e;try{let{stderr:n,stdout:r}=await bn(t);e=r,(e===void 0||e==="")&&(e=n)}catch(n){if(n instanceof Error)throw new TypeError(`Error running CLI help command: "${t}"
|
|
18
18
|
${n.message}
|
|
19
19
|
`)}if(e===void 0||e==="")throw new Error(`No result from running CLI help command: "${t}"
|
|
20
|
-
`);return e}import{isExecutable as
|
|
21
|
-
${
|
|
22
|
-
\`\`\``}}};var
|
|
23
|
-
[Issues](${e}) and pull requests are welcome.`},order:15}};var
|
|
24
|
-
[${n}](license.txt) \xA9 ${e.name}`},order:16}};import{getSoleRule as
|
|
20
|
+
`);return e}import{isExecutable as xn}from"is-executable";import $n from"node:path";import{log as An}from"remark-mdat";import vn from"which";async function Et(t){return t??=await Mn(),jn(t)}async function Mn(){let t=await l();if(t?.bin){let e=typeof t.bin=="string"?t.bin:String(Object.values(t.bin).at(0));if(Fn(e))return An.info(`Inferred <!-- cli-help --> command to run from package.json: ${e}`),e}throw new Error(`Could not infer which command to run for the <!-- cli-help --> rule. Please pass a "cliCommand" option to the expansion comment, e.g. <!-- cli-help {cliCommand: './dist/bin.js'} -->`)}function Fn(t){let e=$n.parse(t);return e.root!==""||e.dir!==""}async function jn(t){let e=await vn(t,{nothrow:!0})??void 0;if(e===null&&(e=await Dn(t)??void 0),e!==void 0&&await xn(e))return e;throw new Error(`The cli-help rule noticed that "${e}" is not executable.`)}async function Dn(t){return(await l())?.bin?.[t]??void 0}import{z as q}from"zod";var Y={"cli-help":{async content(t){let e=q.object({cliCommand:q.string().optional(),depth:q.number().optional(),helpFlag:q.string().optional()}).optional().parse(t),n=await Et(e?.cliCommand);return Ie(n,e?.helpFlag,e?.depth)}}};import{getSoleRule as Un}from"remark-mdat";var Lt={cli:Un(Y)};import In from"node:fs/promises";import Ot from"node:path";import{z as _e}from"zod";var bt={code:{async content(t){let e=_e.object({file:_e.string(),language:_e.string().optional()}).parse(t),n=Ot.extname(e.file)??"",r=await In.readFile(Ot.join(process.cwd(),e.file),"utf8");return`\`\`\`${n}
|
|
21
|
+
${r}
|
|
22
|
+
\`\`\``}}};var W={contributing:{async content(){let e=(await l())?.bugs?.url;if(e===void 0)throw new Error('Could not find "bugs.url" entry in package.json');return`## Contributing
|
|
23
|
+
[Issues](${e}) and pull requests are welcome.`},order:15}};var Z={description:{async content(){let t=await l();if(t.description===void 0)throw new Error('Could not find "description" entry in package.json');return`**${t.description}**`},order:4}};var X={license:{async content(){let t=await l(),{author:e,license:n}=t;if(e?.name===void 0)throw new Error('Could not find "author.name" entry in package.json');if(n===void 0)throw new Error('Could not find "license" entry in package.json');return`## License
|
|
24
|
+
[${n}](license.txt) \xA9 ${e.name}`},order:16}};import{getSoleRule as kt}from"remark-mdat";var Nt={footer:{content:[kt(W),kt(X)],order:17}};import{getSoleRule as _n}from"remark-mdat";var Q={"short-description":_n(Z)};import{z as ee}from"zod";var te={title:{applicationOrder:2,async content(t){let{postfix:e,prefix:n,titleCase:r}=ee.object({postfix:ee.string().optional().default(""),prefix:ee.string().optional().default(""),titleCase:ee.boolean().optional().default(!1)}).parse(t??{}),{name:o}=await l();return`# ${n}${r?Vn(o):o}${e}`},order:1}};function Vn(t){return t.split(/[ _-]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}import{getSoleRule as ne}from"remark-mdat";var Tt={header:{applicationOrder:2,content:[ne(te),ne(H),ne(J),ne(Q)],order:1}};import{toc as Jn}from"mdast-util-toc";import{remark as Bn}from"remark";import Hn from"remark-gfm";import{z as E}from"zod";var oe={"table-of-contents":{applicationOrder:1,async content(t,e){let n=E.object({depth:E.union([E.literal(1),E.literal(2),E.literal(3),E.literal(4),E.literal(5),E.literal(6)]).optional()}).optional().parse(t),r=Jn(e,{heading:null,maxDepth:n?.depth??3,tight:!0}),o="## Table of contents";if(r.map===void 0)throw new Error("Could not generate table of contents");let i={children:r.map.children,type:"root"},s=Bn().use(Hn).stringify(i).replaceAll(`
|
|
25
25
|
|
|
26
26
|
`,`
|
|
27
|
-
`);return[
|
|
28
|
-
`)},order:6}};import{tldrawToImage as
|
|
29
|
-
<source media="(prefers-color-scheme: dark)" srcset="${C.relative(
|
|
27
|
+
`);return[o,s].join(`
|
|
28
|
+
`)},order:6}};import{tldrawToImage as xt}from"@kitschpatrol/tldraw-cli";import zn from"node:crypto";import v from"node:fs/promises";import C from"node:path";import{isFile as Ve}from"path-type";import{z as Je}from"zod";var Mt={tldraw:{async content(t){let{alt:e="tldraw diagram",src:n}=Je.object({alt:Je.string().optional(),src:Je.string()}).parse(t),{assetsPath:r}=await O();if(r===void 0)throw new Error("No assets path found");await v.mkdir(r,{recursive:!0});let o=await Ve(n)?await At(n):void 0;if(o!==void 0){let m=C.basename(n,C.extname(n)),p=C.join(r,`${m}-${o}-light.svg`),u=C.join(r,`${m}-${o}-dark.svg`);if(await Ve(p)&&await Ve(u))return $t(p,u,e)}let[i]=await xt(n,{dark:!1,format:"svg",output:r,transparent:!0});o??=await At(i);let s=`${vt(i)}-${o}-light.svg`;await v.rename(i,s);let[a]=await xt(n,{dark:!0,format:"svg",output:r,transparent:!0}),d=`${vt(a)}-${o}-dark.svg`;if(await v.rename(a,d),o!==void 0){let m=C.basename(d),p=C.basename(s),u=p.replace(`${o}-light.svg`,""),g=await v.readdir(r);for(let L of g){let w=C.basename(L);w!==m&&w!==p&&w.startsWith(u)&&w.endsWith(".svg")&&await v.rm(C.join(r,w))}}return $t(s,d,e)}}};async function $t(t,e,n){let{packageFile:r}=await O();if(r===void 0)throw new Error("No package file found");let o=C.dirname(r),i=C.relative(o,t);return`<picture>
|
|
29
|
+
<source media="(prefers-color-scheme: dark)" srcset="${C.relative(o,e)}">
|
|
30
30
|
<source media="(prefers-color-scheme: light)" srcset="${i}">
|
|
31
31
|
<img alt="${n}" src="${i}">
|
|
32
|
-
</picture>`}async function
|
|
32
|
+
</picture>`}async function At(t){let e=await v.readFile(t),n=zn.createHash("sha1");return n.update(e),n.digest("hex").slice(0,8)}function vt(t){return t.replace(/\.[^./]+$/,"")}import{getSoleRule as Kn}from"remark-mdat";var Ft={toc:Kn(oe)};var jt={...J,...H,...Lt,...Y,...bt,...W,...Z,...Nt,...Tt,...X,...Q,...oe,...te,...Mt,...Ft};async function T(t){let e={addMetaComment:!0,rules:jt},{additionalConfig:n=[],...r}=t??{},o=Array.isArray(n)?n:[n],i=await y({additionalConfig:[e,...o],...r});if(i.packageFile===void 0)throw new Error("Package file path is required in `mdat readme` config");return i}import{findUp as Gn}from"find-up";import{packageDirectory as qn}from"pkg-dir";import{log as Dt}from"remark-mdat";async function Yn(){Dt.info("Searching for package directory...");let t=await qn()??process.cwd(),e=await Gn("readme.md",{stopAt:t,type:"file"});if(e!==void 0)return Dt.info(`Found closest readme at "${e}"`),e}async function re(){let t=await Yn();if(t===void 0)throw new Error("No readme found");return t}async function Wn(t,e,n,r,o){return t??=await re(),R(t,T,x,e,n,r,o)}async function Zn(t,e,n){return b(t,T,x,e,n)}async function Xn(t,e,n,r,o){return t??=await re(),R(t,T,$,e,n,r,o)}async function Qn(t,e,n){return b(t,T,$,e,n)}async function eo(t,e,n,r,o){return t??=await re(),R(t,T,M,e,n,r,o)}export{on as checkFiles,Xn as checkReadmeFiles,Qn as checkReadmeString,rn as checkString,sn as collapseFiles,eo as collapseReadmeFiles,an as collapseString,tn as expandFiles,Wn as expandReadmeFiles,Zn as expandReadmeString,nn as expandString,y as loadConfig,T as loadConfigReadme,Wt as mergeConfigs};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
title: {
|
|
3
|
-
applicationOrder: number;
|
|
4
|
-
content(options?: import("type-fest").JsonValue | undefined): Promise<string>;
|
|
5
|
-
order: number;
|
|
6
|
-
};
|
|
7
2
|
toc: {
|
|
8
3
|
applicationOrder: number;
|
|
9
4
|
content(options: import("type-fest").JsonValue, tree: import("mdast").Root): Promise<string>;
|
|
@@ -12,6 +7,11 @@ declare const _default: {
|
|
|
12
7
|
tldraw: {
|
|
13
8
|
content(options?: import("type-fest").JsonValue | undefined): Promise<string>;
|
|
14
9
|
};
|
|
10
|
+
title: {
|
|
11
|
+
applicationOrder: number;
|
|
12
|
+
content(options?: import("type-fest").JsonValue | undefined): Promise<string>;
|
|
13
|
+
order: number;
|
|
14
|
+
};
|
|
15
15
|
'table-of-contents': {
|
|
16
16
|
applicationOrder: number;
|
|
17
17
|
content(options: import("type-fest").JsonValue, tree: import("mdast").Root): Promise<string>;
|
|
@@ -54,6 +54,9 @@ declare const _default: {
|
|
|
54
54
|
'cli-help': {
|
|
55
55
|
content(options?: import("type-fest").JsonValue | undefined): Promise<string>;
|
|
56
56
|
};
|
|
57
|
+
cli: {
|
|
58
|
+
content(options?: import("type-fest").JsonValue | undefined): Promise<string>;
|
|
59
|
+
};
|
|
57
60
|
banner: {
|
|
58
61
|
content(options?: import("type-fest").JsonValue | undefined): Promise<string>;
|
|
59
62
|
order: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mdat",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI tool and library implementing the Markdown Autophagic Template (MDAT) system. MDAT lets you use comments as dynamic content templates in Markdown files, making it easy to generate and update readme boilerplate.",
|
|
6
6
|
"repository": {
|
|
@@ -42,8 +42,11 @@
|
|
|
42
42
|
"cli"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
+
"@types/node": "^20.14.1",
|
|
46
|
+
"@types/which": "^3.0.4",
|
|
47
|
+
"@types/yargs": "^17.0.32",
|
|
45
48
|
"@clack/prompts": "^0.7.0",
|
|
46
|
-
"@kitschpatrol/tldraw-cli": "^4.5.
|
|
49
|
+
"@kitschpatrol/tldraw-cli": "^4.5.4",
|
|
47
50
|
"@types/mdast": "^4.0.4",
|
|
48
51
|
"@types/unist": "^3.0.2",
|
|
49
52
|
"chalk": "^5.3.0",
|
|
@@ -54,7 +57,7 @@
|
|
|
54
57
|
"find-up": "^7.0.0",
|
|
55
58
|
"globby": "^14.0.1",
|
|
56
59
|
"is-executable": "^2.0.1",
|
|
57
|
-
"mdast-util-toc": "^7.0
|
|
60
|
+
"mdast-util-toc": "^7.1.0",
|
|
58
61
|
"nanoid": "^5.0.7",
|
|
59
62
|
"package-up": "^5.0.0",
|
|
60
63
|
"path-type": "^5.0.0",
|
|
@@ -65,19 +68,16 @@
|
|
|
65
68
|
"remark": "^15.0.1",
|
|
66
69
|
"remark-gfm": "^4.0.0",
|
|
67
70
|
"to-vfile": "^8.0.0",
|
|
68
|
-
"type-fest": "^4.
|
|
71
|
+
"type-fest": "^4.19.0",
|
|
69
72
|
"untildify": "^5.0.0",
|
|
70
73
|
"vfile": "^6.0.1",
|
|
71
74
|
"which": "^4.0.0",
|
|
72
75
|
"yargs": "^17.7.2",
|
|
73
76
|
"zod": "^3.23.8",
|
|
74
|
-
"remark-mdat": "0.6.
|
|
77
|
+
"remark-mdat": "0.6.13"
|
|
75
78
|
},
|
|
76
79
|
"devDependencies": {
|
|
77
|
-
"
|
|
78
|
-
"@types/which": "^3.0.3",
|
|
79
|
-
"@types/yargs": "^17.0.32",
|
|
80
|
-
"tsup": "^8.0.2",
|
|
80
|
+
"tsup": "^8.1.0",
|
|
81
81
|
"typescript": "^5.4.5",
|
|
82
82
|
"vitest": "^1.6.0"
|
|
83
83
|
},
|
package/readme.md
CHANGED
|
@@ -701,6 +701,8 @@ See the [Examples section](../remark-mdat/readme.md#examples) of the `remark-mda
|
|
|
701
701
|
|
|
702
702
|
([Parsing help output](https://github.com/kitschpatrol/mdat/tree/main/packages/mdat/src/lib/readme/rules/cli-help/utilities/parsers) is a bit tricky. The [jc](https://github.com/kellyjonbrazil/jc) project is a heroic collection of output parsers, but does not currently implement help output parsing. It might be interesting to try to contribute mdat's help parsing implementations to jc.)
|
|
703
703
|
|
|
704
|
+
This rule is also aliased under the `<!-- cli -->` keyword.
|
|
705
|
+
|
|
704
706
|
- ###### `<!-- tldraw -->`
|
|
705
707
|
|
|
706
708
|
Allows embedding [tldraw](https://www.tldraw.com) files in your readme. Accepts either a path to a local `.tldr` file, or remote tldraw URLs.
|