(dataOnly = false)
| 41 | let _exportManager: ExportManager; |
| 42 | |
| 43 | const createExportManager = async (dataOnly = false) => { |
| 44 | const exportMng = new ExportManager(logger, clearAdminSchema); |
| 45 | |
| 46 | if (!dataOnly) { |
| 47 | exportMng.addExporter({ |
| 48 | watch: ['collections', 'fields', 'relations'], |
| 49 | exporter: new SchemaExporter(getSchemaService, logger, schemaOptions), |
| 50 | }); |
| 51 | } |
| 52 | |
| 53 | const { syncDirectusCollections } = (await nodeImport(ExportHelper.schemaDir, 'directus_config.js')) as { |
| 54 | syncDirectusCollections: ExportCollectionConfig; |
| 55 | }; |
| 56 | const { syncCustomCollections } = (await nodeImport(ExportHelper.schemaDir, 'config.js')) as { |
| 57 | syncCustomCollections: ExportCollectionConfig; |
| 58 | }; |
| 59 | exportMng.addCollectionExporter(syncDirectusCollections, getItemsService); |
| 60 | exportMng.addCollectionExporter(syncCustomCollections, getItemsService); |
| 61 | |
| 62 | // Additional config |
| 63 | if (env.SCHEMA_SYNC_CONFIG) { |
| 64 | const { syncCustomCollections } = (await nodeImport(ExportHelper.schemaDir, env.SCHEMA_SYNC_CONFIG)) as { |
| 65 | syncCustomCollections: ExportCollectionConfig; |
| 66 | }; |
| 67 | if (syncCustomCollections) { |
| 68 | exportMng.addCollectionExporter(syncCustomCollections, getItemsService); |
| 69 | } else { |
| 70 | logger.warn(`Additonal config specified but not exporting "syncCustomCollections"`); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | return exportMng; |
| 75 | } |
| 76 | |
| 77 | const exportManager = async (dataOnly = false) => { |
| 78 | if (dataOnly && env.SCHEMA_SYNC_DATA_ONLY !== true) { |
no test coverage detected