Quellcode durchsuchen

fix elxr use and npmi

pull/4/head
chess vor 3 Jahren
Ursprung
Commit
a4012ea4e9
2 geänderte Dateien mit 268 neuen und 60 gelöschten Zeilen
  1. 157
    37
      i.js
  2. 111
    23
      index.js

+ 157
- 37
i.js Datei anzeigen

@@ -1,4 +1,4 @@
/* Version: 1.0.0 - May 8, 2021 11:38:39 */
/* Version: 1.0.0 - May 11, 2021 23:29:35 */
'use strict';

var path$1 = require('path');
@@ -12548,7 +12548,7 @@ var moment = createCommonjsModule(function (module, exports) {
return hooks;

})));
}, "/$$rollup_base$$/node_modules/moment");
}, "E:/elixir/production_A/bbhverse/node_modules/moment");

let array8 = arrayUntyped,
array16 = arrayUntyped,
@@ -23611,7 +23611,7 @@ var nodeShellExec = cliverse.nodeShellExec;



const BUILD_VERSION = 'Version: 1.0.0 - built on May 8, 2021 11:38:39';
const BUILD_VERSION = 'Version: 1.0.0 - built on May 11, 2021 23:29:35';
function getVersion() { return BUILD_VERSION; }
console.log(getVersion());

