MaketRandevu/gulpfile.js

115 lines
3.2 KiB
JavaScript
Raw Normal View History

2017-06-11 22:46:30 +03:00
const gulp = require('gulp');
const exec = require('child_process').execSync;
const del = require('del');
const fs = require('fs-extra');
const path = require('path');
const zip = require('zip-dir');
/**
* Install and copy the required files from the "composer_modules" directory.
*
* Composer needs to be installed and configured in order for this command to
* work properly.
*/
gulp.task('composer', function() {
del.sync([
'./src/vendor/**/*',
'!./src/vendor/index.html'
]);
return gulp.src([
2017-06-11 22:46:30 +03:00
'vendor/**/*',
'!vendor/**/demo{,/**}',
'!vendor/**/{demo,docs,examples,test,tests,extras,language}{,/**}',
'!vendor/**/{composer.json,composer.lock,.gitignore}',
2017-06-11 22:52:13 +03:00
'!vendor/**/{*.yml,*.md,*phpunit*,*.mdown}',
2017-06-11 22:46:30 +03:00
'!vendor/bin{,/**}',
'!vendor/codeigniter{,/**}',
'!vendor/doctrine{,/**}',
'!vendor/myclabs{,/**}',
'!vendor/phpdocumentor{,/**}',
'!vendor/phpspec{,/**}',
'!vendor/phpunit{,/**}',
'!vendor/sebastian{,/**}',
'!vendor/symfony{,/**}',
'!vendor/webmozart{,/**}'
])
.pipe(gulp.dest('./src/vendor/'));
});
/**
* Build the project and create an easyappointments.zip file ready for distribution.
*/
2015-12-30 23:33:19 +02:00
gulp.task('build', function(done) {
del.sync([
'build',
'easyappointments-0.0.0.zip'
2015-12-30 23:33:19 +02:00
]);
fs.copySync('src', 'build');
fs.removeSync('build/config.php');
fs.copySync('CHANGELOG.md', 'build/CHANGELOG.md');
fs.copySync('README.md', 'build/README.md');
fs.copySync('LICENSE', 'build/LICENSE');
del.sync([
'build/storage/uploads/*',
'!build/storage/uploads/index.html'
]);
del.sync([
'build/storage/logs/*',
'!build/storage/logs/index.html'
]);
del.sync([
'build/storage/sessions/*',
'!build/storage/sessions/.htaccess',
'!build/storage/sessions/index.html'
]);
del.sync([
'build/storage/cache/*',
'!build/storage/cache/.htaccess',
'!build/storage/cache/index.html'
]);
zip('build', { saveTo: 'easyappointments-0.0.0.zip' }, function (err, buffer) {
2015-12-30 23:33:19 +02:00
if (err)
console.log('Zip Error', err);
done();
});
});
/**
* Generate code documentation.
*/
2015-12-31 00:01:30 +02:00
gulp.task('doc', function(done) {
fs.removeSync('doc/apigen/html');
fs.mkdirSync('doc/apigen/html');
fs.removeSync('doc/jsdoc/html');
fs.mkdirSync('doc/jsdoc/html');
fs.removeSync('doc/plato/html');
fs.mkdirSync('doc/plato/html');
2017-06-11 22:46:30 +03:00
const commands = [
'php doc/apigen/apigen.phar generate ' +
2015-12-31 00:01:30 +02:00
'-s "src/application/controllers,src/application/models,src/application/libraries" ' +
'-d "doc/apigen/html" --exclude "*external*" --tree --todo --template-theme "bootstrap"',
2015-12-31 00:01:30 +02:00
path.join('.', 'node_modules', '.bin', 'jsdoc') + ' "src/assets/js" -d "doc/jsdoc/html"',
2015-12-31 00:01:30 +02:00
path.join('.', 'node_modules', '.bin', 'plato') + ' -r -d "doc/plato/html" "src/assets/js"'
2015-12-31 00:01:30 +02:00
];
commands.forEach(function(command) {
exec(command, function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
});
});
done();
});