Skip to content

Commit 8730c63

Browse files
committed
fix: do a better job cleaning up unnecessary files
1 parent 906ad92 commit 8730c63

3 files changed

Lines changed: 20 additions & 16 deletions

File tree

src/Build/CompressBuildFilesStep.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,15 @@ public function perform(string $environment, ProjectConfiguration $projectConfig
5959
$archive = new \ZipArchive();
6060
$archive->open($this->buildArtifactPath, \ZipArchive::CREATE | \ZipArchive::OVERWRITE);
6161
$environment = (array) $projectConfiguration->getEnvironment($environment);
62-
6362
$files = Finder::create()
6463
->append($this->getRequiredFiles())
6564
->append($this->getRequiredFileTypes())
6665
->append($this->getWordPressCoreFiles($projectConfiguration->getProjectType()));
6766

67+
if ('bedrock' === $projectConfiguration->getProjectType()) {
68+
$files->exclude(['web/wp/wp-content']);
69+
}
70+
6871
if (Arr::has($environment, 'build.include')) {
6972
$files->append($this->getIncludedFiles(Arr::get($environment, 'build.include')));
7073
}

src/Build/CopyWordPressFilesStep.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,14 @@ public function perform(string $environment, ProjectConfiguration $projectConfig
7171

7272
$this->filesystem->mkdir($this->buildDirectory, 0755);
7373

74-
foreach ($this->getProjectFiles($projectConfiguration->getProjectType()) as $file) {
75-
$this->copyFile($file);
74+
$environment = (array) $projectConfiguration->getEnvironment($environment);
75+
$files = $this->getProjectFiles($projectConfiguration->getProjectType());
76+
77+
if (Arr::has($environment, 'build.include')) {
78+
$files->append($this->getIncludedFiles(Arr::get($environment, 'build.include')));
7679
}
7780

78-
foreach ($this->getIncludedFiles(Arr::get((array) $projectConfiguration->getEnvironment($environment), 'build.include', [])) as $file) {
81+
foreach ($files as $file) {
7982
$this->copyFile($file);
8083
}
8184
}

src/Build/ExtractAssetFilesStep.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,22 +76,20 @@ public function perform(string $environment, ProjectConfiguration $projectConfig
7676
$fromDirectory .= '/web';
7777
}
7878

79-
foreach ($this->getAssetFiles($fromDirectory) as $file) {
80-
$this->moveAssetFile($file);
81-
}
82-
}
83-
84-
/**
85-
* Get the asset files that we want to extract.
86-
*/
87-
private function getAssetFiles(string $fromDirectory): Finder
88-
{
89-
return Finder::create()
79+
$files = Finder::create()
9080
->in($fromDirectory)
9181
->files()
92-
->notName(['*.php'])
82+
->notName(['*.php', '*.mo', '*.po'])
9383
->followLinks()
9484
->ignoreDotFiles(true);
85+
86+
if ('bedrock' === $projectConfiguration->getProjectType()) {
87+
$files->exclude(['wp/wp-content']);
88+
}
89+
90+
foreach ($files as $file) {
91+
$this->moveAssetFile($file);
92+
}
9593
}
9694

9795
/**

0 commit comments

Comments
 (0)