forked from manga-download/haruneko
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.app.js
75 lines (64 loc) · 1.82 KB
/
build.app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
const path = require('path');
const fs = require('fs-extra');
const config = require('./package.json');
const argv = require('yargs').argv;
const source = path.join(__dirname, 'src');
const target = path.join(__dirname, 'build.app');
const files = [ /*'main.js'*/ ];
async function getBranch() {
return 'master';
}
async function getManifest() {
let branch = await getBranch();
const baseURL = argv.url || `${config.url}/${branch}`;
return {
name: config.name,
description: config.description,
'chromium-args': '--ignore-certificate-errors',
main: baseURL + '/index.html',
//main: config.main,
//url: baseURL + '/index.html',
'node-remote': [
baseURL + '/*'
],
/*
webkit: {
plugin: true,
'page-cache': false
},
*/
window: {
title: `${config.title} - ${config.description}`,
//icon: 'link.png',
//toolbar: true,
//frame: false,
position: 'center',
width: 1280,
height: 720
},
dependencies: config.dependencies
};
}
async function installModules() {
let modules = path.join(__dirname, target, 'node_modules');
try {
await fs.remove(modules);
} catch(error) {
//
}
if(argv.modules) {
// `cd $target` && `npm install --only=production`
}
}
(async function main() {
await fs.ensureDir(target);
// copy files
for(let file of files) {
fs.copy(path.join(source, file), path.join(target, file));
}
// write application manifest
let manifest = await getManifest();
fs.writeJSON(path.join(target, 'package.json'), manifest, { spaces: 4 });
// install node modules for deployment
await installModules();
})();