Compare commits

...

52 Commits

Author SHA1 Message Date
0e820bec27 3.1.37 2019-07-18 14:42:15 +02:00
91a3d612c6 fix(core): update 2019-07-18 14:42:14 +02:00
c696730e55 3.1.36 2019-07-17 17:57:21 +02:00
38d38ce246 fix(core): update 2019-07-17 17:57:20 +02:00
adfdf68c38 3.1.35 2019-07-17 17:55:03 +02:00
d4a4d69941 fix(core): update 2019-07-17 17:55:02 +02:00
c1fed2c758 3.1.34 2019-07-17 17:04:10 +02:00
9918d81f59 fix(core): update 2019-07-17 17:04:10 +02:00
59d8338f6e 3.1.33 2019-06-19 14:00:24 +02:00
a4f8bd3320 fix(core): update 2019-06-19 14:00:24 +02:00
7c2fdb7224 3.1.32 2019-06-19 11:36:05 +02:00
37384aeb57 fix(core): update 2019-06-19 11:36:04 +02:00
60efda263f 3.1.31 2019-06-19 11:35:19 +02:00
19831037ec fix(core): update 2019-06-19 11:35:19 +02:00
a1d52af813 3.1.30 2019-06-19 10:41:58 +02:00
0a49ff9b03 fix(core): update 2019-06-19 10:41:58 +02:00
ca62326b46 3.1.29 2019-06-18 22:24:53 +02:00
e1de0ee479 fix(core): update 2019-06-18 22:24:53 +02:00
0dea101c07 3.1.28 2019-06-18 22:24:12 +02:00
380a49c59f fix(core): update 2019-06-18 22:24:12 +02:00
5133651e34 3.1.27 2019-06-18 17:30:05 +02:00
c8f26c7c48 fix(core): update 2019-06-18 17:30:04 +02:00
3bb5912046 3.1.26 2019-06-18 16:19:07 +02:00
d75258d9dd fix(core): update 2019-06-18 16:19:07 +02:00
b1577e7542 3.1.25 2019-05-08 22:50:57 +02:00
d5cdeffd17 fix(core): update 2019-05-08 22:50:57 +02:00
c62ce415e9 3.1.24 2019-05-08 22:44:34 +02:00
99014da1e8 fix(core): update 2019-05-08 22:44:34 +02:00
0b5dada524 3.1.23 2019-05-08 22:43:49 +02:00
40bddba3b5 fix(core): update 2019-05-08 22:43:48 +02:00
6f6ee6d799 3.1.22 2019-02-24 22:50:12 +01:00
e30cc3f5a0 fix(core): update 2019-02-24 22:50:12 +01:00
a4562d4d1b 3.1.21 2018-12-24 02:13:05 +01:00
524b405773 fix(core): update 2018-12-24 02:13:04 +01:00
0d19c1c68d 3.1.20 2018-12-23 18:57:15 +01:00
cff79bc3b4 fix(mirror): now refusing to mirror for private code 2018-12-23 18:57:15 +01:00
28541a838d 3.1.19 2018-12-23 18:54:17 +01:00
c3ab527341 fix(core): update 2018-12-23 18:54:16 +01:00
52cc249098 3.1.18 2018-12-23 17:29:25 +01:00
2e189b0660 fix(core): update 2018-12-23 17:29:25 +01:00
f876c7414b 3.1.17 2018-12-12 22:29:59 +01:00
08b7585cfc fix(core): update 2018-12-12 22:29:59 +01:00
76311fab72 3.1.16 2018-12-11 01:02:22 +01:00
1b73df64f5 fix(core): update 2018-12-11 01:02:21 +01:00
701cee573b 3.1.15 2018-12-11 00:25:40 +01:00
3dd086f711 fix(core): update 2018-12-11 00:25:39 +01:00
67ff5d09d4 3.1.14 2018-12-09 16:48:33 +01:00
5cb8a79b6a fix(core): update 2018-12-09 16:48:33 +01:00
2dcbca2362 3.1.13 2018-12-09 16:26:28 +01:00
bd63194f4b fix(core): update 2018-12-09 16:26:28 +01:00
2763fdef5f 3.1.12 2018-12-09 15:53:39 +01:00
bbedde01b9 fix(core): update 2018-12-09 15:53:38 +01:00
17 changed files with 2710 additions and 1132 deletions

