Skip to content

Commit 98d6b22

Browse files
author
Beau VanDenburgh
committed
Added a msi config file
1 parent a894fa5 commit 98d6b22

File tree

7 files changed

+503
-53
lines changed

7 files changed

+503
-53
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ src/node_modules
55
project-delta.wixobj
66
project-delta.wixpdb
77
project-delta.wxs
8-
project-delta.msi
8+
project-delta.msi
9+
10+
WINBUILDER/*
11+
!/WINBUILDER/winbuilder.aip

WINBUILDER/winbuilder.aip

Lines changed: 388 additions & 0 deletions
Large diffs are not rendered by default.

build.js

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,23 @@ packager(config = {
1818
);
1919
console.log(err);
2020
})
21-
.then(cleanUp)
21+
.then(function (path) {
22+
console.log("cleaning up...")
23+
fs.renameSync(path[0],'./build')
24+
fs.rmdirSync('./tmp')
25+
26+
var node_modules = "./build/resources/app/node_modules"
27+
var important_folders = ["build","dist"];
28+
29+
fs.readdirSync(node_modules).forEach( library => {
30+
fs.readdirSync(node_modules + '/' + library)
31+
.filter (subfolder => !important_folders.includes(subfolder))
32+
.forEach(subfolder => {
33+
deleteFolderRecursive(node_modules + "/" + library + "/" + subfolder)
34+
});
35+
});
36+
deleteAnythingThatStartsWithPeriods("./build");
37+
})
2238
.then(function () {//success!
2339
console.log(
2440
" \r"+
@@ -30,14 +46,6 @@ packager(config = {
3046
);
3147
})
3248

33-
34-
function onFail(err) {
35-
console.log(
36-
"Errors were encountered:"
37-
);
38-
console.log(err);
39-
}
40-
4149
function deleteFolderRecursive(path) {
4250
if( fs.existsSync(path) ) {
4351
if(fs.lstatSync(path).isDirectory()){
@@ -62,38 +70,20 @@ function deleteFolderRecursive(path) {
6270
}
6371
};
6472

73+
function updateDeleteProgress(str){
74+
process.stdout.write(`${processed_files++} files deleted\r`);
75+
}
76+
6577
function deleteAnythingThatStartsWithPeriods(path) {
6678
if( fs.existsSync(path) ) {
6779
fs.readdirSync(path).forEach(function(file,index){
6880
var curPath = path + "/" + file;
6981
if(fs.lstatSync(curPath).isDirectory()) { // recurse
7082
deleteAnythingThatStartsWithPeriods(curPath);
7183
} else if(file[0]==".") { // delete file
72-
console.log('')
84+
console.log(file)
7385
fs.unlinkSync(curPath);
7486
}
7587
});
7688
}
77-
};
78-
79-
function updateDeleteProgress(str){
80-
process.stdout.write(`${processed_files++} files deleted\r`);
81-
}
82-
83-
function cleanUp(path) {
84-
console.log("cleaning up...")
85-
fs.renameSync(path[0],'./build')
86-
fs.rmdirSync('./tmp')
87-
deleteAnythingThatStartsWithPeriods("./build");
88-
89-
var node_modules = "./build/resources/app/node_modules"
90-
var important_folders = ["build","dist"];
91-
92-
fs.readdirSync(node_modules).forEach( library => {
93-
fs.readdirSync(node_modules + '/' + library)
94-
.filter (subfolder => !important_folders.includes(subfolder))
95-
.forEach(subfolder => {
96-
deleteFolderRecursive(node_modules + "/" + library + "/" + subfolder)
97-
});
98-
});
99-
}
89+
};

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"dependencies": {
99
"electron": "^1.8.1",
1010
"electron-packager": "^10.1.2",
11+
"ncp": "^2.0.0",
1112
"project-delta": "file:src",
1213
"promptly": "^3.0.3"
1314
},

src/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
"jquery": "3.1.1",
88
"mathquill": "^0.10.1-a"
99
}
10-
}
10+
}

winstall.js

Lines changed: 81 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,51 @@
11
const { MSICreator } = require('electron-wix-msi');
22
const fs = require('fs');
3+
const {ncp} = require('ncp');ncp.limit=16;
34

5+
(async function(){
6+
cleanUpShit(true);
7+
8+
//copy ./src to a temp folder
9+
// await new Promise(function(resolve, reject) {
10+
// ncp("./src","./msibuild",(err) => {
11+
// if(err)
12+
// reject();
13+
// else
14+
// resolve();
15+
// })
16+
// });
417

5-
cleanUpShit(true);
18+
// console.log("cleaning up...")
19+
ncp("./build","%appdata%/Project Delta")
20+
//purge it of anything with a period.
621

7-
const msiCreator = new MSICreator({
8-
appDirectory: './build',
9-
description: 'Type out notes and tests for math',
10-
exe: 'project-delta.exe',
11-
name: 'Project Delta',
12-
manufacturer: 'Beau-Programs',
13-
outputDirectory: './',
14-
version:"1.1.1.1"
15-
});
16-
// Step 2: Create a .wxs template file
17-
(async function(){
18-
console.log("Making .wix")
19-
await msiCreator.create();
20-
console.log("Making .msi")
21-
await msiCreator.compile();
22-
cleanUpShit(false)
22+
// var node_modules = "./msibuild/node_modules"
23+
// var important_folders = ["build","dist"];
24+
25+
// fs.readdirSync(node_modules).forEach( library => {
26+
// fs.readdirSync(node_modules + '/' + library)
27+
// .filter (subfolder => !important_folders.includes(subfolder))
28+
// .forEach(subfolder => {
29+
// deleteFolderRecursive(node_modules + "/" + library + "/" + subfolder)
30+
// });
31+
// });
32+
33+
//configure installer
34+
// const msiCreator = new MSICreator({
35+
// appDirectory: './build/resources/app',
36+
// description: 'Type out notes and tests for math',
37+
// exe: 'project-delta.exe',
38+
// name: 'Project Delta',
39+
// manufacturer: 'Beau-Programs',
40+
// outputDirectory: './',
41+
// version:"1.1.1.1"
42+
// });
43+
44+
// console.log("Making .wix")
45+
// await msiCreator.create();
46+
// console.log("Making .msi")
47+
// await msiCreator.compile();
48+
// cleanUpShit(false)
2349
})()
2450

2551

@@ -37,4 +63,41 @@ function cleanUpShit(deleteInstaller){
3763
fs.unlinkSync(file);
3864
}
3965
});
40-
}
66+
deleteFolderRecursive("./msibuild")
67+
}
68+
69+
function deleteFolderRecursive(path) {
70+
if( fs.existsSync(path) ) {
71+
if(fs.lstatSync(path).isDirectory()){
72+
fs.readdirSync(path).forEach(function(file,index){
73+
var curPath = path + "/" + file;
74+
if(fs.lstatSync(curPath).isDirectory()) { // recurse
75+
deleteFolderRecursive(curPath);
76+
} else { // delete file
77+
fs.unlinkSync(curPath);
78+
}
79+
});
80+
try {
81+
fs.rmdirSync(path);
82+
} catch(e) {
83+
fs.rmdirSync(path);
84+
}
85+
} else {
86+
fs.unlinkSync(path);
87+
}
88+
}
89+
};
90+
91+
function deleteAnythingThatStartsWithPeriods(path) {
92+
if( fs.existsSync(path) ) {
93+
fs.readdirSync(path).forEach(function(file,index){
94+
var curPath = path + "/" + file;
95+
if(fs.lstatSync(curPath).isDirectory()) { // recurse
96+
deleteAnythingThatStartsWithPeriods(curPath);
97+
} else if(file[0]==".") { // delete file
98+
console.log(file)
99+
fs.unlinkSync(curPath);
100+
}
101+
});
102+
}
103+
};

0 commit comments

Comments
 (0)