Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim-the-Diamond authored and github-actions[bot] committed Mar 6, 2024
1 parent 8f9e65e commit ff6326c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions packages/builder/build.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ function replaceForAllOtherOSes(): array
$currentDirectory = getcwd();
$folderName = basename($currentDirectory);

if(!isValidPackageName($folderName)){
if (! isValidPackageName($folderName)) {
do {
writeln('Invalid package name: "builder" is not allowed.');
$name = ask('Package name');
$packageName = $name;
} while (! isValidPackageName($packageName));
}else{
} else {
$packageName = $folderName;
}

Expand Down
76 changes: 38 additions & 38 deletions packages/builder/src/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,64 +100,64 @@ public function run_migrations(): void
public function register_plugins(): void
{
if (confirm('Do you wish to publish the configuration?', true)) {
note('Registering the Filament Resources...');
note('Registering the Filament Resources...');

$providerPath = app_path('Providers/Filament/AdminPanelProvider.php');
$providerPath = app_path('Providers/Filament/AdminPanelProvider.php');

if (File::exists($providerPath)) {
if (File::exists($providerPath)) {

$content = File::get($providerPath);
$content = File::get($providerPath);

$intend = ' ';
$intend = ' ';

$namespace = "\Moox\Builder";
$namespace = "\Moox\Builder";

$pluginsToAdd = multiselect(
label: 'These plugins will be installed:',
options: ['BuilderPlugin'],
default: ['BuilderPlugin'],
);
$pluginsToAdd = multiselect(
label: 'These plugins will be installed:',
options: ['BuilderPlugin'],
default: ['BuilderPlugin'],
);

$function = '::make(),';
$function = '::make(),';

$pattern = '/->plugins\(\[([\s\S]*?)\]\);/';
$newPlugins = '';
$pattern = '/->plugins\(\[([\s\S]*?)\]\);/';
$newPlugins = '';

foreach ($pluginsToAdd as $plugin) {
$searchPlugin = '/'.$plugin.'/';
if (preg_match($searchPlugin, $content)) {
info("$plugin already registered.");
} else {
$newPlugins .= $intend.$namespace.'\\'.$plugin.$function."\n";
foreach ($pluginsToAdd as $plugin) {
$searchPlugin = '/'.$plugin.'/';
if (preg_match($searchPlugin, $content)) {
info("$plugin already registered.");
} else {
$newPlugins .= $intend.$namespace.'\\'.$plugin.$function."\n";
}
}
}

if ($newPlugins) {
if ($newPlugins) {

if (preg_match($pattern, $content)) {
info('Plugins section found. Adding new plugins...');
if (preg_match($pattern, $content)) {
info('Plugins section found. Adding new plugins...');

$replacement = "->plugins([$1\n$newPlugins\n ]);";
$newContent = preg_replace($pattern, $replacement, $content);
$replacement = "->plugins([$1\n$newPlugins\n ]);";
$newContent = preg_replace($pattern, $replacement, $content);

} else {
info('Plugins section created. Adding new plugins...');
} else {
info('Plugins section created. Adding new plugins...');

$pluginsSection = " ->plugins([\n$newPlugins\n ]);";
$placeholderPattern = '/(\->authMiddleware\(\[.*?\]\))\s*\;/s';
$replacement = "$1\n".$pluginsSection;
$newContent = preg_replace($placeholderPattern, $replacement, $content, 1);
}
$pluginsSection = " ->plugins([\n$newPlugins\n ]);";
$placeholderPattern = '/(\->authMiddleware\(\[.*?\]\))\s*\;/s';
$replacement = "$1\n".$pluginsSection;
$newContent = preg_replace($placeholderPattern, $replacement, $content, 1);
}

File::put($providerPath, $newContent);
}
File::put($providerPath, $newContent);
}

} else {
} else {

alert('AdminPanelProvider not found. You need to add the plugins manually.');
alert('AdminPanelProvider not found. You need to add the plugins manually.');
}
}
}
}

public function finish(): void
{
Expand Down

0 comments on commit ff6326c

Please sign in to comment.