diff --git a/.gitattributes b/.gitattributes index b5a039fa..bcf9e4d9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ resources/openpgp*.js binary +resources/keyring*.js binary diff --git a/.gitignore b/.gitignore index 90e9c209..7c65f83d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ resources/openpgpjs.pem build/ .DS_Store -node_modules -test/integration/lib \ No newline at end of file +node_modules/ +npm* +test/lib/ +resources/keyring_nodebug.js +resources/openpgp_nodebug.js diff --git a/Gruntfile.js b/Gruntfile.js index 1909a371..2358ec0e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,52 +1,158 @@ module.exports = function(grunt) { - 'use strict'; - // Project configuration. - grunt.initConfig({ - connect: { - dev: { - options: { - port: 8680, - base: '.', - keepalive: true - } - }, - test: { - options: { - port: 8681, - base: '.' - } - } + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + browserify: { + openpgp_nodebug: { + files: { + 'resources/openpgp_nodebug.js': [] }, - - mocha: { - all: { - options: { - urls: ['http://localhost:<%= connect.test.options.port %>/test/integration/index.html'], - run: false, - reporter: 'Spec' - } - } - }, - - copy: { - npm: { - expand: true, - flatten: true, - cwd: 'node_modules/', - src: ['requirejs/require.js', 'mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'sinon/pkg/sinon.js'], - dest: 'test/integration/lib/' - } + options: { + alias: './src/:openpgp' } + }, + openpgp: { + files: { + 'resources/openpgp.js': [] + }, + options: { + debug: true, + alias: './src/:openpgp' + } + }, + keyring_nodebug: { + files: { + 'resources/keyring_nodebug.js': [] + }, + options: { + alias: './src/keyring/:keyring', + external: [ 'openpgp' ] + } + }, + keyring: { + files: { + 'resources/keyring.js': [] + }, + options: { + debug: true, + alias: './src/keyring/:keyring', + external: [ 'openpgp' ] + } + }, + unittests: { + files: { + 'test/lib/test-bundle.js': [] + }, + options: { + debug: true, + alias: './test/test-all.js:unittests', + external: [ 'openpgp', 'keyring' ] + } + }, + ci_tests: { + files: { + 'test/lib/ci-tests-bundle.js': [] + }, + options: { + debug: true, + alias: './test/ci-tests-all.js:ci-tests', + external: [ 'openpgp', 'keyring' ] + } + } + }, + replace : { + openpgpjs: { + src: ['resources/openpgp.js'], + dest: ['resources/openpgp.js'], + replacements: [{ + from: /OpenPGP.js VERSION/g, + to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>' + }] + }, + openpgpjs_nodebug: { + src: ['resources/openpgp_nodebug.js'], + dest: ['resources/openpgp_nodebug.js'], + replacements: [{ + from: /OpenPGP.js VERSION/g, + to: 'OpenPGP.js v<%= pkg.version %>.<%= grunt.template.today("yyyymmdd") %>' + }] + } + }, + uglify: { + openpgpjs: { + files: { + "resources/openpgp.min.js" : [ "resources/openpgp_nodebug.js" ], + "resources/keyring.min.js" : [ "resources/keyring_nodebug.js" ] + } + }, + options: { + banner: '/*! OpenPGPjs.org this is LGPL licensed code, see LICENSE/our website for more information.- v<%= pkg.version %> - ' + + '<%= grunt.template.today("yyyy-mm-dd") %> */' + } + }, + jsbeautifier : { + files : ["src/**/*.js"], + options : { + indent_size: 2, + preserve_newlines: true, + keep_array_indentation: false, + keep_function_indentation: false, + wrap_line_length: 120 + } + }, + jshint : { + all : ["src/**/*.js"] + }, + jsdoc : { + dist : { + src: ["README.md", "src"], + options: { + destination: "doc", + recurse: true, + template: "jsdoc.template" + } + } + }, + + copy: { + npm: { + expand: true, + flatten: true, + cwd: 'node_modules/', + src: ['mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'sinon/pkg/sinon.js'], + dest: 'test/lib/' + } + } + }); + + // Load the plugin that provides the "uglify" task. + grunt.loadNpmTasks('grunt-browserify'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-text-replace'); + grunt.loadNpmTasks('grunt-jsbeautifier'); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-jsdoc'); + + grunt.registerTask('default', 'Build OpenPGP.js', function() { + grunt.task.run(['browserify', 'replace', 'uglify']); + //TODO jshint is not run because of too many discovered issues, once these are addressed it should autorun + grunt.log.ok('Before Submitting a Pull Request please also run `grunt jshint`.'); + }); + grunt.registerTask('documentation', ['jsdoc']); + + // Load the plugin(s) + grunt.loadNpmTasks('grunt-contrib-copy'); + + // Alias the `mocha_phantomjs` task to run `mocha-phantomjs` + grunt.registerTask('mocha_phantomjs', 'mocha-phantomjs', function () { + var done = this.async(); + require('child_process').exec('node_modules/mocha-phantomjs/bin/mocha-phantomjs ./test/ci-tests.html', function (err, stdout) { + grunt.log.write(stdout); + done(err); }); + }); - // Load the plugin(s) - grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.loadNpmTasks('grunt-contrib-connect'); - grunt.loadNpmTasks('grunt-mocha'); - - // Test/Dev tasks - grunt.registerTask('dev', ['connect:dev']); - grunt.registerTask('test', ['copy', 'connect:test', 'mocha']); - -}; \ No newline at end of file + // Test/Dev tasks + grunt.registerTask('test', ['copy', 'mocha_phantomjs']); +}; diff --git a/Makefile b/Makefile index 8327ae58..fc8a6605 100644 --- a/Makefile +++ b/Makefile @@ -30,9 +30,17 @@ lint: @echo See http://code.google.com/closure/utilities/ @./scripts/lint.sh -minify: - @echo See http://code.google.com/closure/compiler/ - @./scripts/minimize.sh +bundle: + @browserify -d -r ./src/:openpgp > ./resources/openpgp.js + @browserify -r ./src/:openpgp > ./resources/openpgp_nodebug.js + @browserify -d -x openpgp -r ./src/keyring/:keyring > ./resources/keyring.js + @browserify -x openpgp -r ./src/keyring/:keyring > ./resources/keyring_nodebug.js + +bundle-test: + @browserify -d -x openpgp -x keyring -r ./test/test-all.js:unittests > ./test/lib/test-bundle.js + +bundle-ci-test: + @browserify -d -x openpgp -x keyring -r ./test/ci-tests-all.js:ci-tests > ./test/lib/ci-tests-bundle.js test: @echo to be implemented diff --git a/README.md b/README.md index e4984739..3bfc433b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -OpenPGP.js [](https://travis-ci.org/openpgpjs/openpgpjs) -========== +[](http://travis-ci.org/openpgpjs/openpgpjs) +# What is OpenPGP.js? [OpenPGP.js](http://openpgpjs.org/) is a Javascript implementation of the OpenPGP protocol. This is defined in [RFC 4880](http://tools.ietf.org/html/rfc4880). # How do I use it? diff --git a/doc/JXG.Util.html b/doc/JXG.Util.html index 7c1ca492..c29632cf 100644 --- a/doc/JXG.Util.html +++ b/doc/JXG.Util.html @@ -85,7 +85,7 @@ The code is based on the source code for gunzip.c by Pasi Ojala