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.35 kB
import e from"../../../services/sync/sync-collections.mjs";import t from"../../../services/sync/sync-locales.mjs";import n from"../../../services/sync/sync-roles.mjs";import r from"../../../services/sync/sync-tenants.mjs";import{passthroughEmailAdapterInstance as i}from"../../email/adapters/passthrough.mjs";import{destroyKVAdapter as a,getInitializedKVAdapter as o}from"../../kv/lifecycle.mjs";import s from"../../queue/adapters/passthrough.mjs";import c from"../../../utils/services/create-service-context.mjs";import l from"../logger.mjs";const u=async u=>{l.info(`Running sync tasks...`);let d=u.kv??await o(u.config,{env:u.env,runtimeContext:u.runtimeContext}),f=u.kv===void 0,p=c({config:u.config,database:u.database,translationStore:u.translationStore,env:u.env,runtimeContext:u.runtimeContext,queue:s(),kv:d,media:null,email:i}),m=!1,h=async()=>{m||(m=!0,f&&await a(d,{config:u.config,env:u.env,runtimeContext:u.runtimeContext}))};try{let[i,a,o,s]=await Promise.all([t(p),r(p),e(p),n(p)]);for(let[e,t]of[[`locale`,i],[`tenants`,a],[`collection`,o],[`roles`,s]])if(t.error)return l.error(`Sync failed during ${e} sync, with error:`,p.translate.english(t.error.message)||`unknown`),!1;return l.success(`Sync tasks completed`,l.color.green(`successfully`)),!0}finally{await h()}};export{u as default}; //# sourceMappingURL=run-sync-tasks.mjs.map