-
Notifications
You must be signed in to change notification settings - Fork 6
/
luya.php
86 lines (68 loc) · 2.34 KB
/
luya.php
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
<?php
require 'vendor/deployer/deployer/recipe/common.php';
// set custom bin
env('bin/composer', function () {
if (commandExist('composer')) {
$composer = run('which composer')->toString();
}
if (empty($composer)) {
run("cd {{release_path}} && curl -sS https://getcomposer.org/installer | {{bin/php}}");
$composer = '{{bin/php}} {{release_path}}/composer.phar';
}
run("cd {{release_path}} && ".$composer." global require \"fxp/composer-asset-plugin:^1.4.2\"");
return $composer;
});
task('deploy:luya', function() {
// find file name
$file = (has('requireConfig')) ? get('requireConfig') : env('server.name');
// go into configs to write the file
cd('{{release_path}}/configs');
run('echo "<?php return require \''.$file.'.php\';" > server.php');
run('echo "<?php return require \'env-'.$file.'.php\';" > env.php');
cd('{{release_path}}');
$adminCoreCommands = (has('adminCoreCommands')) ? get('adminCoreCommands') : true;
if ($adminCoreCommands) {
// run all basic luya commands
run('./vendor/bin/luya migrate --interactive=0');
}
$commands = (has('beforeCommands')) ? get('beforeCommands') : [];
foreach($commands as $cmd) {
run($cmd);
}
if ($adminCoreCommands) {
if (isVerbose()) {
$import = run('./vendor/bin/luya import --verbose=1');
} else {
$import = run('./vendor/bin/luya import');
}
writeln("Import result: $import");
$health = run('./vendor/bin/luya health');
writeln("Health result: $health");
}
$commands = (has('afterCommands')) ? get('afterCommands') : [];
foreach($commands as $cmd) {
run($cmd);
}
})->desc('Run LUYA commands.');
task('luya:command_exporter', function() {
run('cd {{release_path}} && ./vendor/bin/luya exporter/export');
});
set('shared_dirs', ['public_html/storage']);
task('luya', array(
'deploy:prepare',
'deploy:release',
'deploy:update_code',
'deploy:vendors',
'deploy:luya',
'deploy:symlink',
'deploy:shared',
'cleanup'
))->desc('LUYA project deployment');
task('cleanup:deployfile', function() {
$keepDeployer = (has('keepDeployer')) ? get('keepDeployer') : false;
if (!$keepDeployer) {
run('rm -f {{release_path}}/deploy.php');
}
run('rm -f {{release_path}}/README.md');
})->desc('Remove Deployer File');
after('cleanup', 'cleanup:deployfile');