Skip to content

Commit a6a63b9

Browse files
committed
Merge branch 'npm-update' of https://github.com/Dasc3er/openstamanager into Dasc3er-npm-update
1 parent 088b904 commit a6a63b9

3 files changed

Lines changed: 114 additions & 85 deletions

File tree

assets/src/fonts/.gitkeep

Whitespace-only changes.

gulpfile.js

Lines changed: 101 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,25 @@
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
18+
import { createRequire } from 'module';
19+
const require = createRequire(import.meta.url);
1820

1921
// Librerie NPM richieste per l'esecuzione
20-
const gulp = require('gulp');
21-
const merge = require('merge-stream');
22+
import gulp from 'gulp';
2223
const del = require('del');
2324
const gulpIf = require('gulp-if');
2425
const babel = require('gulp-babel');
26+
const merge = require('merge-stream');
2527

2628
// Minificatori
2729
const minifyJS = require('gulp-uglify');
2830
const minifyCSS = require('gulp-clean-css');
29-
const minifyJSON = require('gulp-json-minify');
31+
import autoprefixer from 'gulp-autoprefixer';
3032

3133
// Interpretatori CSS
3234
const sass = require('gulp-sass')(require('sass'));
3335
const less = require('gulp-less');
3436
const stylus = require('gulp-stylus');
35-
const autoprefixer = require('gulp-autoprefixer');
3637

3738
// Concatenatore
3839
const concat = require('gulp-concat');
@@ -42,13 +43,13 @@ const flatten = require('gulp-flatten');
4243
const rename = require('gulp-rename');
4344

4445
// Release
45-
const glob = require('globby');
4646
const md5File = require('md5-file')
47-
const fs = require('fs');
4847
const archiver = require('archiver');
4948
const shell = require('shelljs');
50-
const inquirer = require('inquirer');
51-
const { Readable } = require('node:stream');
49+
const { Readable } = require('stream');
50+
import * as fs from 'fs';
51+
import inquirer from 'inquirer';
52+
import { globby as glob } from 'globby';
5253

