Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Tasks merged back into single Gruntfile

  • Loading branch information...
commit 54129be8e0801dbc3f97952f82294d664e166f5c 1 parent 4525073
@inossidabile inossidabile authored
View
132 Gruntfile.coffee
@@ -1,5 +1,8 @@
require 'sugar'
+Mincer = require 'mincer'
+semver = require 'semver'
+
module.exports = (grunt) ->
#
# Common settings
@@ -29,7 +32,6 @@ module.exports = (grunt) ->
#
# Grunt extensions
#
- grunt.loadTasks 'lib/tasks'
grunt.loadNpmTasks 'grunt-contrib-testem'
grunt.loadNpmTasks 'grunt-coffeelint'
grunt.loadNpmTasks 'grunt-release'
@@ -111,3 +113,131 @@ module.exports = (grunt) ->
grunt.task.run if @args[0] then "testem:run:#{@args[0]}" else 'testem'
grunt.registerTask 'publish', ['testem', 'publish:ensureCommits', 'doc', 'release', 'publish:gem']
+
+
+ #
+ # Building
+ #
+ grunt.registerMultiTask 'mince', ->
+ Mincer.CoffeeEngine.configure bare: false
+ environment = new Mincer.Environment
+ environment.appendPath x for x in @data.include
+ grunt.file.write @data.dest, environment.findAsset(@data.src).toString()
+
+ grunt.registerTask 'bowerize', ->
+ bower = require 'bower.json'
+ meta = require 'package.json'
+
+ bower.version = meta.version
+ grunt.file.write 'bower.json', JSON.stringify(bower, null, 2)
+
+ #
+ # Publishing
+ #
+ grunt.registerTask 'publish:ensureCommits', ->
+ complete = @async()
+
+ grunt.util.spawn {cmd: "git", args: ["status", "--porcelain" ]}, (error, result) ->
+ if !!error || result.stdout.length > 0
+ console.log ""
+ console.log "Uncommited changes found. Please commit prior to release or use `--force`.".bold
+ console.log ""
+ complete false
+ else
+ complete true
+
+ grunt.registerTask 'publish:gem', ->
+ meta = require 'package.json'
+ complete = @async()
+
+ grunt.util.spawn {cmd: "gem", args: ["build", "joosy.gemspec"]}, (error, result) ->
+ return complete false if error
+
+ gem = "joosy-#{meta.version.replace('-', '.')}.gem"
+ grunt.log.ok "Built #{gem}"
+
+ grunt.util.spawn {cmd: "gem", args: ["push", gem]}, (error, result) ->
+ return complete false if error
+ grunt.log.ok "Published #{gem}"
+ grunt.file.delete gem
+ complete(true)
+
+ #
+ # Documentation
+ #
+ grunt.registerTask 'doc', ['doc:prepare', 'doc:generate']
+
+ grunt.registerTask 'doc:generate', ->
+ complete = @async()
+ version = JSON.parse(grunt.file.read 'package.json').version.split('-')
+ version = version[0]+'-'+version[1]?.split('.')[0]
+ destination = "doc/#{version}"
+ args = ['source', '--output-dir', destination]
+
+ git = (args, callback) ->
+ grunt.util.spawn {cmd: "git", args: args, opts: {stdio: [0,1,2], cwd: 'doc'}}, callback
+
+ date = (version) ->
+ return undefined unless version
+ Date.create(grunt.file.read "doc/#{version}/DATE").format "{d} {Month} {yyyy}"
+
+ git ['pull'], (error, result) ->
+ grunt.fatal "Error pulling from git" if error
+
+ grunt.file.delete destination if grunt.file.exists destination
+ grunt.util.spawn {cmd: "codo", args: args, opts: {stdio: [0,1,2]}}, (error, result) ->
+ grunt.fatal "Error generating docs" if error
+ grunt.file.write "#{destination}/DATE", (new Date).toISOString()
+
+ versions = []
+ for version in grunt.file.expand({cwd: 'doc'}, '*')
+ versions.push version if semver.valid(version)
+
+ versions = versions.sort(semver.rcompare)
+ edge = versions.find (x) -> x.has('-')
+ stable = versions.find (x) -> !x.has('-')
+ versions = versions.remove edge, stable
+
+ versions = {
+ edge:
+ version: edge
+ date: date(edge)
+ stable:
+ version: stable
+ date: date(stable)
+ versions: versions.map (x) -> { version: x, date: date(x) }
+ }
+ grunt.file.write 'doc/versions.js', "window.versions = #{JSON.stringify(versions)}"
+
+ git ['add', '-A'], (error, result) ->
+ grunt.fatal "Error adding files" if error
+
+ git ['commit', '-m', "Updated at #{(new Date).toISOString()}"], (error, result) ->
+ grunt.fatal "Error commiting" if error
+
+ git ['push', 'origin', 'gh-pages'], (error, result) ->
+ grunt.fatal "Error pushing" if error
+ complete()
+
+ grunt.registerTask 'doc:prepare', ->
+ if grunt.file.exists 'doc'
+ unless grunt.file.exists 'doc/.git'
+ grunt.fatal "Documentation directory exists. Please remove it"
+ else
+ return
+
+ complete = @async()
+
+ base = process.cwd()
+ git = (args, callback) ->
+ grunt.util.spawn {cmd: "git", args: args, opts: {stdio: [0,1,2]}}, callback
+
+ git ["clone", "git@github.com:joosy/joosy.git", "doc"], (error, result) ->
+ grunt.fatal "Erorr cloning repo" if error
+ process.chdir 'doc'
+
+ git ["checkout", "gh-pages"], (error, result) ->
+ grunt.fatal "Erorr checking branch out" if error
+
+ process.chdir base
+ complete()
View
16 lib/tasks/build.coffee
@@ -1,16 +0,0 @@
-Mincer = require 'mincer'
-
-module.exports = (grunt) ->
-
- grunt.registerMultiTask 'mince', ->
- Mincer.CoffeeEngine.configure bare: false
- environment = new Mincer.Environment
- environment.appendPath x for x in @data.include
- grunt.file.write @data.dest, environment.findAsset(@data.src).toString()
-
- grunt.registerTask 'bowerize', ->
- bower = require '../../bower.json'
- meta = require '../../package.json'
-
- bower.version = meta.version
- grunt.file.write 'bower.json', JSON.stringify(bower, null, 2)
View
80 lib/tasks/doc.coffee
@@ -1,80 +0,0 @@
-semver = require 'semver'
-
-module.exports = (grunt) ->
-
- grunt.registerTask 'doc', ['doc:prepare', 'doc:generate']
-
- grunt.registerTask 'doc:generate', ->
- complete = @async()
- version = JSON.parse(grunt.file.read 'package.json').version.split('-')
- version = version[0]+'-'+version[1]?.split('.')[0]
- destination = "doc/#{version}"
- args = ['source', '--output-dir', destination]
-
- git = (args, callback) ->
- grunt.util.spawn {cmd: "git", args: args, opts: {stdio: [0,1,2], cwd: 'doc'}}, callback
-
- date = (version) ->
- return undefined unless version
- Date.create(grunt.file.read "doc/#{version}/DATE").format "{d} {Month} {yyyy}"
-
- git ['pull'], (error, result) ->
- grunt.fatal "Error pulling from git" if error
-
- grunt.file.delete destination if grunt.file.exists destination
- grunt.util.spawn {cmd: "codo", args: args, opts: {stdio: [0,1,2]}}, (error, result) ->
- grunt.fatal "Error generating docs" if error
- grunt.file.write "#{destination}/DATE", (new Date).toISOString()
-
- versions = []
- for version in grunt.file.expand({cwd: 'doc'}, '*')
- versions.push version if semver.valid(version)
-
- versions = versions.sort(semver.rcompare)
- edge = versions.find (x) -> x.has('-')
- stable = versions.find (x) -> !x.has('-')
- versions = versions.remove edge, stable
-
- versions = {
- edge:
- version: edge
- date: date(edge)
- stable:
- version: stable
- date: date(stable)
- versions: versions.map (x) -> { version: x, date: date(x) }
- }
- grunt.file.write 'doc/versions.js', "window.versions = #{JSON.stringify(versions)}"
-
- git ['add', '-A'], (error, result) ->
- grunt.fatal "Error adding files" if error
-
- git ['commit', '-m', "Updated at #{(new Date).toISOString()}"], (error, result) ->
- grunt.fatal "Error commiting" if error
-
- git ['push', 'origin', 'gh-pages'], (error, result) ->
- grunt.fatal "Error pushing" if error
- complete()
-
- grunt.registerTask 'doc:prepare', ->
- if grunt.file.exists 'doc'
- unless grunt.file.exists 'doc/.git'
- grunt.fatal "Documentation directory exists. Please remove it"
- else
- return
-
- complete = @async()
-
- base = process.cwd()
- git = (args, callback) ->
- grunt.util.spawn {cmd: "git", args: args, opts: {stdio: [0,1,2]}}, callback
-
- git ["clone", "git@github.com:joosy/joosy.git", "doc"], (error, result) ->
- grunt.fatal "Erorr cloning repo" if error
- process.chdir 'doc'
-
- git ["checkout", "gh-pages"], (error, result) ->
- grunt.fatal "Erorr checking branch out" if error
-
- process.chdir base
- complete()
View
29 lib/tasks/publish.coffee
@@ -1,29 +0,0 @@
-module.exports = (grunt) ->
-
- grunt.registerTask 'publish:ensureCommits', ->
- complete = @async()
-
- grunt.util.spawn {cmd: "git", args: ["status", "--porcelain" ]}, (error, result) ->
- if !!error || result.stdout.length > 0
- console.log ""
- console.log "Uncommited changes found. Please commit prior to release or use `--force`.".bold
- console.log ""
- complete false
- else
- complete true
-
- grunt.registerTask 'publish:gem', ->
- meta = require '../../package.json'
- complete = @async()
-
- grunt.util.spawn {cmd: "gem", args: ["build", "joosy.gemspec"]}, (error, result) ->
- return complete false if error
-
- gem = "joosy-#{meta.version.replace('-', '.')}.gem"
- grunt.log.ok "Built #{gem}"
-
- grunt.util.spawn {cmd: "gem", args: ["push", gem]}, (error, result) ->
- return complete false if error
- grunt.log.ok "Published #{gem}"
- grunt.file.delete gem
- complete(true)
Please sign in to comment.
Something went wrong with that request. Please try again.