Compare commits

...

61 Commits

Author SHA1 Message Date
efdf789575 3.1.74 2019-11-26 17:47:22 +00:00
6ef6446022 fix(npm cache): now correctly setting it when preparing npm 2019-11-26 17:47:21 +00:00
ef7d85e7c4 3.1.73 2019-11-24 13:52:19 +00:00
93b5d9869b 3.1.72 2019-11-24 11:51:53 +00:00
2a0cfeffe9 fix(core): update 2019-11-24 11:51:52 +00:00
909aafbd5f 3.1.71 2019-11-23 22:36:34 +00:00
91288e2d74 3.1.70 2019-11-23 22:32:09 +00:00
25709b1f9a fix(core): update 2019-11-23 22:32:08 +00:00
8a03d9aa94 3.1.69 2019-11-23 19:46:24 +00:00
bbe1cf770a 3.1.68 2019-11-23 19:46:02 +00:00
ac8190282f fix(core): update 2019-11-23 19:46:02 +00:00
446d140e32 3.1.68 2019-11-23 19:45:00 +00:00
726948651e fix(core): update 2019-11-23 19:44:59 +00:00
dd0a7bb782 3.1.67 2019-10-04 15:18:51 +02:00
fca00ffcf8 fix(core): update 2019-10-04 15:18:51 +02:00
13f6334ae5 3.1.66 2019-10-03 00:00:20 +02:00
7275a858d6 fix(core): update 2019-10-03 00:00:20 +02:00
5a3befe5af 3.1.65 2019-10-02 23:55:55 +02:00
385a93a05e update 2019-10-02 23:55:51 +02:00
b4d444ff05 3.1.64 2019-10-02 14:54:21 +02:00
487bcb9a70 fix(core): update 2019-10-02 14:54:21 +02:00
aaf11b66d7 3.1.63 2019-10-02 11:57:00 +02:00
83d7d46896 fix(core): update 2019-10-02 11:56:59 +02:00
693bda6a49 3.1.62 2019-10-02 11:56:06 +02:00
bfe3e266ee fix(core): update 2019-10-02 11:56:05 +02:00
5f33ebd8a7 3.1.61 2019-10-02 11:33:52 +02:00
f78c80e100 fix(core): update 2019-10-02 11:33:52 +02:00
f4d8656831 3.1.60 2019-09-01 14:21:30 +02:00
2290081ef0 fix(core): update 2019-09-01 14:21:30 +02:00
189d02a16f 3.1.59 2019-09-01 14:11:35 +02:00
55aee04334 fix(core): update 2019-09-01 14:11:35 +02:00
0e407b9b9d 3.1.58 2019-09-01 13:54:00 +02:00
24095bbd40 fix(core): update 2019-09-01 13:54:00 +02:00
f97ee94b5a 3.1.57 2019-09-01 13:51:12 +02:00
4cf7aea374 fix(core): update 2019-09-01 13:51:11 +02:00
6ab5e9cb30 3.1.56 2019-09-01 13:49:28 +02:00
95c1145bf5 3.1.55 2019-09-01 13:49:12 +02:00
ea04a1b788 fix(core): update 2019-09-01 13:49:11 +02:00
3bc2499d09 3.1.54 2019-09-01 13:46:03 +02:00
1f5967ac45 fix(core): update 2019-09-01 13:46:03 +02:00
fd952f086b 3.1.53 2019-09-01 13:45:19 +02:00
79500cb2c2 fix(core): update 2019-09-01 13:45:18 +02:00
6c58864fcf 3.1.52 2019-09-01 13:44:22 +02:00
7ea3ac182d fix(core): update 2019-09-01 13:44:21 +02:00
8979d26005 3.1.51 2019-09-01 13:41:04 +02:00
c8876dac88 fix(core): update 2019-09-01 13:41:03 +02:00
9c8a257c2a 3.1.50 2019-08-30 18:40:00 +02:00
8b77930ece fix(core): update 2019-08-30 18:39:59 +02:00
ba672d030f 3.1.49 2019-08-30 14:51:04 +02:00
8ad7e016e7 fix(core): update 2019-08-30 14:51:03 +02:00
d843311d7b 3.1.48 2019-08-30 13:30:16 +02:00
14ef2cfa9b 3.1.47 2019-08-30 12:24:01 +02:00
648effcf86 fix(core): update 2019-08-30 12:24:00 +02:00
572738e88f 3.1.46 2019-08-30 10:40:38 +02:00
129ae93044 fix(core): update 2019-08-30 10:40:38 +02:00
e910892231 3.1.45 2019-08-30 10:38:48 +02:00
6d9cabf7ee fix(core): update 2019-08-30 10:38:47 +02:00
7c7787e811 3.1.44 2019-08-29 20:56:03 +02:00
bde26cc312 fix(core): update 2019-08-29 20:56:02 +02:00
29e81f3ae7 3.1.43 2019-08-29 20:38:45 +02:00
6337b20d62 fix(core): update 2019-08-29 20:38:44 +02:00
17 changed files with 570 additions and 905 deletions

