Skip to content

Commit d0521be

Browse files
czyczy
authored andcommitted
代码迁移
0 parents  commit d0521be

24 files changed

+957
-0
lines changed

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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

.gitignore

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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+
.svn/
15+
*.swp
16+
out/
17+
node_modules/
18+
tmp/
19+
reports/
20+
.sass-cache/
21+

README.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
a yeoman generator for kissy-gallery
2+
3+
## install
4+
### 安装yeoman
5+
6+
````sh
7+
npm install yo grunt-cli -g
8+
````
9+
10+
### 安装kissy-gallery目录生成器
11+
12+
````sh
13+
npm install generator-kissy-gallery -g
14+
````
15+
16+
### 生成组件目录
17+
18+
比如你的组件目录是offline,进入该目录,然后执行命令:
19+
20+
````sh
21+
yo kissy-gallery 1.0
22+
````
23+
24+
默认版本为1.0。
25+
26+
### 打包组件
27+
28+
在组件目录下执行如下命令:
29+
30+
````sh
31+
grunt
32+
````
33+
34+
可以修改gruntfile.js来自定义组件的构建。
35+
36+
### 发布一个新的版本
37+
38+
在组件目录下执行如下命令:
39+
40+
````sh
41+
yo kissy-gallery:version 1.1
42+
````
43+
44+
##changelog
45+
46+
###0.3.1
47+
48+
* 增加flexcombo插件,支持本地调试
49+
50+
插件用法看https://npmjs.org/package/grunt-flexcombo
51+
###0.3.0
52+
53+
* #4 增加组件名称的处理
54+
* #4 优化demo的模块加载
55+
* #4 增加githubName字段,用于kpm
56+
57+
###0.2.8
58+
59+
* fix #3
60+
61+
###0.2.7
62+
63+
* 输出问询提示
64+
* Gruntfile优化
65+
66+
###0.2.5
67+
68+
* 修改demo kissy的引用路径(http://g.tbcdn.cn/kissy/k/1.3.0/kissy-min.js)
69+
* demo 增加kissy dpl样式
70+
71+
###0.2.4
72+
*修正merge命令bug
73+
74+
###0.2.3
75+
76+
*优化文档
77+
78+
###0.2.0
79+
*merge子命令实现,自动merge的功能
80+
*实现merge的同时同步文档
81+
82+
###0.1.9
83+
*去掉多余依赖
84+
85+
###0.1.8
86+
*修正编码问题
87+
88+
###0.1.7
89+
*打包时中文ascii化
90+
91+
###0.1.6
92+
*优化README.md
93+
94+
###0.1.5
95+
*修正yo kissy-gallery:version命令无效的bug

app/USAGE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Description:
2+
创建kissy的gallery组件目录
3+
4+
Example:
5+
yo kissy-gallery 1.0

app/index.js

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
'use strict';
2+
var util = require('util');
3+
var path = require('path');
4+
var generator = require('abc-generator');
5+
var fs = require('fs');
6+
7+
module.exports = Gallery;
8+
9+
function Gallery(args, options, config) {
10+
generator.UIBase.apply(this, arguments);
11+
this.version = args[0] || '1.0';
12+
this.cwd = options.env.cwd;
13+
//库地址
14+
this.reposName = getReposName(this);
15+
//组件名称
16+
this.comName = getComName(this.reposName);
17+
if (fs.existsSync('abc.json')) {
18+
this.abcJSON = JSON.parse(this.readFileAsString('abc.json'));
19+
} else {
20+
this.abcJSON = {}
21+
}
22+
23+
this.on('end',function(){
24+
this.installDependencies();
25+
console.log("组件目录和文件初始化完成!");
26+
console.log("\n打包组件运行:grunt");
27+
})
28+
}
29+
30+
util.inherits(Gallery, generator.UIBase);
31+
32+
var prt = Gallery.prototype;
33+
34+
prt.askFor = function(){
35+
//打印欢迎消息
36+
console.log(this.abcLogo);
37+
}
38+
prt.askAuthor = function(){
39+
var cb = this.async();
40+
41+
var author = {
42+
name: 'kissy-team',
43+
44+
};
45+
46+
if (this.abcJSON && this.abcJSON.author) {
47+
var abcAuthor = this.abcJSON.author;
48+
author.name = abcAuthor.name || 'kissy-team';
49+
author.email = abcAuthor.email || '[email protected]';
50+
}
51+
console.log('阿里同学author请使用花名,email请使用内网邮箱,tag请使用中文(多个英文逗号隔开),github账户名用于代码同步');
52+
var prompts = [{
53+
name: 'author',
54+
message: 'author of component:',
55+
default: author.name
56+
},{
57+
name: 'email',
58+
message: 'email of author:',
59+
default: author.email
60+
},{
61+
name: 'tag',
62+
message: 'tag of component:'
63+
},{
64+
name: 'githubName',
65+
message: 'user name of github:'
66+
}];
67+
68+
this.prompt(prompts, function (props) {
69+
this.author = props.author;
70+
this.email = props.email;
71+
this.tag = props.tag;
72+
this.githubName = props.githubName;
73+
cb();
74+
}.bind(this));
75+
}
76+
prt.copyFile = function(){
77+
this.copy('Gruntfile.js','Gruntfile.js');
78+
this.copy('_.gitignore','.gitignore');
79+
this.template('abc.json','abc.json');
80+
this.template('_package.json','package.json');
81+
this.template('README.md', 'README.md');
82+
83+
}
84+
85+
prt.mk = function(){
86+
var version = this.version;
87+
this.mkdir(version);
88+
var fold = ['demo','spec','build','plugin','guide','meta'];
89+
for(var i=0;i<fold.length;i++){
90+
this.mkdir(path.join(version, fold[i]));
91+
}
92+
}
93+
94+
prt.createVersion = function(){
95+
var version = this.version;
96+
this.comConfig = comConfig(this);
97+
this.template('index.js', path.join(version, 'index.js'));
98+
this.template('alias.js', path.join(version, 'meta','alias.js'));
99+
this.template('modules.js', path.join(version, 'meta','modules.js'));
100+
this.template('index.md', path.join(version, 'guide', 'index.md'));
101+
this.template('index.html', path.join(version, 'demo', 'index.html'));
102+
}
103+
104+
/**
105+
* Scan Project
106+
*/
107+
prt._scan = function _scan() {
108+
// fix windows path
109+
var versionMatch = path.join('*.*/');
110+
var versions = this.expand(versionMatch);
111+
112+
var abc = JSON.parse(this.readFileAsString('abc.json'));
113+
var version = abc.version;
114+
115+
versions = versions.
116+
117+
filter(function(v){
118+
return /^(\d.\d)/.test(v);
119+
}).
120+
map(function(v) {
121+
v = v.match(/^(\d.\d)/)[1];
122+
return {
123+
version: v,
124+
current: v === version
125+
}
126+
});
127+
console.log(versions);
128+
129+
return {
130+
versions: versions
131+
};
132+
133+
};
134+
/**
135+
* 获取库名称
136+
*/
137+
138+
function getReposName(that){
139+
var root = that.cwd;
140+
return path.basename(root);
141+
}
142+
/**
143+
* 获取组件名称
144+
*/
145+
function getComName(reposName){
146+
var first = reposName.substring(0,1).toUpperCase();
147+
var comName = first + reposName.substring(1);
148+
comName = comName.replace(/-(\w)/g,function($1,$2){
149+
return $2.toUpperCase();
150+
});
151+
return comName;
152+
}
153+
function comConfig(that){
154+
var jsonFile = './abc.json';
155+
var sAbcJson = that.readFileAsString(jsonFile);
156+
return JSON.parse(sAbcJson);
157+
}
158+

0 commit comments

Comments
 (0)