UNPKG

@lunora/cli

Version:

The Lunora CLI: init, dev, deploy, codegen, migrate, seed, doctor, insights, logs, registry, and the rest of the project commands

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