@@ -5,7 +5,7 @@ function ask(string $question, string $default = ''): string
5
5
{
6
6
$ answer = readline ($ question .($ default ? " ( {$ default }) " : null ).': ' );
7
7
8
- if (! $ answer ) {
8
+ if ( ! $ answer ) {
9
9
return $ default ;
10
10
}
11
11
@@ -16,7 +16,7 @@ function confirm(string $question, bool $default = false): bool
16
16
{
17
17
$ answer = ask ($ question .' ( ' .($ default ? 'Y/n ' : 'y/N ' ).') ' );
18
18
19
- if (! $ answer ) {
19
+ if ( ! $ answer ) {
20
20
return $ default ;
21
21
}
22
22
@@ -102,6 +102,7 @@ function remove_composer_script($scriptName)
102
102
foreach ($ data ['scripts ' ] as $ name => $ script ) {
103
103
if ($ scriptName === $ name ) {
104
104
unset($ data ['scripts ' ][$ name ]);
105
+
105
106
break ;
106
107
}
107
108
}
@@ -192,48 +193,48 @@ function replaceForAllOtherOSes(): array
192
193
193
194
writeln ('This script will replace the above values in all relevant files in the project directory. ' );
194
195
195
- if (! confirm ('Modify files? ' , true )) {
196
+ if ( ! confirm ('Modify files? ' , true )) {
196
197
exit (1 );
197
198
}
198
199
199
200
$ files = (str_starts_with (strtoupper (PHP_OS ), 'WIN ' ) ? replaceForWindows () : replaceForAllOtherOSes ());
200
201
201
202
foreach ($ files as $ file ) {
202
203
replace_in_file ($ file , [
203
- ':author_name ' => $ authorName ,
204
- ':author_username ' => $ authorUsername ,
205
- 'author@domain.com ' => $ authorEmail ,
206
- ':vendor_name ' => $ vendorName ,
207
- ':vendor_slug ' => $ vendorSlug ,
208
- 'VendorName ' => $ vendorNamespace ,
209
- ':package_name ' => $ packageName ,
210
- ':package_slug ' => $ packageSlug ,
204
+ ':author_name ' => $ authorName ,
205
+ ':author_username ' => $ authorUsername ,
206
+ 'author@domain.com ' => $ authorEmail ,
207
+ ':vendor_name ' => $ vendorName ,
208
+ ':vendor_slug ' => $ vendorSlug ,
209
+ 'VendorName ' => $ vendorNamespace ,
210
+ ':package_name ' => $ packageName ,
211
+ ':package_slug ' => $ packageSlug ,
211
212
':package_slug_without_prefix ' => $ packageSlugWithoutPrefix ,
212
- 'Skeleton ' => $ className ,
213
- 'skeleton ' => $ packageSlug ,
214
- 'migration_table_name ' => title_snake ($ packageSlug ),
215
- 'variable ' => $ variableName ,
216
- ':package_description ' => $ description ,
213
+ 'Skeleton ' => $ className ,
214
+ 'skeleton ' => $ packageSlug ,
215
+ 'migration_table_name ' => title_snake ($ packageSlug ),
216
+ 'variable ' => $ variableName ,
217
+ ':package_description ' => $ description ,
217
218
]);
218
219
219
220
match (true ) {
220
- str_contains ($ file , determineSeparator ('src/Skeleton.php ' )) => rename ($ file , determineSeparator ('./src/ ' .$ className .'.php ' )),
221
- str_contains ($ file , determineSeparator ('src/SkeletonServiceProvider.php ' )) => rename ($ file , determineSeparator ('./src/ ' .$ className .'ServiceProvider.php ' )),
222
- str_contains ($ file , determineSeparator ('src/Facades/Skeleton.php ' )) => rename ($ file , determineSeparator ('./src/Facades/ ' .$ className .'.php ' )),
223
- str_contains ($ file , determineSeparator ('src/Commands/SkeletonCommand.php ' )) => rename ($ file , determineSeparator ('./src/Commands/ ' .$ className .'Command.php ' )),
221
+ str_contains ($ file , determineSeparator ('src/Skeleton.php ' )) => rename ($ file , determineSeparator ('./src/ ' .$ className .'.php ' )),
222
+ str_contains ($ file , determineSeparator ('src/SkeletonServiceProvider.php ' )) => rename ($ file , determineSeparator ('./src/ ' .$ className .'ServiceProvider.php ' )),
223
+ str_contains ($ file , determineSeparator ('src/Facades/Skeleton.php ' )) => rename ($ file , determineSeparator ('./src/Facades/ ' .$ className .'.php ' )),
224
+ str_contains ($ file , determineSeparator ('src/Commands/SkeletonCommand.php ' )) => rename ($ file , determineSeparator ('./src/Commands/ ' .$ className .'Command.php ' )),
224
225
str_contains ($ file , determineSeparator ('database/migrations/create_skeleton_table.php.stub ' )) => rename ($ file , determineSeparator ('./database/migrations/create_ ' .title_snake ($ packageSlugWithoutPrefix ).'_table.php.stub ' )),
225
- str_contains ($ file , determineSeparator ('config/skeleton.php ' )) => rename ($ file , determineSeparator ('./config/ ' .$ packageSlugWithoutPrefix .'.php ' )),
226
- str_contains ($ file , 'README.md ' ) => remove_readme_paragraphs ($ file ),
227
- default => [],
226
+ str_contains ($ file , determineSeparator ('config/skeleton.php ' )) => rename ($ file , determineSeparator ('./config/ ' .$ packageSlugWithoutPrefix .'.php ' )),
227
+ str_contains ($ file , 'README.md ' ) => remove_readme_paragraphs ($ file ),
228
+ default => [],
228
229
};
229
230
}
230
231
231
- if (! $ useLaravelPint ) {
232
+ if ( ! $ useLaravelPint ) {
232
233
safeUnlink (__DIR__ .'/.github/workflows/fix-php-code-style-issues.yml ' );
233
234
safeUnlink (__DIR__ .'/pint.json ' );
234
235
}
235
236
236
- if (! $ usePhpStan ) {
237
+ if ( ! $ usePhpStan ) {
237
238
safeUnlink (__DIR__ .'/phpstan.neon.dist ' );
238
239
safeUnlink (__DIR__ .'/phpstan-baseline.neon ' );
239
240
safeUnlink (__DIR__ .'/.github/workflows/phpstan.yml ' );
@@ -248,19 +249,19 @@ function replaceForAllOtherOSes(): array
248
249
remove_composer_script ('phpstan ' );
249
250
}
250
251
251
- if (! $ useDependabot ) {
252
+ if ( ! $ useDependabot ) {
252
253
safeUnlink (__DIR__ .'/.github/dependabot.yml ' );
253
254
safeUnlink (__DIR__ .'/.github/workflows/dependabot-auto-merge.yml ' );
254
255
}
255
256
256
- if (! $ useLaravelRay ) {
257
+ if ( ! $ useLaravelRay ) {
257
258
remove_composer_deps (['spatie/laravel-ray ' ]);
258
259
}
259
260
260
- if (! $ useUpdateChangelogWorkflow ) {
261
+ if ( ! $ useUpdateChangelogWorkflow ) {
261
262
safeUnlink (__DIR__ .'/.github/workflows/update-changelog.yml ' );
262
263
}
263
264
264
265
confirm ('Execute `composer install` and run tests? ' ) && run ('composer install && composer test ' );
265
266
266
- confirm ('Let this script delete itself? ' , true ) && unlink (__FILE__ );
267
+ confirm ('Let this script delete itself? ' , true ) && unlink (__FILE__ );
0 commit comments