Skip to content

Commit

Permalink
Merge pull request #4 from oat-sa/release-0.3.0
Browse files Browse the repository at this point in the history
Release 0.3.0
ferenckiss89 authored Jun 26, 2019
2 parents f3a90e0 + bc70564 commit 56e76ca
Showing 705 changed files with 90,131 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
pipeline {
agent {
label 'master'
}
stages {
stage('Frontend Tests') {
agent {
docker {
image 'btamas/puppeteer-git'
reuseNode true
}
}
environment {
HOME = '.'
PARALLEL_TESTS = 2
}
options {
skipDefaultCheckout()
}
steps {
dir('.') {
sh(
label: 'Setup frontend toolchain',
script: 'npm install'
)
sh (
label : 'Run frontend tests',
script: 'npm run test'
)
}
}
}
}
}
71 changes: 71 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"env" : {
"browser" : true,
"es6" : true,
"qunit" : true,
"node" : true
},
"globals" : {
"ENVIRONMENT" : true
},
"plugins" : ["es", "jsdoc"],
"parserOptions" : {
"sourceType" : "module",
"ecmaVersion" : 2015
},
"extends" : "eslint:recommended",
"rules" : {
"array-bracket-newline" : ["warn", "consistent"],
"arrow-body-style" : ["error", "as-needed"],
"arrow-spacing" : ["warn", { "before" : true, "after" : true }],
"brace-style" : ["warn", "1tbs"],
"consistent-this" : ["error", "self"],
"eqeqeq" : ["error", "smart"],
"es/no-classes" : ["error"],
"es/no-generators" : ["error"],
"func-call-spacing" : ["error"],
"implicit-arrow-linebreak" : ["error"],
"indent" : ["warn", 4, { "SwitchCase" : 1, "MemberExpression" : "off" }],
"jsdoc/check-alignment" : ["warn"],
"jsdoc/check-param-names" : ["warn"],
"jsdoc/require-param" : ["warn"],
"jsdoc/require-param-name" : ["warn"],
"jsdoc/require-param-type" : ["warn"],
"jsdoc/require-returns" : ["warn"],
"jsdoc/require-returns-check" : ["warn"],
"jsdoc/require-returns-type" : ["warn"],
"linebreak-style" : ["error", "unix"],
"new-parens" : ["error"],
"no-alert" : ["error"],
"no-caller" : ["error"],
"no-confusing-arrow" : ["error", { "allowParens" : false }],
"no-console" : ["error"],
"no-debugger" : ["error"],
"no-duplicate-imports" : ["error"],
"no-eval" : ["error"],
"no-extend-native" : ["error"],
"no-extra-bind" : ["error"],
"no-implicit-globals" : ["error"],
"no-implied-eval" : ["error"],
"no-lone-blocks" : ["error"],
"no-multi-assign" : ["error"],
"no-new-func" : ["error"],
"no-script-url" : ["error"],
"no-self-compare" : ["error"],
"no-sequences" : ["error"],
"no-shadow" : ["error", { "hoist" : "functions" }],
"no-template-curly-in-string" : ["error"],
"no-throw-literal" : ["error"],
"no-trailing-spaces" : ["error"],
"no-undefined" : ["error"],
"no-use-before-define" : ["error", { "functions" : false }],
"no-useless-call" : ["error"],
"no-useless-computed-key" : ["error"],
"no-useless-rename" : ["error"],
"prefer-rest-params" : ["error"],
"prefer-spread" : ["error"],
"prefer-template" : ["error"],
"semi" : ["error", "always"],
"vars-on-top" : ["error"]
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -59,3 +59,5 @@ typings/

# next.js build output
.next

dist
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# tao-item-runner-qti-fe

QTI Item Runner frontend library of TAO.

Available scripts in the project:

- `HOST=<host> PORT=<port> npm run test <testname>`: run test suite
- `HOST` (optional environment variable, default: 127.0.0.1): Test server listen host
- `PORT` (optional environment variable, default: 8082): Test server listen port
- `testname` (optional): Specific test to run. If it is not provided, all will be ran.
- `HOST=<host> PORT=<port> npm run test:keepAlive`: start test server
- `HOST` (optional environment variable, default: 127.0.0.1): Test server listen host
- `PORT` (optional environment variable, default: 8082): Test server listen port
- `npm run build`: build for production into `dist` directory
- `npm run build:watch`: build for production into `dist` directory and watch for changes
- `npm run lint`: check syntax of code
31 changes: 31 additions & 0 deletions build/external-alias.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2019 (original work) Open Assessment Technologies SA ;
*/

export default (externals = []) => ({
name: 'external-alias', // this name will show up in warnings and errors
resolveId(source, importer) {
if (importer && externals.find(external => source.startsWith(external))) {
return {
id: source,
external: true,
moduleSideEffects: true
};
}
return null; // other ids should be handled as usually
}
});
33 changes: 33 additions & 0 deletions build/path.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2019 (original work) Open Assessment Technologies SA ;
*/

/**
* This file contains path definitions for build scripts.
*/
const path = require('path');
const rootPath = path.resolve(__dirname, '..');
const srcDir = path.resolve(rootPath, 'src');

module.exports = {
rootPath,
srcDir,
testDir: path.resolve(rootPath, 'test'),
outputDir: path.resolve(rootPath, 'dist'),
testOutputDir: path.resolve(rootPath, 'test'),
aliases: { taoQtiItem: srcDir, build: path.resolve(rootPath, 'build') }
};
144 changes: 144 additions & 0 deletions build/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2019 (original work) Open Assessment Technologies SA ;
*/

import path from 'path';
import glob from 'glob';
import alias from 'rollup-plugin-alias';
import handlebarsPlugin from 'rollup-plugin-handlebars-plus';
import externalAlias from './external-alias';
import resolve from 'rollup-plugin-node-resolve';
import json from 'rollup-plugin-json';

const { srcDir, outputDir, aliases } = require('./path');
const Handlebars = require('handlebars');

/**
* Support of handlebars 1.3.0
* TODO remove once migrated to hbs >= 3.0.0
*/
const originalVisitor = Handlebars.Visitor;
Handlebars.Visitor = function() {
return originalVisitor.call(this);
};
Handlebars.Visitor.prototype = Object.create(originalVisitor.prototype);
Handlebars.Visitor.prototype.accept = function() {
try {
originalVisitor.prototype.accept.apply(this, arguments);
} catch (e) {}
};
/* --------------------------------------------------------- */

const inputs = glob.sync(path.join(srcDir, '**', '*.js'));

/**
* Define all modules as external, so rollup won't bundle them together.
*/
const localExternals = inputs.map(
input =>
`taoQtiItem/${path
.relative(srcDir, input)
.replace(/\\/g, '/')
.replace(/\.js$/, '')}`
);

export default inputs.map(input => {
const name = path.relative(srcDir, input).replace(/\.js$/, '');
const dir = path.dirname(path.relative(srcDir, input));

return {
input,
output: {
dir: path.join(outputDir, dir),
format: 'amd',
name
},
external: [
'jquery',
'lodash',
'handlebars',
'i18n',
'module',
'context',
'async',
'require',

'raphael',
'scale.raphael',
'lib/gamp/gamp',
'class',
'mathJax',
'nouislider',
'interact',
'select2',
'ckeditor',
'iframeNotifier',

'qtiInfoControlContext',
'qtiCustomInteractionContext',

...localExternals
],
plugins: [
externalAlias([
'core',
'util',
'ui',
'lib',
'taoItems/runner',
'taoItems/assets',
'taoItems/scoring',
'taoQtiItem/portableElementRegistry'
]),
alias({
resolve: ['.js', '.json', '.tpl'],
...aliases
}),
resolve(),
handlebarsPlugin({
handlebars: {
id: 'handlebars',
options: {
sourceMap: false
},
module: Handlebars
},
helpers: ['build/tpl.js'],
templateExtension: '.tpl'
}),
json({
preferConst: false
}),
/**
* The following hack is necessary because expressions.js wants to export an object
* containing a key named 'default', and expressions/engine.js needs to import the whole thing.
* By omitting a line from Rollup's generated bundle, we can preserve the full object.
*/
{
name: 'expressions_helper',
generateBundle(options, bundle) {
if (options.name.match(/expressions[\/\\]engine/)) {
bundle['engine.js'].code = bundle['engine.js'].code.replace(
/expressionProcessors\.hasOwnProperty\('default'\)/,
false
);
}
}
}
]
};
});
Loading

0 comments on commit 56e76ca

Please sign in to comment.