Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/lib/extract/extract-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export default async function extractAccess(dir: string) {

await writeToFile('access', response, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_access'},
fatal: true,
})
}

ux.action.stop()
Expand Down
10 changes: 8 additions & 2 deletions src/lib/extract/extract-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ export async function downloadAllFiles(dir: string) {

const fileList = await getAssetList()
await Promise.all(fileList.map(file => downloadFile(file, dir).catch(error => {
catchError(`Error downloading ${file.filename_disk}: ${error.message}`)
catchError(`Error downloading ${file.filename_disk}: ${error.message}`, {
context: {fileId: file.id, filename: file.filename_disk, operation: 'downloadFile'},
fatal: false,
})
})))
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_assets'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export default async function extractCollections(dir: string) {
)
await writeToFile('collections', collections, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_collections'},
fatal: true,
})
}

ux.action.stop()
Expand Down
10 changes: 8 additions & 2 deletions src/lib/extract/extract-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ async function getDataFromCollection(collection: string, dir: string) {
const response = await api.client.request(readItems(collection as never, {limit: -1}))
await writeToFile(`${collection}`, response, `${dir}/content/`)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_content'},
fatal: true,
})
}
}

Expand All @@ -29,7 +32,10 @@ export async function extractContent(dir: string) {
const collections = await getCollections()
await Promise.all(collections.map(collection => getDataFromCollection(collection, dir)))
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_content'},
fatal: true,
})
}

ux.action.stop()
Expand Down
10 changes: 8 additions & 2 deletions src/lib/extract/extract-dashboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export async function extractDashboards(dir: string) {
const dashboards = filterFields(response, directusDashboardFields)
await writeToFile('dashboards', dashboards, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_dashboards'},
fatal: true,
})
}

ux.action.stop()
Expand All @@ -36,7 +39,10 @@ export async function extractPanels(dir: string) {
const panels = filterFields(response, directusPanelFields)
await writeToFile('panels', panels, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_dashboards'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export default async function extractExtensions(dir: string) {
const response = await api.client.request(readExtensions())
await writeToFile('extensions', response, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_extensions'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ export default async function extractFields(dir: string) {

await writeToFile('fields', fields, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_fields'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export default async function extractFiles(dir: string) {
const files = filterFields(response, directusFileFields)
await writeToFile('files', files, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_files'},
fatal: true,
})
}

ux.action.stop()
Expand Down
10 changes: 8 additions & 2 deletions src/lib/extract/extract-flows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export async function extractFlows(dir: string) {
const flows = filterFields(response, directusFlowFields)
await writeToFile('flows', flows, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_flows'},
fatal: true,
})
}

ux.action.stop()
Expand All @@ -36,7 +39,10 @@ export async function extractOperations(dir: string) {
const operations = filterFields(response, directusOperationFields)
await writeToFile('operations', operations, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_flows'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-folders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export default async function extractFolders(dir: string) {
const folders = filterFields(response, directusFolderFields)
await writeToFile('folders', folders, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_folders'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export default async function extractPermissions(dir: string) {
})
await writeToFile('permissions', response, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_permissions'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export default async function extractPolicies(dir: string) {

await writeToFile('policies', response, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_policies'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export default async function extractPresets(dir: string) {
})
await writeToFile('presets', presets, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_presets'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export default async function extractRelations(dir: string) {

await writeToFile('relations', relations, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_relations'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export default async function extractRoles(dir: string) {
const roles = filterFields(response, directusRoleFields)
await writeToFile('roles', roles, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_roles'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export default async function extractSchema(dir: string) {
const schema = await api.client.request(schemaSnapshot())
await writeToFile('schema/snapshot', schema, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_schema'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export default async function extractSettings(dir: string) {
const settings = await api.client.request(readSettings({limit: -1}))
await writeToFile('settings', settings, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_settings'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export default async function extractTranslations(dir: string) {
const translations = await api.client.request(readTranslations({limit: -1}))
await writeToFile('translations', translations, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_translations'},
fatal: true,
})
}

ux.action.stop()
Expand Down
5 changes: 4 additions & 1 deletion src/lib/extract/extract-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ export default async function extractUsers(dir: string) {
const users = filterFields(response, directusUserFields)
await writeToFile('users', users, dir)
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'extract_users'},
fatal: true,
})
}

ux.action.stop()
Expand Down
20 changes: 16 additions & 4 deletions src/lib/load/load-collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ async function processCollections(collectionsToAdd: any[], fieldsToAdd: any[]) {

await (existingCollection ? addNewFieldsToExistingCollection(collection.collection, fieldsToAdd, existingFields) : addNewCollectionWithFields(collection, fieldsToAdd))
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'load_collections'},
fatal: true,
})
}
}
}
Expand Down Expand Up @@ -85,7 +88,10 @@ async function addNewFieldsToExistingCollection(collectionName: string, fieldsTo
// @ts-ignore - ignore
await api.client.request(createField(collectionName, field))
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'load_collections'},
fatal: true,
})
}
}
}
Expand All @@ -103,7 +109,10 @@ async function updateCollections(collections: any[]) {
await api.client.request(updateCollection(collection.collection, pl))
}
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'load_collections'},
fatal: true,
})
}
}
}
Expand All @@ -126,7 +135,10 @@ async function addCustomFieldsOnSystemCollections(fields: any[]) {
await api.client.request(createField(field.collection, field))
}
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'load_collections'},
fatal: true,
})
}
}
}
10 changes: 8 additions & 2 deletions src/lib/load/load-dashboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export default async function loadDashboards(dir: string) {
try {
await api.client.request(createDashboard(dashboard))
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'load_dashboards'},
fatal: true,
})
}
}))

Expand Down Expand Up @@ -64,7 +67,10 @@ export async function loadPanels(dir: string) {
try {
await api.client.request(createPanel(panel))
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'load_dashboards'},
fatal: true,
})
}
}))
}
15 changes: 12 additions & 3 deletions src/lib/load/load-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ async function getExistingPrimaryKeys(collection: string, primaryKeyField: strin
if (response.length < limit) break
page++
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'load_data'},
fatal: true,
})
break
}
}
Expand All @@ -91,7 +94,10 @@ async function uploadBatch(collection: string, batch: any[], method: Function) {
try {
await api.client.request(method(collection, batch))
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'load_data'},
fatal: true,
})
}
}

Expand Down Expand Up @@ -134,7 +140,10 @@ async function loadSingletons(dir:string) {

await api.client.request(updateSingleton(name, cleanedData))
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'load_data'},
fatal: true,
})
}
}))

Expand Down
5 changes: 4 additions & 1 deletion src/lib/load/load-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export default async function loadExtensions(dir: string): Promise<void> {
})
return `-- Installed ${ext.schema?.name}`
} catch (error) {
catchError(error)
catchError(error, {
context: {operation: 'load_extensions'},
fatal: true,
})
return `-- Failed to install ${ext.schema?.name}`
}
}))
Expand Down
Loading