Skip to content

Commit

Permalink
move default exclude list to nativephp-internal config
Browse files Browse the repository at this point in the history
  • Loading branch information
gwleuverink committed Jan 14, 2025
1 parent 550922d commit 7f6176b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
27 changes: 0 additions & 27 deletions src/Commands/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,6 @@ protected function buildPath(): string
return __DIR__.'/../../resources/js/resources/app';
}

const CLEANUP_PATTERNS = [
// .git and dev directories
'.git',
'dist',
'docker',
'packages',
'**/.github',

// Potentially containing sensitive info
'database/*.sqlite',
'database/*.sqlite-shm',
'database/*.sqlite-wal',

'storage/framework/sessions/*',
'storage/framework/testing/*',
'storage/framework/cache/*',
'storage/framework/views/*',
'storage/logs/*',

// Only needed for local testing
'vendor/nativephp/electron/resources',
'vendor/nativephp/electron/vendor',
'vendor/nativephp/electron/bin',
'vendor/nativephp/laravel/vendor',
'vendor/nativephp/php-bin',
];

public function handle(): void
{
$this->setAppName(slugify: true);
Expand Down
6 changes: 5 additions & 1 deletion src/Traits/CopiesToBuildDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@ protected function copyToBuildDirectory()
$buildPath = $this->buildPath();
$filesystem = new Filesystem;

$patterns = array_merge(
config('nativephp-internal.cleanup_exclude_files', []),
config('nativephp.cleanup_exclude_files', [])
);

// Clean and create build directory
$filesystem->remove($buildPath);
$filesystem->mkdir($buildPath);

// A filtered iterator that will exclude files matching our skip patterns
$patterns = array_merge(static::CLEANUP_PATTERNS, config('nativephp.cleanup_exclude_files', []));
$directory = new RecursiveDirectoryIterator($sourcePath, RecursiveDirectoryIterator::SKIP_DOTS | RecursiveDirectoryIterator::FOLLOW_SYMLINKS);

$filter = new RecursiveCallbackFilterIterator($directory, function ($current) use ($patterns) {
Expand Down

0 comments on commit 7f6176b

Please sign in to comment.