directus-template-cli 0.7.0-beta.8 → 0.7.0-beta.9

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.
@@ -2,6 +2,7 @@ import { Command, Flags, ux } from '@oclif/core';
2
2
  import { text, select, password, log, intro } from '@clack/prompts';
3
3
  import * as path from 'pathe';
4
4
  import { animatedBunny } from '../lib/utils/animated-bunny.js';
5
+ import { BSL_LICENSE_TEXT } from '../lib/constants.js';
5
6
  import * as customFlags from '../flags/common.js';
6
7
  import { DIRECTUS_PINK, DIRECTUS_PURPLE, SEPARATOR } from '../lib/constants.js';
7
8
  import { validateInteractiveFlags, validateProgrammaticFlags } from '../lib/load/apply-flags.js';
@@ -179,6 +180,7 @@ export default class ApplyCommand extends Command {
179
180
  await apply(template.directoryPath, validatedFlags);
180
181
  ux.action.stop();
181
182
  ux.stdout(SEPARATOR);
183
+ log.warn(BSL_LICENSE_TEXT);
182
184
  ux.stdout('Template applied successfully.');
183
185
  ux.exit(0);
184
186
  }
@@ -1,11 +1,11 @@
1
- import { text, password, select, intro } from '@clack/prompts';
1
+ import { text, password, select, intro, log } from '@clack/prompts';
2
2
  import { Command, ux } from '@oclif/core';
3
3
  import slugify from '@sindresorhus/slugify';
4
4
  import chalk from 'chalk';
5
5
  import fs from 'node:fs';
6
6
  import path from 'pathe';
7
7
  import * as customFlags from '../flags/common.js';
8
- import { DIRECTUS_PINK, DIRECTUS_PURPLE, SEPARATOR } from '../lib/constants.js';
8
+ import { DIRECTUS_PINK, DIRECTUS_PURPLE, SEPARATOR, BSL_LICENSE_TEXT } from '../lib/constants.js';
9
9
  import { animatedBunny } from '../lib/utils/animated-bunny.js';
10
10
  import extract from '../lib/extract/index.js';
11
11
  import { getDirectusToken, getDirectusUrl, initializeDirectusApi, validateAuthFlags } from '../lib/utils/auth.js';
