|
10 | 10 | use Deployer\Deployer; |
11 | 11 |
|
12 | 12 | use function Deployer\after; |
13 | | -use function Deployer\before; |
14 | 13 | use function Deployer\get; |
15 | 14 | use function Deployer\has; |
16 | 15 | use function Deployer\info; |
17 | 16 | use function Deployer\invoke; |
18 | | -use function Deployer\localhost; |
19 | 17 | use function Deployer\on; |
20 | 18 | use function Deployer\run; |
21 | 19 | use function Deployer\selectedHosts; |
22 | 20 | use function Deployer\task; |
23 | 21 | use function Deployer\test; |
| 22 | +use function Gaambo\DeployerWordpress\Utils\Localhost\getLocalhost; |
24 | 23 |
|
25 | 24 | $deployerPath = 'vendor/deployer/deployer/'; |
26 | 25 | require_once $deployerPath . 'recipe/common.php'; |
|
51 | 50 | 'deploy:release' |
52 | 51 | ])->desc('Prepares a new release'); |
53 | 52 |
|
| 53 | +// Build theme assets via npm locally |
| 54 | +task('deploy:build_assets', function () { |
| 55 | + on(getLocalhost(), function () { |
| 56 | + if (has('theme/name')) { |
| 57 | + invoke('theme:assets:vendors'); |
| 58 | + invoke('theme:assets:build'); |
| 59 | + } |
| 60 | + }); |
| 61 | +})->once(); |
| 62 | + |
54 | 63 | // Overwrite deployment with rsync (instead of git) |
55 | 64 | Deployer::get()->tasks->remove('deploy:check_remote'); |
56 | 65 | Deployer::get()->tasks->remove('deploy:update_code'); |
| 66 | +// Push all files (incl 'wp:push', 'uploads:push', 'plugins:push', 'mu-plugins:push', 'themes:push') |
57 | 67 | task('deploy:update_code', ['files:push']) |
58 | 68 | ->desc('Pushes local code to the remote hosts'); |
59 | 69 |
|
|
70 | 80 | // Complete deploy task which includes preparation, pushing code and publishing |
71 | 81 | task('deploy', [ |
72 | 82 | 'deploy:prepare', |
| 83 | + 'deploy:build_assets', |
73 | 84 | 'deploy:update_code', |
74 | 85 | 'deploy:publish', |
75 | 86 | ])->desc('Deploy WordPress project'); |
76 | 87 |
|
77 | 88 | // If deploy fails automatically unlock. |
78 | 89 | after('deploy:failed', 'deploy:unlock'); |
79 | 90 |
|
80 | | -// build theme assets via npm locally |
81 | | -before('deploy:update_code', function () { |
82 | | - on(localhost(), function () { |
83 | | - if (!has('theme/name')) { |
84 | | - invoke('theme:assets:vendors'); |
85 | | - invoke('theme:assets:build'); |
86 | | - } |
87 | | - }); |
88 | | -}); |
89 | | - |
90 | 91 | /** |
91 | 92 | * Clears cache via cli |
92 | 93 | * eg via WP Rocket WP CLI command |
|
0 commit comments