UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 1.39 kB
const e=e=>(typeof e==`object`||typeof e==`function`)&&e!==null&&`then`in e,t=e=>{if(!e||typeof e!=`object`&&typeof e!=`function`)return!1;let t=e;return typeof e==`function`&&t.__lucidDatabaseAdapterCreator!==!0?!1:typeof t.adapter==`string`&&typeof t.resolve==`function`},n=()=>({custom:[]}),r=async(e,t)=>e?typeof e==`function`?e(t):e:[],i=e=>`custom`in e,a=e=>{if(e.customArtifactTypes?.length)for(let t of e.artifacts)i(t)&&e.customArtifactTypes.includes(t.type)&&e.target.custom.push(t)},o=async n=>{let i=e(n.db)?await n.db:n.db;t(i)&&a({target:n.target,artifacts:await r(i.hooks?.runtime,n.env),customArtifactTypes:n.customArtifactTypes})},s=async e=>{for(let t of e.plugins){if(!t.hooks?.runtime)continue;let n=await t.hooks.runtime({phase:`prepare`,env:e.env,definition:e.definition,paths:e.paths});if(n.error)throw Error(`Runtime prepare hook failed for the ${t.key} plugin.`);a({target:e.target,artifacts:n.data?.artifacts??[],customArtifactTypes:e.customArtifactTypes})}},c=async e=>{let t=n();return e.customArtifactTypes?.length?(await o({db:e.db,env:e.env,target:t,customArtifactTypes:e.customArtifactTypes}),await s({plugins:e.plugins,env:e.env,definition:e.definition,paths:e.paths,target:t,customArtifactTypes:e.customArtifactTypes}),t):t};export{c as collectRuntimePrepareArtifacts,n as createRuntimePrepareArtifacts}; //# sourceMappingURL=prepare-artifacts.mjs.map