Skip to content

Commit

Permalink
Fix init sed (#398)
Browse files Browse the repository at this point in the history
Co-authored-by: Nícholas André <[email protected]>
  • Loading branch information
tlovett1 and nicholasio authored May 24, 2024
1 parent 249f072 commit 1aba76c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-ants-grow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"10up-toolkit": patch
---

Fix project init command
38 changes: 22 additions & 16 deletions packages/toolkit/scripts/project/bash/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,23 @@ fi
# Fixes weird sed error
LANG=C

if [ "$(uname)" = "Darwin" ]; then
sediopt=( -i '')
else
sediopt=( -i )
fi

# Replace TenUpTheme in all files inside init_path with $name_camel_case recursively
find "$init_path" -type f -exec sed -i -e "s/TenUpTheme/${project_name_camel_case}Theme/g" {} \;
find "$init_path" -type f -exec sed -i -e "s/TenupTheme/${project_name_camel_case}Theme/g" {} \;
find "$init_path" -type f -exec sed -i -e "s/TenUpPlugin/${project_name_camel_case}Plugin/g" {} \;
find "$init_path" -type f -exec sed -i -e "s/TenupPlugin/${project_name_camel_case}Plugin/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/TenUpTheme/${project_name_camel_case}Theme/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/TenupTheme/${project_name_camel_case}Theme/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/TenUpPlugin/${project_name_camel_case}Plugin/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/TenupPlugin/${project_name_camel_case}Plugin/g" {} \;

# Replace TENUP_
find "$init_path" -type f -exec sed -i -e "s/TENUP_/${project_name_uppercase_underscore}_/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/TENUP_/${project_name_uppercase_underscore}_/g" {} \;

# Replace tenup_
find "$init_path" -type f -exec sed -i -e "s/tenup_/${project_name_lowercase_underscore}_/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/tenup_/${project_name_lowercase_underscore}_/g" {} \;

theme_path="$init_path/themes/${project_name_lowercase_hypen}-theme"
plugin_path="$init_path/plugins/${project_name_lowercase_hypen}-plugin"
Expand Down Expand Up @@ -59,22 +65,22 @@ if [ -d "$init_path/mu-plugins/10up-plugin" ]; then
mv "$init_path/mu-plugins/10up-plugin" "$mu_plugin_path"
fi

find "$init_path" -type f -exec sed -i -e "s/tenup-theme/${project_name_lowercase_hypen}-theme/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/tenup-theme/${project_name_lowercase_hypen}-theme/g" {} \;

find "$init_path" -type f -exec sed -i -e "s/tenup-plugin/${project_name_lowercase_hypen}-plugin/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/tenup-plugin/${project_name_lowercase_hypen}-plugin/g" {} \;

find "$init_path" -type f -exec sed -i -e "s/10up-plugin/${project_name_lowercase_hypen}-plugin/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/10up-plugin/${project_name_lowercase_hypen}-plugin/g" {} \;

find "$init_path" -type f -exec sed -i -e "s/tenup-wp-scaffold/${project_name_lowercase_hypen}/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/tenup-wp-scaffold/${project_name_lowercase_hypen}/g" {} \;

find "$init_path" -type f -exec sed -i -e "s/10up\/wp-theme/10up\/${project_name_lowercase_hypen}-theme/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/10up\/wp-theme/10up\/${project_name_lowercase_hypen}-theme/g" {} \;

find "$init_path" -type f -exec sed -i -e "s/10up\/wp-plugin/10up\/${project_name_lowercase_hypen}-plugin/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/10up\/wp-plugin/10up\/${project_name_lowercase_hypen}-plugin/g" {} \;

find "$init_path" -type f -exec sed -i -e "s/10up Plugin/${project_name} Plugin/g" {} \;
find "$init_path" -type f -exec sed -i -e "s/Tenup Plugin/Project Plugin/g" {} \;
find "$init_path" -type f -exec sed -i -e "s/10up Theme/${project_name} Theme/g" {} \;
find "$init_path" -type f -exec sed -i -e "s/Tenup Theme/${project_name} Theme/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/10up Plugin/${project_name} Plugin/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/Tenup Plugin/Project Plugin/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/10up Theme/${project_name} Theme/g" {} \;
find "$init_path" -type f -exec sed "${sediopt[@]}" -e "s/Tenup Theme/${project_name} Theme/g" {} \;

rsync -rc "$toolkit_path/project/local/" "$init_path"

Expand Down

0 comments on commit 1aba76c

Please sign in to comment.