-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhakefile
116 lines (96 loc) · 3.24 KB
/
Phakefile
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
require_once 'vendor/qobo/phake-builder/Phakefile';
/**
* Run WP CLI batch file
*
* There might be a variety of WP CLI batches that
* is ncessary for the app (install, update, content, etc),
* so we standartize the location and naming convention.
*
* Each batch file is processed as a template befor execution
* to make passing variables into there easier.
*
* @param string $name Name of batch file (e.g.: install)
* @param array $app App data
* @return void
*/
function runWPCLIBatch($name, $app) {
$src = 'etc/wp-cli.' . $name;
$dst = $src . '.sh';
$template = new \PhakeBuilder\Template($src);
$placeholders = $template->getPlaceholders();
$data = array();
foreach ($placeholders as $placeholder) {
$data[$placeholder] = getValue($placeholder, $app);
// We really need wp-cli for this
if ($placeholder == 'SYSTEM_COMMAND_WPCLI') {
$data['SYSTEM_COMMAND_WPCLI'] = getValue($placeholder, $app) ?: './vendor/bin/wp --allow-root';
}
}
$bytes = $template->parseToFile($dst, $data);
if (!$bytes) {
throw new \RuntimeException("Failed to create batch file");
}
$parts = array();
$parts[] = getValue('SYSTEM_COMMAND_SHELL', $app) ?: '/bin/sh';
$parts[] = $dst;
doShellCommand($parts);
unlink($dst);
}
group('app', function() {
desc('Install application');
task('install', ':builder:init', function($app) {
printSeparator();
printInfo("Installing application");
});
task('install', ':git:pull', ':git:checkout');
task('install', ':composer:install');
task('install', ':dotenv:create', ':dotenv:reload', ':file:process');
task('install', ':mysql:database-create');
// From here on, you can either import the full MySQL dump with find-replace...
//task('install', ':mysql:database-import');
//task('install', ':mysql:find-replace');
// ... or have a fresh and clean install
task('install', ':wordpress:install');
task('install', ':wordpress:content');
desc('Update application');
task('update', ':builder:init', function($app) {
printSeparator();
printInfo("Updating application");
});
task('update', ':git:pull', ':git:checkout');
task('update', ':composer:install');
task('update', ':dotenv:create', ':dotenv:reload', ':file:process');
task('update', ':mysql:database-import');
task('update', ':mysql:find-replace');
task('update', ':wordpress:update');
desc('Remove application');
task('remove', ':builder:init', function($app) {
printSeparator();
printInfo("Removing application");
});
task('remove', ':mysql:database-drop');
task('remove', ':dotenv:delete');
});
group('wordpress', function() {
desc("Install WordPress");
task('install', ':builder:init', function($app) {
printSeparator();
printInfo("Installing WordPress");
runWPCLIBatch('install', $app);
});
desc("Installation content WordPress");
task('content', ':builder:init', function($app) {
printSeparator();
printInfo("Adding installation content WordPress");
runWPCLIBatch('content', $app);
});
desc("Update content WordPress");
task('update', ':builder:init', function($app) {
printSeparator();
printInfo("Updating content WordPress");
runWPCLIBatch('update', $app);
});
});
# vi:ft=php
?>