@redocly/realm 0.130.0-custom.23 → 0.130.0-custom.24
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.
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{writeFileSync as
|
|
2
|
-
Circular dependency chain: ${
|
|
3
|
-
`);for(const t of
|
|
1
|
+
import{writeFileSync as ot}from"node:fs";import*as u from"path";import{withoutHash as at}from"@redocly/theme/core/utils";import{DEFAULT_LOCALE_PLACEHOLDER as _,SIDEBAR_PREFIX as rt,CONFIG_FILE_NAME as K}from"../../../constants/common.js";import{CATALOG_OUTPUT_FILE_NAME as it}from"../../constants/common.js";import{findDeepFirst as B}from"../../../utils/tree/find-deep-first.js";import{isDefined as X}from"../../../utils/guards/is-defined.js";import{partition as st}from"../../../utils/array/partition.js";import{collectPropValueDeep as x}from"../../../utils/tree/collect-prop-value-deep.js";import{envConfig as nt}from"../../config/env-config.js";import{isLocalLink as lt}from"../../../utils/path/is-local-link.js";import{normalizeRouteSlug as Y}from"../../../utils/path/normalize-route-slug.js";import{slash as ct}from"../../../utils/path/slash.js";import{parsePathVersions as ft}from"../../../utils/path/parse-path-versions.js";import{reporter as A}from"../../tools/notifiers/reporter.js";import{logger as v}from"../../tools/notifiers/logger.js";import{sha1 as dt}from"../../utils/crypto/sha1.js";import{collectItemsLinkedToSidebars as ut,resolveItems as Z}from"../nav-utils.js";import{getExcludedFromLinkCheckerPatterns as gt,getSidebarReferences as mt,hasCircularDependency as pt}from"./utils.js";import{getLocaleFromRelativePath as St}from"../../fs/utils/get-locale-from-relative-path.js";import{isSystemRouteSlug as ht}from"../../utils/system-routes.js";import{ENTITIES_MAP_GLOBAL_DATA_KEY as yt}from"../../constants/plugins/catalog-entities.js";import{telemetryTraceStep as bt}from"../../../cli/telemetry/helpers/trace-step.js";import{OPENAPI_CUSTOM_FIELDS_SERVER_PROPS_GETTER_ID as J}from"../../constants/plugins/openapi-docs.js";const It=180,Pt=170,Ft=10;async function Yt({contentDir:c}){return{id:"sidebars",async afterRoutesCreated(o,f){v.info("Calculating sidebars..."),await bt("build.plugin.sidebars",async()=>{const{cache:y,fs:s}=f,P=o.getConfig(),C=new Map,D=new Set,M=[_,...s.localeFolders],G=o.getGlobalData()[yt]||{},U={};let T=s.scan(/sidebars.yaml$/).map(({relativePath:t})=>t).filter(t=>!Dt(P.ignore??[],t)&&t);const $=await mt(f,c,T),Q=st(T.filter(t=>!$.has(t)),t=>ft(t)?.versionFolderPath||t),O=gt(P),tt=await ut(P?.navbar,o,f,{navFile:K,excludedFromLinkCheckerPatterns:O});let E;const N=pt($);N&&Array.isArray(N)&&await A.panicOnBuildContentError(`Sidebar references have circular dependency. Please check your sidebar files.
|
|
2
|
+
Circular dependency chain: ${N.reverse().join(" -> ")}
|
|
3
|
+
`);for(const t of Q){const g=(await Promise.all(t.map(async i=>{const l=(await y.load(i,"yaml")).data;if(!Array.isArray(l)){await A.panicOnBuildContentErrorForRealFile('Invalid sidebar contents at %rp, items should be an array, got "%s"',i,s,i,typeof l);return}return{items:l,sidebarRelativePath:i,locale:St(i)}}))).filter(X),r=(await w(g))?.firstLink;E||(E=r)}const j=Object.entries(P?.catalogClassic??{});for(const t of M){for(const[a,m]of j)await W(a,m,t);const g={},r=new Set,i=o.getAllRoutesForLocale(t);for(const a of i)if(H(a)&&a.fsPath&&!r.has(a.fsPath)){r.add(a.fsPath);let n=u.posix.dirname(a.fsPath);const d=u.parse(n).root;do g[n]=(g[n]||0)+1,n=u.dirname(n);while(n&&n!="."&&d!=n)}const l=v.startTiming("Creating automatic sidebars...");for(const a of i){if(C.has(a.slug))continue;const m=H(a),n=u.dirname(a.fsPath),d=g[n]===1,p=Et(a.baseSlug||a.slug);m&&d?await w([{items:[{directory:n}],sidebarRelativePath:"sidebar.yaml_"+p,locale:t}]):a.getSidebar!==void 0&&await w([{items:[{page:a.fsPath}],sidebarRelativePath:"sidebar.yaml_"+p,locale:t}])}v.infoTime(l,"Creating automatic sidebars...");for(const[a,m]of j)await W(a,m,t,!0)}if(T.length===0)for(const t of M){v.verbose("Creating default sidebar");const g=t===_,r=`sidebars.yaml${g?"":"_"+t}`,i=g?"":`${s.localizationFolder}/${t}`,l=(await w([{items:[{directory:`./${i}`}],sidebarRelativePath:r,locale:t,ignoredRoutes:D}]))?.firstLink;E||(E=l)}if(!o.getRouteBySlug("/")&&!o.getConfig().redirects?.["/"]){const g=o.getAllRoutes().find(i=>!ht(i.slug)),r=E?E.link:g?.baseSlug??null;if(r){const i=at(r);o.addRedirect("/",{to:i,type:302}),v.info("Creating default redirect for index page => %s",i)}}const z=nt.REDOCLY_METADATA_OUTPUT_FOLDER;z&&(v.info("Writing catalog data..."),ot(u.join(z,it),JSON.stringify(U)));function H(t){return D.has(t.slug)||G[t.fsPath]}async function w(t){if(t.length===0)return;const r=(await Promise.all(t.map(async({items:d,locale:p,sidebarRelativePath:S,ignoredRoutes:L})=>{const e=await Z(d,u.dirname(u.join(c,S)),o,f,{locale:p,ignoredRoutes:L,navFile:S,excludedFromLinkCheckerPatterns:O});if(!e){await A.panicOnBuild("Failed to resolve sidebar configuration. Make sure %rp is valid",S);return}return e}))).flat().filter(X),i=x(r,"routeSlug"),l=t[0].sidebarRelativePath,a=q(l),m=new Set;for(const d of i){const p=o.getRouteBySlug(d)?.fsPath??"",S=G[p];S&&(Array.from(m).find(e=>e.key===S.key&&e.version===S.version)||m.add(S)),o.addRouteSharedData(d,"sidebar",a),C.set(Y(d),r)}const n=m.size===1?Array.from(m)[0]:void 0;return await o.createSharedData(a,{relatedNavbarItem:tt?.get(l),items:r,catalogEntity:n?{key:n.key,version:n.version}:void 0}),{firstLink:B(r,d=>!!d.link),resolved:r}}async function W(t,g,r,i=!1){const l=structuredClone(g);r&&r!==_&&l.items.forEach(e=>{e.directory=u.posix.join(s.localizationFolder||"",r,e.directory||"")});let a=await Z(l.items,c,o,f,{groupCustomSidebars:!0,locale:r,navFile:K,excludedFromLinkCheckerPatterns:O});if(!a){await A.panicOnBuild(`Failed to resolve catalog configuration. Make sure catalog ${t} has valid config`);return}const m=r===_?"":"/"+r.toLowerCase(),n=r===_?"":`-${r}`,d=Y(u.posix.join(m,l.slug));if(i)for(const e of a){const h=e.items?B(e.items,I=>!!I.routeSlug):e.metadata?.type==="catalog-item"?e:void 0;if(!h?.routeSlug)continue;const b=C.get(h.routeSlug);if(!b)continue;const R=o.getRouteBySlug(h.routeSlug);R&&!R.serverPropsGetterIds?.includes(J)&&(R.serverPropsGetterIds=[...R.serverPropsGetterIds||[],J]);const k=x(b,"routeSlug"),F="current-catalog-info-"+e.routeSlug+n,et={catalog:{label:l.title,titleTranslationKey:l.titleTranslationKey,link:d,icon:l?.icon},item:{label:e.metadata?.title,link:e.link,icon:e.icon}};await o.createSharedData(F,et);for(const I of k)o.addRouteSharedData(I,"current-catalog-info",F),D.add(I);const V=B(b,I=>!!I.link&&!I.external&<(I.link)&&(!e.version||I.version===e.version));V&&(e.sidebar=[{...V,items:void 0}])}const p={},S=new Set;for(const e of a){if(!(e.routeSlug||e.sidebar?.[0]?.routeSlug)||!e.fsPath||S.has(e.fsPath))continue;S.add(e.fsPath);const b=u.dirname(e.fsPath);p[b]=(p[b]||0)+1}if(i){const e=await o.createSharedData("catalog-"+t+n,a.flatMap(h=>{const b=u.dirname(h.fsPath??""),R=p[b]===1,k=F=>({...F,fsPath:R?b:F.fsPath??""});return h.type==="group"&&h.items?.every(F=>F.type==="group")?(h.items||[]).map(k):k(h)}));o.addRouteSharedData(d,"catalog",e),Ct(r,a,U,p)}const L=x(a,"routeSlug");for(const e of L)D.add(e)}})}}}function Ct(c,o,f,y){if(c===_)for(const s of o){const P=s.routeSlug||s.sidebar?.[0]?.routeSlug;if(!P||!s.fsPath)continue;const C=u.dirname(s.fsPath),D=y[C]===1;f[P]={link:s.link,rootFileFsPath:s.fsPath,fsPath:D?C:s.fsPath,metadata:s.metadata||{},title:s.metadata?.title||s.label||"Untitled",version:s.version||"latest"}}}function q(c){return rt+ct(c)}async function Zt(c,o,f){const y=u.posix.join(u.dirname(c),o);return await f.exists(y)?q(y):(await A.panicOnBuildContentErrorForRealFile("File %rp: Failed to create relative path for sidebars.yaml using %s",c,f,c,o),null)}function Dt(c,o){const f=/\/?([a-zA-Z0-9-_]+\/)*sidebars?(-[a-zA-Z0-9-_]+)?\.yaml/;return c.filter(s=>f.test(s)).includes(o)}function Et(c){const o=c.replaceAll("/","_");if(o.length>It){const f=o.slice(0,Pt),y=dt(c).slice(0,Ft).replaceAll("/","_");return f+y}else return o}export{Dt as isSidebarIgnored,Zt as resolveSidebarId,Yt as sidebarsPlugin};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redocly/realm",
|
|
3
|
-
"version": "0.130.0-custom.
|
|
3
|
+
"version": "0.130.0-custom.24",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -92,13 +92,13 @@
|
|
|
92
92
|
"yaml-ast-parser": "0.0.43",
|
|
93
93
|
"zod": "^3.25.76",
|
|
94
94
|
"@redocly/config": "0.43.0-custom.1",
|
|
95
|
-
"@redocly/
|
|
96
|
-
"@redocly/asyncapi-docs": "1.7.0-custom.2",
|
|
95
|
+
"@redocly/openapi-docs": "3.18.0-custom.1",
|
|
97
96
|
"@redocly/portal-plugin-mock-server": "0.16.0-next.4",
|
|
98
|
-
"@redocly/
|
|
97
|
+
"@redocly/asyncapi-docs": "1.7.0-custom.2",
|
|
99
98
|
"@redocly/portal-legacy-ui": "0.14.0-next.0",
|
|
100
|
-
"@redocly/
|
|
101
|
-
"@redocly/
|
|
99
|
+
"@redocly/graphql-docs": "1.7.0-custom.2",
|
|
100
|
+
"@redocly/realm-asyncapi-sdk": "0.9.0-next.1",
|
|
101
|
+
"@redocly/theme": "0.62.0-custom.2"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
104
|
"react": "^19.2.4",
|