Comparing version 0.4.8 to 0.4.9
@@ -87,3 +87,2 @@ var _ = require('underscore'); | ||
/** | ||
@@ -215,4 +214,7 @@ * find the app rootDir by the fb.json file | ||
}, | ||
getCharset: function () { | ||
var self = this; | ||
return self.config.charset || 'utf8'; | ||
}, | ||
/** | ||
@@ -219,0 +221,0 @@ * update exist FB app |
@@ -17,4 +17,4 @@ var _ = require('underscore'); | ||
* cfg.version {String} where builded source goto. | ||
* cfg.inputCharset {String} charset of source code | ||
* cfg.outputCharset {String} build charset. | ||
* cfg.inputCharset {String} charset of source code, (optional) | ||
* cfg.outputCharset {String} build charset. (optional) | ||
*/ | ||
@@ -28,6 +28,3 @@ var Page = module.exports = function(cfg) { | ||
self.config = { | ||
inputCharset: 'utf8', | ||
outputCharset: 'utf8' | ||
}; | ||
self.config = {}; | ||
@@ -38,3 +35,2 @@ self._plugins = []; | ||
self.destDir = path.resolve(self.rootDir, Page.destDir); | ||
self.charset = 'utf8'; | ||
@@ -57,2 +53,7 @@ self._build_targets = {}; | ||
/** | ||
* parser page_version string to object | ||
* @param {string} page_version str of page/version | ||
* @return {Object} an obj with name and version | ||
*/ | ||
parsePageVersion: function (page_version) { | ||
@@ -86,17 +87,18 @@ var pvReg = /^(\w[\w\-~]*)[@/\\](\d+(\.\d+)+)[/\\]?$/; | ||
_.extend(Page.prototype, events.EventEmitter.prototype, { | ||
/** | ||
* add a vertion to the page | ||
* @param {string} version version in x.x.x or x.x | ||
* @param {Function} callback callback with an error or null | ||
*/ | ||
addVersion: function (version, callback) { | ||
var self = this; | ||
if (!self.rootDir) { | ||
console.error('不在Page文件夹内!') | ||
return callback(new Error('Page#addVersion: no page')); | ||
return callback(new Error('不在Page文件夹内!')); | ||
} | ||
if (!version) { | ||
console.error("必须指定一个version: fb version {version}") | ||
process.exit(3); | ||
return callback(new Error("必须指定一个版本")); | ||
} | ||
if (!/^(\d+\.)+\d+$/.test(version)) { | ||
console.error("version 格式错误。期望的格式是 1.0") | ||
return callback(new Error('version not illegal')); | ||
return callback(new Error('版本号格式错误。期望的格式是 x.x 或 x.x.x')); | ||
} | ||
@@ -138,3 +140,3 @@ | ||
if (!exist) { | ||
fu.writeJSON(jsonfile, self.config, callback); | ||
fu.writeJSON(jsonfile, {}, callback); | ||
return; | ||
@@ -148,3 +150,3 @@ } | ||
} | ||
self.config = _.defaults(pagejson, self.confg); | ||
self.config = _.defaults(pagejson, self.config); | ||
fu.writeJSON(jsonfile, self.config, callback); | ||
@@ -348,3 +350,2 @@ }); | ||
function (callback){ | ||
//准备工作 | ||
self._startBuild(callback); | ||
@@ -364,8 +365,24 @@ }, | ||
function (callback) { | ||
//扫尾工作 | ||
self._endBuild(callback); | ||
fu.iconv({ | ||
from: { | ||
path: self.destDir, | ||
charset: 'utf8' | ||
}, | ||
to: { | ||
path: self.timestampDir, | ||
charset: self.getOutputCharset() | ||
} | ||
}, | ||
callback | ||
); | ||
}, | ||
function (callback) { | ||
async.forEach([self.srcDir, self.destDir], fu.rmTree, callback); | ||
}, | ||
function (callback) { | ||
reports.fb = { | ||
@@ -458,9 +475,11 @@ build_version: self.version, | ||
var self = this; | ||
var page = { | ||
charset: self.charset, | ||
srcDir: self.srcDir, | ||
destDir: self.destDir, | ||
versionDir: self.versionDir, | ||
config: _.clone(self.config) | ||
config: _.clone(self.config), | ||
chareset: 'utf8' | ||
}; | ||
var prev = new Date(); | ||
@@ -557,7 +576,7 @@ | ||
path: path.join(self.versionDir, 'page'), | ||
charset: self.config.inputCharset | ||
charset: self.getInputCharset() | ||
}, | ||
to: { | ||
path: path.join( self.srcDir, 'page'), | ||
charset: self.charset | ||
charset: 'utf8' | ||
} | ||
@@ -573,7 +592,7 @@ }, callback); | ||
} | ||
console.log(app.getCharset()); | ||
fu.iconv({ | ||
from: { | ||
path: app.getUtilsDir(), | ||
charset: app.config.charset | ||
charset: app.getCharset() | ||
}, | ||
@@ -583,3 +602,3 @@ | ||
path: path.resolve(self.srcDir, 'utils'), | ||
charset: self.charset | ||
charset: 'utf8' | ||
} | ||
@@ -597,10 +616,12 @@ }, callback); | ||
_endBuild: function(callback) { | ||
getOutputCharset: function () { | ||
var self = this; | ||
// change charset to target charset and move to target | ||
fu.iconvDir(self.destDir, self.charset, self.timestampDir, self.config.outputCharset); | ||
// remove tempdir | ||
async.forEach([self.srcDir, self.destDir], fu.rmTree, callback); | ||
return self.config.outputCharset || self.app.config.charset || 'utf8'; | ||
}, | ||
getInputCharset: function () { | ||
var self = this; | ||
return self.config.inputCharset || self.app.config.charset || 'utf8'; | ||
}, | ||
_makeTempDir: function(dir_name, callback) { | ||
@@ -607,0 +628,0 @@ |
@@ -77,4 +77,4 @@ var CssCombo = require('css-combo'); | ||
target: path.resolve(srcBase, file), | ||
inputEncoding: page.charset, | ||
outputEncoding: page.charset, | ||
inputEncoding: page.chareset, | ||
outputEncoding: page.chareset, | ||
debug: config.debug, | ||
@@ -81,0 +81,0 @@ output: path.resolve(buildBase, file), |
@@ -36,3 +36,2 @@ | ||
"overqualified-elements": 1, | ||
// "import": 1, | ||
"regex-selectors": 1, | ||
@@ -39,0 +38,0 @@ "rules-count": 1, |
@@ -37,2 +37,3 @@ var ModuleComplier = require('module-compiler'); | ||
}); | ||
var srcBase = path.resolve(page.srcDir, config.base); | ||
@@ -42,3 +43,8 @@ var buildBase = path.resolve(page.destDir, config.base); | ||
var reporter = ModuleComplier.build(srcBase, buildBase); | ||
reporter.name = 'module-compiler'; | ||
if (reporter.files && reporter.files.length) { | ||
reporter.files.forEach(function (file) { | ||
delete file._moduleCache; | ||
}); | ||
} | ||
} catch (e) { | ||
@@ -45,0 +51,0 @@ return callback(e); |
@@ -5,3 +5,3 @@ { | ||
"description": "build front project", | ||
"version": "0.4.8", | ||
"version": "0.4.9", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -40,3 +40,2 @@ # Kissy Pie (ki) | ||
3. enjoy! | ||
4. | ||
@@ -43,0 +42,0 @@ ### 更新 Kissy Pie |
{ | ||
"charset": "gbk", | ||
"fbversion": "0.4.7", | ||
"fbversion": "0.4.8", | ||
"packages": { | ||
@@ -5,0 +5,0 @@ "common-lib": { |
KISSY.add(function(){ | ||
var a = 'page:index.js'; | ||
}, { | ||
requires: ['./mods/mod1','./mods/mod2'] | ||
requires: ['./mods/mod1','page/mods/mod2'] | ||
}); |
KISSY.add(function(){ | ||
var a = 'mods:mod1.js'; | ||
}, { | ||
requires: ['./submod1', '../mods/submod2', 'utils/sample/index']}); | ||
requires: [ | ||
'./submod1', | ||
'page/mods/submod2', | ||
'page/tpl/foo-tpl', | ||
'utils/sample/index' | ||
] | ||
}); |
{ | ||
"build_version": "1.0", | ||
"build_start_time": "2012-09-27T02:34:23.251Z", | ||
"build_start_time": "2012-10-22T06:52:40.322Z", | ||
"build_timestamp": "20120722", | ||
"build_used_time": 323 | ||
"build_used_time": 333 | ||
} |
@@ -20,5 +20,3 @@ /* | ||
url: url, | ||
data: data, | ||
cache: false, | ||
@@ -28,3 +26,2 @@ dataType: 'json', | ||
callback(null, data); | ||
} | ||
@@ -31,0 +28,0 @@ }); |
{ | ||
"build_version": "1.0", | ||
"build_start_time": "2012-09-27T02:34:23.251Z", | ||
"build_start_time": "2012-10-22T06:52:40.323Z", | ||
"build_timestamp": "20120722", | ||
"build_used_time": 330 | ||
"build_used_time": 333 | ||
} |
@@ -25,2 +25,2 @@ KISSY.add(function (S, pageBuilder, Calendar, Reporter) { | ||
requires: ['utils/build-page', 'utils/calendar-init', './mods/reporter', './mods/timestamp'] | ||
}); | ||
}); |
@@ -1,2 +0,11 @@ | ||
KISSY.add(function (S, Template, fb_tpl, wrap_tpl, error_wrap_tpl, plugin_tpl, csslint_tpl, files_tpl, concat_tpl, css_combo_tpl) { | ||
KISSY.add(function (S, Template, | ||
fb_tpl, | ||
wrap_tpl, | ||
error_wrap_tpl, | ||
plugin_tpl, | ||
csslint_tpl, | ||
files_tpl, | ||
concat_tpl, | ||
css_combo_tpl, | ||
module_compiler_tpl) { | ||
var $ = S.all; | ||
@@ -26,3 +35,3 @@ | ||
} | ||
}) | ||
}); | ||
}, | ||
@@ -74,3 +83,4 @@ | ||
'lesscss': 'files_tpl', | ||
'css-combo': 'css_combo_tpl' | ||
'css-combo': 'css_combo_tpl', | ||
'module-compiler': 'module_compiler_tpl' | ||
}, | ||
@@ -93,2 +103,3 @@ | ||
case 'lesscss': | ||
case 'module-compiler': | ||
report.count = report.files.length; | ||
@@ -138,3 +149,4 @@ break; | ||
'concat_tpl': Template(concat_tpl.html), | ||
'css_combo_tpl': Template(css_combo_tpl.html) | ||
'css_combo_tpl': Template(css_combo_tpl.html), | ||
'module_compiler_tpl': Template(module_compiler_tpl.html) | ||
}); | ||
@@ -145,12 +157,13 @@ return Reporter; | ||
'template', | ||
'page/template/report-fb-tpl', | ||
'page/template/report-wrap-tpl', | ||
'page/template/report-error-wrap-tpl', | ||
'page/template/report-plugin-tpl', | ||
'page/template/report-csslint-tpl', | ||
'page/template/report-files-tpl', | ||
'page/template/report-concat-tpl', | ||
'page/template/report-css-combo-tpl' | ||
'../template/report-fb-tpl', | ||
'../template/report-wrap-tpl', | ||
'../template/report-error-wrap-tpl', | ||
'../template/report-plugin-tpl', | ||
'../template/report-csslint-tpl', | ||
'../template/report-files-tpl', | ||
'../template/report-concat-tpl', | ||
'../template/report-css-combo-tpl', | ||
'../template/report-module-compiler-tpl' | ||
] | ||
}); |
KISSY.add(function(){ | ||
return {"html":"<h4>处理文件列表:</h4>\r\n{{#if !jobs.length}}\r\n <div>\r\n 没有文件\r\n </div>\r\n{{#else}}\r\n <ul >\r\n {{#each jobs as job}}\r\n <li>\r\n <h4><i class=\"icon-file\"></i> {{job.filename}} </h4>\r\n <ul class=\"plugin-file-list\">\r\n {{#each job.imports as file}}\r\n <li>\r\n <i class=\"icon-bookmark\"></i> \r\n {{file}}\r\n </li>\r\n {{/each}}\r\n </ul>\r\n </li>\r\n {{/each}}\r\n </ul>\r\n{{/if}}\r\n"}; | ||
return {"html":"<h4>处理文件列表:</h4>\r\n{{#if !jobs.length}}\r\n <div>\r\n 没有文件\r\n </div>\r\n{{#else}}\r\n <ul class=\"plugin-file-list\">\r\n {{#each jobs as job}}\r\n <li>\r\n <h5><i class=\"icon-file\"></i> {{job.filename}} </h5>\r\n <ul class=\"plugin-file-list\">\r\n {{#each job.imports as file}}\r\n <li>\r\n <i class=\"icon-bookmark\"></i> \r\n {{file}}\r\n </li>\r\n {{/each}}\r\n </ul>\r\n </li>\r\n {{/each}}\r\n </ul>\r\n{{/if}}\r\n"}; | ||
}); |
KISSY.add(function(){ | ||
return {"html":"<div class=\"csslint-list\">\n {{#if lintReport&&lintReport.length}}\n {{#each lintReport as item}}\n <div class='csslint-list-item'>\n <h4 class='csslint-file'>{{item.file}}</h4>\n <p>{{item.fullpath}}</p>\n <pre>{{item.output}}</pre>\n </div>\n {{/each}}\n {{#else}}\n 没有CSS文件\n {{/if}}\n</div>\n"}; | ||
return {"html":"<div class=\"csslint-list\">\n {{#if lintReport&&lintReport.length}}\n {{#each lintReport as item}}\n <div class='csslint-list-item'>\n <h4 class='csslint-file'>{{item.file}}</h4>\n <!-- <p>{{item.fullpath}}</p> -->\n <pre>{{item.output}}</pre>\n </div>\n {{/each}}\n {{#else}}\n 没有CSS文件\n {{/if}}\n</div>\n"}; | ||
}); |
KISSY.add(function(){ | ||
return {"html":"<div class=\"report-plugin-item\">\n <div class=\"report-plugin-item-hd{{#if content}} report-plugin-hd-has-content{{/if}}\">\n <h4>{{name}} \n {{#if typeof report.count === 'number'}}\n <span class='plugin-bdg'>\n <span class=\"badge\">{{report.count}}</span>\n </span>\n {{/if}}\n {{#if typeof report.warningCount === 'number' && report.warningCount > 0}}\n <span class='plugin-bdg'>\n <span class=\"badge badge-warning\">{{report.warningCount}}</span>\n </span>\n {{/if}}\n {{#if typeof report.errorCount === 'number' && report.errorCount > 0}}\n <span class='plugin-bdg'>\n <span class=\"badge badge-important\">{{report.errorCount}}</span>\n </span>\n {{/if}}\n </h4>\n </div>\n {{#if content}}\n <div class='report-plugin-item-bd'>{{content}}</div>\n {{/if}}\n <div class=\"report-plugin-item-ft\">\n <ul>\n <li class='used-time'><i class='icon-time'></i> {{report.used_time}} ms\n </li>\n </ul>\n </div>\n</div>"}; | ||
return {"html":"<div class=\"report-plugin-item\">\n <div class=\"report-plugin-item-hd{{#if content}} report-plugin-hd-has-content{{/if}}\">\n <h4>{{name}} \n {{#if typeof report.count === 'number'}}\n <span class='plugin-bdg'>\n <span title='Execed' class=\"badge\">{{report.count}}</span>\n </span>\n {{/if}}\n {{#if typeof report.warningCount === 'number' && report.warningCount > 0}}\n <span class='plugin-bdg'>\n <span title='Warning' class=\"badge badge-warning\">{{report.warningCount}}</span>\n </span>\n {{/if}}\n {{#if typeof report.errorCount === 'number' && report.errorCount > 0}}\n <span class='plugin-bdg'>\n <span title='Error' class=\"badge badge-important\">{{report.errorCount}}</span>\n </span>\n {{/if}}\n </h4>\n </div>\n {{#if content}}\n <div class='report-plugin-item-bd'>{{content}}</div>\n {{/if}}\n <div class=\"report-plugin-item-ft\">\n <ul>\n <li class='used-time'><i class='icon-time'></i> {{report.used_time}} ms\n </li>\n </ul>\n </div>\n</div>"}; | ||
}); |
{ | ||
"build_version": "1.0", | ||
"build_start_time": "2012-09-27T02:34:23.252Z", | ||
"build_start_time": "2012-10-22T06:52:40.323Z", | ||
"build_timestamp": "20120722", | ||
"build_used_time": 330 | ||
"build_used_time": 337 | ||
} |
@@ -1,1 +0,1 @@ | ||
KISSY.add("utils/build-page",function(a){function c(b,c,d){a.ajax({url:b,data:c,cache:!1,dataType:"json",success:function(a){d(null,a)}})}function d(){var d=this;b("body").delegate("click",".fb-build-page",function(e){e.preventDefault();var f=b(e.target),g=f.parent(".buildto-block"),h=f.attr("data-group-build"),i=g.one(".status"),j=g.one("input");i.html("building...");var k=[],l=j.val();h?(b("input.j-version-checkbox").each(function(a){a.prop("checked")&&a.val()&&k.push(a.val())}),d.fire("group-build",{pages:k,timestamp:l}),c(f.attr("href"),{timestamp:l,pages:k.join(",")},function(b,c){if(b)return a.error(b);if(c.err){var b=c.err;i.html("Error:"+b.message),d.fire("error",{error:c.err});return}i.html("success!"),setTimeout(function(){i.html("")},2e3)})):(c(f.attr("href"),{timestamp:l},function(b,c){if(b)return a.error(b);if(c.err){var b=c.err;i.html("Error:"+b.message),d.fire("error",{error:c.err});return}i.html("success!"),setTimeout(function(){i.html("")},2e3),c.reports&&d.fire("report",{reports:c.reports})}),f.attr("data-page")&&k.push(f.attr("data-page")))})}var b=a.all;return a.extend(d,a.Base),new d}),KISSY.add("utils/calendar-init",function(a,b,c){var d=a.all;return{init:function(e){function g(a){var b=d(a.target);if(f.get("el").contains(b))return;if(b.attr("data-cal-trigger"))return;if(b.parent(".ks-cal-box"))return;f.hide()}d(e.triggers).attr("data-cal-trigger","1");var f=new c.Popup({width:192});f.render(),f.on("hide",function(){d(document.body).detach("click",g)}).on("show",function(){d(document.body).on("click",g)});var h=new b(f.get("contentEl"));h.on("select",function(b){this.targetInput&&d(this.targetInput).val(a.Date.format(b.date,"yyyymmdd")),f.hide()}),d(e.triggers).on("click",function(b){f.show();var c=d(b.target);f.align(c,["bl","tl"]),h.targetInput=c;var e=c.val();if(e){var g=e.match(/^(\d{2,4})(\d\d)(\d\d)$/);console.log(g);var i=a.Date.parse(g.slice(1).join("-"));h.render({date:i,selected:i})}})}}},{requires:["calendar","overlay","calendar/assets/base.css"]}),KISSY.add("page/mods/reporter",function(a,b,c,d,e,f,g,h,i,j){var k=a.all,l=function(b){var c=this;c.$el=k(b);if(!c.$el||!c.$el.length)throw new Error("container is not found");a.ready(function(){c.init()})};return a.extend(l,a.Base,{init:function(){var a=this;k("body").delegate("click",".report-plugin-item-hd",function(a){var b=k(a.currentTarget).siblings(".report-plugin-item-bd");b&&b.toggle()})},addError:function(a){var b=this,c=l.error_wrap_tpl.render(a);b.appendReportEl(k(c))},addReport:function(b){var c=this,d={};a.each(b,function(a,b){c.renderer[b]&&a&&(d[b]=c.renderer[b].call(c,a))});var e=l.wrap_tpl.render(d);c.appendReportEl(k(e))},appendReportEl:function(a){var b=this,c=b.$el.all(".report");c.length>0?a.insertBefore(c[0]):a.appendTo(b.$el),a.slideDown(.2)},pluginRenderer:{csslint:"csslint_tpl","kissy-template":"files_tpl",uglifyjs:"files_tpl",cssmin:"files_tpl",concat:"concat_tpl",lesscss:"files_tpl","css-combo":"css_combo_tpl"},parserPluginReports:function(b){return a.map(b,function(a){switch(a.name){case"csslint":a.count=a.lintReport.length;break;case"concat":case"css-combo":a.count=a.jobs.length;break;case"cssmin":case"uglifyjs":case"kissy-template":case"lesscss":a.count=a.files.length}return a})},renderer:{fb:function(a){return l.fb_tpl.render(a)},plugins:function(b){var c=this,d=[];return b=c.parserPluginReports(b),a.each(b,function(a){var b=a.name,e=c.pluginRenderer[b]||null;e&&(e=l[e]);var f=e?e.render(a):"";d.push(l.plugin_tpl.render({name:b,report:a,content:f}))}),d.join("")}}},{fb_tpl:b(c.html),plugin_tpl:b(f.html),wrap_tpl:b(d.html),error_wrap_tpl:b(e.html),csslint_tpl:b(g.html),files_tpl:b(h.html),concat_tpl:b(i.html),css_combo_tpl:b(j.html)}),l},{requires:["template","page/template/report-fb-tpl","page/template/report-wrap-tpl","page/template/report-error-wrap-tpl","page/template/report-plugin-tpl","page/template/report-csslint-tpl","page/template/report-files-tpl","page/template/report-concat-tpl","page/template/report-css-combo-tpl"]}),KISSY.add("page/mods/timestamp",function(a){var b=a.all;a.ready(function(){b("body").delegate("click",".build-timestamp",function(a){var c=b(a.target),d=b(".timestamp-input"),e=c.clone(!0),f=c.offset(),g=d.offset();e.appendTo("body"),e.css("position","absolute").css("left",f.left).css("top",f.top).show().animate({left:g.left,top:g.top},.2,"easeNone",function(){d.val(c.html()),setTimeout(function(){e.remove()},0)})})})}),KISSY.add("page/index",function(a,b,c,d){var e=a.all;a.ready(function(){var a=new d("#reports");b.on("report",function(b){a.addReport(b.reports)}),b.on("error",function(b){a.addError(b.error)}),c.init({triggers:"input.timestamp-input"})})},{requires:["utils/build-page","utils/calendar-init","./mods/reporter","./mods/timestamp"]}); | ||
KISSY.add("utils/build-page",function(a){function c(b,c,d){a.ajax({url:b,data:c,cache:!1,dataType:"json",success:function(a){d(null,a)}})}function d(){var d=this;b("body").delegate("click",".fb-build-page",function(e){e.preventDefault();var f=b(e.target),g=f.parent(".buildto-block"),h=f.attr("data-group-build"),i=g.one(".status"),j=g.one("input");i.html("building...");var k=[],l=j.val();h?(b("input.j-version-checkbox").each(function(a){a.prop("checked")&&a.val()&&k.push(a.val())}),d.fire("group-build",{pages:k,timestamp:l}),c(f.attr("href"),{timestamp:l,pages:k.join(",")},function(b,c){if(b)return a.error(b);if(c.err){var b=c.err;i.html("Error:"+b.message),d.fire("error",{error:c.err});return}i.html("success!"),setTimeout(function(){i.html("")},2e3)})):(c(f.attr("href"),{timestamp:l},function(b,c){if(b)return a.error(b);if(c.err){var b=c.err;i.html("Error:"+b.message),d.fire("error",{error:c.err});return}i.html("success!"),setTimeout(function(){i.html("")},2e3),c.reports&&d.fire("report",{reports:c.reports})}),f.attr("data-page")&&k.push(f.attr("data-page")))})}var b=a.all;return a.extend(d,a.Base),new d}),KISSY.add("utils/calendar-init",function(a,b,c){var d=a.all;return{init:function(e){function g(a){var b=d(a.target);if(f.get("el").contains(b))return;if(b.attr("data-cal-trigger"))return;if(b.parent(".ks-cal-box"))return;f.hide()}d(e.triggers).attr("data-cal-trigger","1");var f=new c.Popup({width:192});f.render(),f.on("hide",function(){d(document.body).detach("click",g)}).on("show",function(){d(document.body).on("click",g)});var h=new b(f.get("contentEl"));h.on("select",function(b){this.targetInput&&d(this.targetInput).val(a.Date.format(b.date,"yyyymmdd")),f.hide()}),d(e.triggers).on("click",function(b){f.show();var c=d(b.target);f.align(c,["bl","tl"]),h.targetInput=c;var e=c.val();if(e){var g=e.match(/^(\d{2,4})(\d\d)(\d\d)$/);console.log(g);var i=a.Date.parse(g.slice(1).join("-"));h.render({date:i,selected:i})}})}}},{requires:["calendar","overlay","calendar/assets/base.css"]}),KISSY.add("page/mods/reporter",function(a,b,c,d,e,f,g,h,i,j,k){var l=a.all,m=function(b){var c=this;c.$el=l(b);if(!c.$el||!c.$el.length)throw new Error("container is not found");a.ready(function(){c.init()})};return a.extend(m,a.Base,{init:function(){var a=this;l("body").delegate("click",".report-plugin-item-hd",function(a){var b=l(a.currentTarget).siblings(".report-plugin-item-bd");b&&b.toggle()})},addError:function(a){var b=this,c=m.error_wrap_tpl.render(a);b.appendReportEl(l(c))},addReport:function(b){var c=this,d={};a.each(b,function(a,b){c.renderer[b]&&a&&(d[b]=c.renderer[b].call(c,a))});var e=m.wrap_tpl.render(d);c.appendReportEl(l(e))},appendReportEl:function(a){var b=this,c=b.$el.all(".report");c.length>0?a.insertBefore(c[0]):a.appendTo(b.$el),a.slideDown(.2)},pluginRenderer:{csslint:"csslint_tpl","kissy-template":"files_tpl",uglifyjs:"files_tpl",cssmin:"files_tpl",concat:"concat_tpl",lesscss:"files_tpl","css-combo":"css_combo_tpl","module-compiler":"module_compiler_tpl"},parserPluginReports:function(b){return a.map(b,function(a){switch(a.name){case"csslint":a.count=a.lintReport.length;break;case"concat":case"css-combo":a.count=a.jobs.length;break;case"cssmin":case"uglifyjs":case"kissy-template":case"lesscss":case"module-compiler":a.count=a.files.length}return a})},renderer:{fb:function(a){return m.fb_tpl.render(a)},plugins:function(b){var c=this,d=[];return b=c.parserPluginReports(b),a.each(b,function(a){var b=a.name,e=c.pluginRenderer[b]||null;e&&(e=m[e]);var f=e?e.render(a):"";d.push(m.plugin_tpl.render({name:b,report:a,content:f}))}),d.join("")}}},{fb_tpl:b(c.html),plugin_tpl:b(f.html),wrap_tpl:b(d.html),error_wrap_tpl:b(e.html),csslint_tpl:b(g.html),files_tpl:b(h.html),concat_tpl:b(i.html),css_combo_tpl:b(j.html),module_compiler_tpl:b(k.html)}),m},{requires:["template","../template/report-fb-tpl","../template/report-wrap-tpl","../template/report-error-wrap-tpl","../template/report-plugin-tpl","../template/report-csslint-tpl","../template/report-files-tpl","../template/report-concat-tpl","../template/report-css-combo-tpl","../template/report-module-compiler-tpl"]}),KISSY.add("page/template/report-fb-tpl",function(){return{html:'<div class="report-fb">\n <span class="number">\n {{build_version}}\n </span>\n <b class=\'block\'></b><b class=\'triangle\'></b>\n <span class="number">\n {{build_timestamp}}\n </span>\n <span class="number used-time">\n {{build_used_time}}ms\n </span>\n</div>'}}),KISSY.add("page/template/report-wrap-tpl",function(){return{html:'<div class="report" style=\'display:none\'>\n <div class="report-hd">{{fb}}</div>\n <div class="report-bd">{{plugins}}</div>\n</div>'}}),KISSY.add("page/template/report-error-wrap-tpl",function(){return{html:'<div class="report" style=\'display:none\'>\n <div class="report-bd">\n <div class="alert alert-error">\n <h2> {{message}} </h2>\n <h4>error</h4>\n <pre>{{text}}</pre>\n <h4>stack</h4>\n <pre>{{stack}}</pre>\n </div>\n </div>\n</div>'}}),KISSY.add("page/template/report-plugin-tpl",function(){return{html:"<div class=\"report-plugin-item\">\n <div class=\"report-plugin-item-hd{{#if content}} report-plugin-hd-has-content{{/if}}\">\n <h4>{{name}} \n {{#if typeof report.count === 'number'}}\n <span class='plugin-bdg'>\n <span title='Execed' class=\"badge\">{{report.count}}</span>\n </span>\n {{/if}}\n {{#if typeof report.warningCount === 'number' && report.warningCount > 0}}\n <span class='plugin-bdg'>\n <span title='Warning' class=\"badge badge-warning\">{{report.warningCount}}</span>\n </span>\n {{/if}}\n {{#if typeof report.errorCount === 'number' && report.errorCount > 0}}\n <span class='plugin-bdg'>\n <span title='Error' class=\"badge badge-important\">{{report.errorCount}}</span>\n </span>\n {{/if}}\n </h4>\n </div>\n {{#if content}}\n <div class='report-plugin-item-bd'>{{content}}</div>\n {{/if}}\n <div class=\"report-plugin-item-ft\">\n <ul>\n <li class='used-time'><i class='icon-time'></i> {{report.used_time}} ms\n </li>\n </ul>\n </div>\n</div>"}}),KISSY.add("page/template/report-csslint-tpl",function(){return{html:"<div class=\"csslint-list\">\n {{#if lintReport&&lintReport.length}}\n {{#each lintReport as item}}\n <div class='csslint-list-item'>\n <h4 class='csslint-file'>{{item.file}}</h4>\n <!-- <p>{{item.fullpath}}</p> -->\n <pre>{{item.output}}</pre>\n </div>\n {{/each}}\n {{#else}}\n \u6ca1\u6709CSS\u6587\u4ef6\n {{/if}}\n</div>\n"}}),KISSY.add("page/template/report-files-tpl",function(){return{html:'<h4>\u5904\u7406\u6587\u4ef6\u5217\u8868:</h4>\n{{#if !files.length}}\n <div>\n \u6ca1\u6709\u6587\u4ef6\n </div>\n{{#else}}\n <ul class="plugin-file-list">\n {{#each files as file}}\n <li>\n <i class="icon-file"></i> {{file}}\n </li>\n {{/each}}\n </ul>\n{{/if}}\n'}}),KISSY.add("page/template/report-concat-tpl",function(){return{html:'<h4>\u5904\u7406\u6587\u4ef6\u5217\u8868:</h4>\r\n{{#if !jobs.length}}\r\n <div>\r\n \u6ca1\u6709\u6587\u4ef6\r\n </div>\r\n{{#else}}\r\n <ul >\r\n {{#each jobs as job}}\r\n <li>\r\n <h4><i class="icon-file"></i> {{job.filename}}</h4>\r\n <ul class="plugin-file-list">\r\n {{#each job.files as file}}\r\n <li title=\'{{file.path}}\'>{{file.filename}}</li>\r\n {{/each}}\r\n </ul>\r\n </li>\r\n {{/each}}\r\n </ul>\r\n{{/if}}\r\n'}}),KISSY.add("page/template/report-css-combo-tpl",function(){return{html:'<h4>\u5904\u7406\u6587\u4ef6\u5217\u8868:</h4>\r\n{{#if !jobs.length}}\r\n <div>\r\n \u6ca1\u6709\u6587\u4ef6\r\n </div>\r\n{{#else}}\r\n <ul class="plugin-file-list">\r\n {{#each jobs as job}}\r\n <li>\r\n <h5><i class="icon-file"></i> {{job.filename}} </h5>\r\n <ul class="plugin-file-list">\r\n {{#each job.imports as file}}\r\n <li>\r\n <i class="icon-bookmark"></i> \r\n {{file}}\r\n </li>\r\n {{/each}}\r\n </ul>\r\n </li>\r\n {{/each}}\r\n </ul>\r\n{{/if}}\r\n'}}),KISSY.add("page/template/report-module-compiler-tpl",function(){return{html:"<h4>Module Compiler:</h4>\n{{#if !files.length}}\n <div>\n \u6ca1\u6709\u627e\u5230Kissy\u6a21\u5757\n </div>\n{{#else}}\n <ul class=\"plugin-file-list\">\n {{#each files as file}}\n <li>\n <h5 class=\"ks-module status-{{file.status}}\">\n <strong title='{{file.path}}'>{{file.name}}</strong>\n <span>{{file.status}}</span>\n {{#if file.status !== 'ok'}}\n <span class=\"status\">[{{file.status}}]</span>\n {{/if}}\n </h5>\n {{#if file.submods.length}}\n <ul class=\"submods\">\n {{#each file.submods as mod}}\n <li class='status-{{mod.status}}'>\n <strong title='{{mod.path}}'>{{mod.name}}</strong>\n {{#if mod.status !== 'ok'}}\n <span class=\"status\">[{{mod.status}}]</span>\n {{/if}}\n </li>\n {{/each}}\n </ul>\n {{#else}}\n \n {{/if}}\n </li>\n {{/each}}\n </ul>\n{{/if}}"}}),KISSY.add("page/mods/timestamp",function(a){var b=a.all;a.ready(function(){b("body").delegate("click",".build-timestamp",function(a){var c=b(a.target),d=b(".timestamp-input"),e=c.clone(!0),f=c.offset(),g=d.offset();e.appendTo("body"),e.css("position","absolute").css("left",f.left).css("top",f.top).show().animate({left:g.left,top:g.top},.2,"easeNone",function(){d.val(c.html()),setTimeout(function(){e.remove()},0)})})})}),KISSY.add("page/index",function(a,b,c,d){var e=a.all;a.ready(function(){var a=new d("#reports");b.on("report",function(b){a.addReport(b.reports)}),b.on("error",function(b){a.addError(b.error)}),c.init({triggers:"input.timestamp-input"})})},{requires:["utils/build-page","utils/calendar-init","./mods/reporter","./mods/timestamp"]}); |
@@ -7,2 +7,11 @@ /* | ||
page/mods/reporter | ||
page/template/report-fb-tpl | ||
page/template/report-wrap-tpl | ||
page/template/report-error-wrap-tpl | ||
page/template/report-plugin-tpl | ||
page/template/report-csslint-tpl | ||
page/template/report-files-tpl | ||
page/template/report-concat-tpl | ||
page/template/report-css-combo-tpl | ||
page/template/report-module-compiler-tpl | ||
page/mods/timestamp | ||
@@ -19,5 +28,3 @@ page/index | ||
url: url, | ||
data: data, | ||
cache: false, | ||
@@ -27,3 +34,2 @@ dataType: 'json', | ||
callback(null, data); | ||
} | ||
@@ -209,3 +215,12 @@ }); | ||
}); | ||
KISSY.add('page/mods/reporter',function (S, Template, fb_tpl, wrap_tpl, error_wrap_tpl, plugin_tpl, csslint_tpl, files_tpl, concat_tpl, css_combo_tpl) { | ||
KISSY.add('page/mods/reporter',function (S, Template, | ||
fb_tpl, | ||
wrap_tpl, | ||
error_wrap_tpl, | ||
plugin_tpl, | ||
csslint_tpl, | ||
files_tpl, | ||
concat_tpl, | ||
css_combo_tpl, | ||
module_compiler_tpl) { | ||
var $ = S.all; | ||
@@ -235,3 +250,3 @@ | ||
} | ||
}) | ||
}); | ||
}, | ||
@@ -283,3 +298,4 @@ | ||
'lesscss': 'files_tpl', | ||
'css-combo': 'css_combo_tpl' | ||
'css-combo': 'css_combo_tpl', | ||
'module-compiler': 'module_compiler_tpl' | ||
}, | ||
@@ -302,2 +318,3 @@ | ||
case 'lesscss': | ||
case 'module-compiler': | ||
report.count = report.files.length; | ||
@@ -347,3 +364,4 @@ break; | ||
'concat_tpl': Template(concat_tpl.html), | ||
'css_combo_tpl': Template(css_combo_tpl.html) | ||
'css_combo_tpl': Template(css_combo_tpl.html), | ||
'module_compiler_tpl': Template(module_compiler_tpl.html) | ||
}); | ||
@@ -354,13 +372,41 @@ return Reporter; | ||
'template', | ||
'page/template/report-fb-tpl', | ||
'page/template/report-wrap-tpl', | ||
'page/template/report-error-wrap-tpl', | ||
'page/template/report-plugin-tpl', | ||
'page/template/report-csslint-tpl', | ||
'page/template/report-files-tpl', | ||
'page/template/report-concat-tpl', | ||
'page/template/report-css-combo-tpl' | ||
'../template/report-fb-tpl', | ||
'../template/report-wrap-tpl', | ||
'../template/report-error-wrap-tpl', | ||
'../template/report-plugin-tpl', | ||
'../template/report-csslint-tpl', | ||
'../template/report-files-tpl', | ||
'../template/report-concat-tpl', | ||
'../template/report-css-combo-tpl', | ||
'../template/report-module-compiler-tpl' | ||
] | ||
}); | ||
KISSY.add('page/template/report-fb-tpl',function(){ | ||
return {"html":"<div class=\"report-fb\">\n <span class=\"number\">\n {{build_version}}\n </span>\n <b class='block'></b><b class='triangle'></b>\n <span class=\"number\">\n {{build_timestamp}}\n </span>\n <span class=\"number used-time\">\n {{build_used_time}}ms\n </span>\n</div>"}; | ||
}); | ||
KISSY.add('page/template/report-wrap-tpl',function(){ | ||
return {"html":"<div class=\"report\" style='display:none'>\n <div class=\"report-hd\">{{fb}}</div>\n <div class=\"report-bd\">{{plugins}}</div>\n</div>"}; | ||
}); | ||
KISSY.add('page/template/report-error-wrap-tpl',function(){ | ||
return {"html":"<div class=\"report\" style='display:none'>\n <div class=\"report-bd\">\n <div class=\"alert alert-error\">\n <h2> {{message}} </h2>\n <h4>error</h4>\n <pre>{{text}}</pre>\n <h4>stack</h4>\n <pre>{{stack}}</pre>\n </div>\n </div>\n</div>"}; | ||
}); | ||
KISSY.add('page/template/report-plugin-tpl',function(){ | ||
return {"html":"<div class=\"report-plugin-item\">\n <div class=\"report-plugin-item-hd{{#if content}} report-plugin-hd-has-content{{/if}}\">\n <h4>{{name}} \n {{#if typeof report.count === 'number'}}\n <span class='plugin-bdg'>\n <span title='Execed' class=\"badge\">{{report.count}}</span>\n </span>\n {{/if}}\n {{#if typeof report.warningCount === 'number' && report.warningCount > 0}}\n <span class='plugin-bdg'>\n <span title='Warning' class=\"badge badge-warning\">{{report.warningCount}}</span>\n </span>\n {{/if}}\n {{#if typeof report.errorCount === 'number' && report.errorCount > 0}}\n <span class='plugin-bdg'>\n <span title='Error' class=\"badge badge-important\">{{report.errorCount}}</span>\n </span>\n {{/if}}\n </h4>\n </div>\n {{#if content}}\n <div class='report-plugin-item-bd'>{{content}}</div>\n {{/if}}\n <div class=\"report-plugin-item-ft\">\n <ul>\n <li class='used-time'><i class='icon-time'></i> {{report.used_time}} ms\n </li>\n </ul>\n </div>\n</div>"}; | ||
}); | ||
KISSY.add('page/template/report-csslint-tpl',function(){ | ||
return {"html":"<div class=\"csslint-list\">\n {{#if lintReport&&lintReport.length}}\n {{#each lintReport as item}}\n <div class='csslint-list-item'>\n <h4 class='csslint-file'>{{item.file}}</h4>\n <!-- <p>{{item.fullpath}}</p> -->\n <pre>{{item.output}}</pre>\n </div>\n {{/each}}\n {{#else}}\n 没有CSS文件\n {{/if}}\n</div>\n"}; | ||
}); | ||
KISSY.add('page/template/report-files-tpl',function(){ | ||
return {"html":"<h4>处理文件列表:</h4>\n{{#if !files.length}}\n <div>\n 没有文件\n </div>\n{{#else}}\n <ul class=\"plugin-file-list\">\n {{#each files as file}}\n <li>\n <i class=\"icon-file\"></i> {{file}}\n </li>\n {{/each}}\n </ul>\n{{/if}}\n"}; | ||
}); | ||
KISSY.add('page/template/report-concat-tpl',function(){ | ||
return {"html":"<h4>处理文件列表:</h4>\r\n{{#if !jobs.length}}\r\n <div>\r\n 没有文件\r\n </div>\r\n{{#else}}\r\n <ul >\r\n {{#each jobs as job}}\r\n <li>\r\n <h4><i class=\"icon-file\"></i> {{job.filename}}</h4>\r\n <ul class=\"plugin-file-list\">\r\n {{#each job.files as file}}\r\n <li title='{{file.path}}'>{{file.filename}}</li>\r\n {{/each}}\r\n </ul>\r\n </li>\r\n {{/each}}\r\n </ul>\r\n{{/if}}\r\n"}; | ||
}); | ||
KISSY.add('page/template/report-css-combo-tpl',function(){ | ||
return {"html":"<h4>处理文件列表:</h4>\r\n{{#if !jobs.length}}\r\n <div>\r\n 没有文件\r\n </div>\r\n{{#else}}\r\n <ul class=\"plugin-file-list\">\r\n {{#each jobs as job}}\r\n <li>\r\n <h5><i class=\"icon-file\"></i> {{job.filename}} </h5>\r\n <ul class=\"plugin-file-list\">\r\n {{#each job.imports as file}}\r\n <li>\r\n <i class=\"icon-bookmark\"></i> \r\n {{file}}\r\n </li>\r\n {{/each}}\r\n </ul>\r\n </li>\r\n {{/each}}\r\n </ul>\r\n{{/if}}\r\n"}; | ||
}); | ||
KISSY.add('page/template/report-module-compiler-tpl',function(){ | ||
return {"html":"<h4>Module Compiler:</h4>\n{{#if !files.length}}\n <div>\n 没有找到Kissy模块\n </div>\n{{#else}}\n <ul class=\"plugin-file-list\">\n {{#each files as file}}\n <li>\n <h5 class=\"ks-module status-{{file.status}}\">\n <strong title='{{file.path}}'>{{file.name}}</strong>\n <span>{{file.status}}</span>\n {{#if file.status !== 'ok'}}\n <span class=\"status\">[{{file.status}}]</span>\n {{/if}}\n </h5>\n {{#if file.submods.length}}\n <ul class=\"submods\">\n {{#each file.submods as mod}}\n <li class='status-{{mod.status}}'>\n <strong title='{{mod.path}}'>{{mod.name}}</strong>\n {{#if mod.status !== 'ok'}}\n <span class=\"status\">[{{mod.status}}]</span>\n {{/if}}\n </li>\n {{/each}}\n </ul>\n {{#else}}\n \n {{/if}}\n </li>\n {{/each}}\n </ul>\n{{/if}}"}; | ||
}); | ||
KISSY.add('page/mods/timestamp',function (S) { | ||
@@ -420,1 +466,2 @@ | ||
}); | ||
@@ -8,5 +8,3 @@ KISSY.add(function (S) { | ||
url: url, | ||
data: data, | ||
cache: false, | ||
@@ -16,3 +14,2 @@ dataType: 'json', | ||
callback(null, data); | ||
} | ||
@@ -19,0 +16,0 @@ }); |
@@ -155,2 +155,3 @@ var Page = require('../lib/page'); | ||
fu.rmTreeSync(path.resolve(rootDir, timestamp)); | ||
fs.unlinkSync(path.resolve(rootDir, version, 'page/tpl/foo-tpl.js')) | ||
done(); | ||
@@ -228,2 +229,4 @@ }); | ||
data.should.include("KISSY.add('page/mods/submod2',"); | ||
data.should.include("KISSY.add('page/tpl/foo-tpl',"); | ||
data.should.include("KISSY.add('utils/sample/index',"); | ||
//utils | ||
@@ -534,4 +537,2 @@ data.should.include("utils-sample-index.js"); | ||
json.should.be.a('object'); | ||
should.exist(json.outputCharset); | ||
should.exist(json.inputCharset); | ||
done(null); | ||
@@ -538,0 +539,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1278636
210
30671
169