directus-template-cli 0.5.0-beta.2 → 0.5.0-beta.20
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.
- package/README.md +176 -15
- package/dist/commands/apply.d.ts +41 -18
- package/dist/commands/apply.js +113 -122
- package/dist/commands/extract.d.ts +29 -1
- package/dist/commands/extract.js +76 -51
- package/dist/flags/common.d.ts +7 -0
- package/dist/flags/common.js +41 -0
- package/dist/lib/constants.d.ts +3 -0
- package/dist/lib/constants.js +6 -0
- package/dist/lib/extract/extract-access.js +5 -3
- package/dist/lib/extract/extract-assets.d.ts +0 -414
- package/dist/lib/extract/extract-assets.js +29 -25
- package/dist/lib/extract/extract-collections.js +5 -4
- package/dist/lib/extract/extract-content.d.ts +0 -2
- package/dist/lib/extract/extract-content.js +16 -15
- package/dist/lib/extract/extract-dashboards.js +8 -6
- package/dist/lib/extract/extract-extensions.js +5 -3
- package/dist/lib/extract/extract-fields.js +5 -4
- package/dist/lib/extract/extract-files.js +5 -3
- package/dist/lib/extract/extract-flows.js +8 -6
- package/dist/lib/extract/extract-folders.js +5 -3
- package/dist/lib/extract/extract-permissions.js +5 -3
- package/dist/lib/extract/extract-policies.js +5 -3
- package/dist/lib/extract/extract-presets.js +5 -3
- package/dist/lib/extract/extract-relations.js +5 -3
- package/dist/lib/extract/extract-roles.js +5 -3
- package/dist/lib/extract/extract-schema.js +6 -8
- package/dist/lib/extract/extract-settings.js +5 -3
- package/dist/lib/extract/extract-translations.js +6 -6
- package/dist/lib/extract/extract-users.js +6 -6
- package/dist/lib/load/apply-flags.d.ts +22 -0
- package/dist/lib/load/apply-flags.js +67 -0
- package/dist/lib/load/index.js +9 -5
- package/dist/lib/load/load-access.js +47 -41
- package/dist/lib/load/load-collections.js +61 -17
- package/dist/lib/load/load-dashboards.js +30 -30
- package/dist/lib/load/load-data.js +47 -11
- package/dist/lib/load/load-extensions.js +49 -43
- package/dist/lib/load/load-files.js +44 -51
- package/dist/lib/load/load-flows.d.ts +1 -1
- package/dist/lib/load/load-flows.js +44 -38
- package/dist/lib/load/load-folders.js +34 -35
- package/dist/lib/load/load-permissions.js +15 -17
- package/dist/lib/load/load-policies.js +23 -21
- package/dist/lib/load/load-presets.js +27 -26
- package/dist/lib/load/load-relations.js +19 -18
- package/dist/lib/load/load-roles.js +45 -45
- package/dist/lib/load/load-settings.js +39 -2
- package/dist/lib/load/load-translations.js +24 -24
- package/dist/lib/load/load-users.js +44 -34
- package/dist/lib/load/update-required-fields.d.ts +1 -0
- package/dist/lib/load/update-required-fields.js +24 -0
- package/dist/lib/sdk.d.ts +20 -2
- package/dist/lib/sdk.js +124 -9
- package/dist/lib/utils/auth.d.ts +26 -0
- package/dist/lib/utils/auth.js +48 -4
- package/dist/lib/utils/catch-error.d.ts +15 -2
- package/dist/lib/utils/catch-error.js +31 -25
- package/dist/lib/utils/get-template.d.ts +1 -0
- package/dist/lib/utils/get-template.js +42 -1
- package/dist/lib/utils/read-file.js +2 -1
- package/dist/lib/utils/read-templates.js +4 -2
- package/oclif.manifest.json +74 -28
- package/package.json +2 -2
- package/dist/lib/interfaces.d.ts +0 -8
- package/dist/lib/interfaces.js +0 -2
|
@@ -1,415 +1 @@
|
|
|
1
|
-
export declare function getAssetList(): Promise<import("@directus/sdk").Merge<import("@directus/sdk").MapFlatFields<{
|
|
2
|
-
id: string;
|
|
3
|
-
storage: string;
|
|
4
|
-
filename_disk: string;
|
|
5
|
-
filename_download: string;
|
|
6
|
-
title: string;
|
|
7
|
-
type: string;
|
|
8
|
-
folder: string | {
|
|
9
|
-
id: string;
|
|
10
|
-
name: string;
|
|
11
|
-
parent: string | any;
|
|
12
|
-
};
|
|
13
|
-
uploaded_by: string | {
|
|
14
|
-
id: string;
|
|
15
|
-
first_name: string;
|
|
16
|
-
last_name: string;
|
|
17
|
-
email: string;
|
|
18
|
-
password: string;
|
|
19
|
-
location: string;
|
|
20
|
-
title: string;
|
|
21
|
-
description: string;
|
|
22
|
-
tags: string[];
|
|
23
|
-
avatar: string | any;
|
|
24
|
-
language: string;
|
|
25
|
-
theme: string;
|
|
26
|
-
tfa_secret: string;
|
|
27
|
-
status: string;
|
|
28
|
-
role: string | {
|
|
29
|
-
id: string;
|
|
30
|
-
name: string;
|
|
31
|
-
icon: string;
|
|
32
|
-
description: string;
|
|
33
|
-
parent: string | any;
|
|
34
|
-
children: string[] | any[];
|
|
35
|
-
policies: string[] | {
|
|
36
|
-
id: string;
|
|
37
|
-
name: string;
|
|
38
|
-
icon: string;
|
|
39
|
-
description: string;
|
|
40
|
-
ip_access: string;
|
|
41
|
-
enforce_tfa: boolean;
|
|
42
|
-
admin_access: boolean;
|
|
43
|
-
app_access: boolean;
|
|
44
|
-
permissions: number[] | {
|
|
45
|
-
id: number;
|
|
46
|
-
policy: string | any;
|
|
47
|
-
collection: string;
|
|
48
|
-
action: string;
|
|
49
|
-
permissions: Record<string, any>;
|
|
50
|
-
validation: Record<string, any>;
|
|
51
|
-
presets: Record<string, any>;
|
|
52
|
-
fields: string[];
|
|
53
|
-
}[];
|
|
54
|
-
users: string[] | any[];
|
|
55
|
-
roles: string[] | any[];
|
|
56
|
-
}[];
|
|
57
|
-
users: string[] | any[];
|
|
58
|
-
};
|
|
59
|
-
token: string;
|
|
60
|
-
last_access: "datetime";
|
|
61
|
-
last_page: string;
|
|
62
|
-
provider: string;
|
|
63
|
-
external_identifier: string;
|
|
64
|
-
auth_data: Record<string, any>;
|
|
65
|
-
email_notifications: boolean;
|
|
66
|
-
appearance: string;
|
|
67
|
-
theme_dark: string;
|
|
68
|
-
theme_light: string;
|
|
69
|
-
theme_light_overrides: Record<string, unknown>;
|
|
70
|
-
theme_dark_overrides: Record<string, unknown>;
|
|
71
|
-
policies: string[] | {
|
|
72
|
-
id: string;
|
|
73
|
-
name: string;
|
|
74
|
-
icon: string;
|
|
75
|
-
description: string;
|
|
76
|
-
ip_access: string;
|
|
77
|
-
enforce_tfa: boolean;
|
|
78
|
-
admin_access: boolean;
|
|
79
|
-
app_access: boolean;
|
|
80
|
-
permissions: number[] | {
|
|
81
|
-
id: number;
|
|
82
|
-
policy: string | any;
|
|
83
|
-
collection: string;
|
|
84
|
-
action: string;
|
|
85
|
-
permissions: Record<string, any>;
|
|
86
|
-
validation: Record<string, any>;
|
|
87
|
-
presets: Record<string, any>;
|
|
88
|
-
fields: string[];
|
|
89
|
-
}[];
|
|
90
|
-
users: string[] | any[];
|
|
91
|
-
roles: string[] | any[];
|
|
92
|
-
}[];
|
|
93
|
-
};
|
|
94
|
-
uploaded_on: "datetime";
|
|
95
|
-
modified_by: string | {
|
|
96
|
-
id: string;
|
|
97
|
-
first_name: string;
|
|
98
|
-
last_name: string;
|
|
99
|
-
email: string;
|
|
100
|
-
password: string;
|
|
101
|
-
location: string;
|
|
102
|
-
title: string;
|
|
103
|
-
description: string;
|
|
104
|
-
tags: string[];
|
|
105
|
-
avatar: string | any;
|
|
106
|
-
language: string;
|
|
107
|
-
theme: string;
|
|
108
|
-
tfa_secret: string;
|
|
109
|
-
status: string;
|
|
110
|
-
role: string | {
|
|
111
|
-
id: string;
|
|
112
|
-
name: string;
|
|
113
|
-
icon: string;
|
|
114
|
-
description: string;
|
|
115
|
-
parent: string | any;
|
|
116
|
-
children: string[] | any[];
|
|
117
|
-
policies: string[] | {
|
|
118
|
-
id: string;
|
|
119
|
-
name: string;
|
|
120
|
-
icon: string;
|
|
121
|
-
description: string;
|
|
122
|
-
ip_access: string;
|
|
123
|
-
enforce_tfa: boolean;
|
|
124
|
-
admin_access: boolean;
|
|
125
|
-
app_access: boolean;
|
|
126
|
-
permissions: number[] | {
|
|
127
|
-
id: number;
|
|
128
|
-
policy: string | any;
|
|
129
|
-
collection: string;
|
|
130
|
-
action: string;
|
|
131
|
-
permissions: Record<string, any>;
|
|
132
|
-
validation: Record<string, any>;
|
|
133
|
-
presets: Record<string, any>;
|
|
134
|
-
fields: string[];
|
|
135
|
-
}[];
|
|
136
|
-
users: string[] | any[];
|
|
137
|
-
roles: string[] | any[];
|
|
138
|
-
}[];
|
|
139
|
-
users: string[] | any[];
|
|
140
|
-
};
|
|
141
|
-
token: string;
|
|
142
|
-
last_access: "datetime";
|
|
143
|
-
last_page: string;
|
|
144
|
-
provider: string;
|
|
145
|
-
external_identifier: string;
|
|
146
|
-
auth_data: Record<string, any>;
|
|
147
|
-
email_notifications: boolean;
|
|
148
|
-
appearance: string;
|
|
149
|
-
theme_dark: string;
|
|
150
|
-
theme_light: string;
|
|
151
|
-
theme_light_overrides: Record<string, unknown>;
|
|
152
|
-
theme_dark_overrides: Record<string, unknown>;
|
|
153
|
-
policies: string[] | {
|
|
154
|
-
id: string;
|
|
155
|
-
name: string;
|
|
156
|
-
icon: string;
|
|
157
|
-
description: string;
|
|
158
|
-
ip_access: string;
|
|
159
|
-
enforce_tfa: boolean;
|
|
160
|
-
admin_access: boolean;
|
|
161
|
-
app_access: boolean;
|
|
162
|
-
permissions: number[] | {
|
|
163
|
-
id: number;
|
|
164
|
-
policy: string | any;
|
|
165
|
-
collection: string;
|
|
166
|
-
action: string;
|
|
167
|
-
permissions: Record<string, any>;
|
|
168
|
-
validation: Record<string, any>;
|
|
169
|
-
presets: Record<string, any>;
|
|
170
|
-
fields: string[];
|
|
171
|
-
}[];
|
|
172
|
-
users: string[] | any[];
|
|
173
|
-
roles: string[] | any[];
|
|
174
|
-
}[];
|
|
175
|
-
};
|
|
176
|
-
modified_on: "datetime";
|
|
177
|
-
charset: string;
|
|
178
|
-
filesize: string;
|
|
179
|
-
width: number;
|
|
180
|
-
height: number;
|
|
181
|
-
duration: number;
|
|
182
|
-
embed: unknown;
|
|
183
|
-
description: string;
|
|
184
|
-
location: string;
|
|
185
|
-
tags: string[];
|
|
186
|
-
metadata: Record<string, any>;
|
|
187
|
-
focal_point_x: number;
|
|
188
|
-
focal_point_y: number;
|
|
189
|
-
}, "embed" | "type" | "location" | "description" | "id" | "duration" | "title" | "tags" | "storage" | "filename_disk" | "filename_download" | "folder" | "uploaded_by" | "uploaded_on" | "modified_by" | "modified_on" | "charset" | "filesize" | "width" | "height" | "metadata" | "focal_point_x" | "focal_point_y", {
|
|
190
|
-
"year(uploaded_on)": "uploaded_on_year";
|
|
191
|
-
"year(modified_on)": "modified_on_year";
|
|
192
|
-
"month(uploaded_on)": "uploaded_on_month";
|
|
193
|
-
"month(modified_on)": "modified_on_month";
|
|
194
|
-
"week(uploaded_on)": "uploaded_on_week";
|
|
195
|
-
"week(modified_on)": "modified_on_week";
|
|
196
|
-
"day(uploaded_on)": "uploaded_on_day";
|
|
197
|
-
"day(modified_on)": "modified_on_day";
|
|
198
|
-
"weekday(uploaded_on)": "uploaded_on_weekday";
|
|
199
|
-
"weekday(modified_on)": "modified_on_weekday";
|
|
200
|
-
"hour(uploaded_on)": "uploaded_on_hour";
|
|
201
|
-
"hour(modified_on)": "modified_on_hour";
|
|
202
|
-
"minute(uploaded_on)": "uploaded_on_minute";
|
|
203
|
-
"minute(modified_on)": "modified_on_minute";
|
|
204
|
-
"second(uploaded_on)": "uploaded_on_second";
|
|
205
|
-
"second(modified_on)": "modified_on_second";
|
|
206
|
-
"count(tags)": "tags_count";
|
|
207
|
-
}>, {}, import("@directus/sdk").MapFlatFields<{
|
|
208
|
-
id: string;
|
|
209
|
-
storage: string;
|
|
210
|
-
filename_disk: string;
|
|
211
|
-
filename_download: string;
|
|
212
|
-
title: string;
|
|
213
|
-
type: string;
|
|
214
|
-
folder: string | {
|
|
215
|
-
id: string;
|
|
216
|
-
name: string;
|
|
217
|
-
parent: string | any;
|
|
218
|
-
};
|
|
219
|
-
uploaded_by: string | {
|
|
220
|
-
id: string;
|
|
221
|
-
first_name: string;
|
|
222
|
-
last_name: string;
|
|
223
|
-
email: string;
|
|
224
|
-
password: string;
|
|
225
|
-
location: string;
|
|
226
|
-
title: string;
|
|
227
|
-
description: string;
|
|
228
|
-
tags: string[];
|
|
229
|
-
avatar: string | any;
|
|
230
|
-
language: string;
|
|
231
|
-
theme: string;
|
|
232
|
-
tfa_secret: string;
|
|
233
|
-
status: string;
|
|
234
|
-
role: string | {
|
|
235
|
-
id: string;
|
|
236
|
-
name: string;
|
|
237
|
-
icon: string;
|
|
238
|
-
description: string;
|
|
239
|
-
parent: string | any;
|
|
240
|
-
children: string[] | any[];
|
|
241
|
-
policies: string[] | {
|
|
242
|
-
id: string;
|
|
243
|
-
name: string;
|
|
244
|
-
icon: string;
|
|
245
|
-
description: string;
|
|
246
|
-
ip_access: string;
|
|
247
|
-
enforce_tfa: boolean;
|
|
248
|
-
admin_access: boolean;
|
|
249
|
-
app_access: boolean;
|
|
250
|
-
permissions: number[] | {
|
|
251
|
-
id: number;
|
|
252
|
-
policy: string | any;
|
|
253
|
-
collection: string;
|
|
254
|
-
action: string;
|
|
255
|
-
permissions: Record<string, any>;
|
|
256
|
-
validation: Record<string, any>;
|
|
257
|
-
presets: Record<string, any>;
|
|
258
|
-
fields: string[];
|
|
259
|
-
}[];
|
|
260
|
-
users: string[] | any[];
|
|
261
|
-
roles: string[] | any[];
|
|
262
|
-
}[];
|
|
263
|
-
users: string[] | any[];
|
|
264
|
-
};
|
|
265
|
-
token: string;
|
|
266
|
-
last_access: "datetime";
|
|
267
|
-
last_page: string;
|
|
268
|
-
provider: string;
|
|
269
|
-
external_identifier: string;
|
|
270
|
-
auth_data: Record<string, any>;
|
|
271
|
-
email_notifications: boolean;
|
|
272
|
-
appearance: string;
|
|
273
|
-
theme_dark: string;
|
|
274
|
-
theme_light: string;
|
|
275
|
-
theme_light_overrides: Record<string, unknown>;
|
|
276
|
-
theme_dark_overrides: Record<string, unknown>;
|
|
277
|
-
policies: string[] | {
|
|
278
|
-
id: string;
|
|
279
|
-
name: string;
|
|
280
|
-
icon: string;
|
|
281
|
-
description: string;
|
|
282
|
-
ip_access: string;
|
|
283
|
-
enforce_tfa: boolean;
|
|
284
|
-
admin_access: boolean;
|
|
285
|
-
app_access: boolean;
|
|
286
|
-
permissions: number[] | {
|
|
287
|
-
id: number;
|
|
288
|
-
policy: string | any;
|
|
289
|
-
collection: string;
|
|
290
|
-
action: string;
|
|
291
|
-
permissions: Record<string, any>;
|
|
292
|
-
validation: Record<string, any>;
|
|
293
|
-
presets: Record<string, any>;
|
|
294
|
-
fields: string[];
|
|
295
|
-
}[];
|
|
296
|
-
users: string[] | any[];
|
|
297
|
-
roles: string[] | any[];
|
|
298
|
-
}[];
|
|
299
|
-
};
|
|
300
|
-
uploaded_on: "datetime";
|
|
301
|
-
modified_by: string | {
|
|
302
|
-
id: string;
|
|
303
|
-
first_name: string;
|
|
304
|
-
last_name: string;
|
|
305
|
-
email: string;
|
|
306
|
-
password: string;
|
|
307
|
-
location: string;
|
|
308
|
-
title: string;
|
|
309
|
-
description: string;
|
|
310
|
-
tags: string[];
|
|
311
|
-
avatar: string | any;
|
|
312
|
-
language: string;
|
|
313
|
-
theme: string;
|
|
314
|
-
tfa_secret: string;
|
|
315
|
-
status: string;
|
|
316
|
-
role: string | {
|
|
317
|
-
id: string;
|
|
318
|
-
name: string;
|
|
319
|
-
icon: string;
|
|
320
|
-
description: string;
|
|
321
|
-
parent: string | any;
|
|
322
|
-
children: string[] | any[];
|
|
323
|
-
policies: string[] | {
|
|
324
|
-
id: string;
|
|
325
|
-
name: string;
|
|
326
|
-
icon: string;
|
|
327
|
-
description: string;
|
|
328
|
-
ip_access: string;
|
|
329
|
-
enforce_tfa: boolean;
|
|
330
|
-
admin_access: boolean;
|
|
331
|
-
app_access: boolean;
|
|
332
|
-
permissions: number[] | {
|
|
333
|
-
id: number;
|
|
334
|
-
policy: string | any;
|
|
335
|
-
collection: string;
|
|
336
|
-
action: string;
|
|
337
|
-
permissions: Record<string, any>;
|
|
338
|
-
validation: Record<string, any>;
|
|
339
|
-
presets: Record<string, any>;
|
|
340
|
-
fields: string[];
|
|
341
|
-
}[];
|
|
342
|
-
users: string[] | any[];
|
|
343
|
-
roles: string[] | any[];
|
|
344
|
-
}[];
|
|
345
|
-
users: string[] | any[];
|
|
346
|
-
};
|
|
347
|
-
token: string;
|
|
348
|
-
last_access: "datetime";
|
|
349
|
-
last_page: string;
|
|
350
|
-
provider: string;
|
|
351
|
-
external_identifier: string;
|
|
352
|
-
auth_data: Record<string, any>;
|
|
353
|
-
email_notifications: boolean;
|
|
354
|
-
appearance: string;
|
|
355
|
-
theme_dark: string;
|
|
356
|
-
theme_light: string;
|
|
357
|
-
theme_light_overrides: Record<string, unknown>;
|
|
358
|
-
theme_dark_overrides: Record<string, unknown>;
|
|
359
|
-
policies: string[] | {
|
|
360
|
-
id: string;
|
|
361
|
-
name: string;
|
|
362
|
-
icon: string;
|
|
363
|
-
description: string;
|
|
364
|
-
ip_access: string;
|
|
365
|
-
enforce_tfa: boolean;
|
|
366
|
-
admin_access: boolean;
|
|
367
|
-
app_access: boolean;
|
|
368
|
-
permissions: number[] | {
|
|
369
|
-
id: number;
|
|
370
|
-
policy: string | any;
|
|
371
|
-
collection: string;
|
|
372
|
-
action: string;
|
|
373
|
-
permissions: Record<string, any>;
|
|
374
|
-
validation: Record<string, any>;
|
|
375
|
-
presets: Record<string, any>;
|
|
376
|
-
fields: string[];
|
|
377
|
-
}[];
|
|
378
|
-
users: string[] | any[];
|
|
379
|
-
roles: string[] | any[];
|
|
380
|
-
}[];
|
|
381
|
-
};
|
|
382
|
-
modified_on: "datetime";
|
|
383
|
-
charset: string;
|
|
384
|
-
filesize: string;
|
|
385
|
-
width: number;
|
|
386
|
-
height: number;
|
|
387
|
-
duration: number;
|
|
388
|
-
embed: unknown;
|
|
389
|
-
description: string;
|
|
390
|
-
location: string;
|
|
391
|
-
tags: string[];
|
|
392
|
-
metadata: Record<string, any>;
|
|
393
|
-
focal_point_x: number;
|
|
394
|
-
focal_point_y: number;
|
|
395
|
-
}, "embed" | "type" | "location" | "description" | "id" | "duration" | "title" | "tags" | "storage" | "filename_disk" | "filename_download" | "folder" | "uploaded_by" | "uploaded_on" | "modified_by" | "modified_on" | "charset" | "filesize" | "width" | "height" | "metadata" | "focal_point_x" | "focal_point_y", {
|
|
396
|
-
"year(uploaded_on)": "uploaded_on_year";
|
|
397
|
-
"year(modified_on)": "modified_on_year";
|
|
398
|
-
"month(uploaded_on)": "uploaded_on_month";
|
|
399
|
-
"month(modified_on)": "modified_on_month";
|
|
400
|
-
"week(uploaded_on)": "uploaded_on_week";
|
|
401
|
-
"week(modified_on)": "modified_on_week";
|
|
402
|
-
"day(uploaded_on)": "uploaded_on_day";
|
|
403
|
-
"day(modified_on)": "modified_on_day";
|
|
404
|
-
"weekday(uploaded_on)": "uploaded_on_weekday";
|
|
405
|
-
"weekday(modified_on)": "modified_on_weekday";
|
|
406
|
-
"hour(uploaded_on)": "uploaded_on_hour";
|
|
407
|
-
"hour(modified_on)": "modified_on_hour";
|
|
408
|
-
"minute(uploaded_on)": "uploaded_on_minute";
|
|
409
|
-
"minute(modified_on)": "modified_on_minute";
|
|
410
|
-
"second(uploaded_on)": "uploaded_on_second";
|
|
411
|
-
"second(modified_on)": "modified_on_second";
|
|
412
|
-
"count(tags)": "tags_count";
|
|
413
|
-
}>, {}>[]>;
|
|
414
|
-
export declare function downloadFile(file: any, dir: string): Promise<void>;
|
|
415
1
|
export declare function downloadAllFiles(dir: string): Promise<void>;
|
|
@@ -1,42 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.downloadAllFiles =
|
|
3
|
+
exports.downloadAllFiles = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const sdk_1 = require("@directus/sdk");
|
|
6
6
|
const core_1 = require("@oclif/core");
|
|
7
7
|
const node_fs_1 = tslib_1.__importDefault(require("node:fs"));
|
|
8
8
|
const node_path_1 = tslib_1.__importDefault(require("node:path"));
|
|
9
|
-
const
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
10
|
const sdk_2 = require("../sdk");
|
|
11
|
+
const catch_error_1 = tslib_1.__importDefault(require("../utils/catch-error"));
|
|
11
12
|
async function getAssetList() {
|
|
12
|
-
|
|
13
|
-
return response;
|
|
13
|
+
return sdk_2.api.client.request((0, sdk_1.readFiles)({ limit: -1 }));
|
|
14
14
|
}
|
|
15
|
-
exports.getAssetList = getAssetList;
|
|
16
15
|
async function downloadFile(file, dir) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const response = await sdk_2.api.client.request(() => ({
|
|
17
|
+
method: 'GET',
|
|
18
|
+
path: `/assets/${file.id}`,
|
|
19
|
+
}));
|
|
20
20
|
const fullPath = node_path_1.default.join(dir, 'assets', file.filename_disk);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
if (typeof response === 'string') {
|
|
22
|
+
node_fs_1.default.writeFileSync(fullPath, response);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const data = await response.arrayBuffer();
|
|
26
|
+
node_fs_1.default.writeFileSync(fullPath, Buffer.from(data));
|
|
27
|
+
}
|
|
24
28
|
}
|
|
25
|
-
exports.downloadFile = downloadFile;
|
|
26
29
|
async function downloadAllFiles(dir) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
node_fs_1.default.
|
|
30
|
+
core_1.ux.action.start(core_1.ux.colorize(constants_1.DIRECTUS_PINK, 'Downloading assets'));
|
|
31
|
+
try {
|
|
32
|
+
const fullPath = node_path_1.default.join(dir, 'assets');
|
|
33
|
+
if (node_path_1.default && !node_fs_1.default.existsSync(fullPath)) {
|
|
34
|
+
node_fs_1.default.mkdirSync(fullPath, { recursive: true });
|
|
35
|
+
}
|
|
36
|
+
const fileList = await getAssetList();
|
|
37
|
+
await Promise.all(fileList.map(file => downloadFile(file, dir).catch(error => {
|
|
38
|
+
(0, catch_error_1.default)(`Error downloading ${file.filename_disk}: ${error.message}`);
|
|
39
|
+
})));
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
(0, catch_error_1.default)(error);
|
|
31
43
|
}
|
|
32
|
-
|
|
33
|
-
const fileList = await getAssetList();
|
|
34
|
-
// Download all files
|
|
35
|
-
await Promise.all(fileList.map(file => downloadFile(file, dir).catch(error => {
|
|
36
|
-
core_1.ux.warn(`Error downloading ${file.filename_disk}`);
|
|
37
|
-
core_1.ux.warn(error.message);
|
|
38
|
-
})));
|
|
39
|
-
// Log message after all files have been downloaded
|
|
40
|
-
core_1.ux.log('All files have been downloaded.');
|
|
44
|
+
core_1.ux.action.stop();
|
|
41
45
|
}
|
|
42
46
|
exports.downloadAllFiles = downloadAllFiles;
|
|
@@ -3,22 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const sdk_1 = require("@directus/sdk");
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
6
7
|
const sdk_2 = require("../sdk");
|
|
8
|
+
const catch_error_1 = tslib_1.__importDefault(require("../utils/catch-error"));
|
|
7
9
|
const write_to_file_1 = tslib_1.__importDefault(require("../utils/write-to-file"));
|
|
8
10
|
/**
|
|
9
11
|
* Extract collections from the Directus instance
|
|
10
12
|
*/
|
|
11
13
|
async function extractCollections(dir) {
|
|
14
|
+
core_1.ux.action.start(core_1.ux.colorize(constants_1.DIRECTUS_PINK, 'Extracting collections'));
|
|
12
15
|
try {
|
|
13
16
|
const response = await sdk_2.api.client.request((0, sdk_1.readCollections)());
|
|
14
|
-
// Filter out system collections
|
|
15
17
|
const collections = response.filter(collection => !collection.collection.startsWith('directus_'));
|
|
16
18
|
await (0, write_to_file_1.default)('collections', collections, dir);
|
|
17
|
-
core_1.ux.log('Extracted collections');
|
|
18
19
|
}
|
|
19
20
|
catch (error) {
|
|
20
|
-
|
|
21
|
-
core_1.ux.warn(error.message);
|
|
21
|
+
(0, catch_error_1.default)(error);
|
|
22
22
|
}
|
|
23
|
+
core_1.ux.action.stop();
|
|
23
24
|
}
|
|
24
25
|
exports.default = extractCollections;
|
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractContent =
|
|
3
|
+
exports.extractContent = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const sdk_1 = require("@directus/sdk");
|
|
6
6
|
const core_1 = require("@oclif/core");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
7
8
|
const sdk_2 = require("../sdk");
|
|
9
|
+
const catch_error_1 = tslib_1.__importDefault(require("../utils/catch-error"));
|
|
8
10
|
const write_to_file_1 = tslib_1.__importDefault(require("../utils/write-to-file"));
|
|
9
11
|
async function getCollections() {
|
|
10
12
|
const response = await sdk_2.api.client.request((0, sdk_1.readCollections)());
|
|
11
|
-
|
|
13
|
+
return response
|
|
12
14
|
.filter(item => !item.collection.startsWith('directus_', 0))
|
|
13
15
|
.filter(item => item.schema != null)
|
|
14
16
|
.map(i => i.collection);
|
|
15
|
-
return collections;
|
|
16
17
|
}
|
|
17
|
-
exports.getCollections = getCollections;
|
|
18
18
|
async function getDataFromCollection(collection, dir) {
|
|
19
19
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
limit: -1,
|
|
23
|
-
}));
|
|
24
|
-
(0, write_to_file_1.default)(`${collection}`, response, `${dir}/content/`);
|
|
25
|
-
core_1.ux.log('Extracted items from collection: ' + collection);
|
|
20
|
+
const response = await sdk_2.api.client.request((0, sdk_1.readItems)(collection, { limit: -1 }));
|
|
21
|
+
await (0, write_to_file_1.default)(`${collection}`, response, `${dir}/content/`);
|
|
26
22
|
}
|
|
27
23
|
catch (error) {
|
|
28
|
-
|
|
29
|
-
core_1.ux.warn(error.message);
|
|
24
|
+
(0, catch_error_1.default)(error);
|
|
30
25
|
}
|
|
31
26
|
}
|
|
32
|
-
exports.getDataFromCollection = getDataFromCollection;
|
|
33
27
|
async function extractContent(dir) {
|
|
34
|
-
|
|
35
|
-
|
|
28
|
+
core_1.ux.action.start(core_1.ux.colorize(constants_1.DIRECTUS_PINK, 'Extracting content'));
|
|
29
|
+
try {
|
|
30
|
+
const collections = await getCollections();
|
|
31
|
+
await Promise.all(collections.map(collection => getDataFromCollection(collection, dir)));
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
(0, catch_error_1.default)(error);
|
|
35
|
+
}
|
|
36
|
+
core_1.ux.action.stop();
|
|
36
37
|
}
|
|
37
38
|
exports.extractContent = extractContent;
|
|
@@ -4,7 +4,9 @@ exports.extractPanels = exports.extractDashboards = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const sdk_1 = require("@directus/sdk");
|
|
6
6
|
const core_1 = require("@oclif/core");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
7
8
|
const sdk_2 = require("../sdk");
|
|
9
|
+
const catch_error_1 = tslib_1.__importDefault(require("../utils/catch-error"));
|
|
8
10
|
const filter_fields_1 = tslib_1.__importDefault(require("../utils/filter-fields"));
|
|
9
11
|
const system_fields_1 = require("../utils/system-fields");
|
|
10
12
|
const write_to_file_1 = tslib_1.__importDefault(require("../utils/write-to-file"));
|
|
@@ -12,31 +14,31 @@ const write_to_file_1 = tslib_1.__importDefault(require("../utils/write-to-file"
|
|
|
12
14
|
* Extract dashboards from the Directus instance
|
|
13
15
|
*/
|
|
14
16
|
async function extractDashboards(dir) {
|
|
17
|
+
core_1.ux.action.start(core_1.ux.colorize(constants_1.DIRECTUS_PINK, 'Extracting dashboards'));
|
|
15
18
|
try {
|
|
16
19
|
const response = await sdk_2.api.client.request((0, sdk_1.readDashboards)({ limit: -1 }));
|
|
17
20
|
const dashboards = (0, filter_fields_1.default)(response, system_fields_1.directusDashboardFields);
|
|
18
21
|
await (0, write_to_file_1.default)('dashboards', dashboards, dir);
|
|
19
|
-
core_1.ux.log('Extracted dashboards');
|
|
20
22
|
}
|
|
21
23
|
catch (error) {
|
|
22
|
-
|
|
23
|
-
core_1.ux.warn(error.message);
|
|
24
|
+
(0, catch_error_1.default)(error);
|
|
24
25
|
}
|
|
26
|
+
core_1.ux.action.stop();
|
|
25
27
|
}
|
|
26
28
|
exports.extractDashboards = extractDashboards;
|
|
27
29
|
/**
|
|
28
30
|
* Extract panels from the Directus instance
|
|
29
31
|
*/
|
|
30
32
|
async function extractPanels(dir) {
|
|
33
|
+
core_1.ux.action.start(core_1.ux.colorize(constants_1.DIRECTUS_PINK, 'Extracting panels'));
|
|
31
34
|
try {
|
|
32
35
|
const response = await sdk_2.api.client.request((0, sdk_1.readPanels)({ limit: -1 }));
|
|
33
36
|
const panels = (0, filter_fields_1.default)(response, system_fields_1.directusPanelFields);
|
|
34
37
|
await (0, write_to_file_1.default)('panels', panels, dir);
|
|
35
|
-
core_1.ux.log('Extracted panels');
|
|
36
38
|
}
|
|
37
39
|
catch (error) {
|
|
38
|
-
|
|
39
|
-
core_1.ux.warn(error.message);
|
|
40
|
+
(0, catch_error_1.default)(error);
|
|
40
41
|
}
|
|
42
|
+
core_1.ux.action.stop();
|
|
41
43
|
}
|
|
42
44
|
exports.extractPanels = extractPanels;
|
|
@@ -3,20 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const sdk_1 = require("@directus/sdk");
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
6
7
|
const sdk_2 = require("../sdk");
|
|
8
|
+
const catch_error_1 = tslib_1.__importDefault(require("../utils/catch-error"));
|
|
7
9
|
const write_to_file_1 = tslib_1.__importDefault(require("../utils/write-to-file"));
|
|
8
10
|
/**
|
|
9
11
|
* Extract extensions from the API
|
|
10
12
|
*/
|
|
11
13
|
async function extractExtensions(dir) {
|
|
14
|
+
core_1.ux.action.start(core_1.ux.colorize(constants_1.DIRECTUS_PINK, 'Extracting extensions'));
|
|
12
15
|
try {
|
|
13
16
|
const response = await sdk_2.api.client.request((0, sdk_1.readExtensions)());
|
|
14
17
|
await (0, write_to_file_1.default)('extensions', response, dir);
|
|
15
|
-
core_1.ux.log('Extracted extensions');
|
|
16
18
|
}
|
|
17
19
|
catch (error) {
|
|
18
|
-
|
|
19
|
-
core_1.ux.warn(error.message);
|
|
20
|
+
(0, catch_error_1.default)(error);
|
|
20
21
|
}
|
|
22
|
+
core_1.ux.action.stop();
|
|
21
23
|
}
|
|
22
24
|
exports.default = extractExtensions;
|
|
@@ -3,12 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
const sdk_1 = require("@directus/sdk");
|
|
5
5
|
const core_1 = require("@oclif/core");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
6
7
|
const sdk_2 = require("../sdk");
|
|
8
|
+
const catch_error_1 = tslib_1.__importDefault(require("../utils/catch-error"));
|
|
7
9
|
const write_to_file_1 = tslib_1.__importDefault(require("../utils/write-to-file"));
|
|
8
10
|
/**
|
|
9
11
|
* Extract fields from the Directus instance
|
|
10
12
|
*/
|
|
11
13
|
async function extractFields(dir) {
|
|
14
|
+
core_1.ux.action.start(core_1.ux.colorize(constants_1.DIRECTUS_PINK, 'Extracting fields'));
|
|
12
15
|
try {
|
|
13
16
|
const response = await sdk_2.api.client.request((0, sdk_1.readFields)());
|
|
14
17
|
if (!Array.isArray(response)) {
|
|
@@ -25,12 +28,10 @@ async function extractFields(dir) {
|
|
|
25
28
|
return i;
|
|
26
29
|
});
|
|
27
30
|
await (0, write_to_file_1.default)('fields', fields, dir);
|
|
28
|
-
core_1.ux.log('Extracted fields');
|
|
29
31
|
}
|
|
30
32
|
catch (error) {
|
|
31
|
-
|
|
32
|
-
core_1.ux.warn(error.message);
|
|
33
|
-
console.error(error);
|
|
33
|
+
(0, catch_error_1.default)(error);
|
|
34
34
|
}
|
|
35
|
+
core_1.ux.action.stop();
|
|
35
36
|
}
|
|
36
37
|
exports.default = extractFields;
|