Update dependencies and remove outdated ones (#722)

* Update dependencies and remove outdated ones
* Add package lock file
* Add minified file
* Karma now uses headless browser to run QUnit
* Add to readme that node and npm install is required
* Update license info
* Add lint-new but don't use it in CI yet
This commit is contained in:
Moritz
2019-04-10 09:21:23 +02:00
committed by Henrik Ingo
parent 97546a5536
commit 898083116b
14 changed files with 5241 additions and 214 deletions

29
.circleci/config.yml Normal file
View File

@@ -0,0 +1,29 @@
version: 2
jobs:
build:
working_directory: ~/impress.js
docker:
- image: circleci/node:current-browsers
steps:
- checkout
- run:
name: update-npm
command: 'sudo npm install -g npm@latest'
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: install-npm
command: npm install
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: build
command: npm run build
- run:
name: lint
command: npm run lint
- run:
name: test
command: npm test

296
.eslintrc.js Normal file
View File

@@ -0,0 +1,296 @@
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"accessor-pairs": "error",
"array-bracket-newline": "error",
"array-bracket-spacing": "error",
"array-callback-return": "error",
"array-element-newline": "error",
"arrow-body-style": "error",
"arrow-parens": "error",
"arrow-spacing": "error",
"block-scoped-var": "off",
"block-spacing": [
"error",
"always"
],
"brace-style": [
"error",
"1tbs",
{
"allowSingleLine": true
}
],
"callback-return": "error",
"camelcase": "error",
"capitalized-comments": "off",
"class-methods-use-this": "error",
"comma-dangle": "error",
"comma-spacing": [
"error",
{
"after": true,
"before": false
}
],
"comma-style": [
"error",
"last"
],
"complexity": "error",
"computed-property-spacing": [
"error",
"always"
],
"consistent-return": "error",
"consistent-this": "off",
"curly": "error",
"default-case": "error",
"dot-location": "error",
"dot-notation": "error",
"eol-last": "error",
"eqeqeq": "error",
"func-call-spacing": "error",
"func-name-matching": "error",
"func-names": "off",
"func-style": [
"error",
"expression"
],
"function-paren-newline": "error",
"generator-star-spacing": "error",
"global-require": "error",
"guard-for-in": "error",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"implicit-arrow-linebreak": "error",
"indent": "error",
"indent-legacy": "error",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "off",
"keyword-spacing": [
"error",
{
"after": true,
"before": true
}
],
"line-comment-position": "off",
"linebreak-style": [
"error",
"unix"
],
"lines-around-comment": "error",
"lines-around-directive": "off",
"lines-between-class-members": "error",
"max-classes-per-file": "error",
"max-depth": "error",
"max-len": "off",
"max-lines": "error",
"max-lines-per-function": "off",
"max-nested-callbacks": "error",
"max-params": "error",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-comment-style": [
"error",
"separate-lines"
],
"new-cap": "error",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "error",
"no-alert": "error",
"no-array-constructor": "error",
"no-async-promise-executor": "error",
"no-await-in-loop": "error",
"no-bitwise": "error",
"no-buffer-constructor": "error",
"no-caller": "error",
"no-catch-shadow": "error",
"no-confusing-arrow": "error",
"no-continue": "error",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "error",
"no-empty-function": "error",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-extra-parens": "off",
"no-floating-decimal": "error",
"no-implicit-coercion": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-inner-declarations": [
"error",
"functions"
],
"no-invalid-this": "off",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "error",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-misleading-character-class": "error",
"no-mixed-operators": "error",
"no-mixed-requires": "error",
"no-multi-assign": "error",
"no-multi-spaces": "off",
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-negated-in-lhs": "error",
"no-nested-ternary": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "off",
"no-path-concat": "error",
"no-plusplus": "off",
"no-process-env": "error",
"no-process-exit": "error",
"no-proto": "error",
"no-prototype-builtins": "error",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "off",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sync": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-undefined": "off",
"no-underscore-dangle": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-catch": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "off",
"no-void": "error",
"no-warning-comments": "error",
"no-whitespace-before-property": "error",
"no-with": "error",
"nonblock-statement-body-position": "error",
"object-curly-newline": "error",
"object-curly-spacing": [
"error",
"always"
],
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": "off",
"operator-assignment": "error",
"operator-linebreak": "error",
"padded-blocks": "off",
"padding-line-between-statements": "error",
"prefer-arrow-callback": "off",
"prefer-const": "error",
"prefer-destructuring": "off",
"prefer-numeric-literals": "error",
"prefer-object-spread": "error",
"prefer-promise-reject-errors": "error",
"prefer-reflect": "off",
"prefer-rest-params": "off",
"prefer-spread": "error",
"prefer-template": "off",
"quote-props": "off",
"quotes": [
"error",
"double"
],
"radix": "error",
"require-atomic-updates": "error",
"require-await": "error",
"require-jsdoc": "error",
"require-unicode-regexp": "off",
"rest-spread-spacing": "error",
"semi": "error",
"semi-spacing": [
"error",
{
"after": true,
"before": false
}
],
"semi-style": [
"error",
"last"
],
"sort-imports": "error",
"sort-keys": "off",
"sort-vars": "off",
"space-before-blocks": "error",
"space-before-function-paren": "off",
"space-in-parens": [
"error",
"always"
],
"space-infix-ops": "error",
"space-unary-ops": "error",
"spaced-comment": [
"error",
"always"
],
"strict": "error",
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": [
"error",
"never"
],
"valid-jsdoc": "error",
"vars-on-top": "off",
"wrap-regex": "error",
"yield-star-spacing": "error",
"yoda": [
"error",
"never"
]
}
};

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
/js/impress.min.js.map
/js/impress.min.js /js/impress.min.js
/node_modules /node_modules
/npm-debug.log /npm-debug.log

