Skip to content

Feat: Add script to replace keyword placeholders with user input#6

Closed
KIKOmanasijev wants to merge 5 commits intoroots:mainfrom
KIKOmanasijev:main
Closed

Feat: Add script to replace keyword placeholders with user input#6
KIKOmanasijev wants to merge 5 commits intoroots:mainfrom
KIKOmanasijev:main

Conversation

@KIKOmanasijev
Copy link
Copy Markdown

@KIKOmanasijev KIKOmanasijev commented May 26, 2024

This PR adds a PHP script that automates the process of replacing the dummy Class Names, Namespaces, File names and etc, with real user entered data.

Ref #5

Fix: config file name not changing

Opt: remove unused variables

Fix: author_email not changing in composer.json

Fix: composer package name placeholder use correct variable

Fix: don't run composer test script because it does not exist
Comment thread composer.json Outdated
Comment thread composer.json Outdated
Comment thread composer.json Outdated
@Log1x
Copy link
Copy Markdown
Member

Log1x commented May 26, 2024

I'd like to get rid of all the curl/endpoint stuff as well as any over the top "automation" where possible.

The Filament team's take in their plugin skeleton might be a good place to draw some inspiration on simplifying things: https://github.com/filamentphp/plugin-skeleton/blob/main/configure.php

@KIKOmanasijev
Copy link
Copy Markdown
Author

Thanks for the comments @Log1x 🙇‍♂️.

The code styling in composer.json is corrected, and I've simplified the configure.php. Let me know what you think now.

@KIKOmanasijev KIKOmanasijev requested a review from Log1x May 27, 2024 07:31
@jasperf
Copy link
Copy Markdown

jasperf commented Apr 18, 2025

Was playing with a script setup for replacing base example package details , but it seems this Laravel / Filament kind of way is much better. Hope we get this merged soon. Did a test running php ./configure.php using the code at imagewize/sage-native-block#2 and again.. seems to run well. But some parts good be improved. README.md showed

composer require vendor-name/sage-native-block-package

so vendor-name not replaced for some reason. And title in README

# Acorn SageNativeBlock Package

would be better when it would have been three words.

Furthermore I had to make some tweaks:

But beyond that I do not see issues yet. But will have to test some more.

Here the script for reference: https://gist.github.com/jasperf/7fb70fd696d39666475581f62cf7cc43

@trajche
Copy link
Copy Markdown

trajche commented Aug 23, 2025

Nice work @KIKOmanasijev and @jasperf !

@Log1x any plans on merging this or are there any pending things to be done?

@retlehs
Copy link
Copy Markdown
Member

retlehs commented Mar 6, 2026

@codex review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 939aa14ac0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread configure.php

match (true) {
str_contains($file, determineSeparator('src/Example.php')) => rename($file, determineSeparator('./src/'.$className.'.php')),
str_contains($file, determineSeparator('src/Providers/ExampleServiceProvider.php')) => rename($file, determineSeparator('./src/providers/'.$className.'ServiceProvider.php')),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve directory case when renaming service provider file

On case-sensitive filesystems (common in Linux CI/production), renaming to ./src/providers/... fails because the committed directory is src/Providers. The script still rewrites class names in the file, so the file remains ExampleServiceProvider.php while the class becomes <ClassName>ServiceProvider, which breaks PSR-4 autoloading after configuration.

Useful? React with 👍 / 👎.

Comment thread configure.php
match (true) {
str_contains($file, determineSeparator('src/Example.php')) => rename($file, determineSeparator('./src/'.$className.'.php')),
str_contains($file, determineSeparator('src/Providers/ExampleServiceProvider.php')) => rename($file, determineSeparator('./src/providers/'.$className.'ServiceProvider.php')),
str_contains($file, determineSeparator('src/Console/ExampleCommand.php')) => rename($file, determineSeparator('./src/console/'.$className.'.php')),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep Command suffix when renaming console command file

This rename target drops the Command suffix (.../$className.php), but the earlier global replacement changes ExampleCommand to <ClassName>Command inside the file. That leaves the class name and filename out of sync under PSR-4, so the command class will not autoload correctly after running the configurator.

Useful? React with 👍 / 👎.

@retlehs
Copy link
Copy Markdown
Member

retlehs commented Mar 6, 2026

Thanks for putting this together and appreciate you taking the initiative here, and apologies on taking so long to provide more feedback here

We're going to go a different direction with our own implementation in #7

@retlehs retlehs closed this Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants