portapy commands
parent
a0572460ca
commit
87a12a5a71
15
index.js
15
index.js
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
let args = process.argv.slice(2);
|
||||
|
||||
if (args[0] == 'help' || args[0] == '?' || args[0] == 'h'){
|
||||
console.log("heres some help");
|
||||
} else if(args[0] == "version" || args[0] == "v") {
|
||||
console.log("version number placeholder");
|
||||
} else if (args[0] == "py" || args[0] == "pyversion") {
|
||||
if (args[1]){
|
||||
console.log(args[1]);
|
||||
} else {
|
||||
console.log("version of python");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "portapy",
|
||||
"version": "0.0.11",
|
||||
"version": "0.0.13",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "portapy",
|
||||
"version": "0.0.11",
|
||||
"version": "0.0.13",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
@ -10,7 +10,8 @@
|
|||
"clean": "node clean.js"
|
||||
},
|
||||
"bin": {
|
||||
"python": "bin/python.js"
|
||||
"python": "bin/python.js",
|
||||
"portapy": "index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
@ -24,7 +25,6 @@
|
|||
"dependencies": {
|
||||
"copy-dir": "^0.4.0",
|
||||
"minimist": "^1.2.0",
|
||||
"python": "0.0.4",
|
||||
"request": "^2.88.0"
|
||||
},
|
||||
"homepage": "https://github.com/marcus13345/portapy#readme"
|
||||
|
|
|
|||
|
|
@ -11,68 +11,68 @@ const copydir = require('copy-dir');
|
|||
|
||||
async function download() {
|
||||
|
||||
|
||||
let url = await getPythonDownloadLink();
|
||||
let filename = path.parse(url).base;
|
||||
try {
|
||||
fs.mkdirSync('Python-Installer');
|
||||
} catch(e) {'';}
|
||||
try {
|
||||
fs.mkdirSync('Python');
|
||||
} catch(e) {'';}
|
||||
try {
|
||||
fs.mkdirSync('Temp-Python');
|
||||
} catch(e) {'';}
|
||||
try {
|
||||
fs.writeFileSync('.installerLocation', filename);
|
||||
} catch(e) {'';}
|
||||
// let installSettings = fs.readFileSync('unattend.xml');
|
||||
|
||||
let url = await getPythonDownloadLink();
|
||||
let filename = path.parse(url).base;
|
||||
try {
|
||||
fs.mkdirSync('Python-Installer');
|
||||
} catch(e) {'';}
|
||||
try {
|
||||
fs.mkdirSync('Python');
|
||||
} catch(e) {'';}
|
||||
try {
|
||||
fs.mkdirSync('Temp-Python');
|
||||
} catch(e) {'';}
|
||||
try {
|
||||
fs.writeFileSync('.installerLocation', filename);
|
||||
} catch(e) {'';}
|
||||
// let installSettings = fs.readFileSync('unattend.xml');
|
||||
|
||||
let out_file = `Python-Installer/${filename}`
|
||||
let out_file = `Python-Installer/${filename}`
|
||||
|
||||
await new Promise(resolve => {
|
||||
request({
|
||||
uri: url,
|
||||
encoding: null
|
||||
}, function (error, response, body) {
|
||||
fs.writeFileSync(out_file, body, {});
|
||||
resolve();
|
||||
});
|
||||
await new Promise(resolve => {
|
||||
request({
|
||||
uri: url,
|
||||
encoding: null
|
||||
}, function (error, response, body) {
|
||||
fs.writeFileSync(out_file, body, {});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
console.log('Download Complete!');
|
||||
console.log('Download Complete!');
|
||||
|
||||
switch (os.platform())
|
||||
{
|
||||
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=${tempPath}`, {
|
||||
stdio: "inherit"
|
||||
});
|
||||
|
||||
console.log("Creating Portable Python Directory");
|
||||
switch (os.platform())
|
||||
{
|
||||
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=${tempPath}`, {
|
||||
stdio: "inherit"
|
||||
});
|
||||
|
||||
console.log("Creating Portable Python Directory");
|
||||
|
||||
copydir.sync(tempPath, targetPath);
|
||||
console.log("Portable Directory Created!");
|
||||
copydir.sync(tempPath, targetPath);
|
||||
console.log("Portable Directory Created!");
|
||||
|
||||
console.log("Uninstalling Unnecessary Python Files");
|
||||
console.log("Uninstalling Unnecessary Python Files");
|
||||
|
||||
execSync(`${installerPath} /passive /uninstall`, {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
execSync(`${installerPath} /passive /uninstall`, {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
|
||||
fs.rmdirSync(tempPath);
|
||||
fs.rmdirSync(tempPath);
|
||||
|
||||
console.log("PordaPy Installed!");
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
break;
|
||||
}[]
|
||||
console.log("PordaPy Installed!");
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getPythonDownloadLink() {
|
||||
|
|
|
|||
|
|
@ -3,18 +3,20 @@ module.exports = {
|
|||
}
|
||||
const request = require('request');
|
||||
|
||||
function versions()
|
||||
{
|
||||
return new Promise(resolve => {
|
||||
// let matches = [];
|
||||
|
||||
let versions = function() {
|
||||
|
||||
new Promise(resolve => {
|
||||
request({
|
||||
uri: "https://www.python.org/ftp/python/",
|
||||
}, function (error, response, body) {
|
||||
const re = /"[0-9]{1,}\.[0-9]{1,}(\.[0-9]{1,})*\/"/g;
|
||||
let matches = body.match(re)
|
||||
matches = body.match(re)
|
||||
matches = matches.map((value) => {
|
||||
return value.slice(1,-2)
|
||||
return value.slice(1, -2);
|
||||
});
|
||||
resolve(matches);
|
||||
resolve(matches);
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue