directus-template-cli 0.7.0-beta.3 → 0.7.0-beta.5

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.
Files changed (93) hide show
  1. package/bin/dev +2 -3
  2. package/bin/dev.js +3 -0
  3. package/bin/run +0 -1
  4. package/bin/run.js +5 -0
  5. package/dist/commands/apply.d.ts +17 -17
  6. package/dist/commands/apply.js +160 -173
  7. package/dist/commands/extract.d.ts +13 -7
  8. package/dist/commands/extract.js +89 -73
  9. package/dist/commands/init.d.ts +7 -7
  10. package/dist/commands/init.js +78 -80
  11. package/dist/flags/common.d.ts +7 -7
  12. package/dist/flags/common.js +8 -11
  13. package/dist/index.js +1 -5
  14. package/dist/lib/constants.js +6 -9
  15. package/dist/lib/extract/extract-access.js +11 -15
  16. package/dist/lib/extract/extract-assets.js +20 -25
  17. package/dist/lib/extract/extract-collections.js +12 -16
  18. package/dist/lib/extract/extract-content.js +14 -19
  19. package/dist/lib/extract/extract-dashboards.js +22 -28
  20. package/dist/lib/extract/extract-extensions.js +12 -16
  21. package/dist/lib/extract/extract-fields.js +13 -17
  22. package/dist/lib/extract/extract-files.js +15 -19
  23. package/dist/lib/extract/extract-flows.js +22 -28
  24. package/dist/lib/extract/extract-folders.js +15 -19
  25. package/dist/lib/extract/extract-permissions.js +12 -16
  26. package/dist/lib/extract/extract-policies.js +12 -16
  27. package/dist/lib/extract/extract-presets.js +12 -16
  28. package/dist/lib/extract/extract-relations.js +14 -18
  29. package/dist/lib/extract/extract-roles.js +15 -19
  30. package/dist/lib/extract/extract-schema.js +17 -21
  31. package/dist/lib/extract/extract-settings.js +12 -16
  32. package/dist/lib/extract/extract-translations.js +12 -16
  33. package/dist/lib/extract/extract-users.js +15 -19
  34. package/dist/lib/extract/index.js +47 -51
  35. package/dist/lib/init/config.d.ts +1 -1
  36. package/dist/lib/init/config.js +2 -5
  37. package/dist/lib/init/index.js +54 -59
  38. package/dist/lib/init/types.js +1 -2
  39. package/dist/lib/init.d.ts +1 -0
  40. package/dist/lib/init.js +2 -0
  41. package/dist/lib/load/apply-flags.js +17 -23
  42. package/dist/lib/load/index.js +40 -44
  43. package/dist/lib/load/load-access.js +15 -20
  44. package/dist/lib/load/load-collections.js +27 -32
  45. package/dist/lib/load/load-dashboards.js +19 -25
  46. package/dist/lib/load/load-data.js +43 -49
  47. package/dist/lib/load/load-extensions.js +30 -38
  48. package/dist/lib/load/load-files.js +20 -24
  49. package/dist/lib/load/load-flows.js +23 -29
  50. package/dist/lib/load/load-folders.js +16 -20
  51. package/dist/lib/load/load-permissions.js +13 -17
  52. package/dist/lib/load/load-policies.js +14 -18
  53. package/dist/lib/load/load-presets.js +14 -18
  54. package/dist/lib/load/load-relations.d.ts +2 -0
  55. package/dist/lib/load/load-relations.js +16 -18
  56. package/dist/lib/load/load-roles.js +19 -23
  57. package/dist/lib/load/load-settings.js +18 -21
  58. package/dist/lib/load/load-translations.js +14 -18
  59. package/dist/lib/load/load-users.js +21 -25
  60. package/dist/lib/load/update-required-fields.js +13 -17
  61. package/dist/lib/sdk.d.ts +1 -2
  62. package/dist/lib/sdk.js +27 -27
  63. package/dist/lib/types/extension.js +1 -2
  64. package/dist/lib/utils/animated-bunny.js +9 -14
  65. package/dist/lib/utils/auth.d.ts +2 -2
  66. package/dist/lib/utils/auth.js +32 -33
  67. package/dist/lib/utils/catch-error.js +8 -11
  68. package/dist/lib/utils/check-template.js +4 -8
  69. package/dist/lib/utils/chunk-array.js +1 -5
  70. package/dist/lib/utils/ensure-dir.js +7 -12
  71. package/dist/lib/utils/filter-fields.js +1 -4
  72. package/dist/lib/utils/get-role-ids.d.ts +1 -1
  73. package/dist/lib/utils/get-role-ids.js +7 -12
  74. package/dist/lib/utils/get-template.js +33 -37
  75. package/dist/lib/utils/logger.js +11 -13
  76. package/dist/lib/utils/open-url.js +5 -8
  77. package/dist/lib/utils/parse-github-url.js +4 -9
  78. package/dist/lib/utils/path.js +6 -10
  79. package/dist/lib/utils/protected-domains.js +1 -4
  80. package/dist/lib/utils/read-file.js +8 -12
  81. package/dist/lib/utils/read-templates.js +9 -15
  82. package/dist/lib/utils/system-fields.js +19 -22
  83. package/dist/lib/utils/template-defaults.d.ts +1 -1
  84. package/dist/lib/utils/template-defaults.js +5 -14
  85. package/dist/lib/utils/transform-github-url.js +1 -5
  86. package/dist/lib/utils/validate-url.js +3 -6
  87. package/dist/lib/utils/wait.js +1 -5
  88. package/dist/lib/utils/write-to-file.js +8 -11
  89. package/dist/services/docker.js +19 -24
  90. package/dist/services/github.d.ts +1 -1
  91. package/dist/services/github.js +8 -12
  92. package/oclif.manifest.json +4 -4
  93. package/package.json +36 -32
