forked from filamentphp/plugin-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb2bfe4
commit 0c5ad47
Showing
3 changed files
with
27 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,9 +40,9 @@ | |
writeln("Class name : {$className}"); | ||
writeln('---'); | ||
writeln('Packages & Utilities'); | ||
writeln('Use Larastan/PhpStan : ' . ($usePhpStan ? 'yes' : 'no')); | ||
writeln('Use Pint : ' . ($usePint ? 'yes' : 'no')); | ||
writeln('Use Auto-Changelog : ' . ($useUpdateChangelogWorkflow ? 'yes' : 'no')); | ||
writeln('Use Larastan/PhpStan : '.($usePhpStan ? 'yes' : 'no')); | ||
writeln('Use Pint : '.($usePint ? 'yes' : 'no')); | ||
writeln('Use Auto-Changelog : '.($useUpdateChangelogWorkflow ? 'yes' : 'no')); | ||
writeln('------'); | ||
|
||
writeln('This script will replace the above values in all relevant files in the project directory.'); | ||
|
@@ -70,20 +70,20 @@ | |
]); | ||
|
||
match (true) { | ||
str_contains($file, determineSeparator('src/Skeleton.php')) => rename($file, determineSeparator('./src/' . $className . '.php')), | ||
str_contains($file, determineSeparator('src/SkeletonServiceProvider.php')) => rename($file, determineSeparator('./src/' . $className . 'ServiceProvider.php')), | ||
str_contains($file, determineSeparator('src/Facades/Skeleton.php')) => rename($file, determineSeparator('./src/Facades/' . $className . '.php')), | ||
str_contains($file, determineSeparator('src/Commands/SkeletonCommand.php')) => rename($file, determineSeparator('./src/Commands/' . $className . 'Command.php')), | ||
str_contains($file, determineSeparator('database/migrations/create_skeleton_table.php.stub')) => rename($file, determineSeparator('./database/migrations/create_' . $packageSlugWithoutPrefix . '_table.php.stub')), | ||
str_contains($file, determineSeparator('config/skeleton.php')) => rename($file, determineSeparator('./config/' . $packageSlugWithoutPrefix . '.php')), | ||
str_contains($file, determineSeparator('src/Skeleton.php')) => rename($file, determineSeparator('./src/'.$className.'.php')), | ||
str_contains($file, determineSeparator('src/SkeletonServiceProvider.php')) => rename($file, determineSeparator('./src/'.$className.'ServiceProvider.php')), | ||
str_contains($file, determineSeparator('src/Facades/Skeleton.php')) => rename($file, determineSeparator('./src/Facades/'.$className.'.php')), | ||
str_contains($file, determineSeparator('src/Commands/SkeletonCommand.php')) => rename($file, determineSeparator('./src/Commands/'.$className.'Command.php')), | ||
str_contains($file, determineSeparator('database/migrations/create_skeleton_table.php.stub')) => rename($file, determineSeparator('./database/migrations/create_'.$packageSlugWithoutPrefix.'_table.php.stub')), | ||
str_contains($file, determineSeparator('config/skeleton.php')) => rename($file, determineSeparator('./config/'.$packageSlugWithoutPrefix.'.php')), | ||
str_contains($file, 'README.md') => remove_readme_paragraphs($file), | ||
default => [], | ||
}; | ||
} | ||
|
||
if (! $usePint) { | ||
safeUnlink(__DIR__ . '/pint.json'); | ||
safeUnlink(__DIR__ . '/.github/workflows/pint.yml'); | ||
safeUnlink(__DIR__.'/pint.json'); | ||
safeUnlink(__DIR__.'/.github/workflows/pint.yml'); | ||
|
||
remove_composer_deps([ | ||
'laravel/pint', | ||
|
@@ -93,9 +93,9 @@ | |
} | ||
|
||
if (! $usePhpStan) { | ||
safeUnlink(__DIR__ . '/phpstan.neon.dist'); | ||
safeUnlink(__DIR__ . '/phpstan-baseline.neon'); | ||
safeUnlink(__DIR__ . '/.github/workflows/phpstan.yml'); | ||
safeUnlink(__DIR__.'/phpstan.neon.dist'); | ||
safeUnlink(__DIR__.'/phpstan-baseline.neon'); | ||
safeUnlink(__DIR__.'/.github/workflows/phpstan.yml'); | ||
|
||
remove_composer_deps([ | ||
'phpstan/extension-installer', | ||
|
@@ -111,7 +111,7 @@ | |
} | ||
|
||
if (! $useUpdateChangelogWorkflow) { | ||
safeUnlink(__DIR__ . '/.github/workflows/update-changelog.yml'); | ||
safeUnlink(__DIR__.'/.github/workflows/update-changelog.yml'); | ||
} | ||
|
||
confirm('Execute `composer install` and run tests?') && run('composer install && composer test'); | ||
|
@@ -122,7 +122,7 @@ function ask(string $question, string $default = ''): string | |
{ | ||
$consoleColor = new ConsoleColor(); | ||
$def = $default ? $consoleColor->apply('yellow', " ({$default})") : null; | ||
$answer = readline($consoleColor->apply('green', $question . $def . ': ')); | ||
$answer = readline($consoleColor->apply('green', $question.$def.': ')); | ||
|
||
if (! $answer) { | ||
return $default; | ||
|
@@ -146,7 +146,7 @@ function confirm(string $question, bool $default = false): bool | |
|
||
function writeln(string $line): void | ||
{ | ||
echo $line . PHP_EOL; | ||
echo $line.PHP_EOL; | ||
} | ||
|
||
function run(string $command): string | ||
|
@@ -200,20 +200,20 @@ function remove_prefix(string $prefix, string $content): string | |
|
||
function remove_composer_deps(array $names) | ||
{ | ||
$data = json_decode(file_get_contents(__DIR__ . '/composer.json'), true); | ||
$data = json_decode(file_get_contents(__DIR__.'/composer.json'), true); | ||
|
||
foreach ($data['require-dev'] as $name => $version) { | ||
if (in_array($name, $names, true)) { | ||
unset($data['require-dev'][$name]); | ||
} | ||
} | ||
|
||
file_put_contents(__DIR__ . '/composer.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); | ||
file_put_contents(__DIR__.'/composer.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); | ||
} | ||
|
||
function remove_composer_script(array $scriptNames) | ||
{ | ||
$data = json_decode(file_get_contents(__DIR__ . '/composer.json'), true); | ||
$data = json_decode(file_get_contents(__DIR__.'/composer.json'), true); | ||
|
||
foreach ($data['scripts'] as $name => $script) { | ||
if (is_array($script)) { | ||
|
@@ -231,7 +231,7 @@ function remove_composer_script(array $scriptNames) | |
} | ||
} | ||
|
||
file_put_contents(__DIR__ . '/composer.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); | ||
file_put_contents(__DIR__.'/composer.json', json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)); | ||
} | ||
|
||
function remove_readme_paragraphs(string $file): void | ||
|
@@ -258,12 +258,12 @@ function determineSeparator(string $path): string | |
|
||
function replaceForWindows(): array | ||
{ | ||
return preg_split('/\\r\\n|\\r|\\n/', run('dir /S /B * | findstr /v /i .git\ | findstr /v /i vendor | findstr /v /i ' . basename(__FILE__) . ' | findstr /r /i /M /F:/ ":author :vendor :package VendorName skeleton vendor_name vendor_slug [email protected]"')); | ||
return preg_split('/\\r\\n|\\r|\\n/', run('dir /S /B * | findstr /v /i .git\ | findstr /v /i vendor | findstr /v /i '.basename(__FILE__).' | findstr /r /i /M /F:/ ":author :vendor :package VendorName skeleton vendor_name vendor_slug [email protected]"')); | ||
} | ||
|
||
function replaceForAllOtherOSes(): array | ||
{ | ||
return explode(PHP_EOL, run('grep -E -r -l -i ":author|:vendor|:package|VendorName|skeleton|vendor_name|vendor_slug|[email protected]" --exclude-dir=vendor ./* ./.github/* | grep -v ' . basename(__FILE__))); | ||
return explode(PHP_EOL, run('grep -E -r -l -i ":author|:vendor|:package|VendorName|skeleton|vendor_name|vendor_slug|[email protected]" --exclude-dir=vendor ./* ./.github/* | grep -v '.basename(__FILE__))); | ||
} | ||
|
||
class ConsoleColor | ||
|
@@ -381,7 +381,7 @@ public function apply($style, $text) | |
return $text; | ||
} | ||
|
||
return $this->escSequence(implode(';', $sequences)) . $text . $this->escSequence(self::RESET_STYLE); | ||
return $this->escSequence(implode(';', $sequences)).$text.$this->escSequence(self::RESET_STYLE); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters