config: universally define the app name in the package.json as "productName"

The goal is to have this as the only truth, as well as the version string.
This commit is contained in:
Xymorot 2019-12-10 23:36:34 +01:00
parent e02e0d97e0
commit 8a5472e9ee
5 changed files with 20 additions and 10 deletions

View File

@ -1,3 +1,5 @@
const packageJson = require('./package');
const ignoreList = [
/^\/\.idea($|\/)/,
/^\/\.vscode($|\/)/,
@ -32,10 +34,13 @@ const ignoreList = [
/^\/src\/.*tslint\.json/,
];
const name = packageJson.productName;
module.exports = {
packagerConfig: {
icon: 'resources/icon',
ignore: ignoreList,
name: name,
},
electronRebuildConfig: {
force: true,
@ -43,6 +48,9 @@ module.exports = {
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {
name: name,
},
},
],
};

View File

@ -1,5 +1,6 @@
{
"name": "renai",
"productName": "Renai",
"version": "1.0.0",
"description": "Hentai Library Thingy",
"private": true,

View File

@ -3,15 +3,13 @@
"csp": {
"default-src": ["self"],
"style-src": ["unsafe-inline"]
},
"appBundle": "./bundle.js"
}
},
"dev": {
"csp": {
"default-src": ["self"],
"style-src": ["unsafe-inline"],
"script-src": ["self", "unsafe-eval"]
},
"appBundle": "./bundle.js"
}
}
}

View File

@ -8,7 +8,7 @@
content="{{#each csp}}{{@key}}{{#each this}} '{{this}}'{{/each}};{{/each}}"
/>
{{/if}}
<title>Renai</title>
<title>{{appTitle}}</title>
</head>
<body id="app"></body>
<script src="{{appBundle}}"></script>

View File

@ -2,19 +2,22 @@ const handlebars = require('handlebars');
const path = require('path');
const fs = require('fs');
const data = require('./data');
const packageJson = require('../package');
function compile(isDevMode = false) {
const templatePath = path.resolve(__dirname, 'index.html.handlebars');
const template = fs.readFileSync(templatePath).toString();
const compiled = handlebars.compile(template);
let result;
const delegate = handlebars.compile(template);
let extendedData;
if (isDevMode) {
result = compiled(data.dev);
extendedData = data.dev;
} else {
result = compiled(data.prod);
extendedData = data.prod;
}
extendedData.appBundle = './bundle.js';
extendedData.appTitle = packageJson.productName;
return result;
return delegate(extendedData);
}
exports.compile = compile;