From: David Schoonover Date: Tue, 10 Jul 2012 13:04:53 +0000 (-0700) Subject: Build target now compiles derived files for release. Updates middlware to serve the... X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=ec7bc75634cc79ed55c17614c597cf7f938e89b5;p=limn.git Build target now compiles derived files for release. Updates middlware to serve the right directories. --- diff --git a/Cokefile b/Cokefile index 27e89ba..1b23cd0 100644 --- a/Cokefile +++ b/Cokefile @@ -13,9 +13,11 @@ task \link 'Link package source to node_modules so the name resolves correctly' # Browser-based require doens't support relative requires, but things # like `require 'kraken/utils'` rarely work in node without this hack. mkdirp 'node_modules' - if not exists MODULE_LINK + if exists MODULE_LINK + remove MODULE_LINK + else say "Creating #{basename MODULE_LINK} symlink..." - fs.symlinkSync "../lib", MODULE_LINK + fs.symlinkSync "../src", MODULE_LINK task \install 'Install project dependencies.' -> <- sh 'npm install', {-verbose, +errors, +die} @@ -29,7 +31,7 @@ task \setup 'Ensure project is set up for development.' -> task \server 'Start dev server' -> invoke \setup say '' - run 'lib/server/server.co' + run 'src/server/server.co' task \build 'Build coco sources' -> @@ -45,7 +47,7 @@ task \build 'Build coco sources' -> yaml = require 'js-yaml' matchExt = /((?:\.min)?)\.mod((?:\.min)?)\.js$/i - targetDir = 'var' + targetDir = 'lib' console.log 'Building source...' Seq() @@ -57,9 +59,9 @@ task \build 'Build coco sources' -> write 'static/vendor/browserify.js', bundle @ok() - .set glob 'lib/template/**/*.jade', {+sync} + .set glob 'src/template/**/*.jade', {+sync} .seqEach (infile) -> - outfile = "#infile.js".replace /^lib/, "#targetDir/js/kraken" + outfile = "#infile.js".replace /^src/, 'lib' console.log " Compiling Jade template to JS:\t #infile \t-->\t #outfile" template_fn = Jade.compile read(infile), { +pretty, +client, -compileDebug, filename:infile } template = String template_fn .replace /^function anonymous\(/, 'function \(' @@ -72,37 +74,38 @@ task \build 'Build coco sources' -> """ @ok() - .set glob('lib/main-*.co', {+sync}).concat sources("www/modules.yaml", 'development').map -> it.slice 1 - .seqEach (src) -> - infile = src.replace /^js\/kraken/, 'lib' .replace matchExt, '.co' + .set glob('src/main-*.co', {+sync}).concat sources("www/modules.yaml", 'development').map -> it.slice 1 + .seqEach (srcfile) -> + infile = srcfile.replace /^js\/kraken/, 'src' .replace matchExt, '.co' return @ok() unless exists infile - # console.log " Skipping Coco compile:\t (#src)\t #infile does not exist" - # return @ok src + # unless exists infile + # console.log " Skipping Coco compile:\t (#srcfile)\t #infile does not exist" + # return @ok() - outfile = "#targetDir/" + src.replace /^lib/, 'js/kraken' .replace matchExt, '.js' .replace /\.co$/, '.js' + outfile = srcfile.replace /^(js\/kraken|src)/, 'lib' .replace matchExt, '.js' .replace /\.co$/, '.js' console.log " Compiling Coco to JS:\t #infile \t-->\t #outfile" mkdirp dirname outfile write outfile, Coco.compile read(infile), {+bare} @ok() .set sources("www/modules.yaml", 'development').map -> it.slice 1 - .seqEach (src) -> - return @ok() unless matchExt.test src - infile = (if _.startsWith src, 'vendor' then 'static' else targetDir) + '/' + src.replace matchExt, '$1$2.js' + .seqEach (srcfile) -> + return @ok() unless matchExt.test srcfile + outfile = (if _.startsWith srcfile, 'vendor' then 'static' else 'www') + '/' + srcfile + infile = outfile.replace matchExt, '$1$2.js' return @ok() unless exists infile - outfile = targetDir + '/' + src - return @ok() if exists outfile + return @ok() if _.startsWith(srcfile, 'vendor') and exists outfile parts = infile.replace matchExt, '' .split '/' .slice 2 parts.pop() if 'index' is _.last parts ID = parts.join '/' - console.log " Wrapping JS in Module:\t #infile \t-->\t #outfile (#ID)" + console.log " Wrapping JS in Module:\t #infile \t-->\t #outfile" mkdirp dirname outfile write outfile, "require.define('/node_modules/#ID.js', function(require, module, exports, __dirname, __filename, undefined){\n\n" + read(infile) + "\n\n});\n" @ok() .set glob 'www/css/*.styl', {+sync} .seqEach (infile) -> - outfile = infile.replace /^www\//, "#targetDir/" .replace /\.styl$/, '.css' + outfile = infile.replace /\.styl$/, '.css' console.log " Compiling Stylus to CSS:\t #infile \t-->\t #outfile" mkdirp dirname outfile stylus = Stylus read infile diff --git a/package.co b/package.co index 13371fc..4f5821f 100644 --- a/package.co +++ b/package.co @@ -2,7 +2,7 @@ name : 'kraken' version : '0.1.0' description : 'A charting toolkit and dashboard.' homepage : 'http://git.less.ly/?p=kraken-ui.git' -keywords : <[ util server client browser visualization graph ]> +keywords : <[ visualization graph chart util server client browser ]> author : 'David Schoonover (http://less.ly)' contributors : [ 'Andrew Otto ' @@ -10,7 +10,6 @@ contributors : [ 'Diederik van Liere ' ] - # main : './lib' # directories : lib: './lib', bin:'./bin', doc:'./doc', man:'./man' diff --git a/package.json b/package.json index ce86a74..872ab4d 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,13 @@ "description": "A charting toolkit and dashboard.", "homepage": "http://git.less.ly/?p=kraken-ui.git", "keywords": [ + "visualization", + "graph", + "chart", "util", "server", "client", - "browser", - "visualization", - "graph" + "browser" ], "author": "David Schoonover (http://less.ly)", "contributors": [ diff --git a/src/server/middleware.co b/src/server/middleware.co index ba6a37c..dce18b7 100755 --- a/src/server/middleware.co +++ b/src/server/middleware.co @@ -21,11 +21,12 @@ Controller = require './controller' * Limn project-internals */ BASE = dirname dirname __dirname -WWW = "#BASE/www" -VAR = "#BASE/var" -STATIC = "#BASE/static" -DIST = "#BASE/dist" DATA = "#BASE/data" +LIB = "#BASE/llb" +SRC = "#BASE/src" +STATIC = "#BASE/static" +VAR = "#BASE/var" +WWW = "#BASE/www" NODE_ENV = process.env.NODE_ENV or 'development' IS_DEV = NODE_ENV is 'development' @@ -142,8 +143,13 @@ application = limn.application = compiler = require 'connect-compiler-extras' # transparently recompile modules that have changed + @use '/js/kraken', compiler do + enabled : 'coco' + src : SRC + dest : "#VAR/js/kraken" + log_level : LOG_LEVEL @use compiler do - enabled : <[ coco jade-browser stylus yaml ]> + enabled : <[ jade-browser stylus yaml ]> src : WWW dest : VAR options : stylus : { nib:true, include:"#WWW/css" } @@ -175,9 +181,8 @@ application = limn.application = # serve static files @configure -> opts = @set('static file options') or {} - @use express.static DIST, ^opts if exists DIST - @use express.static WWW, ^opts @use express.static VAR, ^opts + @use express.static WWW, ^opts @use express.static STATIC, ^opts