This repository has been archived by the owner on Mar 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
Improving theme cloning process in order to minimize manual updates #268
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
98bc2d1
Improving theme cloning process in order to minimize manual updates
shaal 25998a8
fixing comment line
shaal 1c572e3
remove a non-existing directory `components/css`
shaal 4b7adf4
Support the `-slim` option
shaal 06d72cb
Fixing the function _emulsify_alter_files (code by @ccjjmartin)
shaal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -492,7 +492,6 @@ function _emulsify_get_files_to_copy() { | |
'components/_macros', | ||
'components/_meta', | ||
'components/_twig-components', | ||
'components/css', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, this needed to go. |
||
'components/images', | ||
'components/_patterns/style.scss', | ||
'components/_patterns/00-base/global/01-colors', | ||
|
@@ -550,7 +549,7 @@ function _emulsify_get_files_to_rename() { | |
* @return boolean | ||
* A boolean representing the success or failure of the function. | ||
*/ | ||
function _emulsify_alter_files($theme_path, array $files_to_alter = array(), array $alterations = array(), $absolute = FALSE) { | ||
function _emulsify_alter_files($theme_path, array $files_to_alter = array(), array $alterations = array(), $absolute = FALSE, int $depth = 0) { | ||
if (empty($files_to_alter) || empty($alterations)) { | ||
return TRUE; | ||
} | ||
|
@@ -568,11 +567,11 @@ function _emulsify_alter_files($theme_path, array $files_to_alter = array(), arr | |
$files = scandir($file_path); | ||
$files = array_splice($files, 2); | ||
foreach ($files as $file) { | ||
$processed_files[] = $file_path . $file; | ||
} | ||
$alter_status = _emulsify_alter_files($theme_path, $processed_files, $alterations, TRUE); | ||
if ($alter_status === FALSE) { | ||
return FALSE; | ||
$processed_file = [$file_path . DIRECTORY_SEPARATOR . $file]; | ||
$alter_status = _emulsify_alter_files($theme_path, $processed_file, $alterations, TRUE, $depth + 1); | ||
if ($alter_status === FALSE) { | ||
return FALSE; | ||
} | ||
} | ||
} | ||
elseif ($file_type === 'file') { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@shaal I am curious as to the broken behavior you experienced here. Did "emulsify" on this line get replaced? On the line right after this did it not get replaced? I am definitely pro simplifying install processes so I would love to hear more about the bug you encountered.
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.
I think the goal here is to set this as
emulsify
by default so that it can be auto-replaced. In the "before" code, it says to manually enter your theme's machine name. Setting it automatically on cloned theme creation is preferred.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.
Ok, I was focused on the comment containing the string
emulsify
but that actually isn't the main change here. I should have been looking at theYOURTHEME
versusemulsify
. I am good with this change because it makes the out of the box experience better in most scenarios. I will point out that this is not going to work for people who don't put their theme in the root of/themes/
versus/themes/custom/
But that is likely a bigger issue that what we are trying to address here. We should consider replacing this (in another PR not this one) with just a string calledPATH
and then it drops in the theme path.Alterations are defined in the
_emulsify_get_alterations
function which is currently only doing these:It would be pretty easy to add a new line:
And add another parameter for to that same function to pass the path in. When I wrote this I wasn't thinking we would need the PATH within the twig files.
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.
Created this ticket for follow up on this: #271