Skip to content
This repository has been archived by the owner on Jul 20, 2022. It is now read-only.

Convert init.sh into a Composer PHP script for create-project #23

Open
kasparsd opened this issue Dec 10, 2019 · 2 comments
Open

Convert init.sh into a Composer PHP script for create-project #23

kasparsd opened this issue Dec 10, 2019 · 2 comments

Comments

@kasparsd
Copy link
Collaborator

Convert the logic in init.sh into a Composer PHP script that would allow us to simplify the setup down to a single command of composer create-project xwp/block-scaffolding-wp.

@derekherman
Copy link
Contributor

The Bash script accepts input from the command line, how would this work with composer create-project?

@kasparsd
Copy link
Collaborator Author

This requires converting the Bash script into a PHP script that is cross-platform. Here is the initial prototype for it that can be updated to have the feature parity with what is currently in the init.sh. Notice how it prompts for things:

public static function scaffold( Event $event ) {
$io = $event->getIO();
$default_package_name = sprintf(
'%s/%s',
self::TEMPLATE_VENDOR,
self::TEMPLATE_SLUG
);
$desired_package_name = $io->ask(
'Enter the desired package name (vendor/plugin-name): ',
$default_package_name
);
$package = new PackageNamer( $desired_package_name );
$replacer = new StringReplacer(
array_combine(
self::slug_to_string_map( self::TEMPLATE_VENDOR, self::TEMPLATE_SLUG ),
self::slug_to_string_map( $package->vendor(), $package->slug() )
)
);
/**
* For each file in the project directory:
*
* 1. Rename strings in file.
* 2. Rename the file.
*/
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants