Skip to content

Commit

Permalink
global: improvement of project structure
Browse files Browse the repository at this point in the history
* Improves project structure by splitting the components.

* Improves test feedback by adding test coverage report when you run
  ``npm test``.

Signed-off-by: Harris Tzovanakis <me@drjova.com>
  • Loading branch information
drjova committed Aug 4, 2016
1 parent 3b9cf4a commit 2a1cd73
Show file tree
Hide file tree
Showing 15 changed files with 1,071 additions and 914 deletions.
2 changes: 1 addition & 1 deletion examples/simple/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<script src='./node_modules/tv4/tv4.js'></script>
<script src='./node_modules/angular-schema-form/dist/schema-form.js'></script>
<script src='./node_modules/angular-schema-form/dist/bootstrap-decorator.js'></script>
<script src="/src/invenio-records-js/invenioRecords.module.js"></script>
<script src="/dist/invenio-records-js.js"></script>
<script src="./static/app.js"></script>
<style>
body {
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/static/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@

(function (angular) {
angular.module('invenioRecordsDemo', [
'invenioRecords', 'schemaForm'
'invenioRecords'
]);
})(angular);
28 changes: 18 additions & 10 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ var sourceDirectory = path.join(rootDirectory, './src');

var sourceFiles = [

// Make sure module files are handled first
path.join(sourceDirectory, '/**/*.module.js'),
// Then add all JavaScript files
path.join(sourceDirectory, '/*.js'),

// Then add all JavaScript files
path.join(sourceDirectory, '/**/*.js'),
Expand All @@ -69,7 +69,7 @@ var lintFiles = [
*/

// run all the build tasks
gulp.task('build', ['clean.build'], function (done) {
gulp.task('build', ['clean.build'], function(done) {
runSequence(
'build.src', 'build.templates', done
);
Expand All @@ -80,6 +80,8 @@ gulp.task('build.src', function() {
gulp.src(sourceFiles)
.pipe(plugins.plumber())
.pipe(plugins.concat('invenio-records-js.js'))
.pipe(plugins.stripComments())
.pipe(plugins.header(licences.javascript))
.pipe(gulp.dest('./dist/'))
.pipe(plugins.uglify())
.pipe(plugins.rename('invenio-records-js.min.js'))
Expand All @@ -99,12 +101,12 @@ gulp.task('build.templates', function() {
*/

// Run test once and exit
gulp.task('test', function (done) {
gulp.task('test', function(done) {
runSequence('test.jshint', 'test.src', done);
});

// check jshint
gulp.task('test.jshint', function () {
gulp.task('test.jshint', function() {
return gulp.src(lintFiles)
.pipe(plugins.plumber())
.pipe(plugins.jshint())
Expand All @@ -113,15 +115,15 @@ gulp.task('test.jshint', function () {
});

// test sources
gulp.task('test.src', function (done) {
gulp.task('test.src', function(done) {
karma.start({
configFile: __dirname + '/karma-src.conf.js',
singleRun: true
}, done);
});

// coveralls
gulp.task('coveralls', function () {
gulp.task('coveralls', function() {
return gulp.src('coverage/**/lcov.info')
.pipe(plugins.coveralls());
});
Expand All @@ -131,14 +133,20 @@ gulp.task('coveralls', function () {
* Demo
*/

gulp.task('demo', function() {
// run the demo
gulp.task('demo.run', function() {
gulp.src(rootDirectory)
.pipe(plugins.webserver({
livereload: true,
open: '/examples/index.html'
}));
});

// run build and then the demo
gulp.task('demo', function(done) {
runSequence('build', 'demo.run', done);
});

/**
* Clean tasks
*/
Expand All @@ -152,7 +160,7 @@ gulp.task('clean.build', function() {
* Watch
*/

gulp.task('watch', function () {
gulp.task('watch', function() {
// Watch JavaScript files
gulp.watch(sourceFiles, ['test']);
});
Expand All @@ -161,6 +169,6 @@ gulp.task('watch', function () {
* Default taks
*/

gulp.task('default', function () {
gulp.task('default', function() {
runSequence('test', 'watch');
});
9 changes: 7 additions & 2 deletions karma-src.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ module.exports = function(config) {
'node_modules/angular-schema-form/dist/schema-form.js',
'node_modules/angular-schema-form/dist/bootstrap-decorator.js',
'node_modules/angular-schema-form-dynamic-select/angular-schema-form-dynamic-select.js',
'src/*/*.js',
'src/**/*.js',
'src/**/*.html',
'test/unit/**/*.js',
Expand All @@ -89,8 +90,12 @@ module.exports = function(config) {

// Coverage reporter
coverageReporter: {
type: 'lcov',
dir: 'coverage/'
dir: 'coverage/',
reporters: [
{type: 'text'},
{type: 'html', subdir: 'report-html'},
{type: 'lcov', subdir: 'report-lcov'}
]
},


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"gulp-load-plugins": "^1.1.0",
"gulp-plumber": "^0.6.6",
"gulp-rename": "^1.2.0",
"gulp-strip-comments": "^2.4.3",
"gulp-uglify": "^0.3.1",
"gulp-webserver": "^0.9.1",
"istanbul": "^0.4.1",
"jquery": "^2.1.4",
"jsdoc": "^3.4.0",
"jshint-stylish": "^0.4.0",
Expand Down
Loading

0 comments on commit 2a1cd73

Please sign in to comment.