View File

@@ -79,6 +79,17 @@ REPOSITORY STRUCTURE
WANT TO CONTRIBUTE? WANT TO CONTRIBUTE?
--------------------- ---------------------
### Requirements
* >= node 7.6
* npm
### Setup
```bash
npm install
```
For developers, once you've made changes to the code, you should run these commands for testing: For developers, once you've made changes to the code, you should run these commands for testing:
npm run build npm run build

View File

@@ -1,16 +1,13 @@
var buildify = require('buildify'); const fs = require('fs');
var ls = require('ls');
var path = require('path');
var Terser = require("terser");
var files = ['src/impress.js'];
buildify() // Libraries from src/lib
.load('src/impress.js') files.push('src/lib/gc.js', 'src/lib/util.js')
.perform(function(content){ // Plugins from src/plugins
return "// This file was automatically generated from files in src/ directory.\n\n" + content; files.push('src/plugins/autoplay/autoplay.js',
})
// Libraries from src/lib
.concat(['src/lib/gc.js'])
.concat(['src/lib/util.js'])
// Plugins from src/plugins
.concat(['src/plugins/autoplay/autoplay.js',
'src/plugins/blackout/blackout.js', 'src/plugins/blackout/blackout.js',
'src/plugins/extras/extras.js', 'src/plugins/extras/extras.js',
'src/plugins/form/form.js', 'src/plugins/form/form.js',
@@ -30,22 +27,31 @@ buildify()
'src/plugins/stop/stop.js', 'src/plugins/stop/stop.js',
'src/plugins/substep/substep.js', 'src/plugins/substep/substep.js',
'src/plugins/touch/touch.js', 'src/plugins/touch/touch.js',
'src/plugins/toolbar/toolbar.js']) 'src/plugins/toolbar/toolbar.js')
.save('js/impress.js'); var output = files.map((f)=>{
/* return fs.readFileSync(f).toString();
* Disabled until uglify supports ES6: https://github.com/mishoo/UglifyJS2/issues/448 }).join('\n')
.uglify()
.save('js/impress.min.js');
*/
fs.writeFileSync('js/impress.js', '// This file was automatically generated from files in src/ directory.\n\n' + output)
// terser --compress --mangle --comments '/^!/' --source-map --output js/impress.min.js js/impress.js
var code = fs.readFileSync('js/impress.js').toString();
var options = {
sourceMap: {
filename: 'js/impress.js',
url: 'js/impress.min.js.map'
},
output: {
comments: /^!/
}
};
var result = Terser.minify({'js/impress.js': code}, options);
fs.writeFileSync('js/impress.min.js', result.code);
fs.writeFileSync('js/impress.min.js.map', result.map);
/* Auto generate an index.html that lists all the directories under examples/ /* Auto generate an index.html that lists all the directories under examples/
* This is useful for gh-pages, so you can link to http://impress.github.io/impress.js/examples * This is useful for gh-pages, so you can link to http://impress.github.io/impress.js/examples
*/ */
var ls = require('ls');
var fs = require('fs');
var path = require('path');
var html_list = '<ul><br />\n' var html_list = '<ul><br />\n'
ls( 'examples/*', { type: 'dir' }).forEach(function(dir) { ls( 'examples/*', { type: 'dir' }).forEach(function(dir) {
html_list += ' <li><a href="' + dir['file'] + '/">' + dir['name'] + '</a></li>\n'; html_list += ' <li><a href="' + dir['file'] + '/">' + dir['name'] + '</a></li>\n';
@@ -58,4 +64,3 @@ html += '</body>\n</html>'
var filename = path.resolve(__dirname, 'examples', 'index.html'); var filename = path.resolve(__dirname, 'examples', 'index.html');
fs.writeFileSync(filename, html); fs.writeFileSync(filename, html);
console.log(filename);

View File

@@ -1,9 +0,0 @@
machine:
node:
version: 6
test:
override:
- npm run lint -s
- npm run test -s
- npm run test:sauce

View File

@@ -1,5 +1,6 @@
// This file was automatically generated from files in src/ directory. // This file was automatically generated from files in src/ directory.
/*! Licensed under MIT License - http://github.com/impress/impress.js */
/** /**
* impress.js * impress.js
* *
@@ -9,7 +10,7 @@
* *
* Copyright 2011-2012 Bartek Szopka (@bartaz), 2016-2018 Henrik Ingo (@henrikingo) * Copyright 2011-2012 Bartek Szopka (@bartaz), 2016-2018 Henrik Ingo (@henrikingo)
* *
* Released under the MIT and GPL Licenses. * Released under the MIT License.
* *
* ------------------------------------------------ * ------------------------------------------------
* author: Bartek Szopka, Henrik Ingo * author: Bartek Szopka, Henrik Ingo

View File

@@ -1,99 +0,0 @@
/* jshint node: true */
"use strict";
// Browsers to run on Sauce Labs platforms.
var sauceBrowsers = [
[ "chrome", "53", "Windows 10" ],
[ "chrome", "52", "Windows 10" ],
[ "firefox", "48", "Windows 10" ],
[ "firefox", "47", "Windows 10" ],
[ "microsoftedge", "13", "Windows 10" ]
// These browsers have issues with the iframe based test approach. impress.js itself should work
// fine, it's just that the tests don't. We can figure out later whether there's some option that
// allows to access the DOM inside the iframe with javascript.
// [ "internet explorer", "11", "Windows 10" ],
// [ "safari", "9", "OS X 10.11" ],
// [ "safari", "8", "OS X 10.10" ]
].reduce( function( object, platform ) {
// Convert "internet explorer" -> "ie".
var label = platform[ 0 ].split( " " );
label = (
label.length > 1 ? label.map( function( word ) { return word[ 0 ]; } ) : label
).join( "" ) +
"_v" + platform[ 1 ];
object[ label ] = {
base: "SauceLabs",
browserName: platform[ 0 ],
version: platform[ 1 ],
platform: platform[ 2 ]
};
return object;
}, {} );
module.exports = function( config ) {
if ( !process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY ) {
console.log( "Sauce environments not set --- Skipping" );
return process.exit( 0 );
}
config.set( {
basePath: "",
browserDisconnectTolerance: 5,
frameworks: [ "qunit" ],
singleRun: true,
proxies : {
'/test/' : '/base/test/',
'/js/' : '/base/js/',
'/node_modules/syn/dist/' : '/base/node_modules/syn/dist/'
},
// List of files / patterns to load in the browser
files: [
// The QUnit tests
"test/helpers.js",
"test/core_tests.js",
"test/non_default.js",
"src/plugins/navigation/navigation_tests.js",
// Presentation files, for the iframe
{pattern: "test/*.html", watched: true, served: true, included: false},
{pattern: "test/plugins/*/*.html", watched: true, served: true, included: false},
// JS files for iframe
{pattern: "js/impress.js", watched: true, served: true, included: false},
{pattern: "node_modules/syn/dist/global/syn.js", watched: false, served: true, included: false}
],
// The number of sauce tests to start in parallel.
concurrency: 1,
// Test results reporter to use.
reporters: [ "dots", "saucelabs" ],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
sauceLabs: {
build: "CIRCLE-CI #" + process.env.CIRCLE_BUILD_NUM,
startConnect: true,
tunnelIdentifier: process.env.CIRCLE_BUILD_NUM
},
client: {
clearContext: false,
qunit: {
showUI: true,
testTimeout: 120*1000
}
},
// If browser does not capture, or produce output, in given timeout [ms], kill it
captureTimeout: 60*1000,
browserNoActivityTimeout: 60*1000,
customLaunchers: sauceBrowsers,
// Browsers to launch.
browsers: Object.keys( sauceBrowsers )
} );
};

View File

@@ -1,17 +1,19 @@
module.exports = function( config ) { // Karma configuration
config.set( { // Generated on Thu Feb 28 2019 16:31:36 GMT+0100 (Central European Standard Time)
process.env.CHROME_BIN = require('puppeteer').executablePath()
// Base path, that will be used to resolve files and exclude module.exports = function(config) {
basePath: "", config.set({
// Frameworks to use // base path that will be used to resolve all patterns (eg. files, exclude)
frameworks: [ "qunit" ], basePath: '',
proxies : {
'/test/' : '/base/test/', // frameworks to use
'/js/' : '/base/js/', // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
'/node_modules/syn/dist/' : '/base/node_modules/syn/dist/' frameworks: ['qunit'],
},
plugins: ['karma-firefox-launcher', 'karma-chrome-launcher', 'karma-qunit'],
// List of files / patterns to load in the browser // List of files / patterns to load in the browser
files: [ files: [
@@ -28,53 +30,71 @@ module.exports = function( config ) {
{pattern: "node_modules/syn/dist/global/syn.js", watched: false, served: true, included: false} {pattern: "node_modules/syn/dist/global/syn.js", watched: false, served: true, included: false}
], ],
// List of files to exclude proxies: {
exclude: [], "/test/": "/base/test/",
"/js/": "/base/js/",
// Test results reporter to use "/node_modules/": "/base/node_modules/"
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' },
reporters: [ "progress" ],
// Web server port
port: 9876,
// Enable / disable colors in the output (reporters and logs)
colors: true,
// Level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR ||
// config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_DEBUG,
// Enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera (has to be installed with `npm install karma-opera-launcher`)
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
// - PhantomJS
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
//browsers: [ "Chrome" ],
//browsers: [ "Firefox" ],
browsers: [ "Chrome", "Firefox" ],
client: { client: {
clearContext: false, clearContext: false,
qunit: { qunit: {
showUI: true, showUI: true
testTimeout: 120*1000 }
},
// list of files / patterns to exclude
exclude: [
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress'],
// web server port
port: 9876,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['FirefoxHeadless', 'Chrome_without_security'],
customLaunchers: {
Chrome_without_security: {
base: 'ChromeHeadless',
flags: ['--no-sandbox']
} }
}, },
// If browser does not capture, or produce output, in given timeout [ms], kill it
captureTimeout: 60*1000,
browserNoActivityTimeout: 60*1000,
// Continuous Integration mode // Continuous Integration mode
// if true, it capture browsers, run tests and exit // if true, Karma captures browsers, runs the tests and exits
singleRun: false singleRun: false,
} );
}; // Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}

4776
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -24,24 +24,22 @@
"scripts": { "scripts": {
"build": "node build.js", "build": "node build.js",
"lint": "jshint src test/*.js && jscs src test/*.js", "lint": "jshint src test/*.js && jscs src test/*.js",
"test": "karma start --single-run", "new-lint": "eslint src test",
"test:dev": "karma start", "test": "karma start --log-level debug --single-run=true"
"test:sauce": "karma start karma.conf-sauce.js"
}, },
"devDependencies": { "devDependencies": {
"buildify": "*", "eslint": "^5.15.3",
"chrome": "0.1.0", "jscs": "^3.0.7",
"firefox": "0.0.1", "jshint": "^2.10.2",
"jscs": "2.11.0", "karma": "^4.0.0",
"jshint": "2.9.1", "karma-chrome-launcher": "^2.2.0",
"karma": "0.13.22", "karma-firefox-launcher": "^1.1.0",
"karma-chrome-launcher": "2.2.0", "karma-qunit": "^2.1.0",
"karma-cli": "1.0.0", "ls": "^0.2.1",
"karma-firefox-launcher": "~0.1", "puppeteer": "^1.13.0",
"karma-qunit": "1.0.0", "qunit": "^2.9.2",
"karma-sauce-launcher": "1.0.0", "syn": "^0.13.0",
"ls": "0.2.1", "terser": "^3.17.0"
"qunitjs": "2.0.0-rc1", },
"syn": "0.10.0" "dependencies": {}
}
} }

View File

@@ -7,14 +7,12 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>QUnit tests for impress.js</title> <title>QUnit tests for impress.js</title>
<link rel="stylesheet" href="node_modules/qunitjs/qunit/qunit.css"> <link rel="stylesheet" href="node_modules/qunit/qunit/qunit.css">
</head> </head>
<body> <body>
<div id="qunit"></div> <div id="qunit"></div>
<div id="qunit-fixture"></div> <div id="qunit-fixture"></div>
<script src="node_modules/qunit/qunit/qunit.js"></script>
<script src="node_modules/qunitjs/qunit/qunit.js"></script>
<!-- The QUnit tests. --> <!-- The QUnit tests. -->
<script src="test/helpers.js"></script> <script src="test/helpers.js"></script>
<!-- Core tests --> <!-- Core tests -->
@@ -22,6 +20,5 @@
<script src="test/non_default.js"></script> <script src="test/non_default.js"></script>
<!-- Plugins --> <!-- Plugins -->
<script src="src/plugins/navigation/navigation_tests.js"></script> <script src="src/plugins/navigation/navigation_tests.js"></script>
</body> </body>
</html> </html>

View File

@@ -1,3 +1,4 @@
/*! Licensed under MIT License - http://github.com/impress/impress.js */
/** /**
* impress.js * impress.js
* *
@@ -7,7 +8,7 @@
* *
* Copyright 2011-2012 Bartek Szopka (@bartaz), 2016-2018 Henrik Ingo (@henrikingo) * Copyright 2011-2012 Bartek Szopka (@bartaz), 2016-2018 Henrik Ingo (@henrikingo)
* *
* Released under the MIT and GPL Licenses. * Released under the MIT License.
* *
* ------------------------------------------------ * ------------------------------------------------
* author: Bartek Szopka, Henrik Ingo * author: Bartek Szopka, Henrik Ingo

View File

@@ -87,8 +87,8 @@ QUnit.test( "Initialize Impress.js", function( assert ) {
assert.equal( canvas.style.transform, assert.equal( canvas.style.transform,
"rotateZ(0deg) rotateY(0deg) rotateX(0deg) translate3d(1000px, 0px, 0px)", "rotateZ(0deg) rotateY(0deg) rotateX(0deg) translate3d(1000px, 0px, 0px)",
"canvas.style.transform initialized correctly" ); "canvas.style.transform initialized correctly" );
assert.equal( canvas.style.transformOrigin, assert.ok( canvas.style.transformOrigin === "left top 0px" ||
"left top 0px", canvas.style.transformOrigin === "left top",
"canvas.style.transformOrigin initialized correctly" ); "canvas.style.transformOrigin initialized correctly" );
assert.equal( canvas.style.transformStyle, assert.equal( canvas.style.transformStyle,
"preserve-3d", "preserve-3d",