Comparing version 0.4.15 to 0.4.16
@@ -38,3 +38,3 @@ var _ = require('underscore'); | ||
_.extend(App, /** @lends App */{ | ||
_.extend(App, /** @lends App **/{ | ||
RootDirs: ['tools','docs','common', 'utils'], | ||
@@ -117,5 +117,5 @@ PageDirs: ['core', 'mods', 'test'], | ||
}); | ||
}, | ||
@@ -235,3 +235,3 @@ | ||
}, callback); | ||
}, | ||
@@ -269,3 +269,3 @@ | ||
}); | ||
}, | ||
@@ -436,7 +436,7 @@ | ||
//去除毛燥 :) | ||
if (self.watchTimer) { | ||
clearTimeout(self.watchTimer) | ||
if (self.utilsWatchTimer) { | ||
clearTimeout(self.utilsWatchTimer) | ||
} | ||
self.watchTimer = setTimeout(function () { | ||
self.utilsWatchTimer = setTimeout(function () { | ||
self.emit('utilsChange'); | ||
@@ -491,16 +491,23 @@ }, 50); | ||
stopAutoBuildCommon: function (){ | ||
var self = this; | ||
if (self.commonWatcher) { | ||
self.commonWatcher.stop(); | ||
} | ||
}, | ||
autoBuildCommon: function () { | ||
var self = this; | ||
console.log('start auto build'); | ||
// console.log('start auto build'); | ||
self.startWatchCommon(); | ||
self.on('commonChange', function (err) { | ||
self.buildCommon(function (err, reporter) { | ||
if (err) { | ||
self.emit('common_build_error', err); | ||
return; | ||
} | ||
self.buildCommon(function (err, reporter) { | ||
if (err) { | ||
self.emit('common_build_error', err); | ||
return; | ||
} | ||
self.emit('common_build_success', reporter); | ||
}); | ||
self.emit('common_build_success', reporter); | ||
}); | ||
}); | ||
@@ -514,2 +521,3 @@ }, | ||
var self = this; | ||
self.removeAllListeners('utilsChange'); | ||
if (self.utilsWatchr) { | ||
@@ -568,3 +576,3 @@ self.utilsWatchr.stop(); | ||
var jobs = [ | ||
{ | ||
{ | ||
filename: 'common/package-config.js', | ||
@@ -790,3 +798,3 @@ src: path.join(fbRoot, 'files/package-config.js') | ||
self._plugins.push(plugin); | ||
}, | ||
@@ -872,3 +880,3 @@ | ||
for(var i = 0; i < pages.length; i++) { | ||
parsed = Page.parsePageVersion(pages[i]); | ||
parsed = Page.parsePageVersion(pages[i]); | ||
if (!parsed) { | ||
@@ -913,3 +921,3 @@ error.message = 'Page ' + pages[i] + 'is not valid'; | ||
self.saveConfig(callback); | ||
}); | ||
@@ -916,0 +924,0 @@ |
@@ -110,3 +110,3 @@ var fs = require('fs'); | ||
} | ||
console.log('Update success! Current fbversion is %s', app.config.fbversion); | ||
console.log('App Update success! Current fbversion is %s', app.config.fbversion); | ||
callback(null, 'success!'); | ||
@@ -145,3 +145,2 @@ }); | ||
if (targets.length === 0) { | ||
//ki build -t xxxxxxxx | ||
var current = app.getCurrent(); | ||
@@ -205,4 +204,2 @@ if (current.pageName && appcurrent.version) { | ||
//console.log(reporters); | ||
if (argv.watch) { | ||
@@ -215,15 +212,16 @@ | ||
fbPages.forEach(function (page) { | ||
function watching () { | ||
console.log('[%s] %s','watching'.green, 'utils'); | ||
function watching () { | ||
console.log('[%s] %s','watching'.green, 'utils'); | ||
pages.forEach(function(p){ | ||
console.log('[%s] %s','watching'.green, p); | ||
}) | ||
} | ||
pages.forEach(function(p){ | ||
console.log('[%s] %s','watching'.green, p); | ||
}); | ||
page.startAutoBuild(timestamp); | ||
console.log('watching...'.green) | ||
} | ||
watching(); | ||
watching(); | ||
fbPages.forEach(function (page) { | ||
page.startAutoBuild(timestamp); | ||
page.on('build_fail', function (err) { | ||
@@ -233,3 +231,2 @@ errorHelper.printError(err); | ||
}); | ||
page.on('watch_error', function (err) { | ||
@@ -247,2 +244,3 @@ errorHelper.printError(err); | ||
} else { | ||
@@ -249,0 +247,0 @@ callback(null); |
var util = require('util'); | ||
var colors = require('colors'); | ||
require('colors'); | ||
exports.printError = function (err) { | ||
util.debug(err.stack.red); | ||
delete err.stack; | ||
var stack; | ||
if (!err) { | ||
util.debug('Unknown Error!') | ||
return; | ||
} | ||
if (err.stack) { | ||
stack = err.stack; | ||
delete err.stack; | ||
} | ||
util.debug(JSON.stringify(err, null, 2).red); | ||
if (stack) { | ||
util.debug(stack); | ||
} | ||
}; |
@@ -63,3 +63,3 @@ var _ = require('underscore'); | ||
* parser page_version string to object | ||
* @param {string} page_version str of page/version | ||
* @param {string} page_version str of page/version | ||
* @return {Object} an obj with name and version | ||
@@ -125,3 +125,3 @@ */ | ||
fu.readJSON(path.resolve(rootDir, dirname, Page.BUILD_JSON_NAME), function (err, obj) { | ||
timestamps.push({ | ||
timestamps.push({ | ||
timestamp: dirname, | ||
@@ -198,7 +198,7 @@ build: err ? null : obj | ||
//去除毛燥 :) | ||
if (self.watchTimer) { | ||
clearTimeout(self.watchTimer) | ||
if (self.utilsWatchTimer) { | ||
clearTimeout(self.utilsWatchTimer) | ||
} | ||
self.watchTimer = setTimeout(function () { | ||
self.utilsWatchTimer = setTimeout(function () { | ||
self.emit('change'); | ||
@@ -243,10 +243,10 @@ }, 50); | ||
packages:[{ | ||
name:'utils', | ||
path:self.app.rootDir, | ||
charset:self.app.getCharset() | ||
}, { | ||
name:Page.BASE_DIR_NAME, | ||
path:self.versionDir, | ||
charset:self.getInputCharset() | ||
} | ||
name:'utils', | ||
path:self.app.rootDir, | ||
charset:self.app.getCharset() | ||
}, { | ||
name:Page.BASE_DIR_NAME, | ||
path:self.versionDir, | ||
charset:self.getInputCharset() | ||
} | ||
], | ||
@@ -301,2 +301,4 @@ silent: true | ||
self.app.stopWatchUtils(self); | ||
self.removeAllListeners('build_fail'); | ||
self.removeAllListeners('build_success'); | ||
}, | ||
@@ -310,3 +312,2 @@ | ||
self.build(timestamp, function (err, reports) { | ||
// TODO | ||
if (err) { | ||
@@ -321,5 +322,5 @@ self.emit('build_fail', err); | ||
self.startWatch(); | ||
app.startWatchUtils(self); | ||
app.startWatchUtils(); | ||
app.on('startWatch', buildPage); | ||
app.on('utilsChange', buildPage); | ||
self.on('change', buildPage); | ||
@@ -341,3 +342,3 @@ | ||
}) | ||
}, | ||
}, | ||
callback | ||
@@ -410,3 +411,3 @@ ); | ||
} | ||
}, | ||
}, | ||
callback | ||
@@ -469,3 +470,3 @@ ); | ||
var self = this; | ||
var page = { | ||
@@ -484,3 +485,3 @@ srcDir: self.srcDir, | ||
var prev = new Date(); | ||
async.mapSeries(self._plugins, function(plugin, callback) { | ||
@@ -511,3 +512,3 @@ plugin(page, function (err, report) { | ||
}); | ||
}, | ||
@@ -569,6 +570,6 @@ | ||
async.forEach([ | ||
path.join(self.srcDir, Page.BASE_DIR_NAME), | ||
path.join(self.destDir, Page.BASE_DIR_NAME), | ||
path.join(self.srcDir, 'utils') | ||
], | ||
path.join(self.srcDir, Page.BASE_DIR_NAME), | ||
path.join(self.destDir, Page.BASE_DIR_NAME), | ||
path.join(self.srcDir, 'utils') | ||
], | ||
function (dir, callback) { | ||
@@ -637,3 +638,3 @@ fu.mkdirp(dir, callback); | ||
fs.exists(dirName, function (exist) { | ||
if (!exist) { | ||
@@ -643,4 +644,4 @@ return callback(null); | ||
fu.rmTree(dirName, function (err) { | ||
@@ -671,3 +672,3 @@ if(err) { | ||
self._plugins.push(plugin); | ||
}, | ||
@@ -674,0 +675,0 @@ |
@@ -52,4 +52,4 @@ /** | ||
module.exports = function(config) { | ||
var config = config || {}; | ||
var config = _.defaults(config, { | ||
config = config || {}; | ||
config = _.defaults(config, { | ||
base: '', | ||
@@ -59,4 +59,4 @@ compress: false, | ||
optimization: 1, | ||
silent: false, | ||
color: true, | ||
silent: true, | ||
color: false, | ||
strictImports: false | ||
@@ -78,5 +78,6 @@ }); | ||
} | ||
async.filter( | ||
files, | ||
files, | ||
function(file, callback) { | ||
@@ -89,6 +90,5 @@ fs.stat(path.resolve(base_src, file), function(err, stat){ | ||
}); | ||
}, | ||
}, | ||
function (files) { | ||
if (files.length === 0) { | ||
@@ -98,3 +98,3 @@ return next(null, report); | ||
async.forEach(files, function (file, callback){ | ||
async.forEach(files, function (file, callback) { | ||
var src = path.resolve(base_src, file); | ||
@@ -108,3 +108,4 @@ | ||
if (err) { | ||
return callback(err); | ||
callback(err); | ||
return; | ||
} | ||
@@ -114,15 +115,22 @@ | ||
parseLessFile({ | ||
data: data, | ||
dest: dest | ||
}, { | ||
paths: [ path.dirname(src) ], | ||
compress: config.compress, | ||
yuicompress: config.yuicompress, | ||
optimization: config.optimization, | ||
silent: config.silent, | ||
color: config.color, | ||
filename: file, | ||
strictImports: config.strictImports | ||
}, callback); | ||
try { | ||
parseLessFile({ | ||
data: data, | ||
dest: dest | ||
}, { | ||
paths: [ path.dirname(src) ], | ||
compress: config.compress, | ||
yuicompress: config.yuicompress, | ||
optimization: config.optimization, | ||
silent: config.silent, | ||
color: config.color, | ||
filename: file, | ||
strictImports: config.strictImports | ||
}, callback); | ||
} catch(e) { | ||
console.log('Error catch!') | ||
callback(e); | ||
} | ||
}); | ||
@@ -133,9 +141,10 @@ | ||
if (err) { | ||
return next(err); | ||
next(err); | ||
return; | ||
} | ||
next(null, report); | ||
}); | ||
}); | ||
}); | ||
@@ -142,0 +151,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"description": "build front project", | ||
"version": "0.4.15", | ||
"version": "0.4.16", | ||
"repository": { | ||
@@ -24,3 +24,3 @@ "type": "git", | ||
"async": "~0.1.18", | ||
"less": "~1.3.0", | ||
"less": ">=1.3.0", | ||
"uglify-js": "~1.2.6", | ||
@@ -27,0 +27,0 @@ "iconv-lite": "~0.2.1", |
@@ -26,3 +26,3 @@ # Kissy Pie (ki) | ||
### 方式一: 通过 npm 安装 | ||
1. 首先安装或升级 Node.js ( 不小于 0.8.x) http://nodejs.org/ | ||
1. 首先安装或升级 Node.js ( >= 0.8.x) http://nodejs.org/ | ||
2. 命令行执行 `npm install kissy-pie -g` 安装 | ||
@@ -73,3 +73,3 @@ 3. done! | ||
- less.js http://lesscss.org | ||
- cssmin | ||
- clean-css | ||
- uglifyjs https://github.com/mishoo/UglifyJS | ||
@@ -76,0 +76,0 @@ - csslint http://csslint.net |
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ /* |
Sorry, the diff of this file is not supported yet
39260
1569211
227
+ Addedcopy-anything@2.0.6(transitive)
+ Addederrno@0.1.8(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedimage-size@0.5.5(transitive)
+ Addedis-what@3.14.1(transitive)
+ Addedless@4.2.2(transitive)
+ Addedmake-dir@2.1.0(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedneedle@3.3.1(transitive)
+ Addedparse-node-version@1.0.1(transitive)
+ Addedpify@4.0.1(transitive)
+ Addedprr@1.0.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsax@1.4.1(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedtslib@2.8.1(transitive)
- Removedless@1.3.3(transitive)
- Removedycssmin@1.0.1(transitive)
Updatedless@>=1.3.0