directus-template-cli 0.7.0-beta.1 → 0.7.0-beta.11

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 (106) hide show
  1. package/bin/dev.js +6 -0
  2. package/bin/run.js +5 -0
  3. package/dist/commands/apply.d.ts +17 -17
  4. package/dist/commands/apply.js +165 -173
  5. package/dist/commands/base.d.ts +15 -0
  6. package/dist/commands/base.js +45 -0
  7. package/dist/commands/extract.d.ts +16 -7
  8. package/dist/commands/extract.js +81 -73
  9. package/dist/commands/init.d.ts +21 -15
  10. package/dist/commands/init.js +209 -155
  11. package/dist/flags/common.d.ts +8 -7
  12. package/dist/flags/common.js +13 -11
  13. package/dist/index.js +1 -5
  14. package/dist/lib/constants.d.ts +7 -5
  15. package/dist/lib/constants.js +17 -14
  16. package/dist/lib/extract/extract-access.js +11 -15
  17. package/dist/lib/extract/extract-assets.js +20 -25
  18. package/dist/lib/extract/extract-collections.js +12 -16
  19. package/dist/lib/extract/extract-content.js +14 -19
  20. package/dist/lib/extract/extract-dashboards.js +22 -28
  21. package/dist/lib/extract/extract-extensions.js +12 -16
  22. package/dist/lib/extract/extract-fields.js +13 -17
  23. package/dist/lib/extract/extract-files.js +15 -19
  24. package/dist/lib/extract/extract-flows.js +22 -28
  25. package/dist/lib/extract/extract-folders.js +15 -19
  26. package/dist/lib/extract/extract-permissions.js +12 -16
  27. package/dist/lib/extract/extract-policies.js +12 -16
  28. package/dist/lib/extract/extract-presets.js +12 -16
  29. package/dist/lib/extract/extract-relations.js +14 -18
  30. package/dist/lib/extract/extract-roles.js +15 -19
  31. package/dist/lib/extract/extract-schema.js +17 -21
  32. package/dist/lib/extract/extract-settings.js +12 -16
  33. package/dist/lib/extract/extract-translations.js +12 -16
  34. package/dist/lib/extract/extract-users.js +15 -19
  35. package/dist/lib/extract/index.js +47 -51
  36. package/dist/lib/init/config.d.ts +1 -1
  37. package/dist/lib/init/config.js +4 -7
  38. package/dist/lib/init/index.d.ts +10 -9
  39. package/dist/lib/init/index.js +129 -85
  40. package/dist/lib/init/types.js +1 -2
  41. package/dist/lib/load/apply-flags.js +17 -23
  42. package/dist/lib/load/index.d.ts +1 -12
  43. package/dist/lib/load/index.js +40 -44
  44. package/dist/lib/load/load-access.js +15 -20
  45. package/dist/lib/load/load-collections.js +27 -32
  46. package/dist/lib/load/load-dashboards.js +19 -25
  47. package/dist/lib/load/load-data.js +43 -49
  48. package/dist/lib/load/load-extensions.js +30 -38
  49. package/dist/lib/load/load-files.js +20 -24
  50. package/dist/lib/load/load-flows.js +23 -29
  51. package/dist/lib/load/load-folders.js +16 -20
  52. package/dist/lib/load/load-permissions.js +13 -17
  53. package/dist/lib/load/load-policies.js +14 -18
  54. package/dist/lib/load/load-presets.js +14 -18
  55. package/dist/lib/load/load-relations.d.ts +2 -0
  56. package/dist/lib/load/load-relations.js +16 -18
  57. package/dist/lib/load/load-roles.js +19 -23
  58. package/dist/lib/load/load-settings.js +18 -21
  59. package/dist/lib/load/load-translations.js +14 -18
  60. package/dist/lib/load/load-users.js +21 -25
  61. package/dist/lib/load/update-required-fields.js +13 -17
  62. package/dist/lib/sdk.d.ts +1 -2
  63. package/dist/lib/sdk.js +27 -27
  64. package/dist/lib/types/extension.js +1 -2
  65. package/dist/lib/types.d.ts +18 -0
  66. package/dist/lib/types.js +1 -0
  67. package/dist/lib/utils/animated-bunny.d.ts +2 -0
  68. package/dist/lib/utils/animated-bunny.js +62 -0
  69. package/dist/lib/utils/auth.d.ts +8 -6
  70. package/dist/lib/utils/auth.js +48 -39
  71. package/dist/lib/utils/catch-error.js +8 -11
  72. package/dist/lib/utils/check-template.js +4 -8
  73. package/dist/lib/utils/chunk-array.js +1 -5
  74. package/dist/lib/utils/ensure-dir.js +7 -12
  75. package/dist/lib/utils/filter-fields.js +1 -4
  76. package/dist/lib/utils/get-role-ids.d.ts +1 -1
  77. package/dist/lib/utils/get-role-ids.js +7 -12
  78. package/dist/lib/utils/get-template.js +33 -37
  79. package/dist/lib/utils/logger.js +11 -13
  80. package/dist/lib/utils/open-url.js +5 -8
  81. package/dist/lib/utils/parse-github-url.d.ts +10 -5
  82. package/dist/lib/utils/parse-github-url.js +80 -45
  83. package/dist/lib/utils/path.js +6 -10
  84. package/dist/lib/utils/protected-domains.js +1 -4
  85. package/dist/lib/utils/read-file.js +8 -12
  86. package/dist/lib/utils/read-templates.js +9 -15
  87. package/dist/lib/utils/sanitize-flags.d.ts +3 -0
  88. package/dist/lib/utils/sanitize-flags.js +4 -0
  89. package/dist/lib/utils/system-fields.js +19 -22
  90. package/dist/lib/utils/template-config.d.ts +16 -0
  91. package/dist/lib/utils/template-config.js +34 -0
  92. package/dist/lib/utils/template-defaults.d.ts +1 -1
  93. package/dist/lib/utils/template-defaults.js +5 -14
  94. package/dist/lib/utils/transform-github-url.js +1 -5
  95. package/dist/lib/utils/validate-url.js +3 -6
  96. package/dist/lib/utils/wait.js +1 -5
  97. package/dist/lib/utils/write-to-file.js +8 -11
  98. package/dist/services/docker.js +82 -29
  99. package/dist/services/github.d.ts +1 -1
  100. package/dist/services/github.js +53 -22
  101. package/dist/services/posthog.d.ts +37 -0
  102. package/dist/services/posthog.js +104 -0
  103. package/oclif.manifest.json +32 -13
  104. package/package.json +41 -31
  105. package/bin/dev +0 -17
  106. package/bin/run +0 -5
