aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/add-feature-template.sh24
-rwxr-xr-xtools/delete-feature-template.sh22
-rwxr-xr-xtools/rename-project.sh8
3 files changed, 28 insertions, 26 deletions
diff --git a/tools/add-feature-template.sh b/tools/add-feature-template.sh
index 3b11a44..9637384 100755
--- a/tools/add-feature-template.sh
+++ b/tools/add-feature-template.sh
@@ -32,7 +32,7 @@ dir="../$project_name/Data"
# {{{ --------------------------->
# Create the DB model class
-cat > $dir/Models/$feature_name.cs<< EOF
+cat > $dir/${project_name}.Data.Models/$feature_name.cs<< EOF
using System;
namespace $project_name.Data.Models
@@ -55,7 +55,7 @@ EOF
dbset="public DbSet<$feature_name> ${feature_name}s { get; set; }"
-dbcontext_path="$dir/${project_name}Context.cs"
+dbcontext_path="$dir/${project_name}.Data/${project_name}Context.cs"
if ! grep -q "$dbset" "$dbcontext_path"; then
if grep -Fq "DbSet" $dbcontext_path; then
@@ -77,7 +77,7 @@ dir="../$project_name/Services"
# {{{ --------------------------->
# Create Service and Interface
-cat > $dir/Interfaces/I${feature_name}Service.cs<< EOF
+cat > $dir/${project_name}.Services/Interfaces/I${feature_name}Service.cs<< EOF
using $project_name.Data.Models;
using $project_name.Services.Models.$feature_name;
@@ -88,7 +88,7 @@ namespace $project_name.Services.Interfaces
}
EOF
-cat > $dir/Services/${feature_name}Service.cs<< EOF
+cat > $dir/${project_name}.Services/Services/${feature_name}Service.cs<< EOF
using $project_name.Services.Interfaces;
using System;
using AutoMapper;
@@ -112,7 +112,7 @@ EOF
# {{{ --------------------------->
# Create Service Model
-subdir="$dir/Models/$feature_name"
+subdir="$dir/${project_name}.Services.Models/$feature_name"
mkdir -p $subdir
cat > $subdir/$model${feature_name}ServiceModel.cs<< EOF
@@ -137,7 +137,7 @@ EOF
# {{{ --------------------------->
# Create Service Mappings
-subdir="${dir}/Configurations"
+subdir="$dir/${project_name}.Services/Configurations"
mappings=("${feature_name}ServiceModel, $feature_name" "${feature_name}, ${feature_name}ServiceModel")
cat > $subdir/Service${feature_name}Mappings.cs<< EOF
@@ -173,7 +173,7 @@ dir="../$project_name/Web"
# {{{ --------------------------->
# Add the dependency injection of the Service class
-startup_path="$dir/Startup.cs"
+startup_path="$dir/${project_name}.Web/Startup.cs"
service_name="${feature_name}Service"
if ! grep -q "$service_name" "$startup_path"; then
sed -z -i "s/.*AddTransient[^\n]*\n/&\t\t\tservices.AddTransient<I$service_name, $service_name>();\n/" $startup_path
@@ -184,7 +184,7 @@ fi
# {{{ --------------------------->
# Create View Models
-subdir="$dir/Models/$feature_name"
+subdir="$dir/${project_name}.Web.Models/$feature_name"
mkdir -p $subdir
models=("" "Create" "Edit")
@@ -220,7 +220,7 @@ done
# {{{ --------------------------->
# Update View Imports
-viewimports_path="$dir/Views/_ViewImports.cshtml"
+viewimports_path="$dir/${project_name}.Web/Views/_ViewImports.cshtml"
import_name="$project_name.Web.Models.$feature_name"
if ! grep -q "$import_name" "$viewimports_path"; then
sed -z -i "s/.*@using[^\n]*\n/&@using $import_name\n/" $viewimports_path
@@ -231,7 +231,7 @@ fi
# {{{ --------------------------->
# Create Views
-subdir="$dir/Views/$feature_name"
+subdir="$dir/${project_name}.Web/Views/$feature_name"
mkdir -p $subdir
cat > $subdir/Index.cshtml<< EOF
@@ -342,7 +342,7 @@ EOF
# {{{ --------------------------->
# Create Controller
-subdir="$dir/Controllers"
+subdir="$dir/${project_name}.Web/Controllers"
cat > $subdir/${feature_name}Controller.cs<< EOF
using System;
@@ -461,7 +461,7 @@ EOF
# {{{ --------------------------->
# Create Controller Mappings
-subdir="${dir}/Configurations"
+subdir="${dir}/${project_name}.Web/Configurations"
mappings=("${feature_name}ServiceModel, ${feature_name}WebModel" "Create${feature_name}WebModel, ${feature_name}ServiceModel" "${feature_name}ServiceModel, Edit${feature_name}WebModel" "Edit${feature_name}WebModel, ${feature_name}ServiceModel")
cat > $subdir/Controller${feature_name}Mappings.cs<< EOF
diff --git a/tools/delete-feature-template.sh b/tools/delete-feature-template.sh
index 29484dd..5290c6c 100755
--- a/tools/delete-feature-template.sh
+++ b/tools/delete-feature-template.sh
@@ -24,8 +24,8 @@ feature_name="$2"
dir="../$project_name/Data"
-rm -f $dir/Models/$feature_name.cs
-sed -i "/$feature_name/d" $dir/${project_name}Context.cs
+rm -f $dir/${project_name}.Data.Models/$feature_name.cs
+sed -i "/$feature_name/d" $dir/${project_name}.Data/${project_name}Context.cs
# }}} =============================<
@@ -34,9 +34,9 @@ sed -i "/$feature_name/d" $dir/${project_name}Context.cs
dir="../$project_name/Services"
-rm -f $dir/Configurations/Service${feature_name}Mappings.cs
-rm -rf $dir/Models/$feature_name
-rm -f $dir/${feature_name}Service.cs
+rm -f $dir/${project_name}.Services/Configurations/Service${feature_name}Mappings.cs
+rm -rf $dir/${project_name}.Services.Models/$feature_name
+rm -f $dir/${project_name}.Services/${feature_name}Service.cs
# }}} =============================<
@@ -45,11 +45,11 @@ rm -f $dir/${feature_name}Service.cs
dir="../$project_name/Web"
-rm -f $dir/Configurations/Controller${feature_name}Mappings.cs
-rm -f $dir/Controllers/${feature_name}Controller.cs
-rm -rf $dir/Models/$feature_name
-rm -rf $dir/Views/$feature_name
-sed -i "/$feature_name/d" $dir/Views/_ViewImports.cshtml
-sed -i "/$feature_name/d" $dir/Startup.cs
+rm -f $dir/${project_name}.Web/Configurations/Controller${feature_name}Mappings.cs
+rm -f $dir/${project_name}.Web/Controllers/${feature_name}Controller.cs
+rm -rf $dir/${project_name}.Web.Models/$feature_name
+rm -rf $dir/${project_name}.Web/Views/$feature_name
+sed -i "/$feature_name/d" $dir/${project_name}.Web/Views/_ViewImports.cshtml
+sed -i "/$feature_name/d" $dir/${project_name}.Web/Startup.cs
# }}} =============================<
diff --git a/tools/rename-project.sh b/tools/rename-project.sh
index b0d6d0b..722650a 100755
--- a/tools/rename-project.sh
+++ b/tools/rename-project.sh
@@ -34,12 +34,14 @@ rename () {
done
}
+mv ../$original_name ../$new_name
+
# Rename all directories and then files
-rename $(find ../ -type d -name "*$original_name*")
-rename $(find ../ -type f -name "*$original_name*")
+rename $(find ../$new_name -type d -name "*$original_name*")
+rename $(find ../$new_name -type f -name "*$original_name*")
# Rename all occurences inside files
-find ../ -type f -not -path "../tools/*" -not -path "../.git/*" -print0 | xargs -0 sed -i "s/$original_name/$new_name/g"
+find ../$new_name -type f -not -path "../tools/*" -not -path "../.git/*" -print0 | xargs -0 sed -i "s/$original_name/$new_name/g"
# The database context is named TemplateContext by default
# A third paramter should never be given, the second check is to prevent stack overflow