@lunora/cli
Version:
The Lunora CLI: init, dev, deploy, codegen, run, reset, and migrate commands
2 lines (1 loc) • 1.03 kB
JavaScript
import{existsSync as a,readFileSync as n,readdirSync as m,statSync as p}from"node:fs";import{join as o}from"@visulima/path";import l from"./parseManifest-x3WsxKHz.mjs";const d=/[\u0000-\u001F\u007F-\u009F]/gu,s=t=>t===void 0?void 0:t.replaceAll(d,""),c=t=>m(t).filter(r=>{const e=o(t,r);return p(e).isDirectory()&&a(o(e,"registry.json"))}),S=t=>{const r=o(t,"index.json");if(a(r)){const e=JSON.parse(n(r,"utf8"));if(Array.isArray(e.items))return e.items.filter(i=>typeof i=="object"&&i!==null&&typeof i.name=="string").map(i=>({description:s(i.description),name:s(i.name)??i.name}))}return c(t).map(e=>{const i=JSON.parse(n(o(t,e,"registry.json"),"utf8"));return{description:s(i.description),name:e}})},g=t=>({items:c(t).map(r=>{const e=l(JSON.parse(n(o(t,r,"registry.json"),"utf8")),r);return{...e.description===void 0?{}:{description:e.description},name:e.name,...e.title===void 0?{}:{title:e.title}}}).toSorted((r,e)=>r.name.localeCompare(e.name))});export{g as buildRegistryIndex,S as collectCatalog,c as listItemDirectories};