From 858d97cb5ce2bb60ebadb5ba4ba84b410af99365 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sun, 7 Nov 2021 04:20:14 +0100 Subject: [PATCH] fix(core): update --- .gitlab-ci.yml | 4 ++ .snyk | 4 -- .vscode/launch.json | 24 +------ package-lock.json | 71 ++++++++------------- package.json | 5 +- readme.md | 1 - ts/connector.cloudly/cloudlyconnector.ts | 15 +++-- ts/manager.docker/index.ts | 4 +- ts/manager.docker/mod.classes.dockerfile.ts | 13 ++-- ts/manager.npm/index.ts | 34 ++++++---- ts/mod_trigger/index.ts | 3 +- ts/npmci.plugins.ts | 10 ++- 12 files changed, 88 insertions(+), 100 deletions(-) delete mode 100644 .snyk diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9a4467e..a70f7eb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,6 +12,9 @@ stages: - release - metadata +before_script: + - npm install -g @shipzone/npmci + # ==================== # security stage # ==================== @@ -36,6 +39,7 @@ auditProductionDependencies: - npmci command npm audit --audit-level=high --only=prod --production tags: - docker + allow_failure: true auditDevDependencies: image: registry.gitlab.com/hosttoday/ht-docker-node:npmci diff --git a/.snyk b/.snyk deleted file mode 100644 index 88ba614..0000000 --- a/.snyk +++ /dev/null @@ -1,4 +0,0 @@ -# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. -version: v1.13.1 -ignore: {} -patch: {} diff --git a/.vscode/launch.json b/.vscode/launch.json index 112db52..26e9f92 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,28 +2,10 @@ "version": "0.2.0", "configurations": [ { - "name": "current file", - "type": "node", + "command": "npm test", + "name": "Run npm test", "request": "launch", - "args": [ - "${relativeFile}" - ], - "runtimeArgs": ["-r", "@gitzone/tsrun"], - "cwd": "${workspaceRoot}", - "protocol": "inspector", - "internalConsoleOptions": "openOnSessionStart" - }, - { - "name": "test.ts", - "type": "node", - "request": "launch", - "args": [ - "test/test.ts" - ], - "runtimeArgs": ["-r", "@gitzone/tsrun"], - "cwd": "${workspaceRoot}", - "protocol": "inspector", - "internalConsoleOptions": "openOnSessionStart" + "type": "node-terminal" } ] } diff --git a/package-lock.json b/package-lock.json index e0e80c5..f5d2e6b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,8 @@ "@pushrocks/smartsocket": "^1.2.8", "@pushrocks/smartssh": "^1.2.3", "@pushrocks/smartstring": "^3.0.24", - "@servezone/servezone-interfaces": "^2.0.51", + "@servezone/interfaces": "^1.0.3", + "@tsclass/tsclass": "^3.0.36", "@types/through2": "^2.0.36", "through2": "^4.0.2" }, @@ -40,7 +41,7 @@ "@gitzone/tsrun": "^1.2.18", "@gitzone/tstest": "^1.0.59", "@pushrocks/tapbundle": "^3.2.14", - "@types/node": "^16.11.1", + "@types/node": "^16.11.6", "tslint": "^6.1.3", "tslint-config-prettier": "^1.18.0" } @@ -3219,23 +3220,14 @@ "dev": true, "license": "MIT" }, - "node_modules/@servezone/servezone-interfaces": { - "version": "2.0.51", - "resolved": "https://verdaccio.lossless.one/@servezone%2fservezone-interfaces/-/servezone-interfaces-2.0.51.tgz", - "integrity": "sha512-IvHhxUAlP1PAOJK+XyAj7CrJ0kByPuOsvA/3s7MUgnbFygXn4ci/FNhFlu0BNK5PoAmzmpAMQU0EdX2HQPUkTw==", - "deprecated": "@servezone/servezone-interfaces has been deprecated in favour of @servezone/interfaces - please upgrade asap!!!", + "node_modules/@servezone/interfaces": { + "version": "1.0.3", + "resolved": "https://verdaccio.lossless.one/@servezone%2finterfaces/-/interfaces-1.0.3.tgz", + "integrity": "sha512-DLfLQZGUXRRZsxPXP5rtI8PRWLDV+5CZMM/ri38V6q8eHTfIhjut6kiSDbahuLS75Y9ApjG2qLUeVZFdvgiFPg==", "license": "MIT", "dependencies": { - "@tsclass/tsclass": "^2.0.6" - } - }, - "node_modules/@servezone/servezone-interfaces/node_modules/@tsclass/tsclass": { - "version": "2.0.13", - "resolved": "https://verdaccio.lossless.one/@tsclass%2ftsclass/-/tsclass-2.0.13.tgz", - "integrity": "sha512-ZhN3vLAahP4DOayACh/bskG4SpeqNpR4oH9776hZvz6GoFj7KQinzf03gzC5o2o6tnmOusQ1FYu1NGYmy6Rvdg==", - "license": "MIT", - "dependencies": { - "@pushrocks/tapbundle": "^3.0.13" + "@apiglobal/typedrequest-interfaces": "^1.0.15", + "@tsclass/tsclass": "^3.0.34" } }, "node_modules/@sindresorhus/is": { @@ -3268,9 +3260,9 @@ } }, "node_modules/@tsclass/tsclass": { - "version": "3.0.34", - "resolved": "https://verdaccio.lossless.one/@tsclass%2ftsclass/-/tsclass-3.0.34.tgz", - "integrity": "sha512-aWJWOCRDwepkVIaCmEVUPE62zBHN+XdBwZKS912qYmpKk3LAG4f0rr9oVPIv2kF0y4jhm31GYTP947Oht5Fdng==", + "version": "3.0.36", + "resolved": "https://verdaccio.lossless.one/@tsclass%2ftsclass/-/tsclass-3.0.36.tgz", + "integrity": "sha512-F2kZfnBsqh53ZicMKB7GHrAZYZ1LzOZoGi8EVs4z5Hwi3qRO+3yOteL0F2NP/yvPLd8fMbZEjZgDYdi29GzXbg==", "license": "MIT", "dependencies": { "@pushrocks/tapbundle": "^3.2.9", @@ -3554,9 +3546,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "16.11.1", - "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-16.11.1.tgz", - "integrity": "sha512-PYGcJHL9mwl1Ek3PLiYgyEKtwTMmkMw4vbiyz/ps3pfdRYLVv+SN7qHVAImrjdAXxgluDEw6Ph4lyv+m9UpRmA==", + "version": "16.11.6", + "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-16.11.6.tgz", + "integrity": "sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==", "license": "MIT" }, "node_modules/@types/parcel-bundler": { @@ -18200,22 +18192,13 @@ } } }, - "@servezone/servezone-interfaces": { - "version": "2.0.51", - "resolved": "https://verdaccio.lossless.one/@servezone%2fservezone-interfaces/-/servezone-interfaces-2.0.51.tgz", - "integrity": "sha512-IvHhxUAlP1PAOJK+XyAj7CrJ0kByPuOsvA/3s7MUgnbFygXn4ci/FNhFlu0BNK5PoAmzmpAMQU0EdX2HQPUkTw==", + "@servezone/interfaces": { + "version": "1.0.3", + "resolved": "https://verdaccio.lossless.one/@servezone%2finterfaces/-/interfaces-1.0.3.tgz", + "integrity": "sha512-DLfLQZGUXRRZsxPXP5rtI8PRWLDV+5CZMM/ri38V6q8eHTfIhjut6kiSDbahuLS75Y9ApjG2qLUeVZFdvgiFPg==", "requires": { - "@tsclass/tsclass": "^2.0.6" - }, - "dependencies": { - "@tsclass/tsclass": { - "version": "2.0.13", - "resolved": "https://verdaccio.lossless.one/@tsclass%2ftsclass/-/tsclass-2.0.13.tgz", - "integrity": "sha512-ZhN3vLAahP4DOayACh/bskG4SpeqNpR4oH9776hZvz6GoFj7KQinzf03gzC5o2o6tnmOusQ1FYu1NGYmy6Rvdg==", - "requires": { - "@pushrocks/tapbundle": "^3.0.13" - } - } + "@apiglobal/typedrequest-interfaces": "^1.0.15", + "@tsclass/tsclass": "^3.0.34" } }, "@sindresorhus/is": { @@ -18239,9 +18222,9 @@ } }, "@tsclass/tsclass": { - "version": "3.0.34", - "resolved": "https://verdaccio.lossless.one/@tsclass%2ftsclass/-/tsclass-3.0.34.tgz", - "integrity": "sha512-aWJWOCRDwepkVIaCmEVUPE62zBHN+XdBwZKS912qYmpKk3LAG4f0rr9oVPIv2kF0y4jhm31GYTP947Oht5Fdng==", + "version": "3.0.36", + "resolved": "https://verdaccio.lossless.one/@tsclass%2ftsclass/-/tsclass-3.0.36.tgz", + "integrity": "sha512-F2kZfnBsqh53ZicMKB7GHrAZYZ1LzOZoGi8EVs4z5Hwi3qRO+3yOteL0F2NP/yvPLd8fMbZEjZgDYdi29GzXbg==", "requires": { "@pushrocks/tapbundle": "^3.2.9", "type-fest": "^0.16.0" @@ -18487,9 +18470,9 @@ "integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==" }, "@types/node": { - "version": "16.11.1", - "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-16.11.1.tgz", - "integrity": "sha512-PYGcJHL9mwl1Ek3PLiYgyEKtwTMmkMw4vbiyz/ps3pfdRYLVv+SN7qHVAImrjdAXxgluDEw6Ph4lyv+m9UpRmA==" + "version": "16.11.6", + "resolved": "https://verdaccio.lossless.one/@types%2fnode/-/node-16.11.6.tgz", + "integrity": "sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==" }, "@types/parcel-bundler": { "version": "1.12.3", diff --git a/package.json b/package.json index 2fce69e..f07f3fa 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "@gitzone/tsrun": "^1.2.18", "@gitzone/tstest": "^1.0.59", "@pushrocks/tapbundle": "^3.2.14", - "@types/node": "^16.11.1", + "@types/node": "^16.11.6", "tslint": "^6.1.3", "tslint-config-prettier": "^1.18.0" }, @@ -52,7 +52,8 @@ "@pushrocks/smartsocket": "^1.2.8", "@pushrocks/smartssh": "^1.2.3", "@pushrocks/smartstring": "^3.0.24", - "@servezone/servezone-interfaces": "^2.0.51", + "@servezone/interfaces": "^1.0.3", + "@tsclass/tsclass": "^3.0.36", "@types/through2": "^2.0.36", "through2": "^4.0.2" }, diff --git a/readme.md b/readme.md index 520d0d9..e389306 100644 --- a/readme.md +++ b/readme.md @@ -100,7 +100,6 @@ For further information read the linked docs at the top of this README. Use TypeScript for best in class instellisense. - ## Contribution We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) diff --git a/ts/connector.cloudly/cloudlyconnector.ts b/ts/connector.cloudly/cloudlyconnector.ts index 846bf0c..64f35fb 100644 --- a/ts/connector.cloudly/cloudlyconnector.ts +++ b/ts/connector.cloudly/cloudlyconnector.ts @@ -14,7 +14,7 @@ export class CloudlyConnector { } public async announceDockerContainer( - optionsArg: plugins.servezoneInterfaces.version.IVersionData + optionsArg: plugins.tsclass.container.IContainer ) { const cloudlyUrl = this.npmciRef.npmciConfig.getConfig().urlCloudly; if (!cloudlyUrl) { @@ -25,11 +25,14 @@ export class CloudlyConnector { return; } - const typedrequest = new plugins.typedrequest.TypedRequest( - `https://${cloudlyUrl}/versionmanager`, - 'update' - ); + const typedrequest = + new plugins.typedrequest.TypedRequest( + `https://${cloudlyUrl}/versionmanager`, + 'servezonestandard_InformAboutNewContainerVersion' + ); - const response = await typedrequest.fire(optionsArg); + const response = await typedrequest.fire({ + containerImageInfo: optionsArg + }); } } diff --git a/ts/manager.docker/index.ts b/ts/manager.docker/index.ts index a23b1de..56ede53 100644 --- a/ts/manager.docker/index.ts +++ b/ts/manager.docker/index.ts @@ -134,7 +134,9 @@ export class NpmciDockerManager { const dockerfileArray = await Dockerfile.readDockerfiles(this) .then(Dockerfile.sortDockerfiles) .then(Dockerfile.mapDockerfiles); - const dockerRegistryToPushTo = await this.npmciRegistryStorage.getRegistryByUrl(dockerRegistryUrl); + const dockerRegistryToPushTo = await this.npmciRegistryStorage.getRegistryByUrl( + dockerRegistryUrl + ); if (!dockerRegistryToPushTo) { logger.log( 'error', diff --git a/ts/manager.docker/mod.classes.dockerfile.ts b/ts/manager.docker/mod.classes.dockerfile.ts index 0c50516..0aa279e 100644 --- a/ts/manager.docker/mod.classes.dockerfile.ts +++ b/ts/manager.docker/mod.classes.dockerfile.ts @@ -152,9 +152,8 @@ export class Dockerfile { suffixArg?: string ): string { // determine wether the repo should be mapped accordingly to the registry - const mappedRepo = npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().dockerRegistryRepoMap[ - registryArg - ]; + const mappedRepo = + npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().dockerRegistryRepoMap[registryArg]; const repo = (() => { if (mappedRepo) { return mappedRepo; @@ -274,9 +273,11 @@ export class Dockerfile { ).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, + registryUrl: this.pushTag, + tag: this.buildTag, + labels: [], + version: + this.npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().projectInfo.npm.version, }); } diff --git a/ts/manager.npm/index.ts b/ts/manager.npm/index.ts index 0d533f5..56d8028 100644 --- a/ts/manager.npm/index.ts +++ b/ts/manager.npm/index.ts @@ -54,17 +54,21 @@ 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: string) => { - const npmRegistryUrl = npmEnvArg.split('|')[0]; - let npmToken = npmEnvArg.split('|')[1]; - if (npmEnvArg.split('|')[2] && npmEnvArg.split('|')[2] === 'plain') { - logger.log('ok', 'npm token not base64 encoded.'); - } else { - logger.log('ok', 'npm token base64 encoded.'); - npmToken = plugins.smartstring.base64.decode(npmToken); + await plugins.smartparam.forEachMinimatch( + process.env, + 'NPMCI_TOKEN_NPM*', + (npmEnvArg: string) => { + const npmRegistryUrl = npmEnvArg.split('|')[0]; + let npmToken = npmEnvArg.split('|')[1]; + if (npmEnvArg.split('|')[2] && npmEnvArg.split('|')[2] === 'plain') { + logger.log('ok', 'npm token not base64 encoded.'); + } else { + logger.log('ok', 'npm token base64 encoded.'); + npmToken = plugins.smartstring.base64.decode(npmToken); + } + npmrcFileString += `//${npmRegistryUrl}/:_authToken="${npmToken}"\n`; } - npmrcFileString += `//${npmRegistryUrl}/:_authToken="${npmToken}"\n`; - }); + ); logger.log('info', `setting default npm registry to ${config.npmRegistryUrl}`); npmrcFileString += `registry=https://${config.npmRegistryUrl}\n`; @@ -95,9 +99,13 @@ 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: string) => { - availableRegistries.push(npmEnvArg.split('|')[0]); - }); + await plugins.smartparam.forEachMinimatch( + process.env, + 'NPMCI_TOKEN_NPM*', + (npmEnvArg: string) => { + availableRegistries.push(npmEnvArg.split('|')[0]); + } + ); // -> configure package access level if (config.npmAccessLevel) { diff --git a/ts/mod_trigger/index.ts b/ts/mod_trigger/index.ts index 1eec9c2..dd6f916 100644 --- a/ts/mod_trigger/index.ts +++ b/ts/mod_trigger/index.ts @@ -2,7 +2,8 @@ import * as plugins from './mod.plugins'; import { bash } from '../npmci.bash'; import { logger } from '../npmci.logging'; -const triggerValueRegex = /^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|?([a-zA-Z0-9\.\-\/]*)/; +const triggerValueRegex = + /^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|?([a-zA-Z0-9\.\-\/]*)/; export let trigger = async () => { logger.log('info', 'now running triggers'); diff --git a/ts/npmci.plugins.ts b/ts/npmci.plugins.ts index 7ca0dca..50a3e7b 100644 --- a/ts/npmci.plugins.ts +++ b/ts/npmci.plugins.ts @@ -9,7 +9,7 @@ import * as typedrequest from '@apiglobal/typedrequest'; export { typedrequest }; // @servezone -import * as servezoneInterfaces from '@servezone/servezone-interfaces'; +import * as servezoneInterfaces from '@servezone/interfaces'; export { servezoneInterfaces }; @@ -51,6 +51,14 @@ export { smartstring, }; +// @tsclass scope +import * as tsclass from '@tsclass/tsclass'; + +export { + tsclass +} + +// third party import * as through2 from 'through2'; export { through2 };