hubl/make-webmanifest.mjs
2020-08-24 16:44:03 +02:00

39 lines
1.1 KiB
JavaScript

'use strict';
import fs from 'fs';
if(!fs.existsSync("config.json")) throw "[Error] (Mandatory) Missing config.json file";
let config = JSON.parse(fs.readFileSync('config.json'));
if(!config.clientName) throw "[Error] (Mandatory) Missing clientName on config.json";
if(!config.clientLogo) throw "[Error] (Mandatory) Missing clientLogo on config.json";
let manifest = {
"lang": "fr",
"dir": "ltr",
"name": config.clientName,
"description": `Hubl of ${config.clientName}`,
"short_name": config.clientName,
"icons": [{
"src": config.clientLogo,
"purpose": "any"
}, {
"src": "/images/hubl-icon-192.png",
"sizes": "192x192",
"type": "image/png"
}, {
"src": "/images/hubl-icon-512.png",
"sizes": "512x512",
"type": "image/png"
}],
"start_url": ".",
"display": "standalone",
"orientation": "portrait",
"background_color": "#fff",
'theme_color': "white"
}
fs.existsSync("dist") || fs.mkdirSync("dist");
fs.writeFileSync('dist/manifest.webmanifest', JSON.stringify(manifest, null, 2));
console.log(`Created manifest for ${config.clientName}`);