Updated Gulpfile. Fixed #1746.
This commit is contained in:
parent
5e3ff74575
commit
17dc0943a3
72
gulpfile.js
72
gulpfile.js
@ -21,9 +21,11 @@ var argv = require('yargs').argv,
|
|||||||
mainBowerFiles = require('main-bower-files'),
|
mainBowerFiles = require('main-bower-files'),
|
||||||
minifyCSS = require('gulp-minify-css'),
|
minifyCSS = require('gulp-minify-css'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
uglify = require('gulp-uglify');
|
through = require('through2'),
|
||||||
|
uglify = require('gulp-uglify'),
|
||||||
|
vsprintf = require('sprintf-js').vsprintf;
|
||||||
|
|
||||||
// Directory where the results go
|
// Directory where the results go to
|
||||||
var output_directory = path.join('openslides', 'static');
|
var output_directory = path.join('openslides', 'static');
|
||||||
|
|
||||||
|
|
||||||
@ -67,13 +69,22 @@ gulp.task('ckeditor', function () {
|
|||||||
.pipe(gulp.dest(path.join(output_directory, 'ckeditor')));
|
.pipe(gulp.dest(path.join(output_directory, 'ckeditor')));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Compiles translation files (*.po) to *.json and saves them in the directory
|
||||||
|
// openslides/static/i18n/.
|
||||||
|
gulp.task('translations', function () {
|
||||||
|
return gulp.src(path.join('openslides', 'locale', 'angular-gettext', '*.po'))
|
||||||
|
.pipe(gettext.compile({
|
||||||
|
format: 'json'
|
||||||
|
}))
|
||||||
|
.pipe(gulp.dest(path.join(output_directory, 'i18n')));
|
||||||
|
});
|
||||||
|
|
||||||
// Gulp default task. Runs all other tasks before.
|
// Gulp default task. Runs all other tasks before.
|
||||||
gulp.task('default', ['js-libs', 'css-libs', 'fonts-libs', 'ckeditor'], function () {});
|
gulp.task('default', ['js-libs', 'css-libs', 'fonts-libs', 'ckeditor', 'translations'], function () {});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extra tasks that have to be called manually. Useful for development and
|
* Extra tasks that have to be called manually. Useful for development.
|
||||||
* packageing.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Extracts translatable strings using angular-gettext and saves them in file
|
// Extracts translatable strings using angular-gettext and saves them in file
|
||||||
@ -85,19 +96,50 @@ gulp.task('pot', function () {
|
|||||||
.pipe(gulp.dest('openslides/locale/angular-gettext/'));
|
.pipe(gulp.dest('openslides/locale/angular-gettext/'));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Compiles translation files (*.po) to *.json and saves them in the directory
|
|
||||||
// openslides/static/i18n/.
|
|
||||||
gulp.task('translations', function () {
|
|
||||||
return gulp.src('openslides/locale/angular-gettext/*.po')
|
|
||||||
.pipe(gettext.compile({
|
|
||||||
format: 'json'
|
|
||||||
}))
|
|
||||||
.pipe(gulp.dest(path.join(output_directory, 'i18n')));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Checks JavaScript using JSHint
|
// Checks JavaScript using JSHint
|
||||||
gulp.task('jshint', function () {
|
gulp.task('jshint', function () {
|
||||||
return gulp.src([ 'gulpfile.js', path.join( 'openslides', '*', 'static', '**', '*.js' ) ])
|
return gulp.src([ 'gulpfile.js', path.join( 'openslides', '*', 'static', '**', '*.js' ) ])
|
||||||
.pipe(jshint())
|
.pipe(jshint())
|
||||||
.pipe(jshint.reporter('default'));
|
.pipe(jshint.reporter('default'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Extracts names, URLs and licensed of all uses bower components and prints
|
||||||
|
// it to the console. This is useful to update the README.rst during release
|
||||||
|
// process.
|
||||||
|
gulp.task('bower-components-for-readme', function () {
|
||||||
|
var files = [];
|
||||||
|
return gulp.src([
|
||||||
|
path.join('bower_components', '*', 'bower.json'),
|
||||||
|
path.join('bower_components', '*', 'component.json'),
|
||||||
|
])
|
||||||
|
.pipe(
|
||||||
|
through.obj(
|
||||||
|
function (chunk, encoding, callback) {
|
||||||
|
files.push(chunk);
|
||||||
|
callback();
|
||||||
|
},
|
||||||
|
function (callback) {
|
||||||
|
// Extract JSON from bower.json or components.json file.
|
||||||
|
var extracted = [];
|
||||||
|
for (var index = 0; index < files.length; index++) {
|
||||||
|
extracted.push(JSON.parse(files[index].contents.toString()));
|
||||||
|
}
|
||||||
|
// Sort files.
|
||||||
|
extracted.sort(function (a, b) {
|
||||||
|
return a.name < b.name ? -1 : 1;
|
||||||
|
});
|
||||||
|
// Print out line for README.rst.
|
||||||
|
for (var index2 = 0; index2 < extracted.length; index2++) {
|
||||||
|
var data = [
|
||||||
|
extracted[index2].name,
|
||||||
|
extracted[index2].homepage,
|
||||||
|
extracted[index2].license,
|
||||||
|
];
|
||||||
|
console.log(vsprintf(' * `%s <%s>`_, License: %s', data));
|
||||||
|
}
|
||||||
|
// End stream without further file processing.
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
"main-bower-files": "~2.4.1",
|
"main-bower-files": "~2.4.1",
|
||||||
"yargs": "~1.3.3",
|
"yargs": "~1.3.3",
|
||||||
"po2json": "~0.3.2",
|
"po2json": "~0.3.2",
|
||||||
"gulp-jshint": "~1.11.2"
|
"gulp-jshint": "~1.11.2",
|
||||||
|
"through2": "~2.0.0",
|
||||||
|
"sprintf-js": "~1.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user