Permalink
Browse files

Package and build a dist of the custom widget.

By default the Makefile builds the widget:

    make
  • Loading branch information...
1 parent 4457d7f commit ae3cafdd85d1ddf19272b598084988739b561cb3 @MarkBennett committed Feb 9, 2011
Showing with 8,659 additions and 1 deletion.
  1. +84 −0 Makefile
  2. +1 −0 TODO
  3. +36 −0 build/jslint-check.js
  4. +5,504 −0 build/lib/jslint.js
  5. +1,239 −0 build/lib/parse-js.js
  6. +1,562 −0 build/lib/process.js
  7. +22 −0 build/lib/squeeze-more.js
  8. +199 −0 build/uglify.js
  9. +1 −1 src/custom_widget.js
  10. +7 −0 src/intro.js
  11. +3 −0 src/outro.js
  12. +1 −0 version.txt
View
@@ -0,0 +1,84 @@
+V ?= 0
+
+SRC_DIR = src
+TEST_DIR = spec
+BUILD_DIR = build
+
+PREFIX = .
+DIST_DIR = ${PREFIX}/dist
+
+JS_ENGINE ?= `which node nodejs`
+COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe
+
+BASE_FILES = ${SRC_DIR}/custom_widget.js
+
+MODULES = ${SRC_DIR}/intro.js\
+ ${BASE_FILES}\
+ ${SRC_DIR}/outro.js
+
+JQ = ${DIST_DIR}/custom-widget.js
+JQ_MIN = ${DIST_DIR}/custom-widget.min.js
+
+JQ_VER = $(shell cat version.txt)
+VER = sed "s/@VERSION/${JQ_VER}/"
+
+DATE=$(shell git log -1 --pretty=format:%ad)
+
+all: jquery min lint
+ @@echo "Custom widget build complete."
+
+${DIST_DIR}:
+ @@mkdir -p ${DIST_DIR}
+
+ifeq ($(strip $(V)),0)
+verbose = --quiet
+else ifeq ($(strip $(V)),1)
+verbose =
+else
+verbose = --verbose
+endif
+
+jquery: ${JQ}
+jq: ${JQ}
+
+${JQ}: ${MODULES} | ${DIST_DIR}
+ @@echo "Building" ${JQ}
+
+ @@cat ${MODULES} | \
+ sed 's/.function..jQuery...{//' | \
+ sed 's/}...jQuery..;//' | \
+ sed 's/@DATE/'"${DATE}"'/' | \
+ ${VER} > ${JQ};
+
+lint: jquery
+ @@if test ! -z ${JS_ENGINE}; then \
+ echo "Checking against JSLint..."; \
+ ${JS_ENGINE} build/jslint-check.js; \
+ else \
+ echo "You must have NodeJS installed in order to test against JSLint."; \
+ fi
+
+min: ${JQ_MIN}
+
+${JQ_MIN}: jquery
+ @@if test ! -z ${JS_ENGINE}; then \
+ echo "Minifying" ${JQ_MIN}; \
+ ${COMPILER} ${JQ} > ${JQ_MIN}.tmp; \
+ sed '$ s#^\( \*/\)\(.\+\)#\1\n\2;#' ${JQ_MIN}.tmp > ${JQ_MIN}; \
+ rm -rf ${JQ_MIN}.tmp; \
+ else \
+ echo "You must have NodeJS installed in order to minify."; \
+ fi
+
+
+clean:
+ @@echo "Removing Distribution directory:" ${DIST_DIR}
+ @@rm -rf ${DIST_DIR}
+
+ @@echo "Removing built copy of Sizzle"
+ @@rm -f src/selector.js
+
+ @@echo "Removing cloned directories"
+ @@rm -rf test/qunit src/sizzle
+
+.PHONY: all jquery lint min init jq clean
View
1 TODO
@@ -1,3 +1,4 @@
+* Add a make system which tests custom code against jslint (jquery)
* Add a build system which minimizes JS with uglify (jquery)
* Add a build system which combines many seperate javascript files (jquery-ui)
* Add a documentation system which builds HTML documentation (nodejs)
View
@@ -0,0 +1,36 @@
+var JSLINT = require("./lib/jslint").JSLINT,
+ print = require("sys").print,
+ src = require("fs").readFileSync("dist/jquery.js", "utf8");
+
+JSLINT(src, { evil: true, forin: true, maxerr: 100 });
+
+// All of the following are known issues that we think are 'ok'
+// (in contradiction with JSLint) more information here:
+// http://docs.jquery.com/JQuery_Core_Style_Guidelines
+var ok = {
+ "Expected an identifier and instead saw 'undefined' (a reserved word).": true,
+ "Use '===' to compare with 'null'.": true,
+ "Use '!==' to compare with 'null'.": true,
+ "Expected an assignment or function call and instead saw an expression.": true,
+ "Expected a 'break' statement before 'case'.": true,
+ "'e' is already defined.": true
+};
+
+var e = JSLINT.errors, found = 0, w;
+
+for ( var i = 0; i < e.length; i++ ) {
+ w = e[i];
+
+ if ( !ok[ w.reason ] ) {
+ found++;
+ print( "\n" + w.evidence + "\n" );
+ print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason );
+ }
+}
+
+if ( found > 0 ) {
+ print( "\n" + found + " Error(s) found.\n" );
+
+} else {
+ print( "JSLint check passed.\n" );
+}
Oops, something went wrong.

0 comments on commit ae3cafd

Please sign in to comment.