GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( e51949...763526 )
by Anton
01:57
created

laravel.php ➔ laravel_version_compare()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer;
9
10
require_once __DIR__ . '/common.php';
11
12
set('shared_dirs', ['storage']);
13
set('shared_files', ['.env']);
14
set('writable_dirs', [
15
    'bootstrap/cache',
16
    'storage',
17
    'storage/app',
18
    'storage/app/public',
19
    'storage/framework',
20
    'storage/framework/cache',
21
    'storage/framework/sessions',
22
    'storage/framework/views',
23
    'storage/logs',
24
]);
25
set('log_files', 'storage/logs/*.log');
26
set('laravel_version', function () {
27
    $result = run('{{bin/php}} {{release_path}}/artisan --version');
28
    preg_match_all('/(\d+\.?)+/', $result, $matches);
29
    return $matches[0][0] ?? 5.5;
30
});
31
32
/**
33
 * Run an artisan command.
34
 *
35
 * Supported options:
36
 * - 'min' => #.#: The minimum Laravel version required (included).
37
 * - 'max' => #.#: The maximum Laravel version required (included).
38
 * - 'skipIfNoEnv': Skip and warn the user if `.env` file is inexistant or empty.
39
 * - 'failIfNoEnv': Fail the command if `.env` file is inexistant or empty.
40
 * - 'runInCurrent': Run the artisan command in the current directory.
41
 * - 'showOutput': Show the output of the command if given.
42
 *
43
 * @param string $command The artisan command (with cli options if any).
44
 * @param array $options The options that define the behaviour of the command.
45
 * @return callable A function that can be used as a task.
46
 */
47
function artisan($command, $options = [])
48
{
49
    return function () use ($command, $options) {
50
        $versionTooEarly = array_key_exists('min', $options)
51
            && laravel_version_compare($options['min'], '<');
52
53
        $versionTooLate = array_key_exists('max', $options)
54
            && laravel_version_compare($options['max'], '>');
55
56
        if ($versionTooEarly || $versionTooLate) {
57
            return;
58
        }
59
        if (in_array('failIfNoEnv', $options) && !test('[ -s {{release_path}}/.env ]')) {
60
            throw new \Exception('Your .env file is empty! Cannot proceed.');
61
        }
62
        if (in_array('skipIfNoEnv', $options) && !test('[ -s {{release_path}}/.env ]')) {
63
            warning("Your .env file is empty! Skipping...</>");
64
            return;
65
        }
66
67
        $artisan = in_array('runInCurrent', $options)
68
            ? '{{deploy_path}}/current/artisan'
69
            : '{{release_path}}/artisan';
70
71
        $output = run("{{bin/php}} $artisan $command");
72
73
        if (in_array('showOutput', $options)) {
74
            writeln("<info>$output</info>");
75
        }
76
    };
77
}
78
79
function laravel_version_compare($version, $comparator)
80
{
81
    return version_compare(get('laravel_version'), $version, $comparator);
82
}
83
84
desc('Disable maintenance mode');
85
task('artisan:up', artisan('up', ['runInCurrent', 'showOutput']));
86
87
desc('Enable maintenance mode');
88
task('artisan:down', artisan('down', ['runInCurrent', 'showOutput']));
89
90
desc('Execute artisan migrate');
91
task('artisan:migrate', artisan('migrate --force', ['skipIfNoEnv']));
92
93
desc('Execute artisan migrate:fresh');
94
task('artisan:migrate:fresh', artisan('migrate:fresh --force'));
95
96
desc('Execute artisan migrate:rollback');
97
task('artisan:migrate:rollback', artisan('migrate:rollback --force', ['showOutput']));
98
99
desc('Execute artisan migrate:status');
100
task('artisan:migrate:status', artisan('migrate:status', ['showOutput']));
101
102
desc('Execute artisan db:seed');
103
task('artisan:db:seed', artisan('db:seed --force', ['showOutput']));
104
105
desc('Execute artisan cache:clear');
106
task('artisan:cache:clear', artisan('cache:clear'));
107
108
desc('Execute artisan config:clear');
109
task('artisan:config:clear', artisan('config:clear'));
110
111
desc('Execute artisan config:cache');
112
task('artisan:config:cache', artisan('config:cache'));
113
114
desc('Execute artisan route:cache');
115
task('artisan:route:cache', artisan('route:cache'));
116
117
desc('Execute artisan view:clear');
118
task('artisan:view:clear', artisan('view:clear'));
119
120
desc('Execute artisan view:cache');
121
task('artisan:view:cache', artisan('view:cache', ['min' => 5.6]));
122
123
desc('Execute artisan optimize');
124
task('artisan:optimize', artisan('optimize', ['min' => 5.7]));
125
126
desc('Execute artisan optimize:clear');
127
task('artisan:optimize:clear', artisan('optimize:clear', ['min' => 5.7]));
128
129
desc('Execute artisan queue:restart');
130
task('artisan:queue:restart', artisan('queue:restart'));
131
132
desc('Execute artisan storage:link');
133
task('artisan:storage:link', artisan('storage:link', ['min' => 5.3]));
134
135
desc('Execute artisan horizon:assets');
136
task('artisan:horizon:assets', artisan('horizon:assets'));
137
138
desc('Execute artisan horizon:publish');
139
task('artisan:horizon:publish', artisan('horizon:publish'));
140
141
desc('Execute artisan horizon:terminate');
142
task('artisan:horizon:terminate', artisan('horizon:terminate'));
143
144
desc('Execute artisan telescope:clear');
145
task('artisan:telescope:clear', artisan('telescope:clear'));
146
147
desc('Execute artisan telescope:prune');
148
task('artisan:telescope:prune', artisan('telescope:prune'));
149
150
desc('Execute artisan telescope:publish');
151
task('artisan:telescope:publish', artisan('telescope:publish'));
152
153
desc('Execute artisan nova:publish');
154
task('artisan:nova:publish', artisan('nova:publish'));
155
156
desc('Execute artisan event:clear');
157
task('artisan:event:clear', artisan('event:clear', ['min' => '5.8.9']));
158
159
desc('Execute artisan event:cache');
160
task('artisan:event:cache', artisan('event:cache', ['min' => '5.8.9']));
161
162
/**
163
 * Task deploy:public_disk support the public disk.
164
 * To run this task automatically, please add below line to your deploy.php file
165
 *
166
 *     before('deploy:symlink', 'deploy:public_disk');
167
 *
168
 * @see https://laravel.com/docs/5.2/filesystem#configuration
169
 */
170
desc('Make symlink for public disk');
171
task('deploy:public_disk', function () {
172
    // Remove from source.
173
    run('if [ -d $(echo {{release_path}}/public/storage) ]; then rm -rf {{release_path}}/public/storage; fi');
174
175
    // Create shared dir if it does not exist.
176
    run('mkdir -p {{deploy_path}}/shared/storage/app/public');
177
178
    // Symlink shared dir to release dir
179
    run('{{bin/symlink}} {{deploy_path}}/shared/storage/app/public {{release_path}}/public/storage');
180
});
181
182
/**
183
 * Main deploy task.
184
 */
185
desc('Deploy your project');
186
task('deploy', [
187
    'deploy:prepare',
188
    'deploy:vendors',
189
    'artisan:storage:link',
190
    'artisan:view:cache',
191
    'artisan:config:cache',
192
    'deploy:publish',
193
]);
194