Skip to content

Commit 8b2064e

Browse files
[6.x] Publish dev build during setup-cp-vite/make:fieldtype commands (#13282)
1 parent 3565f5f commit 8b2064e

File tree

5 files changed

+31
-0
lines changed

5 files changed

+31
-0
lines changed

src/Console/Commands/Concerns/MakesVueComponents.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ private function wireUpAddonJs(string $addon): void
8686
});
8787

8888
$this->configureViteInAddonServiceProvider();
89+
90+
$this->call('vendor:publish', ['--tag' => 'statamic-cp-dev']);
8991
}
9092

9193
private function cpJsExists(): bool

src/Console/Commands/SetupCpVite.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function handle(): void
4040
->addScriptsToPackageJson()
4141
->publishViteConfig()
4242
->publishStubs()
43+
->publishDevBuild()
4344
->appendViteSnippetToAppServiceProvider();
4445
}
4546

@@ -138,6 +139,13 @@ private function publishStubs(): self
138139
return $this;
139140
}
140141

142+
private function publishDevBuild(): self
143+
{
144+
$this->call('vendor:publish', ['--tag' => 'statamic-cp-dev']);
145+
146+
return $this;
147+
}
148+
141149
private function appendViteSnippetToAppServiceProvider(): self
142150
{
143151
spin(

tests/Console/Commands/Concerns/CleansUpGeneratedPaths.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ protected function cleanupPaths()
2020
resource_path('js/components'),
2121
resource_path('views/widgets'),
2222
base_path('vendor'),
23+
public_path('vendor'),
24+
__DIR__.'/../../../../resources/dist-dev',
2325
];
2426

2527
foreach ($dirs as $dir) {

tests/Console/Commands/MakeFieldtypeTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function setUp(): void
2121

2222
Process::fake();
2323
$this->files = app(Filesystem::class);
24+
$this->files->makeDirectory(__DIR__.'/../../../resources/dist-dev', 0755, true, true);
2425
$this->fakeSuccessfulComposerRequire();
2526
}
2627

@@ -156,6 +157,8 @@ public function it_can_make_a_fieldtype_into_an_addon()
156157
{
157158
$path = base_path('addons/yoda/bag-odah');
158159

160+
$this->assertDirectoryDoesNotExist(public_path('vendor/statamic/cp-dev'));
161+
159162
$this->artisan('statamic:make:addon', ['addon' => 'yoda/bag-odah']);
160163

161164
Composer::shouldReceive('installedPath')->andReturn($path);
@@ -168,5 +171,7 @@ public function it_can_make_a_fieldtype_into_an_addon()
168171

169172
$this->assertFileExists($fieldtype);
170173
$this->assertStringContainsString('namespace Yoda\BagOdah\Fieldtypes;', $this->files->get($fieldtype));
174+
175+
$this->assertDirectoryExists(public_path('vendor/statamic/cp-dev'));
171176
}
172177
}

tests/Console/Commands/SetupCpViteTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ public function it_only_publishes_necessary_stubs()
137137
$this->assertFileDoesNotExist(resource_path('js/components/fieldtypes/ExampleFieldtype.vue'));
138138
}
139139

140+
#[Test]
141+
public function it_publishes_dev_build()
142+
{
143+
$this->assertDirectoryDoesNotExist(public_path('vendor/statamic/cp-dev'));
144+
145+
$this
146+
->artisan('statamic:setup-cp-vite', ['--only-necessary' => true])
147+
->expectsOutputToContain('Publishing [statamic-cp-dev] assets.');
148+
149+
$this->assertDirectoryExists(public_path('vendor/statamic/cp-dev'));
150+
}
151+
140152
#[Test]
141153
public function it_appends_vite_snippet_to_app_service_provider()
142154
{
@@ -192,5 +204,7 @@ public function boot(): void
192204
PHP);
193205

194206
$this->files->put(base_path('package.json'), json_encode([]));
207+
208+
$this->files->makeDirectory(__DIR__.'/../../../resources/dist-dev', 0755, true, true);
195209
}
196210
}

0 commit comments

Comments
 (0)