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:
parent
e02e0d97e0
commit
8a5472e9ee
|
@ -1,3 +1,5 @@
|
||||||
|
const packageJson = require('./package');
|
||||||
|
|
||||||
const ignoreList = [
|
const ignoreList = [
|
||||||
/^\/\.idea($|\/)/,
|
/^\/\.idea($|\/)/,
|
||||||
/^\/\.vscode($|\/)/,
|
/^\/\.vscode($|\/)/,
|
||||||
|
@ -32,10 +34,13 @@ const ignoreList = [
|
||||||
/^\/src\/.*tslint\.json/,
|
/^\/src\/.*tslint\.json/,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const name = packageJson.productName;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
packagerConfig: {
|
packagerConfig: {
|
||||||
icon: 'resources/icon',
|
icon: 'resources/icon',
|
||||||
ignore: ignoreList,
|
ignore: ignoreList,
|
||||||
|
name: name,
|
||||||
},
|
},
|
||||||
electronRebuildConfig: {
|
electronRebuildConfig: {
|
||||||
force: true,
|
force: true,
|
||||||
|
@ -43,6 +48,9 @@ module.exports = {
|
||||||
makers: [
|
makers: [
|
||||||
{
|
{
|
||||||
name: '@electron-forge/maker-squirrel',
|
name: '@electron-forge/maker-squirrel',
|
||||||
|
config: {
|
||||||
|
name: name,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "renai",
|
"name": "renai",
|
||||||
|
"productName": "Renai",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Hentai Library Thingy",
|
"description": "Hentai Library Thingy",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|
|
@ -3,15 +3,13 @@
|
||||||
"csp": {
|
"csp": {
|
||||||
"default-src": ["self"],
|
"default-src": ["self"],
|
||||||
"style-src": ["unsafe-inline"]
|
"style-src": ["unsafe-inline"]
|
||||||
},
|
}
|
||||||
"appBundle": "./bundle.js"
|
|
||||||
},
|
},
|
||||||
"dev": {
|
"dev": {
|
||||||
"csp": {
|
"csp": {
|
||||||
"default-src": ["self"],
|
"default-src": ["self"],
|
||||||
"style-src": ["unsafe-inline"],
|
"style-src": ["unsafe-inline"],
|
||||||
"script-src": ["self", "unsafe-eval"]
|
"script-src": ["self", "unsafe-eval"]
|
||||||
},
|
}
|
||||||
"appBundle": "./bundle.js"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
content="{{#each csp}}{{@key}}{{#each this}} '{{this}}'{{/each}};{{/each}}"
|
content="{{#each csp}}{{@key}}{{#each this}} '{{this}}'{{/each}};{{/each}}"
|
||||||
/>
|
/>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<title>Renai</title>
|
<title>{{appTitle}}</title>
|
||||||
</head>
|
</head>
|
||||||
<body id="app"></body>
|
<body id="app"></body>
|
||||||
<script src="{{appBundle}}"></script>
|
<script src="{{appBundle}}"></script>
|
||||||
|
|
|
@ -2,19 +2,22 @@ const handlebars = require('handlebars');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const data = require('./data');
|
const data = require('./data');
|
||||||
|
const packageJson = require('../package');
|
||||||
|
|
||||||
function compile(isDevMode = false) {
|
function compile(isDevMode = false) {
|
||||||
const templatePath = path.resolve(__dirname, 'index.html.handlebars');
|
const templatePath = path.resolve(__dirname, 'index.html.handlebars');
|
||||||
const template = fs.readFileSync(templatePath).toString();
|
const template = fs.readFileSync(templatePath).toString();
|
||||||
const compiled = handlebars.compile(template);
|
const delegate = handlebars.compile(template);
|
||||||
let result;
|
let extendedData;
|
||||||
if (isDevMode) {
|
if (isDevMode) {
|
||||||
result = compiled(data.dev);
|
extendedData = data.dev;
|
||||||
} else {
|
} else {
|
||||||
result = compiled(data.prod);
|
extendedData = data.prod;
|
||||||
}
|
}
|
||||||
|
extendedData.appBundle = './bundle.js';
|
||||||
|
extendedData.appTitle = packageJson.productName;
|
||||||
|
|
||||||
return result;
|
return delegate(extendedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.compile = compile;
|
exports.compile = compile;
|
||||||
|
|
Loading…
Reference in New Issue