Last active
          August 29, 2015 14:14 
        
      - 
      
- 
        Save alejandrobernardis/9db271e81c64f81002c5 to your computer and use it in GitHub Desktop. 
    Angular Template (makefile)
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | DEPLOY_PATH := ./deploy | |
| NODE_PATH := ./node_modules | |
| STATIC_PATH := ./static | |
| STATIC_STRUCT := ./static/{component,style,data,image,script,stylus,vendor,view} | |
| VENDOR_PATH := ./static/vendor | |
| OK := " - Ok." | |
| NOT_FOUND := " - Not found." | |
| FAIL := " - Fail." | |
| SERVER_PID := /tmp/pyserver.pid | |
| GULP_PID := /tmp/gulp-default.pid | |
| YEAR := $(shell date +"%Y") | |
| define PACKAGE_FILE | |
| { | |
| "name": "project-name", | |
| "version": "1.0.0", | |
| "repository": {}, | |
| "devDependencies": { | |
| "browser-sync": ">=1.7.3", | |
| "gulp": ">=3.8.10", | |
| "gulp-stylus": ">=1.3.4", | |
| "gulp-uglify": ">=1.1.0", | |
| "gulp-watch": ">=3.0.0", | |
| "nib": ">=1.0.4" | |
| } | |
| } | |
| endef | |
| export PACKAGE_FILE | |
| define BOWERRC_FILE | |
| { | |
| "directory": "static/vendor/" | |
| } | |
| endef | |
| export BOWERRC_FILE | |
| define BOWER_FILE | |
| { | |
| "name": "project-name", | |
| "version": "1.0.0", | |
| "ignore": [], | |
| "dependencies": { | |
| "angular": ">= 1.3.7", | |
| "angular-route": ">= 1.3.7", | |
| "angular-messages": ">= 1.3.7", | |
| "angular-touch": ">= 1.3.7", | |
| "angular-loader": ">= 1.3.7", | |
| "angular-i18n": ">= 1.3.7", | |
| "angular-cookie": ">= 1.3.7", | |
| "angular-aria": ">= 1.3.7", | |
| "angular-ui-router": ">= 0.2.13", | |
| "jquery": ">= 2.1.1", | |
| "bootstrap": ">=3.3.1" | |
| } | |
| } | |
| endef | |
| export BOWER_FILE | |
| define GULP_FILE | |
| var gulp = require('gulp'); | |
| var stylus = require('gulp-stylus'); | |
| var uglify = require('gulp-uglify'); | |
| var nib = require('nib'); | |
| gulp.task('deploy', function() { | |
| gulp.src('./deploy/script/**/*.js') | |
| .pipe(uglify()) | |
| .pipe(gulp.dest('./deploy/script/')) | |
| }); | |
| gulp.task('stylus', function () { | |
| return gulp.src('./static/stylus/**/*.styl') | |
| .pipe(stylus({ | |
| use: nib(), | |
| compress: true | |
| })) | |
| .pipe(gulp.dest('./static/style/')); | |
| }); | |
| gulp.task('default', function () { | |
| gulp.watch('./static/stylus/**/*.styl', ['stylus']); | |
| }); | |
| endef | |
| export GULP_FILE | |
| define HTML_INDEX_FILE | |
| <!DOCTYPE html> | |
| <html> | |
| <head lang="en"> | |
| <meta charset="utf-8"> | |
| <title></title> | |
| </head> | |
| <body> | |
| </body> | |
| </html> | |
| endef | |
| export HTML_INDEX_FILE | |
| define MIT_LICENSE_FILE | |
| The MIT License (MIT) | |
| Copyright (c) $(YEAR) Alejandro M. Bernardis | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in all | |
| copies or substantial portions of the Software. | |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
| SOFTWARE. | |
| endef | |
| export MIT_LICENSE_FILE | |
| define GITIGNORE_FILE | |
| deploy/ | |
| dist/ | |
| node_modules/ | |
| .DS_* | |
| *.mo | |
| *.pot | |
| *.log | |
| .idea/ | |
| .idea-old/ | |
| *.ignore | |
| bin/b7/ | |
| bin/b7 | |
| 2.7/ | |
| 2.7 | |
| fileobject/ | |
| fileobjects/ | |
| endef | |
| export GITIGNORE_FILE | |
| # Tasks | |
| clean: | |
| @echo "~ Clean ..." | |
| @sudo rm -fRv $(DEPLOY_PATH) $(NODE_PATH) | |
| @echo "Done." | |
| structure: | |
| @echo "~ Initialize structure ..." | |
| @mkdir -pv $(DEPLOY_PATH) $(STATIC_STRUCT) | |
| @echo "$$HTML_INDEX_FILE" > ./index.html | |
| @echo "$$MIT_LICENSE_FILE" > ./license.md | |
| @echo "$$GITIGNORE_FILE" > ./.gitignore | |
| @touch ./readme.md | |
| @echo "$$PACKAGE_FILE" > ./package.json | |
| @echo "$$BOWERRC_FILE" > ./.bowerrc | |
| @echo "$$BOWER_FILE" > ./bower.json | |
| @echo "$$GULP_FILE" > ./gulpfile.json | |
| @read -p "Project Name: " REPLY; for i in *.json; do sed -i .bak -e s/project-name/$$REPLY/g $$i; done; echo "$$REPLY" > .project_name; | |
| -@rm -f *.bak | |
| @echo "Done." | |
| init: structure | |
| @echo "~ Initialize dependencies ..." | |
| @sudo npm install | |
| @rm -fRv $(VENDOR_PATH)/* | |
| @bower install | |
| @echo "Done." | |
| run: kill | |
| @echo "~ Run ..." | |
| @echo " * Server starting" | |
| @nohup /usr/local/bin/python -m SimpleHTTPServer > /tmp/pyserver.out 2> /tmp/pyserver.err < /dev/null & echo "$$!" > $(SERVER_PID) | |
| @if [ -e $(SERVER_PID) ]; then echo " - PID = `cat $(SERVER_PID)`"; else echo $(FAIL); fi; | |
| @echo " * Preprocessor starting" | |
| @nohup /usr/local/bin/gulp default > /tmp/gulp-default.out 2> /tmp/gulp-default.err < /dev/null & echo "$$!" > $(GULP_PID) | |
| @if [ -e $(GULP_PID) ]; then echo " - PID = `cat $(GULP_PID)`"; else echo $(FAIL); fi; | |
| @echo "Done." | |
| kill: | |
| @echo "~ Kill ..." | |
| @echo " * Server stopping" | |
| -@if [ -e $(SERVER_PID) ]; then kill -9 `cat $(SERVER_PID)`; echo $(OK); else echo $(NOT_FOUND); fi; | |
| @echo " * Preprocessor stopping" | |
| -@if [ -e $(GULP_PID) ]; then kill -9 `cat $(GULP_PID)`; echo $(OK); else echo $(NOT_FOUND); fi; | |
| -@rm -f $(SERVER_PID) $(GULP_PID) | |
| @echo "Done." | |
| deploy: | |
| @gulp deploy | |
| .PHONY: clean structure init run kill deploy | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment