Commit 94a60a48 authored by Tristan Cavelier's avatar Tristan Cavelier

Replace grunt by makefile: see description

Grunt is not used anymore. Why?
Grunt is realy useful when you want to do some tasks to several files,
like jslint src/**/*.js. But in this case, each files have their own
specific dependencies. For instance, davstorage has jIO, jQuery and Base64,
revisionstorage has jIO and hex_sha256, jio.outro needs hex_md5, etc.
Why use a Makefile?
- All developers know Makefiles
- We can choose a task by typing "make <task>"
- It is more extensible than grunt
- It removes grunt dependency
parent 15509d82
OUT = jio.js
UGLY_OUT = jio.min.js
LINT_CMD = jslint --terse --indent 2 --maxlen 80
UGLIFY_CMD = uglifyjs
FILE_DIR = src/jio
STORAGE_DIR = src/jio.storage
# The order is important!
LINT_FILES = exceptions jio.intro storages/* commands/* jobs/status/* jobs/job announcements/announcement activityUpdater announcements/announcer jobs/jobIdHandler jobs/jobManager jobs/jobRules jio.outro jioNamespace
FILES = intro $(LINT_FILES) outro
STORAGE_FILES = *
auto: build lint
build: concat uglify
# concat source FILES to build jio.js
concat:
cat $(FILES:%=$(FILE_DIR)/%.js) > "$(OUT)"
# uglify jio.js to build jio.min.js
uglify:
$(UGLIFY_CMD) -- "$(OUT)" > "$(UGLY_OUT)"
# lint all files in FILES and STORAGE_FILES
# command: jslint [options] file
# [options] are defined in the source file:
# The file can contain a line beginning by:
# // -*- jslint: [options] -*-
# If there is several such lines, only the first is used. Example:
# // -*- jslint: --sloppy --maxlen 80 --predef hex_sha256 -*-
lint:
bash -c "result=0 ; for file in $(LINT_FILES:%=$(FILE_DIR)/%.js) $(STORAGE_FILES:%=$(STORAGE_DIR)/%.js) ; do out=\"\$$($(LINT_CMD) \$$(grep '^// *-\*- *jslint: .* -\*-' \$$file | head -1 | sed 's/^\/\/ *-\*- *jslint: \(.*\) -\*-/\1/') \$$file)\" ; res=\$$? ; [ \$$res != 0 ] && echo \"\$$out\" ; [ \$$res -gt \$$result ] && result=\$$res ; done ; exit \$$result ;"
.phony: clean
clean:
find -name '*~' -delete
realclean:
rm -f "$(OUT)"
rm -f "$(UGLY_OUT)"
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - '+
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> Nexedi;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
concat: {
dist: {
src: ['<banner:meta.banner>',
'<file_strip_banner:../../src/<%= pkg.name %>/intro.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/localstorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/davstorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/replicatestorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/indexstorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/cryptstorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/conflictmanagerstorage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/outro.js>'],
dest: '../../<%= pkg.name %>.js'
}
},
min: {
dist: {
src: ['<banner:meta.banner>', '<config:concat.dist.dest>'],
dest: '../../<%= pkg.name %>.min.js'
}
},
qunit: {
files: []
},
lint: {
files: ['grunt.js','../../<%= pkg.name %>.js']
},
watch: {
files: '<config:lint.files>',
tasks: 'lint'
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {
jQuery: true,
sjcl: true,
Base64: true,
MD5: true,
hex_sha256: true,
jIO: true,
console: true,
unescape: true,
// Needed to avoid "not defined error" with requireJs
define: true,
require: true,
// Needed to avoid "not defined error" with sinonJs
sinon: true,
module: true,
test: true,
ok: true,
deepEqual: true,
expect: true,
stop: true,
start: true,
equal: true
}
},
uglify: {}
});
// Default task.
grunt.registerTask('default', 'concat lint min');
};
{
"name": "jio.storage",
"title": "JIO Storage",
"description": "Javascript Input Output Storage",
"version": "0.1.0",
"homepage": "",
"author": {
"name": "Tristan Cavelier",
"email": "tristan.cavelier@tiolive.com"
},
"repository": {
"type": "git",
"url": "http://git.erp5.org/repos/jio.git"
},
"bugs": {
"url": ""
},
"licenses": [
],
"dependencies": {
"jquery": "~1.7"
},
"keywords": []
}
auto: grunt
grunt:
grunt
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: '<json:package.json>',
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - '+
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> Nexedi;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
concat: {
dist: {
src: ['<banner:meta.banner>',
// Wrapper top
'<file_strip_banner:../../src/<%= pkg.name %>/intro.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/exceptions.js>',
// Jio wrapper top
'<file_strip_banner:../../src/<%= pkg.name %>/jio.intro.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/storages/storage.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/command.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/allDocsCommand.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/getCommand.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/removeCommand.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/putAttachmentCommand.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/putCommand.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/commands/postCommand.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/jobStatus.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/doneStatus.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/failStatus.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/initialStatus.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/onGoingStatus.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/status/waitStatus.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/job.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/announcements/announcement.js>',
// Singletons
'<file_strip_banner:../../src/<%= pkg.name %>/activityUpdater.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/announcements/announcer.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/jobIdHandler.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/jobManager.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jobs/jobRules.js>',
// Jio wrappor bottem
'<file_strip_banner:../../src/<%= pkg.name %>/jio.outro.js>',
'<file_strip_banner:../../src/<%= pkg.name %>/jioNamespace.js>',
// Wrapper bottom
'<file_strip_banner:../../src/<%= pkg.name %>/outro.js>'],
dest: '../../<%= pkg.name %>.js'
}
},
min: {
dist: {
src: ['<banner:meta.banner>', '<config:concat.dist.dest>'],
dest: '../../<%= pkg.name %>.min.js'
}
},
qunit: {
files: [// '../../test/jiotests.html',
'../../test/jiotests_withoutrequirejs.html']
},
lint: {
files: ['grunt.js',
'../../<%= pkg.name %>.js']
// '../../js/base64.requirejs_module.js',
// '../../src/jio.dummystorages.js',
// '../../js/jquery.requirejs_module.js',
// '../../test/jiotests.js',
// '../../test/jiotests.loader.js']
},
watch: {
files: '<config:lint.files>',
tasks: 'lint qunit'
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {
hex_md5: true,
console: true,
unescape: true,
// Needed to avoid "not defined error" with requireJs
define: true,
require: true,
// Needed to avoid "not defined error" with sinonJs
sinon: true,
module: true,
test: true,
ok: true,
deepEqual: true,
expect: true,
stop: true,
start: true,
equal: true
}
},
uglify: {}
});
// Default task.
grunt.registerTask('default', 'concat lint min');
};
{
"name": "jio",
"title": "JIO",
"description": "Javascript Input Output",
"version": "0.1.0",
"homepage": "",
"author": {
"name": "Tristan Cavelier",
"email": "tristan.cavelier@tiolive.com"
},
"repository": {
"type": "git",
"url": "http://git.erp5.org/repos/jio.git"
},
"bugs": {
"url": ""
},
"licenses": [
],
"dependencies": {
"jquery": "~1.7"
},
"keywords": []
}
#!/bin/bash
for node in `ls -1` ; do
if [ -d "$node" ] ; then
printf "\n\033[1m\033[36mmake -C %s\033[0m\n" "$node"
make -C "$node"
fi
done
auto: grunt
check-syntax: grunt
grunt:
make -C ../../grunt/*_gruntJIO > /dev/null 2>&1
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment