diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..682346ef --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*.log +*.swp + +node_modules/ +npm-debug.log + +tmp/ +doc/ diff --git a/.jshintignore b/.jshintignore new file mode 100644 index 00000000..49012469 --- /dev/null +++ b/.jshintignore @@ -0,0 +1,5 @@ +.git/ +doc/ +node_modules/ +tmp/ +test/fixtures/ diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 00000000..df38ec3d --- /dev/null +++ b/.jshintrc @@ -0,0 +1,72 @@ +{ + // Enforcing Options ///////////////////////////////////////////////////////// + + "bitwise" : true, // Prohibit bitwise operators (&, |, ^, etc.). + "curly" : true, // Require {} for every new block or scope. + "eqeqeq" : true, // Require triple equals i.e. `===`. + "forin" : false, // Tolerate `for in` loops without `hasOwnPrototype`. + "immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );` + "latedef" : true, // Prohibit hariable use before definition. + "newcap" : true, // Require capitalization of all constructor functions e.g. `new F()`. + "noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`. + "noempty" : true, // Prohibit use of empty blocks. + "nonew" : true, // Prohibit use of constructors for side-effects. + "plusplus" : false, // Prohibit use of `++` & `--`. + "regexp" : false, // Prohibit `.` and `[^...]` in regular expressions. + "undef" : true, // Require all non-global variables be declared before they are used. + "strict" : true, // Require `use strict` pragma in every file. + "trailing" : true, // Prohibit trailing whitespaces. + + // Relaxing Options ////////////////////////////////////////////////////////// + + "asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons). + "boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments. + "debug" : false, // Allow debugger statements e.g. browser breakpoints. + "eqnull" : false, // Tolerate use of `== null`. + "es5" : true, // Allow ECMAScript 5 syntax. + "esnext" : false, // Allow ES.next specific features such as const and let + "evil" : false, // Tolerate use of `eval`. + "expr" : false, // Tolerate `ExpressionStatement` as Programs. + "funcscope" : false, // Tolerate declaring variables inside of control structures while accessing them later + "globalstrict" : true, // Allow global "use strict" (also enables 'strict'). + "iterator" : false, // Allow usage of __iterator__ property. + "lastsemic" : false, // Tolerate semicolon omited for the last statement. + "laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons. + "laxcomma" : true, // This option suppresses warnings about comma-first coding style + "loopfunc" : false, // Allow functions to be defined within loops. + "multistr" : false, // Tolerate multi-line strings. + "onecase" : false, // Tolerate swithes with only one case. + "proto" : false, // Allow usage of __proto__ property. + "regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`. + "scripturl" : true, // Tolerate script-targeted URLs. + "smarttabs" : false, // Allow mixed tabs and spaces when the latter are used for alignmnent only. + "shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`. + "sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`. + "supernew" : true, // Tolerate `new function () { ... };` and `new Object;`. + + // Environments ////////////////////////////////////////////////////////////// + + "browser" : false, // Defines globals exposed by modern browsers + "couch" : false, // Defines globals exposed by CouchDB + "devel" : false, // Allow developments statements e.g. `console.log();`. + "dojo" : false, // Defines globals exposed by the Dojo Toolkit + "jquery" : false, // Defines globals exposed by the jQuery + "mootools" : false, // Defines globals exposed by the MooTools + "node" : true, // Defines globals exposed when running under Node.JS + "nonstandard" : false, // Defines non-standard but widely adopted globals such as escape and unescape + "prototypejs" : false, // Defines globals exposed by the Prototype + "rhino" : false, // Defines globals exposed when running under Rhino + "wsh" : false, // Defines globals exposed when running under WSH + + // Legacy //////////////////////////////////////////////////////////////////// + + "nomen" : false, // Prohibit use of initial or trailing underbars in names. + "onevar" : false, // Allow only one `var` statement per function. + "passfail" : false, // Stop on first error. + "white" : false, // Check against strict whitespace and indentation rules. + + // Undocumented ////////////////////////////////////////////////////////////// + + "maxerr" : 100, // Maximum error before stopping. + "indent" : 2 // Specify indentation spacing +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..1afdae55 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +(The MIT License) + +Copyright (C) 2012 by Vitaly Puzrin + +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. diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..2a185037 --- /dev/null +++ b/Makefile @@ -0,0 +1,102 @@ +PATH := ./node_modules/.bin:${PATH} + +NPM_PACKAGE := $(shell node -e 'process.stdout.write(require("./package.json").name)') +NPM_VERSION := $(shell node -e 'process.stdout.write(require("./package.json").version)') + +TMP_PATH := /tmp/${NPM_PACKAGE}-$(shell date +%s) + +REMOTE_NAME ?= origin +REMOTE_REPO ?= $(shell git config --get remote.${REMOTE_NAME}.url) + +CURR_HEAD := $(firstword $(shell git show-ref --hash HEAD | cut --bytes=-6) master) +GITHUB_PROJ := nodeca/${NPM_PACKAGE} +SRC_URL_FMT := https://github.com/${GITHUB_PROJ}/blob/${CURR_HEAD}/{file}\#L{line} + + +help: + echo "make help - Print this help" + echo "make lint - Lint sources with JSHint" + echo "make test - Lint sources and run all tests" + echo "make doc - Build API docs" + echo "make dev-deps - Install developer dependencies" + echo "make gh-pages - Build and push API docs into gh-pages branch" + echo "make publish - Set new version tag and publish npm package" + echo "make todo - Find and list all TODOs" + + +lint: + if test ! `which jshint` ; then \ + echo "You need 'jshint' installed in order to run lint." >&2 ; \ + echo " $ make dev-deps" >&2 ; \ + exit 128 ; \ + fi + jshint . --show-non-errors + + +test: lint + @if test ! `which vows` ; then \ + echo "You need 'vows' installed in order to run tests." >&2 ; \ + echo " $ make dev-deps" >&2 ; \ + exit 128 ; \ + fi + NODE_ENV=test mocha + + +doc: + @if test ! `which ndoc` ; then \ + echo "You need 'ndoc' installed in order to generate docs." >&2 ; \ + echo " $ make dev-deps" >&2 ; \ + exit 128 ; \ + fi + rm -rf ./doc + ndoc --output ./doc --linkFormat "${SRC_URL_FMT}" ./lib + + +dev-deps: + @if test ! `which npm` ; then \ + echo "You need 'npm' installed." >&2 ; \ + echo " See: http://npmjs.org/" >&2 ; \ + exit 128 ; \ + fi + which jshint > /dev/null || npm install jshint + which ndoc > /dev/null || npm install ndoc + npm install + + +gh-pages: + @if test -z ${REMOTE_REPO} ; then \ + echo 'Remote repo URL not found' >&2 ; \ + exit 128 ; \ + fi + $(MAKE) doc && \ + cp -r ./doc ${TMP_PATH} && \ + touch ${TMP_PATH}/.nojekyll + cd ${TMP_PATH} && \ + git init && \ + git add . && \ + git commit -q -m 'Recreated docs' + cd ${TMP_PATH} && \ + git remote add remote ${REMOTE_REPO} && \ + git push --force remote +master:gh-pages + rm -rf ${TMP_PATH} + + +publish: + @if test 0 -ne `git status --porcelain | wc -l` ; then \ + echo "Unclean working tree. Commit or stash changes first." >&2 ; \ + exit 128 ; \ + fi + @if test 0 -ne `git tag -l ${NPM_VERSION} | wc -l` ; then \ + echo "Tag ${NPM_VERSION} exists. Update package.json" >&2 ; \ + exit 128 ; \ + fi + git tag ${NPM_VERSION} && git push origin ${NPM_VERSION} + npm publish https://github.com/${GITHUB_PROJ}/tarball/${NPM_VERSION} + + +todo: + grep 'TODO' -n -r ./lib 2>/dev/null || test true + + +.PHONY: publish lint test doc dev-deps gh-pages todo +.SILENT: help lint test doc todo diff --git a/index.js b/index.js new file mode 100644 index 00000000..420476ef --- /dev/null +++ b/index.js @@ -0,0 +1 @@ +module.exports = require('./lib/mincer'); diff --git a/lib/mincer.js b/lib/mincer.js new file mode 100644 index 00000000..c9186163 --- /dev/null +++ b/lib/mincer.js @@ -0,0 +1,6 @@ +module.exports = { + VERSION: '0.0.0', + + Environment: require('./mincer/environment'), + Manifest: require('./mincer/manifest') +}; diff --git a/lib/mincer/asset.js b/lib/mincer/asset.js new file mode 100644 index 00000000..305156b7 --- /dev/null +++ b/lib/mincer/asset.js @@ -0,0 +1,12 @@ +/** + * class Asset + **/ + + +/** + * Asset#digest -> String + **/ + + +/** + * Asset# diff --git a/lib/mincer/environment.js b/lib/mincer/environment.js new file mode 100644 index 00000000..4fa614e0 --- /dev/null +++ b/lib/mincer/environment.js @@ -0,0 +1,23 @@ +/** + * class Environment + **/ + + +/** + * new Environment(root) + **/ + + +/** + * Environment#prependPath(path) -> Void + **/ + + +/** + * Environment#appendPath(path) -> Void + **/ + + +/** + * Environment#find(logicalPath) -> Asset + **/ diff --git a/lib/mincer/manifest.js b/lib/mincer/manifest.js new file mode 100644 index 00000000..2e01514f --- /dev/null +++ b/lib/mincer/manifest.js @@ -0,0 +1,3 @@ +/** + * class Manifest + **/ diff --git a/package.json b/package.json new file mode 100644 index 00000000..7ea54f3b --- /dev/null +++ b/package.json @@ -0,0 +1,25 @@ +{ + "name" : "mincer", + "version" : "0.0.0", + "description" : "Web assets processor inspired by Sprockets.", + "keywords" : ["sprockets", "assets", "minify", "uglify", "bundle", "less.js", "stylus"], + "homepage" : "https://github.com/nodeca/hike-js", + + "author" : "Aleksey V Zapparov (http://ixti.net/)", + + "bugs" : { "url": "https://github.com/nodeca/hike-js/issues" }, + "license" : { "type": "MIT", "url": "https://github.com/nodeca/hike-js/blob/master/LICENSE" }, + "repository" : { "type": "git", "url": "git://github.com/nodeca/hike-js.git" }, + + "main" : "./index.js", + + "scripts" : { + "test": "make test" + }, + "dependencies" : { + "hike": "git://github.com/nodeca/hike-js.git", + "underscore": "1.3.3" + }, + "devDependencies" : { "mocha": "1.0.1" }, + "engines" : { "node": ">= 0.6.0" } +}