package/bin/dev CHANGED
@@ -1,8 +1,7 @@
1
- #!/usr/bin/env node
2
1
 
3
2
  const oclif = require('@oclif/core')
4
3
 
5
- const path = require('path')
4
+ const path = require('node:path')
6
5
  const project = path.join(__dirname, '..', 'tsconfig.json')
7
6
 
8
7
  // In dev mode -> use ts-node and dev plugins
@@ -11,7 +10,7 @@ process.env.NODE_ENV = 'development'
11
10
  require('ts-node').register({project})
12
11
 
13
12
  // In dev mode, always show stack traces
14
- oclif.settings.debug = true;
13
+ oclif.settings.debug = true
15
14
 
16
15
  // Start the CLI
17
16
  oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
package/bin/dev.js ADDED
@@ -0,0 +1,3 @@
1
+ import {execute} from '@oclif/core'
2
+
3
+ await execute({development: true, dir: import.meta.url})
package/bin/run CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
 
3
2
  const oclif = require('@oclif/core')
4
3
 
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {execute} from '@oclif/core'
4
+
5
+ await execute({dir: import.meta.url})
@@ -3,23 +3,23 @@ export default class ApplyCommand extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
6
- content: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
7
- dashboards: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
- directusToken: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
9
- directusUrl: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
10
- extensions: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
11
- files: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
12
- flows: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
13
- partial: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
14
- permissions: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
15
- programmatic: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
16
- schema: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
17
- settings: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
18
- templateLocation: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
19
- templateType: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
20
- userEmail: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
21
- userPassword: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
22
- users: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
6
+ content: import("@oclif/core/interfaces").BooleanFlag<boolean>;
7
+ dashboards: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
+ directusToken: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ directusUrl: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ extensions: import("@oclif/core/interfaces").BooleanFlag<boolean>;
11
+ files: import("@oclif/core/interfaces").BooleanFlag<boolean>;
12
+ flows: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ partial: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ permissions: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ programmatic: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ schema: import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
+ settings: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
+ templateLocation: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
19
+ templateType: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
20
+ userEmail: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
21
+ userPassword: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
22
+ users: import("@oclif/core/interfaces").BooleanFlag<boolean>;
23
23
  };
