-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathsilverstripe.php
More file actions
95 lines (83 loc) · 2.39 KB
/
silverstripe.php
File metadata and controls
95 lines (83 loc) · 2.39 KB
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
<?php
namespace Deployer;
require_once __DIR__ . '/common.php';
add('recipes', ['silverstripe']);
/**
* Path to the assets folder.
* Defaults to `"public/assets"` (or `"assets"` on older installations).
*/
set('shared_assets', function () {
if (test('[ -d {{release_or_current_path}}/public ]') || test('[ -d {{deploy_path}}/shared/public ]')) {
return 'public/assets';
}
return 'assets';
});
set('shared_dirs', [
'{{shared_assets}}',
]);
set('writable_dirs', [
'{{shared_assets}}',
]);
/**
* Path to the `sake` binary.
* Defaults to `"vendor/bin/sake"`, if it exists.
*/
set('silverstripe_sake', function () {
$candidates = [
'vendor/bin/sake',
'vendor/silverstripe/framework/bin/sake',
];
foreach ($candidates as $candidate) {
if (test("[ -x '{{release_or_current_path}}/$candidate' ]")) {
return $candidate;
}
}
});
/**
* Deprecated option, retained for backward compatibility.
* For Silverstripe 6 and above, use `silverstripe_sake` instead.
*/
set('silverstripe_cli_script', function () {
$candidates = [
'framework/cli-script.php',
'vendor/silverstripe/framework/cli-script.php',
];
foreach ($candidates as $candidate) {
if (test("[ -f '{{release_or_current_path}}/$candidate' ]")) {
return $candidate;
}
}
});
/**
* Helper tasks
*/
desc('Rebuild the database');
task('silverstripe:build', function () {
if (get('silverstripe_cli_script')) {
// Old behavior (Silverstripe < 6)
run('{{bin/php}} {{release_or_current_path}}/{{silverstripe_cli_script}} /dev/build');
} elseif (get('silverstripe_sake')) {
// New behavior (Silverstripe >= 6)
run('{{release_or_current_path}}/{{silverstripe_sake}} db:build');
}
});
desc('Rebuild database and cache');
task('silverstripe:buildflush', function () {
if (get('silverstripe_cli_script')) {
// Old behavior (Silverstripe < 6)
run('{{bin/php}} {{release_or_current_path}}/{{silverstripe_cli_script}} /dev/build flush=all');
} elseif (get('silverstripe_sake')) {
// New behavior (Silverstripe >= 6)
run('{{release_or_current_path}}/{{silverstripe_sake}} -f db:build');
}
});
/**
* Main task
*/
desc('Deploys your project');
task('deploy', [
'deploy:prepare',
'deploy:vendors',
'silverstripe:buildflush',
'deploy:publish',
]);