directus-template-cli 0.4.2 → 0.4.3
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.
|
@@ -11,12 +11,17 @@ const write_to_file_1 = tslib_1.__importDefault(require("../utils/write-to-file"
|
|
|
11
11
|
async function extractFields(dir) {
|
|
12
12
|
try {
|
|
13
13
|
const response = await sdk_2.api.client.request((0, sdk_1.readFields)());
|
|
14
|
+
if (!Array.isArray(response)) {
|
|
15
|
+
throw new TypeError('Unexpected response format');
|
|
16
|
+
}
|
|
14
17
|
const fields = response
|
|
15
18
|
.filter(
|
|
16
19
|
// @ts-ignore
|
|
17
|
-
(i) => !i.meta.system)
|
|
20
|
+
(i) => i.meta && !i.meta.system)
|
|
18
21
|
.map(i => {
|
|
19
|
-
|
|
22
|
+
if (i.meta) {
|
|
23
|
+
delete i.meta.id;
|
|
24
|
+
}
|
|
20
25
|
return i;
|
|
21
26
|
});
|
|
22
27
|
await (0, write_to_file_1.default)('fields', fields, dir);
|
|
@@ -25,6 +30,7 @@ async function extractFields(dir) {
|
|
|
25
30
|
catch (error) {
|
|
26
31
|
core_1.ux.warn('Error extracting Fields:');
|
|
27
32
|
core_1.ux.warn(error.message);
|
|
33
|
+
console.error(error);
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
exports.default = extractFields;
|
|
@@ -13,7 +13,7 @@ async function extractRelations(dir) {
|
|
|
13
13
|
const response = await sdk_2.api.client.request((0, sdk_1.readRelations)());
|
|
14
14
|
// Fetching fields to filter out system fields while retaining custom fields on system collections
|
|
15
15
|
const fields = await sdk_2.api.client.request((0, sdk_1.readFields)());
|
|
16
|
-
const customFields = fields.filter((i) => !i.meta.system);
|
|
16
|
+
const customFields = fields.filter((i) => { var _a; return !((_a = i.meta) === null || _a === void 0 ? void 0 : _a.system); });
|
|
17
17
|
const relations = response
|
|
18
18
|
// Filter out relations where the collection starts with 'directus_' && the field is not within the customFields array
|
|
19
19
|
.filter((i) => !i.collection.startsWith('directus_', 0)
|
|
@@ -5,7 +5,7 @@ const core_1 = require("@oclif/core");
|
|
|
5
5
|
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
6
6
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
7
7
|
function logError(error, options = {}) {
|
|
8
|
-
const errorMessage = `Status ${error.response.status} • ${error.errors[0].message}\n`;
|
|
8
|
+
const errorMessage = `Status ${error.response.status} • ${JSON.stringify(error.errors[0].message)}\n`;
|
|
9
9
|
if (options.fatal) {
|
|
10
10
|
core_1.ux.error(errorMessage);
|
|
11
11
|
}
|
package/oclif.manifest.json
CHANGED