fix(core): update

This commit is contained in:
2021-05-14 18:11:12 +00:00
parent efdf789575
commit f850c79b6c
27 changed files with 9928 additions and 1536 deletions

View File

@ -13,7 +13,9 @@ export class CloudlyConnector {
this.npmciRef = npmciRefArg;
}
public async announceDockerContainer(optionsArg: plugins.servezoneInterfaces.version.IVersionData) {
public async announceDockerContainer(
optionsArg: plugins.servezoneInterfaces.version.IVersionData
) {
const cloudlyUrl = this.npmciRef.npmciConfig.getConfig().urlCloudly;
if (!cloudlyUrl) {
logger.log(
@ -23,9 +25,10 @@ export class CloudlyConnector {
return;
}
const typedrequest = new plugins.typedrequest.TypedRequest<
plugins.servezoneInterfaces.request.version.IRequest_Any_Cloudly_VersionManager_Update
>(`https://${cloudlyUrl}/versionmanager`, 'update');
const typedrequest = new plugins.typedrequest.TypedRequest<plugins.servezoneInterfaces.request.version.IRequest_Any_Cloudly_VersionManager_Update>(
`https://${cloudlyUrl}/versionmanager`,
'update'
);
const response = await typedrequest.fire(optionsArg);
}

View File

@ -5,6 +5,6 @@ export const npmciInstance = new Npmci();
export { Dockerfile, Npmci };
if (process.env.CLI_CALL) {
export const runCli = async () => {
npmciInstance.start();
}
};

View File

@ -21,7 +21,7 @@ export class NpmciDockerManager {
* handle cli input
* @param argvArg
*/
public handleCli = async argvArg => {
public handleCli = async (argvArg) => {
if (argvArg._.length >= 2) {
const action: string = argvArg._[1];
switch (action) {
@ -85,7 +85,7 @@ export class NpmciDockerManager {
new DockerRegistry({
registryUrl: 'registry.gitlab.com',
username: 'gitlab-ci-token',
password: process.env.CI_BUILD_TOKEN
password: process.env.CI_BUILD_TOKEN,
})
);
@ -93,7 +93,7 @@ export class NpmciDockerManager {
await plugins.smartparam.forEachMinimatch(
process.env,
'NPMCI_LOGIN_DOCKER*',
async envString => {
async (envString) => {
this.npmciRegistryStorage.addRegistry(DockerRegistry.fromEnvString(envString));
}
);
@ -104,7 +104,7 @@ export class NpmciDockerManager {
* pushes an image towards a registry
* @param argvArg
*/
public push = async argvArg => {
public push = async (argvArg) => {
await this.prepare();
let dockerRegistryUrls: string[] = [];
@ -151,7 +151,7 @@ export class NpmciDockerManager {
/**
* pulls an image
*/
public pull = async argvArg => {
public pull = async (argvArg) => {
await this.prepare();
const registryUrlArg = argvArg._[2];
let suffix = null;

View File

@ -31,7 +31,7 @@ export class Dockerfile {
for (const dockerfilePath of fileTree) {
const myDockerfile = new Dockerfile(npmciDockerManagerRefArg, {
filePath: dockerfilePath,
read: true
read: true,
});
readDockerfilesArray.push(myDockerfile);
}
@ -51,7 +51,7 @@ export class Dockerfile {
const cleanTagsOriginal = Dockerfile.cleanTagsArrayFunction(sortableArrayArg, sortedArray);
let sorterFunctionCounter: number = 0;
const sorterFunction = () => {
sortableArrayArg.forEach(dockerfileArg => {
sortableArrayArg.forEach((dockerfileArg) => {
const cleanTags = Dockerfile.cleanTagsArrayFunction(sortableArrayArg, sortedArray);
if (
cleanTags.indexOf(dockerfileArg.baseImage) === -1 &&
@ -83,7 +83,7 @@ export class Dockerfile {
* maps local Dockerfiles dependencies to the correspoding Dockerfile class instances
*/
public static async mapDockerfiles(sortedDockerfileArray: Dockerfile[]): Promise<Dockerfile[]> {
sortedDockerfileArray.forEach(dockerfileArg => {
sortedDockerfileArray.forEach((dockerfileArg) => {
if (dockerfileArg.localBaseImageDependent) {
sortedDockerfileArray.forEach((dockfile2: Dockerfile) => {
if (dockfile2.cleanTag === dockerfileArg.baseImage) {
@ -198,7 +198,7 @@ export class Dockerfile {
trackingArrayArg: Dockerfile[]
): string[] {
const cleanTagsArray: string[] = [];
dockerfileArrayArg.forEach(dockerfileArg => {
dockerfileArrayArg.forEach((dockerfileArg) => {
if (trackingArrayArg.indexOf(dockerfileArg) === -1) {
cleanTagsArray.push(dockerfileArg.cleanTag);
}
@ -269,14 +269,14 @@ export class Dockerfile {
);
await bash(`docker tag ${this.buildTag} ${this.pushTag}`);
await bash(`docker push ${this.pushTag}`);
const imageDigest = (await bash(
`docker inspect --format="{{index .RepoDigests 0}}" ${this.pushTag}`
)).split('@')[1];
const imageDigest = (
await bash(`docker inspect --format="{{index .RepoDigests 0}}" ${this.pushTag}`)
).split('@')[1];
console.log(`The image ${this.pushTag} has digest ${imageDigest}`);
await this.npmciDockerManagerRef.npmciRef.cloudlyConnector.announceDockerContainer({
dockerImageUrl: this.pushTag,
dockerImageVersion: this.npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().projectInfo
.npm.version
.npm.version,
});
}

View File

@ -32,7 +32,7 @@ export class DockerRegistry {
return new DockerRegistry({
registryUrl: registryUrl,
username: username,
password: password
password: password,
});
}

View File

@ -1,11 +1,11 @@
import { logger } from '../npmci.logging';
import * as plugins from './mod.plugins';
import { Objectmap } from '@pushrocks/lik';
import { ObjectMap } from '@pushrocks/lik';
import { DockerRegistry } from './mod.classes.dockerregistry';
export class RegistryStorage {
objectMap = new Objectmap<DockerRegistry>();
objectMap = new ObjectMap<DockerRegistry>();
constructor() {
// Nothing here
}
@ -15,13 +15,13 @@ export class RegistryStorage {
}
getRegistryByUrl(registryUrlArg: string) {
return this.objectMap.find(registryArg => {
return this.objectMap.find((registryArg) => {
return registryArg.registryUrl === registryUrlArg;
});
}
async loginAll() {
await this.objectMap.forEach(async registryArg => {
await this.objectMap.forEach(async (registryArg) => {
await registryArg.login();
});
logger.log('success', 'logged in successfully into all available DockerRegistries!');

View File

@ -14,7 +14,7 @@ export class NpmciGitManager {
* handle cli input
* @param argvArg
*/
public handleCli = async argvArg => {
public handleCli = async (argvArg) => {
if (argvArg._.length >= 2) {
const action: string = argvArg._[1];
switch (action) {

View File

@ -24,8 +24,8 @@ export class NpmciNpmManager {
await this.install();
break;
case 'build':
await this.build();
break;
await this.build();
break;
case 'prepare':
await this.prepare();
break;
@ -54,7 +54,7 @@ export class NpmciNpmManager {
public async prepare() {
const config = this.npmciRef.npmciConfig.getConfig();
let npmrcFileString: string = '';
await plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_TOKEN_NPM*', npmEnvArg => {
await plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_TOKEN_NPM*', (npmEnvArg) => {
const npmRegistryUrl = npmEnvArg.split('|')[0];
const npmToken = npmEnvArg.split('|')[1];
npmrcFileString += `//${npmRegistryUrl}/:_authToken="${plugins.smartstring.base64.decode(
@ -91,7 +91,7 @@ export class NpmciNpmManager {
let publishVerdaccioAsWell = false;
const config = this.npmciRef.npmciConfig.getConfig();
const availableRegistries: string[] = [];
await plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_TOKEN_NPM*', npmEnvArg => {
await plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_TOKEN_NPM*', (npmEnvArg) => {
availableRegistries.push(npmEnvArg.split('|')[0]);
});
@ -116,7 +116,7 @@ export class NpmciNpmManager {
// publishEverywhere
if (publishVerdaccioAsWell) {
const verdaccioRegistry = availableRegistries.find(registryString =>
const verdaccioRegistry = availableRegistries.find((registryString) =>
registryString.startsWith('verdaccio')
);
if (verdaccioRegistry) {

View File

@ -2,7 +2,7 @@ import { logger } from '../npmci.logging';
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) {
const action: string = argvArg._[1];
switch (action) {

View File

@ -9,7 +9,7 @@ export let trigger = async () => {
await plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_TRIGGER_*', evaluateTrigger);
};
const evaluateTrigger = async triggerEnvVarArg => {
const evaluateTrigger = async (triggerEnvVarArg) => {
const triggerRegexResultArray = triggerValueRegex.exec(triggerEnvVarArg);
const regexDomain = triggerRegexResultArray[1];
const regexProjectId = triggerRegexResultArray[2];
@ -30,13 +30,13 @@ const evaluateTrigger = async triggerEnvVarArg => {
{
name: 'token',
payload: regexProjectTriggerToken,
type: 'string'
type: 'string',
},
{
name: 'ref',
payload: regexRefName,
type: 'string'
}
type: 'string',
},
]
);
};

View File

@ -13,7 +13,7 @@ export let nvmAvailable = smartpromise.defer<boolean>();
*/
const npmciSmartshell = new plugins.smartshell.Smartshell({
executor: 'bash',
sourceFilePaths: []
sourceFilePaths: [],
});
/**
@ -84,7 +84,7 @@ export let bash = async (commandArg: string, retryArg: number = 2): Promise<stri
logger.log('info', 'ShellExec would be: ' + commandArg);
execResult = {
exitCode: 0,
stdout: 'testOutput'
stdout: 'testOutput',
};
}
return execResult.stdout;

View File

@ -32,7 +32,7 @@ export class Npmci {
this.analytics = new plugins.smartanalytics.Analytics({
apiEndPoint: 'https://pubapi.lossless.one/analytics',
projectId: 'gitzone',
appName: 'npmci'
appName: 'npmci',
});
this.cloudlyConnector = new CloudlyConnector(this);
this.npmciEnv = new NpmciEnv(this);

View File

@ -14,11 +14,11 @@ export class NpmciCli {
// clean
this.smartcli.addCommand('clean').subscribe(
async argv => {
async (argv) => {
const modClean = await import('./mod_clean/index');
await modClean.clean();
},
err => {
(err) => {
console.log(err);
process.exit(1);
}
@ -26,11 +26,11 @@ export class NpmciCli {
// command
this.smartcli.addCommand('command').subscribe(
async argv => {
async (argv) => {
const modCommand = await import('./mod_command/index');
await modCommand.command();
},
err => {
(err) => {
console.log(err);
process.exit(1);
}
@ -38,10 +38,10 @@ export class NpmciCli {
// command
this.smartcli.addCommand('git').subscribe(
async argvArg => {
async (argvArg) => {
await this.npmciRef.gitManager.handleCli(argvArg);
},
err => {
(err) => {
console.log(err);
process.exit(1);
}
@ -49,10 +49,10 @@ export class NpmciCli {
// build
this.smartcli.addCommand('docker').subscribe(
async argvArg => {
async (argvArg) => {
await this.npmciRef.dockerManager.handleCli(argvArg);
},
err => {
(err) => {
console.log(err);
process.exit(1);
}
@ -60,10 +60,10 @@ export class NpmciCli {
// node
this.smartcli.addCommand('node').subscribe(
async argvArg => {
async (argvArg) => {
await this.npmciRef.nodejsManager.handleCli(argvArg);
},
err => {
(err) => {
console.log(err);
process.exit(1);
}
@ -71,21 +71,21 @@ export class NpmciCli {
// npm
this.smartcli.addCommand('npm').subscribe(
async argvArg => {
async (argvArg) => {
await this.npmciRef.npmManager.handleCli(argvArg);
},
err => {
(err) => {
console.log(err);
}
);
// trigger
this.smartcli.addCommand('ssh').subscribe(
async argvArg => {
async (argvArg) => {
const modSsh = await import('./mod_ssh/index');
await modSsh.handleCli(argvArg);
},
err => {
(err) => {
console.log(err);
process.exit(1);
}
@ -93,11 +93,11 @@ export class NpmciCli {
// trigger
this.smartcli.addCommand('trigger').subscribe(
async argv => {
async (argv) => {
const modTrigger = await import('./mod_trigger/index');
await modTrigger.trigger();
},
err => {
(err) => {
console.log(err);
process.exit(1);
}

View File

@ -47,8 +47,7 @@ export class NpmciConfig {
this.npmciQenv = new plugins.qenv.Qenv(
paths.NpmciProjectDir,
paths.NpmciProjectNogitDir,
false,
logger
false
);
this.configObject = {
@ -59,7 +58,7 @@ export class NpmciConfig {
npmAccessLevel: 'private',
npmRegistryUrl: 'registry.npmjs.org',
dockerBuildargEnvMap: {},
urlCloudly: this.npmciQenv.getEnvVarOnDemand('NPMCI_URL_CLOUDLY')
urlCloudly: this.npmciQenv.getEnvVarOnDemand('NPMCI_URL_CLOUDLY'),
};
}

View File

@ -7,8 +7,8 @@ export const logger = new plugins.smartlog.Smartlog({
containerName: 'Some ContainerName',
environment: 'test',
runtime: 'node',
zone: 'Some Zone'
}
zone: 'Some Zone',
},
});
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());

View File

@ -47,7 +47,7 @@ export {
smartshell,
smartsocket,
smartssh,
smartstring
smartstring,
};
import * as through2 from 'through2';