add option for npm access level
This commit is contained in:
@ -1,63 +1,63 @@
|
||||
import * as plugins from './mod.plugins'
|
||||
let sshInstance: plugins.smartssh.SshInstance
|
||||
import * as plugins from './mod.plugins';
|
||||
let sshInstance: plugins.smartssh.SshInstance;
|
||||
|
||||
export let handleCli = async (argvArg) => {
|
||||
export let handleCli = async argvArg => {
|
||||
if (argvArg._.length >= 2) {
|
||||
let action: string = argvArg._[1]
|
||||
let action: string = argvArg._[1];
|
||||
switch (action) {
|
||||
case 'prepare':
|
||||
await prepare()
|
||||
break
|
||||
await prepare();
|
||||
break;
|
||||
default:
|
||||
plugins.beautylog.error(`action >>${action}<< not supported`)
|
||||
process.exit(1)
|
||||
plugins.beautylog.error(`action >>${action}<< not supported`);
|
||||
process.exit(1);
|
||||
}
|
||||
} else {
|
||||
plugins.beautylog.error(`>>npmci ssh ...<< please specify an action!`)
|
||||
process.exit(1)
|
||||
plugins.beautylog.error(`>>npmci ssh ...<< please specify an action!`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* checks if not undefined
|
||||
*/
|
||||
let notUndefined = (stringArg: string) => {
|
||||
return (stringArg && stringArg !== 'undefined' && stringArg !== '##')
|
||||
}
|
||||
return stringArg && stringArg !== 'undefined' && stringArg !== '##';
|
||||
};
|
||||
|
||||
/**
|
||||
* checks for ENV vars in form of NPMCI_SSHKEY_* and deploys any found ones
|
||||
*/
|
||||
export let prepare = async () => {
|
||||
sshInstance = new plugins.smartssh.SshInstance() // init ssh instance
|
||||
plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_SSHKEY_*', evaluateSshEnv)
|
||||
sshInstance = new plugins.smartssh.SshInstance(); // init ssh instance
|
||||
plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_SSHKEY_*', evaluateSshEnv);
|
||||
if (!process.env.NPMTS_TEST) {
|
||||
sshInstance.writeToDisk()
|
||||
sshInstance.writeToDisk();
|
||||
} else {
|
||||
plugins.beautylog.log('In test mode, so not storing SSH keys to disk!')
|
||||
plugins.beautylog.log('In test mode, so not storing SSH keys to disk!');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* gets called for each found SSH ENV Var and deploys it
|
||||
*/
|
||||
let evaluateSshEnv = async (sshkeyEnvVarArg: string) => {
|
||||
let sshEnvArray = sshkeyEnvVarArg.split('|')
|
||||
let sshKey = new plugins.smartssh.SshKey()
|
||||
plugins.beautylog.info('Found SSH identity for ' + sshEnvArray[1])
|
||||
let sshEnvArray = sshkeyEnvVarArg.split('|');
|
||||
let sshKey = new plugins.smartssh.SshKey();
|
||||
plugins.beautylog.info('Found SSH identity for ' + sshEnvArray[1]);
|
||||
if (notUndefined(sshEnvArray[0])) {
|
||||
plugins.beautylog.log('---> host defined!')
|
||||
sshKey.host = sshEnvArray[0]
|
||||
plugins.beautylog.log('---> host defined!');
|
||||
sshKey.host = sshEnvArray[0];
|
||||
}
|
||||
if (notUndefined(sshEnvArray[1])) {
|
||||
plugins.beautylog.log('---> privKey defined!')
|
||||
sshKey.privKeyBase64 = sshEnvArray[1]
|
||||
plugins.beautylog.log('---> privKey defined!');
|
||||
sshKey.privKeyBase64 = sshEnvArray[1];
|
||||
}
|
||||
if (notUndefined(sshEnvArray[2])) {
|
||||
plugins.beautylog.log('---> pubKey defined!')
|
||||
sshKey.pubKeyBase64 = sshEnvArray[2]
|
||||
plugins.beautylog.log('---> pubKey defined!');
|
||||
sshKey.pubKeyBase64 = sshEnvArray[2];
|
||||
}
|
||||
|
||||
sshInstance.addKey(sshKey)
|
||||
return
|
||||
}
|
||||
sshInstance.addKey(sshKey);
|
||||
return;
|
||||
};
|
||||
|
@ -1 +1 @@
|
||||
export * from '../npmci.plugins'
|
||||
export * from '../npmci.plugins';
|
||||
|
Reference in New Issue
Block a user