@@ -65,6 +65,7 @@ export default class ExtractCommand extends Command {
65
65
  ux.action.start(`Extracting template - ${ux.colorize(DIRECTUS_PINK, templateName)} from ${ux.colorize(DIRECTUS_PINK, flags.directusUrl)} to ${ux.colorize(DIRECTUS_PINK, directory)}`);
66
66
  await extract(directory);
67
67
  ux.action.stop();
68
+ log.warn(BSL_LICENSE_TEXT);
68
69
  ux.stdout(SEPARATOR);
69
70
  ux.stdout('Template extracted successfully.');
70
71
  this.exit(0);
@@ -15,3 +15,5 @@ export declare const DEFAULT_REPO: {
15
15
  export declare const POSTHOG_PUBLIC_KEY = "phc_STopE6gj6LDIjYonVF7493kQJK8S4v0Xrl6YPr2z9br";
16
16
  export declare const POSTHOG_HOST = "https://us.i.posthog.com";
17
17
  export declare const DEFAULT_BRANCH = "main";
18
+ export declare const BSL_LICENSE_URL = "https://directus.io/bsl";
19
+ export declare const BSL_LICENSE_TEXT: string;
@@ -1,3 +1,4 @@
1
+ import chalk from 'chalk';
1
2
  export const DIRECTUS_PURPLE = '#6644ff';
2
3
  export const DIRECTUS_PINK = '#FF99DD';
3
4
  export const SEPARATOR = '------------------';
@@ -8,10 +9,12 @@ export const COMMUNITY_TEMPLATE_REPO = {
8
9
  export const DEFAULT_REPO = {
9
10
  owner: 'directus-labs',
10
11
  path: '',
11
- ref: 'cms-template',
12
+ ref: 'main',
12
13
  repo: 'starters',
13
14
  url: 'https://github.com/directus-labs/starters',
14
15
  };
15
16
  export const POSTHOG_PUBLIC_KEY = 'phc_STopE6gj6LDIjYonVF7493kQJK8S4v0Xrl6YPr2z9br';
16
17
  export const POSTHOG_HOST = 'https://us.i.posthog.com';
17
18
  export const DEFAULT_BRANCH = 'main';
19
+ export const BSL_LICENSE_URL = 'https://directus.io/bsl';
20
+ 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. For all organizations and people 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 ${chalk.underline(chalk.cyan(BSL_LICENSE_URL))} for more information or reach out to us at ${chalk.underline(chalk.cyan('sales-demo-with-evil-sales@directus.io'))}.`;
@@ -6,7 +6,7 @@ export const DIRECTUS_CONFIG = {
6
6
  };
7
7
  export const DOCKER_CONFIG = {
8
8
  composeFile: 'docker-compose.yml',
9
- healthCheckEndpoint: '/server/ping',
9
+ healthCheckEndpoint: '/server/info',
10
10
  interval: 3000,
11
11
  maxAttempts: 30,
12
12
  };
@@ -1,4 +1,4 @@
1
- import { note, outro, spinner } from '@clack/prompts';
1
+ import { note, outro, spinner, log as clackLog } from '@clack/prompts';
2
2
  import { ux } from '@oclif/core';
3
3
  import chalk from 'chalk';
4
4
  import { execa } from 'execa';
@@ -14,6 +14,7 @@ import catchError from '../utils/catch-error.js';
14
14
  import { createGigetString, parseGitHubUrl } from '../utils/parse-github-url.js';
15
15
  import { readTemplateConfig } from '../utils/template-config.js';
16
16
  import { DOCKER_CONFIG } from './config.js';
17
+ import { BSL_LICENSE_TEXT } from '../constants.js';
17
18
  export async function init({ dir, flags }) {
18
19
  // Check target directory
19
20
  const shouldForce = flags.overrideDir;
@@ -81,11 +82,15 @@ export async function init({ dir, flags }) {
81
82
  };
82
83
  // Find and copy all .env.example files
83
84
  const envFiles = glob.sync(path.join(dir, '**', '.env.example'));
85
+ // Process all env files first
84
86
  for (const file of envFiles) {
85
87
  const envFile = file.replace('.env.example', '.env');
86
88
  fs.copyFileSync(file, envFile);
87
- // Read default Directus login info from .env
88
- const parsedEnv = dotenv.parse(fs.readFileSync(file, 'utf8'));
89
+ }
90
+ // Then read Directus-specific info only from the Directus env file
91
+ const directusEnvFile = path.join(directusDir, '.env');
92
+ if (fs.existsSync(directusEnvFile)) {
93
+ const parsedEnv = dotenv.parse(fs.readFileSync(directusEnvFile, 'utf8'));
89
94
  directusInfo.email = parsedEnv.ADMIN_EMAIL;
90
95
  directusInfo.password = parsedEnv.ADMIN_PASSWORD;
91
96
  directusInfo.url = parsedEnv.PUBLIC_URL;
@@ -101,8 +106,12 @@ export async function init({ dir, flags }) {
101
106
  }
102
107
  try {
103
108
  await dockerService.startContainers(directusDir);
104
- const healthCheckUrl = `${directusInfo.url}${DOCKER_CONFIG.healthCheckEndpoint}`;
105
- await dockerService.waitForHealthy(healthCheckUrl);
109
+ const healthCheckUrl = `${directusInfo.url || 'http://localhost:8055'}${DOCKER_CONFIG.healthCheckEndpoint}`;
110
+ // Wait for healthy before proceeding
111
+ const isHealthy = await dockerService.waitForHealthy(healthCheckUrl);
112
+ if (!isHealthy) {
113
+ throw new Error('Directus failed to become healthy');
114
+ }
106
115
  const templatePath = path.join(directusDir, 'template');
107
116
  ux.stdout(`Attempting to apply template from: ${templatePath}`);
108
117
  await ApplyCommand.run([
@@ -153,6 +162,7 @@ export async function init({ dir, flags }) {
153
162
  const readmeText = '- Review the \`./README.md\` file for more information and next steps.';
154
163
  const nextSteps = chalk.white(`${directusText}${projectText}${frontendText}${readmeText}`);
155
164
  note(nextSteps, 'Next Steps');
165
+ clackLog.warn(BSL_LICENSE_TEXT);
156
166
  outro(`Problems or questions? Hop into the community on Discord at ${chalk.underline(chalk.cyan('https://directus.chat'))}`);
157
167
  }
158
168
  catch (error) {
@@ -378,5 +378,5 @@
378
378
  ]
379
379
  }
380
380
  },
381
- "version": "0.7.0-beta.8"
381
+ "version": "0.7.0-beta.9"
382
382
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "directus-template-cli",
3
- "version": "0.7.0-beta.8",
3
+ "version": "0.7.0-beta.9",
4
4
  "description": "CLI Utility for applying templates to a Directus instance.",
5
5
  "author": "bryantgillespie @bryantgillespie",
6
6
  "type": "module",