forked from Baystation12/Baystation12
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
203 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
$COLOR_RESET = [char]27 + '[0m' | ||
$COLOR_GREEN = [char]27 + '[32m' | ||
$COLOR_BLUE = [char]27 + '[36m' | ||
|
||
$script_dir = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
$mod_name = "" | ||
$mod_name_upper = "" | ||
$mod_name_lower = "" | ||
|
||
while (-not $mod_name) { | ||
Write-Host "${COLOR_GREEN}| ${COLOR_RESET}Название мода пишется заглавными буквами, а также с" | ||
Write-Host "${COLOR_GREEN}| ${COLOR_RESET}использованием подчёркиваний вместо пробелов или тире." | ||
Write-Host "${COLOR_GREEN}| ${COLOR_RESET}Пример: COOKIE_FACTORY" | ||
$mod_name = Read-Host "${COLOR_BLUE}> ${COLOR_RESET}Введи название мода" | ||
Write-Host | ||
$mod_name = $mod_name -replace '\s|-', '_' | ||
|
||
$mod_name_upper = $mod_name.ToUpper() | ||
$mod_name_lower = $mod_name.ToLower() | ||
|
||
Write-Host "${COLOR_GREEN}| ${COLOR_RESET}Выбранное название: ${mod_name_upper} / ${mod_name_lower}" | ||
$confirmation = Read-Host "${COLOR_BLUE}> ${COLOR_RESET}Всё верно? (Y/n)" | ||
Write-Host | ||
if ($confirmation -and $confirmation.ToLower() -ne "y") { | ||
$mod_name = "" | ||
} | ||
} | ||
|
||
if (-Not (Test-Path "$script_dir\_example" -PathType Container)) { | ||
Write-Host "Папка mods\_example не найдена. Убедись что она существует и попробуй ещё раз." | ||
Exit | ||
} | ||
|
||
$modpack_dir = Join-Path -Path $script_dir -ChildPath $mod_name_lower | ||
if (Test-Path "$modpack_dir" -PathType Container) { | ||
Write-Host "Папка mods\$mod_name_lower уже существует." | ||
Exit | ||
} | ||
|
||
New-Item -ItemType Directory -Path "$modpack_dir" | Out-Null | ||
Copy-Item -Path "$script_dir\_example\*" -Destination "$modpack_dir" | ||
|
||
# Rename files | ||
Get-ChildItem "$modpack_dir" | ForEach-Object { | ||
$newName = $_.Name -replace "_example", "_$mod_name_lower" | ||
Rename-Item -Path $_.FullName -NewName $newName | ||
} | ||
|
||
# Process and update content of all the files | ||
Get-ChildItem "$modpack_dir\*.*" | ForEach-Object { | ||
$content = Get-Content $_.FullName | ForEach-Object { | ||
$_ -creplace "EXAMPLE", $mod_name_upper -creplace "example", $mod_name_lower | ||
} | ||
$content | Set-Content $_.FullName | ||
} | ||
|
||
Write-Host "Готово! Файлы для мода $mod_name_upper созданы." | ||
Write-Host "Находятся они в папке mods/$mod_name_lower." |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import os | ||
|
||
COLOR_RESET = '\033[0m' | ||
COLOR_GREEN = '\033[32m' | ||
COLOR_BLUE = '\033[36m' | ||
|
||
script_dir = os.path.dirname(os.path.realpath(__file__)) | ||
mod_name = "" | ||
mod_name_upper = "" | ||
mod_name_lower = "" | ||
|
||
|
||
while not mod_name: | ||
print(f"{COLOR_GREEN}| {COLOR_RESET}Название мода пишется заглавными буквами, а также с") | ||
print(f"{COLOR_GREEN}| {COLOR_RESET}использованием подчёркиваний вместо пробелов или тире.") | ||
print(f"{COLOR_GREEN}| {COLOR_RESET}Пример: COOKIE_FACTORY") | ||
mod_name = input(f"{COLOR_BLUE}> {COLOR_RESET}Введи название мода: ") | ||
print() | ||
mod_name = mod_name.replace(' ', '_') | ||
mod_name = mod_name.replace('-', '_') | ||
|
||
mod_name_upper = mod_name.upper() | ||
mod_name_lower = mod_name.lower() | ||
|
||
print(f"{COLOR_GREEN}| {COLOR_RESET}Выбранное название: {mod_name_upper} / {mod_name_lower}") | ||
confirmation = input(f"{COLOR_BLUE}> {COLOR_RESET}Всё верно? (Y/n) ").lower() | ||
print() | ||
if confirmation and confirmation != "y": | ||
mod_name = "" | ||
|
||
if not os.path.exists(f"{script_dir}/_example"): | ||
print("Папка mods/_example не найдена. Убедись что она существует и попробуй ещё раз.") | ||
print() | ||
input("Нажмите Enter для закрытия...") | ||
exit() | ||
|
||
if os.path.exists(f"{script_dir}/{mod_name_lower}"): | ||
print(f"Папка mods/{mod_name_lower} уже существует.") | ||
print() | ||
input("Нажмите Enter для закрытия...") | ||
exit() | ||
|
||
os.mkdir(f"{script_dir}/{mod_name_lower}") | ||
|
||
for filename in os.listdir(f"{script_dir}/_example"): | ||
source = f"{script_dir}/_example/{filename}" | ||
destination = f"{script_dir}/{mod_name_lower}/{filename}" | ||
if os.path.isdir(source): | ||
continue | ||
with open(source, 'r', encoding="utf8") as src_file, open(destination, 'w', encoding="utf8") as dest_file: | ||
dest_file.write(src_file.read().replace("EXAMPLE", mod_name_upper).replace("example", mod_name_lower)) | ||
|
||
|
||
# Rename files | ||
for filename in os.listdir(f"{script_dir}/{mod_name_lower}"): | ||
new_name = filename.replace("_example", f"_{mod_name_lower}") | ||
os.rename(f"{script_dir}/{mod_name_lower}/{filename}", f"{script_dir}/{mod_name_lower}/{new_name}") | ||
|
||
|
||
print(f"Готово! Файлы для мода {mod_name_upper} созданы.") | ||
print(f"Находятся они в папке mods/{mod_name_lower}.") | ||
print() | ||
input("Нажмите Enter для закрытия...") |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
|
||
COLOR_RESET='\033[0m' | ||
COLOR_GREEN='\033[32m' | ||
COLOR_BLUE='\033[36m' | ||
|
||
mod_name="" | ||
mod_name_upper="" | ||
mod_name_lower="" | ||
|
||
script_dir=$(dirname "$0") | ||
|
||
while [ -z "$mod_name" ]; do | ||
echo -e "${COLOR_GREEN}| ${COLOR_RESET}Название мода пишется заглавными буквами, а также с" | ||
echo -e "${COLOR_GREEN}| ${COLOR_RESET}использованием подчёркиваний вместо пробелов или тире." | ||
echo -e "${COLOR_GREEN}| ${COLOR_RESET}Пример: COOKIE_FACTORY" | ||
echo -en "${COLOR_BLUE}> ${COLOR_RESET}Введи название мода: " | ||
read mod_name | ||
echo | ||
|
||
mod_name=$(echo "$mod_name" | sed -E 's/\s|-/_/g') | ||
|
||
mod_name_upper=$(echo "$mod_name" | tr '[:lower:]' '[:upper:]') | ||
mod_name_lower=$(echo "$mod_name" | tr '[:upper:]' '[:lower:]') | ||
|
||
echo -e "${COLOR_GREEN}| ${COLOR_RESET}Выбранное название: ${mod_name_upper} / ${mod_name_lower}" | ||
echo -en "${COLOR_BLUE}> ${COLOR_RESET}Всё верно? (Y/n) " | ||
read confirmation | ||
echo | ||
|
||
confirmation=${confirmation:-y} | ||
if [ "${confirmation,,}" != "y" ]; then | ||
mod_name="" | ||
fi | ||
done | ||
|
||
if [ ! -d "$script_dir/_example" ]; then | ||
echo "Папка mods/_example не найдена. Убедись что она существует и попробуй ещё раз." | ||
exit 1 | ||
fi | ||
|
||
if [ -d "$script_dir/$mod_name_lower" ]; then | ||
echo "Папка mods/$mod_name_lower уже существует." | ||
exit 1 | ||
fi | ||
|
||
mkdir -p "$script_dir/$mod_name_lower" | ||
cp "$script_dir/_example/"* "$script_dir/$mod_name_lower/" | ||
|
||
# Rename files | ||
for file in "$script_dir/$mod_name_lower"/*example*; do | ||
new_name=$(echo "$file" | sed -E "s/_example/_$mod_name_lower/") | ||
mv "$file" "$new_name" | ||
done | ||
|
||
# Process and update content of all the files | ||
for file in "$script_dir/$mod_name_lower"/*; do | ||
sed -i'' -e "s/EXAMPLE/$mod_name_upper/g" -e "s/example/$mod_name_lower/g" "$file" | ||
done | ||
|
||
echo "Готово! Файлы для мода $mod_name_upper созданы." | ||
echo "Находятся они в папке mods/$mod_name_lower." |
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