From bcd56daebdee7d493c6d290c5804e6e254ef8e8c Mon Sep 17 00:00:00 2001 From: BrOakes Date: Tue, 20 Nov 2018 18:39:29 -0500 Subject: [PATCH] tryin something here --- package-lock.json | 15 ++++++++++++++- package.json | 3 ++- scripts/postinstall.js | 2 +- scripts/uninstall.js | 13 +++++++++---- util/downloadpython.js | 25 +++++++++++++++++-------- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index dd9b20b..2c173b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "portapy", - "version": "0.0.4", + "version": "0.0.7", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -64,6 +64,14 @@ "delayed-stream": "~1.0.0" } }, + "copy-dir": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/copy-dir/-/copy-dir-0.4.0.tgz", + "integrity": "sha512-mIefrD97nE1XX2th570tR5UQvW6/92czEPGe+oTtrxPAJl+KOKLpzcRa+e38WEpmt/IUN1n65KvRMzPblR+fDQ==", + "requires": { + "mkdir-p": "~0.0.4" + } + }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", @@ -217,6 +225,11 @@ "resolved": "http://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, + "mkdir-p": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/mkdir-p/-/mkdir-p-0.0.7.tgz", + "integrity": "sha1-JMXb4m2jqZ7xWKHu+aXC3Z3laDw=" + }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", diff --git a/package.json b/package.json index 69527dd..93ba8fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "portapy", - "version": "0.0.4", + "version": "0.0.7", "description": "", "main": "index.js", "scripts": { @@ -22,6 +22,7 @@ "url": "https://github.com/marcus13345/portapy/issues" }, "dependencies": { + "copy-dir": "^0.4.0", "minimist": "^1.2.0", "python": "0.0.4", "request": "^2.88.0" diff --git a/scripts/postinstall.js b/scripts/postinstall.js index 41429e8..b7d36e9 100644 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -1,7 +1,7 @@ // pip install --target=lib numpy six pypng pyplatec let {execSync} = require('child_process'); -let pythonDownloader = require('./util/downloadpython.js') +let pythonDownloader = require('../util/downloadpython.js') pythonDownloader.download(); diff --git a/scripts/uninstall.js b/scripts/uninstall.js index 1f999e4..51ab9a5 100644 --- a/scripts/uninstall.js +++ b/scripts/uninstall.js @@ -3,8 +3,13 @@ const fs = require('fs'); let installerFilename = fs.readFileSync('.installerLocation').toString(); -let pythonPath = path.resolve(__dirname, 'Python-Installer', installerFilename); +let pythonInstallerPath = path.resolve(__dirname, 'Python-Installer', installerFilename); -require('child_process').execSync(`${pythonPath} /passive /uninstall`, { - stdio: 'inherit' -}); \ No newline at end of file +let pythonPath = path.resolve(__dirname, 'Python'); + +fs.rmdirSync(pythonPath); + + +// require('child_process').execSync(`${pythonInstallerPath} /passive /uninstall`, { +// stdio: 'inherit' +// }); \ No newline at end of file diff --git a/util/downloadpython.js b/util/downloadpython.js index 8ac4aaf..5cf6f87 100644 --- a/util/downloadpython.js +++ b/util/downloadpython.js @@ -7,6 +7,7 @@ const fs = require('fs'); const os = require('os'); const {execSync} = require('child_process'); const path = require('path'); +const copydir = require('copy-dir'); async function download() { @@ -20,6 +21,9 @@ async function download() { try { fs.mkdirSync('Python'); } catch(e) {'';} + try { + fs.mkdirSync('Temp-Python'); + } catch(e) {'';} try { fs.writeFileSync('.installerLocation', filename); } catch(e) {'';} @@ -45,26 +49,31 @@ async function download() { case 'win32': { try { let installerPath = path.join(__dirname, '..', 'Python-Installer/', filename); + let tempPath = path.join(__dirname, '..', 'Temp-Python/'); let targetPath = path.join(__dirname, '..', 'Python/'); - execSync(`${installerPath} /passive DefaultJustForMeTargetDir=${targetPath}`, { + execSync(`${installerPath} /passive DefaultJustForMeTargetDir=${tempPath}`, { stdio: "inherit" }); + + console.log("Creating Portable Python Directory"); - let files = fs.readdirSync(targetPath); - files.forEach(function (element) { - console.log(element); + copydir.sync(tempPath, targetPath); + console.log("Portable Directory Created!"); + + console.log("Uninstalling Unnecessary Python Files"); + + execSync(`${installerPath} /passive /uninstall`, { + stdio: 'inherit' }); + fs.rmdirSync(tempPath); - console.log("Python Installed!"); + console.log("PordaPy Installed!"); } catch (err) { console.log(err); } break; }[] } - - - } function getPythonDownloadLink() {