Skip to content

Commit

Permalink
[8.x] Adds ability to symlink directory in from skeleton to package (#…
Browse files Browse the repository at this point in the history
…282)

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* [7.x] Adds ability to symlink directory in from skeleton to package

solved orchestral/workbench#64

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

---------

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone authored Dec 17, 2024
1 parent eeb561b commit adc1d1a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Foundation/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* install: bool,
* auth: bool,
* welcome: bool|null,
* sync: array<int, array{from: string, to: string}>,
* sync: array<int, array{from: string, to: string, reverse?: bool}>,
* build: array<int|string, array<string, mixed>|string>,
* assets: array<int, string>,
* discovers: TWorkbenchDiscoversConfig
Expand All @@ -54,7 +54,7 @@
* install?: bool,
* auth?: bool,
* welcome?: bool|null,
* sync?: array<int, array{from: string, to: string}>,
* sync?: array<int, array{from: string, to: string, reverse?: bool}>,
* build?: array<int|string, array<string, mixed>|string>,
* assets?: array<int, string>,
* discovers?: TWorkbenchOptionalDiscoversConfig
Expand Down
9 changes: 6 additions & 3 deletions src/Workbench/Actions/AddAssetSymlinkFolders.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,19 @@ public function __construct(
*/
public function handle(): void
{
/** @var array<int, array{from: string, to: string}> $sync */
/** @var array<int, array{from: string, to: string, reverse?: bool}> $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]
Expand Down
9 changes: 6 additions & 3 deletions src/Workbench/Actions/RemoveAssetSymlinkFolders.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ public function __construct(
*/
public function handle(): void
{
/** @var array<int, array{from: string, to: string}> $sync */
/** @var array<int, array{from: string, to: string, reverse?: bool}> $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) {
Expand Down
4 changes: 4 additions & 0 deletions testbench.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ workbench:
api: true
commands: true
views: true
sync:
- from: storage
to: workbench/storage
reverse: true

purge:
directories: public/vendor/*
2 changes: 2 additions & 0 deletions workbench/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.env
.env.dist
.env.example

/storage

0 comments on commit adc1d1a

Please sign in to comment.