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