add option for npm access level

This commit is contained in:
2018-04-04 22:25:13 +02:00
parent c8c17e6cba
commit 0ab1e1ab7c
70 changed files with 1977 additions and 1846 deletions

View File

@@ -1,47 +1,47 @@
import * as plugins from './mod.plugins'
import { bash } from '../npmci.bash'
import * as plugins from './mod.plugins';
import { bash } from '../npmci.bash';
export interface IDockerRegistryConstructorOptions {
registryUrl: string,
username: string,
password: string
registryUrl: string;
username: string;
password: string;
}
export class DockerRegistry {
registryUrl: string
username: string
password: string
constructor (optionsArg: IDockerRegistryConstructorOptions) {
this.registryUrl = optionsArg.registryUrl
this.username = optionsArg.username
this.password = optionsArg.password
plugins.beautylog.info(`created DockerRegistry for ${this.registryUrl}`)
registryUrl: string;
username: string;
password: string;
constructor(optionsArg: IDockerRegistryConstructorOptions) {
this.registryUrl = optionsArg.registryUrl;
this.username = optionsArg.username;
this.password = optionsArg.password;
plugins.beautylog.info(`created DockerRegistry for ${this.registryUrl}`);
}
static fromEnvString (envString: string): DockerRegistry {
let dockerRegexResultArray = envString.split('|')
static fromEnvString(envString: string): DockerRegistry {
let dockerRegexResultArray = envString.split('|');
if (dockerRegexResultArray.length !== 3) {
plugins.beautylog.error('malformed docker env var...')
process.exit(1)
return
plugins.beautylog.error('malformed docker env var...');
process.exit(1);
return;
}
let registryUrl = dockerRegexResultArray[0]
let username = dockerRegexResultArray[1]
let password = dockerRegexResultArray[2]
let registryUrl = dockerRegexResultArray[0];
let username = dockerRegexResultArray[1];
let password = dockerRegexResultArray[2];
return new DockerRegistry({
registryUrl: registryUrl,
username: username,
password: password
})
});
}
async login () {
async login() {
if (this.registryUrl === 'docker.io') {
await bash(`docker login -u ${this.username} -p ${this.password}`)
plugins.beautylog.info('Logged in to standard docker hub')
await bash(`docker login -u ${this.username} -p ${this.password}`);
plugins.beautylog.info('Logged in to standard docker hub');
} else {
await bash(`docker login -u ${this.username} -p ${this.password} ${this.registryUrl}`)
await bash(`docker login -u ${this.username} -p ${this.password} ${this.registryUrl}`);
}
plugins.beautylog.ok(`docker authenticated for ${this.registryUrl}!`)
plugins.beautylog.ok(`docker authenticated for ${this.registryUrl}!`);
}
}