Skip to content

Commit

Permalink
Added a msi config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Beau VanDenburgh committed Feb 2, 2018
1 parent a894fa5 commit 98d6b22
Show file tree
Hide file tree
Showing 7 changed files with 503 additions and 53 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@ src/node_modules
project-delta.wixobj
project-delta.wixpdb
project-delta.wxs
project-delta.msi
project-delta.msi

WINBUILDER/*
!/WINBUILDER/winbuilder.aip
388 changes: 388 additions & 0 deletions WINBUILDER/winbuilder.aip

Large diffs are not rendered by default.

56 changes: 23 additions & 33 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,23 @@ packager(config = {
);
console.log(err);
})
.then(cleanUp)
.then(function (path) {
console.log("cleaning up...")
fs.renameSync(path[0],'./build')
fs.rmdirSync('./tmp')

var node_modules = "./build/resources/app/node_modules"
var important_folders = ["build","dist"];

fs.readdirSync(node_modules).forEach( library => {
fs.readdirSync(node_modules + '/' + library)
.filter (subfolder => !important_folders.includes(subfolder))
.forEach(subfolder => {
deleteFolderRecursive(node_modules + "/" + library + "/" + subfolder)
});
});
deleteAnythingThatStartsWithPeriods("./build");
})
.then(function () {//success!
console.log(
" \r"+
Expand All @@ -30,14 +46,6 @@ packager(config = {
);
})


function onFail(err) {
console.log(
"Errors were encountered:"
);
console.log(err);
}

function deleteFolderRecursive(path) {
if( fs.existsSync(path) ) {
if(fs.lstatSync(path).isDirectory()){
Expand All @@ -62,38 +70,20 @@ function deleteFolderRecursive(path) {
}
};

function updateDeleteProgress(str){
process.stdout.write(`${processed_files++} files deleted\r`);
}

function deleteAnythingThatStartsWithPeriods(path) {
if( fs.existsSync(path) ) {
fs.readdirSync(path).forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.lstatSync(curPath).isDirectory()) { // recurse
deleteAnythingThatStartsWithPeriods(curPath);
} else if(file[0]==".") { // delete file
console.log('')
console.log(file)
fs.unlinkSync(curPath);
}
});
}
};

function updateDeleteProgress(str){
process.stdout.write(`${processed_files++} files deleted\r`);
}

function cleanUp(path) {
console.log("cleaning up...")
fs.renameSync(path[0],'./build')
fs.rmdirSync('./tmp')
deleteAnythingThatStartsWithPeriods("./build");

var node_modules = "./build/resources/app/node_modules"
var important_folders = ["build","dist"];

fs.readdirSync(node_modules).forEach( library => {
fs.readdirSync(node_modules + '/' + library)
.filter (subfolder => !important_folders.includes(subfolder))
.forEach(subfolder => {
deleteFolderRecursive(node_modules + "/" + library + "/" + subfolder)
});
});
}
};
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dependencies": {
"electron": "^1.8.1",
"electron-packager": "^10.1.2",
"ncp": "^2.0.0",
"project-delta": "file:src",
"promptly": "^3.0.3"
},
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"jquery": "3.1.1",
"mathquill": "^0.10.1-a"
}
}
}
99 changes: 81 additions & 18 deletions winstall.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,51 @@
const { MSICreator } = require('electron-wix-msi');
const fs = require('fs');
const {ncp} = require('ncp');ncp.limit=16;

(async function(){
cleanUpShit(true);

//copy ./src to a temp folder
// await new Promise(function(resolve, reject) {
// ncp("./src","./msibuild",(err) => {
// if(err)
// reject();
// else
// resolve();
// })
// });

cleanUpShit(true);
// console.log("cleaning up...")
ncp("./build","%appdata%/Project Delta")
//purge it of anything with a period.

const msiCreator = new MSICreator({
appDirectory: './build',
description: 'Type out notes and tests for math',
exe: 'project-delta.exe',
name: 'Project Delta',
manufacturer: 'Beau-Programs',
outputDirectory: './',
version:"1.1.1.1"
});
// Step 2: Create a .wxs template file
(async function(){
console.log("Making .wix")
await msiCreator.create();
console.log("Making .msi")
await msiCreator.compile();
cleanUpShit(false)
// var node_modules = "./msibuild/node_modules"
// var important_folders = ["build","dist"];

// fs.readdirSync(node_modules).forEach( library => {
// fs.readdirSync(node_modules + '/' + library)
// .filter (subfolder => !important_folders.includes(subfolder))
// .forEach(subfolder => {
// deleteFolderRecursive(node_modules + "/" + library + "/" + subfolder)
// });
// });

//configure installer
// const msiCreator = new MSICreator({
// appDirectory: './build/resources/app',
// description: 'Type out notes and tests for math',
// exe: 'project-delta.exe',
// name: 'Project Delta',
// manufacturer: 'Beau-Programs',
// outputDirectory: './',
// version:"1.1.1.1"
// });

// console.log("Making .wix")
// await msiCreator.create();
// console.log("Making .msi")
// await msiCreator.compile();
// cleanUpShit(false)
})()


Expand All @@ -37,4 +63,41 @@ function cleanUpShit(deleteInstaller){
fs.unlinkSync(file);
}
});
}
deleteFolderRecursive("./msibuild")
}

function deleteFolderRecursive(path) {
if( fs.existsSync(path) ) {
if(fs.lstatSync(path).isDirectory()){
fs.readdirSync(path).forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.lstatSync(curPath).isDirectory()) { // recurse
deleteFolderRecursive(curPath);
} else { // delete file
fs.unlinkSync(curPath);
}
});
try {
fs.rmdirSync(path);
} catch(e) {
fs.rmdirSync(path);
}
} else {
fs.unlinkSync(path);
}
}
};

function deleteAnythingThatStartsWithPeriods(path) {
if( fs.existsSync(path) ) {
fs.readdirSync(path).forEach(function(file,index){
var curPath = path + "/" + file;
if(fs.lstatSync(curPath).isDirectory()) { // recurse
deleteAnythingThatStartsWithPeriods(curPath);
} else if(file[0]==".") { // delete file
console.log(file)
fs.unlinkSync(curPath);
}
});
}
};

0 comments on commit 98d6b22

Please sign in to comment.