]> gitweb.fluxo.info Git - templater.git/commitdiff
Adds diff option
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 17 Nov 2017 15:13:43 +0000 (13:13 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 17 Nov 2017 15:13:43 +0000 (13:13 -0200)
TODO.md
share/templater/drupal8/files/puppet/Puppetfile [moved from share/templater/drupal8/files/Puppetfile with 100% similarity]
share/templater/drupal8/setup
share/templater/templater/functions
templater

diff --git a/TODO.md b/TODO.md
index 6ad302d8bb56cf510c13c6c3a7e89fbe1dbdcfce..220a16c7d63ce18da1becac26939582745a074e4 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -24,7 +24,7 @@ TODO
 * Code:
   * Makefiles: non-conflicting target names with aliases/shorthands in the main Makefile
   * Check/detect/verify mode, telling which modules are installed and checking for missing things (like LICENSE)
-  * Update and diff modes to compare/update configs between a project and templater's defaults
+  * Update mode to update configs between a project and templater's defaults
   * If git is in use, commit all changes, but check first it there are non-commited changes in the repo
   * Hugo: tell the user about adding a theme: http://gohugo.io/getting-started/quick-start/
   * Be verbose about the need to review and edit files, adding LICENSE headers into source files, etc
index f9c8dfc96a7337239734b812a81a35d2909b6b6b..738e4ecf12faed191b5d1ad706fca7eea93fc52f 100755 (executable)
@@ -43,9 +43,9 @@ function templater_drupal8 {
     fi
 
     if [ -d "puppet" ] && [ ! -e "puppet/Puppetfile" ]; then
-      cp $SHARE/drupal8/files/Puppetfile puppet/
+      cp $SHARE/drupal8/files/puppet/Puppetfile puppet/
     else
-      cp $SHARE/drupal8/files/Puppetfile puppet/Puppetfile.drupal8
+      cp $SHARE/drupal8/files/puppet/Puppetfile puppet/Puppetfile.drupal8
     fi
 
     if [ ! -e "bin/post-receive" ]; then
index b8658d2532e2617ed46289272e4c33c4966234ff..4507650701b10362f4d3eb596d9daf7189af2fa7 100644 (file)
@@ -104,3 +104,33 @@ function templater_install_makefile {
   #  echo Makefile.local >> .gitignore
   #fi
 }
+
+# Check differences
+function templater_diff {
+  local module="$1"
+  local cwd="`pwd`"
+
+  if [ -z "$module" ]; then
+    return
+  fi
+
+  if [ ! -d "$SHARE/$module/files" ]; then
+    return
+  fi
+
+  (
+  cd $SHARE/$module/files
+
+  find . -type f | while read file; do
+    # File exists, check differences
+    if [ -e "$cwd/$file" ]; then
+      diff -u $cwd/$file $file
+    else
+      # Use a templaterignore instead
+      if echo $file | grep -q -v 'example'; then
+        templater_echo "Missing $file"
+      fi
+    fi
+  done
+  )
+}
index ad24eb39d4d289de0bdc248673ee63649e371db1..06ae2884ab8b84abacde7a487116d235584681d0 100755 (executable)
--- a/templater
+++ b/templater
@@ -65,16 +65,27 @@ templater_init
 # Go to project folder
 cd $PROJECT &> /dev/null
 
-# Setup modules
+# Process modules
 if [ -z "$MODULES" ]; then
   for project in `templater_implementations`; do
     templater_ask $project
   done
 else
   for module in $MODULES; do
-    if `templater_implementations | grep -q "^$module"`; then
-      #templater_$module
-      $SHARE/$module/setup $SHARE
+    # Skip options
+    if echo $module | grep -q '^--'; then
+      continue
+    fi
+
+    #if `templater_implementations | grep -q "^$module"`; then
+    if [ -d "$SHARE/$module" ]; then
+      # Dispatch
+      if echo $* | grep -q -- '--diff'; then
+        templater_diff $module
+      #elif echo $* | grep -q -- '--update'; then
+      else
+        $SHARE/$module/setup $SHARE
+      fi
     else
       templater_echo "No such module $module, skipping"
     fi