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');
|
2015-12-30 15:18:18 +02:00
|
|
|
|
|
|
|
/**
|
2016-11-13 14:46:02 +03:00
|
|
|
* Install and copy the required files from the "composer_modules" directory.
|
2015-12-30 15:18:18 +02:00
|
|
|
*
|
|
|
|
* Composer needs to be installed and configured in order for this command to
|
|
|
|
* work properly.
|
|
|
|
*/
|
|
|
|
gulp.task('composer', function() {
|
|
|
|
del.sync([
|
2016-07-12 00:13:24 +03:00
|
|
|
'./src/vendor/**/*',
|
2016-10-16 22:37:00 +03:00
|
|
|
'!./src/vendor/index.html'
|
2015-12-30 15:18:18 +02:00
|
|
|
]);
|
|
|
|
|
|
|
|
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}',
|
|
|
|
'!vendor/**/{*.yml,*.md}',
|
|
|
|
'!vendor/bin{,/**}',
|
|
|
|
'!vendor/codeigniter{,/**}',
|
|
|
|
'!vendor/doctrine{,/**}',
|
|
|
|
'!vendor/myclabs{,/**}',
|
|
|
|
'!vendor/phpdocumentor{,/**}',
|
|
|
|
'!vendor/phpspec{,/**}',
|
|
|
|
'!vendor/phpunit{,/**}',
|
|
|
|
'!vendor/sebastian{,/**}',
|
|
|
|
'!vendor/symfony{,/**}',
|
|
|
|
'!vendor/webmozart{,/**}'
|
2015-12-30 15:18:18 +02:00
|
|
|
])
|
2016-07-12 00:13:24 +03:00
|
|
|
.pipe(gulp.dest('./src/vendor/'));
|
2015-12-30 15:18:18 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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([
|
|
|
|
'.tmp-package',
|
|
|
|
'easyappointments.zip'
|
|
|
|
]);
|
|
|
|
|
|
|
|
fs.copySync('src', '.tmp-package');
|
|
|
|
fs.copySync('.tmp-package/config-sample.php', '.tmp-package/config.php');
|
|
|
|
fs.removeSync('.tmp-package/config-sample.php');
|
|
|
|
fs.copySync('CHANGELOG.md', '.tmp-package/CHANGELOG.md');
|
|
|
|
fs.copySync('README.md', '.tmp-package/README.md');
|
|
|
|
fs.copySync('LICENSE', '.tmp-package/LICENSE');
|
2015-12-30 15:18:18 +02:00
|
|
|
|
2016-11-13 14:25:02 +03:00
|
|
|
del.sync([
|
|
|
|
'.tmp-package/storage/uploads/*',
|
|
|
|
'!.tmp-package/storage/uploads/index.html'
|
|
|
|
]);
|
|
|
|
|
2016-01-17 20:06:57 +02:00
|
|
|
del.sync([
|
2016-11-13 01:59:38 +03:00
|
|
|
'.tmp-package/storage/logs/*',
|
|
|
|
'!.tmp-package/storage/logs/index.html'
|
2016-10-16 22:37:00 +03:00
|
|
|
]);
|
2016-01-17 20:06:57 +02:00
|
|
|
|
2016-11-13 14:25:02 +03:00
|
|
|
del.sync([
|
|
|
|
'.tmp-package/storage/sessions/*',
|
|
|
|
'!.tmp-package/storage/sessions/.htaccess',
|
|
|
|
'!.tmp-package/storage/sessions/index.html'
|
|
|
|
]);
|
|
|
|
|
|
|
|
del.sync([
|
|
|
|
'.tmp-package/storage/cache/*',
|
|
|
|
'!.tmp-package/storage/cache/.htaccess',
|
|
|
|
'!.tmp-package/storage/cache/index.html'
|
|
|
|
]);
|
|
|
|
|
2015-12-30 23:33:19 +02:00
|
|
|
zip('.tmp-package', { saveTo: 'easyappointments.zip' }, function (err, buffer) {
|
|
|
|
if (err)
|
|
|
|
console.log('Zip Error', err);
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
2015-12-30 15:18:18 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate code documentation.
|
|
|
|
*/
|
2015-12-31 00:01:30 +02:00
|
|
|
gulp.task('doc', function(done) {
|
2016-10-16 22:37:00 +03:00
|
|
|
fs.removeSync('doc/apigen');
|
2015-12-31 00:01:30 +02:00
|
|
|
fs.mkdirSync('doc/apigen');
|
2016-10-16 22:37:00 +03:00
|
|
|
fs.removeSync('doc/jsdoc');
|
2015-12-31 00:01:30 +02:00
|
|
|
fs.mkdirSync('doc/jsdoc');
|
2016-10-16 22:37:00 +03:00
|
|
|
fs.removeSync('doc/plato');
|
2015-12-31 00:01:30 +02:00
|
|
|
fs.mkdirSync('doc/plato');
|
2015-12-30 15:18:18 +02:00
|
|
|
|
2017-06-11 22:46:30 +03:00
|
|
|
const commands = [
|
2015-12-31 00:01:30 +02:00
|
|
|
'php rsc/apigen.phar generate ' +
|
|
|
|
'-s "src/application/controllers,src/application/models,src/application/libraries" ' +
|
|
|
|
'-d "doc/apigen" --exclude "*external*" --tree --todo --template-theme "bootstrap"',
|
|
|
|
|
2016-10-16 22:37:00 +03:00
|
|
|
path.join('.', 'node_modules', '.bin', 'jsdoc') + ' "src/assets/js" -d "doc/jsdoc"',
|
2015-12-31 00:01:30 +02:00
|
|
|
|
2016-10-16 22:37:00 +03:00
|
|
|
path.join('.', 'node_modules', '.bin', 'plato') + ' -r -d "doc/plato" "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();
|
2015-12-30 15:18:18 +02:00
|
|
|
});
|