23
.gitignore vendored
View File

@@ -1,7 +1,22 @@
dist/ .nogit/
node_modules/
# artifacts
coverage/ coverage/
public/ public/
config.json pages/
# installs
node_modules/
# caches
.yarn/ .yarn/
.npmci_cache .cache/
.rpt2_cache
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
# custom

View File

@@ -1,5 +1,5 @@
# gitzone standard # gitzone ci_default
image: hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
@@ -50,13 +50,13 @@ testLTS:
- docker - docker
- notpriv - notpriv
testSTABLE: testBuild:
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
- npmci node install stable - npmci node install lts
- npmci npm install - npmci npm install
- npmci npm test - npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
@@ -65,7 +65,7 @@ testSTABLE:
release: release:
stage: release stage: release
script: script:
- npmci node install stable - npmci node install lts
- npmci npm publish - npmci npm publish
only: only:
- tags - tags
@@ -78,19 +78,11 @@ release:
# ==================== # ====================
codequality: codequality:
stage: metadata stage: metadata
image: docker:stable
allow_failure: true allow_failure: true
services:
- docker:stable-dind
script: script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/') - npmci command npm install -g tslint typescript
- docker run - npmci npm install
--env SOURCE_CODE="$PWD" - npmci command "tslint -c tslint.json ./ts/**/*.ts"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
tags: tags:
- docker - docker
- priv - priv
@@ -109,10 +101,10 @@ pages:
image: hosttoday/ht-docker-node:npmci image: hosttoday/ht-docker-node:npmci
stage: metadata stage: metadata
script: script:
- npmci command npm install -g typedoc typescript - npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/ - npmci command tsdoc
tags: tags:
- docker - docker
- notpriv - notpriv

View File

@@ -1,16 +1,26 @@
{ {
"npmts":{ "npmts": {
"mode":"default", "mode": "default",
"coverageTreshold": "70", "coverageTreshold": "70",
"cli": true "cli": true
}, },
"npmci": { "npmci": {
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public", "npmAccessLevel": "public",
"npmRegistryUrl": "registry.npmjs.org" "npmRegistryUrl": "registry.npmjs.org"
}, },
"npmdocker":{ "npmdocker": {
"baseImage":"hosttoday/ht-docker-node:npmci", "baseImage": "hosttoday/ht-docker-node:npmci",
"command": "npmci test stable" "command": "npmci test stable"
},
"gitzone": {
"module": {
"githost": "gitlab.com",
"gitscope": "shipzone",
"gitrepo": "npmci",
"shortDescription": "node and docker in gitlab ci on steroids",
"npmPackagename": "@shipzone/npmci",
"license": "MIT"
} }
}
} }

