Use package.json. Use grunt-bump. Fix exec with configs.

This commit is contained in:
Nicolas Stepien 2012-09-25 04:03:07 +02:00
parent 8f776c7182
commit fca313f582
5 changed files with 59 additions and 30 deletions

View File

@ -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 <james.r.campos@gmail.com>
@ -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,

View File

@ -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.

View File

@ -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: '<json:package.json>',
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 <james.r.campos@gmail.com>',
@ -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 <james.r.campos@gmail.com>',
'// @copyright <%= grunt.template.today("yyyy") %> Nicolas Stepien <stepien.nicolas@gmail.com>',
@ -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: '<config:meta.files.latestjs>'
}
},
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');
};

20
package.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "4chan-X-Alpha",
"version": "3.0.0",
"author": "Nicolas Stepien <stepien.nicolas@gmail.com>",
"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"
}
}

View File

@ -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: {}