5354
// Configurazione
5455
const config = {
@@ -78,8 +79,27 @@ const config = {
7879
};
7980
config.babelOptions.compact = !config.debug;
8081

82+
function waitPipes(pipes, done) {
83+
if (!pipes || pipes.length === 0) {
84+
done();
85+
return Promise.resolve();
86+
}
87+
88+
return Promise.all(
89+
pipes.map(pipe => new Promise((resolve, reject) => {
90+
pipe.on('end', resolve);
91+
pipe.on('error', reject);
92+
}))
93+
).then(() => {
94+
done();
95+
}).catch(err => {
96+
console.error('Error in pipe:', err);
97+
done(err);
98+
});
99+
}
100+
81101
// Elaborazione e minificazione di JS
82-
const JS = gulp.parallel(() => {
102+
const JS = gulp.parallel(function vendorJS() {
83103
const vendor = [
84104
'jquery/dist/jquery.js',
85105
'autosize/dist/autosize.js',
@@ -138,12 +158,12 @@ const JS = gulp.parallel(() => {
138158
})
139159
.pipe(babel(config.babelOptions))
140160
.pipe(concat('app.min.js'))
141-
.pipe(gulpIf(!config.debug, minifyJS({compress:false})))
161+
.pipe(gulpIf(!config.debug, minifyJS({ compress: false })))
142162
.pipe(gulp.dest(config.production + '/' + config.paths.js));
143163
}, srcJS);
144164

145165
// Elaborazione e minificazione di JS personalizzati
146-
function srcJS() {
166+
export function srcJS(done) {
147167
const js = gulp.src([
148168
config.development + '/' + config.paths.js + '/base/*.js',
149169
])
@@ -160,7 +180,7 @@ function srcJS() {
160180
.pipe(gulpIf(!config.debug, minifyJS()))
161181
.pipe(gulp.dest(config.production + '/' + config.paths.js));
162182

163-
return merge(js, functions);
183+
return waitPipes([js, functions], done);
164184
}
165185

166186
// Elaborazione e minificazione di CSS
@@ -207,7 +227,7 @@ const CSS = gulp.parallel(() => {
207227
}, srcCSS);
208228

209229
// Elaborazione e minificazione di CSS personalizzati
210-
function srcCSS() {
230+
export function srcCSS(done) {
211231
const css = gulp.src([
212232
config.development + '/' + config.paths.css + '/*.{css,scss,less,styl}',
213233
])
@@ -229,17 +249,17 @@ function srcCSS() {
229249
.pipe(gulp.dest(config.production + '/' + config.paths.css));
230250

231251
const themes = gulp.src([
232-
config.development + '/' + config.paths.css + '/themes/*.{css,scss,less,styl}',
233-
config.nodeDirectory + '/admin-lte/dist/css/adminlte.min.css',
234-
])
235-
.pipe(gulpIf('*.scss', sass(), gulpIf('*.less', less(), gulpIf('*.styl', stylus()))))
236-
.pipe(autoprefixer())
237-
.pipe(gulpIf(!config.debug, minifyCSS(config.minifiers.css)))
238-
.pipe(concat('themes.min.css'))
239-
.pipe(flatten())
240-
.pipe(gulp.dest(config.production + '/' + config.paths.css));
241-
242-
return merge(css, print, themes);
252+
config.development + '/' + config.paths.css + '/themes/*.{css,scss,less,styl}',
253+
config.nodeDirectory + '/admin-lte/dist/css/adminlte.min.css',
254+
])
255+
.pipe(gulpIf('*.scss', sass(), gulpIf('*.less', less(), gulpIf('*.styl', stylus()))))
256+
.pipe(autoprefixer())
257+
.pipe(gulpIf(!config.debug, minifyCSS(config.minifiers.css)))
258+
.pipe(concat('themes.min.css'))
259+
.pipe(flatten())
260+
.pipe(gulp.dest(config.production + '/' + config.paths.css));
261+
262+
return waitPipes([css, print, themes], done);
243263
}
244264

245265

@@ -250,27 +270,27 @@ const images = srcImages;
250270
function srcImages() {
251271
return gulp.src([
252272
config.development + '/' + config.paths.images + '/**/*.{jpg,png,jpeg,gif}',
253-
])
273+
], {encoding: false})
254274
.pipe(gulp.dest(config.production + '/' + config.paths.images));
255275
}
256276

257-
function leaflet() {
258-
gulp.src([
277+
function leaflet(done) {
278+
const leaflet = gulp.src([
259279
config.nodeDirectory + '/leaflet.fullscreen/icon-fullscreen.svg',
260-
]).pipe(gulp.dest(config.production + '/' + config.paths.images + '/leaflet'));
261-
262-
gulp.src([
263280
config.development + '/' + config.paths.images + '/leaflet/*',
264-
]).pipe(gulp.dest(config.production + '/' + config.paths.images + '/leaflet'));
281+
], {encoding: false})
282+
.pipe(gulp.dest(config.production + '/' + config.paths.images + '/leaflet'));
265283

266-
return gulp.src([
284+
const images = gulp.src([
267285
config.nodeDirectory + '/leaflet/dist/images/*.{jpg,png,jpeg}',
268-
])
286+
], {encoding: false})
269287
.pipe(flatten())
270288
.pipe(gulp.dest(config.production + '/' + config.paths.images + '/leaflet'));
289+
290+
return waitPipes([images, leaflet], done);
271291
}
272292

273-
function wacom(){
293+
function wacom(done) {
274294
// Librerie da node_modules secondo package.json
275295
const vendor = [
276296
'clipper-lib/clipper.js',
@@ -306,7 +326,7 @@ function wacom(){
306326
// Prima copiamo il file WASM necessario
307327
const wasmStream = gulp.src([
308328
config.development + '/' + config.paths.js + '/wacom/common/libs/signature_sdk.wasm'
309-
])
329+
], {encoding: false})
310330
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/wacom/'));
311331

312332
// Poi processiamo i file JS che lo utilizzano
@@ -317,9 +337,8 @@ function wacom(){
317337
.pipe(concat('wacom.min.js'))
318338
.pipe(gulpIf(!config.debug, minifyJS()))
319339
.pipe(gulp.dest(config.production + '/' + config.paths.js));
320-
321-
// Usiamo merge per garantire che wasmStream sia completato prima di jsStream
322-
return merge(wasmStream, jsStream);
340+
341+
return waitPipes([jsStream, wasmStream], done);
323342
}
324343

325344
// Elaborazione dei fonts
@@ -342,7 +361,7 @@ const fonts = gulp.parallel(() => {
342361
vendor[i] = config.nodeDirectory + '/' + vendor[i];
343362
}
344363

345-
return gulp.src(vendor)
364+
return gulp.src(vendor, {encoding: false})
346365
.pipe(flatten())
347366
.pipe(gulp.dest(config.production + '/' + config.paths.fonts));
348367
}, srcFonts);
@@ -351,7 +370,7 @@ const fonts = gulp.parallel(() => {
351370
function srcFonts() {
352371
return gulp.src([
353372
config.development + '/' + config.paths.fonts + '/**/*.{otf,eot,svg,ttf,woff,woff2}',
354-
])
373+
], {encoding: false})
355374
.pipe(flatten())
356375
.pipe(gulp.dest(config.production + '/' + config.paths.fonts));
357376
}
@@ -381,7 +400,7 @@ function ckeditor() {
381400
function colorpicker() {
382401
return gulp.src([
383402
config.nodeDirectory + '/bootstrap-colorpicker/dist/**/*.{jpg,png,jpeg}',
384-
])
403+
], {encoding: false})
385404
.pipe(flatten())
386405
.pipe(gulp.dest(config.production + '/' + config.paths.images + '/bootstrap-colorpicker'));
387406
}
@@ -419,44 +438,41 @@ function csrf() {
419438
.pipe(gulp.dest(config.production + '/' + config.paths.js + '/csrf'));
420439
}
421440

422-
function pdfjs() {
441+
function pdfjs(done) {
423442
const web = gulp.src([
424-
config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-4.0.379-dist/web/**/*',
425-
'!' + config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-4.0.379-dist/web/cmaps/*',
426-
'!' + config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-4.0.379-dist/web/*.map',
427-
'!' + config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-4.0.379-dist/web/*.pdf',
428-
])
443+
config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-*-dist/web/**/*',
444+
'!' + config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-*-dist/web/cmaps/*',
445+
'!' + config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-*-dist/web/*.map',
446+
'!' + config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-*-dist/web/*.pdf',
447+
], {encoding: false})
429448
.pipe(gulp.dest(config.production + '/pdfjs/web'));
430449

431450
const build = gulp.src([
432-
config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-4.0.379-dist/build/*',
433-
'!' + config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-4.0.379-dist/build/*.map',
434-
])
451+
config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-*-dist/build/*',
452+
'!' + config.nodeDirectory + '/pdfjs-viewer-element/dist/pdfjs-*-dist/build/*.map',
453+
], {encoding: false})
435454
.pipe(gulp.dest(config.production + '/pdfjs/build'));
436455

437-
return merge(web, build);
456+
return waitPipes([web, build], done);
438457
}
439458

440459
function uaparser() {
441460
return gulp.src([
442461
config.nodeDirectory + '/ua-parser-js/dist/icons/mono/**/*',
443462
'!' + config.nodeDirectory + '/ua-parser-js/dist/icons/mono/LICENSE.md',
444-
])
445-
.pipe(gulp.dest(config.production + '/img/icons/'));
463+
], {encoding: false})
464+
.pipe(gulp.dest(config.production + '/' + config.paths.images + '/icons/'));
446465
}
447466

448467
// Elaborazione e minificazione delle informazioni sull'internazionalizzazione
449468
function i18n() {
450469
return gulp.src([
451470
config.nodeDirectory + '/**/{i18n,lang,locale,locales}/*.{js,json}',
452-
config.development + '/' + config.paths.js + '/i18n/**/*.{js,json}',
453471
config.nodeDirectory + '/moment/min/locales.js',
454472
'!' + config.nodeDirectory + '/**/{src,plugins}/**',
455-
'!' + config.nodeDirectory + '/ckeditor4/**',
456-
'!' + config.nodeDirectory + '/summernote/**',
473+
'!' + config.nodeDirectory + '/ckeditor4-full/**',
457474
'!' + config.nodeDirectory + '/jquery-ui/**',
458475
])
459-
//.pipe(gulpIf('*.js', minifyJS(), gulpIf('*.json', minifyJSON())))
460476
.pipe(gulpIf('!*.min.*', rename({
461477
suffix: '.min'
462478
})))
@@ -468,9 +484,9 @@ function i18n() {
468484

469485

470486
// Operazioni per la release
471-
function release(done) {
487+
export function release(done) {
472488
// Impostazione dello zip
473-
let output = fs.createWriteStream('./release.zip', {flags: 'w'});
489+
let output = fs.createWriteStream('./release.zip', { flags: 'w' });
474490
let archive = archiver('zip');
475491

476492
output.on('close', function () {
@@ -542,7 +558,7 @@ function release(done) {
542558
archive.file('logs/.htaccess', {});
543559

544560
// Aggiunta del file dei checksum
545-
let checksumFile = fs.createWriteStream('./checksum.json', {flags: 'w'});
561+
let checksumFile = fs.createWriteStream('./checksum.json', { flags: 'w' });
546562
checksumFile.write(JSON.stringify(checksum));
547563
checksumFile.close();
548564
archive.file('checksum.json', {});
@@ -610,25 +626,38 @@ function release(done) {
610626
}).catch(err => {
611627
console.error('Si è verificato un errore:', err);
612628
});
613-
614629
});
615630
}
616631

617632
// Pulizia
618-
function clean() {
633+
export function clean() {
619634
return del([config.production]);
620-
}
635+
};
621636

622637
// Operazioni di default per la generazione degli assets
623-
const bower = gulp.series(clean, gulp.parallel(JS, CSS, images, fonts, ckeditor, colorpicker, i18n, pdfjs, uaparser, hotkeys, chartjs, password_strength, csrf, leaflet, wacom));
624-
625-
// Debug su CSS e JS
626-
exports.srcJS = srcJS;
627-
exports.srcCSS = srcCSS;
628-
629-
exports.bower = bower;
630-
exports.release = release;
631-
exports.default = bower;
638+
export const bower = gulp.series(
639+
clean,
640+
gulp.parallel(
641+
JS,
642+
CSS,
643+
images,
644+
fonts,
645+
ckeditor,
646+
colorpicker,
647+
i18n,
648+
pdfjs,
649+
hotkeys,
650+
chartjs,
651+
password_strength,
652+
csrf,
653+
leaflet,
654+
wacom,
655+
uaparser
656+
)
657+
);
658+
659+
// Assicurati che il task default sia esportato correttamente
660+
export default bower;
632661

633662
// Watch task - lanciato con `gulp watch`, resta in attesa e ogni volta che viene modificato un asset in src
634663
// viene aggiornata la dist

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,28 +62,28 @@
6262
"devDependencies": {
6363
"@babel/core": "^7.11.1",
6464
"@babel/preset-env": "^7.11.0",
65-
"archiver": "^3.0.0",
65+
"archiver": "^7.0.0",
6666
"cwd": "^0.10.0",
67-
"del": "^4.0.0",
68-
"globby": "^11.0.1",
67+
"del": "^6.0.0",
68+
"globby": "^14.0.1",
6969
"gulp": "^4.0.2",
70-
"gulp-autoprefixer": "^7.0.0",
70+
"gulp-autoprefixer": "^9.0.0",
7171
"gulp-babel": "^8.0.0",
7272
"gulp-clean-css": "^4.0.0",
7373
"gulp-concat": "^2.6.0",
74-
"gulp-debug": "^4.0.0",
74+
"gulp-debug": "^5.0.0",
7575
"gulp-flatten": "^0.4.0",
76-
"gulp-if": "^2.0.2",
77-
"gulp-json-minify": "^1.0.5",
78-
"gulp-less": "^4.0.1",
79-
"gulp-rename": "^1.4.0",
80-
"gulp-sass": "^5.1.0",
81-
"gulp-stylus": "^2.6.0",
76+
"gulp-if": "^3.0.0",
77+
"gulp-less": "^5.0.0",
78+
"gulp-rename": "^2.0.0",
79+
"gulp-sass": "^6.0.0",
80+
"gulp-stylus": "^3.0.0",
8281
"gulp-uglify": "^3.0.2",
83-
"inquirer": "^4.0.1",
82+
"inquirer": "^9.2.12",
83+
"main-bower-files": "^2.13.1",
8484
"md5-file": "^5.0.0",
8585
"sass": "^1.62.1",
86-
"shelljs": ">=0.8.5"
86+
"shelljs": "^0.8.5"
8787
},
8888
"scripts": {
8989
"gulp": "gulp",

0 commit comments

Comments
 (0)