directus-template-cli 0.4.1 → 0.4.2

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.
@@ -8,6 +8,7 @@ const node_path_1 = tslib_1.__importDefault(require("node:path"));
8
8
  const load_1 = tslib_1.__importDefault(require("../lib/load/"));
9
9
  const auth_1 = require("../lib/utils/auth");
10
10
  const log_error_1 = tslib_1.__importDefault(require("../lib/utils/log-error"));
11
+ const open_url_1 = tslib_1.__importDefault(require("../lib/utils/open-url"));
11
12
  const path_1 = tslib_1.__importDefault(require("../lib/utils/path"));
12
13
  const read_templates_1 = require("../lib/utils/read-templates");
13
14
  const transform_github_url_1 = require("../lib/utils/transform-github-url");
@@ -17,17 +18,21 @@ async function getTemplate() {
17
18
  {
18
19
  choices: [
19
20
  {
20
- name: 'Official templates',
21
- value: 'official',
21
+ name: 'Community templates',
22
+ value: 'community',
22
23
  },
23
24
  {
24
25
  name: 'From a local directory',
25
26
  value: 'local',
26
27
  },
27
28
  {
28
- name: 'From a GitHub repository',
29
+ name: 'From a public GitHub repository',
29
30
  value: 'github',
30
31
  },
32
+ {
33
+ name: 'Get premium templates',
34
+ value: 'directus-plus',
35
+ },
31
36
  ],
32
37
  message: 'What type of template would you like to apply?',
33
38
  name: 'templateType',
@@ -35,8 +40,8 @@ async function getTemplate() {
35
40
  },
36
41
  ]);
37
42
  let template;
38
- if (templateType.templateType === 'official') {
39
- // Get official templates
43
+ if (templateType.templateType === 'community') {
44
+ // Get community templates
40
45
  let templates = [];
41
46
  // Resolve the path for downloading
42
47
  const downloadDir = (0, path_1.default)(node_path_1.default.join(__dirname, '..', 'downloads', 'official'), false);
@@ -54,10 +59,10 @@ async function getTemplate() {
54
59
  catch (error) {
55
60
  (0, log_error_1.default)(error, { fatal: true });
56
61
  }
57
- const officialTemplateChoices = templates.map((template) => ({ name: template.templateName, value: template }));
62
+ const communityTemplateChoices = templates.map((template) => ({ name: template.templateName, value: template }));
58
63
  template = await inquirer.prompt([
59
64
  {
60
- choices: officialTemplateChoices,
65
+ choices: communityTemplateChoices,
61
66
  message: 'Select a template.',
62
67
  name: 'template',
63
68
  type: 'list',
@@ -100,23 +105,28 @@ async function getTemplate() {
100
105
  (0, log_error_1.default)(error, { fatal: true });
101
106
  }
102
107
  }
108
+ if (templateType.templateType === 'directus-plus') {
109
+ (0, open_url_1.default)('https://directus.io/plus?utm_source=directus-template-cli&utm_content=apply-command');
110
+ core_1.ux.log('Redirecting to Directus website.');
111
+ core_1.ux.exit(0);
112
+ }
103
113
  return template;
104
114
  }
105
115
  class ApplyCommand extends core_1.Command {
106
116
  async run() {
107
117
  const chosenTemplate = await getTemplate();
108
- this.log(`You selected ${chosenTemplate.template.templateName}`);
109
- this.log(separator);
118
+ core_1.ux.log(`You selected ${chosenTemplate.template.templateName}`);
119
+ core_1.ux.log(separator);
110
120
  const directusUrl = await (0, auth_1.getDirectusUrl)();
111
121
  await (0, auth_1.getDirectusToken)(directusUrl);
112
- this.log(separator);
122
+ core_1.ux.log(separator);
113
123
  // Run load script
114
124
  core_1.ux.log(`Applying template - ${chosenTemplate.template.templateName} to ${directusUrl}`);
115
125
  await (0, load_1.default)(chosenTemplate.template.directoryPath);
116
126
  core_1.ux.action.stop();
117
- this.log(separator);
118
- this.log('Template applied successfully.');
119
- this.exit(0);
127
+ core_1.ux.log(separator);
128
+ core_1.ux.log('Template applied successfully.');
129
+ core_1.ux.exit(0);
120
130
  }
121
131
  }
122
132
  ApplyCommand.description = 'Apply a template to a blank Directus instance.';
@@ -0,0 +1 @@
1
+ export default function openUrl(url: string): void;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const node_child_process_1 = require("node:child_process");
4
+ function openUrl(url) {
5
+ switch (process.platform) {
6
+ case 'darwin': {
7
+ (0, node_child_process_1.exec)(`open ${url}`);
8
+ break;
9
+ }
10
+ case 'win32': {
11
+ (0, node_child_process_1.exec)(`start ${url}`);
12
+ break;
13
+ }
14
+ default: {
15
+ (0, node_child_process_1.exec)(`xdg-open ${url}`);
16
+ }
17
+ }
18
+ }
19
+ exports.default = openUrl;
@@ -47,5 +47,5 @@
47
47
  ]
48
48
  }
49
49
  },
50
- "version": "0.4.1"
50
+ "version": "0.4.2"
51
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "directus-template-cli",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "CLI Utility for applying templates to a Directus instance.",
5
5
  "author": "bryantgillespie @bryantgillespie",
6
6
  "bin": {