-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEW Allow files to have a .tmpl extension which is stripped #5
Conversation
@dhensby good idea but it won't work if you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As commented; Make sure it renames in post-create-project.
@tractorcow this appeared to be the canonical source of mapping from the composer meta data to the filename and I couldn't (and can't now) find anywhere referencing Any pointers where to look for that? |
Check out this bit of code: public static function getSubscribedEvents()
{
return [
'post-create-project-cmd' => 'cleanupProject',
'post-package-update' => 'installPackage',
'post-package-install' => 'installPackage',
];
} You would want to add your hook in the The logic for this method would look VERY similar to Let me know if you need any more help. ;P |
src/RecipeInstaller.php
Outdated
@@ -44,6 +44,10 @@ protected function installProjectFiles($recipe, $sourceRoot, $destinationRoot, $ | |||
$any = false; | |||
foreach($fileIterator as $path => $info) { | |||
$destination = $destinationRoot . substr($path, strlen($sourceRoot)); | |||
$extension = pathinfo($destination, PATHINFO_EXTENSION); | |||
if ($extension === 'tmpl') { | |||
$destination = substr($destination, -5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean substr($destination, 0, -5)
? $destination
would end up just being .tmpl
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops - fixed
This check
Should we loosen this check so that it matches path with / without the tml suffix? Just to ensure backwards compatibility. Otherwise files that were deleted will be re-created once and you'll end up with duplicate |
440b867
to
16a9232
Compare
@tractorcow recipe-plugin/src/RecipePlugin.php Lines 89 to 110 in 3e16a5b
|
This is currently the case. We normalise the |
16a9232
to
d8f9f31
Compare
You do it before clearing them. The logic is:
Good call just making sure. :) |
src/RecipeInstaller.php
Outdated
if ($extension === 'tmpl') { | ||
$destination = substr($destination, -5); | ||
$destinationExt = pathinfo($destination, PATHINFO_EXTENSION); | ||
if ($destinationExt === 'tmpl') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this condition twice? They both compare the same string that comes from $path? It's hard to follow.
$path -> $destination -> check ext
$path -> $relativePath -> check ext
3902b63
to
9ac246a
Compare
9ac246a
to
a9ad0bb
Compare
Is this still blocked? Looks like all of @tractorcow feedback has been addressed? |
it just doesn't work. I think it's actually really difficult to do :/ |
😞 Shall we close the PR then? Doesn't look like it's going to be addressed in the near future. |
Yeah - I think I got as far as I could and wasn't getting anywhere when I last worked on it. It's a big shame, though, as it's a big pain when IDEs pick up these files :( |
Allows a fix for silverstripe/recipe-cms#9
--
Added:
file_exists
,file_get_contents
,copy
, etc).tmpl
so that they don't get picked up by IDEs as first class classes