3437
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,7 @@
{ {
"name": "@shipzone/npmci", "name": "@shipzone/npmci",
"version": "3.1.11", "version": "3.1.37",
"private": false,
"description": "node and docker in gitlab ci on steroids", "description": "node and docker in gitlab ci on steroids",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
@@ -23,36 +24,45 @@
}, },
"homepage": "https://gitlab.com/gitzone/npmci#README", "homepage": "https://gitlab.com/gitzone/npmci#README",
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.0.22", "@gitzone/tsbuild": "^2.1.11",
"@gitzone/tsrun": "^1.1.13", "@gitzone/tsrun": "^1.2.6",
"@gitzone/tstest": "^1.0.15", "@gitzone/tstest": "^1.0.24",
"@pushrocks/tapbundle": "^3.0.7", "@pushrocks/tapbundle": "^3.0.9",
"@types/node": "^10.12.10", "@types/node": "^12.0.8",
"tslint": "^5.11.0", "tslint": "^5.17.0",
"tslint-config-prettier": "^1.17.0" "tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^3.0.2", "@pushrocks/lik": "^3.0.5",
"@pushrocks/npmextra": "^3.0.1", "@pushrocks/npmextra": "^3.0.5",
"@pushrocks/projectinfo": "^4.0.2", "@pushrocks/projectinfo": "^4.0.2",
"@pushrocks/smartcli": "^3.0.6", "@pushrocks/smartanalytics": "^2.0.15",
"@pushrocks/smartdelay": "^2.0.2", "@pushrocks/smartcli": "^3.0.7",
"@pushrocks/smartfile": "^6.0.11", "@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartlog": "^2.0.9", "@pushrocks/smartfile": "^7.0.2",
"@pushrocks/smartlog-destination-local": "^7.0.5", "@pushrocks/smartgit": "^1.0.9",
"@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartlog-destination-local": "^8.0.2",
"@pushrocks/smartparam": "^1.0.4", "@pushrocks/smartparam": "^1.0.4",
"@pushrocks/smartpromise": "^2.0.5", "@pushrocks/smartpromise": "^3.0.2",
"@pushrocks/smartrequest": "^1.1.14", "@pushrocks/smartrequest": "^1.1.16",
"@pushrocks/smartshell": "^2.0.11", "@pushrocks/smartshell": "^2.0.23",
"@pushrocks/smartsocket": "^1.1.38",
"@pushrocks/smartssh": "^1.2.3", "@pushrocks/smartssh": "^1.2.3",
"@pushrocks/smartstring": "^3.0.5", "@pushrocks/smartstring": "^3.0.10",
"@types/lodash": "^4.14.118", "@types/shelljs": "^0.8.5",
"@types/shelljs": "^0.8.0",
"@types/through2": "^2.0.34", "@types/through2": "^2.0.34",
"lodash": "^4.17.11", "through2": "^3.0.1"
"smartanalytics": "^2.0.9",
"smartsocket": "^1.1.19",
"through2": "^3.0.0"
}, },
"private": false "files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"dist_ts_web/*",
"assets/*",
"cli.js",
"npmextra.json",
"readme.md"
]
} }

View File

@@ -1,25 +1,20 @@
# npmci # @shipzone/npmci
node and docker in gitlab ci on steroids node and docker in gitlab ci on steroids
## Availabililty ## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@shipzone/npmci)
[![npm](https://shipzone.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/@shipzone/npmci) * [gitlab.com (source)](https://gitlab.com/shipzone/npmci)
[![git](https://shipzone.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/shipzone/npmci) * [github.com (source mirror)](https://github.com/shipzone/npmci)
[![git](https://shipzone.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/shipzone/npmci) * [docs (typedoc)](https://shipzone.gitlab.io/npmci/)
[![docs](https://shipzone.gitlab.io/assets/repo-button-docs.svg)](https://shipzone.gitlab.io/npmci/)
## Status for master ## Status for master
[![build status](https://gitlab.com/shipzone/npmci/badges/master/build.svg)](https://gitlab.com/shipzone/npmci/commits/master)
[![build status](https://GitLab.com/shipzone/npmci/badges/master/build.svg)](https://GitLab.com/shipzone/npmci/commits/master) [![coverage report](https://gitlab.com/shipzone/npmci/badges/master/coverage.svg)](https://gitlab.com/shipzone/npmci/commits/master)
[![coverage report](https://GitLab.com/shipzone/npmci/badges/master/coverage.svg)](https://GitLab.com/shipzone/npmci/commits/master) [![npm downloads per month](https://img.shields.io/npm/dm/@shipzone/npmci.svg)](https://www.npmjs.com/package/@shipzone/npmci)
[![npm downloads per month](https://img.shields.io/npm/dm/npmci.svg)](https://www.npmjs.com/package/@shipzone/npmci) [![Known Vulnerabilities](https://snyk.io/test/npm/@shipzone/npmci/badge.svg)](https://snyk.io/test/npm/@shipzone/npmci)
[![Dependency Status](https://david-dm.org/shipzone/npmci.svg)](https://david-dm.org/shipzone/npmci) [![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![bitHound Dependencies](https://www.bithound.io/github/shipzone/npmci/badges/dependencies.svg)](https://www.bithound.io/github/shipzone/npmci/master/dependencies/npm) [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![bitHound Code](https://www.bithound.io/github/shipzone/npmci/badges/code.svg)](https://www.bithound.io/github/shipzone/npmci) [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage ## Usage
@@ -98,9 +93,9 @@ For further information read the linked docs at the top of this README.
Use TypeScript for best in class instellisense. Use TypeScript for best in class instellisense.
For further information read the linked docs at the top of this README. For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) > MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://shipzone.gitlab.io/assets/repo-footer.svg)](https://push.rocks) [![repo-footer](https://shipzone.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

@@ -10,6 +10,9 @@ import { Dockerfile } from './mod.classes.dockerfile';
import { DockerRegistry } from './mod.classes.dockerregistry'; import { DockerRegistry } from './mod.classes.dockerregistry';
import { RegistryStorage } from './mod.classes.registrystorage'; import { RegistryStorage } from './mod.classes.registrystorage';
// config
import { configObject } from '../npmci.config';
// instances // instances
const npmciRegistryStorage = new RegistryStorage(); const npmciRegistryStorage = new RegistryStorage();
@@ -21,7 +24,7 @@ export let modArgvArg; // will be set through the build command
* handle cli input * handle cli input
* @param argvArg * @param argvArg
*/ */
export let handleCli = async argvArg => { export const handleCli = async argvArg => {
modArgvArg = argvArg; modArgvArg = argvArg;
if (argvArg._.length >= 2) { if (argvArg._.length >= 2) {
const action: string = argvArg._[1]; const action: string = argvArg._[1];
@@ -56,7 +59,7 @@ export let handleCli = async argvArg => {
/** /**
* builds a cwd of Dockerfiles by triggering a promisechain * builds a cwd of Dockerfiles by triggering a promisechain
*/ */
export let build = async () => { export const build = async () => {
await prepare(); await prepare();
logger.log('info', 'now building Dockerfiles...'); logger.log('info', 'now building Dockerfiles...');
await helpers await helpers
@@ -69,7 +72,7 @@ export let build = async () => {
/** /**
* login to the DockerRegistries * login to the DockerRegistries
*/ */
export let login = async () => { export const login = async () => {
await prepare(); await prepare();
await npmciRegistryStorage.loginAll(); await npmciRegistryStorage.loginAll();
}; };
@@ -77,7 +80,7 @@ export let login = async () => {
/** /**
* logs in docker * logs in docker
*/ */
export let prepare = async () => { export const prepare = async () => {
// Always login to GitLab Registry // Always login to GitLab Registry
if (!process.env.CI_BUILD_TOKEN || process.env.CI_BUILD_TOKEN === '') { if (!process.env.CI_BUILD_TOKEN || process.env.CI_BUILD_TOKEN === '') {
logger.log('error', 'No registry token specified by gitlab!'); logger.log('error', 'No registry token specified by gitlab!');
@@ -98,31 +101,54 @@ export let prepare = async () => {
return; return;
}; };
export let push = async argvArg => { /**
* pushes an image towards a registry
* @param argvArg
*/
export const push = async argvArg => {
await prepare(); await prepare();
const registryUrlArg = argvArg._[2]; let dockerRegistryUrls: string[] = [];
// lets parse the input of cli and npmextra
if (argvArg._.length >= 3 && argvArg._[2] !== 'npmextra') {
dockerRegistryUrls.push(argvArg._[2]);
} else {
if (configObject.dockerRegistries.length === 0) {
logger.log(
'warn',
`There are no docker registries listed in npmextra.json! This is strange!`
);
}
dockerRegistryUrls = dockerRegistryUrls.concat(configObject.dockerRegistries);
}
// lets determine the suffix
let suffix = null; let suffix = null;
if (argvArg._.length >= 4) { if (argvArg._.length >= 4) {
suffix = argvArg._[3]; suffix = argvArg._[3];
} }
const dockerfileArray = await helpers
.readDockerfiles() // lets push to the registries
.then(helpers.sortDockerfiles) for (const dockerRegistryUrl of dockerRegistryUrls) {
.then(helpers.mapDockerfiles); const dockerfileArray = await helpers
const localDockerRegistry = npmciRegistryStorage.getRegistryByUrl(registryUrlArg); .readDockerfiles()
if (!localDockerRegistry) { .then(helpers.sortDockerfiles)
logger.log( .then(helpers.mapDockerfiles);
'error', const dockerRegistryToPushTo = npmciRegistryStorage.getRegistryByUrl(dockerRegistryUrl);
`Cannot push to registry ${registryUrlArg}, because it was not found in the authenticated registry list.` if (!dockerRegistryToPushTo) {
); logger.log(
process.exit(1); 'error',
} `Cannot push to registry ${dockerRegistryUrl}, because it was not found in the authenticated registry list.`
for (const dockerfile of dockerfileArray) { );
await dockerfile.push(localDockerRegistry, suffix); process.exit(1);
}
for (const dockerfile of dockerfileArray) {
await dockerfile.push(dockerRegistryToPushTo, suffix);
}
} }
}; };
export let pull = async argvArg => { export const pull = async argvArg => {
await prepare(); await prepare();
const registryUrlArg = argvArg._[2]; const registryUrlArg = argvArg._[2];
let suffix = null; let suffix = null;
@@ -139,7 +165,10 @@ export let pull = async argvArg => {
} }
}; };
export let test = async () => { /**
* tests docker files
*/
export const test = async () => {
await prepare(); await prepare();
return await helpers.readDockerfiles().then(helpers.testDockerfiles); return await helpers.readDockerfiles().then(helpers.testDockerfiles);
}; };

View File

@@ -42,9 +42,7 @@ export class Dockerfile {
public async build() { public async build() {
logger.log('info', 'now building Dockerfile for ' + this.cleanTag); logger.log('info', 'now building Dockerfile for ' + this.cleanTag);
const buildArgsString = await helpers.getDockerBuildArgs(); const buildArgsString = await helpers.getDockerBuildArgs();
const buildCommand = `docker build -t ${this.buildTag} -f ${ const buildCommand = `docker build -t ${this.buildTag} -f ${this.filePath} ${buildArgsString} .`;
this.filePath
} ${buildArgsString} .`;
await bash(buildCommand); await bash(buildCommand);
return; return;
} }
@@ -86,9 +84,7 @@ export class Dockerfile {
if (testFileExists) { if (testFileExists) {
// run tests // run tests
await bash( await bash(
`docker run --name npmci_test_container --entrypoint="bash" ${ `docker run --name npmci_test_container --entrypoint="bash" ${this.buildTag} -c "mkdir /npmci_test"`
this.buildTag
} -c "mkdir /npmci_test"`
); );
await bash(`docker cp ${testFile} npmci_test_container:/npmci_test/test.sh`); await bash(`docker cp ${testFile} npmci_test_container:/npmci_test/test.sh`);
await bash(`docker commit npmci_test_container npmci_test_image`); await bash(`docker commit npmci_test_container npmci_test_image`);

View File

@@ -165,7 +165,7 @@ export let getDockerBuildArgs = async (): Promise<string> => {
let buildArgsString: string = ''; let buildArgsString: string = '';
for (const key in NpmciConfig.configObject.dockerBuildargEnvMap) { for (const key in NpmciConfig.configObject.dockerBuildargEnvMap) {
const targetValue = process.env[NpmciConfig.configObject.dockerBuildargEnvMap[key]]; const targetValue = process.env[NpmciConfig.configObject.dockerBuildargEnvMap[key]];
buildArgsString = `${buildArgsString} --build-arg ${key}=${targetValue}`; buildArgsString = `${buildArgsString} --build-arg ${key}="${targetValue}"`;
} }
return buildArgsString; return buildArgsString;
}; };

View File

@@ -3,6 +3,8 @@ import * as plugins from './mod.plugins';
import { bash } from '../npmci.bash'; import { bash } from '../npmci.bash';
import { repo } from '../npmci.env'; import { repo } from '../npmci.env';
import { configObject } from '../npmci.config';
/** /**
* handle cli input * handle cli input
* @param argvArg * @param argvArg
@@ -15,10 +17,10 @@ export let handleCli = async argvArg => {
await mirror(); await mirror();
break; break;
default: default:
logger.log('error', `>>npmci git ...<< action >>${action}<< not supported`); logger.log('error', `npmci git -> action >>${action}<< not supported!`);
} }
} else { } else {
logger.log('info', `>>npmci git ...<< cli arguments invalid... Please read the documentation.`); logger.log('info', `npmci git -> cli arguments invalid! Please read the documentation.`);
} }
}; };
@@ -26,9 +28,22 @@ export let mirror = async () => {
const githubToken = process.env.NPMCI_GIT_GITHUBTOKEN; const githubToken = process.env.NPMCI_GIT_GITHUBTOKEN;
const githubUser = process.env.NPMCI_GIT_GITHUBGROUP || repo.user; const githubUser = process.env.NPMCI_GIT_GITHUBGROUP || repo.user;
const githubRepo = process.env.NPMCI_GIT_GITHUB || repo.repo; const githubRepo = process.env.NPMCI_GIT_GITHUB || repo.repo;
if (
configObject.projectInfo.npm.packageJson.private === true ||
configObject.npmAccessLevel === 'private'
) {
logger.log(
'warn',
`refusing to mirror due to private property use a private mirror location instead`
);
return;
}
if (githubToken) { if (githubToken) {
logger.log('info', 'found github token.'); logger.log('info', 'found github token.');
logger.log('info', 'attempting the mirror the repository to GitHub'); logger.log('info', 'attempting the mirror the repository to GitHub');
// plugins.smartgit.GitRepo;
// add the mirror // add the mirror
await bash( await bash(
`git remote add mirror https://${githubToken}@github.com/${githubUser}/${githubRepo}.git` `git remote add mirror https://${githubToken}@github.com/${githubUser}/${githubRepo}.git`

View File

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

View File

@@ -36,7 +36,7 @@ export let install = async versionArg => {
logger.log('info', `now installing node version ${versionArg}`); logger.log('info', `now installing node version ${versionArg}`);
let version: string; let version: string;
if (versionArg === 'stable') { if (versionArg === 'stable') {
version = '11'; version = '12';
} else if (versionArg === 'lts') { } else if (versionArg === 'lts') {
version = '10'; version = '10';
} else if (versionArg === 'legacy') { } else if (versionArg === 'legacy') {

View File

@@ -39,12 +39,17 @@ export let handleCli = async argvArg => {
const prepare = async () => { const prepare = async () => {
const config = await configModule.getConfig(); const config = await configModule.getConfig();
let npmrcFileString: string = ''; let npmrcFileString: string = '';
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 npmRegistryUrl = npmEnvArg.split('|')[0];
const npmToken = npmEnvArg.split('|')[1]; const npmToken = npmEnvArg.split('|')[1];
npmrcFileString = `//${npmRegistryUrl}/:_authToken="${npmToken}"\n`; npmrcFileString += `//${npmRegistryUrl}/:_authToken="${plugins.smartstring.base64.decode(
npmToken
)}"\n`;
}); });
logger.log('info', `setting default npm registry to ${config.npmRegistryUrl}`);
npmrcFileString += `registry=https://${config.npmRegistryUrl}\n`;
// final check
if (npmrcFileString.length > 0) { if (npmrcFileString.length > 0) {
logger.log('info', 'found one or more access tokens'); logger.log('info', 'found one or more access tokens');
} else { } else {
@@ -52,9 +57,8 @@ const prepare = async () => {
process.exit(1); process.exit(1);
} }
// lets save it to disk
plugins.smartfile.memory.toFsSync(npmrcFileString, '/root/.npmrc'); plugins.smartfile.memory.toFsSync(npmrcFileString, '/root/.npmrc');
logger.log('info', `setting default npm registry to ${config.npmRegistryUrl}`);
await bash(`npm set registry https://${config.npmRegistryUrl}`);
return; return;
}; };
@@ -62,25 +66,55 @@ const prepare = async () => {
* publish a package to npm * publish a package to npm
*/ */
const publish = async () => { const publish = async () => {
let npmAccessCliString = ``; const buildPublishCommand = async () => {
let npmRegistryCliString = ``; let npmAccessCliString = ``;
const config = await configModule.getConfig(); let npmRegistryCliString = ``;
let publishVerdaccioAsWell = false;
const config = await configModule.getConfig();
const availableRegistries: string[] = [];
await plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_TOKEN_NPM*', npmEnvArg => {
availableRegistries.push(npmEnvArg.split('|')[0]);
});
// -> configure package access level // -> configure package access level
if ( if (config.npmAccessLevel) {
config.npmAccessLevel && npmAccessCliString = `--access=${config.npmAccessLevel}`;
(config.npmAccessLevel === 'public' || config.npmAccessLevel === 'private') if (config.npmAccessLevel === 'public') {
) { publishVerdaccioAsWell = true;
npmAccessCliString = `--access=${config.npmAccessLevel}`; }
} } else {
throw new Error('You need to set a npmAccessLevel!!!');
}
// -> configure registry url
if (config.npmRegistryUrl) {
npmRegistryCliString = `--registry=https://${config.npmRegistryUrl}`;
} else {
logger.log('error', `no registry url specified. Can't publish!`);
process.exit(1);
}
// -> configure registry url let publishCommand = `npm publish ${npmAccessCliString} ${npmRegistryCliString} `;
if (config.npmRegistryUrl) {
npmAccessCliString = `--registry=https://${config.npmRegistryUrl}`; // publishEverywhere
} else { if (publishVerdaccioAsWell) {
logger.log('error', `no registry url specified. Can't publish!`); const verdaccioRegistry = availableRegistries.find(registryString =>
process.exit(1); registryString.startsWith('verdaccio')
} );
if (verdaccioRegistry) {
logger.log(
'info',
`package is public and verdaccio registry is specified. Also publishing to Verdaccio!`
);
publishCommand = `${publishCommand} && npm publish ${npmAccessCliString} --registry=https://${verdaccioRegistry}`;
} else {
logger.log(
'error',
`This package should also be published to Verdaccio, however there is no Verdaccio registry data available!`
);
}
}
return publishCommand;
};
// -> preparing // -> preparing
logger.log('info', `now preparing environment:`); logger.log('info', `now preparing environment:`);
@@ -101,7 +135,7 @@ const publish = async () => {
// -> publish it // -> publish it
logger.log('info', `now invoking npm to publish the package!`); logger.log('info', `now invoking npm to publish the package!`);
await bash(`npm publish ${npmAccessCliString} ${npmRegistryCliString}`); await bash(await buildPublishCommand());
logger.log('success', `Package was successfully published!`); logger.log('success', `Package was successfully published!`);
}; };

View File

@@ -6,7 +6,7 @@ const triggerValueRegex = /^([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)\|([a-zA-Z0-9\.]*)
export let trigger = async () => { export let trigger = async () => {
logger.log('info', 'now running triggers'); logger.log('info', 'now running triggers');
plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_TRIGGER_*', evaluateTrigger); await plugins.smartparam.forEachMinimatch(process.env, 'NPMCI_TRIGGER_*', evaluateTrigger);
}; };
const evaluateTrigger = async triggerEnvVarArg => { const evaluateTrigger = async triggerEnvVarArg => {

View File

@@ -5,12 +5,21 @@ import { repo } from './npmci.env';
import { KeyValueStore } from '@pushrocks/npmextra'; import { KeyValueStore } from '@pushrocks/npmextra';
/**
* the main config interface for npmci
*/
export interface INpmciOptions { export interface INpmciOptions {
projectInfo: plugins.projectinfo.ProjectInfo;
// npm
npmGlobalTools: string[]; npmGlobalTools: string[];
npmAccessLevel?: 'private' | 'public'; npmAccessLevel?: 'private' | 'public';
npmRegistryUrl?: string; npmRegistryUrl: string;
dockerRegistryRepoMap: any;
dockerBuildargEnvMap: any; // docker
dockerRegistries: string[];
dockerRegistryRepoMap: { [key: string]: string };
dockerBuildargEnvMap: { [key: string]: string };
} }
// instantiate a kvStorage for the current directory // instantiate a kvStorage for the current directory
@@ -19,8 +28,12 @@ export let kvStorage = new KeyValueStore('custom', `${repo.user}_${repo.repo}`);
// handle config retrival // handle config retrival
const npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd); const npmciNpmextra = new plugins.npmextra.Npmextra(paths.cwd);
const defaultConfig: INpmciOptions = { const defaultConfig: INpmciOptions = {
projectInfo: new plugins.projectinfo.ProjectInfo(paths.cwd),
npmGlobalTools: [], npmGlobalTools: [],
dockerRegistries: [],
dockerRegistryRepoMap: {}, dockerRegistryRepoMap: {},
npmAccessLevel: 'private',
npmRegistryUrl: 'registry.npmjs.org',
dockerBuildargEnvMap: {} dockerBuildargEnvMap: {}
}; };
export let configObject = npmciNpmextra.dataFor<INpmciOptions>('npmci', defaultConfig); export let configObject = npmciNpmextra.dataFor<INpmciOptions>('npmci', defaultConfig);

View File

@@ -2,7 +2,7 @@ import { logger } from './npmci.logging';
import * as plugins from './npmci.plugins'; import * as plugins from './npmci.plugins';
import * as env from './npmci.env'; import * as env from './npmci.env';
import { Analytics } from 'smartanalytics'; import { Analytics } from '@pushrocks/smartanalytics';
export let npmciAnalytics = new Analytics({ export let npmciAnalytics = new Analytics({
apiEndPoint: 'https://pubapi.lossless.one/analytics', apiEndPoint: 'https://pubapi.lossless.one/analytics',

View File

@@ -15,7 +15,7 @@ import * as smartparam from '@pushrocks/smartparam';
import * as smartpromise from '@pushrocks/smartpromise'; import * as smartpromise from '@pushrocks/smartpromise';
import * as smartrequest from '@pushrocks/smartrequest'; import * as smartrequest from '@pushrocks/smartrequest';
import * as smartshell from '@pushrocks/smartshell'; import * as smartshell from '@pushrocks/smartshell';
import * as smartsocket from 'smartsocket'; import * as smartsocket from '@pushrocks/smartsocket';
import * as smartssh from '@pushrocks/smartssh'; import * as smartssh from '@pushrocks/smartssh';
import * as smartstring from '@pushrocks/smartstring'; import * as smartstring from '@pushrocks/smartstring';
@@ -36,8 +36,6 @@ export {
smartstring smartstring
}; };
// third party
import * as lodash from 'lodash';
import * as through2 from 'through2'; import * as through2 from 'through2';
export { lodash, through2 }; export { through2 };