Skip to content

Commit

Permalink
Merge branch 'release/1.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Jun 16, 2021
2 parents ae7358e + a2798b5 commit 535da04
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v1.5.3
## 06/16/2021

1. [](#bugfix)
* Fixes over-zealous regex that caused duplication in copy tasks [#69](https://github.com/getgrav/grav-plugin-devtools/issues/69)

# v1.5.2
## 05/19/2021

Expand Down
2 changes: 1 addition & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: DevTools
slug: devtools
type: plugin
version: 1.5.2
version: 1.5.3
description: Plugin and Theme scaffolding utilities
icon: cogs
author:
Expand Down
49 changes: 36 additions & 13 deletions classes/DevToolsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,43 @@ protected function createComponent(): bool
@rename( $base_old_filename . '.php', $base_new_filename . '.php');
@rename( $base_old_filename . '.yaml', $base_new_filename . '.yaml');

$regex_array = [
$new_theme . '.php' => [
['/class ' . $this->inflector::camelize($current_theme) . ' extends/i'],
['class ' . $this->inflector::camelize($name) . ' extends']
],
'blueprints.yaml' => [
['/'.$this->inflector::camelize($current_theme).'/', '/'.$this->inflector::hyphenize($current_theme).'/', '/'.$this->inflector::titleize($current_theme).'/', '/'.$this->inflector::underscorize($current_theme).'/'],
[$this->inflector::camelize($name), $this->inflector::hyphenize($name),$this->inflector::titleize($name), $this->inflector::underscorize($name)]
],
'README.md' => [
['/'.$this->inflector::camelize($current_theme).'/', '/'.$this->inflector::hyphenize($current_theme).'/', '/'.$this->inflector::titleize($current_theme).'/', '/'.$this->inflector::underscorize($current_theme).'/'],
[$this->inflector::camelize($name), $this->inflector::hyphenize($name),$this->inflector::titleize($name), $this->inflector::underscorize($name)]
]
$camelized_current = $this->inflector::camelize($current_theme);
$camelized_new = $this->inflector::camelize($name);

$hyphenized_current = $this->inflector::hyphenize($current_theme);
$hyphenized_new = $this->inflector::hyphenize($name);

$titleized_current = $this->inflector::titleize($current_theme);
$titleized_new = $this->inflector::titleize($name);

$underscoreized_current = $this->inflector::underscorize($current_theme);
$underscoreized_new = $this->inflector::underscorize($name);

$variations_regex = [
["/$camelized_current/", "/$hyphenized_current/"],
[$camelized_new, $hyphenized_new]
];

if (!in_array("/$titleized_current/", array_values($variations_regex[0]))) {
$current_regex = $variations_regex[0];
$new_regex = $variations_regex[1];
$current_regex[] = "/$titleized_current/";
$new_regex[] = $titleized_new;
$variations_regex = [$current_regex, $new_regex];
}

if (!in_array("/$underscoreized_current/", array_values($variations_regex[0]))) {
$current_regex = $variations_regex[0];
$new_regex = $variations_regex[1];
$current_regex[] = "/$underscoreized_current/";
$new_regex[] = $underscoreized_new;
$variations_regex = [$current_regex, $new_regex];
}

$regex_array = [
$new_theme . '.php' => $variations_regex,
'blueprints.yaml' => $variations_regex,
'README.md' => $variations_regex,
];

foreach ($regex_array as $filename => $data) {
Expand Down

0 comments on commit 535da04

Please sign in to comment.