View File

@@ -1,7 +1,5 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
variables:
GIT_STRATEGY: clone
cache:
paths:
@@ -102,7 +100,7 @@ trigger:
pages:
image: hosttoday/ht-docker-dbase:npmci
services:
- docker:18-dind
- docker:stable-dind
stage: metadata
script:
- npmci command npm install -g @gitzone/tsdoc

1227
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@shipzone/npmci",
"version": "3.1.42",
"version": "3.1.74",
"private": false,
"description": "node and docker in gitlab ci on steroids",
"main": "dist/index.js",
@@ -9,8 +9,8 @@
"npmci": "cli.js"
},
"scripts": {
"test": "(rm -f config.json) && tstest test/",
"build": "(rm -f config.json) && tsbuild && (npm run testVersion)",
"test": "tstest test/",
"build": "tsbuild && (npm run testVersion)",
"testVersion": "(cd test/assets/ && node ../../cli.js -v)"
},
"repository": {
@@ -26,33 +26,32 @@
"devDependencies": {
"@gitzone/tsbuild": "^2.1.17",
"@gitzone/tsrun": "^1.2.6",
"@gitzone/tstest": "^1.0.24",
"@pushrocks/tapbundle": "^3.0.13",
"@types/node": "^12.7.2",
"tslint": "^5.19.0",
"@gitzone/tstest": "^1.0.28",
"@pushrocks/tapbundle": "^3.2.0",
"@types/node": "^12.12.12",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@apiglobal/typedrequest": "^1.0.24",
"@pushrocks/lik": "^3.0.11",
"@pushrocks/npmextra": "^3.0.5",
"@pushrocks/npmextra": "^3.0.7",
"@pushrocks/projectinfo": "^4.0.2",
"@pushrocks/qenv": "^4.0.2",
"@pushrocks/qenv": "^4.0.6",
"@pushrocks/smartanalytics": "^2.0.15",
"@pushrocks/smartcli": "^3.0.7",
"@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartfile": "^7.0.2",
"@pushrocks/smartgit": "^1.0.13",
"@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartdelay": "^2.0.6",
"@pushrocks/smartfile": "^7.0.6",
"@pushrocks/smartlog": "^2.0.21",
"@pushrocks/smartlog-destination-local": "^8.0.2",
"@pushrocks/smartparam": "^1.0.4",
"@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartrequest": "^1.1.23",
"@pushrocks/smartshell": "^2.0.23",
"@pushrocks/smartsocket": "^1.1.45",
"@pushrocks/smartpromise": "^3.0.6",
"@pushrocks/smartrequest": "^1.1.43",
"@pushrocks/smartshell": "^2.0.25",
"@pushrocks/smartsocket": "^1.1.58",
"@pushrocks/smartssh": "^1.2.3",
"@pushrocks/smartstring": "^3.0.10",
"@servezone/servezone-interfaces": "^2.0.28",
"@types/shelljs": "^0.8.5",
"@pushrocks/smartstring": "^3.0.17",
"@servezone/servezone-interfaces": "^2.0.51",
"@types/through2": "^2.0.34",
"through2": "^3.0.1"
},

View File

@@ -29,28 +29,34 @@ let sortableArray: npmci.Dockerfile[];
tap.test('should return valid Dockerfiles', async () => {
const npmciInstance = new npmci.Npmci();
dockerfile1 = new npmci.Dockerfile(npmciInstance.dockerManager, { filePath: './Dockerfile', read: true });
dockerfile2 = new npmci.Dockerfile(npmciInstance.dockerManager, { filePath: './Dockerfile_sometag1', read: true });
dockerfile1 = new npmci.Dockerfile(npmciInstance.dockerManager, {
filePath: './Dockerfile',
read: true
});
dockerfile2 = new npmci.Dockerfile(npmciInstance.dockerManager, {
filePath: './Dockerfile_sometag1',
read: true
});
expect(dockerfile1.version).to.equal('latest');
return expect(dockerfile2.version).to.equal('sometag1');
});
tap.test('should read a directory of Dockerfiles', async () => {
const npmciInstance = new npmci.Npmci();
return npmci.Dockerfile
.readDockerfiles(npmciInstance.dockerManager)
.then(async (readDockerfilesArrayArg: npmci.Dockerfile[]) => {
return npmci.Dockerfile.readDockerfiles(npmciInstance.dockerManager).then(
async (readDockerfilesArrayArg: npmci.Dockerfile[]) => {
sortableArray = readDockerfilesArrayArg;
return expect(readDockerfilesArrayArg[1].version).to.equal('sometag1');
});
}
);
});
tap.test('should sort an array of Dockerfiles', async () => {
return npmci.Dockerfile
.sortDockerfiles(sortableArray)
.then(async (sortedArrayArg: npmci.Dockerfile[]) => {
return npmci.Dockerfile.sortDockerfiles(sortableArray).then(
async (sortedArrayArg: npmci.Dockerfile[]) => {
console.log(sortedArrayArg);
});
}
);
});
tap.test('should build all Dockerfiles', async () => {

View File

@@ -1,8 +1,32 @@
import * as plugins from '../npmci.plugins';
import { Npmci } from '../npmci.classes.npmci';
import { logger } from '../npmci.logging';
/**
*
* connects to cloudly
*/
export class CloudlyConnector {
public npmciRef: Npmci;
constructor(npmciRefArg: Npmci) {
this.npmciRef = npmciRefArg;
}
public async announceDockerContainer(optionsArg: plugins.servezoneInterfaces.version.IVersionData) {
const cloudlyUrl = this.npmciRef.npmciConfig.getConfig().urlCloudly;
if (!cloudlyUrl) {
logger.log(
'warn',
'no cloudly url provided. Thus we cannot announce the newly built Dockerimage!'
);
return;
}
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

@@ -50,7 +50,7 @@ export class NpmciDockerManager {
`>>npmci docker ...<< cli arguments invalid... Please read the documentation.`
);
}
}
};
/**
* builds a cwd of Dockerfiles by triggering a promisechain
@@ -62,7 +62,7 @@ export class NpmciDockerManager {
.then(Dockerfile.sortDockerfiles)
.then(Dockerfile.mapDockerfiles)
.then(Dockerfile.buildDockerfiles);
}
};
/**
* login to the DockerRegistries
@@ -70,7 +70,7 @@ export class NpmciDockerManager {
public login = async () => {
await this.prepare();
await this.npmciRegistryStorage.loginAll();
}
};
/**
* logs in docker
@@ -98,7 +98,7 @@ export class NpmciDockerManager {
}
);
return;
}
};
/**
* pushes an image towards a registry
@@ -146,7 +146,7 @@ export class NpmciDockerManager {
await dockerfile.push(dockerRegistryToPushTo, suffix);
}
}
}
};
/**
* pulls an image
@@ -165,7 +165,7 @@ export class NpmciDockerManager {
for (const dockerfile of dockerfileArray) {
await dockerfile.pull(localDockerRegistry, suffix);
}
}
};
/**
* tests docker files
@@ -173,5 +173,5 @@ export class NpmciDockerManager {
public test = async () => {
await this.prepare();
return await Dockerfile.readDockerfiles(this).then(Dockerfile.testDockerfiles);
}
};
}

View File

@@ -214,6 +214,7 @@ export class Dockerfile {
public version: string;
public cleanTag: string;
public buildTag: string;
public pushTag: string;
public containerName: string;
public content: string;
public baseImage: string;
@@ -248,7 +249,9 @@ export class Dockerfile {
public async build() {
logger.log('info', 'now building Dockerfile for ' + this.cleanTag);
const buildArgsString = await Dockerfile.getDockerBuildArgs(this.npmciDockerManagerRef);
const buildCommand = `docker build -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
const buildCommand = `docker build --label="version=${
this.npmciDockerManagerRef.npmciRef.npmciConfig.getConfig().projectInfo.npm.version
}" -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
await bash(buildCommand);
return;
}
@@ -257,15 +260,24 @@ export class Dockerfile {
* pushes the Dockerfile to a registry
*/
public async push(dockerRegistryArg: DockerRegistry, versionSuffix: string = null) {
const pushTag = Dockerfile.getDockerTagString(
this.pushTag = Dockerfile.getDockerTagString(
this.npmciDockerManagerRef,
dockerRegistryArg.registryUrl,
this.repo,
this.version,
versionSuffix
);
await bash(`docker tag ${this.buildTag} ${pushTag}`);
await bash(`docker push ${pushTag}`);
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];
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
});
}
/**

View File

@@ -3,4 +3,3 @@ import * as plugins from './mod.plugins';
import * as paths from '../npmci.paths';
import { Dockerfile } from './mod.classes.dockerfile';

View File

@@ -1,6 +1,6 @@
import { logger } from '../npmci.logging';
import * as plugins from './mod.plugins';
import { bash } from '../npmci.bash';
import { bash, bashNoError } from '../npmci.bash';
import { Npmci } from '../npmci.classes.npmci';
export class NpmciGitManager {
@@ -27,12 +27,12 @@ export class NpmciGitManager {
} else {
logger.log('info', `npmci git -> cli arguments invalid! Please read the documentation.`);
}
}
};
public mirror = async () => {
const githubToken = process.env.NPMCI_GIT_GITHUBTOKEN;
const githubUser = process.env.NPMCI_GIT_GITHUBGROUP || this.npmciRef.npmciEnv.repo.user;
const githubRepo = process.env.NPMCI_GIT_GITHUB || this.npmciRef.npmciEnv.repo;
const githubRepo = process.env.NPMCI_GIT_GITHUB || this.npmciRef.npmciEnv.repo.repo;
if (
this.npmciRef.npmciConfig.getConfig().projectInfo.npm.packageJson.private === true ||
this.npmciRef.npmciConfig.getConfig().npmAccessLevel === 'private'
@@ -47,19 +47,25 @@ export class NpmciGitManager {
logger.log('info', 'found github token.');
logger.log('info', 'attempting the mirror the repository to GitHub');
// plugins.smartgit.GitRepo;
// remove old mirrors
await bashNoError('git remote rm mirror');
await bash(`git fetch`);
// add the mirror
await bash(
await bashNoError(
`git remote add mirror https://${githubToken}@github.com/${githubUser}/${githubRepo}.git`
);
await bash(`git push mirror --all`);
await bashNoError(`git push mirror --all`);
await bashNoError(`git checkout origin/master`);
await bashNoError(`git push mirror master`);
logger.log('ok', 'pushed all branches to mirror!');
await bash(`git push mirror --tags`);
await bashNoError(`git push mirror --tags`);
logger.log('ok', 'pushed all tags to mirror!');
// remove old mirrors
await bashNoError('git remote rm mirror');
} else {
logger.log('error', `cannot find NPMCI_GIT_GITHUBTOKEN env var!`);
process.exit(1);
}
}
};
}

View File

@@ -1,5 +1 @@
export * from '../npmci.plugins';
import * as smartgit from '@pushrocks/smartgit';
export { smartgit };

View File

@@ -62,7 +62,6 @@ export class NpmciNodeJsManager {
await bash('npm install -g npm');
await bash('node -v');
await bash('npm -v');
await bash(`npm config set cache ${paths.NpmciCacheDir} --global `);
// lets look for further config
const config = await this.npmciRef.npmciConfig.getConfig();

View File

@@ -1,4 +1,5 @@
import * as plugins from './mod.plugins';
import * as paths from '../npmci.paths';
import { logger } from '../npmci.logging';
import { bash, bashNoError, nvmAvailable } from '../npmci.bash';
@@ -22,6 +23,9 @@ export class NpmciNpmManager {
case 'install':
await this.install();
break;
case 'build':
await this.build();
break;
case 'prepare':
await this.prepare();
break;
@@ -70,6 +74,10 @@ export class NpmciNpmManager {
// lets save it to disk
plugins.smartfile.memory.toFsSync(npmrcFileString, '/root/.npmrc');
// lets set the cache directory
await bash(`npm config set cache ${paths.NpmciCacheDir} --global `);
return;
}
@@ -133,8 +141,8 @@ export class NpmciNpmManager {
await bash(`npm -v`);
// -> build it
await bash(`npm install`);
await bash(`npm run build`);
await this.install();
await this.build();
logger.log('success', `Nice!!! The build for the publication was successfull!`);
logger.log('info', `Lets clean up so we don't publish any packages that don't belong to us:`);
@@ -152,7 +160,12 @@ export class NpmciNpmManager {
public async install(): Promise<void> {
logger.log('info', 'now installing dependencies:');
await bash('npm install');
await bash('npm ci');
}
public async build(): Promise<void> {
logger.log('info', 'now building the project:');
await bash('npm run build');
}
public async test(): Promise<void> {

View File

@@ -34,7 +34,7 @@ export class Npmci {
projectId: 'gitzone',
appName: 'npmci'
});
this.cloudlyConnector = new CloudlyConnector();
this.cloudlyConnector = new CloudlyConnector(this);
this.npmciEnv = new NpmciEnv(this);
this.npmciInfo = new NpmciInfo(this);
this.npmciCli = new NpmciCli(this);

View File

@@ -106,5 +106,5 @@ export class NpmciCli {
public startParse = () => {
this.smartcli.startParse();
}
};
}

View File

@@ -1,10 +1,9 @@
import * as plugins from './npmci.plugins';
import * as paths from './npmci.paths';
import { logger } from "./npmci.logging";
import { logger } from './npmci.logging';
import { Npmci } from './npmci.classes.npmci';
export class NpmciInfo {
public npmciRef: Npmci;
public projectInfo = new plugins.projectinfo.ProjectinfoNpm(paths.NpmciPackageRoot);
@@ -12,7 +11,7 @@ export class NpmciInfo {
this.npmciRef = npmciArg;
}
public printToConsole () {
public printToConsole() {
logger.log('info', `npmci version: ${this.projectInfo.version}`);
}
}

View File

@@ -3,12 +3,15 @@ import * as path from 'path';
export { path };
// @apiglobal
import * as typedrequest from '@apiglobal/typedrequest';
export { typedrequest };
// @servezone
import * as servezoneInterfaces from '@servezone/servezone-interfaces';
export {
servezoneInterfaces
};
export { servezoneInterfaces };
// @pushrocks
import * as npmextra from '@pushrocks/npmextra';