Skip to content

Commit

Permalink
Converted requirejs to webpack (#7)
Browse files Browse the repository at this point in the history
bacon: test
Resolves: OKTA-88839
  • Loading branch information
lboyette-okta committed May 11, 2016
1 parent 67fb8e6 commit 21d5049
Show file tree
Hide file tree
Showing 21 changed files with 283 additions and 537 deletions.
11 changes: 4 additions & 7 deletions .jshintrc
Expand Up @@ -48,14 +48,11 @@
"waits": false,
"spyOn": false,
"runs": false,
"jasmine": false
},
"globals": {
"jasmine": false,
"escape": false,
"crypto": false,
"JSON": false,
"module": true,
"it": true,
"xit": true,
"require": true,
"describe": true,
"__dirname": true
}
}
226 changes: 16 additions & 210 deletions Gruntfile.js
@@ -1,200 +1,8 @@
var packageJson = require('./package.json');

/* globals module */
module.exports = function(grunt) {

var COPYRIGHT_TEXT = grunt.file.read('lib/copyright.frag');
var SDK_VERSION_TEXT = '<%= sdkversion %>';

function escapeRegexText(text) {
return text.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
}

function removeCopyrights(content) {
var copyrightRegex = new RegExp(escapeRegexText(COPYRIGHT_TEXT), 'g');
return content.replace(copyrightRegex, '');
}

function addCopyright(content) {
return COPYRIGHT_TEXT + content;
}

function singleCopyright(content, srcpath) {
if (srcpath.indexOf('copyright.frag') > 0) {
return content;
} else {
return addCopyright(removeCopyrights(content));
}
}

function substituteSdkVersion(content) {
var sdkVersionRegex = new RegExp(escapeRegexText(SDK_VERSION_TEXT));
return content.replace(sdkVersionRegex, packageJson.version);
}

function processFile(content, srcpath) {
return substituteSdkVersion(singleCopyright(content, srcpath));
}

grunt.initConfig({

pkg: grunt.file.readJSON('package.json'),

concat: {
options: {
separator: '\n\n'
},
browser: {
src: [
'lib/copyright.frag',
'lib/browser_start.frag',
'lib/vendor/polyfills.js',
'lib/browser_crypto.frag',
'lib/index.js',
'lib/browser_end.frag'
],
dest: 'target/OktaAuth.js'
},
browserJquery: {
src: [
'lib/copyright.frag',
'lib/browser_jquery_start.frag',
'lib/vendor/polyfills.js',
'lib/browser_crypto.frag',
'lib/index.js',
'lib/browser_jquery_end.frag'
],
dest: 'target/OktaAuthRequireJquery.js'
},
browserRequireReqwest: {
src: [
'lib/copyright.frag',
'lib/browser_reqwest_start.frag',
'lib/vendor/polyfills.js',
'lib/browser_crypto.frag',
'lib/index.js',
'lib/browser_reqwest_end.frag'
],
dest: 'target/OktaAuthRequireReqwest.js'
}
},

copy: {
browser: {
files: [
{
src: 'node_modules/q/q.js',
dest: 'target/q.js'
},
{
src: 'node_modules/almond/almond.js',
dest: 'target/almond.js'
},
{
src: 'lib/umd_start.frag',
dest: 'target/umd_start.frag'
},
{
src: 'lib/umd_end.frag',
dest: 'target/umd_end.frag'
}
]
},
reqwest: {
files: [
{
src: 'node_modules/reqwest/reqwest.js',
dest: 'target/reqwest.js'
}
]
},
browserRequireReqwest: {
files: [
{
src: 'target/OktaAuthRequireReqwest.js',
dest: 'dist/browser/OktaAuthRequireReqwest.js'
}
],
options: {
process: processFile
}
},
browserReqwest: {
files: [
{
src: 'target/OktaAuthReqwest.js',
dest: 'dist/browser/OktaAuthReqwest.min.js'
}
],
options: {
process: processFile
}
},
browserRequire: {
files: [
{
src: 'target/OktaAuth.js',
dest: 'dist/browser/OktaAuth.require.js'
}
],
options: {
process: processFile
}
},
browserJquery: {
files: [
{
src: 'target/OktaAuthRequireJquery.js',
dest: 'dist/browser/OktaAuthRequireJquery.js'
}
],
options: {
process: processFile
}
}
},

rename: {
OktaAuthRequireReqwest: {
files: [{
src: ['target/OktaAuthRequireReqwest.js'],
dest: 'target/OktaAuth.js'
}]
}
},

requirejs: {
options: {
baseUrl: 'target/',
include: [
'OktaAuth'
],
name: 'almond', // assumes a production build using almond
out: 'dist/browser/OktaAuth.js',
wrap: {
startFile: 'target/umd_start.frag',
endFile: 'target/umd_end.frag'
}
},
dev: {
options: {
optimize: 'none'
}
},
compile: {
options: {
out: 'dist/browser/OktaAuth.min.js',
optimize: 'uglify2'
}
},
compileReqwest: {
options: {
out: 'target/OktaAuthReqwest.js',
optimize: 'uglify2'
}
}
},

jasmine: {
phantom: {
options: {
Expand Down Expand Up @@ -238,33 +46,31 @@ module.exports = function(grunt) {
port: 9696
}
}
},

shell: {
AMDJqueryQ: {
command: 'npm run build:AMDJqueryQ'
},
UMDNoDependencies: {
command: 'npm run build'
}
}
});

grunt.loadTasks('buildtools/bumpprereleaseversion');

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-rename');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-shell');

grunt.registerTask('test', ['jshint', 'buildBrowserRequireJquery', 'connect:server', 'jasmine:phantom']);
grunt.registerTask('test', ['jshint', 'buildAMDWithoutJqueryOrQ', 'connect:server', 'jasmine:phantom']);
grunt.registerTask('default', ['test', 'buildUMDWithNoDependencies']);

grunt.registerTask('default',
['jshint', 'copy:browser',
'buildBrowserRequireJquery', 'connect:server', 'jasmine:phantom',
'buildBrowserRequire', 'buildBrowserRequireReqwest',
'buildBrowserUMD', 'buildBrowserUMDReqwest']);
// Builds an AMD version that requires jQuery and Q
grunt.registerTask('buildAMDWithoutJqueryOrQ', ['shell:AMDJqueryQ']);

grunt.registerTask('buildBrowserRequire', ['concat:browser', 'copy:browserRequire']);
grunt.registerTask('buildBrowserRequireReqwest', ['concat:browserRequireReqwest', 'copy:browserRequireReqwest']);
grunt.registerTask('buildBrowserRequireJquery', ['concat:browserJquery', 'copy:browserJquery']);
grunt.registerTask('buildBrowserUMD', ['buildBrowserRequire', 'requirejs:compile']);
grunt.registerTask('buildBrowserUMDReqwest',
['buildBrowserRequireReqwest',
'copy:browser', 'copy:reqwest', 'rename:OktaAuthRequireReqwest',
'requirejs:compileReqwest', 'copy:browserReqwest']);
// Builds a UMD version that has no dependencies
grunt.registerTask('buildUMDWithNoDependencies', ['shell:UMDNoDependencies']);
};
63 changes: 0 additions & 63 deletions THIRD-PARTY-NOTICES
Expand Up @@ -8,69 +8,6 @@ of a given package.

Third Party Notices

Almond
Version (if any): 0.3.1
Brief Description: A replacement AMD loader for RequireJS. It provides a
minimal AMD API footprint that includes loader plugin support. Only useful for
built/bundled AMD modules, does not do dynamic loading.
License: MIT or New BSD, MIT selected

Almond is released under two licenses: new BSD, and MIT. You may pick the
license that best suits your development needs. The text of both licenses are
provided below.

The "New" BSD License:
----------------------

Copyright (c) 2010-2011, The Dojo Foundation. All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the Dojo Foundation nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MIT License
-----------

Copyright (c) 2010-2011, The Dojo Foundation

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


Base64.js
Version (if any): 0.3.0
Brief Description: Duo two-factor authentication for Java web
Expand Down
36 changes: 0 additions & 36 deletions lib/browser_jquery_end.frag

This file was deleted.

11 changes: 0 additions & 11 deletions lib/copyright.frag

This file was deleted.

0 comments on commit 21d5049

Please sign in to comment.