├── app ├── USAGE ├── templates │ └── 1.4.8 │ │ ├── totoro-config.json │ │ ├── src │ │ ├── article │ │ │ ├── article-view.xtpl │ │ │ ├── article.less │ │ │ ├── article.js │ │ │ └── article-view.js │ │ ├── header │ │ │ ├── header.less │ │ │ └── header.js │ │ ├── index.less │ │ ├── index.js │ │ └── index.css │ │ ├── _.gitignore │ │ ├── bower.json │ │ ├── test │ │ ├── runner.js │ │ ├── spec │ │ │ └── index-spec.js │ │ └── runner.html │ │ ├── build │ │ ├── index-min.css │ │ ├── header │ │ │ ├── header-min.js │ │ │ └── header.js │ │ ├── index-min.js │ │ ├── article │ │ │ ├── article-min.js │ │ │ ├── article.js │ │ │ ├── article-view-min.js │ │ │ └── article-view.js │ │ ├── index.js │ │ └── index.css │ │ ├── _package.json │ │ ├── demo │ │ ├── online_index.html │ │ └── dev_index.html │ │ ├── README.md │ │ └── gulpfile.js └── index.js ├── def ├── templates │ └── 1.4.8 │ │ ├── abc.json │ │ ├── demo │ │ ├── online_index.html │ │ └── dev_index.html │ │ ├── README.md │ │ └── gulpfile.js └── index.js ├── .gitattributes ├── .gitignore ├── package.json └── README.md /app/USAGE: -------------------------------------------------------------------------------- 1 | Description: 2 | 3 | Example: 4 | yo bee 5 | -------------------------------------------------------------------------------- /app/templates/1.4.8/totoro-config.json: -------------------------------------------------------------------------------- 1 | { 2 | "runner":"./test/runner.html" 3 | } -------------------------------------------------------------------------------- /app/templates/1.4.8/src/article/article-view.xtpl: -------------------------------------------------------------------------------- 1 |

{{title}}

2 |

{{content}}

