1.PHONY : all test dependencies clean veryclean lint js css font 2 3NODE_MODULES := node_modules/.bin 4BOWER_COMPONENTS := bower_components 5 6all: lint js css test 7js: dist/sequence-diagram-min.js dist/sequence-diagram-raphael-min.js dist/sequence-diagram-snap-min.js 8css: dist/sequence-diagram-min.css font 9font: dist/danielbd.woff2 dist/danielbd.woff 10 11node_modules: package.json 12 # 13 # NPM update needed. 14 # 15 npm update 16 touch $@ 17 18bower_components: bower.json 19 # 20 # Bower update needed. 21 # 22 $(NODE_MODULES)/bower update 23 touch $@ 24 25dependencies: node_modules bower_components 26 27clean: 28 -rm build/* 29 -git checkout -- dist 30 31veryclean: clean 32 -rm -rf node_modules 33 -rm -rf bower_components 34 35lint: dependencies package.json bower.json 36 $(NODE_MODULES)/jshint --verbose src/*.js 37 $(NODE_MODULES)/jshint --verbose test/*.js 38 $(NODE_MODULES)/jsonlint package.json -q 39 $(NODE_MODULES)/jsonlint bower.json -q 40 41 $(NODE_MODULES)/jsonlint .jscsrc -q 42 $(NODE_MODULES)/jscs --fix src/*.js 43 $(NODE_MODULES)/jscs --fix test/*.js 44 45test: dependencies dist/sequence-diagram-min.js 46 47 # Test the un-minifed file (with underscore) 48 $(NODE_MODULES)/qunit \ 49 -c dist/sequence-diagram.js \ 50 -t test/*-tests.js \ 51 -d test/*-mock.js $(BOWER_COMPONENTS)/underscore/underscore-min.js 52 53 # Test the un-minifed file (with lodash) 54 $(NODE_MODULES)/qunit \ 55 -c dist/sequence-diagram.js \ 56 -t test/*-tests.js \ 57 -d test/*-mock.js $(BOWER_COMPONENTS)/lodash/dist/lodash.min.js 58 59 # Test the minifed file (with underscore) 60 $(NODE_MODULES)/qunit \ 61 -c dist/sequence-diagram-min.js \ 62 -t test/*-tests.js \ 63 -d test/*-mock.js $(BOWER_COMPONENTS)/underscore/underscore-min.js 64 65 # Test the minifed file (with lodash) 66 $(NODE_MODULES)/qunit \ 67 -c dist/sequence-diagram-min.js \ 68 -t test/*-tests.js \ 69 -d test/*-mock.js $(BOWER_COMPONENTS)/lodash/dist/lodash.min.js 70 71build/grammar.js: src/grammar.jison 72 mkdir -p build 73 $(NODE_MODULES)/jison $< -o $@.tmp 74 75 # After building the grammar, run it through the uglifyjs to fix some non-strict issues. 76 # Until https://github.com/zaach/jison/issues/285 is fixed, we must do this to create valid non-minified code. 77 $(NODE_MODULES)/uglifyjs \ 78 $@.tmp -o $@ \ 79 --comments all --compress --beautify 80 81 rm $@.tmp 82 83# Compile the grammar 84build/diagram-grammar.js: src/diagram.js build/grammar.js 85 $(NODE_MODULES)/preprocess $< . > $@ 86 87# Combine all javascript files together (Raphael and Snap.svg) 88dist/sequence-diagram.js: src/main.js build/diagram-grammar.js src/jquery-plugin.js src/sequence-diagram.js src/theme.js src/theme-snap.js src/theme-raphael.js fonts/daniel/daniel_700.font.js 89 mkdir -p dist 90 $(NODE_MODULES)/preprocess $< . -SNAP=true -RAPHAEL=true > $@ 91 92# Combine just Raphael theme 93dist/sequence-diagram-raphael.js: src/main.js build/diagram-grammar.js src/jquery-plugin.js src/sequence-diagram.js src/theme.js src/theme-raphael.js fonts/daniel/daniel_700.font.js 94 $(NODE_MODULES)/preprocess $< . -RAPHAEL=true > $@ 95 96# Combine just Snap.svg theme 97dist/sequence-diagram-snap.js: src/main.js build/diagram-grammar.js src/jquery-plugin.js src/sequence-diagram.js src/theme.js src/theme-snap.js 98 $(NODE_MODULES)/preprocess $< . -SNAP=true > $@ 99 100dist/sequence-diagram.css: src/sequence-diagram.css 101 cp $< $@ 102 103# Minify the CSS 104dist/sequence-diagram-min.css: dist/sequence-diagram.css 105 $(NODE_MODULES)/minify --output $@ $< 106 107# Move some fonts TODO optomise the fonts 108dist/%.woff: fonts/daniel/%.woff 109 cp $< $@ 110 111dist/%.woff2: fonts/daniel/%.woff2 112 cp $< $@ 113 114# Minify the final javascript 115dist/%-min.js dist/%-min.js.map: dist/%.js 116 117 # 118 # Please ignore the warnings below (these are in combined js code) 119 # 120 $(NODE_MODULES)/uglifyjs \ 121 $< -o $@ \ 122 --compress --comments --lint \ 123 --source-map $@.map \ 124 --source-map-url `basename $<` 125