create-directus-docker 1.0.7 → 1.0.8

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/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2023 Dave Kobrenski <dave@rlmg.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
17
+ DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
18
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
19
+ OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,51 +1,44 @@
1
- ## Docker with Directus / MySQL / Adminer / GraphQL
1
+ # Docker with Directus + MySQL + Adminer + GraphiQL
2
2
 
3
- This package contains everything you need to get up and running with Directus CMS with a MySQL backend, plus an interactive GraphQL playground to help you develop your API queries.
3
+ A quick-start installer and launcher for Docker compose, containing Directus with MySQL, an Adminer UI for managing the database, and a GraphiQL playground. Plus a helper app to walk you through initializing environment variables and launching all services.
4
4
 
5
- **Before you do anything else**, you need [Docker](https://www.docker.com) and [Node](https://nodejs.org) installed on your machine:
5
+ ## Installation & Usage
6
6
 
7
- - [Install Docker Desktop](https://www.docker.com/products/docker-desktop/)
8
- - [Install Node](https://nodejs.org/en/download/)
9
-
10
- Once you've installed Node and Docker, and have Docker Desktop running on your machine, you can install and configure this package by following these steps:
7
+ ```bash
8
+ npx create-directus-docker@latest <my-project>
9
+ ```
11
10
 
12
- 1. Open a terminal session:
13
- **Mac:** Go to /Applications/Utilities then double-click Terminal.
14
- **Windows:** Click 'Start' taskbar button, Select 'All apps', scroll down and select 'Terminal'
15
- 2. CD into the parent directory where you'd like to install this, ie `cd '~/Documents/My-Folder'`.
16
- 3. From there, run:
17
- `git clone https://github.com/rollmug/directus-mysql-template.git`
18
- OR, if you don't have git installed, [manually download it here](https://github.com/rollmug/directus-mysql-template/archive/refs/heads/main.zip) and unzip it.
19
- 4. Navigate into the folder you just downloaded, ie `cd 'directus-mysql-template'`
11
+ Once installed, simply run:
20
12
 
21
- **Configure your Directus/MySQL setup:**
13
+ ```bash
14
+ cd <my-project>
15
+ npm start
16
+ ```
22
17
 
23
- 1. Within the directus-mysql-template directory, run `npm install`
24
- 2. Lastly, run `npm start`. The wizard will walk you through the config, and automatically launch all containers for you.
18
+ The wizard will walk you through configuring your environment variables, and will launch all services for you.
25
19
 
26
- *Note that you'll only have to do these two steps the first time you run this.*
27
-
28
- ### Starting/stopping with Docker Compose
20
+ **Boom!** You're done. Now you can access the URLS from here:
29
21
 
30
- To **stop** your running containers, simply run `docker compose down` in your terminal from within the project directory. All containers will be stopped.
22
+ Directus CMS: http://localhost:8055
23
+ Adminer (for MySQL): http://localhost:8080
24
+ GraphQL Playground: http://localhost:4000/graphql
31
25
 
32
- To **restart** your stopped containers, you can let the helper app do it for you:
26
+ ## Requirements
33
27
 
34
- `npm start`
28
+ You need [Docker](https://www.docker.com) and [Node](https://nodejs.org) installed on your machine:
35
29
 
36
- Or you can follow this sequence:
30
+ - [Install Docker Desktop](https://www.docker.com/products/docker-desktop/)
31
+ - [Install Node](https://nodejs.org/en/download/)
37
32
 
38
- `docker compose up mysql -d`
33
+ ## Starting/stopping with Docker Compose
39
34
 
40
- Then wait 10-20 seconds (for MySQL to boot), then type:
35
+ To **stop** your running containers, simply run either `npm run stop` or `docker compose down` from within the project directory. All containers will be stopped.
41
36
 
42
- `docker compose up -d`
37
+ To **restart** your stopped containers, you can let the helper app do it for you:
43
38
 
44
- **Boom!** You're done. Now you can access the URLS from here:
39
+ `npm start`
45
40
 
46
- Directus CMS: http://localhost:8055
47
- GraphQL Playground: http://localhost:4000/graphql
48
- Adminer (for MySQL): http://localhost:8080
41
+ The helper app waits for MySQL to be ready before starting the rest of the services (otherwise, you'd get errors).
49
42
 
50
43
  **Check on running containers:**
51
44
 
@@ -77,10 +70,4 @@ Temporarily Disable CORS in Chrome (MacOS):
77
70
 
78
71
  **Firefox:**
79
72
 
80
- For Firefox you can simply install [CORS Everywhere](https://addons.mozilla.org/en-US/firefox/addon/cors-everywhere/) addon.
81
-
82
- ### Examples of getting an auth token for API:
83
-
84
- curl -X POST localhost:8055/auth/login -H 'Content-Type: application/json' -d '{"email":"you@email.com","password":"your-password"}'
85
-
86
- curl -X POST localhost:8055/auth/refresh -H 'Content-Type: application/json' -d '{"refresh_token": "W5L70MBXKElx5ZVZwxmQVG8qdVjukiRVIwD5FYG7tCPyyuCM_I3IyCsYnFhMUrRi", "mode": "json"}'
73
+ For Firefox you can simply install [CORS Everywhere](https://addons.mozilla.org/en-US/firefox/addon/cors-everywhere/) addon.
package/package.json CHANGED
@@ -1,54 +1,36 @@
1
1
  {
2
2
  "name": "create-directus-docker",
3
- "version": "1.0.7",
4
- "description": "A helper app to configure Directus on Docker with MySQL, Adminer, and GraphQL",
5
- "main": "./lib/index.js",
6
- "type": "module",
7
- "scripts": {
8
- "start": "node ./lib/index.js",
9
- "launch": "node ./lib/index.js",
10
- "test": "echo \"No test specified\""
11
- },
12
- "bin": {
13
- "create-directus-docker": "./lib/index.js",
14
- "cdd": "./lib/index.js"
3
+ "description": "An installer for Dockerized Directus + MySQL + Adminer + GraphiQL with a helper Node app",
4
+ "version": "1.0.8",
5
+ "author": {
6
+ "name": "Dave Kobrenski",
7
+ "email": "dave@rlmg.com"
15
8
  },
16
- "files": [
17
- "docker-compose.yml",
18
- "./lib/index.js",
19
- "./lib/check-requirements.js",
20
- "./lib/launch-services.js"
21
- ],
9
+ "bin": "src/cli.js",
22
10
  "keywords": [
23
11
  "directus",
24
12
  "docker",
25
13
  "mysql",
26
14
  "installer"
27
15
  ],
28
- "exports": {
29
- ".": "./lib/index.js",
30
- "./package.json": "./package.json"
31
- },
32
- "repository": {
33
- "type": "git",
34
- "url": "git+https://github.com/rollmug/directus-mysql-template.git"
35
- },
36
- "author": {
37
- "name": "Dave Kobrenski",
38
- "email": "dave@rlmg.com"
39
- },
40
- "license": "GPL-3.0-only",
41
- "bugs": {
42
- "url": "https://github.com/rollmug/directus-mysql-template/issues"
16
+ "scripts": {
17
+ "init": "npm-run-all -p copy:*",
18
+ "copy:package": "copy-file ../directus-mysql-template/package.json ./templates/default/package.json",
19
+ "copy:compose": "copy-file ../directus-mysql-template/docker-compose.yml ./templates/default/docker-compose.yml",
20
+ "copy:readme": "copy-file ../directus-mysql-template/README.md ./templates/default/README.md",
21
+ "copy:lib": "copyfiles --flat ../directus-mysql-template/lib/*.js ./templates/default/lib"
43
22
  },
44
- "homepage": "https://github.com/rollmug/directus-mysql-template#readme",
23
+ "files": [
24
+ "src",
25
+ "templates"
26
+ ],
45
27
  "dependencies": {
46
28
  "chalk": "^5.2.0",
47
- "dotenv": "^16.0.3",
48
- "generate-password": "^1.7.0",
49
- "inquirer": "^9.1.4",
50
- "log-update": "^5.0.1",
51
- "ora": "^6.1.2",
52
- "wait-on": "^7.0.1"
29
+ "create-create-app": "^7.3.0"
30
+ },
31
+ "license": "MIT",
32
+ "devDependencies": {
33
+ "copy-file-util": "^0.1.6",
34
+ "npm-run-all": "^4.1.5"
53
35
  }
54
36
  }
package/src/cli.js ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env node
2
+
3
+ const chalk = require('chalk');
4
+ const { resolve } = require('path');
5
+ const { create } = require('create-create-app');
6
+
7
+ const templateRoot = resolve(__dirname, '..', 'templates');
8
+
9
+ const caveat = () => {
10
+ return `
11
+ ${chalk.yellow("Directus with MySQL, Adminer, and GraphiQL:")}
12
+
13
+ Installed successfully.
14
+
15
+ ${process.argv}
16
+ `
17
+ }
18
+
19
+ create('create-directus-docker', {
20
+ templateRoot,
21
+ after: ({ answers }) => {
22
+ //custom stuff to do or print out here...
23
+ let msg = `cd ${answers.name} && npm start`
24
+ console.log(`To configure and launch all services, run ${chalk.green(msg)}`);
25
+ },
26
+ caveat,
27
+ });
@@ -0,0 +1,98 @@
1
+ ## Docker with Directus / MySQL / Adminer / GraphQL
2
+
3
+ This package contains everything you need to get up and running with Directus CMS with a MySQL backend, plus an interactive GraphQL playground to help you develop your API queries.
4
+
5
+ **Requirements:** you need [Docker](https://www.docker.com) and [Node](https://nodejs.org) installed on your machine:
6
+
7
+ - [Install Docker Desktop](https://www.docker.com/products/docker-desktop/)
8
+ - [Install Node](https://nodejs.org/en/download/)
9
+
10
+ ### Quick Install:
11
+
12
+ **The easiest way to get up and running is to open a terminal session and run:**
13
+
14
+ ```bash
15
+ npx create-directus-docker <my-project>
16
+ ```
17
+
18
+ Then, just follow the on-screen prompts.
19
+
20
+ ### Manual Install
21
+
22
+ As an alternative, you can install this package by following these steps. Once you've installed Node and Docker, and have Docker Desktop running on your machine:
23
+
24
+ 1. Open a terminal session:
25
+ **Mac:** Go to /Applications/Utilities then double-click Terminal.
26
+ **Windows:** Click 'Start' taskbar button, Select 'All apps', scroll down and select 'Terminal'
27
+ 2. CD into the parent directory where you'd like to install this, ie `cd '~/Documents/My-Folder'`.
28
+ 3. From there, run:
29
+ `git clone https://github.com/rollmug/directus-mysql-template.git`
30
+ OR, if you don't have git installed, [manually download it here](https://github.com/rollmug/directus-mysql-template/archive/refs/heads/main.zip) and unzip it.
31
+ 4. Navigate into the folder you just downloaded, ie `cd 'directus-mysql-template'`
32
+
33
+ **Configure your Directus/MySQL setup:**
34
+
35
+ 1. Within the directus-mysql-template directory, run `npm install`
36
+ 2. Lastly, run `npm start`. The wizard will walk you through the config, and automatically launch all containers for you.
37
+
38
+ *Note that you'll only have to do these two steps the first time you run this.*
39
+
40
+ ### Starting/stopping with Docker Compose
41
+
42
+ To **stop** your running containers, simply run `docker compose down` in your terminal from within the project directory. All containers will be stopped.
43
+
44
+ To **restart** your stopped containers, you can let the helper app do it for you:
45
+
46
+ `npm start`
47
+
48
+ Or you can follow this sequence:
49
+
50
+ `docker compose up mysql -d`
51
+
52
+ Then wait 10-20 seconds (for MySQL to boot), then type:
53
+
54
+ `docker compose up -d`
55
+
56
+ **Boom!** You're done. Now you can access the URLS from here:
57
+
58
+ Directus CMS: http://localhost:8055
59
+ GraphQL Playground: http://localhost:4000/graphql
60
+ Adminer (for MySQL): http://localhost:8080
61
+
62
+ **Check on running containers:**
63
+
64
+ Simply run `docker compose ps` to see the status of running containers. Or, run `docker compose ps -a` to see all containers, running or not.
65
+
66
+ ## CORS problems on localhost
67
+
68
+ When using the GraphiQL playground on localhost, you'll run into some browser problems related to CORS. Here's how to get around it:
69
+
70
+ **Safari:**
71
+
72
+ 1. Enable the developer menu by opening up Settings > Advanced, then check "Show Develop bar in menu"
73
+ 2. Click the Develop menu and check "Disable Cross-Origin Restrictions"
74
+
75
+ **Chrome**
76
+
77
+ Temporarily Disable CORS in Chrome (MacOS):
78
+
79
+ 1. Quit Chrome
80
+ 2. Open terminal and run:
81
+
82
+ `open -n -a "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" --args --user-data-dir="/tmp/chrome_dev_test" --disable-web-security`
83
+
84
+ **Windows:**
85
+
86
+ 1. Right click on desktop, add new shortcut
87
+ 2. Add the target as "[PATH_TO_CHROME]\chrome.exe" --disable-web-security --disable-gpu --user-data-dir=~/chromeTemp
88
+ 3. Click OK
89
+
90
+ **Firefox:**
91
+
92
+ For Firefox you can simply install [CORS Everywhere](https://addons.mozilla.org/en-US/firefox/addon/cors-everywhere/) addon.
93
+
94
+ ### Examples of getting an auth token for API:
95
+
96
+ curl -X POST localhost:8055/auth/login -H 'Content-Type: application/json' -d '{"email":"you@email.com","password":"your-password"}'
97
+
98
+ curl -X POST localhost:8055/auth/refresh -H 'Content-Type: application/json' -d '{"refresh_token": "W5L70MBXKElx5ZVZwxmQVG8qdVjukiRVIwD5FYG7tCPyyuCM_I3IyCsYnFhMUrRi", "mode": "json"}'
@@ -0,0 +1,23 @@
1
+ import chalk from 'chalk';
2
+ import { lookpath } from 'lookpath';
3
+
4
+ export default async function checkRequirements() {
5
+ const nodeVersion = process.versions.node;
6
+ const major = +nodeVersion.split('.')[0];
7
+ const docker = await lookpath('bash');
8
+
9
+ if(!docker) {
10
+ console.error(`${chalk.red(`Docker needs to be installed and running`)}.`);
11
+ console.error(`Please install or open Docker on your machine.`);
12
+ console.error(`For installation instructions, visit this page:`);
13
+ console.error(`https://www.docker.com/products/docker-desktop/`);
14
+ process.exit(1);
15
+ }
16
+
17
+ if (major < 12) {
18
+ console.error(`You are running ${chalk.red(`Node ${nodeVersion}`)}.`);
19
+ console.error(`Directus requires ${chalk.green(`Node 12`)} and up.`);
20
+ console.error('Please update your Node version and try again.');
21
+ process.exit(1);
22
+ }
23
+ };
@@ -8,12 +8,24 @@ import * as fs from 'fs';
8
8
  import * as dotenv from 'dotenv';
9
9
  dotenv.config();
10
10
 
11
+ import gitconfig from 'gitconfig';
12
+
11
13
  import checkRequirements from './check-requirements.js';
12
14
  import launchServices from './launch-services.js';
13
15
 
14
16
  const rootPath = path.resolve();
15
17
  const envPath = './.env';
16
18
 
19
+ async function gitData() {
20
+ try {
21
+ return (await gitconfig.get({
22
+ location: "global"
23
+ })).user ?? {}
24
+ } catch {
25
+ return {}
26
+ }
27
+ }
28
+
17
29
  try {
18
30
  console.log(chalk.magentaBright("Configure Directus with MySQL, Adminer, and a GraphQL playground"));
19
31
  console.log(chalk.dim("---------------------------------------------\n"));
@@ -28,6 +40,8 @@ try {
28
40
  //let's do the configuring!
29
41
  console.log("Follow the prompts to configure Directus and MySQL.\n");
30
42
 
43
+ let git = await gitData();
44
+
31
45
  if (fs.existsSync(path.join(rootPath, 'mysql')) === false) {
32
46
  fs.mkdir(path.join(rootPath, 'mysql'), () => {
33
47
  //console.log(`'mysql' directory created.`);
@@ -46,6 +60,7 @@ try {
46
60
  {
47
61
  name: 'ADMIN_EMAIL',
48
62
  message: "Type your email then hit return:",
63
+ default: git.email,
49
64
  validate: (email) => {
50
65
  let valid = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email)
51
66
 
@@ -126,11 +141,27 @@ try {
126
141
 
127
142
  writeStream.end();
128
143
 
129
- console.log(chalk.greenBright("\nAll set!"));
130
- console.log("You can always edit the variables that we've just set in the .env file manually.\n");
131
- console.log(`${chalk.greenBright("To launch all services, just run 'npm start'.")}\n`);
132
- })
144
+ //console.log(chalk.greenBright("\nAll set!"));
145
+ console.log("\nYou can always edit the variables that we've just set in the .env file manually.\n");
146
+
147
+ inquirer.prompt([
148
+ {
149
+ type: 'confirm',
150
+ name: 'start_now',
151
+ message: "Would you like to start all services now?"
152
+ }
153
+ ]).then(answers => {
154
+ //console.log(answers);
155
+
156
+ if (answers.start_now === true) {
157
+ console.log(`${chalk.greenBright("Launching all services.")}\n`);
158
+ launchServices();
159
+ } else {
160
+ console.log(`${chalk.greenBright("Ok. To launch all services when you're ready, just run 'npm start' (and make sure you have Docker running when you do!)")}\n`);
161
+ }
162
+ });
163
+ });
133
164
  }
134
165
  } catch (err) {
135
- console.error(err)
166
+ console.error(err);
136
167
  }
@@ -0,0 +1,112 @@
1
+ import chalk from 'chalk';
2
+ import ora from 'ora';
3
+ import waitOn from 'wait-on';
4
+ import { spawn } from 'node:child_process';
5
+ import logUpdate from 'log-update';
6
+ import open from 'open';
7
+ import inquirer from 'inquirer';
8
+
9
+ export default function launchServices() {
10
+ const launch = spawn('docker', ['compose', 'up', 'mysql', '-d']);
11
+
12
+ const opts = {
13
+ resources: [
14
+ 'tcp:127.0.0.1:3306'
15
+ ],
16
+ delay: 1000,
17
+ interval: 100,
18
+ timeout: 30000,
19
+ tcpTimeout: 30000
20
+ }
21
+
22
+ launch.stderr.on('data', (data) => {
23
+ logUpdate(`${data}`);
24
+ });
25
+
26
+ launch.on('close', code => {
27
+ logUpdate.done();
28
+ console.log(`Docker has launched MySQL service (status = ${code}).`);
29
+
30
+ const loader = ora('Waiting for MySQL to be ready').start();
31
+
32
+ waitOn(opts, (err) => {
33
+ if (err) console.log(err);
34
+ // once here, all resources are available
35
+
36
+ const sleeper = spawn('sleep', [5]);
37
+
38
+ sleeper.on('close', code => {
39
+ loader.stop();
40
+ console.log('MySQL ready.');
41
+
42
+ logUpdate("Building and launching containers:\n");
43
+ logUpdate.done();
44
+
45
+ const launch2 = spawn('docker', ['compose', 'up', '-d']);
46
+
47
+ launch2.stderr.on('data', (data) => {
48
+ logUpdate(`${data}`);
49
+ });
50
+
51
+ launch2.on('close', code => {
52
+ logUpdate('Done.');
53
+ logUpdate.done();
54
+
55
+ const pingOpts = {
56
+ resources: [
57
+ 'http://localhost:8055'
58
+ ],
59
+ delay: 1000,
60
+ interval: 300,
61
+ timeout: 40000,
62
+ tcpTimeout: 40000
63
+ }
64
+
65
+ const loader2 = ora('Waiting for Directus to be ready').start();
66
+
67
+ waitOn(pingOpts).then(() => {
68
+ loader2.stop();
69
+ logUpdate('Directus ready.');
70
+ logUpdate.done();
71
+
72
+ console.log(chalk.green("\nAll services should be ready. You can access them at the following URLs:\n"));
73
+
74
+ console.log(`Directus CMS: ${chalk.cyan("http://localhost:8055")}`);
75
+ console.log(`Adminer: ${chalk.cyan("http://localhost:8080")}`);
76
+ console.log(`GraphiQL Playground: ${chalk.cyan("http://localhost:4000/graphql")}`);
77
+
78
+ console.log(`\n${chalk.redBright("Note: learn how to avoid CORS errors in the GraphiQL Playground when running on localhost:")}`);
79
+ console.log(`https://github.com/rollmug/directus-mysql-template#cors-problems-on-localhost`)
80
+
81
+ console.log(`\n${chalk.green("When you're finished, you can stop all running containers with:")}\n`);
82
+ console.log(`npm run stop\n`);
83
+ console.log(`${chalk.green("You can start them all back up again with:")}`);
84
+ console.log(`npm run launch\n`);
85
+
86
+ inquirer.prompt([
87
+ {
88
+ type: 'confirm',
89
+ name: 'open_now',
90
+ message: "Open services in browser now?"
91
+ }
92
+ ]).then(answers => {
93
+ if(answers.open_now === true) {
94
+ open('http://localhost:8055');
95
+ open('http://localhost:8080');
96
+ open('http://localhost:4000/graphql');
97
+ } else {
98
+ process.exit(1);
99
+ }
100
+ });
101
+ }).catch((err) => {
102
+ //console.log(err);
103
+ loader2.stop();
104
+ console.log(`${chalk.redBright("Directus taking too long to respond. You may need to manually start it.")}`);
105
+ console.log(`Just run ${chalk.greenBright("npm run launch")} and you should be good to go.`)
106
+ process.exit(1);
107
+ });
108
+ });
109
+ });
110
+ });
111
+ });
112
+ }
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "directus-mysql-docker",
3
+ "version": "1.0.8",
4
+ "description": "A helper app to configure Directus on Docker with MySQL, Adminer, and GraphQL",
5
+ "main": "./lib/index.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "start": "node ./lib/index.js",
9
+ "launch": "node ./lib/index.js",
10
+ "stop": "docker-compose down",
11
+ "test": "echo \"No test specified\""
12
+ },
13
+ "bin": {
14
+ "create-directus-docker": "./lib/index.js",
15
+ "cdd": "./lib/index.js"
16
+ },
17
+ "files": [
18
+ "docker-compose.yml",
19
+ "lib/**/*",
20
+ "./lib/index.js",
21
+ "./lib/check-requirements.js",
22
+ "./lib/launch-services.js"
23
+ ],
24
+ "keywords": [
25
+ "directus",
26
+ "docker",
27
+ "mysql",
28
+ "installer"
29
+ ],
30
+ "exports": {
31
+ ".": "./lib/index.js",
32
+ "./package.json": "./package.json"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/rollmug/directus-mysql-template.git"
37
+ },
38
+ "author": {
39
+ "name": "Dave Kobrenski",
40
+ "email": "dave@rlmg.com"
41
+ },
42
+ "license": "GPL-3.0-only",
43
+ "bugs": {
44
+ "url": "https://github.com/rollmug/directus-mysql-template/issues"
45
+ },
46
+ "homepage": "https://github.com/rollmug/directus-mysql-template#readme",
47
+ "dependencies": {
48
+ "chalk": "^5.2.0",
49
+ "dotenv": "^16.0.3",
50
+ "generate-password": "^1.7.0",
51
+ "gitconfig": "^2.0.8",
52
+ "inquirer": "^9.1.4",
53
+ "log-update": "^5.0.1",
54
+ "lookpath": "^1.2.2",
55
+ "open": "^8.4.0",
56
+ "ora": "^6.1.2",
57
+ "wait-on": "^7.0.1"
58
+ }
59
+ }
@@ -1,13 +0,0 @@
1
- import chalk from 'chalk';
2
-
3
- export default function checkRequirements() {
4
- const nodeVersion = process.versions.node;
5
- const major = +nodeVersion.split('.')[0];
6
-
7
- if (major < 12) {
8
- console.error(`You are running ${chalk.red(`Node ${nodeVersion}`)}.`);
9
- console.error(`Directus requires ${chalk.green(`Node 12`)} and up.`);
10
- console.error('Please update your Node version and try again.');
11
- process.exit(1);
12
- }
13
- };
@@ -1,71 +0,0 @@
1
- import chalk from 'chalk';
2
- import ora from 'ora';
3
- import waitOn from 'wait-on';
4
- import { spawn } from 'node:child_process';
5
- import logUpdate from 'log-update';
6
-
7
- export default function launchServices() {
8
- const launch = spawn('docker', ['compose', 'up', 'mysql', '-d']);
9
-
10
- const opts = {
11
- resources: [
12
- 'tcp:127.0.0.1:3306'
13
- ],
14
- delay: 1000,
15
- interval: 100,
16
- timeout: 30000,
17
- tcpTimeout: 30000
18
- }
19
-
20
- launch.stderr.on('data', (data) => {
21
- logUpdate(`${data}`);
22
- });
23
-
24
- launch.on('close', code => {
25
- logUpdate.done();
26
- console.log(`Docker has launched MySQL service (status = ${code}).`);
27
-
28
- const loader = ora('Waiting for MySQL to be ready').start();
29
-
30
- waitOn(opts, (err) => {
31
- if (err) console.log(err);
32
- // once here, all resources are available
33
-
34
- const sleeper = spawn('sleep', [5]);
35
-
36
- sleeper.on('close', code => {
37
- loader.stop();
38
- console.log('MySQL ready.');
39
-
40
- logUpdate("Building and launching containers:\n");
41
- logUpdate.done();
42
-
43
- const launch2 = spawn('docker', ['compose', 'up', '-d']);
44
-
45
- launch2.stderr.on('data', (data) => {
46
- logUpdate(`${data}`);
47
- });
48
-
49
- launch2.on('close', code => {
50
- logUpdate('Done.');
51
- logUpdate.done();
52
-
53
- console.log(chalk.green("\nAll services should be ready. You can access them at the following URLs:\n"));
54
-
55
- console.log(`Directus CMS: ${chalk.cyan("http://localhost:8055")}`);
56
- console.log(`Adminer: ${chalk.cyan("http://localhost:8080")}`);
57
- console.log(`GraphiQL Playground: ${chalk.cyan("http://localhost:4000/graphql")}`);
58
-
59
- console.log(`\n${chalk.redBright("Note: learn how to avoid CORS errors in the GraphiQL Playground when running on localhost:")}`);
60
- console.log(`https://github.com/rollmug/directus-mysql-template#cors-problems-on-localhost`)
61
-
62
- console.log(`\n${chalk.green("Done! When you're finished, you can stop all running containers with:")}\n`);
63
- console.log(`docker compose down\n`);
64
- console.log(`${chalk.green("You can start them all back up again with:")}`);
65
- console.log(`npm start\n`);
66
- });
67
- });
68
-
69
- });
70
- });
71
- }