@@ -1,16 +1,60 @@
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_1 = tslib_1.__importDefault(require("inquirer"));
6
- const node_path_1 = tslib_1.__importDefault(require("node:path"));
7
- const init_1 = require("../lib/init");
8
- const github_1 = require("../services/github");
9
- class InitCommand extends core_1.Command {
10
- constructor() {
11
- super(...arguments);
12
- this.targetDir = '.';
13
- }
1
+ import { confirm, intro, select, text, isCancel, cancel, log as clackLog } from '@clack/prompts';
2
+ import { Args, Flags, ux } from '@oclif/core';
3
+ import chalk from 'chalk';
4
+ import fs from 'node:fs';
5
+ import os from 'node:os';
6
+ import path from 'pathe';
7
+ import { disableTelemetry } from '../flags/common.js';
8
+ import { DIRECTUS_PURPLE } from '../lib/constants.js';
9
+ import { init } from '../lib/init/index.js';
10
+ import { animatedBunny } from '../lib/utils/animated-bunny.js';
11
+ import { createGitHub } from '../services/github.js';
12
+ import { readTemplateConfig } from '../lib/utils/template-config.js';
13
+ import { createGigetString, parseGitHubUrl } from '../lib/utils/parse-github-url.js';
14
+ import { downloadTemplate } from 'giget';
15
+ import { BaseCommand } from './base.js';
16
+ import { track, shutdown } from '../services/posthog.js';
17
+ export default class InitCommand extends BaseCommand {
18
+ static args = {
19
+ directory: Args.directory({
20
+ default: '.',
21
+ description: 'Directory to create the project in',
22
+ required: false,
23
+ }),
24
+ };
25
+ static description = 'Initialize a new Directus + Frontend monorepo using official or community starters.';
26
+ static examples = [
27
+ '$ directus-template-cli init',
28
+ '$ directus-template-cli init my-project',
29
+ '$ directus-template-cli init --frontend=nextjs --template=simple-cms',
30
+ '$ directus-template-cli init my-project --frontend=nextjs --template=simple-cms',
31
+ ];
32
+ static flags = {
33
+ frontend: Flags.string({
34
+ description: 'Frontend framework to use (e.g., nextjs, nuxt, astro)',
35
+ }),
36
+ gitInit: Flags.boolean({
37
+ aliases: ['git-init'],
38
+ allowNo: true,
39
+ default: true,
40
+ description: 'Initialize a new Git repository',
41
+ }),
42
+ installDeps: Flags.boolean({
43
+ aliases: ['install-deps'],
44
+ allowNo: true,
45
+ default: true,
46
+ description: 'Install dependencies automatically',
47
+ }),
48
+ overrideDir: Flags.boolean({
49
+ default: false,
50
+ description: 'Override the default directory',
51
+ }),
52
+ template: Flags.string({
53
+ description: 'Template name (e.g., simple-cms) or GitHub URL (e.g., https://github.com/directus-labs/starters/tree/main/simple-cms)',
54
+ }),
55
+ disableTelemetry: disableTelemetry,
56
+ };
57
+ targetDir = '.';
14
58
  /**
15
59
  * Entrypoint for the command.
16
60
  * @returns Promise that resolves when the command is complete.
@@ -18,175 +62,185 @@ class InitCommand extends core_1.Command {
18
62
  async run() {
19
63
  const { args, flags } = await this.parse(InitCommand);
20
64
  const typedFlags = flags;
65
+ const typedArgs = args;
21
66
  // Set the target directory and create it if it doesn't exist
22
- this.targetDir = node_path_1.default.resolve(args.directory);
23
- // if (!fs.existsSync(this.targetDir)) {
24
- // fs.mkdirSync(this.targetDir, {recursive: true})
25
- // }
26
- await (typedFlags.programmatic ? this.runProgrammatic(typedFlags) : this.runInteractive(typedFlags));
67
+ this.targetDir = path.resolve(args.directory);
68
+ await this.runInteractive(typedFlags, typedArgs);
27
69
  }
28
70
  /**
29
71
  * Interactive mode: prompts the user for each piece of info, with added template checks.
30
72
  * @param flags - The flags passed to the command.
73
+ * @param args - The arguments passed to the command.
31
74
  * @returns void
32
75
  */
33
- async runInteractive(flags) {
34
- core_1.ux.styledHeader('Directus Template CLI - Init');
76
+ async runInteractive(flags, args) {
77
+ // Show animated intro
78
+ await animatedBunny('Let\'s create a new Directus project!');
79
+ intro(`${chalk.bgHex(DIRECTUS_PURPLE).white.bold('Directus Template CLI')} - Create Project`);
35
80
  // Create GitHub service
36
- const github = (0, github_1.createGitHub)();
81
+ const github = createGitHub();
82
+ // If no dir is provided, ask for it
83
+ if (!args.directory || args.directory === '.') {
84
+ let dirResponse = await text({
85
+ message: 'Enter the directory to create the project in:',
86
+ placeholder: './my-directus-project',
87
+ });
88
+ if (isCancel(dirResponse)) {
89
+ cancel('Project creation cancelled.');
90
+ process.exit(0);
91
+ }
92
+ // If there's no response, set a default
93
+ if (!dirResponse) {
94
+ clackLog.warn('No directory provided, using default: ./my-directus-project');
95
+ dirResponse = './my-directus-project';
96
+ }
97
+ this.targetDir = dirResponse;
98
+ }
99
+ if (fs.existsSync(this.targetDir) && !flags.overrideDir) {
100
+ const overrideDirResponse = await confirm({
101
+ message: 'Directory already exists. Would you like to overwrite it?',
102
+ });
103
+ if (isCancel(overrideDirResponse)) {
104
+ cancel('Project creation cancelled.');
105
+ process.exit(0);
106
+ }
107
+ if (overrideDirResponse) {
108
+ flags.overrideDir = true;
109
+ }
110
+ }
37
111
  // 1. Fetch available templates
38
112
  const availableTemplates = await github.getTemplates();
39
113
  // 2. Prompt for template if not provided
40
114
  let { template } = flags;
41
115
  if (!template) {
42
- template = await inquirer_1.default
43
- .prompt([
44
- {
45
- choices: availableTemplates,
46
- message: 'Which Directus starters template would you like to use?',
47
- name: 'template',
48
- type: 'list',
49
- },
50
- ])
51
- .then(ans => ans.template);
116
+ const templateResponse = await select({
117
+ message: 'Which Directus backend template would you like to use?',
118
+ options: availableTemplates.map(template => ({
119
+ label: template,
120
+ value: template,
121
+ })),
122
+ });
123
+ if (isCancel(templateResponse)) {
124
+ cancel('Project creation cancelled.');
125
+ process.exit(0);
126
+ }
127
+ template = templateResponse;
52
128
  }
53
129
  // 3. Validate that the template exists, fetch subdirectories
54
130
  let directories = await github.getTemplateDirectories(template);
55
- while (directories.length === 0) {
131
+ const isDirectUrl = template?.startsWith('http');
132
+ while (!isDirectUrl && directories.length === 0) {
56
133
  this.log(`Template "${template}" doesn't seem to exist in directus-labs/directus-starters.`);
57
- template = await core_1.ux.prompt('Please enter a valid template name, or Ctrl+C to cancel:');
134
+ const templateNameResponse = await text({
135
+ message: 'Please enter a valid template name, or Ctrl+C to cancel:',
136
+ });
137
+ if (isCancel(templateNameResponse)) {
138
+ cancel('Project creation cancelled.');
139
+ process.exit(0);
140
+ }
141
+ template = templateNameResponse;
58
142
  directories = await github.getTemplateDirectories(template);
59
143
  }
60
144
  flags.template = template;
61
- // Filter out the 'directus' folder; the rest are potential frontends
62
- const potentialFrontends = directories.filter(dir => dir !== 'directus');
63
- if (potentialFrontends.length === 0) {
64
- this.error(`No frontends found for template "${template}". Exiting.`);
65
- }
66
- // 4. If user hasn't specified a valid flags.frontend, ask from the list
145
+ // Download the template to a temporary directory to read its configuration
146
+ const tempDir = path.join(os.tmpdir(), `directus-template-${Date.now()}`);
67
147
  let chosenFrontend = flags.frontend;
68
- if (!chosenFrontend || !potentialFrontends.includes(chosenFrontend)) {
69
- chosenFrontend = await inquirer_1.default
70
- .prompt([
71
- {
72
- choices: potentialFrontends,
148
+ try {
149
+ await downloadTemplate(createGigetString(parseGitHubUrl(template)), {
150
+ dir: tempDir,
151
+ force: true,
152
+ });
153
+ // Read template configuration
154
+ const templateInfo = readTemplateConfig(tempDir);
155
+ // 4. If template has frontends and user hasn't specified a valid one, ask from the list
156
+ if (templateInfo?.frontendOptions.length > 0 && (!chosenFrontend || !templateInfo.frontendOptions.find(f => f.id === chosenFrontend))) {
157
+ const frontendResponse = await select({
73
158
  message: 'Which frontend framework do you want to use?',
74
- name: 'chosenFrontend',
75
- type: 'list',
76
- },
77
- ])
78
- .then(ans => ans.chosenFrontend);
159
+ options: [
160
+ ...templateInfo.frontendOptions.map(frontend => ({
161
+ label: frontend.name,
162
+ value: frontend.id,
163
+ })),
164
+ // { label: 'No frontend', value: '' },
165
+ ],
166
+ });
167
+ if (isCancel(frontendResponse)) {
168
+ cancel('Project creation cancelled.');
169
+ process.exit(0);
170
+ }
171
+ chosenFrontend = frontendResponse;
172
+ }
173
+ flags.frontend = chosenFrontend;
79
174
  }
80
- flags.frontend = chosenFrontend;
81
- // 5. Continue with the rest of the interactive flow:
82
- // if (!this.checkDockerInstalled()) {
83
- // const {installDocker} = await inquirer.prompt<{ installDocker: boolean }>([
84
- // {
85
- // default: false,
86
- // message: 'Docker is not installed. Do you want to install Docker?',
87
- // name: 'installDocker',
88
- // type: 'confirm',
89
- // },
90
- // ])
91
- // if (installDocker) {
92
- // ux.log('Please follow Docker\'s official instructions to install Docker, then re-run the init command.')
93
- // this.exit(0)
94
- // }
95
- // }
96
- const { installDeps } = await inquirer_1.default.prompt([
97
- {
98
- default: true,
99
- message: 'Would you like to install project dependencies automatically?',
100
- name: 'installDeps',
101
- type: 'confirm',
102
- },
103
- ]);
104
- const { initGit } = await inquirer_1.default.prompt([
105
- {
106
- default: true,
107
- message: 'Initialize a new Git repository?',
108
- name: 'initGit',
109
- type: 'confirm',
110
- },
111
- ]);
112
- await (0, init_1.init)(this.targetDir, {
113
- frontend: chosenFrontend,
114
- gitInit: initGit,
115
- installDeps,
116
- template,
117
- });
118
- }
119
- /**
120
- * Programmatic mode: relies on flags only, with checks for template existence and valid frontend.
121
- * @param flags - The flags passed to the command.
122
- * @returns void
123
- */
124
- async runProgrammatic(flags) {
125
- const github = (0, github_1.createGitHub)();
126
- if (!flags.template) {
127
- core_1.ux.error('Missing --template parameter for programmatic mode.');
175
+ finally {
176
+ // Clean up temporary directory
177
+ if (fs.existsSync(tempDir)) {
178
+ fs.rmSync(tempDir, { recursive: true, force: true });
179
+ }
128
180
  }
129
- if (!flags.frontend) {
130
- core_1.ux.error('Missing --frontend parameter for programmatic mode.');
181
+ const installDepsResponse = await confirm({
182
+ initialValue: true,
183
+ message: 'Would you like to install project dependencies automatically?',
184
+ });
185
+ if (isCancel(installDepsResponse)) {
186
+ cancel('Project creation cancelled.');
187
+ process.exit(0);
131
188
  }
132
- const template = flags.template;
133
- const directories = await github.getTemplateDirectories(template);
134
- if (directories.length === 0) {
135
- core_1.ux.error(`Template "${template}" doesn't seem to exist in directus-labs/directus-starters.`);
189
+ const installDeps = installDepsResponse;
190
+ const initGitResponse = await confirm({
191
+ initialValue: true,
192
+ message: 'Initialize a new Git repository?',
193
+ });
194
+ if (isCancel(initGitResponse)) {
195
+ cancel('Project creation cancelled.');
196
+ process.exit(0);
136
197
  }
137
- const potentialFrontends = directories.filter(dir => dir !== 'directus');
138
- const frontend = flags.frontend;
139
- if (!potentialFrontends.includes(frontend)) {
140
- core_1.ux.error(`Frontend "${frontend}" doesn't exist in template "${template}". Available frontends: ${potentialFrontends.join(', ')}`);
198
+ const initGit = initGitResponse;
199
+ // Track the command start unless telemetry is disabled
200
+ if (!flags.disableTelemetry) {
201
+ await track({
202
+ lifecycle: 'start',
203
+ distinctId: this.userConfig.distinctId,
204
+ command: 'init',
205
+ flags: {
206
+ frontend: chosenFrontend,
207
+ gitInit: initGit,
208
+ installDeps,
209
+ template,
210
+ },
211
+ runId: this.runId,
212
+ config: this.config,
213
+ });
141
214
  }
142
- await (0, init_1.init)(this.targetDir, {
143
- frontend,
144
- installDeps: true,
145
- template,
215
+ // Initialize the project
216
+ await init({
217
+ dir: this.targetDir,
218
+ flags: {
219
+ frontend: chosenFrontend,
220
+ gitInit: initGit,
221
+ installDeps,
222
+ template,
223
+ overrideDir: flags.overrideDir,
224
+ },
146
225
  });
226
+ // Track the command completion unless telemetry is disabled
227
+ if (!flags.disableTelemetry) {
228
+ await track({
229
+ command: 'init',
230
+ lifecycle: 'complete',
231
+ distinctId: this.userConfig.distinctId,
232
+ flags: {
233
+ frontend: chosenFrontend,
234
+ gitInit: initGit,
235
+ installDeps,
236
+ template,
237
+ overrideDir: flags.overrideDir,
238
+ },
239
+ runId: this.runId,
240
+ config: this.config,
241
+ });
242
+ await shutdown();
243
+ }
244
+ ux.exit(0);
147
245
  }
148
246
  }
149
- InitCommand.args = {
150
- directory: core_1.Args.directory({
151
- default: '.',
152
- description: 'Directory to create the project in',
153
- required: false,
154
- }),
155
- };
156
- InitCommand.description = 'Initialize a new Directus + Frontend monorepo using official or community starters.';
157
- InitCommand.examples = [
158
- '$ directus-template-cli init',
159
- '$ directus-template-cli init my-project',
160
- '$ directus-template-cli init --frontend=nextjs --template=simple-cms --programmatic',
161
- '$ directus-template-cli init my-project --frontend=nextjs --template=simple-cms --programmatic',
162
- ];
163
- InitCommand.flags = {
164
- frontend: core_1.Flags.string({
165
- description: 'Frontend framework to use (e.g., nextjs, nuxt, astro)',
166
- }),
167
- gitInit: core_1.Flags.boolean({
168
- aliases: ['git-init'],
169
- allowNo: true,
170
- default: true,
171
- description: 'Initialize a new Git repository',
172
- }),
173
- installDeps: core_1.Flags.boolean({
174
- aliases: ['install-deps'],
175
- allowNo: true,
176
- default: true,
177
- description: 'Install dependencies automatically',
178
- }),
179
- overrideDir: core_1.Flags.boolean({
180
- default: false,
181
- description: 'Override the default directory',
182
- }),
183
- programmatic: core_1.Flags.boolean({
184
- char: 'p',
185
- default: false,
186
- description: 'Run in programmatic mode (non-interactive)',
187
- }),
188
- template: core_1.Flags.string({
189
- description: 'Template name (e.g., simple-cms) or GitHub URL (e.g., https://github.com/directus-labs/starters/tree/main/simple-cms)',
190
- }),
191
- };
192
- exports.default = InitCommand;
@@ -1,7 +1,8 @@
1
- export declare const directusToken: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
2
- export declare const directusUrl: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
3
- export declare const userEmail: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
4
- export declare const userPassword: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
5
- export declare const programmatic: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
6
- export declare const templateLocation: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
7
- export declare const templateName: import("@oclif/core/lib/interfaces").OptionFlag<string, import("@oclif/core/lib/interfaces").CustomOptions>;
1
+ export declare const directusToken: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
2
+ export declare const directusUrl: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
3
+ export declare const userEmail: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
4
+ export declare const userPassword: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
5
+ export declare const programmatic: import("@oclif/core/interfaces").BooleanFlag<boolean>;
6
+ export declare const templateLocation: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
+ export declare const templateName: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
8
+ export declare const disableTelemetry: import("@oclif/core/interfaces").BooleanFlag<boolean>;
@@ -1,41 +1,43 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.templateName = exports.templateLocation = exports.programmatic = exports.userPassword = exports.userEmail = exports.directusUrl = exports.directusToken = void 0;
4
- const core_1 = require("@oclif/core");
5
- exports.directusToken = core_1.Flags.string({
1
+ import { Flags } from '@oclif/core';
2
+ export const directusToken = Flags.string({
6
3
  description: 'Token to use for the Directus instance',
7
4
  env: 'DIRECTUS_TOKEN',
8
5
  exclusive: ['userEmail', 'userPassword'],
9
6
  });
10
- exports.directusUrl = core_1.Flags.string({
7
+ export const directusUrl = Flags.string({
11
8
  description: 'URL of the Directus instance',
12
9
  env: 'DIRECTUS_URL',
13
10
  });
14
- exports.userEmail = core_1.Flags.string({
11
+ export const userEmail = Flags.string({
15
12
  dependsOn: ['userPassword'],
16
13
  description: 'Email for Directus authentication',
17
14
  env: 'DIRECTUS_EMAIL',
18
15
  exclusive: ['directusToken'],
19
16
  });
20
- exports.userPassword = core_1.Flags.string({
17
+ export const userPassword = Flags.string({
21
18
  dependsOn: ['userEmail'],
22
19
  description: 'Password for Directus authentication',
23
20
  env: 'DIRECTUS_PASSWORD',
24
21
  exclusive: ['directusToken'],
25
22
  });
26
- exports.programmatic = core_1.Flags.boolean({
23
+ export const programmatic = Flags.boolean({
27
24
  char: 'p',
28
25
  default: false,
29
26
  description: 'Run in programmatic mode (non-interactive) for use cases such as CI/CD pipelines.',
30
27
  summary: 'Run in programmatic mode',
31
28
  });
32
- exports.templateLocation = core_1.Flags.string({
29
+ export const templateLocation = Flags.string({
33
30
  dependsOn: ['programmatic'],
34
31
  description: 'Location of the template',
35
32
  env: 'TEMPLATE_LOCATION',
36
33
  });
37
- exports.templateName = core_1.Flags.string({
34
+ export const templateName = Flags.string({
38
35
  dependsOn: ['programmatic'],
39
36
  description: 'Name of the template',
40
37
  env: 'TEMPLATE_NAME',
41
38
  });
39
+ export const disableTelemetry = Flags.boolean({
40
+ default: false,
41
+ description: 'Disable telemetry',
42
+ env: 'DISABLE_TELEMETRY',
43
+ });
package/dist/index.js CHANGED
@@ -1,5 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = void 0;
4
- var core_1 = require("@oclif/core");
5
- Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
1
+ export { run } from '@oclif/core';
@@ -1,15 +1,12 @@
1
1
  export declare const DIRECTUS_PURPLE = "#6644ff";
2
2
  export declare const DIRECTUS_PINK = "#FF99DD";
3
3
  export declare const SEPARATOR = "------------------";
4
+ export declare const pinkText: import("chalk").ChalkInstance;
5
+ export declare const purpleText: import("chalk").ChalkInstance;
4
6
  export declare const COMMUNITY_TEMPLATE_REPO: {
5
7
  string: string;
6
8
  url: string;
7
9
  };
8
- export declare const STARTERS_TEMPLATE_REPO: {
9
- branch: string;
10
- string: string;
11
- url: string;
12
- };
13
10
  export declare const DEFAULT_REPO: {
14
11
  owner: string;
15
12
  path: string;
@@ -17,3 +14,8 @@ export declare const DEFAULT_REPO: {
17
14
  repo: string;
18
15
  url: string;
19
16
  };
17
+ export declare const POSTHOG_PUBLIC_KEY = "phc_STopE6gj6LDIjYonVF7493kQJK8S4v0Xrl6YPr2z9br";
18
+ export declare const POSTHOG_HOST = "https://us.i.posthog.com";
19
+ export declare const DEFAULT_BRANCH = "main";
20
+ export declare const BSL_LICENSE_URL = "https://directus.io/bsl";
21
+ export declare const BSL_LICENSE_TEXT: string;
@@ -1,22 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_REPO = exports.STARTERS_TEMPLATE_REPO = exports.COMMUNITY_TEMPLATE_REPO = exports.SEPARATOR = exports.DIRECTUS_PINK = exports.DIRECTUS_PURPLE = void 0;
4
- exports.DIRECTUS_PURPLE = '#6644ff';
5
- exports.DIRECTUS_PINK = '#FF99DD';
6
- exports.SEPARATOR = '------------------';
7
- exports.COMMUNITY_TEMPLATE_REPO = {
1
+ import chalk from 'chalk';
2
+ import terminalLink from 'terminal-link';
3
+ export const DIRECTUS_PURPLE = '#6644ff';
4
+ export const DIRECTUS_PINK = '#FF99DD';
5
+ export const SEPARATOR = '------------------';
6
+ export const pinkText = chalk.hex(DIRECTUS_PINK);
7
+ export const purpleText = chalk.hex(DIRECTUS_PURPLE);
8
+ export const COMMUNITY_TEMPLATE_REPO = {
8
9
  string: 'github:directus-labs/directus-templates',
9
10
  url: 'https://github.com/directus-labs/directus-templates',
10
11
  };
11
- exports.STARTERS_TEMPLATE_REPO = {
12
- branch: 'cms-template',
13
- string: 'github:directus-labs/starters',
14
- url: 'https://github.com/directus-labs/starters',
15
- };
16
- exports.DEFAULT_REPO = {
12
+ export const DEFAULT_REPO = {
17
13
  owner: 'directus-labs',
18
14
  path: '',
19
- ref: 'cms-template',
15
+ ref: 'main',
20
16
  repo: 'starters',
21
17
  url: 'https://github.com/directus-labs/starters',
22
18
  };
19
+ export const POSTHOG_PUBLIC_KEY = 'phc_STopE6gj6LDIjYonVF7493kQJK8S4v0Xrl6YPr2z9br';
20
+ export const POSTHOG_HOST = 'https://us.i.posthog.com';
21
+ export const DEFAULT_BRANCH = 'main';
22
+ export const BSL_LICENSE_URL = 'https://directus.io/bsl';
23
+ const BSL_LINK = terminalLink(BSL_LICENSE_URL, BSL_LICENSE_URL);
24
+ const BSL_MAILTO = terminalLink('sales-demo-with-evil-sales@directus.io', 'mailto:sales-demo-with-evil-sales@directus.io');
25
+ export const BSL_LICENSE_TEXT = `You REQUIRE a license to use Directus if your organisation has more than $5MM USD a year in revenue and/or funding.\nFor all organizations with less than $5MM USD a year in revenue and funding, Directus is free for personal projects, hobby projects and in production. This second group does not require a license. \nDirectus is licensed under BSL1.1. Visit ${pinkText(BSL_LINK)} for more information or reach out to us at ${pinkText(BSL_MAILTO)}.`;
@@ -1,15 +1,12 @@
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 constants_1 = require("../constants");
6
- const sdk_1 = require("../sdk");
7
- const catch_error_1 = tslib_1.__importDefault(require("../utils/catch-error"));
8
- const write_to_file_1 = tslib_1.__importDefault(require("../utils/write-to-file"));
9
- async function extractAccess(dir) {
10
- core_1.ux.action.start(core_1.ux.colorize(constants_1.DIRECTUS_PINK, 'Extracting access'));
1
+ import { ux } from '@oclif/core';
2
+ import { DIRECTUS_PINK } from '../constants.js';
3
+ import { api } from '../sdk.js';
4
+ import catchError from '../utils/catch-error.js';
5
+ import writeToFile from '../utils/write-to-file.js';
6
+ export default async function extractAccess(dir) {
7
+ ux.action.start(ux.colorize(DIRECTUS_PINK, 'Extracting access'));
11
8
  try {
12
- const response = await sdk_1.api.client.request(() => ({
9
+ const response = await api.client.request(() => ({
13
10
  method: 'GET',
14
11
  path: '/access?limit=-1',
15
12
  }));
@@ -17,11 +14,10 @@ async function extractAccess(dir) {
17
14
  // for (const access of response) {
18
15
  // delete access.id
19
16
  // }
20
- await (0, write_to_file_1.default)('access', response, dir);
17
+ await writeToFile('access', response, dir);
21
18
  }
22
19
  catch (error) {
23
- (0, catch_error_1.default)(error);
20
+ catchError(error);
24
21
  }
25
- core_1.ux.action.stop();
22
+ ux.action.stop();
26
23
  }
27
- exports.default = extractAccess;