-------------------------------------------------------------------------------- /def/templates/1.4.8/abc.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "bee", 3 | "builder": "@ali/builder-bee" 4 | } -------------------------------------------------------------------------------- /app/templates/1.4.8/_.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log 4 | *.swp 5 | .sw* 6 | .idea/* -------------------------------------------------------------------------------- /app/templates/1.4.8/src/header/header.less: -------------------------------------------------------------------------------- 1 | header{ 2 | background-color: #2b81af; 3 | color: #fff; 4 | padding: 20px; 5 | } -------------------------------------------------------------------------------- /app/templates/1.4.8/src/article/article.less: -------------------------------------------------------------------------------- 1 | article{ 2 | background-color: #009900; 3 | color: #fff; 4 | padding: 20px; 5 | } -------------------------------------------------------------------------------- /app/templates/1.4.8/src/index.less: -------------------------------------------------------------------------------- 1 | body{ 2 | margin: 0; 3 | } 4 | 5 | @import './header/header'; 6 | @import './article/article'; 7 | -------------------------------------------------------------------------------- /app/templates/1.4.8/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%=name%>", 3 | "kissy":"<%=kissy%>", 4 | "dependencies": { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /app/templates/1.4.8/test/runner.js: -------------------------------------------------------------------------------- 1 | KISSY.add(function(S, require){ 2 | //在这里requires需要运行的用例文件 3 | require('test/spec/index-spec'); 4 | }) -------------------------------------------------------------------------------- /app/templates/1.4.8/build/index-min.css: -------------------------------------------------------------------------------- 1 | body{margin:0}header{background-color:#2b81af;color:#fff;padding:20px}article{background-color:#090;color:#fff;padding:20px} -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.js text 4 | *.css text 5 | *.coffee text 6 | *.md text 7 | *.markdown text 8 | *.json text 9 | *.less text 10 | *.sass text 11 | -------------------------------------------------------------------------------- /app/templates/1.4.8/src/index.js: -------------------------------------------------------------------------------- 1 | //初始化header模块 2 | var header = require('./header/header'); 3 | header.init(); 4 | 5 | //初始化article模块 6 | var article = require('./article/article'); 7 | article.init(); -------------------------------------------------------------------------------- /app/templates/1.4.8/build/header/header-min.js: -------------------------------------------------------------------------------- 1 | KISSY.add("bee-demo/header/header",["node"],function(e,d,a,i){var n=d("node").all;i.exports={init:function(){e.log("header init"),n("header").html("this is header")}}}); -------------------------------------------------------------------------------- /app/templates/1.4.8/src/header/header.js: -------------------------------------------------------------------------------- 1 | var $ = require('node').all; 2 | module.exports = { 3 | init:function(){ 4 | S.log('header init'); 5 | $('header').html('this is header'); 6 | } 7 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea/ 3 | .ipr 4 | .iws 5 | *~ 6 | ~* 7 | *.diff 8 | *.patch 9 | *.bak 10 | .DS_Store 11 | Thumbs.db 12 | .project 13 | .*proj 14 | *.swp 15 | out/ 16 | node_modules/ 17 | tmp/ 18 | reports/ 19 | .sass-cache/ 20 | 21 | -------------------------------------------------------------------------------- /app/templates/1.4.8/build/index-min.js: -------------------------------------------------------------------------------- 1 | KISSY.add("bee-demo/index.js",["bee-demo/header/header","bee-demo/article/article"],function(e,r){var a,d=r("bee-demo/header/header"),i=r("bee-demo/article/article");a=function(e){var r=d;r.init();var a=i;return a.init(),e}()}); -------------------------------------------------------------------------------- /app/templates/1.4.8/test/spec/index-spec.js: -------------------------------------------------------------------------------- 1 | KISSY.add(function (S,require) { 2 | var index = require('<%=name%>/index'); 3 | describe('<%=name%> index', function () { 4 | it('index init',function(){ 5 | expect(index).toBeTruthy(); 6 | }) 7 | }); 8 | 9 | }); -------------------------------------------------------------------------------- /app/templates/1.4.8/build/header/header.js: -------------------------------------------------------------------------------- 1 | KISSY.add('bee-demo/header/header',["node"],function(S ,require, exports, module) { 2 | var $ = require('node').all; 3 | module.exports = { 4 | init:function(){ 5 | S.log('header init'); 6 | $('header').html('this is header'); 7 | } 8 | } 9 | }); -------------------------------------------------------------------------------- /app/templates/1.4.8/build/article/article-min.js: -------------------------------------------------------------------------------- 1 | KISSY.add("bee-demo/article/article",["node","./article-view","kg/xtemplate/3.3.3/runtime"],function(e,t,i,r){var l=t("node").all,n=t("./article-view"),a=t("kg/xtemplate/3.3.3/runtime");r.exports={init:function(){e.log("article init");var t=new a(n).render({title:"this is article",content:"render by kg/xtemplate"});l("article").html(t)}}}); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "generator-bee", 3 | "version": "5.2.5", 4 | "description": "kissy project generator", 5 | "repository": "", 6 | "keywords": [ 7 | "kissy", 8 | "yeoman-generator" 9 | ], 10 | "author": "jianping,minghe", 11 | "main": "app/index.js", 12 | "license": "BSD", 13 | "dependencies": { 14 | "yeoman-generator": "~0.13.2", 15 | "async": "~0.2.10", 16 | "lodash": "~1.2.1" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/templates/1.4.8/src/article/article.js: -------------------------------------------------------------------------------- 1 | var $ = require('node').all; 2 | var tpl = require('./article-view'); 3 | var XTemplate = require("kg/xtemplate/3.3.3/runtime"); 4 | module.exports = { 5 | init:function(){ 6 | S.log('article init'); 7 | var html = new XTemplate(tpl).render({ 8 | title:'this is article', 9 | content:'render by kg/xtemplate' 10 | }); 11 | $('article').html(html); 12 | } 13 | } -------------------------------------------------------------------------------- /app/templates/1.4.8/build/index.js: -------------------------------------------------------------------------------- 1 | KISSY.add("bee-demo/index.js", ["bee-demo/header/header","bee-demo/article/article"], function(S ,require, exports, module) { 2 | var beeDemoHeaderHeader = require("bee-demo/header/header"); 3 | var beeDemoArticleArticle = require("bee-demo/article/article"); 4 | var beeDemoIndex; 5 | beeDemoIndex = function (exports) { 6 | //初始化header模块 7 | var header = beeDemoHeaderHeader; 8 | header.init(); 9 | //初始化article模块 10 | var article = beeDemoArticleArticle; 11 | article.init(); 12 | return exports; 13 | }(); 14 | }); -------------------------------------------------------------------------------- /app/templates/1.4.8/build/article/article.js: -------------------------------------------------------------------------------- 1 | KISSY.add('bee-demo/article/article',["node","./article-view","kg/xtemplate/3.3.3/runtime"],function(S ,require, exports, module) { 2 | var $ = require('node').all; 3 | var tpl = require('./article-view'); 4 | var XTemplate = require("kg/xtemplate/3.3.3/runtime"); 5 | module.exports = { 6 | init:function(){ 7 | S.log('article init'); 8 | var html = new XTemplate(tpl).render({ 9 | title:'this is article', 10 | content:'render by kg/xtemplate' 11 | }); 12 | $('article').html(html); 13 | } 14 | } 15 | }); -------------------------------------------------------------------------------- /app/templates/1.4.8/build/article/article-view-min.js: -------------------------------------------------------------------------------- 1 | KISSY.add("bee-demo/article/article-view",[],function(e,t,a,n){var o=n.exports=function(e){{var t,a=this,n=a.root,o=a.buffer,r=a.scope,i=(a.runtime,a.name,a.pos),c=r.data,d=r.affix,l=n.nativeCommands,s=n.utils;s.callFn,s.callCommand,l.range,l.foreach,l.forin,l.each,l["with"],l["if"],l.set,l.include,l.parse,l.extend,l.block,l.macro,l["debugger"]}o.data+="

";var p=(t=d.title)!==e?t:(t=c.title)!==e?t:r.resolveLooseUp(["title"]);o=o.writeEscaped(p),o.data+="

\n

",i.line=2;var f=(t=d.content)!==e?t:(t=c.content)!==e?t:r.resolveLooseUp(["content"]);return o=o.writeEscaped(f),o.data+="

",o};o.TPL_NAME=n.id||n.name}); -------------------------------------------------------------------------------- /app/templates/1.4.8/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "<%=name%>", 3 | "version": "1.0.0", 4 | "description": "this is an kissy bee project", 5 | "main": "index.js", 6 | "devDependencies": { 7 | "bufferstreams": "0.0.2", 8 | "gulp": "^3.8.7", 9 | "gulp-copy": "0.0.2", 10 | "gulp-filter": "^1.0.2", 11 | "gulp-kclean": "1.0.3", 12 | "gulp-kmc": "1.0.27", 13 | "gulp-less": "^1.3.5", 14 | "gulp-mini-css": "0.0.3", 15 | "gulp-minify": "0.0.5", 16 | "gulp-minify-css": "^0.3.11", 17 | "gulp-rename": "^1.2.0", 18 | "gulp-uglify": "^1.0.1", 19 | "gulp-util": "^3.0.0", 20 | "gulp-xtemplate": "^1.2.2", 21 | "memory-cache": "0.0.5", 22 | "xtemplate": "3.3.3" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/templates/1.4.8/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | } 4 | header { 5 | background-color: #2b81af; 6 | color: #fff; 7 | padding: 20px; 8 | } 9 | article { 10 | background-color: #009900; 11 | color: #fff; 12 | padding: 20px; 13 | } 14 | /*# sourceMappingURL=data:application/json,%7B%22version%22%3A3%2C%22sources%22%3A%5B%22src%2Findex.less%22%5D%2C%22names%22%3A%5B%5D%2C%22mappings%22%3A%22AAAI%3BEACF%2CSAAA%3B%3BAAEI%3BEACJ%2CyBAAA%3BEACA%2CWAAA%3BEACA%2CaAAA%3B%3BAAEK%3BEACL%2CyBAAA%3BEACA%2CWAAA%3BEACA%2CaAAA%22%2C%22sourcesContent%22%3A%5B%22body%7B%5Cn%20%20margin%3A%200%3B%5Cn%7D%5Cnheader%7B%5Cn%20%20background-color%3A%20%232b81af%3B%5Cn%20%20color%3A%20%23fff%3B%5Cn%20%20padding%3A%2020px%3B%5Cn%7D%5Cnarticle%7B%5Cn%20%20background-color%3A%20%23009900%3B%5Cn%20%20color%3A%20%23fff%3B%5Cn%20%20padding%3A%2020px%3B%5Cn%7D%22%5D%7D */ -------------------------------------------------------------------------------- /app/templates/1.4.8/build/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | } 4 | header { 5 | background-color: #2b81af; 6 | color: #fff; 7 | padding: 20px; 8 | } 9 | article { 10 | background-color: #009900; 11 | color: #fff; 12 | padding: 20px; 13 | } 14 | /*# sourceMappingURL=data:application/json,%7B%22version%22%3A3%2C%22sources%22%3A%5B%22src%2Findex.less%22%5D%2C%22names%22%3A%5B%5D%2C%22mappings%22%3A%22AAAI%3BEACF%2CSAAA%3B%3BAAEI%3BEACJ%2CyBAAA%3BEACA%2CWAAA%3BEACA%2CaAAA%3B%3BAAEK%3BEACL%2CyBAAA%3BEACA%2CWAAA%3BEACA%2CaAAA%22%2C%22sourcesContent%22%3A%5B%22body%7B%5Cn%20%20margin%3A%200%3B%5Cn%7D%5Cnheader%7B%5Cn%20%20background-color%3A%20%232b81af%3B%5Cn%20%20color%3A%20%23fff%3B%5Cn%20%20padding%3A%2020px%3B%5Cn%7D%5Cnarticle%7B%5Cn%20%20background-color%3A%20%23009900%3B%5Cn%20%20color%3A%20%23fff%3B%5Cn%20%20padding%3A%2020px%3B%5Cn%7D%22%5D%7D */ -------------------------------------------------------------------------------- /app/templates/1.4.8/demo/online_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | daily阶段demo 5 | 6 | 7 | 8 | 9 | 10 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 |
32 | 33 |
34 | 35 | 36 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /def/templates/1.4.8/demo/online_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | daily阶段demo 5 | 6 | 7 | 8 | 9 | 10 | 22 | 23 | 24 | 25 | 28 | 29 | 30 | 31 |
32 | 33 |
34 | 35 | 36 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /def/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var util = require('util'); 3 | var path = require('path'); 4 | var yeoman = require('yeoman-generator'); 5 | var fs = require('fs'); 6 | 7 | module.exports = Bee; 8 | 9 | function Bee(args, options, config) { 10 | yeoman.generators.Base.apply(this, arguments); 11 | this.cwd = options.env.cwd; 12 | this.kissy = '1.4.8'; 13 | //工程名称 14 | this.name = getProjectName(this); 15 | } 16 | 17 | util.inherits(Bee, yeoman.generators.NamedBase); 18 | 19 | var prt = Bee.prototype; 20 | 21 | prt.copyFile = function(){ 22 | var kissyDir = this.kissy+'/'; 23 | this.template(kissyDir+'abc.json','abc.json'); 24 | this.template(kissyDir+'gulpfile.js','gulpfile.js'); 25 | this.template(kissyDir+'README.md','README.md'); 26 | this.template(kissyDir+'demo/dev_index.html', 'demo/dev_index.html'); 27 | this.template(kissyDir+'demo/online_index.html', 'demo/online_index.html'); 28 | }; 29 | 30 | /** 31 | * 获取工程名称 32 | */ 33 | 34 | function getProjectName(that){ 35 | var root = that.cwd; 36 | return path.basename(root); 37 | } -------------------------------------------------------------------------------- /app/templates/1.4.8/demo/dev_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 开发阶段demo 5 | 6 | 7 | 8 | 9 | 10 | 26 | 27 | 28 | 29 | 32 | 33 | 34 | 35 |
36 | 37 |
38 | 39 |
40 | 41 |
42 | 43 | 44 | 47 | 48 | -------------------------------------------------------------------------------- /def/templates/1.4.8/demo/dev_index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 开发阶段demo 5 | 6 | 7 | 8 | 9 | 10 | 27 | 28 | 29 | 30 | 33 | 34 | 35 |

调试:运行 def xcake dev 后,demo路径加上ks-debug ,开启调试模式。

36 |
37 | 38 |
39 | 40 |
41 | 42 |
43 | 44 | 45 | 48 | 49 | -------------------------------------------------------------------------------- /def/templates/1.4.8/README.md: -------------------------------------------------------------------------------- 1 | ## <%=name%> 2 | 3 | <%=name%>是由[def-bee](http://def.taobao.net/doc/#@ali/def-bee)生成。 4 | 5 | ## 调试 6 | 7 | 模块文件使用CMD规范,是无法使用源码直接调试的,需要启动本地静态服务: 8 | 9 | def bee dev 10 | 11 | 12 | 包配置路径指向本地服务: 13 | 14 | //url带有ks-debug 15 | if(KISSY.config('debug')){ 16 | base = 'http://localhost:5555/src/'; 17 | } 18 | KISSY.config({ 19 | packages: [ 20 | { 21 | name: '<%=name%>', 22 | base: base, 23 | ignorePackageNameInUri: true, 24 | combine:false 25 | } 26 | ]} 27 | ); 28 | 29 | 写法请参考demo/dev_index.html。 30 | 31 | 本地服务会监听文件的改变编译xtpl模板、less。 32 | 33 | ## 线上调试 34 | 35 | 可以使用chales或fiddler代理工具,将包路径代理到本地服务路径。 36 | 37 | ## 打包构建 38 | 39 | 运行 def build -l 即可。 40 | 41 | ## 生成的目录结构 42 | 43 | bee-demo // 工程名,也是库名 44 | | |-----src // 源码目录 45 | | | |---------index.js // index页面入口脚本 46 | | | |---------index.less // index页面样式 47 | | |-----build // 发布目录 48 | | | |---------deps.js // 模块依赖表 49 | | |-----demo // demo目录 50 | | |-----build // 发布目录 51 | | |-----README.md // 库介绍 52 | | |-----gulpfile.js // gulp打包时使用的配置信息 53 | | |-----package.js // 依赖包配置 -------------------------------------------------------------------------------- /app/templates/1.4.8/README.md: -------------------------------------------------------------------------------- 1 | ## <%=name%> 2 | 3 | <%=name%>是由[generator-bee](https://github.com/kissyteam/generator-bee)生成。 4 | 5 | ## 调试 6 | 7 | 模块文件使用CMD规范,是无法使用源码直接调试的,所以bee 内置了个本地静态服务,运行: 8 | 9 | gulp 10 | 11 | 会编译文件到build目录,同时会起一个本地server,访问:[http://localhost:5555/<%=name%>/index.js](http://localhost:5555/<%=name%>/index.js),就是访问<%=name%>/src/index.js文件。 12 | 13 | 包配置路径指向本地服务: 14 | 15 | //url带有ks-debug 16 | if(KISSY.config('debug')){ 17 | base = 'http://localhost:5555/<%=name%>/'; 18 | } 19 | KISSY.config({ 20 | packages: [ 21 | { 22 | name: '<%=name%>', 23 | base: base, 24 | ignorePackageNameInUri: true, 25 | debug: true, 26 | combine:false 27 | } 28 | ]} 29 | ); 30 | 31 | 写法请参考demo/dev_index.html。 32 | 33 | ## 线上调试 34 | 35 | 可以使用chales或fiddler代理工具,将包路径代理到本地服务路径。 36 | 37 | ## 构建 38 | 39 | 打包文件 40 | 41 | gulp 42 | 43 | 监听文件改变实时编译 44 | 45 | gulp watch 46 | 47 | 默认编译less和生成kissy模块名和依赖表。 48 | 49 | ## 生成的目录结构 50 | 51 | bee-demo // 工程名,也是库名 52 | | |-----src // 源码目录 53 | | | |---------index.js // index页面入口脚本 54 | | | |---------mods // 依赖的业务模块 55 | | | |---------index.less // index页面样式 56 | | |-----build // 发布目录 57 | | | |---------deps.js // 模块依赖表 58 | | |-----demo // demo目录 59 | | |-----test // 测试用例目录 60 | | |-----build // 发布目录 61 | | |-----README.md // 库介绍 62 | | |-----gulpfile.js // gulp打包时使用的配置信息 63 | | |-----package.js // 依赖包配置 -------------------------------------------------------------------------------- /app/templates/1.4.8/src/article/article-view.js: -------------------------------------------------------------------------------- 1 | KISSY.add(function(S,require,exports,module){ 2 | /*compiled by xtemplate#3.3.3*/ 3 | var ret = module.exports = function content(undefined){ 4 | var t; 5 | var t0; 6 | var t1; 7 | var t2; 8 | var t3; 9 | var t4; 10 | var t5; 11 | var t6; 12 | var t7; 13 | var t8; 14 | var t9; 15 | var tpl = this; 16 | var root = tpl.root; 17 | var buffer = tpl.buffer; 18 | var scope = tpl.scope; 19 | var runtime = tpl.runtime; 20 | var name = tpl.name; 21 | var pos = tpl.pos; 22 | var data = scope.data; 23 | var affix = scope.affix; 24 | var nativeCommands = root.nativeCommands; 25 | var utils = root.utils; 26 | var callFnUtil = utils["callFn"]; 27 | var callCommandUtil = utils["callCommand"]; 28 | var rangeCommand = nativeCommands["range"]; 29 | var foreachCommand = nativeCommands["foreach"]; 30 | var forinCommand = nativeCommands["forin"]; 31 | var eachCommand = nativeCommands["each"]; 32 | var withCommand = nativeCommands["with"]; 33 | var ifCommand = nativeCommands["if"]; 34 | var setCommand = nativeCommands["set"]; 35 | var includeCommand = nativeCommands["include"]; 36 | var parseCommand = nativeCommands["parse"]; 37 | var extendCommand = nativeCommands["extend"]; 38 | var blockCommand = nativeCommands["block"]; 39 | var macroCommand = nativeCommands["macro"]; 40 | var debuggerCommand = nativeCommands["debugger"]; 41 | 42 | 43 | buffer.data += '

'; 44 | var id0 = ((t=(affix.title)) !== undefined ? t:((t = data.title) !== undefined ? t :scope.resolveLooseUp(["title"]))); 45 | buffer = buffer.writeEscaped(id0); 46 | buffer.data += '

\n

'; 47 | pos.line = 2; 48 | var id1 = ((t=(affix.content)) !== undefined ? t:((t = data.content) !== undefined ? t :scope.resolveLooseUp(["content"]))); 49 | buffer = buffer.writeEscaped(id1); 50 | buffer.data += '

'; 51 | return buffer; 52 | }; 53 | ret.TPL_NAME = module.id || module.name; 54 | }); -------------------------------------------------------------------------------- /app/templates/1.4.8/build/article/article-view.js: -------------------------------------------------------------------------------- 1 | KISSY.add('bee-demo/article/article-view',[],function(S ,require, exports, module) { 2 | 3 | 4 | var ret = module.exports = function content(undefined){ 5 | var t; 6 | var t0; 7 | var t1; 8 | var t2; 9 | var t3; 10 | var t4; 11 | var t5; 12 | var t6; 13 | var t7; 14 | var t8; 15 | var t9; 16 | var tpl = this; 17 | var root = tpl.root; 18 | var buffer = tpl.buffer; 19 | var scope = tpl.scope; 20 | var runtime = tpl.runtime; 21 | var name = tpl.name; 22 | var pos = tpl.pos; 23 | var data = scope.data; 24 | var affix = scope.affix; 25 | var nativeCommands = root.nativeCommands; 26 | var utils = root.utils; 27 | var callFnUtil = utils["callFn"]; 28 | var callCommandUtil = utils["callCommand"]; 29 | var rangeCommand = nativeCommands["range"]; 30 | var foreachCommand = nativeCommands["foreach"]; 31 | var forinCommand = nativeCommands["forin"]; 32 | var eachCommand = nativeCommands["each"]; 33 | var withCommand = nativeCommands["with"]; 34 | var ifCommand = nativeCommands["if"]; 35 | var setCommand = nativeCommands["set"]; 36 | var includeCommand = nativeCommands["include"]; 37 | var parseCommand = nativeCommands["parse"]; 38 | var extendCommand = nativeCommands["extend"]; 39 | var blockCommand = nativeCommands["block"]; 40 | var macroCommand = nativeCommands["macro"]; 41 | var debuggerCommand = nativeCommands["debugger"]; 42 | 43 | 44 | buffer.data += '

'; 45 | var id0 = ((t=(affix.title)) !== undefined ? t:((t = data.title) !== undefined ? t :scope.resolveLooseUp(["title"]))); 46 | buffer = buffer.writeEscaped(id0); 47 | buffer.data += '

\n

'; 48 | pos.line = 2; 49 | var id1 = ((t=(affix.content)) !== undefined ? t:((t = data.content) !== undefined ? t :scope.resolveLooseUp(["content"]))); 50 | buffer = buffer.writeEscaped(id1); 51 | buffer.data += '

'; 52 | return buffer; 53 | }; 54 | ret.TPL_NAME = module.id || module.name; 55 | }); -------------------------------------------------------------------------------- /app/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | var util = require('util'); 3 | var path = require('path'); 4 | var yeoman = require('yeoman-generator'); 5 | var fs = require('fs'); 6 | 7 | module.exports = Bee; 8 | 9 | function Bee(args, options, config) { 10 | yeoman.generators.Base.apply(this, arguments); 11 | this.cwd = options.env.cwd; 12 | //工程名称 13 | this.name = getProjectName(this); 14 | this.kissy = '1.4.8'; 15 | this.outputLog = this.arguments[0]; 16 | this.on('end',function(){ 17 | if(this.outputLog != 'none'){ 18 | this.log("\n"); 19 | console.log("目录和文件初始化完成!"); 20 | this.log("\n"); 21 | this.log("1.运行npm install安装工具依赖\n"); 22 | this.log("2.运行gulp命令打包并开启调试服务器,比如bee-demo工程,http://localhost:5555/bee-demo/1.0.0/index.js,指向src/index.js\n"); 23 | this.log("3.参考demo/dev_index.html(url加上?ks-debug)进行demo开发\n"); 24 | } 25 | }) 26 | } 27 | 28 | util.inherits(Bee, yeoman.generators.NamedBase); 29 | 30 | var prt = Bee.prototype; 31 | 32 | prt.welcome = function(){ 33 | // welcome message 34 | var welcome = '\n\n欢迎使用bee!\nbee是kissy简单工程构建器,遵循最新的kissy规范。\nbee由kissy小组维护。\n'; 35 | 36 | console.log(welcome); 37 | }; 38 | 39 | prt.mk = function(){ 40 | var fold = ['demo','build','src']; 41 | for(var i=0;i 2 | 3 | 4 | 5 | 6 | Runner 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![http://gtms04.alicdn.com/tps/i4/T1i9hTFpBnXXcDeDnx-300-80.png](http://gtms04.alicdn.com/tps/i4/T1i9hTFpBnXXcDeDnx-300-80.png) 2 | 3 | ## generator-bee 4 | 5 | **generator-bee**是kissy简单工程构建器,跟generator-xcake和generator-clam有所不同,强调简单和快速,没有复杂的目录分级和复杂的命令功能,不是以页面作为划分维度,适用于小工程构建。 6 | 7 | generator-bee 遵循最新的kissy规范,由kissy小组维护,会生成demo页面和测试用例范例。 8 | 9 | * [demo工程传送门](https://github.com/minghe/bee-demo) 10 | * [在线demo](http://apebook.org/bee-demo/demo/dev_index.html) 11 | 12 | ## 安装 13 | 14 | 安装yeoman 15 | 16 | npm install yo gulp -g 17 | 18 | 安装kissy-gallery目录生成器 19 | 20 | npm install generator-bee -g 21 | 22 | 生成组件目录 23 | 24 | 新建个工程目录,进入执行命令: 25 | 26 | yo bee 27 | 28 | ## 调试 29 | 30 | 模块文件使用CMD规范,是无法使用源码直接调试的,所以bee 内置了个本地静态服务,运行: 31 | 32 | gulp 33 | 34 | 会编译文件到build目录,同时会起一个本地server,访问:[http://localhost:5555/bee-demo/index.js](http://localhost:5555/bee-demo/index.js),就是访问bee-demo/src/index.js文件。 35 | 36 | 包配置路径指向本地服务: 37 | 38 | //url带有ks-debug 39 | if(KISSY.config('debug')){ 40 | base = 'http://localhost:5555'; 41 | } 42 | KISSY.config({ 43 | packages: [ 44 | { 45 | name: 'bee-demo', 46 | base: base, 47 | ignorePackageNameInUri: true, 48 | debug: true, 49 | combine:false 50 | } 51 | ]} 52 | ); 53 | 54 | 写法请参考demo/dev_index.html。 55 | 56 | 57 | ## 构建 58 | 59 | 打包文件 60 | 61 | gulp 62 | 63 | 监听文件改变实时编译 64 | 65 | gulp watch 66 | 67 | 默认编译less和生成kissy模块名和依赖表。 68 | 69 | ## 生成的目录结构 70 | 71 | bee-demo // 工程名,也是库名 72 | | |-----src // 源码目录 73 | | | |---------index.js // index页面入口脚本 74 | | | |---------mods // 依赖的业务模块 75 | | | |---------index.less // index页面样式 76 | | |-----build // 发布目录 77 | | | |---------deps.js // 模块依赖表 78 | | |-----demo // demo目录 79 | | |-----test // 测试用例目录 80 | | |-----build // 发布目录 81 | | |-----README.md // 库介绍 82 | | |-----gulpfile.js // gulp打包时使用的配置信息 83 | | |-----package.js // 依赖包配置 84 | 85 | ## 代码规范 86 | 87 | 模块文件使用CMD规范。 88 | 89 | //初始化header模块 90 | var header = require('./mods/header'); 91 | header.init(); 92 | 93 | //初始化article模块 94 | var article = require('./mods/article'); 95 | article.init(); 96 | 97 | 使用**require()**来引用模块。 98 | 99 | ## 工程内使用kg组件 100 | 101 | 编辑bower.json: 102 | 103 | "dependencies": { 104 | "reactive": "kg/reactive#0.2.0" 105 | } 106 | 107 | 格式为 kg/组件名#版本号 。 108 | 109 | 然后运行bower install ,会自动拉取组件到src/kg目录。 110 | 111 | 业务模块引用组件: 112 | 113 | var Reactive = require('./kg/reactive/index'); 114 | 115 | ## CHANGELOG 116 | 117 | ### v5.2.4 118 | 119 | * 修正打包时空格bug 120 | 121 | ### v5.2.2 122 | 123 | * 默认任务增加xtpl打包 124 | 125 | ### v5.2.0 126 | 127 | * 修正kmc打包错误 128 | * 优化源码目录结构 129 | 130 | ### v5.0.9 131 | 132 | * 增加def的适配 133 | * 优化打包文件 134 | 135 | ### v5.0.6 136 | 137 | * 修改demo地址 138 | 139 | ### v5.0.5 140 | 141 | * 去掉5.0的支持 142 | * 优化调试方式 143 | * 修正本地服务器css加载错误 144 | 145 | ### v5.0.2 146 | 147 | * 优化代码 148 | * 去掉gulpfile.js中得无用代码 149 | * 增加对xtpl文件的编译 150 | * 1.4.7更新为1.4.8 151 | 152 | ### v5.0.1 153 | 154 | * 使用新的gulp插件 155 | 156 | 157 | ### v5.0.0 158 | 159 | * 适配kissy5.0.0 160 | 161 | ### v1.0.3 162 | 163 | * 优化brower配置 164 | 165 | ### v1.0.2 166 | 167 | * 增加kg brower配置 168 | 169 | ### v1.0.1 170 | 171 | * kissy1.4.7 172 | * 使用gulp打包 173 | * 使用kclean优化代码 174 | * 去掉kissy mini支持 175 | 176 | ### v0.0.2 177 | 178 | * 新增kissy mini工程支持 -------------------------------------------------------------------------------- /def/templates/1.4.8/gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var kmc = require('gulp-kmc'); 3 | var less = require('gulp-less'); 4 | var css = require('gulp-mini-css'); 5 | var kclean = require('gulp-kclean'); 6 | var rename = require("gulp-rename"); 7 | var filter = require('gulp-filter'); 8 | var minify = require('gulp-minify'); 9 | var XTemplate = require('xtemplate'); 10 | var gulpXTemplate = require('gulp-xtemplate'); 11 | var path = require('path'); 12 | var fs = require('fs'); 13 | var src = "./src", 14 | dest = "./build"; 15 | var root = process.cwd(); 16 | //包配置 17 | var pkg = path.basename(root); 18 | var comboSuffix = '-combo'; 19 | 20 | kmc.config({ 21 | packages:[{ 22 | name: pkg, 23 | base: src 24 | }] 25 | }); 26 | 27 | var dirs = fs.readdirSync(src); 28 | 29 | var kissyFiles = []; 30 | dirs.forEach(function(i){ 31 | var stat = fs.statSync(path.join(src,i)); 32 | //排除非版本号目录 33 | if(stat.isFile()&&new RegExp(/.*\.js/).test(i)){ 34 | i = i.replace('.js',''); 35 | kissyFiles.push(i); 36 | } 37 | }); 38 | 39 | //使用kmc合并并编译kissy模块文件 40 | function renderKmc(fileName){ 41 | var comboFiles = fileName.map(function(name){ 42 | return { 43 | src: pkg+"/"+name+".js", 44 | dest: name + comboSuffix+".js" 45 | }; 46 | }); 47 | var cleanFiles = fileName.map(function(name){ 48 | return { 49 | src:name+comboSuffix+'.js', 50 | outputModule:pkg+'/'+name 51 | }; 52 | }); 53 | return gulp.src([src+'/**/*.js']) 54 | //转换cmd模块为kissy模块 55 | .pipe(kmc.convert({ 56 | kissy: true, 57 | ignoreFiles: ['-min.js'] 58 | })) 59 | //合并文件 60 | .pipe(kmc.combo({ 61 | deps:'deps.js', 62 | files:comboFiles 63 | })) 64 | //优化代码 65 | .pipe(kclean({ 66 | files:cleanFiles 67 | })) 68 | .pipe(minify()) 69 | .pipe(filter(function(file){ 70 | var files = fileName.map(function(name){ 71 | return name+comboSuffix+'.js'; 72 | }); 73 | return files.indexOf(file.relative) == -1; 74 | })) 75 | .pipe(rename(function(file){ 76 | fileName.forEach(function(name){ 77 | file.basename = file.basename.replace(name+comboSuffix+'-min',name+'-min'); 78 | }) 79 | })) 80 | .pipe(gulp.dest(dest)); 81 | } 82 | 83 | 84 | gulp.task('kmc', function() { 85 | return renderKmc(kissyFiles); 86 | }); 87 | 88 | gulp.task('mini-css', function(){ 89 | return gulp.src([src+'/**/*.css']) 90 | .pipe(gulp.dest(dest)) 91 | .pipe(css({ext:'-min.css'})) 92 | .pipe(gulp.dest(dest)); 93 | }); 94 | 95 | gulp.task('less', function(){ 96 | return gulp.src([src+'/**/*.less']) 97 | .pipe(less()) 98 | .on('error',function(e){ 99 | console.log(e); 100 | }) 101 | .pipe(gulp.dest(src)); 102 | }); 103 | 104 | gulp.task('css',['less','mini-css']); 105 | 106 | gulp.task('xtpl',function(){ 107 | return gulp.src(src+'/**/*.xtpl') 108 | .pipe(gulpXTemplate({ 109 | wrap: 'kissy', 110 | XTemplate: XTemplate, 111 | renderJs: 'none' 112 | })) 113 | .on('error',function(e){ 114 | console.log(e); 115 | }) 116 | .pipe(gulp.dest(src)); 117 | }); 118 | 119 | 120 | gulp.task('watch', function() { 121 | gulp.watch(src+'/**/*.xtpl', ['xtpl']); 122 | gulp.watch(src+'/**/*.less', ['css']); 123 | }); 124 | 125 | gulp.task('default', ['xtpl','kmc','css']); -------------------------------------------------------------------------------- /app/templates/1.4.8/gulpfile.js: -------------------------------------------------------------------------------- 1 | var gulp = require('gulp'); 2 | var kmc = require('gulp-kmc'); 3 | var less = require('gulp-less'); 4 | var css = require('gulp-mini-css'); 5 | var kclean = require('gulp-kclean'); 6 | var rename = require("gulp-rename"); 7 | var filter = require('gulp-filter'); 8 | var minify = require('gulp-minify'); 9 | var XTemplate = require('xtemplate'); 10 | var gulpXTemplate = require('gulp-xtemplate'); 11 | var path = require('path'); 12 | var fs = require('fs'); 13 | var src = "./src", 14 | dest = "./build"; 15 | var root = process.cwd(); 16 | //包配置 17 | var pkg = path.basename(root); 18 | var comboSuffix = '-combo'; 19 | 20 | kmc.config({ 21 | packages:[{ 22 | name: pkg, 23 | base: src 24 | }] 25 | }); 26 | 27 | kmc.server({ 28 | port:5555, 29 | fixModule:true, 30 | path: dest, 31 | kissy:true 32 | }); 33 | 34 | 35 | var dirs = fs.readdirSync(src); 36 | 37 | var kissyFiles = []; 38 | dirs.forEach(function(i){ 39 | var stat = fs.statSync(path.join(src,i)); 40 | //排除非版本号目录 41 | if(stat.isFile()&&new RegExp(/.*\.js/).test(i)){ 42 | i = i.replace('.js',''); 43 | kissyFiles.push(i); 44 | } 45 | }); 46 | 47 | //使用kmc合并并编译kissy模块文件 48 | function renderKmc(fileName){ 49 | var comboFiles = fileName.map(function(name){ 50 | return { 51 | src: pkg+"/"+name+".js", 52 | dest: name + comboSuffix+".js" 53 | }; 54 | }); 55 | var cleanFiles = fileName.map(function(name){ 56 | return { 57 | src:name+comboSuffix+'.js', 58 | outputModule:pkg+'/'+name 59 | }; 60 | }); 61 | return gulp.src([src+'/**/*.js']) 62 | //转换cmd模块为kissy模块 63 | .pipe(kmc.convert({ 64 | kissy: true, 65 | ignoreFiles: ['-min.js'] 66 | })) 67 | //合并文件 68 | .pipe(kmc.combo({ 69 | deps:'deps.js', 70 | files:comboFiles 71 | })) 72 | //优化代码 73 | .pipe(kclean({ 74 | files:cleanFiles 75 | })) 76 | .pipe(minify()) 77 | .pipe(filter(function(file){ 78 | var files = fileName.map(function(name){ 79 | return name+comboSuffix+'.js'; 80 | }); 81 | return files.indexOf(file.relative) == -1; 82 | })) 83 | .pipe(rename(function(file){ 84 | fileName.forEach(function(name){ 85 | file.basename = file.basename.replace(name+comboSuffix+'-min',name+'-min'); 86 | }) 87 | })) 88 | .pipe(gulp.dest(dest)); 89 | } 90 | 91 | 92 | gulp.task('kmc', function() { 93 | return renderKmc(kissyFiles); 94 | }); 95 | 96 | gulp.task('mini-css', function(){ 97 | return gulp.src([src+'/**/*.css']) 98 | .pipe(gulp.dest(dest)) 99 | .pipe(css({ext:'-min.css'})) 100 | .pipe(gulp.dest(dest)); 101 | }); 102 | 103 | gulp.task('less', function(){ 104 | return gulp.src([src+'/**/*.less']) 105 | .pipe(less()) 106 | .on('error',function(e){ 107 | console.log(e); 108 | }) 109 | .pipe(gulp.dest(src)); 110 | }); 111 | 112 | gulp.task('css',['less','mini-css']); 113 | 114 | gulp.task('xtpl',function(){ 115 | return gulp.src(src+'/**/*.xtpl') 116 | .pipe(gulpXTemplate({ 117 | wrap: 'kissy', 118 | XTemplate: XTemplate, 119 | renderJs: 'none' 120 | })) 121 | .on('error',function(e){ 122 | console.log(e); 123 | }) 124 | .pipe(gulp.dest(src)); 125 | }); 126 | 127 | 128 | gulp.task('watch', function() { 129 | gulp.watch(src+'/**/*.xtpl', ['xtpl']); 130 | gulp.watch(src+'/**/*.less', ['css']); 131 | }); 132 | 133 | gulp.task('default', ['kmc','css','watch']); --------------------------------------------------------------------------------