From 96fbf8a9f13e100d8048074fc1360f88c9878e83 Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Mon, 20 Apr 2020 10:57:34 +0200 Subject: [PATCH 01/13] fix(webpack): Fix module.exports exported module --- src/dateTimeInput.js | 2 +- test/webpack/webpack.test.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dateTimeInput.js b/src/dateTimeInput.js index 8cc18d1..5940b5a 100644 --- a/src/dateTimeInput.js +++ b/src/dateTimeInput.js @@ -17,7 +17,7 @@ var ng = typeof angular === 'undefined' ? require('angular') : angular var mt = typeof moment === 'undefined' ? require('moment') : moment factory(ng, mt) - module.exports = 'ui.bootstrap.datetimepicker' + module.exports = 'ui.dateTimeInput' /* istanbul ignore next */ } else if (typeof define === 'function' && /* istanbul ignore next */ define.amd) { define(['angular', 'moment'], factory) diff --git a/test/webpack/webpack.test.js b/test/webpack/webpack.test.js index 0ba779c..e0a5d06 100644 --- a/test/webpack/webpack.test.js +++ b/test/webpack/webpack.test.js @@ -20,7 +20,8 @@ describe('webpack require', function () { }); it('should be available when required', function () { - require('../../'); + var exported = require('../../'); + expect(exported).toBe('ui.dateTimeInput'); expect(loadDateTimeInput).not.toThrow(); }); }); From 51aea61fb5795de36b330ab7a55c3d0cd881e813 Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Mon, 27 Apr 2020 11:14:26 +0200 Subject: [PATCH 02/13] chore(travis): Update node to version 10 in travis.yml Can't update to 12 yet because gulp v3 doesn't support it. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 590b3e4..3a84db0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ cache: notifications: email: none node_js: - - '6' + - '10' before_install: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start From 28fe5c1baa286c6f695a14d7247ac3a153e9440d Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Mon, 27 Apr 2020 11:23:15 +0200 Subject: [PATCH 03/13] chore: Remove non-existing GruntFile.js from misc files --- .npmignore | 1 - paths.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.npmignore b/.npmignore index 7a6b7b1..5b8e638 100644 --- a/.npmignore +++ b/.npmignore @@ -8,7 +8,6 @@ bower_components complexity coverage demo -Gruntfile.js gulpfile.js karma.conf.js paths.js diff --git a/paths.js b/paths.js index b1ac32c..63c7630 100644 --- a/paths.js +++ b/paths.js @@ -7,7 +7,7 @@ var nodeModules = [ 'node_modules/angular-mocks/angular-mocks.js' ] var bumpFiles = ['package.json', 'bower.json', 'README.md', 'src/js/*.js'] -var miscFiles = ['GruntFile.js', 'gulpfile.js', 'karma.conf.js', 'paths.js'] +var miscFiles = ['gulpfile.js', 'karma.conf.js', 'paths.js'] var demoFiles = [] var sourceFiles = ['src/**/*.js'] var testFiles = ['test/**/*.spec.js'] From 08de6ffa8c362b87a780df79d7658315b0fea97e Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Mon, 27 Apr 2020 11:28:59 +0200 Subject: [PATCH 04/13] chore(gulp): remove undefined task jscs --- gulpfile.js | 2 +- package.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 227ab0b..f498240 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -38,7 +38,7 @@ gulp.task('lint', function () { }) gulp.task('tdd', function (done) { - gulp.watch(paths.all, ['jscs', 'lint']) + gulp.watch(paths.all, ['lint']) var config = testConfig( { diff --git a/package.json b/package.json index 5d72dd1..bd36f82 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "eslint": "^3.8.1", "gulp": "^3.9.1", "gulp-htmlmin": "^3.0.0", - "gulp-jscs": "^4.0.0", "gulp-jshint": "^2.0.1", "gulp-standard": "^8.0.2", "jasmine-core": "^2.5.2", From 3bec3631118d1b4cb8d18bc12ac677c07a4faa64 Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Mon, 27 Apr 2020 11:31:33 +0200 Subject: [PATCH 05/13] chore(gulp): add missing del module --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index bd36f82..581a88a 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "angular-mocks": "^1.x", "coveralls": "^2.11.14", "cz-conventional-changelog": "^1.2.0", + "del": "^5.1.0", "eslint": "^3.8.1", "gulp": "^3.9.1", "gulp-htmlmin": "^3.0.0", From d654cd85727bb3a25df9876a09972c0a406bffef Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Mon, 27 Apr 2020 11:35:28 +0200 Subject: [PATCH 06/13] chore(gulp): update standard + remove unused gulp deps --- package.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package.json b/package.json index 581a88a..7ad8853 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,7 @@ "del": "^5.1.0", "eslint": "^3.8.1", "gulp": "^3.9.1", - "gulp-htmlmin": "^3.0.0", - "gulp-jshint": "^2.0.1", - "gulp-standard": "^8.0.2", + "gulp-standard": "^8.0.4", "jasmine-core": "^2.5.2", "jquery": "^3.1.1", "jshint": "^2.9.4", From 093483a0accb876e5aa8ce6b2a138dd90169da27 Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Mon, 27 Apr 2020 11:35:44 +0200 Subject: [PATCH 07/13] chore(gulp): update to gulp 4 --- gulpfile.js | 16 ++++++++-------- package.json | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index f498240..1c40523 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -12,14 +12,14 @@ var standard = require('gulp-standard') var karmaConfig = path.join(__dirname, 'karma.conf.js') -gulp.task('clean', function () { +gulp.task('clean', function clean () { var del = require('del') return del([ 'build' ]) }) -gulp.task('complexity', function (done) { +gulp.task('complexity', function complexity (done) { var callback = function () { done() } @@ -27,7 +27,7 @@ gulp.task('complexity', function (done) { plato.inspect(paths.lint, 'build/complexity', {title: 'prerender', recurse: true}, callback) }) -gulp.task('lint', function () { +gulp.task('lint', function lint () { return gulp .src(paths.lint) .pipe(standard()) @@ -37,8 +37,8 @@ gulp.task('lint', function () { })) }) -gulp.task('tdd', function (done) { - gulp.watch(paths.all, ['lint']) +gulp.task('tdd', function tdd (done) { + gulp.watch(paths.all, gulp.parallel('lint')) var config = testConfig( { @@ -53,7 +53,7 @@ gulp.task('tdd', function (done) { server.start() }) -gulp.task('test', ['lint'], function (done) { +gulp.task('test', gulp.series('lint', function test (done) { var config = testConfig( { configFile: karmaConfig, @@ -64,9 +64,9 @@ gulp.task('test', ['lint'], function (done) { var server = new Server(config, done) server.start() -}) +})) -gulp.task('default', ['complexity', 'test']) +gulp.task('default', gulp.parallel('complexity', 'test')) var testConfig = function (options) { var travisDefaultOptions = { diff --git a/package.json b/package.json index 7ad8853..088b058 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "cz-conventional-changelog": "^1.2.0", "del": "^5.1.0", "eslint": "^3.8.1", - "gulp": "^3.9.1", + "gulp": "^4.0.0", "gulp-standard": "^8.0.4", "jasmine-core": "^2.5.2", "jquery": "^3.1.1", From 262e195f86ad514d7f1bf3d8e72c10649931e3c6 Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Mon, 27 Apr 2020 11:36:58 +0200 Subject: [PATCH 08/13] chore(travis): Update node to version 12 in travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3a84db0..78cd93d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ cache: notifications: email: none node_js: - - '10' + - '12' before_install: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start From a06a075cb667f1a008103a922b9d0e449612d945 Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Mon, 27 Apr 2020 11:55:42 +0200 Subject: [PATCH 09/13] chore(contributing.md): Remove references to invalid gulp steps --- .github/contributing.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/contributing.md b/.github/contributing.md index 3ed5cd7..461db9b 100644 --- a/.github/contributing.md +++ b/.github/contributing.md @@ -32,9 +32,6 @@ We use Gulp for managing the build. Here are some useful Gulp tasks: * `npm test` Runs all tests (webpack, commonjs, etc) checks the coding style, lints the code, calculates complexity, runs all tests, and enforces code coverage. You should make sure you do this before submitting a PR. * `gulp` The default task checks the coding style, lints the code, calculates complexity, runs the tests (not webpack or commonJS tests), and enforces code coverage. - * `gulp scss` Generates the css file from the source scss. - * `gulp css-lint` Lint the css files after generating. - * `gulp templatecache` Generates src/js/datetimepicker.templates.js. You must re-add the IIFE around the generated code after it is generated (PR to fix this would be apprecaited) # Contributing to AngularJS From 0f57ea5c117f6f6b15c15fa1df25fb75594e27a8 Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Mon, 27 Apr 2020 11:57:35 +0200 Subject: [PATCH 10/13] chore(webpack): upgrade webpack to 4 Found out that the default webpack works just fine for us, and specify and entry point actually creates an error. This is the advised usage on https://github.com/webpack-contrib/karma-webpack --- package.json | 4 ++-- test/webpack/app.js | 12 ------------ test/webpack/karma.conf.js | 6 ++---- test/webpack/webpack.conf.js | 19 ------------------- test/webpack/webpack.test.js | 2 +- 5 files changed, 5 insertions(+), 38 deletions(-) delete mode 100644 test/webpack/app.js delete mode 100644 test/webpack/webpack.conf.js diff --git a/package.json b/package.json index 088b058..5fd084b 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "karma-jasmine": "^1.0.2", "karma-phantomjs-launcher": "^1.0.2", "karma-threshold-reporter": "^0.1.15", - "karma-webpack": "^1.8.0", + "karma-webpack": "^4.0.2", "lodash": "^4.16.4", "phantomjs-prebuilt": "^2.1.13", "plato": "^1.7.0", @@ -45,7 +45,7 @@ "semantic-release": "^6.3.0", "standard": "^8.4.0", "tape": "^4.6.2", - "webpack": "^1.13.2" + "webpack": "^4.43.0" }, "scripts": { "coverage:upload": "cat build/coverage/lcov.info | coveralls", diff --git a/test/webpack/app.js b/test/webpack/app.js deleted file mode 100644 index 1ee17e6..0000000 --- a/test/webpack/app.js +++ /dev/null @@ -1,12 +0,0 @@ -/* globals require */ - -/** See the file "LICENSE" for the full license governing this code. - * - * - * @author Dale "Ducky" Lotts - * @since 9/11/16. - */ - -var angular = require('angular'); - -angular.module('app', []); diff --git a/test/webpack/karma.conf.js b/test/webpack/karma.conf.js index 972b6fe..0647377 100644 --- a/test/webpack/karma.conf.js +++ b/test/webpack/karma.conf.js @@ -8,8 +8,6 @@ * @since 9/11/16. */ -var webpackConfig = require('./webpack.conf'); - module.exports = function(config) { 'use strict'; config.set({ @@ -30,10 +28,10 @@ module.exports = function(config) { }], // webpack configuration - webpack: webpackConfig, + webpack: {}, // webpack middlewae configuration - webpackMiddleware: { noInfo: true }, + webpackMiddleware: { stats: 'errors-only' }, // list of files to exclude exclude: [], diff --git a/test/webpack/webpack.conf.js b/test/webpack/webpack.conf.js deleted file mode 100644 index c9d1d1b..0000000 --- a/test/webpack/webpack.conf.js +++ /dev/null @@ -1,19 +0,0 @@ -/* globals __dirname */ -/* jshint node:true */ - -/** - * See the file "LICENSE" for the full license governing this code. - * - * @author Dale "Ducky" Lotts - * @since 9/11/16. - */ - -var path = require('path') - -module.exports = { - entry: [path.join(__dirname, 'app.js')], - output: { - path: __dirname, - filename: 'bundle.js' - } -}; diff --git a/test/webpack/webpack.test.js b/test/webpack/webpack.test.js index e0a5d06..26c01c0 100644 --- a/test/webpack/webpack.test.js +++ b/test/webpack/webpack.test.js @@ -16,7 +16,7 @@ describe('webpack require', function () { } it('should throw an error if the module is not defined', function () { - expect(loadDateTimeInput).toThrow(); + expect(loadDateTimeInput).toThrowError(/\[\$injector:nomod\] Module 'ui\.dateTimeInput'/); }); it('should be available when required', function () { From 52b060a66ac6b48678eae31311a2256155b454f7 Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Mon, 27 Apr 2020 12:20:37 +0200 Subject: [PATCH 11/13] chores(test): upgrade karma and jasmine dependencies Jasmine 3.x introduces randomised order in tests, which we can't support for the webpack tests, so we disabled it. Otherwise everything works fine (tested by commenting out some tests). --- package.json | 13 ++++++------- test/webpack/karma.conf.js | 9 ++++++++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 5fd084b..daf82ee 100644 --- a/package.json +++ b/package.json @@ -26,16 +26,15 @@ "eslint": "^3.8.1", "gulp": "^4.0.0", "gulp-standard": "^8.0.4", - "jasmine-core": "^2.5.2", "jquery": "^3.1.1", "jshint": "^2.9.4", "jshint-stylish": "^2.2.1", - "karma": "^1.3.0", - "karma-chrome-launcher": "^2.0.0", - "karma-coverage": "^1.1.1", - "karma-firefox-launcher": "^1.0.0", - "karma-jasmine": "^1.0.2", - "karma-phantomjs-launcher": "^1.0.2", + "karma": "^5.0.0", + "karma-chrome-launcher": "^3.1.0", + "karma-coverage": "^2.0.2", + "karma-firefox-launcher": "^1.3.0", + "karma-jasmine": "^3.1.1", + "karma-phantomjs-launcher": "^1.0.4", "karma-threshold-reporter": "^0.1.15", "karma-webpack": "^4.0.2", "lodash": "^4.16.4", diff --git a/test/webpack/karma.conf.js b/test/webpack/karma.conf.js index 0647377..e4ffb61 100644 --- a/test/webpack/karma.conf.js +++ b/test/webpack/karma.conf.js @@ -70,6 +70,13 @@ module.exports = function(config) { // Concurrency level // how many browser should be started simultaneous - concurrency: Infinity + concurrency: Infinity, + + // Webpack tests need the tests to run in order in order to test the require call + client: { + jasmine: { + random: false + } + }, }); }; From 7f214e3da6750a8bb4a91712f36cfe49d49d78fb Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Mon, 27 Apr 2020 16:13:51 +0200 Subject: [PATCH 12/13] fix(tests): Istambul seems to behave just a bit diffently --- src/dateTimeInput.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/dateTimeInput.js b/src/dateTimeInput.js index 5940b5a..18523b4 100644 --- a/src/dateTimeInput.js +++ b/src/dateTimeInput.js @@ -18,8 +18,7 @@ var mt = typeof moment === 'undefined' ? require('moment') : moment factory(ng, mt) module.exports = 'ui.dateTimeInput' - /* istanbul ignore next */ - } else if (typeof define === 'function' && /* istanbul ignore next */ define.amd) { + } else /* istanbul ignore next */ if (typeof define === 'function' && define.amd) { define(['angular', 'moment'], factory) } else { factory(root.angular, root.moment) From e80e08faa1ae0648df1beb3c35bf1104f4b1ed86 Mon Sep 17 00:00:00 2001 From: Antoine Bolvy Date: Mon, 27 Apr 2020 16:23:12 +0200 Subject: [PATCH 13/13] fix(tests): upgrade travis config, remove PhantomJS --- .travis.yml | 13 ++++++++----- gulpfile.js | 4 ++-- karma.conf.js | 3 +-- package.json | 2 -- test/webpack/karma.conf.js | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 78cd93d..e8afe38 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,18 @@ sudo: false +dist: bionic language: node_js +node_js: + - '12' +services: + - xvfb +addons: + firefox: latest + chrome: latest cache: directories: - node_modules notifications: email: none -node_js: - - '12' -before_install: - - export DISPLAY=:99.0 - - sh -e /etc/init.d/xvfb start before_script: - npm prune script: diff --git a/gulpfile.js b/gulpfile.js index 1c40523..7cc6cbd 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -43,7 +43,7 @@ gulp.task('tdd', function tdd (done) { var config = testConfig( { autoWatch: true, - browsers: ['PhantomJS'], + browsers: ['ChromeHeadless'], configFile: karmaConfig, singleRun: false } @@ -70,7 +70,7 @@ gulp.task('default', gulp.parallel('complexity', 'test')) var testConfig = function (options) { var travisDefaultOptions = { - browsers: ['Firefox'], + browsers: ['FirefoxHeadless', 'ChromeHeadless'], reporters: ['dots', 'coverage', 'threshold'] } diff --git a/karma.conf.js b/karma.conf.js index e1ecd92..eb026b8 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -26,7 +26,6 @@ module.exports = function (config) { 'karma-jasmine', 'karma-chrome-launcher', 'karma-firefox-launcher', - 'karma-phantomjs-launcher', 'karma-coverage', 'karma-threshold-reporter' ], @@ -85,7 +84,7 @@ module.exports = function (config) { // - Safari (only Mac) // - PhantomJS // - IE (only Windows) - browsers: ['PhantomJS'], + browsers: ['FirefoxHeadless', 'ChromeHeadless'], // If browser does not capture in given timeout [ms], kill it captureTimeout: 60000, diff --git a/package.json b/package.json index daf82ee..8e1385c 100644 --- a/package.json +++ b/package.json @@ -34,11 +34,9 @@ "karma-coverage": "^2.0.2", "karma-firefox-launcher": "^1.3.0", "karma-jasmine": "^3.1.1", - "karma-phantomjs-launcher": "^1.0.4", "karma-threshold-reporter": "^0.1.15", "karma-webpack": "^4.0.2", "lodash": "^4.16.4", - "phantomjs-prebuilt": "^2.1.13", "plato": "^1.7.0", "run-browser": "^2.0.2", "semantic-release": "^6.3.0", diff --git a/test/webpack/karma.conf.js b/test/webpack/karma.conf.js index e4ffb61..412a0b3 100644 --- a/test/webpack/karma.conf.js +++ b/test/webpack/karma.conf.js @@ -62,7 +62,7 @@ module.exports = function(config) { // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher - browsers: ['PhantomJS'], + browsers: ['FirefoxHeadless', 'ChromeHeadless'], // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits