From c9a45602e33be606fe8e83e193234ae4eaa3a3b7 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Tue, 2 Dec 2014 18:39:31 +0100 Subject: [PATCH] Replace Makefile with gulp --- .gitignore | 1 + CONTRIBUTING.md | 39 +++++++++++++++++---------- Makefile | 49 ---------------------------------- gulpfile.coffee | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 19 ++++++++++++++ 5 files changed, 115 insertions(+), 63 deletions(-) delete mode 100644 Makefile create mode 100644 gulpfile.coffee create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 74f77e3..25a56fe 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ node_modules *.js .DS_Store VimFx.xpi +build diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 85454e9..9d8e7dc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -79,6 +79,8 @@ Code! Try to follow the following simple rules: - Try to keep lines at most 80 characters long. - Indent using two spaces. +Please lint your code. See below. + Break up your pull request in several commits if necessary. The first line of commit messages should be a short summary. Add a blank line and then a nicely formatted markdown description after it if needed. @@ -86,17 +88,26 @@ formatted markdown description after it if needed. Finally send a pull request to same branch as you based your topic branch on (master or develop). -### Tips: - -- Compile the .coffee files with the **`--bare`** option! Otherwise you will - get errors. -- Run `coffee -cbw .` from the root of the project to automatically compile on - changes. -- Put a file called exactly `VimFx@akhodakivskiy.github.com` in the extensions/ - folder of a Firefox profile, containing the absolute path to the extension/ - folder in the project. Then you just need to restart Firefox (use some - add-on!) after each change. More details in this [MDN article][mdn-extdevenv]. -- Only create tickets for issues and feature requests in English. Otherwise - duplicate tickets in different languages will pile up. - -[mdn-extdevenv]: https://developer.mozilla.org/en-US/docs/Setting_up_extension_development_environment#Firefox_extension_proxy_file +### Building VimFx + +1. Install [Node.js]. +2. Run `npm install` to download dependencies and development dependencies. +3. Run `npm install -g gulp` to be able to run [`gulp`][gulp] commands. + (Alternatively, you may use `./node_modules/.bin/gulp`.) +4. Create a new Firefox profile for development. +5. Install the [Extension Auto-Installer] add-on in your development profile. + +- `gulp build` creates the `build/` directory. It is basically a copy of the + `extension/` directory, with the .coffee files compiled to .js. +- `gulp xpi` zips up the `build/` directory into `build/VimFx.xpi`. +- `gulp push` (or just `gulp`) pushes `build/VimFx.xpi` to + `http://localhost:8888`, which causes the Extension Auto-Installer to + automatically install it. (No need to restart Firefox.) +- `gulp clean` removes the `build/` directory. +- `gulp lint` lints your code. + +An easy workflow is code, `gulp`, test, repeat. + +[Node.js]: http://nodejs.org/ +[gulp]: https://github.com/gulpjs/gulp +[Extension Auto-Installer]: https://addons.mozilla.org/firefox/addon/autoinstaller diff --git a/Makefile b/Makefile deleted file mode 100644 index a0f05c1..0000000 --- a/Makefile +++ /dev/null @@ -1,49 +0,0 @@ -.DEFAULT: all -.PHONY: clean lint release - -V=@ - -plugin_archive := VimFx.xpi - -coffee_files = extension/bootstrap.coffee -coffee_files += $(shell find extension/packages -type f -name '*.coffee') - -js_files = $(coffee_files:.coffee=.js) - -zip_files = chrome.manifest icon.png install.rdf options.xul resources locale defaults -zip_files += $(subst extension/,,$(js_files)) - -all: clean gen zip - $(V)echo "Done dev" - -release: clean gen min zip - $(V)echo "Done release" - -min: say-min $(js_files:.js=.min.js) - -say-min: - $(V)echo "Minifing js files…" - -%.min.js: %.js - $(V)uglifyjs $< --screw-ie8 -c -m -o $< - -lint: - $(V)echo "Running coffeescript lint…" - $(V)coffeelint -f lint-config.json $(coffee_files) - -zip: $(plugin_archive) - -$(plugin_archive): $(addprefix extension/,$(zip_files)) - $(V)echo "Creating archive…" - $(V)cd extension && zip -qr ../$(plugin_archive) $(zip_files) - -gen: $(js_files) - -$(js_files): - $(V)echo "Generating js files…" - $(V)coffee -c --bare $(coffee_files) - -clean: - $(V)echo "Performing clean…" - $(V)rm -f ./$(plugin_archive) - $(V)rm -f $(js_files) diff --git a/gulpfile.coffee b/gulpfile.coffee new file mode 100644 index 0000000..f9429d7 --- /dev/null +++ b/gulpfile.coffee @@ -0,0 +1,70 @@ +### +# Copyright Simon Lydell 2014. +# +# This file is part of VimFx. +# +# VimFx is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# VimFx is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with VimFx. If not, see . +### + +fs = require('fs') +path = require('path') +request = require('request') +gulp = require('gulp') +gutil = require('gutil') +changed = require('gulp-changed') +coffee = require('gulp-coffee') +coffeelint = require('gulp-coffeelint') +zip = require('gulp-zip') +rimraf = require('rimraf') + +DEST = 'build' +XPI = 'VimFx.xpi' + +gulp.task('default', ['push']) + +gulp.task('clean', (callback) -> + rimraf(DEST, callback) +) + +gulp.task('copy', -> + gulp.src(['extension/**/!(*.coffee)', 'COPYING']) + .pipe(changed(DEST)) + .pipe(gulp.dest(DEST)) +) + +gulp.task('coffee', -> + gulp.src('extension/**/*.coffee') + .pipe(changed(DEST, {extension: '.coffee'})) + .pipe(coffee({bare: true}).on('error', gutil.log)) + .pipe(gulp.dest(DEST)) +) + +gulp.task('build', ['copy', 'coffee']) + +gulp.task('xpi', ['build'], -> + gulp.src("#{ DEST }/**/!(#{ XPI })") + .pipe(zip(XPI, {compress: false})) + .pipe(gulp.dest(DEST)) +) + +gulp.task('push', ['xpi'], -> + body = fs.readFileSync(path.join(DEST, XPI)) + request.post({url: 'http://localhost:8888', body }) +) + +gulp.task('lint', -> + gulp.src(['extension/**/*.coffee', 'gulpfile.coffee']) + .pipe(coffeelint()) + .pipe(coffeelint.reporter()) +) diff --git a/package.json b/package.json new file mode 100644 index 0000000..a9862f9 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "VimFx", + "version": "0.5.14", + "license": "GPLv3", + "private": true, + "scripts": {}, + "dependencies": {}, + "devDependencies": { + "coffee-script": "~1.8.0", + "gulp": "^3.8.10", + "gulp-changed": "^1.0.0", + "gulp-coffee": "^2.2.0", + "gulp-coffeelint": "^0.4.0", + "gulp-zip": "^2.0.2", + "gutil": "^1.5.5", + "request": "^2.49.0", + "rimraf": "^2.2.8" + } +} -- 2.39.3