2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* 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, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
// Librerie NPM richieste per l'esecuzione
|
2020-08-06 10:17:56 +02:00
|
|
|
const gulp = require('gulp');
|
|
|
|
const merge = require('merge-stream');
|
|
|
|
const del = require('del');
|
|
|
|
const gulpIf = require('gulp-if');
|
2020-08-19 14:16:47 +02:00
|
|
|
const babel = require('gulp-babel');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Minificatori
|
2020-08-06 10:17:56 +02:00
|
|
|
const minifyJS = require('gulp-uglify');
|
|
|
|
const minifyCSS = require('gulp-clean-css');
|
|
|
|
const minifyJSON = require('gulp-json-minify');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Interpretatori CSS
|
2023-05-11 16:06:25 +02:00
|
|
|
const sass = require('gulp-sass')(require('sass'));
|
2020-08-06 10:17:56 +02:00
|
|
|
const less = require('gulp-less');
|
|
|
|
const stylus = require('gulp-stylus');
|
|
|
|
const autoprefixer = require('gulp-autoprefixer');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Concatenatore
|
2020-08-06 10:17:56 +02:00
|
|
|
const concat = require('gulp-concat');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Altro
|
2020-08-06 10:17:56 +02:00
|
|
|
const flatten = require('gulp-flatten');
|
|
|
|
const rename = require('gulp-rename');
|
2020-08-03 15:29:19 +02:00
|
|
|
|
|
|
|
// Release
|
2020-08-06 10:17:56 +02:00
|
|
|
const glob = require('globby');
|
|
|
|
const md5File = require('md5-file')
|
|
|
|
const fs = require('fs');
|
|
|
|
const archiver = require('archiver');
|
|
|
|
const shell = require('shelljs');
|
|
|
|
const inquirer = require('inquirer');
|
2024-08-28 19:13:37 +02:00
|
|
|
const { Readable } = require('stream');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Configurazione
|
2020-08-06 10:17:56 +02:00
|
|
|
const config = {
|
2017-08-04 16:28:16 +02:00
|
|
|
production: 'assets/dist', // Cartella di destinazione
|
|
|
|
development: 'assets/src', // Cartella dei file di personalizzazione
|
2023-01-24 14:53:28 +01:00
|
|
|
debug: false,
|
2020-08-19 14:16:47 +02:00
|
|
|
nodeDirectory: './node_modules', // Percorso per node_modules
|
2017-08-04 16:28:16 +02:00
|
|
|
paths: {
|
|
|
|
js: 'js',
|
|
|
|
css: 'css',
|
|
|
|
images: 'img',
|
|
|
|
fonts: 'fonts'
|
2020-08-19 14:16:47 +02:00
|
|
|
},
|
|
|
|
babelOptions: {
|
2023-01-24 14:53:28 +01:00
|
|
|
compact: true,
|
2020-08-19 14:16:47 +02:00
|
|
|
presets: [
|
|
|
|
['@babel/env', {
|
|
|
|
modules: false
|
|
|
|
}],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
minifiers: {
|
|
|
|
css: {
|
|
|
|
rebase: false,
|
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
}
|
|
|
|
};
|
2020-08-19 14:16:47 +02:00
|
|
|
config.babelOptions.compact = !config.debug;
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Elaborazione e minificazione di JS
|
2020-06-30 13:24:55 +02:00
|
|
|
const JS = gulp.parallel(() => {
|
2020-08-19 14:16:47 +02:00
|
|
|
const vendor = [
|
|
|
|
'jquery/dist/jquery.js',
|
|
|
|
'autosize/dist/autosize.js',
|
2021-07-20 15:23:39 +02:00
|
|
|
'autocompleter/autocomplete.js',
|
|
|
|
'html5sortable/dist/html5sortable.js',
|
2024-05-22 17:16:50 +02:00
|
|
|
'popper.js/dist/umd/popper.js',
|
2020-08-19 14:16:47 +02:00
|
|
|
'bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js',
|
|
|
|
'moment/moment.js',
|
2021-07-20 20:48:02 +02:00
|
|
|
'components-jqueryui/jquery-ui.js',
|
2020-08-19 14:16:47 +02:00
|
|
|
'datatables.net/js/jquery.dataTables.js',
|
|
|
|
'datatables.net-buttons/js/dataTables.buttons.js',
|
|
|
|
'datatables.net-buttons/js/buttons.colVis.js',
|
|
|
|
'datatables.net-buttons/js/buttons.flash.js',
|
|
|
|
'datatables.net-buttons/js/buttons.html5.js',
|
|
|
|
'datatables.net-buttons/js/buttons.print.js',
|
|
|
|
'datatables.net-scroller/js/dataTables.scroller.js',
|
|
|
|
'datatables.net-select/js/dataTables.select.js',
|
|
|
|
'dropzone/dist/dropzone.js',
|
2020-09-04 09:42:38 +02:00
|
|
|
'autonumeric/dist/autoNumeric.min.js',
|
2020-08-19 14:16:47 +02:00
|
|
|
'eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js',
|
2023-01-23 23:10:52 +01:00
|
|
|
'fullcalendar-scheduler/index.global.js',
|
|
|
|
'@fullcalendar/moment/index.global.js',
|
|
|
|
'@fullcalendar/core/locales/it.global.js',
|
2020-08-19 14:16:47 +02:00
|
|
|
'geocomplete/jquery.geocomplete.js',
|
|
|
|
'inputmask/dist/min/jquery.inputmask.bundle.min.js',
|
|
|
|
'jquery-form/src/jquery.form.js',
|
|
|
|
'jquery-ui-touch-punch/jquery.ui.touch-punch.js',
|
|
|
|
'jquery.shorten/src/jquery.shorten.js',
|
|
|
|
'numeral/numeral.js',
|
|
|
|
'parsleyjs/dist/parsley.js',
|
|
|
|
'select2/dist/js/select2.min.js',
|
|
|
|
'signature_pad/dist/signature_pad.js',
|
|
|
|
'sweetalert2/dist/sweetalert2.js',
|
|
|
|
'toastr/build/toastr.min.js',
|
|
|
|
'tooltipster/dist/js/tooltipster.bundle.js',
|
|
|
|
'admin-lte/dist/js/adminlte.js',
|
|
|
|
'bootstrap/dist/js/bootstrap.min.js',
|
|
|
|
'bootstrap-daterangepicker/daterangepicker.js',
|
|
|
|
'datatables.net-bs/js/dataTables.bootstrap.js',
|
|
|
|
'datatables.net-buttons-bs/js/buttons.bootstrap.js',
|
|
|
|
'smartwizard/dist/js/jquery.smartWizard.min.js',
|
2021-03-25 19:25:30 +01:00
|
|
|
'bootstrap-maxlength/dist/bootstrap-maxlength.js',
|
2023-06-15 14:09:04 +02:00
|
|
|
'leaflet/dist/leaflet.js',
|
|
|
|
'leaflet-gesture-handling/dist/leaflet-gesture-handling.min.js',
|
2024-06-30 14:48:45 +02:00
|
|
|
'leaflet.fullscreen/Control.FullScreen.js',
|
2024-04-01 23:09:37 +02:00
|
|
|
'ismobilejs/dist/isMobile.min.js',
|
|
|
|
'ua-parser-js/dist/ua-parser.min.js',
|
2024-11-14 17:46:47 +01:00
|
|
|
'readmore.js/readmore.js',
|
2020-08-19 14:16:47 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
for (const i in vendor) {
|
|
|
|
vendor[i] = config.nodeDirectory + '/' + vendor[i];
|
|
|
|
}
|
|
|
|
|
2022-11-28 11:44:56 +01:00
|
|
|
return gulp.src(vendor, {
|
|
|
|
allowEmpty: true
|
|
|
|
})
|
2020-08-19 14:16:47 +02:00
|
|
|
.pipe(babel(config.babelOptions))
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(concat('app.min.js'))
|
2024-06-10 12:03:44 +02:00
|
|
|
.pipe(gulpIf(!config.debug, minifyJS({compress:false})))
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.js));
|
2020-06-30 13:24:55 +02:00
|
|
|
}, srcJS);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Elaborazione e minificazione di JS personalizzati
|
2020-06-30 13:24:55 +02:00
|
|
|
function srcJS() {
|
2020-08-06 10:17:56 +02:00
|
|
|
const js = gulp.src([
|
2020-08-19 14:16:47 +02:00
|
|
|
config.development + '/' + config.paths.js + '/base/*.js',
|
2020-06-30 13:24:55 +02:00
|
|
|
])
|
2020-08-19 14:16:47 +02:00
|
|
|
.pipe(babel(config.babelOptions))
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(concat('custom.min.js'))
|
2020-08-19 14:16:47 +02:00
|
|
|
.pipe(gulpIf(!config.debug, minifyJS()))
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.js));
|
2019-07-26 17:40:52 +02:00
|
|
|
|
2020-08-19 14:16:47 +02:00
|
|
|
const functions = gulp.src([
|
2019-07-26 17:40:52 +02:00
|
|
|
config.development + '/' + config.paths.js + '/functions/*.js',
|
|
|
|
])
|
2020-08-19 14:16:47 +02:00
|
|
|
.pipe(babel(config.babelOptions))
|
2019-07-26 17:40:52 +02:00
|
|
|
.pipe(concat('functions.min.js'))
|
2020-08-19 14:16:47 +02:00
|
|
|
.pipe(gulpIf(!config.debug, minifyJS()))
|
2019-07-26 17:40:52 +02:00
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.js));
|
2020-06-30 13:24:55 +02:00
|
|
|
|
2020-08-19 14:16:47 +02:00
|
|
|
return merge(js, functions);
|
2020-06-30 13:24:55 +02:00
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Elaborazione e minificazione di CSS
|
2020-06-30 13:24:55 +02:00
|
|
|
const CSS = gulp.parallel(() => {
|
2020-08-19 14:16:47 +02:00
|
|
|
const vendor = [
|
|
|
|
'bootstrap-colorpicker/dist/css/bootstrap-colorpicker.css',
|
|
|
|
'dropzone/dist/dropzone.css',
|
|
|
|
'eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css',
|
|
|
|
'font-awesome/css/font-awesome.min.css',
|
|
|
|
'parsleyjs/src/parsley.css',
|
|
|
|
'select2/dist/css/select2.min.css',
|
|
|
|
'sweetalert2/dist/sweetalert2.css',
|
|
|
|
'toastr/build/toastr.min.css',
|
|
|
|
'tooltipster/dist/css/tooltipster.bundle.css',
|
|
|
|
'admin-lte/dist/css/AdminLTE.css',
|
|
|
|
'bootstrap/dist/css/bootstrap.min.css',
|
|
|
|
'bootstrap-daterangepicker/daterangepicker.css',
|
|
|
|
'datatables.net-bs/css/dataTables.bootstrap.css',
|
|
|
|
'datatables.net-buttons-bs/css/buttons.bootstrap.css',
|
|
|
|
'datatables.net-scroller-bs/css/scroller.bootstrap.css',
|
|
|
|
'datatables.net-select-bs/css/select.bootstrap.css',
|
|
|
|
'smartwizard/dist/css/smart_wizard.min.css',
|
|
|
|
'smartwizard/dist/css/smart_wizard_theme_arrows.min.css',
|
2023-06-15 14:09:04 +02:00
|
|
|
'leaflet-gesture-handling/dist/leaflet-gesture-handling.min.css',
|
|
|
|
'leaflet/dist/leaflet.css',
|
2024-06-30 14:48:45 +02:00
|
|
|
'leaflet.fullscreen/Control.FullScreen.css',
|
2024-05-20 13:17:14 +02:00
|
|
|
'@ttskch/select2-bootstrap4-theme/dist/select2-bootstrap4.min.css'
|
2020-08-19 14:16:47 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
for (const i in vendor) {
|
|
|
|
vendor[i] = config.nodeDirectory + '/' + vendor[i];
|
|
|
|
}
|
|
|
|
|
2022-11-28 11:44:56 +01:00
|
|
|
return gulp.src(vendor, {
|
|
|
|
allowEmpty: true
|
|
|
|
})
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(gulpIf('*.scss', sass(), gulpIf('*.less', less(), gulpIf('*.styl', stylus()))))
|
2020-06-30 13:24:55 +02:00
|
|
|
.pipe(autoprefixer())
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(minifyCSS({
|
|
|
|
rebase: false,
|
|
|
|
}))
|
|
|
|
.pipe(concat('app.min.css'))
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.css));
|
2020-06-30 13:24:55 +02:00
|
|
|
}, srcCSS);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Elaborazione e minificazione di CSS personalizzati
|
2020-06-30 13:24:55 +02:00
|
|
|
function srcCSS() {
|
2020-08-06 10:17:56 +02:00
|
|
|
const css = gulp.src([
|
2020-06-30 13:24:55 +02:00
|
|
|
config.development + '/' + config.paths.css + '/*.{css,scss,less,styl}',
|
|
|
|
])
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(gulpIf('*.scss', sass(), gulpIf('*.less', less(), gulpIf('*.styl', stylus()))))
|
2020-06-30 13:24:55 +02:00
|
|
|
.pipe(autoprefixer())
|
2020-08-19 14:16:47 +02:00
|
|
|
.pipe(gulpIf(!config.debug, minifyCSS(config.minifiers.css)))
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(concat('style.min.css'))
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.css));
|
|
|
|
|
2020-08-06 10:17:56 +02:00
|
|
|
const print = gulp.src([
|
2020-06-30 13:24:55 +02:00
|
|
|
config.development + '/' + config.paths.css + '/print/*.{css,scss,less,styl}',
|
|
|
|
], {
|
|
|
|
allowEmpty: true
|
|
|
|
})
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(gulpIf('*.scss', sass(), gulpIf('*.less', less(), gulpIf('*.styl', stylus()))))
|
2020-06-30 13:24:55 +02:00
|
|
|
.pipe(autoprefixer())
|
2020-08-19 14:16:47 +02:00
|
|
|
.pipe(gulpIf(!config.debug, minifyCSS(config.minifiers.css)))
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(concat('print.min.css'))
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.css));
|
|
|
|
|
2020-08-06 10:17:56 +02:00
|
|
|
const themes = gulp.src([
|
2024-05-16 18:02:50 +02:00
|
|
|
config.development + '/' + config.paths.css + '/themes/*.{css,scss,less,styl}',
|
|
|
|
config.nodeDirectory + '/admin-lte/dist/css/adminlte.min.css',
|
|
|
|
])
|
|
|
|
.pipe(gulpIf('*.scss', sass(), gulpIf('*.less', less(), gulpIf('*.styl', stylus()))))
|
|
|
|
.pipe(autoprefixer())
|
|
|
|
.pipe(gulpIf(!config.debug, minifyCSS(config.minifiers.css)))
|
|
|
|
.pipe(concat('themes.min.css'))
|
|
|
|
.pipe(flatten())
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.css));
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2020-06-30 13:24:55 +02:00
|
|
|
return merge(css, print, themes);
|
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
|
2020-06-30 13:24:55 +02:00
|
|
|
// Elaborazione delle immagini
|
|
|
|
const images = srcImages;
|
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
// Elaborazione delle immagini personalizzate
|
2020-06-30 13:24:55 +02:00
|
|
|
function srcImages() {
|
|
|
|
return gulp.src([
|
|
|
|
config.development + '/' + config.paths.images + '/**/*.{jpg,png,jpeg,gif}',
|
|
|
|
])
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.images));
|
2020-06-30 13:24:55 +02:00
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2023-06-15 14:09:04 +02:00
|
|
|
function leaflet() {
|
2024-06-30 14:48:45 +02:00
|
|
|
gulp.src([
|
|
|
|
config.nodeDirectory + '/leaflet.fullscreen/icon-fullscreen.svg',
|
|
|
|
]).pipe(gulp.dest(config.production + '/' + config.paths.images + '/leaflet'));
|
|
|
|
|
2024-09-05 18:17:12 +02:00
|
|
|
gulp.src([
|
|
|
|
config.development + '/' + config.paths.images + '/leaflet/*',
|
|
|
|
]).pipe(gulp.dest(config.production + '/' + config.paths.images + '/leaflet'));
|
|
|
|
|
2023-06-15 14:09:04 +02:00
|
|
|
return gulp.src([
|
|
|
|
config.nodeDirectory + '/leaflet/dist/images/*.{jpg,png,jpeg}',
|
|
|
|
])
|
|
|
|
.pipe(flatten())
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.images + '/leaflet'));
|
|
|
|
}
|
|
|
|
|
2023-07-28 14:17:04 +02:00
|
|
|
function wacom(){
|
|
|
|
const vendor = [
|
|
|
|
'modules/clipper-lib/clipper.js',
|
|
|
|
'modules/js-md5/build/md5.min.js',
|
|
|
|
'modules/poly2tri/dist/poly2tri.min.js',
|
|
|
|
'modules/protobufjs/dist/protobuf.min.js',
|
|
|
|
'modules/jszip/dist/jszip.min.js',
|
|
|
|
'modules/gl-matrix/gl-matrix-min.js',
|
|
|
|
'modules/rbush/rbush.min.js',
|
|
|
|
'modules/js-ext/js-ext-min.js',
|
|
|
|
'modules/digital-ink/digital-ink-min.js',
|
|
|
|
'common/will/tools.js',
|
|
|
|
'modules/sjcl/sjcl.js',
|
|
|
|
'common/libs/signature_sdk.js',
|
2024-02-19 19:03:55 +01:00
|
|
|
'common/libs/signature_sdk_helper.js',
|
|
|
|
'common/libs/stu-sdk.min.js',
|
|
|
|
'modules/node-forge/dist/forge.min.js',
|
2023-07-28 14:17:04 +02:00
|
|
|
'sigCaptDialog/sigCaptDialog.js',
|
|
|
|
'sigCaptDialog/stuCaptDialog.js'
|
|
|
|
];
|
|
|
|
|
|
|
|
for (const i in vendor) {
|
|
|
|
vendor[i] = config.development + '/' + config.paths.js + '/wacom/' + vendor[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
gulp.src([
|
|
|
|
'assets/src/js/wacom/common/libs/signature_sdk.wasm'
|
|
|
|
])
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/wacom/'));
|
2023-06-15 14:09:04 +02:00
|
|
|
|
2023-07-28 14:17:04 +02:00
|
|
|
return gulp.src(vendor, {
|
|
|
|
allowEmpty: true
|
|
|
|
})
|
|
|
|
.pipe(babel(config.babelOptions))
|
|
|
|
.pipe(concat('wacom.min.js'))
|
|
|
|
.pipe(gulpIf(!config.debug, minifyJS()))
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.js));
|
|
|
|
|
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Elaborazione dei fonts
|
2020-08-19 14:16:47 +02:00
|
|
|
const fonts = gulp.parallel(() => {
|
|
|
|
const vendor = [
|
|
|
|
'font-awesome/fonts/fontawesome-webfont.eot',
|
|
|
|
'font-awesome/fonts/fontawesome-webfont.svg',
|
|
|
|
'font-awesome/fonts/fontawesome-webfont.ttf',
|
|
|
|
'font-awesome/fonts/fontawesome-webfont.woff',
|
|
|
|
'font-awesome/fonts/fontawesome-webfont.woff2',
|
|
|
|
'font-awesome/fonts/FontAwesome.otf',
|
2022-06-10 17:33:35 +02:00
|
|
|
'../assets/src/css/fonts/sourcesanspro-regular-webfont.eot',
|
|
|
|
'../assets/src/css/fonts/sourcesanspro-regular-webfont.svg',
|
|
|
|
'../assets/src/css/fonts/sourcesanspro-regular-webfont.ttf',
|
|
|
|
'../assets/src/css/fonts/sourcesanspro-regular-webfont.woff',
|
|
|
|
'../assets/src/css/fonts/sourcesanspro-regular-webfont.woff2',
|
2020-08-19 14:16:47 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
for (const i in vendor) {
|
|
|
|
vendor[i] = config.nodeDirectory + '/' + vendor[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
return gulp.src(vendor)
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(flatten())
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.fonts));
|
2020-06-30 13:24:55 +02:00
|
|
|
}, srcFonts);
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Elaborazione dei fonts personalizzati
|
2020-06-30 13:24:55 +02:00
|
|
|
function srcFonts() {
|
|
|
|
return gulp.src([
|
|
|
|
config.development + '/' + config.paths.fonts + '/**/*.{otf,eot,svg,ttf,woff,woff2}',
|
|
|
|
])
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(flatten())
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.fonts));
|
2020-06-30 13:24:55 +02:00
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2020-06-30 13:24:55 +02:00
|
|
|
function ckeditor() {
|
2022-07-31 02:59:22 +02:00
|
|
|
|
|
|
|
const ckeditor = gulp.src([
|
2021-10-25 16:21:19 +02:00
|
|
|
config.nodeDirectory + '/ckeditor4/{adapters,lang,skins,plugins,core}/**/*.{js,json,css,png,gif,html}',
|
2021-05-26 15:43:18 +02:00
|
|
|
config.nodeDirectory + '/ckeditor4/*.{js,css}',
|
2020-06-30 13:24:55 +02:00
|
|
|
])
|
2017-09-22 14:37:18 +02:00
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/ckeditor'));
|
2022-07-31 02:59:22 +02:00
|
|
|
|
|
|
|
const plugins = gulp.src([
|
|
|
|
config.nodeDirectory + '/ckeditor/plugins/{emoji,autocomplete,textmatch,textwatcher}/**/*.{js,json,css,png,gif,html}',
|
|
|
|
config.nodeDirectory + '/ckeditor-image-to-base/*.{js,json,css,png,gif,html}',
|
|
|
|
])
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/ckeditor/plugins'));
|
|
|
|
|
2022-07-31 19:20:49 +02:00
|
|
|
return merge(ckeditor, plugins);
|
2020-06-30 13:24:55 +02:00
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2020-06-30 13:24:55 +02:00
|
|
|
function colorpicker() {
|
|
|
|
return gulp.src([
|
2020-08-19 14:16:47 +02:00
|
|
|
config.nodeDirectory + '/bootstrap-colorpicker/dist/**/*.{jpg,png,jpeg}',
|
2020-06-30 13:24:55 +02:00
|
|
|
])
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(flatten())
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.images + '/bootstrap-colorpicker'));
|
2020-06-30 13:24:55 +02:00
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2020-08-19 14:16:47 +02:00
|
|
|
function password_strength() {
|
2020-06-30 13:24:55 +02:00
|
|
|
return gulp.src([
|
2020-08-19 14:16:47 +02:00
|
|
|
config.nodeDirectory + '/pwstrength-bootstrap/dist/*.js',
|
2019-07-18 18:33:56 +02:00
|
|
|
])
|
|
|
|
.pipe(concat('password.min.js'))
|
2022-08-01 10:33:47 +02:00
|
|
|
.pipe(gulpIf(!config.debug, minifyJS()))
|
2019-07-18 18:33:56 +02:00
|
|
|
.pipe(gulp.dest(config.production + '/password-strength'));
|
2020-06-30 13:24:55 +02:00
|
|
|
}
|
2019-07-18 18:33:56 +02:00
|
|
|
|
2020-06-30 13:24:55 +02:00
|
|
|
function hotkeys() {
|
|
|
|
return gulp.src([
|
2020-08-19 14:16:47 +02:00
|
|
|
config.nodeDirectory + '/hotkeys-js/dist/hotkeys.min.js',
|
2020-02-20 02:02:01 +01:00
|
|
|
])
|
|
|
|
.pipe(flatten())
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/hotkeys-js'));
|
2020-06-30 13:24:55 +02:00
|
|
|
}
|
2020-02-20 02:02:01 +01:00
|
|
|
|
2020-06-30 13:24:55 +02:00
|
|
|
function chartjs() {
|
|
|
|
return gulp.src([
|
2022-07-07 15:26:32 +02:00
|
|
|
config.nodeDirectory + '/chart.js/dist/chart.min.js',
|
2020-06-30 13:24:55 +02:00
|
|
|
])
|
2017-09-18 15:45:47 +02:00
|
|
|
.pipe(flatten())
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/chartjs'));
|
2020-06-30 13:24:55 +02:00
|
|
|
}
|
2017-09-18 15:45:47 +02:00
|
|
|
|
2020-06-30 13:24:55 +02:00
|
|
|
function csrf() {
|
|
|
|
return gulp.src([
|
|
|
|
'./vendor/owasp/csrf-protector-php/js/csrfprotector.js',
|
|
|
|
])
|
2018-07-08 18:25:36 +02:00
|
|
|
.pipe(flatten())
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/csrf'));
|
2020-06-30 13:24:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function pdfjs() {
|
2020-08-06 10:17:56 +02:00
|
|
|
const web = gulp.src([
|
2024-03-22 18:41:37 +01:00
|
|
|
config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-4.0.379-dist/web/**/*',
|
|
|
|
'!' + config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-4.0.379-dist/web/cmaps/*',
|
|
|
|
'!' + config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-4.0.379-dist/web/*.map',
|
|
|
|
'!' + config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-4.0.379-dist/web/*.pdf',
|
2020-06-30 13:24:55 +02:00
|
|
|
])
|
2023-04-28 19:18:14 +02:00
|
|
|
.pipe(gulp.dest(config.production + '/pdfjs/web'));
|
2017-12-30 14:13:11 +01:00
|
|
|
|
2020-08-06 10:17:56 +02:00
|
|
|
const build = gulp.src([
|
2024-03-22 18:41:37 +01:00
|
|
|
config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-4.0.379-dist/build/*',
|
|
|
|
'!' + config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-4.0.379-dist/build/*.map',
|
2020-06-30 13:24:55 +02:00
|
|
|
])
|
2023-04-28 19:18:14 +02:00
|
|
|
.pipe(gulp.dest(config.production + '/pdfjs/build'));
|
2020-06-30 13:24:55 +02:00
|
|
|
|
|
|
|
return merge(web, build);
|
|
|
|
}
|
2017-12-20 14:05:14 +01:00
|
|
|
|
2017-08-04 16:28:16 +02:00
|
|
|
// Elaborazione e minificazione delle informazioni sull'internazionalizzazione
|
2020-06-30 13:24:55 +02:00
|
|
|
function i18n() {
|
|
|
|
return gulp.src([
|
2020-08-19 14:16:47 +02:00
|
|
|
config.nodeDirectory + '/**/{i18n,lang,locale,locales}/*.{js,json}',
|
2020-06-30 13:24:55 +02:00
|
|
|
config.development + '/' + config.paths.js + '/i18n/**/*.{js,json}',
|
2023-02-14 23:43:30 +01:00
|
|
|
config.nodeDirectory + '/moment/min/locales.js',
|
2020-08-19 14:16:47 +02:00
|
|
|
'!' + config.nodeDirectory + '/**/{src,plugins}/**',
|
2021-05-27 14:27:40 +02:00
|
|
|
'!' + config.nodeDirectory + '/ckeditor4/**',
|
2020-08-19 14:16:47 +02:00
|
|
|
'!' + config.nodeDirectory + '/summernote/**',
|
|
|
|
'!' + config.nodeDirectory + '/jquery-ui/**',
|
2020-06-30 13:24:55 +02:00
|
|
|
])
|
|
|
|
//.pipe(gulpIf('*.js', minifyJS(), gulpIf('*.json', minifyJSON())))
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(gulpIf('!*.min.*', rename({
|
|
|
|
suffix: '.min'
|
|
|
|
})))
|
|
|
|
.pipe(flatten({
|
|
|
|
includeParents: 1
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/i18n'));
|
2020-06-30 13:24:55 +02:00
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// PHP DebugBar assets
|
2020-06-30 13:24:55 +02:00
|
|
|
function phpDebugBar() {
|
|
|
|
return gulp.src([
|
|
|
|
'./vendor/maximebf/debugbar/src/DebugBar/Resources/**/*',
|
|
|
|
'!./vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/**/*',
|
|
|
|
])
|
2017-08-04 16:28:16 +02:00
|
|
|
.pipe(gulpIf('*.css', minifyCSS(), gulpIf('*.js', minifyJS())))
|
|
|
|
.pipe(gulp.dest(config.production + '/php-debugbar'));
|
2020-06-30 13:24:55 +02:00
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Operazioni per la release
|
2020-06-30 13:50:41 +02:00
|
|
|
function release(done) {
|
2017-12-30 12:05:09 +01:00
|
|
|
// Impostazione dello zip
|
2020-08-03 15:29:19 +02:00
|
|
|
let output = fs.createWriteStream('./release.zip', {flags: 'w'});
|
|
|
|
let archive = archiver('zip');
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2017-09-08 13:24:48 +02:00
|
|
|
output.on('close', function () {
|
2017-08-07 13:07:18 +02:00
|
|
|
console.log('ZIP completato!');
|
2017-08-04 16:28:16 +02:00
|
|
|
});
|
|
|
|
|
2017-09-08 13:24:48 +02:00
|
|
|
archive.on('error', function (err) {
|
2017-08-04 16:28:16 +02:00
|
|
|
throw err;
|
|
|
|
});
|
|
|
|
|
|
|
|
archive.pipe(output);
|
|
|
|
|
2022-11-14 22:25:54 +01:00
|
|
|
// Individuazione dei file da aggiungere e escludere
|
2020-08-03 15:29:19 +02:00
|
|
|
glob([
|
|
|
|
'**/*',
|
|
|
|
'!checksum.json',
|
2024-03-02 02:52:30 +01:00
|
|
|
'!mysql.json',
|
|
|
|
'!mysql_5_7.json',
|
|
|
|
'!mariadb_10_x.json',
|
2024-01-15 14:52:26 +01:00
|
|
|
'!settings.json',
|
2023-10-06 19:32:01 +02:00
|
|
|
'!manifest.json',
|
2020-08-03 15:29:19 +02:00
|
|
|
'!.idea/**',
|
|
|
|
'!.git/**',
|
2023-03-31 19:38:17 +02:00
|
|
|
'!.github/**',
|
|
|
|
'!.vscode/**',
|
2020-08-03 15:29:19 +02:00
|
|
|
'!node_modules/**',
|
2020-10-06 23:37:07 +02:00
|
|
|
'!include/custom/**',
|
2020-08-03 15:29:19 +02:00
|
|
|
'!backup/**',
|
|
|
|
'!files/**',
|
2021-09-21 17:12:39 +02:00
|
|
|
'files/temp/.gitkeep',
|
2020-08-03 15:29:19 +02:00
|
|
|
'!logs/**',
|
|
|
|
'!config.inc.php',
|
2022-11-14 22:25:54 +01:00
|
|
|
'!psalm.xml',
|
2020-11-10 13:07:36 +01:00
|
|
|
'!update/structure.php',
|
2024-01-15 14:52:26 +01:00
|
|
|
'!update/settings.php',
|
2020-08-03 15:29:19 +02:00
|
|
|
'!**/*.(lock|phar|log|zip|bak|jar|txt)',
|
|
|
|
'!**/~*',
|
2020-11-10 13:07:36 +01:00
|
|
|
'!vendor/tecnickcom/tcpdf/examples/**',
|
2020-08-03 15:29:19 +02:00
|
|
|
'!vendor/tecnickcom/tcpdf/fonts/*',
|
|
|
|
'vendor/tecnickcom/tcpdf/fonts/*helvetica*',
|
|
|
|
'!vendor/mpdf/mpdf/tmp/*',
|
|
|
|
'!vendor/mpdf/mpdf/ttfonts/*',
|
|
|
|
'vendor/mpdf/mpdf/ttfonts/DejaVuinfo.txt',
|
|
|
|
'vendor/mpdf/mpdf/ttfonts/DejaVu*Condensed*',
|
2020-11-10 13:07:36 +01:00
|
|
|
'!vendor/maximebf/debugbar/src/DebugBar/Resources/vendor/**',
|
|
|
|
'!vendor/respect/validation/tests/**',
|
|
|
|
'!vendor/willdurand/geocoder/tests/**',
|
2020-08-03 15:29:19 +02:00
|
|
|
], {
|
2017-08-04 16:28:16 +02:00
|
|
|
dot: true,
|
2020-08-19 14:16:47 +02:00
|
|
|
}).then(function (files) {
|
2020-08-03 15:29:19 +02:00
|
|
|
// Aggiunta dei file con i relativi checksum
|
|
|
|
let checksum = {};
|
|
|
|
for (const file of files) {
|
|
|
|
if (fs.lstatSync(file).isDirectory()) {
|
|
|
|
archive.directory(file, file);
|
|
|
|
} else {
|
|
|
|
archive.file(file);
|
|
|
|
|
|
|
|
if (!file.startsWith('vendor')) {
|
|
|
|
checksum[file] = md5File.sync(file);
|
|
|
|
}
|
|
|
|
}
|
2017-12-30 12:05:09 +01:00
|
|
|
}
|
|
|
|
|
2020-08-03 15:29:19 +02:00
|
|
|
// Eccezioni
|
|
|
|
archive.file('backup/.htaccess', {});
|
|
|
|
archive.file('files/.htaccess', {});
|
|
|
|
archive.file('files/my_impianti/componente.ini', {});
|
|
|
|
archive.file('logs/.htaccess', {});
|
|
|
|
|
|
|
|
// Aggiunta del file dei checksum
|
|
|
|
let checksumFile = fs.createWriteStream('./checksum.json', {flags: 'w'});
|
|
|
|
checksumFile.write(JSON.stringify(checksum));
|
|
|
|
checksumFile.close();
|
|
|
|
archive.file('checksum.json', {});
|
|
|
|
|
2020-08-28 11:20:20 +02:00
|
|
|
// Aggiunta del file per il controllo di integrità del database
|
2024-08-28 19:13:37 +02:00
|
|
|
var bufferStream = new Readable();
|
|
|
|
|
|
|
|
bufferStream.push(shell.exec('php update/structure.php', {
|
2020-08-28 11:20:20 +02:00
|
|
|
silent: true
|
2024-08-28 19:13:37 +02:00
|
|
|
}).stdout);
|
|
|
|
bufferStream.push(null);
|
|
|
|
archive.append(bufferStream, { name: 'mysql.json' });
|
2020-08-28 11:20:20 +02:00
|
|
|
|
2024-01-15 14:52:26 +01:00
|
|
|
// Aggiunta del file per il controllo delle impostazioni
|
2024-08-28 19:13:37 +02:00
|
|
|
bufferStream = new Readable();
|
|
|
|
bufferStream.push(shell.exec('php update/settings.php', {
|
2024-01-15 14:52:26 +01:00
|
|
|
silent: true
|
2024-08-28 19:13:37 +02:00
|
|
|
}).stdout);
|
|
|
|
bufferStream.push(null);
|
|
|
|
archive.append(bufferStream, { name: 'settings.json' });
|
2024-01-15 14:52:26 +01:00
|
|
|
|
2020-08-03 15:29:19 +02:00
|
|
|
// Aggiunta del commit corrente nel file REVISION
|
2024-08-28 19:13:37 +02:00
|
|
|
bufferStream = new Readable();
|
|
|
|
bufferStream.push(shell.exec('git rev-parse --short HEAD', {
|
2020-08-03 15:29:19 +02:00
|
|
|
silent: true
|
2024-08-28 19:13:37 +02:00
|
|
|
}).stdout);
|
|
|
|
bufferStream.push(null);
|
|
|
|
archive.append(bufferStream, { name: 'REVISION' });
|
2017-12-30 12:10:06 +01:00
|
|
|
|
2024-08-28 19:13:37 +02:00
|
|
|
// Opzioni sulla release
|
2020-08-03 15:29:19 +02:00
|
|
|
inquirer.prompt([{
|
|
|
|
type: 'input',
|
|
|
|
name: 'version',
|
|
|
|
message: 'Numero di versione:',
|
2024-08-28 19:13:37 +02:00
|
|
|
validate: (input) => input ? true : 'Il numero di versione non può essere vuoto.'
|
2020-08-03 15:29:19 +02:00
|
|
|
}, {
|
|
|
|
type: 'confirm',
|
|
|
|
name: 'beta',
|
|
|
|
message: 'Versione beta?',
|
|
|
|
default: false,
|
|
|
|
}]).then(function (result) {
|
2024-08-28 19:13:37 +02:00
|
|
|
|
2020-08-03 15:29:19 +02:00
|
|
|
let version = result.version;
|
|
|
|
|
2024-08-28 19:13:37 +02:00
|
|
|
// Aggiungi 'beta' solo se l'opzione beta è selezionata
|
2020-08-03 15:29:19 +02:00
|
|
|
if (result.beta) {
|
|
|
|
version += 'beta';
|
|
|
|
}
|
|
|
|
|
2024-08-28 19:13:37 +02:00
|
|
|
// Creazione di un stream leggibile con la versione
|
|
|
|
const bufferStream = new Readable({
|
|
|
|
read() {
|
|
|
|
this.push(version);
|
|
|
|
this.push(null);
|
|
|
|
}
|
2020-08-03 15:29:19 +02:00
|
|
|
});
|
|
|
|
|
2024-08-28 19:13:37 +02:00
|
|
|
// Aggiunta della versione corrente nel file VERSION
|
|
|
|
archive.append(bufferStream, { name: 'VERSION' });
|
|
|
|
|
|
|
|
// Completamento dello ZIP
|
2020-08-03 15:29:19 +02:00
|
|
|
archive.finalize();
|
|
|
|
|
|
|
|
done();
|
2024-08-28 19:13:37 +02:00
|
|
|
}).catch(err => {
|
|
|
|
console.error('Si è verificato un errore:', err);
|
2020-08-03 15:29:19 +02:00
|
|
|
});
|
2024-08-28 19:13:37 +02:00
|
|
|
|
2018-09-20 12:05:22 +02:00
|
|
|
});
|
2020-06-30 13:24:55 +02:00
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Pulizia
|
2020-06-30 13:24:55 +02:00
|
|
|
function clean() {
|
2017-08-04 16:28:16 +02:00
|
|
|
return del([config.production]);
|
2020-06-30 13:24:55 +02:00
|
|
|
}
|
2017-08-04 16:28:16 +02:00
|
|
|
|
|
|
|
// Operazioni di default per la generazione degli assets
|
2023-07-28 14:17:04 +02:00
|
|
|
const bower = gulp.series(clean, gulp.parallel(JS, CSS, images, fonts, phpDebugBar, ckeditor, colorpicker, i18n, pdfjs, hotkeys, chartjs, password_strength, csrf, leaflet, wacom));
|
2017-08-04 16:28:16 +02:00
|
|
|
|
2020-07-08 21:12:16 +02:00
|
|
|
// Debug su CSS e JS
|
|
|
|
exports.srcJS = srcJS;
|
|
|
|
exports.srcCSS = srcCSS;
|
|
|
|
|
2020-06-30 13:24:55 +02:00
|
|
|
exports.bower = bower;
|
|
|
|
exports.release = release;
|
|
|
|
exports.default = bower;
|
2021-11-27 15:05:53 +01:00
|
|
|
|
|
|
|
// Watch task - lanciato con `gulp watch`, resta in attesa e ogni volta che viene modificato un asset in src
|
|
|
|
// viene aggiornata la dist
|
|
|
|
gulp.task('watch', function () {
|
2021-11-27 18:00:42 +01:00
|
|
|
gulp.watch('assets/src/css/*.css', gulp.series(srcCSS, CSS));
|
|
|
|
gulp.watch('assets/src/css/print/*.css', gulp.series(srcCSS, CSS));
|
2021-11-27 15:05:53 +01:00
|
|
|
gulp.watch('assets/src/css/themes/*.css', gulp.series(srcCSS, CSS));
|
2021-11-27 18:00:42 +01:00
|
|
|
gulp.watch('assets/src/js/base/*.js', gulp.series(srcJS, JS));
|
|
|
|
gulp.watch('assets/src/js/functions/*.js', gulp.series(srcJS, JS));
|
2021-11-27 15:05:53 +01:00
|
|
|
gulp.watch('assets/src/img/*', gulp.series(images));
|
|
|
|
});
|