Permalink
Browse files

Reorganize & switch to Grunt

  • Loading branch information...
1 parent 40c56e6 commit 16652cbeaf307792b578fb63abcbc6d3ede8bcef @andreyvit andreyvit committed Jan 20, 2015
View
@@ -2,7 +2,7 @@ node_modules
LiveReload.safariextension/*.js
Chrome/LiveReload/*.js
Firefox/content/*.js
-interim/*.js
+lib/**.js
/dist
/update/McCoy
/Chrome/*.pem
@@ -3,7 +3,6 @@
<head>
<meta charset="utf-8">
<script src="devtools.js"></script>
- <script src="devtools-chrome.js"></script>
</head>
<body>
</body>
@@ -5,7 +5,6 @@
"background": {
"scripts": [
"global.js",
- "global-chrome.js"
]
},
"content_scripts": [
View
@@ -0,0 +1,73 @@
+module.exports = function(grunt) {
+
+ grunt.initConfig({
+ pkg: grunt.file.readJSON('package.json'),
+
+ coffee: {
+ src: {
+ expand: true,
+ cwd: 'src',
+ src: '**/*.coffee',
+ dest: 'lib',
+ ext: '.js'
+ }
+ },
+
+ browserify: {
+ safari: {
+ files: {
+ 'LiveReload.safariextension/global.js': ['lib/safari/global.js'],
+ 'LiveReload.safariextension/injected.js': ['lib/safari/injected.js']
+ }
+ },
+ chrome: {
+ files: {
+ 'Chrome/LiveReload/global.js': ['lib/chrome/global.js'],
+ 'Chrome/LiveReload/injected.js': ['lib/chrome/injected.js'],
+ 'Chrome/LiveReload/devtools.js': ['lib/chrome/devtools.js']
+ }
+ },
+ firefox: {
+ files: {
+ 'Firefox/content/firefox.js': ['lib/firefox/firefox.js']
+ }
+ }
+ },
+
+ compress: {
+ options: {
+ pretty: true,
+ level: 9,
+ },
+ chrome: {
+ options: {
+ archive: 'dist/<%= pkg.version %>/LiveReload-<%= pkg.version %>-ChromeWebStore.zip'
+ },
+ files: [
+ { expand: true, cwd: 'Chrome/LiveReload', src: ['**.{json,js,html,png}'], dest: 'LiveReload/' }
+ ]
+ },
+ firefox: {
+ options: {
+ archive: 'dist/<%= pkg.version %>/LiveReload-<%= pkg.version %>.xpi',
+ mode: 'zip'
+ },
+ files: [
+ { expand: true, cwd: 'Firefox', src: ['**/*.{js,xul,manifest,rdf,png}'], dest: '/' }
+ ]
+ }
+ }
+ });
+
+ grunt.loadNpmTasks('grunt-contrib-coffee');
+ grunt.loadNpmTasks('grunt-browserify');
+ grunt.loadNpmTasks('grunt-contrib-compress');
+
+ grunt.registerTask('build', ['coffee', 'browserify']);
+ grunt.registerTask('default', ['build']);
+
+ grunt.registerTask('chrome', ['coffee', 'browserify:chrome', 'compress:chrome']);
+ grunt.registerTask('firefox', ['coffee', 'browserify:firefox', 'compress:firefox']);
+ grunt.registerTask('all', ['chrome', 'firefox']);
+
+};
@@ -3,7 +3,6 @@
<head>
<meta charset="utf-8">
<script src="global.js"></script>
- <script src="global-safari.js"></script>
</head>
<body>
</body>
View
@@ -0,0 +1,44 @@
+LiveReload Browser Extensions
+=============================
+
+Prerequsities:
+
+* Node.js (0.10.x or later) with npm
+
+Install dependencies:
+
+* `npm install`
+
+Build and package extensions:
+
+ grunt chrome
+ grunt firefox
+ grunt all
+
+(Safari extension must be built manually, using Safari's GUI packager tool.)
+
+Build CoffeeScript modules, but don't pack:
+
+ grunt build
+
+
+Release checklist
+-----------------
+
+1. Bump version number in `package.json`, commit.
+
+1. `grunt all`
+
+1. Package Safari extension.
+
+1. Test, test, test.
+
+1. `rake tag`
+
+1. `rake upload:safari`, `rake upload:firefox` or `rake upload:all`
+
+1. Download and verify that uploads worked.
+
+1. `rake upload:manifest`
+
+1. Publish Chrome extension on the Chrome Web Store.
View
@@ -1,29 +1,17 @@
-require 'rake/clean'
-
VERSION_FILES = %w(
- src/global.coffee
- src/injected.coffee
+ src/common/version.coffee
LiveReload.safariextension/Info.plist
Chrome/LiveReload/manifest.json
Firefox/install.rdf
)
-def coffee dst, src
- sh 'coffee', '-c', '-b', '-o', File.dirname(dst), src
-end
-
-def browserify dst, src
- sh 'node_modules/.bin/browserify', '-t', 'coffeeify', src, '-o', dst
-end
-
-def concat dst, *srcs
- puts 'cat >' +dst
- text = srcs.map { |src| File.read(src).rstrip + "\n" }
- File.open(dst, 'w') { |f| f.puts text }
-end
-
def version
- File.read('VERSION').strip
+ content = File.read('package.json')
+ if content =~ /"version": "(\d+\.\d+\.\d+)"/
+ return $1
+ else
+ raise "Failed to get version info from package.json"
+ end
end
def subst_version_refs_in_file file, ver
@@ -48,126 +36,12 @@ def subst_version_refs_in_file file, ver
File.open(file, 'w') { |f| f.write data }
end
-
-file 'LiveReload.safariextension/global.js' => ['src/global.coffee'] do |task|
- browserify task.name, task.prerequisites.first
-end
-
-file 'LiveReload.safariextension/global-safari.js' => ['src/global-safari.coffee'] do |task|
- coffee task.name, task.prerequisites.first
-end
-
-file 'interim/injected.js' => ['src/injected.coffee'] do |task|
- coffee task.name, task.prerequisites.first
-end
-
-file 'interim/injected-safari.js' => ['src/injected-safari.coffee'] do |task|
- coffee task.name, task.prerequisites.first
-end
-
-file 'interim/injected-chrome.js' => ['src/injected-chrome.coffee'] do |task|
- coffee task.name, task.prerequisites.first
-end
-
-file 'LiveReload.safariextension/injected.js' => ['interim/injected.js', 'interim/injected-safari.js'] do |task|
- concat task.name, *task.prerequisites
-end
-
-file 'Chrome/LiveReload/global.js' => ['src/global.coffee'] do |task|
- browserify task.name, task.prerequisites.first
-end
-
-file 'Chrome/LiveReload/global-chrome.js' => ['src/global-chrome.coffee'] do |task|
- coffee task.name, task.prerequisites.first
-end
-
-file 'Chrome/LiveReload/devtools.js' => ['src/devtools.coffee'] do |task|
- coffee task.name, task.prerequisites.first
-end
-
-file 'Chrome/LiveReload/devtools-chrome.js' => ['src/devtools-chrome.coffee'] do |task|
- coffee task.name, task.prerequisites.first
-end
-
-file 'Chrome/LiveReload/injected.js' => ['interim/injected.js', 'interim/injected-chrome.js'] do |task|
- concat task.name, *task.prerequisites
-end
-
-file 'Firefox/content/global.js' => ['src/global.coffee'] do |task|
- browserify task.name, task.prerequisites.first
-end
-file 'Firefox/content/injected.js' => ['src/injected.coffee'] do |task|
- coffee task.name, task.prerequisites.first
-end
-file 'Firefox/content/firefox.js' => ['src/firefox.coffee'] do |task|
- coffee task.name, task.prerequisites.first
-end
-
-FIREFOX_SRC = FileList['Firefox/**/*.{js,xul,manifest,rdf,png}']
-FIREFOX_SRC.include %w(Firefox/content/global.js Firefox/content/injected.js Firefox/content/firefox.js)
-
-file "dist/LiveReload-#{version}.xpi" => FIREFOX_SRC do |task|
-end
-
-desc "Build Firefox extension"
-task :firefox => FIREFOX_SRC do |task|
- mkdir_p "dist/#{version}"
- dest = "dist/#{version}/LiveReload-#{version}.xpi"
- full_dest = File.expand_path(dest)
- rm full_dest if File.exists?(full_dest)
- Dir.chdir 'Firefox' do
- sh 'zip', full_dest, *task.prerequisites.map { |f| f.sub(%r!^Firefox/!, '') }
- end
- sh 'open', '-R', full_dest
-end
-
-desc "Zip Chrome extension for the Chrome Web Store"
-task :chrome => :build do |task|
- mkdir_p "dist/#{version}"
- dest = "dist/#{version}/LiveReload-#{version}-ChromeWebStore.zip"
- full_dest = File.expand_path(dest)
- rm full_dest if File.exists?(full_dest)
- Dir.chdir 'Chrome' do
- sh 'zip', '-r', full_dest, 'LiveReload'
- end
- sh 'open', '-R', full_dest
-end
-
-desc "Build Firefox and Chrome extensions"
-task :all => [:chrome, :firefox]
-
-
desc "Embed version number where it belongs"
task :version do
ver = version
VERSION_FILES.each { |file| subst_version_refs_in_file(file, ver) }
- Rake::Task[:build].invoke
-end
-
-desc "Increase version number"
-task :bump do
- prev = version
- components = File.read('VERSION').strip.split('.')
- components[-1] = (components[-1].to_i + 1).to_s
- File.open('VERSION', 'w') { |f| f.write "#{components.join('.')}\n" }
- puts "#{prev} => #{version}"
- Rake::Task[:version].invoke
end
-desc "Build all files"
-task :build => [
- 'LiveReload.safariextension/global.js',
- 'LiveReload.safariextension/global-safari.js',
- 'LiveReload.safariextension/injected.js',
- 'Chrome/LiveReload/global.js',
- 'Chrome/LiveReload/global-chrome.js',
- 'Chrome/LiveReload/devtools.js',
- 'Chrome/LiveReload/devtools-chrome.js',
- 'Chrome/LiveReload/injected.js',
- 'Firefox/content/global.js',
- 'Firefox/content/injected.js',
- 'Firefox/content/firefox.js',
-]
def upload_file file, folder='dist'
path = "#{folder}/#{file}"
@@ -215,19 +89,3 @@ desc "Move (git tag -f) the tag for the current version"
task :retag do
sh 'git', 'tag', '-f', "v#{version}"
end
-
-task :default => :build
-
-CLEAN.push *[
- 'interim/injected.js',
- 'interim/injected-safari.js',
- 'interim/injected-chrome.js',
-]
-CLOBBER.push *[
- 'LiveReload.safariextension/global.js',
- 'LiveReload.safariextension/global-safari.js',
- 'LiveReload.safariextension/injected.js',
- 'Chrome/LiveReload/global.js',
- 'Chrome/LiveReload/global-chrome.js',
- 'Chrome/LiveReload/injected.js',
-]
View
@@ -1 +0,0 @@
-2.0.9
View
@@ -2,18 +2,18 @@
"author": "Andrey Tarantsov <andrey@tarantsov.com>",
"name": "livereload-extensions",
"description": "LiveReload browser extensions (not meant to be installed; npm is used for dependencies only)",
- "version": "2.0.8",
+ "version": "2.0.9",
"private": true,
"repository": {
"type": "git",
"url": "git://github.com/livereload/livereload-extensions.git"
},
- "dependencies": {
- "livereload-client": "=0.1.1"
- },
+ "dependencies": {},
"devDependencies": {
- "browserify": "^8.0.3",
- "coffeeify": "^1.0.0"
+ "grunt": "^0.4.5",
+ "grunt-browserify": "^3.3.0",
+ "grunt-contrib-coffee": "^0.12.0",
+ "grunt-contrib-compress": "^0.13.0"
},
"optionalDependencies": {},
"engines": {
@@ -1,3 +1,4 @@
+require('../common/devtools')
class DevTools
@@ -1,3 +1,4 @@
+{ LiveReloadGlobal, TabState } = require('../common/global')
TabState::send = (message, data={}) ->
chrome.tabs.sendMessage @tab, [message, data]
@@ -1,3 +1,4 @@
+{ LiveReloadInjected } = require('../common/injected')
LiveReloadInjected::send = (message, data) ->
chrome.runtime.sendMessage [message, data]
File renamed without changes.
@@ -1,6 +1,6 @@
# LRClient = require 'livereload-client'
-ExtVersion = '2.0.9'
+ExtVersion = require('./version')
Status =
unavailable:
@@ -218,5 +218,5 @@ LiveReloadGlobal =
# @client.open()
-window.TabState = TabState
-window.LiveReloadGlobal = LiveReloadGlobal
+exports.TabState = TabState
+exports.LiveReloadGlobal = LiveReloadGlobal
Oops, something went wrong.

0 comments on commit 16652cb

Please sign in to comment.