Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

重构助手 #19

Merged
merged 12 commits into from
Sep 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
*swp
*~

node_modules
build
*.pem
ext/
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "gm2chrome"]
path = gm2chrome
url = https://github.com/bcho/gm2chrome
158 changes: 158 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
module.exports = function (grunt) {

grunt.initConfig({

// 脚本基本信息
pkg: grunt.file.readJSON('package.json'),

// 文件夹路径
dir: {
src: './src',
manifest: './src/manifest',
build: './build',
dist: './',
test: './src/test',
docs: './docs',
nodeModules: './node_modules'
},

// 任务配置

clean: {
build: ['<%= dir.build %>']
},

concat: {
build_gm: {
src: [
'<%= dir.manifest %>/greasemonkey.js',
'<%= dir.src %>/gdut-jwgl-helper.js'
],
dest: '<%= dir.build %>/gdut-jwgl-helper.gm.js'
}
},

connect: {
// 执行测试
test: {
options: {
base: [
'<%= dir.src %>',
'<%= dir.test %>',
'<%= dir.nodeModules %>',
'<%= dir.docs %>'
],
port: 9000,
useAvailabePort: true
}
}
},

copy: {
build_crx: {
files: [
{
src: '<%= dir.src %>/gdut-jwgl-helper.js',
dest: '<%= dir.build %>/crx/gdut-jwgl-helper.js'
},
{
src: '<%= dir.manifest %>/crx.json',
dest: '<%= dir.build %>/crx/manifest.json'
},
{
src: '<%= dir.src %>/vendor/jquery.min.js',
dest: '<%= dir.build %>/crx/jquery.min.js'
}
]
},

publish_gm: {
src: '<%= dir.build %>/gdut-jwgl-helper.gm.js',
dest: '<%= dir.dist %>/gdut-jwgl-helper.<%= pkg.version %>.js'
},

publish_crx: {
src: '<%= dir.build %>/crx.crx',
dest: '<%= dir.dist %>/gdut-jwgl-helper.<%= pkg.version %>.crx'
}
},

shell: {
build_crx: {
command: function () {
// 可以使用命令行参数 ``--chrome`` 来指定打包使用的 chrome
var chrome = grunt.option('chrome') || 'chromium',
pem = grunt.template.process(
'<%= dir.manifest %>/gdut-jwgl-helper.pem'
),
cmd = chrome + ' --pack-extension=<%= dir.build %>/crx';

if (grunt.file.exists(pem)) {
cmd += ' --pack-extension-key=' + pem;
} else {
cmd += '&& mv <%= dir.build %>/crx.pem ' + pem;
}

return cmd;
}
}
},

watch: {
src: {
files: ['<%= dir.src %>/**/*.js', '<%= dir.src %>/**/*.json'],
tasks: ['copy:build_crx', 'build_gm']
}
}

});

// 加载 grunt 的插件
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-shell');

// 定义任务

// 将脚本打包成 crx 格式
grunt.registerTask('build_crx', [
'copy:build_crx',
'shell:build_crx'
]);

// 将脚本打包成 greasemonkey 脚本格式
grunt.registerTask('build_gm', [
'concat:build_gm'
]);

// 打包任务
grunt.registerTask('package', [
'clean:build',
'build_gm',
'build_crx'
]);

// 发布任务
grunt.registerTask('publish', [
'package',
'copy:publish_gm',
'copy:publish_crx'
]);

// 测试任务
grunt.registerTask('test', [
'connect:test:keepalive'
]);

// 默认任务:
// - 运行测试用例的静态服务器
// - 检测代码改动并自动打包
grunt.registerTask('default', [
'connect:test',
'watch:src'
]);

};
31 changes: 0 additions & 31 deletions Makefile

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ gdut-jwgl-helper

## 安裝

[脚本地址](http://raw.github.com/vtmer/gdut-jwgl-helper/master/gdut-jwgl-helper.js)
[脚本地址](http://raw.github.com/vtmer/gdut-jwgl-helper/master/gdut-jwgl-helper.0.2.0js)

### Chrome / Chromium / 猎豹 / 360

Expand All @@ -36,7 +36,7 @@ gdut-jwgl-helper

#### 方案二:

安装 [Chrome插件](https://github.com/vtmer/gdut-jwgl-helper/blob/master/gdut-jwgl-helper.crx?raw=true),
安装 [Chrome插件](https://github.com/vtmer/gdut-jwgl-helper/blob/master/gdut-jwgl-helper.0.2.0.crx?raw=true),
因为暂时还未在 Chrome Web Store 上架,所以先手拖到 chrome://extensions 安装吧 :)


Expand All @@ -49,4 +49,4 @@ gdut-jwgl-helper

[@Link](http://weibo.com/linkjie)

[@hbc](http://www.douban.com/people/minibc)
[@hbc](https://github.com/bcho)
Loading