From 98d6b2281002e0987a572a2b4df8558081166f01 Mon Sep 17 00:00:00 2001 From: Beau VanDenburgh Date: Thu, 1 Feb 2018 18:53:03 -0600 Subject: [PATCH] Added a msi config file --- .gitignore | 5 +- WINBUILDER/winbuilder.aip | 388 ++++++++++++++++++++++++++++++++++++++ build.js | 56 +++--- package-lock.json | 5 + package.json | 1 + src/package.json | 2 +- winstall.js | 99 ++++++++-- 7 files changed, 503 insertions(+), 53 deletions(-) create mode 100644 WINBUILDER/winbuilder.aip diff --git a/.gitignore b/.gitignore index 1aa64a5..0ba764b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,7 @@ src/node_modules project-delta.wixobj project-delta.wixpdb project-delta.wxs -project-delta.msi \ No newline at end of file +project-delta.msi + +WINBUILDER/* +!/WINBUILDER/winbuilder.aip \ No newline at end of file diff --git a/WINBUILDER/winbuilder.aip b/WINBUILDER/winbuilder.aip new file mode 100644 index 0000000..f4a1d03 --- /dev/null +++ b/WINBUILDER/winbuilder.aip @@ -0,0 +1,388 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build.js b/build.js index b2dff54..ec6dd6e 100644 --- a/build.js +++ b/build.js @@ -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"+ @@ -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()){ @@ -62,6 +70,10 @@ 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){ @@ -69,31 +81,9 @@ function deleteAnythingThatStartsWithPeriods(path) { 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) - }); - }); -} +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 66c3e08..c3abd28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1125,6 +1125,11 @@ "thenify-all": "1.6.0" } }, + "ncp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ncp/-/ncp-2.0.0.tgz", + "integrity": "sha1-GVoh1sRuNh0vsSgbo4uR6d9727M=" + }, "nodeify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/nodeify/-/nodeify-1.0.1.tgz", diff --git a/package.json b/package.json index 436c2ef..291b037 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/src/package.json b/src/package.json index 3c71e8c..c37139e 100644 --- a/src/package.json +++ b/src/package.json @@ -7,4 +7,4 @@ "jquery": "3.1.1", "mathquill": "^0.10.1-a" } -} \ No newline at end of file +} diff --git a/winstall.js b/winstall.js index 27c6032..99b9e37 100644 --- a/winstall.js +++ b/winstall.js @@ -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) })() @@ -37,4 +63,41 @@ function cleanUpShit(deleteInstaller){ fs.unlinkSync(file); } }); -} \ No newline at end of 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); + } + }); + } +}; \ No newline at end of file