4040writeln ("Class name : {$ className }" );
4141writeln ('--- ' );
4242writeln ('Packages & Utilities ' );
43- writeln ('Use Larastan/PhpStan : ' . ($ usePhpStan ? 'yes ' : 'no ' ));
44- writeln ('Use Pint : ' . ($ usePint ? 'yes ' : 'no ' ));
45- writeln ('Use Auto-Changelog : ' . ($ useUpdateChangelogWorkflow ? 'yes ' : 'no ' ));
43+ writeln ('Use Larastan/PhpStan : ' . ($ usePhpStan ? 'yes ' : 'no ' ));
44+ writeln ('Use Pint : ' . ($ usePint ? 'yes ' : 'no ' ));
45+ writeln ('Use Auto-Changelog : ' . ($ useUpdateChangelogWorkflow ? 'yes ' : 'no ' ));
4646writeln ('------ ' );
4747
4848writeln ('This script will replace the above values in all relevant files in the project directory. ' );
7070 ]);
7171
7272 match (true ) {
73- str_contains ($ file , determineSeparator ('src/Skeleton.php ' )) => rename ($ file , determineSeparator ('./src/ ' . $ className . '.php ' )),
74- str_contains ($ file , determineSeparator ('src/SkeletonServiceProvider.php ' )) => rename ($ file , determineSeparator ('./src/ ' . $ className . 'ServiceProvider.php ' )),
75- str_contains ($ file , determineSeparator ('src/Facades/Skeleton.php ' )) => rename ($ file , determineSeparator ('./src/Facades/ ' . $ className . '.php ' )),
76- str_contains ($ file , determineSeparator ('src/Commands/SkeletonCommand.php ' )) => rename ($ file , determineSeparator ('./src/Commands/ ' . $ className . 'Command.php ' )),
77- str_contains ($ file , determineSeparator ('database/migrations/create_skeleton_table.php.stub ' )) => rename ($ file , determineSeparator ('./database/migrations/create_ ' . $ packageSlugWithoutPrefix . '_table.php.stub ' )),
78- str_contains ($ file , determineSeparator ('config/skeleton.php ' )) => rename ($ file , determineSeparator ('./config/ ' . $ packageSlugWithoutPrefix . '.php ' )),
73+ str_contains ($ file , determineSeparator ('src/Skeleton.php ' )) => rename ($ file , determineSeparator ('./src/ ' . $ className. '.php ' )),
74+ str_contains ($ file , determineSeparator ('src/SkeletonServiceProvider.php ' )) => rename ($ file , determineSeparator ('./src/ ' . $ className. 'ServiceProvider.php ' )),
75+ str_contains ($ file , determineSeparator ('src/Facades/Skeleton.php ' )) => rename ($ file , determineSeparator ('./src/Facades/ ' . $ className. '.php ' )),
76+ str_contains ($ file , determineSeparator ('src/Commands/SkeletonCommand.php ' )) => rename ($ file , determineSeparator ('./src/Commands/ ' . $ className. 'Command.php ' )),
77+ str_contains ($ file , determineSeparator ('database/migrations/create_skeleton_table.php.stub ' )) => rename ($ file , determineSeparator ('./database/migrations/create_ ' . $ packageSlugWithoutPrefix. '_table.php.stub ' )),
78+ str_contains ($ file , determineSeparator ('config/skeleton.php ' )) => rename ($ file , determineSeparator ('./config/ ' . $ packageSlugWithoutPrefix. '.php ' )),
7979 str_contains ($ file , 'README.md ' ) => remove_readme_paragraphs ($ file ),
8080 default => [],
8181 };
8282}
8383
8484if (! $ usePint ) {
85- safeUnlink (__DIR__ . '/pint.json ' );
86- safeUnlink (__DIR__ . '/.github/workflows/pint.yml ' );
85+ safeUnlink (__DIR__ . '/pint.json ' );
86+ safeUnlink (__DIR__ . '/.github/workflows/pint.yml ' );
8787
8888 remove_composer_deps ([
8989 'laravel/pint ' ,
9393}
9494
9595if (! $ usePhpStan ) {
96- safeUnlink (__DIR__ . '/phpstan.neon.dist ' );
97- safeUnlink (__DIR__ . '/phpstan-baseline.neon ' );
98- safeUnlink (__DIR__ . '/.github/workflows/phpstan.yml ' );
96+ safeUnlink (__DIR__ . '/phpstan.neon.dist ' );
97+ safeUnlink (__DIR__ . '/phpstan-baseline.neon ' );
98+ safeUnlink (__DIR__ . '/.github/workflows/phpstan.yml ' );
9999
100100 remove_composer_deps ([
101101 'phpstan/extension-installer ' ,
111111}
112112
113113if (! $ useUpdateChangelogWorkflow ) {
114- safeUnlink (__DIR__ . '/.github/workflows/update-changelog.yml ' );
114+ safeUnlink (__DIR__ . '/.github/workflows/update-changelog.yml ' );
115115}
116116
117117confirm ('Execute `composer install` and run tests? ' ) && run ('composer install && composer test ' );
@@ -122,7 +122,7 @@ function ask(string $question, string $default = ''): string
122122{
123123 $ consoleColor = new ConsoleColor ();
124124 $ def = $ default ? $ consoleColor ->apply ('yellow ' , " ( {$ default }) " ) : null ;
125- $ answer = readline ($ consoleColor ->apply ('green ' , $ question . $ def . ': ' ));
125+ $ answer = readline ($ consoleColor ->apply ('green ' , $ question. $ def. ': ' ));
126126
127127 if (! $ answer ) {
128128 return $ default ;
@@ -146,7 +146,7 @@ function confirm(string $question, bool $default = false): bool
146146
147147function writeln (string $ line ): void
148148{
149- echo $ line . PHP_EOL ;
149+ echo $ line. PHP_EOL ;
150150}
151151
152152function run (string $ command ): string
@@ -200,20 +200,20 @@ function remove_prefix(string $prefix, string $content): string
200200
201201function remove_composer_deps (array $ names )
202202{
203- $ data = json_decode (file_get_contents (__DIR__ . '/composer.json ' ), true );
203+ $ data = json_decode (file_get_contents (__DIR__ . '/composer.json ' ), true );
204204
205205 foreach ($ data ['require-dev ' ] as $ name => $ version ) {
206206 if (in_array ($ name , $ names , true )) {
207207 unset($ data ['require-dev ' ][$ name ]);
208208 }
209209 }
210210
211- file_put_contents (__DIR__ . '/composer.json ' , json_encode ($ data , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ));
211+ file_put_contents (__DIR__ . '/composer.json ' , json_encode ($ data , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ));
212212}
213213
214214function remove_composer_script (array $ scriptNames )
215215{
216- $ data = json_decode (file_get_contents (__DIR__ . '/composer.json ' ), true );
216+ $ data = json_decode (file_get_contents (__DIR__ . '/composer.json ' ), true );
217217
218218 foreach ($ data ['scripts ' ] as $ name => $ script ) {
219219 if (is_array ($ script )) {
@@ -231,7 +231,7 @@ function remove_composer_script(array $scriptNames)
231231 }
232232 }
233233
234- file_put_contents (__DIR__ . '/composer.json ' , json_encode ($ data , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ));
234+ file_put_contents (__DIR__ . '/composer.json ' , json_encode ($ data , JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ));
235235}
236236
237237function remove_readme_paragraphs (string $ file ): void
@@ -258,12 +258,12 @@ function determineSeparator(string $path): string
258258
259259function replaceForWindows (): array
260260{
261- 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 author@domain.com" ' ));
261+ 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 author@domain.com" ' ));
262262}
263263
264264function replaceForAllOtherOSes (): array
265265{
266- return explode (PHP_EOL , run ('grep -E -r -l -i ":author|:vendor|:package|VendorName|skeleton|vendor_name|vendor_slug|author@domain.com" --exclude-dir=vendor ./* ./.github/* | grep -v ' . basename (__FILE__ )));
266+ return explode (PHP_EOL , run ('grep -E -r -l -i ":author|:vendor|:package|VendorName|skeleton|vendor_name|vendor_slug|author@domain.com" --exclude-dir=vendor ./* ./.github/* | grep -v ' . basename (__FILE__ )));
267267}
268268
269269class ConsoleColor
@@ -381,7 +381,7 @@ public function apply($style, $text)
381381 return $ text ;
382382 }
383383
384- return $ this ->escSequence (implode ('; ' , $ sequences )) . $ text . $ this ->escSequence (self ::RESET_STYLE );
384+ return $ this ->escSequence (implode ('; ' , $ sequences )). $ text. $ this ->escSequence (self ::RESET_STYLE );
385385 }
386386
387387 /**
0 commit comments