create-directus-docker 1.4.4 → 1.5.1
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/package.json +8 -4
- package/src/cli.js +40 -32
- package/templates/default/lib/launch-services.js +11 -14
- package/templates/default/package.json +1 -1
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-directus-docker",
|
|
3
3
|
"description": "An installer for Dockerized Directus + MySQL + Adminer + GraphiQL with a helper Node app",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Dave Kobrenski",
|
|
8
8
|
"email": "dave@rlmg.com"
|
|
9
9
|
},
|
|
10
|
-
"bin":
|
|
10
|
+
"bin": {
|
|
11
|
+
"create-directus-docker": "src/cli.js",
|
|
12
|
+
"cdd": "src/cli.js"
|
|
13
|
+
},
|
|
11
14
|
"keywords": [
|
|
12
15
|
"directus",
|
|
13
16
|
"docker",
|
|
@@ -32,10 +35,11 @@
|
|
|
32
35
|
],
|
|
33
36
|
"dependencies": {
|
|
34
37
|
"chalk": "^5.2.0",
|
|
35
|
-
"create-create-app": "7.1.0",
|
|
36
38
|
"execa": "^6.1.0",
|
|
39
|
+
"fs-extra": "^11.1.0",
|
|
37
40
|
"log-update": "^5.0.1",
|
|
38
|
-
"upath": "^2.0.1"
|
|
41
|
+
"upath": "^2.0.1",
|
|
42
|
+
"yargs": "^17.6.2"
|
|
39
43
|
},
|
|
40
44
|
"license": "MIT",
|
|
41
45
|
"devDependencies": {
|
package/src/cli.js
CHANGED
|
@@ -3,40 +3,26 @@
|
|
|
3
3
|
import upath from 'upath';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import path from 'path';
|
|
6
|
-
import {fileURLToPath} from 'url';
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import logUpdate from 'log-update';
|
|
8
|
+
import fs from 'fs-extra';
|
|
9
|
+
import yargs from 'yargs';
|
|
10
|
+
import { hideBin } from 'yargs/helpers';
|
|
11
11
|
|
|
12
12
|
const __filename = fileURLToPath(import.meta.url);
|
|
13
13
|
const __dirname = path.dirname(__filename);
|
|
14
|
+
const templateDir = upath.resolve(__dirname, '../templates/default');
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// const install = spawn('npm', ['install']);
|
|
26
|
-
|
|
27
|
-
// install.stdout.on('data', (data) => {
|
|
28
|
-
// logUpdate(`${data}`);
|
|
29
|
-
// });
|
|
30
|
-
|
|
31
|
-
// install.on('close', (code) => {
|
|
32
|
-
// logUpdate.done();
|
|
33
|
-
// execa('npm', ['start']).stdout.pipe(process.stdout);
|
|
34
|
-
// });
|
|
35
|
-
// });
|
|
36
|
-
// },
|
|
37
|
-
|
|
38
|
-
caveat: ({ packageDir }) => {
|
|
39
|
-
return `
|
|
16
|
+
const rootPath = path.resolve();
|
|
17
|
+
|
|
18
|
+
const argv = yargs(hideBin(process.argv)).argv;
|
|
19
|
+
const args = argv._;
|
|
20
|
+
|
|
21
|
+
//check enough args
|
|
22
|
+
if (args.length > 0) {
|
|
23
|
+
const packageDir = args[0];
|
|
24
|
+
|
|
25
|
+
const successMsg = `
|
|
40
26
|
${chalk.bold.yellowBright("Directus with MySQL, Adminer, and GraphiQL:")}
|
|
41
27
|
|
|
42
28
|
To configure and run your Directus services, first ${chalk.bold("make sure you have Docker installed and running")}, then run:
|
|
@@ -49,6 +35,28 @@ For more information, see:
|
|
|
49
35
|
https://github.com/davekobrenski/create-directus-docker
|
|
50
36
|
|
|
51
37
|
Enjoy!
|
|
52
|
-
|
|
38
|
+
`;
|
|
39
|
+
console.log("");
|
|
40
|
+
logUpdate(`Creating directory: ${packageDir}...`);
|
|
41
|
+
const dirFullPath = path.join(rootPath, packageDir);
|
|
42
|
+
|
|
43
|
+
//make the dir for the project
|
|
44
|
+
if (fs.existsSync(dirFullPath) === false) {
|
|
45
|
+
fs.mkdir(path.join(rootPath, packageDir)).then(() => {
|
|
46
|
+
//success
|
|
47
|
+
logUpdate(chalk.greenBright(`Directory '${packageDir}' created successfully.`));
|
|
48
|
+
logUpdate.done();
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
fs.copySync(templateDir, dirFullPath);
|
|
52
|
+
logUpdate(successMsg);
|
|
53
|
+
} catch (err) {
|
|
54
|
+
console.error(err);
|
|
55
|
+
}
|
|
56
|
+
}).catch(err => console.error(err));
|
|
57
|
+
} else {
|
|
58
|
+
console.error(chalk.redBright(`Error: Specified directory '${packageDir}' already exists.`));
|
|
53
59
|
}
|
|
54
|
-
}
|
|
60
|
+
} else {
|
|
61
|
+
console.error(chalk.redBright(`Error: please specify a project directory.`));
|
|
62
|
+
}
|
|
@@ -124,30 +124,27 @@ export default function launchServices() {
|
|
|
124
124
|
jq.run(q, data.toString(), { input: 'string' })
|
|
125
125
|
.then((data) => {
|
|
126
126
|
const json = JSON.parse(data);
|
|
127
|
-
console.log(data);
|
|
127
|
+
//console.log(data);
|
|
128
128
|
|
|
129
129
|
if(json.State == 'running') {
|
|
130
|
-
logUpdate(`${chalk.yellowBright("Directus appears to be running, but took a while to respond.")}
|
|
131
|
-
console.log(`Just run ${chalk.greenBright("npm run launch")} to verify, and you should be good to go.`);
|
|
132
|
-
|
|
133
|
-
logUpdate.done();
|
|
130
|
+
logUpdate(`${chalk.yellowBright("Directus appears to be running, but took a while to respond.")}. \nJust run ${chalk.greenBright("npm run launch")} to verify, and you should be good to go.`);
|
|
134
131
|
} else {
|
|
135
|
-
logUpdate(`${chalk.redBright("Directus taking too long to respond. You may need to manually start it.")}
|
|
136
|
-
logUpdate.done();
|
|
137
|
-
console.log(`Just run ${chalk.greenBright("npm run launch")} and you should be good to go.`);
|
|
132
|
+
logUpdate(`${chalk.redBright("Directus taking too long to respond. You may need to manually start it.")}. \nJust run ${chalk.greenBright("npm run launch")} and you should be good to go.`);
|
|
138
133
|
}
|
|
139
134
|
});
|
|
140
135
|
});
|
|
141
136
|
|
|
142
137
|
check.on('close', (code) => {
|
|
143
138
|
if (code !== 0) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
139
|
+
var line1 = `${chalk.redBright("Directus taking too long to respond. You may need to manually start it.")}`;
|
|
140
|
+
var line2 = `Just run ${chalk.greenBright("npm run launch")} and you should be good to go.`;
|
|
141
|
+
var line3 = `You can also check if it is running with ${chalk.greenBright("docker-compose ps")}`;
|
|
142
|
+
logUpdate(`${line1} \n${line2} \n${line3}`);
|
|
147
143
|
} else {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
144
|
+
var line1 = `${chalk.yellowBright("Directus appears to be running, but took a while to respond.")}`;
|
|
145
|
+
var line2 = `Just run ${chalk.greenBright("npm run launch")} to verify, and you should be good to go.`;
|
|
146
|
+
var line3 = `You can also check if it is running with ${chalk.greenBright("docker-compose ps")}`;
|
|
147
|
+
logUpdate(`${line1} \n${line2} \n${line3}`);
|
|
151
148
|
}
|
|
152
149
|
});
|
|
153
150
|
});
|