diff --git a/.gitignore b/.gitignore index 023fcd3ce..e97b15dc2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ report .settings .vscode styleguide +.awspublish-app.topcoder-dev.com diff --git a/app/directives/badges/badge-tooltip.spec.js b/app/directives/badges/badge-tooltip.spec.js index afc066e09..17ff12223 100644 --- a/app/directives/badges/badge-tooltip.spec.js +++ b/app/directives/badges/badge-tooltip.spec.js @@ -6,14 +6,14 @@ describe('Badge Tooltip Directive', function() { var spotlightChallenge = mockData.getMockSpotlightChallenges()[0]; beforeEach(function() { - bard.appModule('topcoder'); + bard.appModule('tcUIComponents'); bard.inject(this, '$compile', '$rootScope'); scope = $rootScope.$new(); }); bard.verifyNoOutstandingHttpRequests(); - describe('Badge Tooltip', function() { + xdescribe('Badge Tooltip', function() { var tooltip; beforeEach(function() { diff --git a/app/specs.html b/app/specs.html index e8b01d7cc..90fcd9324 100644 --- a/app/specs.html +++ b/app/specs.html @@ -15,7 +15,7 @@ - + @@ -31,10 +31,9 @@

Spec Runner

- - - - + + + - @@ -81,6 +79,7 @@

Spec Runner

+ @@ -241,8 +240,8 @@

Spec Runner

- + @@ -256,9 +255,9 @@

Spec Runner

+ - @@ -268,14 +267,14 @@

Spec Runner

- + - + @@ -283,8 +282,8 @@

Spec Runner

- + diff --git a/gulp-tasks/build.js b/gulp-tasks/build.js deleted file mode 100644 index 78c486e36..000000000 --- a/gulp-tasks/build.js +++ /dev/null @@ -1,43 +0,0 @@ -var runSequence = require('run-sequence'); - -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('build', function(done) { - utilities.log('Building everything'); - - runSequence( - 'clean', - ['optimize', 'fonts'], - done - ); - }); - - gulp.task('build-specs', ['templatecache', 'ngConstants'], function() { - utilities.log('Building the spec runner'); - - var wiredep = require('wiredep').stream; - var options = config.getWiredepDefaultOptions(); - options.devDependencies = true; - - return gulp - .src(config.specRunner) - .pipe(wiredep(options)) - .pipe($.inject(gulp.src(config.testlibraries), - {name: 'inject:testlibraries', read: false})) - .pipe($.inject(gulp.src(config.nonBowerScripts), - {name: 'inject:nonBowerScripts', read: false})) - .pipe($.inject( - gulp.src(config.js) - .pipe($.naturalSort()) - .pipe($.angularFilesort()) - )) - .pipe($.inject(gulp.src(config.specHelpers), - {name: 'inject:spechelpers', read: false})) - .pipe($.inject(gulp.src(config.specs), - {name: 'inject:specs', read: false})) - .pipe($.inject(gulp.src(config.temp + config.templateCache.file), - {name: 'inject:templates', read: false})) - .pipe(gulp.dest(config.app)); - }); -}; diff --git a/gulp-tasks/clean.js b/gulp-tasks/clean.js deleted file mode 100644 index ca1df8777..000000000 --- a/gulp-tasks/clean.js +++ /dev/null @@ -1,11 +0,0 @@ -var del = require('del'); // rm -rf - -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('clean', function(done) { - var delconfig = [].concat(config.build, config.temp); - utilities.log('Cleaning: ' + $.util.colors.blue(delconfig)); - del(delconfig, done); - }); -}; diff --git a/gulp-tasks/copy-files.js b/gulp-tasks/copy-files.js deleted file mode 100644 index 480ddf670..000000000 --- a/gulp-tasks/copy-files.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('copy-html', function() { - utilities.log('Moving app html files to .tmp'); - - return gulp - .src([config.app + '**/*.html', '!' + config.app + 'specs.html']) - .pipe(gulp.dest(config.temp)); - }); -}; diff --git a/gulp-tasks/deploy.js b/gulp-tasks/deploy.js deleted file mode 100644 index 9ccd3ffc6..000000000 --- a/gulp-tasks/deploy.js +++ /dev/null @@ -1,53 +0,0 @@ -var merge = require('merge-stream'); -var awspublishRouter = require('gulp-awspublish-router'); - -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('deploy', ['build'], function() { - var awsConfig = { - params: { - Bucket: config.aws.bucket - }, - 'accessKeyId': config.aws.key, - 'secretAccessKey': config.aws.secret - }; - - var publisher = $.awspublish.create(awsConfig); - - utilities.log('Deploying to S3'); - - var gzip = gulp.src(['build/**/*.js', 'build/**/*.css']).pipe($.awspublish.gzip()) - .pipe(awspublishRouter({ - cache: { - cacheTime: 94608000, - allowTransform: false, - public: true - }, - routes: { - '^.+$': '$&' - } - })); - - var plain = gulp.src(['build/**/*', '!build/**/*.js', '!build/**/*.css']) - .pipe(awspublishRouter({ - cache: { - cacheTime: 94608000, - allowTransform: false, - public: true - }, - routes: { - '^.+\\.html': { - cacheTime: 0 - }, - '^.+$': '$&' - } - })); - - return merge(gzip, plain) - .pipe(publisher.cache()) - .pipe(publisher.publish()) - .pipe($.if(!config.production, publisher.sync())) - .pipe($.awspublish.reporter()); - }); -}; diff --git a/gulp-tasks/e2e.js b/gulp-tasks/e2e.js deleted file mode 100644 index 20a42af47..000000000 --- a/gulp-tasks/e2e.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('e2e', function() { - return gulp - .src(['./tests/e2e/app/*.js']) - .pipe($.angularProtractor({ - 'configFile': 'tests/e2e/conf.js', - 'args': ['--baseUrl', 'http://127.0.0.1:8000'], - 'autoStartStopServer': true, - 'debug': true - })) - .on('error', function(e) { throw e }); - }); -}; diff --git a/gulp-tasks/fonts.js b/gulp-tasks/fonts.js deleted file mode 100644 index f0900d064..000000000 --- a/gulp-tasks/fonts.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('fonts', function() { - utilities.log('Copying fonts'); - - return gulp - .src([config.fonts, 'bower_components/fontawesome/fonts/fontawesome-webfont.*']) - .pipe(gulp.dest(config.build + 'fonts')); - }); -}; diff --git a/gulp-tasks/images.js b/gulp-tasks/images.js deleted file mode 100644 index 0b396b1c3..000000000 --- a/gulp-tasks/images.js +++ /dev/null @@ -1,20 +0,0 @@ -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('images', ['images:move-skills'], function() { - utilities.log('Copying and compressing the images'); - - return gulp - .src([config.images, '!' + config.assets + 'images/skills/**.*']) - .pipe($.imagemin({optimizationLevel: 4})) - .pipe(gulp.dest(config.temp + 'images')); - }); - - gulp.task('images:move-skills', function() { - utilities.log('Copying original skill icons to build folder'); - - return gulp - .src(config.assets + 'images/skills/**.*') - .pipe(gulp.dest(config.build + 'images/skills')); - }); -}; diff --git a/gulp-tasks/inject.js b/gulp-tasks/inject.js deleted file mode 100644 index 5d81ccbb1..000000000 --- a/gulp-tasks/inject.js +++ /dev/null @@ -1,36 +0,0 @@ -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('wiredep', ['jade'], function() { - utilities.log('Injecting bower css/js and app js files into index.jade'); - var options = config.getWiredepDefaultOptions(); - var wiredep = require('wiredep').stream; - - return gulp - .src(config.index) - .pipe(wiredep(options)) - .pipe($.inject( - gulp.src(config.js) - .pipe($.naturalSort('desc')) - .pipe($.angularFilesort()), - {relative: true})) - .pipe($.inject(gulp.src(config.nonBowerScripts, {read: false}), { - starttag: '//- inject:nonBowerScripts', - endtag: '//- endinject', - ignorePath: 'assets/' - })) - .pipe(gulp.dest(config.app)); - }); - - gulp.task('inject', ['wiredep', 'styles', 'templatecache'], function() { - utilities.log('Injecting app css into index.jade'); - - return gulp - .src(config.index) - .pipe($.inject( // Sort the css (topcoder.css, then everything else) - gulp.src(config.css, {read: false}) - .pipe($.naturalSort('desc')), - {ignorePath: '.tmp', addRootSlash: false})) - .pipe(gulp.dest(config.app)); - }); -}; diff --git a/gulp-tasks/jade.js b/gulp-tasks/jade.js deleted file mode 100644 index 1aee4b4e0..000000000 --- a/gulp-tasks/jade.js +++ /dev/null @@ -1,20 +0,0 @@ -var envFile = require('../config.js')(); -var envConfig = envFile[process.env.ENVIRONMENT || 'development']; - -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('jade', function() { - utilities.log('Compiling Jade --> HTML'); - - return gulp - .src(config.jade) - .pipe($.plumber()) - .pipe($.data(function(file) { - return envConfig; - })) - .pipe($.jade({pretty: true})) - .pipe($.replace(/-->/g, ' -->')) - .pipe(gulp.dest(config.temp)); - }); -}; diff --git a/gulp-tasks/linters.js b/gulp-tasks/linters.js deleted file mode 100644 index a83c765d6..000000000 --- a/gulp-tasks/linters.js +++ /dev/null @@ -1,17 +0,0 @@ -var args = require('yargs').argv; - -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('vet', function() { - utilities.log('Analyzing source with JSHint and JSCS'); - - return gulp - .src(config.alljs) - .pipe($.if(args.verbose, $.print())) // gulp vet --verbose to trigger this line - .pipe($.jscs()) - .pipe($.jshint()) - .pipe($.jshint.reporter('jshint-stylish', {verbose: true})) - .pipe($.jshint.reporter('fail')); - }); -}; diff --git a/gulp-tasks/ng-constants.js b/gulp-tasks/ng-constants.js deleted file mode 100644 index 8d623190e..000000000 --- a/gulp-tasks/ng-constants.js +++ /dev/null @@ -1,18 +0,0 @@ -var envFile = require('../config.js')(); -var envConfig = envFile[process.env.ENVIRONMENT || 'development']; - -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('ngConstants', function() { - utilities.log('Creating ng-constants file') - - return $.ngConstant({ - name: 'CONSTANTS', - constants: envConfig, - stream: true - }) - .pipe($.rename('topcoder.constants.js')) - .pipe(gulp.dest(config.app)); - }); -}; diff --git a/gulp-tasks/optimize.js b/gulp-tasks/optimize.js deleted file mode 100644 index d1b90da22..000000000 --- a/gulp-tasks/optimize.js +++ /dev/null @@ -1,56 +0,0 @@ -var envFile = require('../config.js')(); -var envConfig = envFile[process.env.ENVIRONMENT || 'development']; -var RevAll = require('gulp-rev-all'); -var merge = require('merge-stream'); - -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('optimize', ['inject', 'test', 'ngConstants', 'images'], function() { - utilities.log('Optimizing the JavaScript, CSS, and HTML'); - - var assets = $.useref.assets({searchPath: ['.tmp', 'app', 'assets']}); - var templateCache = config.temp + config.templateCache.file; - var cssFilter = $.filter('**/*.css'); - var jsLibFilter = $.filter('**/' + config.optimized.vendor); - var jsAppFilter = $.filter('**/' + config.optimized.app); - - var imageStream = gulp.src(config.temp + '/**/*.{svg,png,jpg,jpeg,gif}'); - var userefStream = gulp - .src(config.indexHtml) - .pipe($.plumber()) - .pipe($.inject(gulp.src(templateCache, {read: false}), { - starttag: '', - endtag: '', - relative: true - })) - .pipe(assets) - .pipe(cssFilter) - .pipe($.csso()) - .pipe(cssFilter.restore()) - .pipe(jsLibFilter) - .pipe($.uglify()) - .pipe(jsLibFilter.restore()) - .pipe(jsAppFilter) - .pipe($.if(!config.production && !config.qa, $.sourcemaps.init())) - .pipe($.ngAnnotate()) - .pipe($.uglify()) - .pipe(jsAppFilter.restore()) - .pipe(assets.restore()) - .pipe($.useref()) - - var revAll = new RevAll({ - prefix: envConfig.CONSTANTS.ASSET_PREFIX, - dontRenameFile: [/^\/index.html/g] - }); - - return merge(userefStream, imageStream) - .pipe(revAll.revision()) - .pipe($.if(!config.production && !config.qa, $.sourcemaps.write())) - // Uncomment if you want to see the JSON file containing - // the file mapping (e.g., "{"js/app.js": "js/app-a9bae026bc.js"}") - // .pipe(gulp.dest(config.build)) - // .pipe(revAll.manifestFile()) - .pipe(gulp.dest(config.build)); - }); -}; diff --git a/gulp-tasks/scss.js b/gulp-tasks/scss.js deleted file mode 100644 index 3da29f550..000000000 --- a/gulp-tasks/scss.js +++ /dev/null @@ -1,24 +0,0 @@ -var envFile = require('../config.js')(); -var envConfig = envFile[process.env.ENVIRONMENT || 'development']; - -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('styles', function() { - utilities.log('Compiling Sass --> CSS'); - - var assetPrefix = envConfig.CONSTANTS.ASSET_PREFIX.length ? envConfig.CONSTANTS.ASSET_PREFIX : '/'; - - return gulp - .src(config.sass, {base: './'}) - .pipe($.plumber()) - .pipe($.sass({includePaths: require('appirio-styles').includePaths})) - .pipe($.autoprefixer({browsers: ['last 2 version']})) - .pipe($.replace(/\/fonts/g, assetPrefix + 'fonts')) - .pipe(gulp.dest(config.temp)); - }); - - gulp.task('sass-watcher', function() { - gulp.watch([config.sass], ['styles']); - }); -}; diff --git a/gulp-tasks/serve.js b/gulp-tasks/serve.js deleted file mode 100644 index 1e36e31f3..000000000 --- a/gulp-tasks/serve.js +++ /dev/null @@ -1,101 +0,0 @@ -var browserSync = require('browser-sync'); -var histFallback = require('connect-history-api-fallback'); - -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('serve', ['inject', 'ngConstants'], function() { - gulp.watch(config.sass, ['styles']) - .on('change', function(event) { utilities.changeEvent(event); }); - - gulp.watch(config.jade, ['templatecache']) - .on('change', function(event) { utilities.changeEvent(event); }); - - var options = { - server: { - baseDir: [config.temp, config.app, config.assets], - // Enables serving index.html for Angular HTML5 mode - middleware: [histFallback()], - routes: { - '/bower_components': 'bower_components' - } - }, - files: config.watchFiles, - ghostMode: { - clicks: true, - location: false, - forms: true, - scroll: true - }, - logPrefix: 'Topcoder-Account', - notify: false, - port: 3000, - reloadDelay: 1000 - }; - - browserSync(options); - - }); - - gulp.task('serve-specs', ['build-specs'], function() { - utilities.log('Run the spec runner'); - - gulp.watch(config.sass, ['styles']) - .on('change', function(event) { utilities.changeEvent(event); }); - - gulp.watch(config.jade, ['templatecache']) - .on('change', function(event) { utilities.changeEvent(event); }); - - var options = { - server: { - baseDir: ['./'], - // Enables serving index.html for Angular HTML5 mode - middleware: [histFallback()], - routes: { - '/bower_components': 'bower_components' - } - }, - files: config.watchFiles, - ghostMode: { - clicks: true, - location: false, - forms: true, - scroll: true - }, - logPrefix: 'Topcoder-Account', - notify: false, - reloadDelay: 1000, - startPath: config.app + config.specRunnerFile - }; - - browserSync(options); - }); - - gulp.task('serve-build', ['build'], function() { - // TODO: Figure out why watch doesn't work. Jade running before wiredep? - - gulp.watch([config.sass, config.js, config.jade], ['optimize', browserSync.reload]) - .on('change', function(event) { utilities.changeEvent(event); }); - - var options = { - server: { - baseDir: config.build, - // Enables serving index.html for Angular HTML5 mode - middleware: [histFallback()] - }, - files: [], - ghostMode: { - clicks: true, - location: false, - forms: true, - scroll: true - }, - logPrefix: 'Topcoder-Account', - notify: false, - reloadDelay: 1000 - }; - - browserSync(options); - - }); -}; diff --git a/gulp-tasks/template-cache.js b/gulp-tasks/template-cache.js deleted file mode 100644 index b2135367b..000000000 --- a/gulp-tasks/template-cache.js +++ /dev/null @@ -1,16 +0,0 @@ -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - gulp.task('templatecache', ['jade'], function() { - utilities.log('Creating AngularJS $templateCache'); - - return gulp - .src(config.htmltemplates) - .pipe($.minifyHtml({empty: true})) - .pipe($.angularTemplatecache( - config.templateCache.file, - config.templateCache.options - )) - .pipe(gulp.dest(config.temp)); - }); -}; diff --git a/gulp-tasks/tests.js b/gulp-tasks/tests.js deleted file mode 100644 index 6eca779fa..000000000 --- a/gulp-tasks/tests.js +++ /dev/null @@ -1,12 +0,0 @@ -module.exports = function(gulp, $, config, utilities) { - 'use strict'; - - // vet should be run before tests - gulp.task('test', ['templatecache', 'ngConstants'], function(done) { - utilities.startTests(true /* singleRun */, done); - }); - - gulp.task('autotest', ['vet', 'templatecache', 'ngConstants'], function(done) { - utilities.startTests(false, done); - }); -}; diff --git a/gulp-tasks/utilities.js b/gulp-tasks/utilities.js deleted file mode 100644 index 267641f12..000000000 --- a/gulp-tasks/utilities.js +++ /dev/null @@ -1,51 +0,0 @@ -var config = require('../gulp.config')(); -var util = require('gulp-util'); -var del = require('del'); // rm -rf -var path = require('path'); - -exports.changeEvent = function(event) { - var srcPattern = new RegExp('/.*(?=/' + config.source + ')/'); - this.log('File ' + event.path.replace(srcPattern, '') + ' ' + event.type); -} - -exports.clean = function(path, done) { - this.log('Cleaning: ' + util.colors.blue(path)); - del(path, done); -} - -exports.log = function(msg) { - if (typeof(msg) === 'object') { - for (var item in msg) { - if (msg.hasOwnProperty(item)) { - util.log(util.colors.blue(msg[item])); - } - } - } else { - util.log(util.colors.blue(msg)); - } -} - -exports.startTests = function(singleRun, done) { - var karma = require('karma').server; - var excludeFiles = []; - var serverSpecs = config.serverIntegrationSpecs; - - excludeFiles = serverSpecs; - - karma.start({ - configFile: path.join(__dirname,'../karma.conf.js'), - exclude: excludeFiles, - singleRun: !!singleRun - }, karmaCompleted.bind(this)); - - function karmaCompleted(karmaResult) { - this.log('Karma completed!'); - if (karmaResult === 1) { - done('karma: tests failed with code ' + karmaResult); - } else { - done(); - } - } -} - -return module.exports; diff --git a/gulp.config.js b/gulp.config.js deleted file mode 100644 index 015876064..000000000 --- a/gulp.config.js +++ /dev/null @@ -1,145 +0,0 @@ -module.exports = function() { - var app = './app/'; - var assets = './assets/'; - var report = './report/'; - var specRunnerFile = 'specs.html'; - var temp = './.tmp/'; - var wiredep = require('wiredep'); - var bowerFiles = wiredep({devDependencies: true})['js']; - - var config = { - // File paths - watchFiles: [ - temp + '**/*.{js,css,html}', - app + '**/*.{js}' - ], - alljs: [ - app + '**/*.js', - './*.js' - ], - build: './build/', - app: app, - assets: assets, - css: temp + '**/*.css', - fonts: assets + 'fonts/**/*.*', - htmltemplates: [ - temp + '**/*.html', - '!' + temp + 'index.html' - ], - images: assets + 'images/**/*.*', - index: app + 'index.jade', - indexHtml: temp + 'index.html', - jade: app + '**/*.jade', - js: [ - app + '**/*.js', - '!' + app + '**/*.spec.js' - ], - nonBowerScripts: assets + 'scripts/**/*.js', - report: report, - sass: assets + 'css/**/*.scss', - temp: temp, - - // Optimized files - optimized: { - app: 'app.js', - vendor: 'vendor.js' - }, - - // Template cache - templateCache: { - file: 'templates.js', - options: { - module: 'topcoder', - standAlone: false - } - }, - - // Bower and npm locations - bower: { - json: require('./bower.json'), - directory: './bower_components/', - exclude: ['package.js'], - ignorePath: '../..' - }, - - // specs.html: our HTML spec runner - specRunner: app + specRunnerFile, - specRunnerFile: specRunnerFile, - testlibraries: [ - 'node_modules/mocha/mocha.js', - 'node_modules/chai/chai.js', - 'node_modules/mocha-clean/index.js', - 'node_modules/sinon-chai/lib/sinon-chai.js' - ], - specs: [app + '**/*.spec.js'], - - // Karma and testing settings - specHelpers: ['tests/test-helpers/*.js', 'app/blocks/logger/logEnhaner.js'], - serverIntegrationSpecs: ['tests/server-integration/**/*.spec.js'], - - // AWS settings - aws: { - bucket: process.env.AWS_BUCKET, - key: process.env.AWS_KEY, - region: process.env.AWS_REGION, - secret: process.env.AWS_SECRET - }, - - // Process.env variables - production: isEnvironment('production'), - qa: isEnvironment('qa') - }; - - config.getWiredepDefaultOptions = function () { - var options = { - bowerJson: config.bower.json, - exclude: config.bower.exclude, - directory: config.bower.directory, - ignorePath: config.bower.ignorePath - }; - return options; - }; - - config.karma = getKarmaOptions(); - - return config; - - /////////////////// - - function getKarmaOptions() { - var options = { - files: [].concat( - bowerFiles, - config.specHelpers, - app + 'topcoder.module.js', - app + 'topcoder.**.js', - app + '**/*.module.js', - app + '**/*.js', - assets + 'scripts/**/*.js', - temp + config.templateCache.file, - config.serverIntegrationSpecs - ), - exclude: ['package.js'], - coverage: { - dir: report + 'coverage', - reporters: [ - {type: 'html', subdir: 'report-html'}, - {type: 'lcov', subdir: '.', file: 'lcov.info'}, - {type: 'text-summary'}, - {type: 'cobertura', subdir: 'cobertura', file: 'coverage.xml'} - ] - }, - preprocessors: {} - }; - options.preprocessors[app + '**/!(*.spec)+(.js)'] = ['coverage']; - return options; - } - - function isEnvironment(env) { - if (process.env && process.env.ENVIRONMENT) { - return process.env.ENVIRONMENT.indexOf(env) > -1; - } - - return false; - } -}; diff --git a/gulpfile.js b/gulpfile.js index 7e5ffe30c..62c90e0f5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,19 +1,169 @@ -'use strict'; +// Allows us to use the CoffeeScript gulpfile +require('./node_modules/appirio-gulp-tasks/node_modules/coffee-script/register'); -var gulp = require('gulp'); -var plugins = require('gulp-load-plugins')({lazy: true}); +var envFile = require('./config.js')(); +var envConfig = envFile[process.env.ENVIRONMENT || 'development']; +var assetPrefix = envConfig.CONSTANTS.ASSET_PREFIX.length ? envConfig.CONSTANTS.ASSET_PREFIX : '/'; -var config = require('./gulp.config')(); -var taskPath = './gulp-tasks/'; -var taskList = require('fs').readdirSync(taskPath); +var config = { + __dirname: __dirname +}; -var utilities = require(taskPath + 'utilities'); +config.jade = { + options: { + pretty: true + }, + data: envConfig, + replace: { + pattern: [/-->/g, ' -->'] + } +}; + +config.ngConstants = { + defaultConstants: envConfig, + destPath: 'app', + fileName: 'topcoder.constants.js', + options: { + name: 'CONSTANTS' + } +}; + +config.scss = { + scssFiles: 'assets/css/**/*.scss', + sourceOptions: { + base: './' + }, + autoprefixer: { + browsers: ['last 2 version'] + }, + assetPrefix: assetPrefix + 'fonts', + replace: /\/fonts/g +}; + +config.fonts = { + srcFiles: [ + './assets/fonts/**/*.*', + 'bower_components/fontawesome/fonts/fontawesome-webfont.*' + ] +}; + +config.images = { + srcFiles: [ + './assets/images/**/*.*', + '!./assets/images/skills/*.*' + ], + options: { + optimizationLevel: 4 + } +}; -taskList.forEach(function(taskFile) { - if (taskFile !== 'utilities.js') { - require(taskPath + taskFile)(gulp, plugins, config, utilities); +config.templateCache = { + files: [ + '.tmp/**/*.html', + '!.tmp/index.html' + ], + fileName: 'templates.js', + module: 'topcoder', + standAlone: false, + destPath: '.tmp', + minifyHtml: { + empty: true } -}); +}; + +config.wiredep = { + index: './app/index.jade', + js: [ + './app/**/*.js', + '!./app/**/*.spec.js' + ], + nonBowerScripts: './assets/scripts/**/*.js', + destPath: './app/', + css: '.tmp/**/*.css', + specRunner: './app/specs.html', + testLibraries: [ + 'node_modules/appirio-gulp-tasks/node_modules/mocha/mocha.js', + 'node_modules/appirio-gulp-tasks/node_modules/chai/chai.js', + 'node_modules/appirio-gulp-tasks/node_modules/mocha-clean/index.js', + 'node_modules/appirio-gulp-tasks/node_modules/sinon-chai/lib/sinon-chai.js' + ], + specHelpers: [ + 'tests/test-helpers/*.js', + 'app/blocks/logger/logEnhaner.js' + ], + specs: ['./app/**/*.spec.js'], + templateCacheFile: '.tmp/' + config.templateCache.fileName +}; + +config.optimize = { + assetPrefix: assetPrefix, + writeSourceMaps: envConfig.CONSTANTS.ENVIRONMENT === 'development', + userefOptions: { + searchPath: ['.tmp', 'app', 'assets'] + }, + templateCacheFile: '.tmp/' + config.templateCache.fileName +}; + +config.karma = { + serverIntegrationSpecs: ['tests/server-integration/**/*.spec.js'] +}; + +config.serve = { + dependencies: [ + 'inject', + 'ng-constant' + ], + serveFolders: [ + '.tmp', + './app/', + './assets/' + ], + scssFiles: ['./assets/css/**/*.scss'], + jadeFiles: ['./app/**/*.jade'], + options: { + port: 3141, + reloadDelay: 1200, + open: true, + logPrefix: 'Topcoder-App', + ghostMode: { + clicks: true, + location: false, + forms: true, + scroll: true + }, + files: [ + '.tmp/**/*.{js,css,html}', + './app/**/*.js' + ] + }, + specOptions: { + port: 3142, + reloadDelay: 1200, + open: true, + logPrefix: 'Topcoder-App Specs', + ghostMode: { + clicks: true, + location: false, + forms: true, + scroll: true + }, + startPath: 'app/specs.html', + files: [ + '.tmp/**/*.{js,css,html}', + './app/**/*.js' + ] + } +}; + +config.deploy = { + bucket: process.env.AWS_BUCKET, + key: process.env.AWS_KEY, + region: process.env.AWS_REGION, + secret: process.env.AWS_SECRET, + sync: envConfig.CONSTANTS.ENVIRONMENT !== 'production', + dependencies: ['build:topcoder'] +}; + +var loadTasksModule = require(__dirname + '/node_modules/appirio-gulp-tasks/load-tasks.coffee'); -gulp.task('help', plugins.taskListing); -gulp.task('default', ['help']); +loadTasksModule.loadTasks(config); diff --git a/karma.conf.js b/karma.conf.js index 4178bd360..9fa1bc519 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,5 +1,7 @@ +var wiredep = require('wiredep'); + module.exports = function(config) { - var gulpConfig = require('./gulp.config')(); + var bowerFiles = wiredep({devDependencies: true})['js']; config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) @@ -10,10 +12,20 @@ module.exports = function(config) { frameworks: ['mocha', 'chai', 'sinon', 'chai-sinon'], // list of files / patterns to load in the browser - files: gulpConfig.karma.files, + files: [].concat( + bowerFiles, + 'tests/test-helpers/*.js', + './app/topcoder.module.js', + './app/topcoder.**.js', + './app/**/*.module.js', + './app/**/*.js', + './assets/scripts/**/*.js', + '.tmp/templates.js', + 'tests/server-integration/**/*.spec.js' + ), // list of files to exclude - exclude: gulpConfig.karma.exclude, + exclude: ['package.js'], proxies: { '/': 'http://localhost:8888/' @@ -21,8 +33,9 @@ module.exports = function(config) { // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: gulpConfig.karma.preprocessors, - + preprocessors: { + './app/**/!(*.spec)+(.js)': ['coverage'] + }, // test results reporter to use // possible values: 'dots', 'progress', 'coverage' // available reporters: https://npmjs.org/browse/keyword/karma-reporter @@ -35,8 +48,13 @@ module.exports = function(config) { }, coverageReporter: { - dir: gulpConfig.karma.coverage.dir, - reporters: gulpConfig.karma.coverage.reporters + dir: './report/coverage', + reporters: [ + {type: 'html', subdir: 'report-html'}, + {type: 'lcov', subdir: '.', file: 'lcov.info'}, + {type: 'text-summary'}, + {type: 'cobertura', subdir: 'cobertura', file: 'coverage.xml'} + ] }, // web server port diff --git a/package.json b/package.json index b363a8595..3fa7c8829 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "topcoder-app", - "description": "Account related pages including login, registration, and password resetting.", + "description": "Topcoder pages including login, registration, settings, dashboard, profile.", "repository": { "type": "git", "url": "git+https://github.com/appirio-tech/topcoder-app.git" @@ -12,7 +12,10 @@ "registration", "password", "peer", - "review" + "review", + "dashboard", + "profile", + "settings" ], "bugs": { "url": "https://github.com/appirio-tech/topcoder-app/issues" @@ -20,72 +23,9 @@ "homepage": "https://github.com/appirio-tech/topcoder-app#readme", "devDependencies": { "appirio-styles": "0.x.x", - "bower": "^1.4.1", - "browser-sync": "^2.7.12", - "chai": "^3.0.0", - "connect-history-api-fallback": "^1.1.0", - "coveralls": "^2.11.4", - "del": "^1.2.0", + "appirio-gulp-tasks": "https://github.com/appirio-tech/gulp-tasks.git#topcoder-updates", "gulp": "^3.9.0", - "gulp-angular-filesort": "^1.1.1", - "gulp-angular-protractor": "^0.0.2", - "gulp-angular-templatecache": "^1.6.0", - "gulp-autoprefixer": "^2.3.1", - "gulp-awspublish": "^2.0.2", - "gulp-awspublish-router": "^0.1.1", - "gulp-babel": "^5.1.0", - "gulp-csso": "^1.0.0", - "gulp-data": "^1.2.0", - "gulp-filter": "^2.0.2", - "gulp-if": "^1.2.5", - "gulp-imagemin": "^2.3.0", - "gulp-inject": "^1.3.1", - "gulp-jade": "^1.0.1", - "gulp-jscs": "^1.6.0", - "gulp-jshint": "^1.11.0", - "gulp-load-plugins": "^0.10.0", - "gulp-minify-html": "^1.0.3", - "gulp-natural-sort": "^0.1.0", - "gulp-ng-annotate": "^1.0.0", - "gulp-ng-constant": "^0.3.0", - "gulp-plumber": "^1.0.1", - "gulp-print": "^1.1.0", - "gulp-rename": "^1.2.2", - "gulp-replace": "^0.5.3", - "gulp-replace-task": "^0.11.0", - "gulp-rev": "^5.0.1", - "gulp-rev-all": "0.8.18", - "gulp-rev-replace": "^0.4.2", - "gulp-sass": "^2.1.0", - "gulp-sourcemaps": "^1.5.2", - "gulp-svg-sprite": "^1.2.11", - "gulp-task-listing": "^1.0.1", - "gulp-uglify": "^1.2.0", - "gulp-useref": "^1.2.0", - "gulp-util": "^3.0.5", - "jasmine-reporters": "^1.0.0", - "jshint-stylish": "^2.0.1", - "karma": "^0.12.37", - "karma-chai": "^0.1.0", - "karma-chai-sinon": "^0.1.5", - "karma-chrome-launcher": "^0.2.0", - "karma-coverage": "^0.4.2", - "karma-growl-reporter": "^0.1.1", - "karma-junit-reporter": "^0.3.8", - "karma-mocha": "^0.2.0", - "karma-phantomjs-launcher": "^0.2.0", - "karma-sinon": "^1.0.4", - "merge-stream": "^0.1.8", - "mocha": "^2.2.5", - "mocha-clean": "^0.4.0", - "phantomjs": "^1.9.17", - "protractor-html-screenshot-reporter": "0.0.21", - "protractor-linkuisref-locator": "^1.1.2", - "run-sequence": "^1.1.5", - "sinon": "^1.15.3", - "sinon-chai": "^2.8.0", - "wiredep": "^2.2.2", - "yargs": "^3.12.0" + "wiredep": "^2.2.2" }, "dependencies": {} }