-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdown.ts
64 lines (53 loc) · 1.66 KB
/
down.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { flags } from "@oclif/command";
import chalk from "chalk";
import * as inquirer from "inquirer";
import * as shelljs from "shelljs";
import { displayCommandHeader, testTargetDirectory } from "../actions";
import { VERBOSE_DESCRIPTION } from "../constants";
import TargetDirectoryCommand from "./target-directory-command";
export default class Down extends TargetDirectoryCommand {
static description = "Stops a running Laravel Up environment";
static flags = {
verbose: flags.boolean({
char: "v",
default: false,
description: VERBOSE_DESCRIPTION
}),
destroy: flags.boolean({
char: "d",
default: false,
description: "Stops Docker containers and removes all volumes"
})
};
static args = TargetDirectoryCommand.combineArgs([]);
async run() {
const { args, flags } = this.parse(Down);
displayCommandHeader("Shutting down your Laravel Up environment...");
const directory = this.targetDirectory
? this.targetDirectory
: this.currentDirectory;
if (!testTargetDirectory(directory)) {
return false;
}
if (flags.destroy) {
const confirmPrompt = (await inquirer.prompt([
{
message: chalk.yellow(
"Are you sure you would like to clear your local Database(s)?"
),
name: "confirm",
type: "confirm"
}
])).confirm;
if (!confirmPrompt) {
return;
}
}
shelljs.cd(directory);
shelljs.exec(
["docker-compose", "down", flags.destroy ? "-v" : ""].join(" "),
{ silent: !flags.verbose }
);
console.log(chalk.gray("Your Laravel Up environment has been stopped"));
}
}