From fca313f5827ffc65418c90f6904183230bc9b60f Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 25 Sep 2012 04:03:07 +0200 Subject: [PATCH] Use package.json. Use grunt-bump. Fix exec with configs. --- 4chan_x.user.js | 3 +-- CONTRIBUTING.md | 8 +++---- grunt.js | 54 +++++++++++++++++++++++++++------------------- package.json | 20 +++++++++++++++++ src/globals.coffee | 4 ++-- 5 files changed, 59 insertions(+), 30 deletions(-) create mode 100644 package.json diff --git a/4chan_x.user.js b/4chan_x.user.js index b13afe409..730f0a77f 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -20,7 +20,7 @@ // @icon https://github.com/MayhemYDG/4chan-x/raw/stable/img/icon.gif // ==/UserScript== -/* 4chan X Alpha - Version 3.0.0 - 2012-09-24 +/* 4chan X Alpha - Version 3.0.0 - 2012-09-25 * http://mayhemydg.github.com/4chan-x/ * * Copyright (c) 2009-2011 James Campos @@ -42,7 +42,6 @@ * Thank you. */ -// Generated by CoffeeScript 1.3.3 (function() { var $, $$, AutoGIF, Board, Build, Clone, Conf, Config, FileInfo, Get, ImageHover, Main, Post, QuoteBacklink, QuoteCT, QuoteInline, QuoteOP, QuotePreview, Quotify, Redirect, RevealSpoilers, Sauce, Thread, ThreadUpdater, Time, UI, d, g, __hasProp = {}.hasOwnProperty, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bc094ba27..df1bdbff8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,10 +18,8 @@ Open your console with: - Clone 4chan X. - `cd` into it. - Install [node.js](http://nodejs.org/). -- Install [CoffeeScript](http://coffeescript.org/) with `npm install -g coffee-script`. - Install [Grunt](http://gruntjs.com/) with `npm install -g grunt`. -- Install [grunt-exec](https://npmjs.org/package/grunt-exec) with `npm install grunt-exec`. -- Install [grunt-image-embed](https://npmjs.org/package/grunt-image-embed) with `npm install grunt-image-embed`. +- Install 4chan X dependencies with `npm install`. ### Build @@ -30,7 +28,9 @@ Open your console with: ### Release -- To upgrade, edit the version in `grunt.js` and run `grunt upgrade`. +- To patch, run `grunt patch` (`0.0.x` version bump). +- To upgrade, run `grunt upgrade` (`0.x.0` version bump). +- Release with `grunt release`. Note: this is only used to release new 4chan X versions, and is not needed or wanted in pull requests. diff --git a/grunt.js b/grunt.js index 8e9f13beb..0f441e96b 100644 --- a/grunt.js +++ b/grunt.js @@ -1,19 +1,13 @@ module.exports = function(grunt) { - // Some tasks do not support directives. - var meta = { - name: '4chan X Alpha', - version: '3.0.0', - }; - // Project configuration. grunt.initConfig({ + pkg: '', meta: { - name: meta.name, - version: meta.version, + name: '<%= pkg.name.replace(/-/g, " ") %>', repo: 'https://github.com/MayhemYDG/4chan-x/', banner: [ - '/* <%= meta.name %> - Version <%= meta.version %> - <%= grunt.template.today("yyyy-mm-dd") %>', + '/* <%= meta.name %> - Version <%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>', ' * http://mayhemydg.github.com/4chan-x/', ' *', ' * Copyright (c) 2009-2011 James Campos ', @@ -38,7 +32,7 @@ module.exports = function(grunt) { metadataBlock: [ '// ==UserScript==', '// @name <%= meta.name %>', - '// @version <%= meta.version %>', + '// @version <%= pkg.version %>', '// @description Adds various features.', '// @copyright 2009-2011 James Campos ', '// @copyright <%= grunt.template.today("yyyy") %> Nicolas Stepien ', @@ -58,7 +52,7 @@ module.exports = function(grunt) { '// @icon <%= meta.repo %>raw/stable/img/icon.gif', '// ==/UserScript==' ].join('\n'), - latest: 'document.dispatchEvent(new CustomEvent("<%= meta.name.replace(/ /g, "") %>Update",{detail:{v:"<%= meta.version %>"}}))', + latest: 'document.dispatchEvent(new CustomEvent("<%= pkg.name.replace(/-/g, "") %>Update",{detail:{v:"<%= pkg.version %>"}}))', files: { metajs: '4chan_x.meta.js', userjs: '4chan_x.user.js', @@ -90,17 +84,29 @@ module.exports = function(grunt) { dest: '' } }, + coffee: { + all: { + src: 'tmp/script.coffee', + dest: 'tmp/script.js' + }, + }, exec: { - coffee: { - command: 'coffee --compile tmp/script.coffee', + commit: { + command: function(grunt) { + var name, version; + name = grunt.config(['pkg', 'name']).replace(/-/g, ' '); + version = grunt.config(['pkg', 'version']); + return [ + 'git checkout master', + 'git commit -am "Release ' + name + ' v' + version + '."', + 'git tag -a ' + version + ' -m "' + version + '"', + 'git tag -af stable -m "' + version + '"' + ].join(' && '); + }, stdout: true }, - commit: { - command: [ - 'git commit -am "Release ' + meta.name + ' v' + meta.version + '."', - 'git tag -a ' + meta.version + ' -m "' + meta.version + '"', - 'git tag -af stable -m "' + meta.version + '"' - ].join(' && '), + push: { + command: 'git push && git push --tags', stdout: true }, clean: { @@ -109,13 +115,17 @@ module.exports = function(grunt) { }, watch: { files: ['grunt.js', 'lib/**/*.coffee', 'src/**/*.coffee', 'css/**/*.css', 'img/*'], - tasks: 'coffee concat:build' + tasks: 'default' } }); + grunt.loadNpmTasks('grunt-bump'); + grunt.loadNpmTasks('grunt-contrib-coffee'); grunt.loadNpmTasks('grunt-exec'); - grunt.registerTask('default', 'concat:coffee exec:coffee concat:js exec:clean'); - grunt.registerTask('upgrade', 'concat:meta concat:latest default exec:commit'); + grunt.registerTask('default', 'concat:coffee coffee concat:js exec:clean'); + grunt.registerTask('release', 'concat:meta concat:latest default exec:commit exec:push'); + grunt.registerTask('patch', 'bump'); + grunt.registerTask('upgrade', 'bump:minor'); }; diff --git a/package.json b/package.json new file mode 100644 index 000000000..49e49d02f --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "4chan-X-Alpha", + "version": "3.0.0", + "author": "Nicolas Stepien ", + "description": "Cross-browser userscript for maximum lurking on 4chan.", + "repository": { + "type": "git", + "url": "https://github.com/MayhemYDG/4chan-x.git" + }, + "dependencies": { + "grunt-bump": "0.0.x", + "grunt-contrib-coffee": "0.3.x", + "grunt-exec": "0.3.x", + "grunt-image-embed": "0.0.x" + }, + "license": "MIT", + "engines": { + "node": ">=0.8" + } +} diff --git a/src/globals.coffee b/src/globals.coffee index 5216f7621..3240504f0 100644 --- a/src/globals.coffee +++ b/src/globals.coffee @@ -5,8 +5,8 @@ return unless /^(boards|images|sys)\.4chan\.org$/.test location.hostname Conf = {} d = document g = - VERSION: '<%= meta.version %>' - NAMESPACE: "<%= meta.name.replace(/ /g, '_') %>." + VERSION: '<%= pkg.version %>' + NAMESPACE: "<%= pkg.name.replace(/-/g, '_') %>." boards: {} threads: {} posts: {}