diff --git a/src/Foundation/Config.php b/src/Foundation/Config.php index 19be9df7..01c84c96 100644 --- a/src/Foundation/Config.php +++ b/src/Foundation/Config.php @@ -42,7 +42,7 @@ * install: bool, * auth: bool, * welcome: bool|null, - * sync: array, + * sync: array, * build: array|string>, * assets: array, * discovers: TWorkbenchDiscoversConfig @@ -54,7 +54,7 @@ * install?: bool, * auth?: bool, * welcome?: bool|null, - * sync?: array, + * sync?: array, * build?: array|string>, * assets?: array, * discovers?: TWorkbenchOptionalDiscoversConfig diff --git a/src/Workbench/Actions/AddAssetSymlinkFolders.php b/src/Workbench/Actions/AddAssetSymlinkFolders.php index 7ff6dc76..2d76923d 100644 --- a/src/Workbench/Actions/AddAssetSymlinkFolders.php +++ b/src/Workbench/Actions/AddAssetSymlinkFolders.php @@ -32,16 +32,19 @@ public function __construct( */ public function handle(): void { - /** @var array $sync */ + /** @var array $sync */ $sync = $this->config->getWorkbenchAttributes()['sync'] ?? []; Collection::make($sync) ->map(function ($pair) { + /** @var bool $reverse */ + $reverse = isset($pair['reverse']) && \is_bool($pair['reverse']) ? $pair['reverse'] : false; + /** @var string $from */ - $from = package_path($pair['from']); + $from = $reverse === false ? package_path($pair['from']) : base_path($pair['from']); /** @var string $to */ - $to = base_path($pair['to']); + $to = $reverse === false ? base_path($pair['to']) : package_path($pair['to']); return $this->files->isDirectory($from) ? ['from' => $from, 'to' => $to] diff --git a/src/Workbench/Actions/RemoveAssetSymlinkFolders.php b/src/Workbench/Actions/RemoveAssetSymlinkFolders.php index d1789118..3c7b57b6 100644 --- a/src/Workbench/Actions/RemoveAssetSymlinkFolders.php +++ b/src/Workbench/Actions/RemoveAssetSymlinkFolders.php @@ -31,16 +31,19 @@ public function __construct( */ public function handle(): void { - /** @var array $sync */ + /** @var array $sync */ $sync = $this->config->getWorkbenchAttributes()['sync'] ?? []; Collection::make($sync) ->map(static function ($pair) { + /** @var bool $reverse */ + $reverse = isset($pair['reverse']) && \is_bool($pair['reverse']) ? $pair['reverse'] : false; + /** @var string $from */ - $from = package_path($pair['from']); + $from = $reverse === false ? package_path($pair['from']) : base_path($pair['from']); /** @var string $to */ - $to = base_path($pair['to']); + $to = $reverse === false ? base_path($pair['to']) : package_path($pair['to']); if (windows_os() && is_dir($to) && readlink($to) !== $to) { return [$to, static function ($to) { diff --git a/testbench.yaml b/testbench.yaml index 4fcbf859..11fa749e 100644 --- a/testbench.yaml +++ b/testbench.yaml @@ -15,6 +15,10 @@ workbench: api: true commands: true views: true + sync: + - from: storage + to: workbench/storage + reverse: true purge: directories: public/vendor/* diff --git a/workbench/.gitignore b/workbench/.gitignore index 6088e424..3d86fd9e 100644 --- a/workbench/.gitignore +++ b/workbench/.gitignore @@ -1,3 +1,5 @@ .env .env.dist .env.example + +/storage