24
24
  /**
25
25
  * MAIN
@@ -1,19 +1,89 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const core_1 = require("@oclif/core");
5
- const inquirer = tslib_1.__importStar(require("inquirer"));
6
- const path = tslib_1.__importStar(require("node:path"));
7
- const customFlags = tslib_1.__importStar(require("../flags/common"));
8
- const constants_1 = require("../lib/constants");
9
- const apply_flags_1 = require("../lib/load/apply-flags");
10
- const index_js_1 = tslib_1.__importDefault(require("../lib/load/index.js"));
11
- const auth_1 = require("../lib/utils/auth");
12
- const catch_error_1 = tslib_1.__importDefault(require("../lib/utils/catch-error"));
13
- const get_template_1 = require("../lib/utils/get-template");
14
- const logger_1 = require("../lib/utils/logger");
15
- const open_url_1 = tslib_1.__importDefault(require("../lib/utils/open-url"));
16
- class ApplyCommand extends core_1.Command {
1
+ import { Command, Flags, ux } from '@oclif/core';
2
+ import { text, select, password } from '@clack/prompts';
3
+ import * as path from 'pathe';
4
+ import * as customFlags from '../flags/common.js';
5
+ import { DIRECTUS_PINK, SEPARATOR } from '../lib/constants.js';
6
+ import { validateInteractiveFlags, validateProgrammaticFlags } from '../lib/load/apply-flags.js';
7
+ import apply from '../lib/load/index.js';
8
+ import { getDirectusToken, getDirectusUrl, initializeDirectusApi } from '../lib/utils/auth.js';
9
+ import catchError from '../lib/utils/catch-error.js';
10
+ import { getCommunityTemplates, getGithubTemplate, getInteractiveLocalTemplate, getLocalTemplate } from '../lib/utils/get-template.js';
11
+ import { logger } from '../lib/utils/logger.js';
12
+ import openUrl from '../lib/utils/open-url.js';
13
+ export default class ApplyCommand extends Command {
14
+ static description = 'Apply a template to a blank Directus instance.';
15
+ static examples = [
16
+ '$ directus-template-cli apply',
17
+ '$ directus-template-cli apply -p --directusUrl="http://localhost:8055" --directusToken="admin-token-here" --templateLocation="./my-template" --templateType="local"',
18
+ '$ directus-template-cli@beta apply -p --directusUrl="http://localhost:8055" --directusToken="admin-token-here" --templateLocation="./my-template" --templateType="local" --partial --no-content --no-users',
19
+ ];
20
+ static flags = {
21
+ content: Flags.boolean({
22
+ allowNo: true,
23
+ default: undefined,
24
+ description: 'Load Content (data)',
25
+ }),
26
+ dashboards: Flags.boolean({
27
+ allowNo: true,
28
+ default: undefined,
29
+ description: 'Load Dashboards (dashboards, panels)',
30
+ }),
31
+ directusToken: customFlags.directusToken,
32
+ directusUrl: customFlags.directusUrl,
33
+ extensions: Flags.boolean({
34
+ allowNo: true,
35
+ default: undefined,
36
+ description: 'Load Extensions',
37
+ }),
38
+ files: Flags.boolean({
39
+ allowNo: true,
40
+ default: undefined,
41
+ description: 'Load Files (files, folders)',
42
+ }),
43
+ flows: Flags.boolean({
44
+ allowNo: true,
45
+ default: undefined,
46
+ description: 'Load Flows (operations, flows)',
47
+ }),
48
+ partial: Flags.boolean({
49
+ dependsOn: ['programmatic'],
50
+ description: 'Enable partial template application (all components enabled by default)',
51
+ summary: 'Enable partial template application',
52
+ }),
53
+ permissions: Flags.boolean({
54
+ allowNo: true,
55
+ default: undefined,
56
+ description: 'Loads permissions data. Collections include: directus_roles, directus_policies, directus_access, directus_permissions.',
57
+ summary: 'Load permissions (roles, policies, access, permissions)',
58
+ }),
59
+ programmatic: customFlags.programmatic,
60
+ schema: Flags.boolean({
61
+ allowNo: true,
62
+ default: undefined,
63
+ description: 'Load schema (collections, relations)',
64
+ }),
65
+ settings: Flags.boolean({
66
+ allowNo: true,
67
+ default: undefined,
68
+ description: 'Load settings (project settings, translations, presets)',
69
+ }),
70
+ templateLocation: customFlags.templateLocation,
71
+ templateType: Flags.string({
72
+ default: 'local',
73
+ dependsOn: ['programmatic'],
74
+ description: 'Type of template to apply. You can apply templates from our community repo, local directories, or public repositories from Github. Defaults to local. ',
75
+ env: 'TEMPLATE_TYPE',
76
+ options: ['community', 'local', 'github'],
77
+ summary: 'Type of template to apply. Options: community, local, github.',
78
+ }),
79
+ userEmail: customFlags.userEmail,
80
+ userPassword: customFlags.userPassword,
81
+ users: Flags.boolean({
82
+ allowNo: true,
83
+ default: undefined,
84
+ description: 'Load users',
85
+ }),
86
+ };
17
87
  /**
18
88
  * MAIN
19
89
  * Run the command
@@ -31,88 +101,83 @@ class ApplyCommand extends core_1.Command {
31
101
  * @returns {Promise<void>} - Returns nothing
32
102
  */
