Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions docs/recipe/silverstripe.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The [deploy](#deploy) task of **Silverstripe** consists of:
* [deploy:shared](/docs/recipe/deploy/shared.md#deploy-shared) – Creates symlinks for shared files and dirs
* [deploy:writable](/docs/recipe/deploy/writable.md#deploy-writable) – Makes writable dirs
* [deploy:vendors](/docs/recipe/deploy/vendors.md#deploy-vendors) – Installs vendors
* [silverstripe:buildflush](/docs/recipe/silverstripe.md#silverstripe-buildflush) – Runs /dev/build?flush=all
* [silverstripe:buildflush](/docs/recipe/silverstripe.md#silverstripe-buildflush) – Rebuild database and cache
* [deploy:publish](/docs/recipe/common.md#deploy-publish) – Publishes the release
* [deploy:symlink](/docs/recipe/deploy/symlink.md#deploy-symlink) – Creates symlink to release
* [deploy:unlock](/docs/recipe/deploy/lock.md#deploy-unlock) – Unlocks deploy
Expand All @@ -52,7 +52,8 @@ The silverstripe recipe is based on the [common](/docs/recipe/common.md) recipe.
### shared_assets
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L13)

Silverstripe configuration
Path to the assets folder.
Defaults to `"public/assets"` (or `"assets"` on older installations).

```php title="Default value"
if (test('[ -d {{release_or_current_path}}/public ]') || test('[ -d {{deploy_path}}/shared/public ]')) {
Expand All @@ -63,11 +64,11 @@ return 'assets';


### shared_dirs
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L22)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L21)

Overrides [shared_dirs](/docs/recipe/deploy/shared.md#shared_dirs) from `recipe/deploy/shared.php`.

Silverstripe shared dirs


```php title="Default value"
[
Expand All @@ -77,11 +78,11 @@ Silverstripe shared dirs


### writable_dirs
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L27)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L25)

Overrides [writable_dirs](/docs/recipe/deploy/writable.md#writable_dirs) from `recipe/deploy/writable.php`.

Silverstripe writable dirs


```php title="Default value"
[
Expand All @@ -90,10 +91,23 @@ Silverstripe writable dirs
```


### silverstripe_sake
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L33)

Path to the `sake` binary.
Defaults to `"vendor/bin/sake"`, if it exists.
:::info Autogenerated
The value of this configuration is autogenerated on access.
:::




### silverstripe_cli_script
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L32)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L49)

Silverstripe cli script
Deprecated option, retained for backward compatibility.
For Silverstripe 6 and above, use `silverstripe_sake` instead.
:::info Autogenerated
The value of this configuration is autogenerated on access.
:::
Expand All @@ -105,23 +119,23 @@ The value of this configuration is autogenerated on access.
## Tasks

### silverstripe\:build {#silverstripe-build}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L48)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L65)

Runs /dev/build.
Rebuild the database.

Helper tasks


### silverstripe\:buildflush {#silverstripe-buildflush}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L53)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L76)

Runs /dev/build?flush=all.
Rebuild database and cache.




### deploy {#deploy}
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L61)
[Source](https://github.com/deployphp/deployer/blob/master/recipe/silverstripe.php#L90)

Deploys your project.

Expand Down
55 changes: 42 additions & 13 deletions recipe/silverstripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
add('recipes', ['silverstripe']);

/**
* Silverstripe configuration
* 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';
Expand All @@ -18,40 +18,69 @@
});


// Silverstripe shared dirs
set('shared_dirs', [
'{{shared_assets}}',
]);

// Silverstripe writable dirs
set('writable_dirs', [
'{{shared_assets}}',
]);

// Silverstripe cli script
/**
* 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 () {
$paths = [
$candidates = [
'framework/cli-script.php',
'vendor/silverstripe/framework/cli-script.php',
];
foreach ($paths as $path) {
if (test('[ -f {{release_or_current_path}}/' . $path . ' ]')) {
return $path;
foreach ($candidates as $candidate) {
if (test("[ -f '{{release_or_current_path}}/$candidate' ]")) {
return $candidate;
}
}
});

/**
* Helper tasks
*/
desc('Runs /dev/build');
desc('Rebuild the database');
task('silverstripe:build', function () {
run('{{bin/php}} {{release_or_current_path}}/{{silverstripe_cli_script}} /dev/build');
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('Runs /dev/build?flush=all');
desc('Rebuild database and cache');
task('silverstripe:buildflush', function () {
run('{{bin/php}} {{release_or_current_path}}/{{silverstripe_cli_script}} /dev/build flush=all');
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');
}
});

/**
Expand Down