2 # Copyright Simon Lydell 2014.
4 # This file is part of VimFx.
6 # VimFx is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # VimFx is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with VimFx. If not, see <http://www.gnu.org/licenses/>.
21 { join } = require('path')
22 request = require('request')
23 gulp = require('gulp')
24 changed = require('gulp-changed')
25 coffee = require('gulp-coffee')
26 coffeelint = require('gulp-coffeelint')
27 mustache = require('gulp-mustache')
28 util = require('gulp-util')
29 zip = require('gulp-zip')
30 rimraf = require('rimraf')
34 LOCALE = 'extension/locale'
36 read = (filepath) -> fs.readFileSync(filepath).toString()
37 template = (data) -> mustache(data, {extension: ''})
39 gulp.task('default', ['push'])
41 gulp.task('clean', (callback) ->
42 rimraf(DEST, callback)
46 gulp.src(['extension/**/!(*.coffee|*.tmpl)', 'COPYING'])
48 .pipe(gulp.dest(DEST))
51 gulp.task('coffee', ->
52 gulp.src('extension/**/*.coffee')
53 .pipe(changed(DEST, {extension: '.coffee'}))
54 .pipe(coffee({bare: true}).on('error', util.log))
55 .pipe(gulp.dest(DEST))
58 gulp.task('chrome.manifest', ->
59 gulp.src('extension/chrome.manifest.tmpl')
60 .pipe(template({locales: fs.readdirSync(LOCALE).map((locale) -> {locale})}))
61 .pipe(gulp.dest(DEST))
64 gulp.task('install.rdf', ->
65 pkg = require('./package.json')
67 [ [ { name: creator } ], developers, contributors, translators ] =
68 read('PEOPLE.md').trim().replace(/^#.+\n|^\s*-\s*/mg, '').split('\n\n')
69 .map((block) -> block.split('\n').map((name) -> {name}))
71 getDescription = (locale) -> read(join(LOCALE, locale, 'description')).trim()
73 descriptions = fs.readdirSync(LOCALE)
76 description: getDescription(locale)
79 gulp.src('extension/install.rdf.tmpl')
82 minVersion: pkg.firefoxVersions.min
83 maxVersion: pkg.firefoxVersions.max
84 creator, developers, contributors, translators
85 defaultDescription: getDescription('en-US')
88 .pipe(gulp.dest(DEST))
91 gulp.task('build', ['copy', 'coffee', 'chrome.manifest', 'install.rdf'])
93 gulp.task('xpi', ['build'], ->
94 gulp.src("#{ DEST }/**/!(#{ XPI })")
95 .pipe(zip(XPI, {compress: false}))
96 .pipe(gulp.dest(DEST))
99 gulp.task('push', ['xpi'], ->
100 body = fs.readFileSync(join(DEST, XPI))
101 request.post({url: 'http://localhost:8888', body })
105 gulp.src(['extension/**/*.coffee', 'gulpfile.coffee'])
107 .pipe(coffeelint.reporter())