Skip to content

Commit 0a06e31

Browse files
authored
Merge pull request #24 from tattersoftware/source
Vendor Path
2 parents 39b82b0 + 7edae2e commit 0a06e31

8 files changed

+41
-19
lines changed

Diff for: src/FrontendPublisher.php

+14-4
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,32 @@
1515
*/
1616
abstract class FrontendPublisher extends Publisher
1717
{
18+
/**
19+
* Destination path relative to vendor/ directory.
20+
* Must be set by child classes.
21+
*/
22+
protected string $vendorPath = '';
23+
1824
/**
1925
* Destination path relative to AssetsConfig::directory.
2026
* Must be set by child classes.
2127
*/
22-
protected string $path = '';
28+
protected string $publicPath = '';
2329

2430
/**
2531
* Set the real destination.
2632
*/
2733
public function __construct(?string $source = null, ?string $destination = null)
2834
{
29-
if ($this->path === '') {
30-
throw new DomainException('Invalid relative destination $path.');
35+
if ($this->vendorPath === '') {
36+
throw new DomainException('Invalid relative source path.');
37+
}
38+
if ($this->publicPath === '') {
39+
throw new DomainException('Invalid relative destination path.');
3140
}
3241

33-
$this->destination = FrontendBundle::base() . ltrim($this->path, '\\/');
42+
$this->source = dirname(COMPOSER_PATH) . '/' . ltrim($this->vendorPath, '\\/');
43+
$this->destination = FrontendBundle::base() . ltrim($this->publicPath, '\\/');
3444

3545
if (! is_dir($this->destination)) {
3646
mkdir($this->destination, 0775, true);

Diff for: src/Publishers/AdminLTEPublisher.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
class AdminLTEPublisher extends FrontendPublisher
88
{
9-
protected $source = 'vendor/almasaeed2010/adminlte/dist';
10-
protected string $path = 'adminlte';
9+
protected string $vendorPath = 'almasaeed2010/adminlte/dist';
10+
protected string $publicPath = 'adminlte';
1111
}

Diff for: src/Publishers/BootstrapPublisher.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
class BootstrapPublisher extends FrontendPublisher
88
{
9-
protected $source = 'vendor/twbs/bootstrap/dist';
10-
protected string $path = 'bootstrap';
9+
protected string $vendorPath = 'twbs/bootstrap/dist';
10+
protected string $publicPath = 'bootstrap';
1111
}

Diff for: src/Publishers/DataTablesPublisher.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
class DataTablesPublisher extends FrontendPublisher
88
{
9-
protected $source = 'vendor/datatables.net/datatables.net';
10-
protected string $path = 'datatables';
9+
protected string $vendorPath = 'datatables.net/datatables.net';
10+
protected string $publicPath = 'datatables';
1111

1212
/**
1313
* Reads files from the sources and copies them out to their destinations.

Diff for: src/Publishers/DataTablesStylePublisher.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
class DataTablesStylePublisher extends FrontendPublisher
88
{
9-
protected $source = 'vendor/datatables.net/datatables.net-bs4';
10-
protected string $path = 'datatables';
9+
protected string $vendorPath = 'datatables.net/datatables.net-bs4';
10+
protected string $publicPath = 'datatables';
1111

1212
/**
1313
* Reads files from the sources and copies them out to their destinations.

Diff for: src/Publishers/FontAwesomePublisher.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
class FontAwesomePublisher extends FrontendPublisher
88
{
9-
protected $source = 'vendor/fortawesome/font-awesome';
10-
protected string $path = 'font-awesome';
9+
protected string $vendorPath = 'fortawesome/font-awesome';
10+
protected string $publicPath = 'font-awesome';
1111

1212
/**
1313
* Reads files from the sources and copies them out to their destinations.

Diff for: src/Publishers/JQueryPublisher.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
class JQueryPublisher extends FrontendPublisher
88
{
9-
protected $source = 'vendor/components/jquery';
10-
protected string $path = 'jquery';
9+
protected string $vendorPath = 'components/jquery';
10+
protected string $publicPath = 'jquery';
1111
}

Diff for: tests/FrontendPublisherTest.php

+15-3
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,23 @@ final class FrontendPublisherTest extends CIUnitTestCase
1111
{
1212
use AssetsTestTrait;
1313

14+
public function testPublisherThrowsWithoutSourcePath()
15+
{
16+
$this->expectException('DomainException');
17+
$this->expectExceptionMessage('Invalid relative source path');
18+
19+
new class () extends FrontendPublisher {
20+
protected string $publicPath = 'adminlte';
21+
};
22+
}
23+
1424
public function testPublisherThrowsWithoutPath()
1525
{
1626
$this->expectException('DomainException');
17-
$this->expectExceptionMessage('Invalid relative destination $path');
27+
$this->expectExceptionMessage('Invalid relative destination path');
1828

1929
new class () extends FrontendPublisher {
30+
protected string $vendorPath = 'almasaeed2010/adminlte/dist';
2031
};
2132
}
2233

@@ -25,8 +36,9 @@ public function testPublisherSetsDestination()
2536
// Allow publishing to the test folder
2637
config('Publisher')->restrictions[SUPPORTPATH] = '*';
2738

28-
$publisher = new class () extends FrontendPublisher {
29-
protected string $path = 'foobar';
39+
$publisher = new class () extends FrontendPublisher {
40+
protected string $publicPath = 'foobar';
41+
protected string $vendorPath = 'almasaeed2010/adminlte/dist';
3042
};
3143

3244
$this->assertSame($this->assets->directory . 'vendor/foobar/', $publisher->getDestination());

0 commit comments

Comments
 (0)