Skip to content

Commit f65e494

Browse files
committed
feat: aggiunta aggiornamento publiccode.yml in fase di release
1 parent 51a2858 commit f65e494

1 file changed

Lines changed: 171 additions & 159 deletions

File tree

gulpfile.js

Lines changed: 171 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -488,168 +488,180 @@ function i18n() {
488488

489489
// Operazioni per la release
490490
export function release(done) {
491-
// Impostazione dello zip
492-
let output = fs.createWriteStream('./release.zip', { flags: 'w' });
493-
let archive = archiver('zip');
494-
495-
output.on('close', function () {
496-
console.log('ZIP completato!');
497-
});
498-
499-
archive.on('error', function (err) {
500-
throw err;
501-
});
502-
503-
archive.pipe(output);
504-
505-
// Individuazione dei file da aggiungere e escludere
506-
glob([
507-
'**/*',
508-
'!checksum.json',
509-
'!mysql.json',
510-
'!mysql_8_3.json',
511-
'!mariadb_10_x.json',
512-
'!settings.json',
513-
'!views.json',
514-
'!modules.json',
515-
'!manifest.json',
516-
'!.idea/**',
517-
'!.git/**',
518-
'!.github/**',
519-
'!.vscode/**',
520-
'!node_modules/**',
521-
'!include/custom/**',
522-
'!backup/**',
523-
'!files/**',
524-
'files/temp/.gitkeep',
525-
'!logs/**',
526-
'!config.inc.php',
527-
'!psalm.xml',
528-
'!update/structure.php',
529-
'!update/settings.php',
530-
'!**/*.(lock|phar|log|zip|bak|jar|txt)',
531-
'!**/~*',
532-
'!vendor/tecnickcom/tcpdf/examples/**',
533-
'!vendor/tecnickcom/tcpdf/fonts/*',
534-
'vendor/tecnickcom/tcpdf/fonts/*helvetica*',
535-
'!vendor/mpdf/mpdf/tmp/*',
536-
'!vendor/mpdf/mpdf/ttfonts/*',
537-
'vendor/mpdf/mpdf/ttfonts/DejaVuinfo.txt',
538-
'vendor/mpdf/mpdf/ttfonts/DejaVu*Condensed*',
539-
'vendor/mpdf/mpdf/ttfonts/ocrbinfo.txt',
540-
'vendor/mpdf/mpdf/ttfonts/ocrb10.ttf',
541-
'!vendor/respect/validation/tests/**',
542-
'!vendor/willdurand/geocoder/tests/**',
543-
'!docker/**',
544-
], {
545-
dot: true,
546-
}).then(function (files) {
547-
// Aggiunta dei file con i relativi checksum
548-
let checksum = {};
549-
for (const file of files) {
550-
if (fs.lstatSync(file).isDirectory()) {
551-
archive.directory(file, file);
552-
} else {
553-
archive.file(file);
554-
555-
if (!file.startsWith('vendor')) {
556-
checksum[file] = md5File.sync(file);
557-
}
558-
}
491+
// Opzioni sulla release
492+
inquirer.prompt([{
493+
type: 'input',
494+
name: 'version',
495+
message: 'Numero di versione:',
496+
validate: (input) => input ? true : 'Il numero di versione non può essere vuoto.'
497+
}, {
498+
type: 'confirm',
499+
name: 'beta',
500+
message: 'Versione beta?',
501+
default: false,
502+
}]).then(function (result) {
503+
504+
let version = result.version;
505+
506+
// Aggiungi '-beta' solo se l'opzione beta è selezionata
507+
if (result.beta) {
508+
version += '-beta';
559509
}
560510

561-
// Eccezioni
562-
archive.file('backup/.htaccess', {});
563-
archive.file('files/.htaccess', {});
564-
archive.file('files/my_impianti/componente.ini', {});
565-
archive.file('logs/.htaccess', {});
566-
567-
// Aggiunta del file dei checksum
568-
let checksumFile = fs.createWriteStream('./checksum.json', { flags: 'w' });
569-
checksumFile.write(JSON.stringify(checksum));
570-
checksumFile.close();
571-
archive.file('checksum.json', {});
572-
573-
// Aggiunta del file per il controllo di integrità del database
574-
var bufferStream = new Readable();
575-
576-
bufferStream.push(shell.exec('php update/structure.php', {
577-
silent: true
578-
}).stdout);
579-
bufferStream.push(null);
580-
archive.append(bufferStream, { name: 'mysql.json' });
581-
582-
// Aggiunta del file per il controllo delle impostazioni
583-
bufferStream = new Readable();
584-
bufferStream.push(shell.exec('php update/settings.php', {
585-
silent: true
586-
}).stdout);
587-
bufferStream.push(null);
588-
archive.append(bufferStream, { name: 'settings.json' });
589-
590-
// Aggiunta del file per il controllo delle viste
591-
bufferStream = new Readable();
592-
bufferStream.push(shell.exec('php update/views.php', {
593-
silent: true
594-
}).stdout);
595-
bufferStream.push(null);
596-
archive.append(bufferStream, { name: 'views.json' });
597-
598-
// Aggiunta del file per il controllo dei moduli
599-
bufferStream = new Readable();
600-
bufferStream.push(shell.exec('php update/modules.php', {
601-
silent: true
602-
}).stdout);
603-
bufferStream.push(null);
604-
archive.append(bufferStream, { name: 'modules.json' });
605-
606-
607-
// Aggiunta del commit corrente nel file REVISION
608-
bufferStream = new Readable();
609-
bufferStream.push(shell.exec('git rev-parse --short HEAD', {
610-
silent: true
611-
}).stdout);
612-
bufferStream.push(null);
613-
archive.append(bufferStream, { name: 'REVISION' });
614-
615-
// Opzioni sulla release
616-
inquirer.prompt([{
617-
type: 'input',
618-
name: 'version',
619-
message: 'Numero di versione:',
620-
validate: (input) => input ? true : 'Il numero di versione non può essere vuoto.'
621-
}, {
622-
type: 'confirm',
623-
name: 'beta',
624-
message: 'Versione beta?',
625-
default: false,
626-
}]).then(function (result) {
627-
628-
let version = result.version;
629-
630-
// Aggiungi 'beta' solo se l'opzione beta è selezionata
631-
if (result.beta) {
632-
version += 'beta';
633-
}
634-
635-
// Creazione di un stream leggibile con la versione
636-
const bufferStream = new Readable({
637-
read() {
638-
this.push(version);
639-
this.push(null);
640-
}
511+
// Aggiorna il file publiccode.yml con la nuova versione e data di rilascio
512+
const releaseDate = new Date().toISOString().split('T')[0];
513+
514+
gulp.src('publiccode.yml')
515+
.pipe(replace(/softwareVersion: .*/, `softwareVersion: ${version}`))
516+
.pipe(replace(/releaseDate: .*/, `releaseDate: ${releaseDate}`))
517+
.pipe(gulp.dest('.'))
518+
.on('end', function() {
519+
console.log(`Aggiornato publiccode.yml: versione ${version}, data ${releaseDate}`);
520+
521+
// Impostazione dello zip con il nome che include la versione
522+
let zipFileName = `openstamanager-${version}.zip`;
523+
let output = fs.createWriteStream(`./${zipFileName}`, { flags: 'w' });
524+
let archive = archiver('zip');
525+
526+
output.on('close', function () {
527+
console.log(`ZIP completato: ${zipFileName}`);
528+
done();
529+
});
530+
531+
archive.on('error', function (err) {
532+
throw err;
533+
});
534+
535+
archive.pipe(output);
536+
537+
// Individuazione dei file da aggiungere e escludere
538+
glob([
539+
'**/*',
540+
'!checksum.json',
541+
'!mysql.json',
542+
'!mysql_8_3.json',
543+
'!mariadb_10_x.json',
544+
'!settings.json',
545+
'!views.json',
546+
'!modules.json',
547+
'!manifest.json',
548+
'!.idea/**',
549+
'!.git/**',
550+
'!.github/**',
551+
'!.vscode/**',
552+
'!node_modules/**',
553+
'!include/custom/**',
554+
'!backup/**',
555+
'!files/**',
556+
'files/temp/.gitkeep',
557+
'!logs/**',
558+
'!config.inc.php',
559+
'!psalm.xml',
560+
'!update/structure.php',
561+
'!update/settings.php',
562+
'!**/*.(lock|phar|log|zip|bak|jar|txt)',
563+
'!**/~*',
564+
'!vendor/tecnickcom/tcpdf/examples/**',
565+
'!vendor/tecnickcom/tcpdf/fonts/*',
566+
'vendor/tecnickcom/tcpdf/fonts/*helvetica*',
567+
'!vendor/mpdf/mpdf/tmp/*',
568+
'!vendor/mpdf/mpdf/ttfonts/*',
569+
'vendor/mpdf/mpdf/ttfonts/DejaVuinfo.txt',
570+
'vendor/mpdf/mpdf/ttfonts/DejaVu*Condensed*',
571+
'vendor/mpdf/mpdf/ttfonts/ocrbinfo.txt',
572+
'vendor/mpdf/mpdf/ttfonts/ocrb10.ttf',
573+
'!vendor/respect/validation/tests/**',
574+
'!vendor/willdurand/geocoder/tests/**',
575+
'!docker/**',
576+
], {
577+
dot: true,
578+
}).then(function (files) {
579+
// Aggiunta dei file con i relativi checksum
580+
let checksum = {};
581+
for (const file of files) {
582+
if (fs.lstatSync(file).isDirectory()) {
583+
archive.directory(file, file);
584+
} else {
585+
archive.file(file);
586+
587+
if (!file.startsWith('vendor')) {
588+
checksum[file] = md5File.sync(file);
589+
}
590+
}
591+
}
592+
593+
// Eccezioni
594+
archive.file('backup/.htaccess', {});
595+
archive.file('files/.htaccess', {});
596+
archive.file('files/my_impianti/componente.ini', {});
597+
archive.file('logs/.htaccess', {});
598+
599+
// Aggiunta del file dei checksum
600+
let checksumFile = fs.createWriteStream('./checksum.json', { flags: 'w' });
601+
checksumFile.write(JSON.stringify(checksum));
602+
checksumFile.close();
603+
archive.file('checksum.json', {});
604+
605+
// Aggiunta del file per il controllo di integrità del database
606+
var bufferStream = new Readable();
607+
608+
bufferStream.push(shell.exec('php update/structure.php', {
609+
silent: true
610+
}).stdout);
611+
bufferStream.push(null);
612+
archive.append(bufferStream, { name: 'mysql.json' });
613+
614+
// Aggiunta del file per il controllo delle impostazioni
615+
bufferStream = new Readable();
616+
bufferStream.push(shell.exec('php update/settings.php', {
617+
silent: true
618+
}).stdout);
619+
bufferStream.push(null);
620+
archive.append(bufferStream, { name: 'settings.json' });
621+
622+
// Aggiunta del file per il controllo delle viste
623+
bufferStream = new Readable();
624+
bufferStream.push(shell.exec('php update/views.php', {
625+
silent: true
626+
}).stdout);
627+
bufferStream.push(null);
628+
archive.append(bufferStream, { name: 'views.json' });
629+
630+
// Aggiunta del file per il controllo dei moduli
631+
bufferStream = new Readable();
632+
bufferStream.push(shell.exec('php update/modules.php', {
633+
silent: true
634+
}).stdout);
635+
bufferStream.push(null);
636+
archive.append(bufferStream, { name: 'modules.json' });
637+
638+
639+
// Aggiunta del commit corrente nel file REVISION
640+
bufferStream = new Readable();
641+
bufferStream.push(shell.exec('git rev-parse --short HEAD', {
642+
silent: true
643+
}).stdout);
644+
bufferStream.push(null);
645+
archive.append(bufferStream, { name: 'REVISION' });
646+
647+
// Creazione di un stream leggibile con la versione
648+
const versionStream = new Readable({
649+
read() {
650+
this.push(version);
651+
this.push(null);
652+
}
653+
});
654+
655+
// Aggiunta della versione corrente nel file VERSION
656+
archive.append(versionStream, { name: 'VERSION' });
657+
658+
// Completamento dello ZIP
659+
archive.finalize();
660+
});
641661
});
642-
643-
// Aggiunta della versione corrente nel file VERSION
644-
archive.append(bufferStream, { name: 'VERSION' });
645-
646-
// Completamento dello ZIP
647-
archive.finalize();
648-
649-
done();
650-
}).catch(err => {
651-
console.error('Si è verificato un errore:', err);
652-
});
662+
}).catch(err => {
663+
console.error('Si è verificato un errore:', err);
664+
done(err);
653665
});
654666
}
655667

0 commit comments

Comments
 (0)