33
103
  async runInteractive(flags) {
34
- const validatedFlags = (0, apply_flags_1.validateInteractiveFlags)(flags);
35
- core_1.ux.styledHeader(core_1.ux.colorize(constants_1.DIRECTUS_PURPLE, 'Directus Template CLI - Apply'));
36
- const templateType = await inquirer.prompt([
37
- {
38
- choices: [
39
- { name: 'Community templates', value: 'community' },
40
- { name: 'From a local directory', value: 'local' },
41
- { name: 'From a public GitHub repository', value: 'github' },
42
- { name: 'Get premium templates', value: 'directus-plus' },
43
- ],
44
- message: 'What type of template would you like to apply?',
45
- name: 'templateType',
46
- type: 'list',
47
- },
48
- ]);
104
+ const validatedFlags = validateInteractiveFlags(flags);
105
+ // /* TODO: Replace with custom styledHeader function */ ux.styledHeader(ux.colorize(DIRECTUS_PURPLE, 'Directus Template CLI - Apply'))
106
+ const templateType = await select({
107
+ options: [
108
+ { label: 'Community templates', value: 'community' },
109
+ { label: 'From a local directory', value: 'local' },
110
+ { label: 'From a public GitHub repository', value: 'github' },
111
+ { label: 'Get premium templates', value: 'directus-plus' },
112
+ ],
113
+ message: 'What type of template would you like to apply?',
114
+ });
49
115
  let template;
50
- switch (templateType.templateType) {
116
+ switch (templateType) {
51
117
  case 'community': {
52
- const templates = await (0, get_template_1.getCommunityTemplates)();
53
- const { selectedTemplate } = await inquirer.prompt([
54
- {
55
- choices: templates.map(t => ({ name: t.templateName, value: t })),
56
- message: 'Select a template.',
57
- name: 'selectedTemplate',
58
- type: 'list',
59
- },
60
- ]);
118
+ const templates = await getCommunityTemplates();
119
+ const selectedTemplate = await select({
120
+ options: templates.map(t => ({ label: t.templateName, value: t })),
121
+ message: 'Select a template.',
122
+ });
61
123
  template = selectedTemplate;
62
124
  break;
63
125
  }
64
126
  case 'local': {
65
- const localTemplateDir = await core_1.ux.prompt('What is the local template directory?');
127
+ const localTemplateDir = await text({
128
+ message: 'What is the local template directory?',
129
+ });
66
130
  template = await this.selectLocalTemplate(localTemplateDir);
67
131
  break;
68
132
  }
69
133
  case 'github': {
70
- const ghTemplateUrl = await core_1.ux.prompt('What is the public GitHub repository URL?');
71
- template = await (0, get_template_1.getGithubTemplate)(ghTemplateUrl);
134
+ const ghTemplateUrl = await text({
135
+ message: 'What is the public GitHub repository URL?',
136
+ });
137
+ template = await getGithubTemplate(ghTemplateUrl);
72
138
  break;
73
139
  }
74
140
  case 'directus-plus': {
75
- (0, open_url_1.default)('https://directus.io/plus?utm_source=directus-template-cli&utm_content=apply-command');
76
- core_1.ux.log('Redirecting to Directus website.');
77
- core_1.ux.exit(0);
141
+ openUrl('https://directus.io/plus?utm_source=directus-template-cli&utm_content=apply-command');
142
+ ux.stdout('Redirecting to Directus website.');
143
+ ux.exit(0);
78
144
  }
79
145
  }
80
- core_1.ux.log(`You selected ${core_1.ux.colorize(constants_1.DIRECTUS_PINK, template.templateName)}`);
81
- core_1.ux.log(constants_1.SEPARATOR);
146
+ ux.stdout(`You selected ${ux.colorize(DIRECTUS_PINK, template.templateName)}`);
147
+ ux.stdout(SEPARATOR);
82
148
  // Get Directus URL
83
- const directusUrl = await (0, auth_1.getDirectusUrl)();
149
+ const directusUrl = await getDirectusUrl();
84
150
  validatedFlags.directusUrl = directusUrl;
85
151
  // Prompt for login method
86
- const loginMethod = await inquirer.prompt([
87
- {
88
- choices: [
89
- { name: 'Directus Access Token', value: 'token' },
90
- { name: 'Email and Password', value: 'email' },
91
- ],
92
- default: 'token',
93
- message: 'How do you want to log in?',
94
- name: 'loginMethod',
95
- type: 'list',
96
- },
97
- ]);
98
- if (loginMethod.loginMethod === 'token') {
99
- const directusToken = await (0, auth_1.getDirectusToken)(directusUrl);
152
+ const loginMethod = await select({
153
+ options: [
154
+ { label: 'Directus Access Token', value: 'token' },
155
+ { label: 'Email and Password', value: 'email' },
156
+ ],
157
+ message: 'How do you want to log in?',
158
+ });
159
+ if (loginMethod === 'token') {
160
+ const directusToken = await getDirectusToken(directusUrl);
100
161
  validatedFlags.directusToken = directusToken;
101
162
  }
102
163
  else {
103
- const userEmail = await core_1.ux.prompt('What is your email?');
164
+ const userEmail = await text({
165
+ message: 'What is your email?',
166
+ });
104
167
  validatedFlags.userEmail = userEmail;
105
- const userPassword = await core_1.ux.prompt('What is your password?', { type: 'hide' });
168
+ const userPassword = await password({
169
+ message: 'What is your password?',
170
+ });
106
171
  validatedFlags.userPassword = userPassword;
107
172
  }
108
- await (0, auth_1.initializeDirectusApi)(validatedFlags);
173
+ await initializeDirectusApi(validatedFlags);
109
174
  if (template) {
110
- core_1.ux.styledHeader(core_1.ux.colorize(constants_1.DIRECTUS_PURPLE, `Applying template - ${template.templateName} to ${directusUrl}`));
111
- await (0, index_js_1.default)(template.directoryPath, validatedFlags);
112
- core_1.ux.action.stop();
113
- core_1.ux.log(constants_1.SEPARATOR);
114
- core_1.ux.info('Template applied successfully.');
115
- core_1.ux.exit(0);
175
+ // /* TODO: Replace with custom styledHeader function */ ux.styledHeader(ux.colorize(DIRECTUS_PURPLE, `Applying template - ${template.templateName} to ${directusUrl}`))
176
+ await apply(template.directoryPath, validatedFlags);
177
+ ux.action.stop();
178
+ ux.stdout(SEPARATOR);
179
+ ux.stdout('Template applied successfully.');
180
+ ux.exit(0);
116
181
  }
117
182
  }
118
183
  /**
@@ -122,36 +187,36 @@ class ApplyCommand extends core_1.Command {
122
187
  * @returns {Promise<void>} - Returns nothing
123
188
  */
124
189
  async runProgrammatic(flags) {
125
- const validatedFlags = (0, apply_flags_1.validateProgrammaticFlags)(flags);
190
+ const validatedFlags = validateProgrammaticFlags(flags);
126
191
  let template;
127
192
  switch (validatedFlags.templateType) {
128
193
  case 'community': {
129
- const templates = await (0, get_template_1.getCommunityTemplates)();
194
+ const templates = await getCommunityTemplates();
130
195
  template = templates.find(t => t.templateName === validatedFlags.templateLocation) || templates[0];
131
196
  break;
132
197
  }
133
198
  case 'local': {
134
- template = await (0, get_template_1.getLocalTemplate)(validatedFlags.templateLocation);
199
+ template = await getLocalTemplate(validatedFlags.templateLocation);
135
200
  break;
136
201
  }
137
202
  case 'github': {
138
- template = await (0, get_template_1.getGithubTemplate)(validatedFlags.templateLocation);
203
+ template = await getGithubTemplate(validatedFlags.templateLocation);
139
204
  break;
140
205
  }
141
206
  default: {
142
- (0, catch_error_1.default)('Invalid template type. Please check your template type.', {
207
+ catchError('Invalid template type. Please check your template type.', {
143
208
  fatal: true,
144
209
  });
145
210
  }
146
211
  }
147
- await (0, auth_1.initializeDirectusApi)(validatedFlags);
212
+ await initializeDirectusApi(validatedFlags);
148
213
  const logMessage = `Applying template - ${template.templateName} to ${validatedFlags.directusUrl}`;
149
- core_1.ux.styledHeader(logMessage);
150
- logger_1.logger.log('info', logMessage);
151
- await (0, index_js_1.default)(template.directoryPath, validatedFlags);
152
- core_1.ux.action.stop();
153
- core_1.ux.log(constants_1.SEPARATOR);
154
- core_1.ux.info('Template applied successfully.');
214
+ // /* TODO: Replace with custom styledHeader function */ ux.styledHeader(logMessage)
215
+ logger.log('info', logMessage);
216
+ await apply(template.directoryPath, validatedFlags);
217
+ ux.action.stop();
218
+ ux.stdout(SEPARATOR);
219
+ ux.stdout('Template applied successfully.');
155
220
  // ux.exit(0)
156
221
  }
157
222
  /**
@@ -162,104 +227,26 @@ class ApplyCommand extends core_1.Command {
162
227
  */
163
228
  async selectLocalTemplate(localTemplateDir) {
164
229
  try {
165
- const templates = await (0, get_template_1.getInteractiveLocalTemplate)(localTemplateDir);
230
+ const templates = await getInteractiveLocalTemplate(localTemplateDir);
166
231
  if (templates.length === 1) {
167
232
  return templates[0];
168
233
  }
169
- const { selectedTemplate } = await inquirer.prompt([
170
- {
171
- choices: templates.map(t => ({
172
- name: `${t.templateName} (${path.basename(t.directoryPath)})`,
173
- value: t,
174
- })),
175
- message: 'Multiple templates found. Please select one:',
176
- name: 'selectedTemplate',
177
- type: 'list',
178
- },
179
- ]);
234
+ const selectedTemplate = await select({
235
+ options: templates.map(t => ({
236
+ label: `${t.templateName} (${path.basename(t.directoryPath)})`,
237
+ value: t,
238
+ })),
239
+ message: 'Multiple templates found. Please select one:',
240
+ });
180
241
  return selectedTemplate;
181
242
  }
182
243
  catch (error) {
183
244
  if (error instanceof Error) {
184
- core_1.ux.error(error.message);
245
+ ux.error(error.message);
185
246
  }
186
247
  else {
187
- core_1.ux.error('An unknown error occurred while getting the local template.');
248
+ ux.error('An unknown error occurred while getting the local template.');
188
249
  }
189
250
  }
190
251
  }
191
252
  }
192
- ApplyCommand.description = 'Apply a template to a blank Directus instance.';
193
- ApplyCommand.examples = [
194
- '$ directus-template-cli apply',
195
- '$ directus-template-cli apply -p --directusUrl="http://localhost:8055" --directusToken="admin-token-here" --templateLocation="./my-template" --templateType="local"',
196
- '$ directus-template-cli@beta apply -p --directusUrl="http://localhost:8055" --directusToken="admin-token-here" --templateLocation="./my-template" --templateType="local" --partial --no-content --no-users',
197
- ];
198
- ApplyCommand.flags = {
199
- content: core_1.Flags.boolean({
200
- allowNo: true,
201
- default: undefined,
202
- description: 'Load Content (data)',
203
- }),
204
- dashboards: core_1.Flags.boolean({
205
- allowNo: true,
206
- default: undefined,
207
- description: 'Load Dashboards (dashboards, panels)',
208
- }),
209
- directusToken: customFlags.directusToken,
210
- directusUrl: customFlags.directusUrl,
211
- extensions: core_1.Flags.boolean({
212
- allowNo: true,
213
- default: undefined,
214
- description: 'Load Extensions',
215
- }),
216
- files: core_1.Flags.boolean({
217
- allowNo: true,
218
- default: undefined,
219
- description: 'Load Files (files, folders)',
220
- }),
221
- flows: core_1.Flags.boolean({
222
- allowNo: true,
223
- default: undefined,
224
- description: 'Load Flows (operations, flows)',
225
- }),
226
- partial: core_1.Flags.boolean({
227
- dependsOn: ['programmatic'],
228
- description: 'Enable partial template application (all components enabled by default)',
229
- summary: 'Enable partial template application',
230
- }),
231
- permissions: core_1.Flags.boolean({
232
- allowNo: true,
233
- default: undefined,
234
- description: 'Loads permissions data. Collections include: directus_roles, directus_policies, directus_access, directus_permissions.',
235
- summary: 'Load permissions (roles, policies, access, permissions)',
236
- }),
237
- programmatic: customFlags.programmatic,
238
- schema: core_1.Flags.boolean({
239
- allowNo: true,
240
- default: undefined,
241
- description: 'Load schema (collections, relations)',
242
- }),
243
- settings: core_1.Flags.boolean({
244
- allowNo: true,
245
- default: undefined,
246
- description: 'Load settings (project settings, translations, presets)',
247
- }),
248
- templateLocation: customFlags.templateLocation,
249
- templateType: core_1.Flags.string({
250
- default: 'local',
251
- dependsOn: ['programmatic'],
252
- description: 'Type of template to apply. You can apply templates from our community repo, local directories, or public repositories from Github. Defaults to local. ',
253
- env: 'TEMPLATE_TYPE',
254
- options: ['community', 'local', 'github'],
255
- summary: 'Type of template to apply. Options: community, local, github.',
256
- }),
257
- userEmail: customFlags.userEmail,
258
- userPassword: customFlags.userPassword,
259
- users: core_1.Flags.boolean({
260
- allowNo: true,
261
- default: undefined,
262
- description: 'Load users',
263
- }),
264
- };
265
- exports.default = ApplyCommand;
@@ -3,13 +3,13 @@ export default class ExtractCommand extends Command {
3
3
  static description: string;
4
4
  static examples: string[];
5
5
  static flags: {
6
- directusToken: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
- directusUrl: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
8
- programmatic: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
9
- templateLocation: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
10
- templateName: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
11
- userEmail: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
12
- userPassword: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
6
+ directusToken: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ directusUrl: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ programmatic: import("@oclif/core/interfaces").BooleanFlag<boolean>;
9
+ templateLocation: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ templateName: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
11
+ userEmail: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ userPassword: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
13
  };
14
14
  /**
15
15
  * Main run method for the ExtractCommand
@@ -36,6 +36,12 @@ export default class ExtractCommand extends Command {
36
36
  * @returns {Promise<void>} - Returns nothing
37
37
  */
38
38
  private runProgrammatic;
39
+ /**
40
+ * Helper function to create styled headers since ux.styledHeader is removed in v4
41
+ * @param text - The text to style as a header
42
+ * @returns {void}
43
+ */
44
+ private styledHeader;
39
45
  /**
40
46
  * Validates the flags for programmatic mode
41
47
  * @param {ExtractFlags} flags - The command flags to validate