@@ -23999,7 +23999,7 @@ var op = {
console.log('result : ' + JSON.stringify(r));
Object.keys(processedArgs).forEach((v) => { v != '_' ? namedArgs.push('--' + v + '=' + processedArgs[v]) : null; });
// PB : TODO -- Convert all the cli args back to string.
var args = [__dirname + '/windowselevate.hta'].concat(processedArgs._).concat(namedArgs.join(' ')); args.push('--runas=self');
var args = [__dirname + '/.run/windowselevate.hta'].concat(processedArgs._).concat(namedArgs.join(' ')); args.push('--runas=self');
args.push('--nodepath=' + r[r.length - 1]);
if (!processedArgs.node_env) args.push('--node_env=' + ENV.NODE_ENV);
if (processedArgs.debug) args.push('--debug=true'); // Enable to debug elevated..
@@ -24286,9 +24286,9 @@ var op = {
// console.dir(env)
console.log('Running exlr pull : ' + path__default['default'].dirname(__dirname));

if (!processedArgs.runas) gitRepos.map((repo) => performPull(repo, 'master'));
if (!processedArgs.runas) gitRepos.map((def) => performPull(def.repo, def.branch || 'master'));
if (__isElevated) {
return any(elevatedRunasRepos.map((repo) => performPull(repo, 'master'))).then(() => {
return any(elevatedRunasRepos.map((def) => performPull(def.repo, def.branch || 'master'))).then(() => {
fs.writeFileSync('run.done', 'success');
}).catch(() => {
fs.writeFileSync('run.done', 'error');
@@ -24378,33 +24378,33 @@ var op = {
var repotasks = [];
var env = Object.assign({}, process.env);
delete env.NODE_ENV;
gitRepos.forEach(repo => {
gitRepos.forEach(repodef => {

rmtasks.push(
// () => {
// console.log(`--rm package-lock.json for ${repo}--------------------`)
// console.log(`--rm package-lock.json for ${repodef.repo}--------------------`)
// return nodeShellExec(`"${gitbash}"`, ['-c', '"rm package-lock.json"'], {
nodeShellExec('rm', ['package-lock.json'], {
inherit: true, shell: true
, cwd: instanceroot + '/' + repo
, cwd: instanceroot + '/' + repodef.repo
, env: process.env
, title: `rm 'package-lock.json' for ${repo}`
, title: `rm 'package-lock.json' for ${repodef.repo}`
})
.then(()=>{
console.log(`--rm package-lock.json for ${repo}--------------------`);
console.log(`--rm package-lock.json for ${repodef.repo}--------------------`);
}).catch((e) => { console.error(e); })
// }
);

if (npmbuildrepos.indexOf(repo) < 0) {
if (npmbuildrepos.indexOf(repodef.repo) < 0) {
repotasks.push(
() => {
console.log(`--npm i for ${repo}--------------------`);
console.log(`--npm i for ${repodef.repo}--------------------`);
var p = nodeShellExec('npm', ['i', '--force'], {
inherit: true, shell: true
, cwd: instanceroot + '/' + repo
, cwd: instanceroot + '/' + repodef.repo
, env
, title: `npm i for ${repo}`
, title: `npm i for ${repodef.repo}`
}).then(Tasq.then).catch(Tasq.catch);
return p;
});
@@ -24431,17 +24431,17 @@ var op = {
// }).then(Tasq.then).catch(Tasq.catch)
// })

var bowerRepos = ['client'];
bowerRepos.forEach(repo => {
var bowerRepos = [{ repo : 'client'}];
bowerRepos.forEach(repodef => {
repotasks.push(() => {
console.log(instanceroot + '/' + repo + '/node_modules/bower/bin/bower');
console.log(instanceroot + '/' + repodef.repo + '/node_modules/bower/bin/bower');
// var p = nodeShellExec('node_modules/bower/bin/bower', ['install'], {
var p = nodeShellExec(`"${gitbash}"`, ['-c', '"node_modules/bower/bin/bower i"'], {

inherit: true, shell: true
, cwd: instanceroot + '/' + repo
, cwd: instanceroot + '/' + repodef.repo
, env: process.env
, title: `bower i for ${repo}`
, title: `bower i for ${repodef.repo}`
}).then(Tasq.then).catch(Tasq.catch);
return p;
});
@@ -24533,6 +24533,28 @@ var op = {
console.log(serverPid);
kill(serverPid);
}
, 'model' : () => {
if (__isElevated) {
var tasks = [
() => {
var p = nodeShellExec('mklink', [ `${processedArgs._[2]}.json`
, `..\\..\\node_modules\\chess-server-lib\\common\\models\\${processedArgs._[2]}.json`], {
inherit: true, shell: true
, cwd : instanceroot + `/${selectedinstance.instanceName}-server/${selectedinstance.instanceName}/models`
, title: `mklink ${processedArgs._[2]}.json ..\\..\\node_modules\\chess-server-lib\\common\\models\\${processedArgs._[2]}.json`
, env: process.env
}).catch((e) => { console.error(e); });
return p;
}
];
return any(tasks).then(() => {
fs.writeFileSync('run.done', 'success');
}).catch(() => {
fs.writeFileSync('run.done', 'error');
})
}
else return op['runas']()
}
, 'use' : () => {
// use a certain named instance.
// Eg :
@@ -24550,7 +24572,8 @@ var op = {
*/
var runconfig = { NODE_ENV: repomanifest.node_env };
try { runconfig = Object.assign(runconfig, commonjsRequire(instanceroot + '/run.js',"/$$rollup_base$$")); } catch (e) { }
if ((!processedArgs.runas || processedArgs.runas !== 'self' && !processedArgs.force) &&
// We no longer need to check ruans.. ??? if we were initiated from self invoked privileged shell ?
if (( /*processedArgs.runas && processedArgs.runas !== 'self' &&*/ !processedArgs.force) &&
runconfig.NODE_ENV && runconfig.NODE_ENV === (repomanifest.node_env || runconfig.NODE_ENV) &&
repomanifest.instanceName && runconfig.use === repomanifest.instanceName) {

@@ -24604,9 +24627,9 @@ var op = {

// cant use git checkout -b it fails when branch already exists.
var performCheckout = (def) => {
if (excludeCheckouts[repo]) return Promise.resolve({ 'skipped': true })
if (excludeCheckouts[def.repo]) return Promise.resolve({ 'skipped': true })
return performPullOrCloneForBranch(def)().then(()=>{
return performPullOrCloneForBranch(def).then(()=>{
nodeShellExec('git', ['checkout', def.branch || checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], {
// return nodeShellExec('git', ['switch', '-m', '-C', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], {
// inherit : true, shell: true,
@@ -24650,6 +24673,11 @@ var op = {
};
if (runconfig.NODE_ENV === 'development') performMerge = () => { return Promise.resolve(true) };

// var performRepoOperation = function(def) {
// elevatedRunasRepos.map((repo) => enqueueCheckout({ repo, branch: def.branch, requiresElevation : true }))
// return any(gitRepos.map((repo) => performCheckout({ repo, branch: def.branch})))
// }

return any(tasks).then(() => {
var pr = Promise.resolve(true);
if (!__isElevated) {
@@ -24658,28 +24686,28 @@ var op = {

//target is the env is we specify in elxr use command. Default is dev
//Switch to target branch
return any(gitRepos.map((repo) => performCheckout({ repo, branch})))
return any(gitRepos.map((repodef) => { return performCheckout({ repo : repodef.repo, branch}).catch(e=>{ console.log(e); }) } ))
// pull or clone target branch
.then(() => any(gitRepos.map((repo) => performPullAll({repo}))) )
.then(() => any(gitRepos.map((repo) => performPullAll(repo))) )
// switch to source branch
.then( () => {
if(mergesource) return any(gitRepos.map((repo) => performCheckout({ repo, branch: mergesource})))
if(mergesource) return any(gitRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch: mergesource})))
else return Promise.resolve(true) // Dont do anything if there is no source to merge from.
})
//Pull on merge source branch
.then( () => {
if(!mergesource) return Promise.resolve(true)
return any(gitRepos.map((repo) => performPullAll({repo})))
return any(gitRepos.map((repo) => performPullAll(repo)))
})
//Switch to target branch
.then( () => {
if(!mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repo) => performCheckout({ repo, branch})))
return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch})))
})
.then( //Merge source branch to target branch
() => {
if(!mergesource) return Promise.resolve(true)
return any(gitRepos.map((repo) => performMerge({ repo }))).catch(err => { console.error('error in performMerge ' + err); })
return any(gitRepos.map((repo) => performMerge( repo ))).catch(err => { console.error('error in performMerge ' + err); })
})
})
}
@@ -24711,28 +24739,28 @@ var op = {
}
return any(tasks).then(()=>{
return any(elevatedRunasRepos.map((repo) => performCheckout({ repo, branch, requiresElevation : true})))
return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch, requiresElevation : true})))
// pull or clone target branch
.then( () => any(elevatedRunasRepos.map((repo) => performPullAll({repo}))) )
.then( () => any(elevatedRunasRepos.map((repo) => performPullAll(repo))) )
// switch to source branch
.then( () => {
if(mergesource) return any(elevatedRunasRepos.map((repo) => performCheckout({ repo, branch: mergesource, requiresElevation : true})))
if(mergesource) return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch: mergesource, requiresElevation : true})))
else return Promise.resolve(true) // Dont do anything if there is no source to merge from.
})
//Pull on merge source branch
.then( () => {
if(!mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repo) => performPullAll({repo, requiresElevation : true })))
return any(elevatedRunasRepos.map((repodef) => performPullAll({repo : repodef.repo, requiresElevation : true })))
})
//Switch to target branch
.then( () => {
if(!mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repo) => performCheckout({ repo, branch, requiresElevation : true})))
return any(elevatedRunasRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch, requiresElevation : true})))
})
.then( //Merge source branch to target branch
() => {
if(!mergesource) return Promise.resolve(true)
return any(elevatedRunasRepos.map((repo) => performMerge({ repo, requiresElevation : true }))).catch(err => { console.error('error in performMerge ' + err); })
return any(elevatedRunasRepos.map((repodef) => performMerge({ repo : repodef.repo, requiresElevation : true }))).catch(err => { console.error('error in performMerge ' + err); })
})
.then(() => {
fs.writeFileSync('run.done', 'success');
@@ -24863,6 +24891,11 @@ var elxr = {
}
, getpulltask(def){

def = def || {
requiresElevation : true,
reqularRepos : gitRepos,
elevatedRepos : elevatedRunasRepos
};
console.log(`-------------------Processing pull for : ${def.repo} ${def.branch}`);
console.dir(def);

@@ -25159,7 +25192,7 @@ var prerequisites = [
var steps = [
() => {
if (!existsSync(downloadsdir + '/' + this.installer)) {
return nodeShellExec('download.bat', [this.url, downloadsdir + '/' + this.installer])
return nodeShellExec('.run/download.bat', [this.url, downloadsdir + '/' + this.installer])
}
else return Promise.resolve(true)
}
@@ -25270,6 +25303,10 @@ function ensureDirectoryExistence(filePath) {
var mainTasks = [];
function verifyAndInstallPrerequisites() {
fs.writeFileSync(ensureDirectoryExistence(path__default['default'].normalize(downloadsdir + '/readme.txt')), `${getVersion()} Your local downloads for this instance`);
// PB : TODO -- Keep only the last n runs...
ensureDirectoryExistence('.run/download.bat');

// PB : TODO include and build from files... using rollup..
var downloadbatch =
`::**************************************************************************
:Download_ <url> <File>
@@ -25279,8 +25316,89 @@ function verifyAndInstallPrerequisites() {
(New-Object System.Net.WebClient).DownloadFile('%1','%2')
exit /b
::**************************************************************************`;
fs.writeFileSync('download.bat', downloadbatch);
fs.writeFileSync('.run/download.bat', downloadbatch);

var windowselevate =
`
<html><HTA:APPLICATION ID="windowselevate" icon="#"/>
<script language="vbscript">
document.title = "elxr control panel"
self.ResizeTo 200,600
Sub Window_Onload
self.MoveTo (screen.availWidth - (document.body.clientWidth + 40)),10
End Sub

Set objShell = CreateObject("WScript.Shell")
Set objENV = objShell.Environment("Process")
dim NODE_ENV
NODE_ENV = objENV("NODE_ENV")
</script>

<script language="javascript">
//WINDOWSTATE="minimize" SHOWINTASKBAR="no" SYSMENU="no" CAPTION="no"
// https://devblogs.microsoft.com/scripting/how-can-i-pass-command-line-variables-to-an-hta-when-it-starts/
// alert(windowselevate.commandLine)
var args = windowselevate.commandLine.split('"').slice(3);
// alert(args)
var processedArgs = { _ : [] }
var namedArgs = [];
for(var item in args){
if(args[item].charAt(0) === '-'){
namedArgs.push(args[item])
var split = args[item].split('=');
processedArgs[split[0].slice(2)] = split[1] || true;
}
else processedArgs._.push(args[item]);
}
// args = args.forEach(function(item){ })
// alert('processedArgs._ : ' + processedArgs._);
// alert(processedArgs.runas);
// PB : TODO -- Convert all the cli args back to string.
var cargs = (processedArgs.debug ? '--inspect-brk=9228' : '') + ' elxr ' + processedArgs._.join(' ') + ' ' + namedArgs.join(' ');
// alert(cargs)
var shell = new ActiveXObject('shell.application');
// alert('launching node privilged. ' + processedArgs['nodepath'])
// shell.ShellExecute('where', 'node', '', '', 10);
shell.ShellExecute('node', cargs, '', 'runas', 1);
// shell.ShellExecute(processedArgs['nodepath'], cargs, '', 'runas', 1);
var fso = new ActiveXObject('Scripting.FileSystemObject');
window.onload = function() {
document.body.style.backgroundColor = 'black';
document.body.style.fontFamily = 'arial';
var log = document.createElement('div');
log.innerHTML='Please Wait';
function l(msg){ log.innerHTML+= msg; };
log.style.color = 'blue';
log.style.width = '95%';
log.id = 'log';
document.body.appendChild(log);
l('<Br/>Current config : ')
l('<Br/>NODE_ENV = ' + NODE_ENV)
l('<Br/>cmd = ' + processedArgs._[0])
processedArgs._[1] === 'use' ? l('<Br/>using = ' + processedArgs._[2]) : null;
l('<Br/><Br/>')
var timer = function(){
l('.');
if(fso.FileExists("run.done")) close();
else window.setTimeout(timer, 1000);
};
window.setTimeout(timer, 3000);
};
</script>
</html>
`;
fs.writeFileSync('.run/windowselevate.hta', windowselevate);

var downloadtasks = [];
var installtasks = [];
prerequisites.forEach(preq => {
@@ -25419,6 +25537,8 @@ acquireElevationState().then(() => {
// "current_run": { "instanceName": "elixir", "node_env": "production" }
// }

// ,([^\}^\S\r]*?\}) // Regexp to eliminate extra comma at the end of an array or an object...

var elxr_1 = {

};

+ 111
- 23
index.js Datei anzeigen

@@ -402,7 +402,7 @@ var op = {
console.log('result : ' + JSON.stringify(r))
Object.keys(processedArgs).forEach((v) => { v != '_' ? namedArgs.push('--' + v + '=' + processedArgs[v]) : null; })
// PB : TODO -- Convert all the cli args back to string.
var args = [__dirname + '/windowselevate.hta'].concat(processedArgs._).concat(namedArgs.join(' ')); args.push('--runas=self');
var args = [__dirname + '/.run/windowselevate.hta'].concat(processedArgs._).concat(namedArgs.join(' ')); args.push('--runas=self');
args.push('--nodepath=' + r[r.length - 1])
if (!processedArgs.node_env) args.push('--node_env=' + ENV.NODE_ENV)
if (processedArgs.debug) args.push('--debug=true') // Enable to debug elevated..
@@ -695,7 +695,7 @@ var op = {

if (!processedArgs.runas) gitRepos.map((def) => performPull(def.repo, def.branch || 'master'))
if (__isElevated) {
return any(elevatedRunasRepos.map((repo) => performPull(def.repo, def.branch || 'master'))).then(() => {
return any(elevatedRunasRepos.map((def) => performPull(def.repo, def.branch || 'master'))).then(() => {
fs.writeFileSync('run.done', 'success')
}).catch(() => {
fs.writeFileSync('run.done', 'error')
@@ -785,33 +785,33 @@ var op = {
var repotasks = []
var env = Object.assign({}, process.env)
delete env.NODE_ENV
gitRepos.forEach(repo => {
gitRepos.forEach(repodef => {

rmtasks.push(
// () => {
// console.log(`--rm package-lock.json for ${repo}--------------------`)
// console.log(`--rm package-lock.json for ${repodef.repo}--------------------`)
// return nodeShellExec(`"${gitbash}"`, ['-c', '"rm package-lock.json"'], {
nodeShellExec('rm', ['package-lock.json'], {
inherit: true, shell: true
, cwd: instanceroot + '/' + repo
, cwd: instanceroot + '/' + repodef.repo
, env: process.env
, title: `rm 'package-lock.json' for ${repo}`
, title: `rm 'package-lock.json' for ${repodef.repo}`
})
.then(()=>{
console.log(`--rm package-lock.json for ${repo}--------------------`)
console.log(`--rm package-lock.json for ${repodef.repo}--------------------`)
}).catch((e) => { console.error(e) })
// }
)

if (npmbuildrepos.indexOf(repo) < 0) {
if (npmbuildrepos.indexOf(repodef.repo) < 0) {
repotasks.push(
() => {
console.log(`--npm i for ${repo}--------------------`)
console.log(`--npm i for ${repodef.repo}--------------------`)
var p = nodeShellExec('npm', ['i', '--force'], {
inherit: true, shell: true
, cwd: instanceroot + '/' + repo
, cwd: instanceroot + '/' + repodef.repo
, env
, title: `npm i for ${repo}`
, title: `npm i for ${repodef.repo}`
}).then(Tasq.then).catch(Tasq.catch)
return p;
})
@@ -838,17 +838,17 @@ var op = {
// }).then(Tasq.then).catch(Tasq.catch)
// })

var bowerRepos = ['client']
bowerRepos.forEach(repo => {
var bowerRepos = [{ repo : 'client'}]
bowerRepos.forEach(repodef => {
repotasks.push(() => {
console.log(instanceroot + '/' + repo + '/node_modules/bower/bin/bower')
console.log(instanceroot + '/' + repodef.repo + '/node_modules/bower/bin/bower')
// var p = nodeShellExec('node_modules/bower/bin/bower', ['install'], {
var p = nodeShellExec(`"${gitbash}"`, ['-c', '"node_modules/bower/bin/bower i"'], {

inherit: true, shell: true
, cwd: instanceroot + '/' + repo
, cwd: instanceroot + '/' + repodef.repo
, env: process.env
, title: `bower i for ${repo}`
, title: `bower i for ${repodef.repo}`
}).then(Tasq.then).catch(Tasq.catch)
return p;
})
@@ -979,7 +979,8 @@ var op = {
*/
var runconfig = { NODE_ENV: repomanifest.node_env }
try { runconfig = Object.assign(runconfig, require(instanceroot + '/run.js')) } catch (e) { }
if ((!processedArgs.runas || processedArgs.runas !== 'self' && !processedArgs.force) &&
// We no longer need to check ruans.. ??? if we were initiated from self invoked privileged shell ?
if (( /*processedArgs.runas && processedArgs.runas !== 'self' &&*/ !processedArgs.force) &&
runconfig.NODE_ENV && runconfig.NODE_ENV === (repomanifest.node_env || runconfig.NODE_ENV) &&
repomanifest.instanceName && runconfig.use === repomanifest.instanceName) {

@@ -1033,9 +1034,9 @@ var op = {

// cant use git checkout -b it fails when branch already exists.
var performCheckout = (def) => {
if (excludeCheckouts[repo]) return Promise.resolve({ 'skipped': true })
if (excludeCheckouts[def.repo]) return Promise.resolve({ 'skipped': true })
return performPullOrCloneForBranch(def)().then(()=>{
return performPullOrCloneForBranch(def).then(()=>{
nodeShellExec('git', ['checkout', def.branch || checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], {
// return nodeShellExec('git', ['switch', '-m', '-C', checkoutMap[runconfig.NODE_ENV] || runconfig.NODE_ENV], {
// inherit : true, shell: true,
@@ -1109,7 +1110,7 @@ var op = {

//target is the env is we specify in elxr use command. Default is dev
//Switch to target branch
return any(gitRepos.map((repodef) => performCheckout({ repo : repodef.repo, branch})))
return any(gitRepos.map((repodef) => { return performCheckout({ repo : repodef.repo, branch}).catch(e=>{ console.log(e); }) } ))
// pull or clone target branch
.then(() => any(gitRepos.map((repo) => performPullAll(repo))) )
// switch to source branch
@@ -1651,7 +1652,7 @@ var prerequisites = [
var steps = [
() => {
if (!existsSync(downloadsdir + '/' + this.installer)) {
return nodeShellExec('download.bat', [this.url, downloadsdir + '/' + this.installer])
return nodeShellExec('.run/download.bat', [this.url, downloadsdir + '/' + this.installer])
}
else return Promise.resolve(true)
}
@@ -1762,6 +1763,10 @@ function ensureDirectoryExistence(filePath) {
var mainTasks = [];
function verifyAndInstallPrerequisites() {
fs.writeFileSync(ensureDirectoryExistence(path.normalize(downloadsdir + '/readme.txt')), `${getVersion()} Your local downloads for this instance`)
// PB : TODO -- Keep only the last n runs...
ensureDirectoryExistence('.run/download.bat')

// PB : TODO include and build from files... using rollup..
var downloadbatch =
`::**************************************************************************
:Download_ <url> <File>
@@ -1771,8 +1776,89 @@ function verifyAndInstallPrerequisites() {
(New-Object System.Net.WebClient).DownloadFile('%1','%2')
exit /b
::**************************************************************************`
fs.writeFileSync('download.bat', downloadbatch)
fs.writeFileSync('.run/download.bat', downloadbatch)

var windowselevate =
`
<html><HTA:APPLICATION ID="windowselevate" icon="#"/>
<script language="vbscript">
document.title = "elxr control panel"
self.ResizeTo 200,600
Sub Window_Onload
self.MoveTo (screen.availWidth - (document.body.clientWidth + 40)),10
End Sub

Set objShell = CreateObject("WScript.Shell")
Set objENV = objShell.Environment("Process")
dim NODE_ENV
NODE_ENV = objENV("NODE_ENV")
</script>

<script language="javascript">
//WINDOWSTATE="minimize" SHOWINTASKBAR="no" SYSMENU="no" CAPTION="no"
// https://devblogs.microsoft.com/scripting/how-can-i-pass-command-line-variables-to-an-hta-when-it-starts/
// alert(windowselevate.commandLine)
var args = windowselevate.commandLine.split('"').slice(3);
// alert(args)
var processedArgs = { _ : [] }
var namedArgs = [];
for(var item in args){
if(args[item].charAt(0) === '-'){
namedArgs.push(args[item])
var split = args[item].split('=');
processedArgs[split[0].slice(2)] = split[1] || true;
}
else processedArgs._.push(args[item]);
}
// args = args.forEach(function(item){ })
// alert('processedArgs._ : ' + processedArgs._);
// alert(processedArgs.runas);
// PB : TODO -- Convert all the cli args back to string.
var cargs = (processedArgs.debug ? '--inspect-brk=9228' : '') + ' elxr ' + processedArgs._.join(' ') + ' ' + namedArgs.join(' ');
// alert(cargs)
var shell = new ActiveXObject('shell.application');
// alert('launching node privilged. ' + processedArgs['nodepath'])
// shell.ShellExecute('where', 'node', '', '', 10);
shell.ShellExecute('node', cargs, '', 'runas', 1);
// shell.ShellExecute(processedArgs['nodepath'], cargs, '', 'runas', 1);
var fso = new ActiveXObject('Scripting.FileSystemObject');
window.onload = function() {
document.body.style.backgroundColor = 'black';
document.body.style.fontFamily = 'arial';
var log = document.createElement('div');
log.innerHTML='Please Wait';
function l(msg){ log.innerHTML+= msg; };
log.style.color = 'blue';
log.style.width = '95%';
log.id = 'log';
document.body.appendChild(log);
l('<Br/>Current config : ')
l('<Br/>NODE_ENV = ' + NODE_ENV)
l('<Br/>cmd = ' + processedArgs._[0])
processedArgs._[1] === 'use' ? l('<Br/>using = ' + processedArgs._[2]) : null;
l('<Br/><Br/>')
var timer = function(){
l('.');
if(fso.FileExists("run.done")) close();
else window.setTimeout(timer, 1000);
};
window.setTimeout(timer, 3000);
};
</script>
</html>
`
fs.writeFileSync('.run/windowselevate.hta', windowselevate)

var downloadtasks = [];
var installtasks = [];
prerequisites.forEach(preq => {
@@ -1938,4 +2024,6 @@ function downloadandinstall(items) {
// }
// },
// "current_run": { "instanceName": "elixir", "node_env": "production" }
// }
// }

// ,([^\}^\S\r]*?\}) // Regexp to eliminate extra comma at the end of an array or an object...

Laden…
Abbrechen
Speichern