Compare commits

...

56 Commits

Author SHA1 Message Date
5d468fc840 3.0.57 2018-09-22 14:13:26 +02:00
e2ac6cdcc9 fix(dependencies): update 2018-09-22 14:13:25 +02:00
fcd04415be 3.0.56 2018-07-16 00:04:24 +02:00
1fd1899099 fix(ci): update to latest standards 2018-07-16 00:04:24 +02:00
7df7f882d1 3.0.55 2018-07-16 00:02:30 +02:00
348b4d60fd fix(security): snyk 2018-07-16 00:02:29 +02:00
37589fb5e5 3.0.54 2018-07-15 23:58:43 +02:00
3dd115fe42 fix(ci): adjust to newer build system 2018-07-15 23:58:43 +02:00
01c88a6a6c 3.0.53 2018-07-15 23:49:38 +02:00
f5cacb7400 fix(core): update 2018-07-15 23:49:37 +02:00
887da51d78 3.0.52 2018-07-02 23:15:25 +02:00
585703fc55 fix(core): switch to @pushrocks/smartpromise 2018-07-02 23:15:24 +02:00
ec3e296d73 3.0.51 2018-07-02 23:09:52 +02:00
33f234cf73 fix(core): update to latest standards 2018-07-02 23:09:52 +02:00
e7ec765ed5 3.0.50 2018-05-27 15:43:50 +02:00
2f46197864 fix(structure): removed .npmignore 2018-05-27 15:43:50 +02:00
da44233263 3.0.49 2018-05-27 15:41:58 +02:00
cb2430f7b2 fix(build): improved asset handling 2018-05-27 15:41:58 +02:00
5fe9134f4a 3.0.48 2018-05-27 14:34:42 +02:00
7681f09d38 feat(npm) switch to npm as default package manager 2018-05-27 14:34:38 +02:00
d55c77560a 3.0.47 2018-05-07 10:51:45 +02:00
0e337a3574 fix(ci): update .gitlab.yml to latest gitzone version 2018-05-07 10:51:45 +02:00
94c5567b75 3.0.46 2018-05-05 02:28:26 +02:00
7b37506d4e update .npmignore 2018-05-05 02:28:02 +02:00
a401633b73 3.0.45 2018-05-05 02:27:29 +02:00
948a8e64d7 3.0.44 2018-05-04 15:58:18 +02:00
9e8fbac573 update to better smartcli parsing 2018-05-04 15:58:11 +02:00
362740a55f 3.0.43 2018-05-04 00:48:32 +02:00
3edc08b0ed update snyk policy 2018-05-04 00:48:25 +02:00
15d7e6cbfc 3.0.42 2018-05-04 00:42:53 +02:00
6824210da0 3.0.41 2018-05-04 00:23:23 +02:00
41d2d04958 update dependencies 2018-05-04 00:23:21 +02:00
e490c6f730 3.0.40 2018-05-04 00:22:10 +02:00
bdf4815145 3.0.39 2018-05-03 23:52:55 +02:00
84fdf8b139 now cleans up before publishing 2018-05-03 23:52:51 +02:00
545896821d 3.0.38 2018-05-03 21:29:38 +02:00
c7516458bd update .gitignore 2018-05-03 21:29:35 +02:00
c2f92e63c5 3.0.37 2018-05-03 20:40:29 +02:00
d4116aefdb update npm 2018-05-03 20:40:26 +02:00
0f5f1f7772 3.0.36 2018-05-03 20:08:00 +02:00
7722187ea5 update ci 2018-05-03 20:07:49 +02:00
734a21c925 update publishing process 2018-05-03 19:56:38 +02:00
bb36beb682 3.0.35 2018-05-03 19:48:03 +02:00
3417ca83ed 3.0.34 2018-05-03 19:12:22 +02:00
dea6264c34 update ci 2018-05-03 19:12:17 +02:00
b6ca597ca5 3.0.33 2018-05-03 19:05:12 +02:00
1539d49426 update publish process 2018-05-03 19:05:09 +02:00
51fbc906a0 3.0.32 2018-04-29 17:40:18 +02:00
0e3732cade update 2018-04-29 17:40:14 +02:00
4f968472c8 update 2018-04-29 17:37:59 +02:00
68aa8d1302 3.0.31 2018-04-29 17:37:06 +02:00
cbfe992ffc update 2018-04-29 17:37:04 +02:00
6614b1c3d3 3.0.30 2018-04-29 16:37:38 +02:00
20fd6a8d7b update gitlab-ci 2018-04-29 16:37:33 +02:00
81eb0e252e 3.0.29 2018-04-29 16:32:37 +02:00
ac804886fa update publish step 2018-04-29 16:32:29 +02:00
23 changed files with 2439 additions and 2196 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@ coverage/
public/ public/
config.json config.json
.yarn/ .yarn/
.npmci_cache

View File

@@ -3,32 +3,39 @@ image: hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .yarn/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: "$CI_BUILD_STAGE"
stages: stages:
- security - security
- test - test
- release - release
- trigger - metadata
- pages
# ====================
# security stage
# ====================
mirror: mirror:
stage: security stage: security
script: script:
- npmci git mirror - npmci git mirror
tags: tags:
- docker - docker
- notpriv
snyk: snyk:
stage: security stage: security
script: script:
- npmci command yarn global add snyk - npmci command npm install -g snyk
- npmci command yarn install --ignore-scripts - npmci command npm install --ignore-scripts
- npmci command snyk test - npmci command snyk test
tags: tags:
- docker - docker
- notpriv
# ====================
# test stage
# ====================
testLEGACY: testLEGACY:
stage: test stage: test
script: script:
@@ -38,6 +45,7 @@ testLEGACY:
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
allow_failure: true allow_failure: true
testLTS: testLTS:
@@ -49,47 +57,86 @@ testLTS:
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
testSTABLE: testSTABLE:
stage: test stage: test
script: script:
- npmci node install lts - npmci node install stable
- npmci npm install - npmci npm install
- npmci npm test - npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
release: release:
stage: release stage: release
script: script:
- npmci npm prepare - npmci node install stable
- npmci npm publish - npmci npm publish
only: only:
- tags - tags
tags: tags:
- docker - docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--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:
- docker
- priv
trigger: trigger:
stage: trigger stage: metadata
script: script:
- npmci trigger - npmci trigger
only: only:
- tags - tags
tags: tags:
- docker - docker
- notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci image: hosttoday/ht-docker-node:npmci
stage: pages stage: metadata
script: script:
- npmci command yarn global add npmpage - npmci command npm install -g typedoc typescript
- npmci command npmpage - npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags: tags:
- docker - docker
- notpriv
only: only:
- tags - tags
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
paths: paths:
- public - public
allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true

View File

@@ -1,5 +0,0 @@
pages/
coverage/
test/
node_modules/
config.json

21
.snyk
View File

@@ -1,15 +1,28 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. # Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.10.2 version: v1.12.0
# ignores vulnerabilities until expiry date; change duration by modifying expiry date # ignores vulnerabilities until expiry date; change duration by modifying expiry date
ignore: ignore:
'npm:shelljs:20140723': 'npm:shelljs:20140723':
- shelljs: - shelljs:
reason: None given reason: None given
expires: '2018-05-04T20:41:54.426Z' expires: '2018-06-02T22:48:10.660Z'
- smartshell > shelljs: - smartshell > shelljs:
reason: None given reason: None given
expires: '2018-05-04T20:41:54.426Z' expires: '2018-06-02T22:48:10.660Z'
- smartssh > shelljs: - smartssh > shelljs:
reason: None given reason: None given
expires: '2018-05-04T20:41:54.426Z' expires: '2018-06-02T22:48:10.660Z'
- smartshell > shelljs:
reason: None given
expires: '2018-08-14T21:49:25.248Z'
- smartssh > shelljs:
reason: None given
expires: '2018-08-14T21:49:25.248Z'
- shelljs:
reason: None given
expires: '2018-08-14T21:49:25.248Z'
'npm:stringstream:20180511':
- request > stringstream:
reason: None given
expires: '2018-08-14T21:49:25.248Z'
patch: {} patch: {}

View File

@@ -1,100 +0,0 @@
# npmci
node and docker in gitlab ci on steroids
## Availabililty
[![npm](https://gitzone.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/npmci)
[![git](https://gitzone.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/gitzone/npmci)
[![git](https://gitzone.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/gitzone/npmci)
[![docs](https://gitzone.gitlab.io/assets/repo-button-docs.svg)](https://gitzone.gitlab.io/npmci/)
## Status for master
[![build status](https://GitLab.com/gitzone/npmci/badges/master/build.svg)](https://GitLab.com/gitzone/npmci/commits/master)
[![coverage report](https://GitLab.com/gitzone/npmci/badges/master/coverage.svg)](https://GitLab.com/gitzone/npmci/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/npmci.svg)](https://www.npmjs.com/package/npmci)
[![Dependency Status](https://david-dm.org/gitzonetools/npmci.svg)](https://david-dm.org/gitzonetools/npmci)
[![bitHound Dependencies](https://www.bithound.io/github/gitzonetools/npmci/badges/dependencies.svg)](https://www.bithound.io/github/gitzonetools/npmci/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/gitzonetools/npmci/badges/code.svg)](https://www.bithound.io/github/gitzonetools/npmci)
[![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
Use TypeScript for best in class instellisense.
npmci is designed to work in docker CI environments. The following docker images come with npmci presinstalled:
Docker Hub:
* [hosttoday/ht-docker-node:npmci](https://hub.docker.com/r/hosttoday/ht-docker-node/)
has LTS node version and npmci preinstalled.
* [hosttoday/ht-docker-dbase](https://hub.docker.com/r/hosttoday/ht-docker-dbase/)
based on docker:git, can be used to build docker images in conjunction with docker:dind
npmci can be called from commandline:
```shell
# Install any node version:
npmci install lts # will install latest LTS node version and update PATH for node and npm versions
npmci install stable # will install latest stable node version and update PATH for node and npm
npmci install legacy # will install latest legacy node version and update PATH for node and npm
npmci install x.x.x # will install any specific node version.
# Install any node version, install dependencies and run test in cwd:
npmci test lts # will install latest lts node version and run "npm install" and "npm test".
npmci test stable # will install latest stable node version and run "npm install" and "npm test".
npmci test legacy # will install latest legacy node version and run "npm install" and "npm test".
npmci test x.x.x # will install any specific node version and run "npm install" and "npm test".
npmci test docker # will test any build image with tests defined in ./npmci/dockertest_1.sh to ./npmci/dockertest_100.sh
## npmci test docker will look at all Dockerfiles and look for according tags on GitLab container registry
# prepare tools
npmci prepare npm # will look for $NPMCI_TOKEN_NPM env var and create .npmrc, so npm is authenticated
npmci prepare docker # will look for $NPMCI_LOGIN_DOCKER in form username|password and authenticate docker
npmci prepare docker-gitlab # will authenticate docker for gitlab container registry
# build containers
npmci build docker # will build containers
## all Dockerfiles named Dockerfile* are picked up.
## specify tags like this Dockerfile_[tag]
## uploads all built images as [username]/[reponame]:[tag]_test to GitLab
## then test in next step with "npmci test docker"
# publish npm module
npmci publish npm # will look vor $NPMCI_TOKEN_NPM env var and push any module in cwd to npm
npmci publish docker
# trigger webhooks
npmci trigger # will look for NPMCI_TRIGGER_1 to NPMCI_TRIGGER_100 in form domain|id|token|ref|name
```
## Configuration
npmci supports the use of npmextra.
To configure npmci create a `npmextra.json` file at the root of your project
```json
{
"npmci": {
"globalNpmTools": ["npm-check-updates", "protractor", "npmts", "gitzone"]
}
}
```
**Available options**
| setting | example | description |
| -------------- | ----------------------------- | ------------------------------------------------------------------------------------------------- |
| globalNpmTools | "globalNpmTools": ["gitbook"] | Will look for the specified package names locally and (if not yet present) install them from npm. |
For further information read the linked docs at the top of this README.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://gitzone.gitlab.io/assets/repo-footer.svg)](https://push.rocks)

View File

@@ -1,22 +0,0 @@
# SSH
npmci allows easy usage of ssh:
## Add the SSH KEY to the environment
To make npmci aware of any SSH KEY add it to the environment in the following format
```
# Key
NPMCI_SSHKEY_[A_NAME_FROM_YOU]
# Value:
[targeted host]|[privatekey as base64]|***
```
## Use npmci cli tool in your ci script
```
npmci prepare ssh
npmci command git remote add heroku ssh://git@heroku.com/[you project name].git
npmci command git push heroku master
```

View File

@@ -5,11 +5,8 @@
"cli": true "cli": true
}, },
"npmci": { "npmci": {
"globalNpmTools": [
"npmts"
],
"npmGlobalTools": [ "npmGlobalTools": [
"npmts" "@gitzone/npmts"
], ],
"npmAccessLevel": "public" "npmAccessLevel": "public"
}, },

2149
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "@shipzone/npmci", "name": "@shipzone/npmci",
"version": "3.0.28", "version": "3.0.57",
"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",
@@ -8,8 +8,8 @@
"npmci": "dist/cli.js" "npmci": "dist/cli.js"
}, },
"scripts": { "scripts": {
"test": "(rm -f config.json) && (npmts) && (npm run testVersion)", "test": "(rm -f config.json) && tstest test/",
"build": "(rm -f config.json) && (npmts) && (npm run testVersion)", "build": "(rm -f config.json) && tsbuild && (npm run testVersion)",
"testVersion": "(cd test/assets/ && node ../../dist/cli.js -v)" "testVersion": "(cd test/assets/ && node ../../dist/cli.js -v)"
}, },
"repository": { "repository": {
@@ -23,31 +23,34 @@
}, },
"homepage": "https://gitlab.com/gitzone/npmci#README", "homepage": "https://gitlab.com/gitzone/npmci#README",
"devDependencies": { "devDependencies": {
"tapbundle": "^2.0.0" "@gitzone/tsbuild": "^2.0.22",
"@gitzone/tsrun": "^1.1.12",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.10.3"
}, },
"dependencies": { "dependencies": {
"@types/lodash": "^4.14.74", "@pushrocks/lik": "^3.0.1",
"@types/shelljs": "^0.7.4", "@pushrocks/npmextra": "^3.0.1",
"@types/through2": "^2.0.33", "@pushrocks/projectinfo": "^4.0.2",
"@pushrocks/smartcli": "^3.0.4",
"@pushrocks/smartdelay": "^2.0.2",
"@pushrocks/smartfile": "^6.0.8",
"@pushrocks/smartparam": "^1.0.4",
"@pushrocks/smartpromise": "^2.0.5",
"@pushrocks/smartrequest": "^1.1.14",
"@pushrocks/smartshell": "^2.0.6",
"@pushrocks/smartssh": "^1.2.3",
"@pushrocks/smartstring": "^3.0.4",
"@types/lodash": "^4.14.116",
"@types/shelljs": "^0.8.0",
"@types/through2": "^2.0.34",
"beautylog": "^6.1.10", "beautylog": "^6.1.10",
"cflare": "^1.0.5", "cflare": "^1.0.5",
"lik": "^2.0.5", "lodash": "^4.17.11",
"lodash": "^4.17.4",
"npmextra": "^2.0.9",
"projectinfo": "^3.0.2",
"request": "^2.81.0",
"shelljs": "^0.8.1",
"smartanalytics": "^2.0.9", "smartanalytics": "^2.0.9",
"smartcli": "^2.0.7", "smartsocket": "^1.1.19",
"smartdelay": "^1.0.3",
"smartfile": "^4.2.20",
"smartparam": "^1.0.2",
"smartq": "^1.1.6",
"smartshell": "^1.0.18",
"smartsocket": "^1.1.10",
"smartssh": "^1.2.2",
"smartstring": "^2.0.24",
"smartsystem": "^2.0.2",
"through2": "^2.0.3" "through2": "^2.0.3"
} },
"private": false
} }

View File

@@ -25,6 +25,79 @@ node and docker in gitlab ci on steroids
Use TypeScript for best in class instellisense. Use TypeScript for best in class instellisense.
npmci is designed to work in docker CI environments. The following docker images come with npmci presinstalled:
Docker Hub:
- [hosttoday/ht-docker-node:npmci](https://hub.docker.com/r/hosttoday/ht-docker-node/)
has LTS node version and npmci preinstalled.
- [hosttoday/ht-docker-dbase](https://hub.docker.com/r/hosttoday/ht-docker-dbase/)
based on docker:git, can be used to build docker images in conjunction with docker:dind
npmci can be called from commandline and handle a lot of tasks durug ci:
```shell
# Handle node versions
npmci node install stable # will install latest stable node version and update PATH for node and npm
npmci node install lts # will install latest LTS node version and update PATH for node and npm versions
npmci node install legacy # will install latest legacy node version and update PATH for node and npm
npmci node install x.x.x # will install any specific node version.
# Handle npm and yarn tasks
npmcu npm login # logs in npm using the auth key provided at env var "NPMCI_TOKEN_NPM"
npmci npm install # installs dependencies using npm or yarn dependending on availablity
npmci npm test # tests the package
npmci npm publish # builds a package and publishes it
# handle docker tasks
npmci docker prepare
## npmci test docker will look at all Dockerfiles and look for according tags on GitLab container registry
# prepare tools
npmci prepare npm # will look for $NPMCI_TOKEN_NPM env var and create .npmrc, so npm is authenticated
npmci prepare docker # will look for $NPMCI_LOGIN_DOCKER in form username|password and authenticate docker
npmci prepare docker-gitlab # will authenticate docker for gitlab container registry
# build containers
npmci docker build # will build containers
## all Dockerfiles named Dockerfile* are picked up.
## specify tags like this Dockerfile_[tag]
## uploads all built images as [username]/[reponame]:[tag]_test to GitLab
## then test in next step with "npmci test docker"
# publish npm module
npmci publish npm # will look vor $NPMCI_TOKEN_NPM env var and push any module in cwd to npm
npmci publish docker
# trigger webhooks
npmci trigger # will look for NPMCI_TRIGGER_1 to NPMCI_TRIGGER_100 in form domain|id|token|ref|name
```
## Configuration
npmci supports the use of npmextra.
To configure npmci create a `npmextra.json` file at the root of your project
```json
{
"npmci": {
"globalNpmTools": ["npm-check-updates", "protractor", "npmts", "gitzone"]
}
}
```
**Available options**
| setting | example | description |
| -------------- | ----------------------------- | ------------------------------------------------------------------------------------------------- |
| globalNpmTools | "globalNpmTools": ["gitbook"] | Will look for the specified package names locally and (if not yet present) install them from npm. |
For further information read the linked docs at the top of this README.
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)

View File

@@ -1,4 +1,4 @@
import { tap, expect } from 'tapbundle'; import { tap, expect } from '@pushrocks/tapbundle';
import * as path from 'path'; import * as path from 'path';
// Setup test // Setup test

View File

@@ -1,31 +0,0 @@
import * as plugins from './mod.plugins';
let npmciCflare = new plugins.cflare.CflareAccount();
/**
* handle cli input
* @param argvArg
*/
export let handleCli = async argvArg => {
if (argvArg._.length >= 2) {
let action: string = argvArg._[1];
switch (action) {
default:
plugins.beautylog.error(`>>npmci cloudflare ...<< action >>${action}<< not supported`);
process.exit(1);
}
} else {
plugins.beautylog.log(
`>>npmci cloudflare ...<< cli arguments invalid... Please read the documentation.`
);
process.exit(1);
}
};
export let purge = async argvArg => {
npmciCflare.auth({
email: '',
key: ''
});
npmciCflare.purgeZone(argvArg._[1]);
};

View File

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

View File

@@ -34,7 +34,7 @@ export let readDockerfiles = async (): Promise<Dockerfile[]> => {
* @returns Promise<Dockerfile[]> * @returns Promise<Dockerfile[]>
*/ */
export let sortDockerfiles = (sortableArrayArg: Dockerfile[]): Promise<Dockerfile[]> => { export let sortDockerfiles = (sortableArrayArg: Dockerfile[]): Promise<Dockerfile[]> => {
let done = plugins.q.defer<Dockerfile[]>(); let done = plugins.smartpromise.defer<Dockerfile[]>();
plugins.beautylog.info('sorting Dockerfiles:'); plugins.beautylog.info('sorting Dockerfiles:');
let sortedArray: Dockerfile[] = []; let sortedArray: Dockerfile[] = [];
let cleanTagsOriginal = cleanTagsArrayFunction(sortableArrayArg, sortedArray); let cleanTagsOriginal = cleanTagsArrayFunction(sortableArrayArg, sortedArray);

View File

@@ -1,6 +1,7 @@
import * as plugins from '../npmci.plugins'; import * as plugins from '../npmci.plugins';
import * as paths from '../npmci.paths';
import * as npmciConfig from '../npmci.config'; import * as npmciConfig from '../npmci.config';
import { bash, bashNoError, nvmAvailable, yarnAvailable } from '../npmci.bash'; import { bash, bashNoError, nvmAvailable } from '../npmci.bash';
/** /**
* handle cli input * handle cli input
@@ -33,11 +34,11 @@ export let install = async versionArg => {
plugins.beautylog.log(`now installing node version ${versionArg}`); plugins.beautylog.log(`now installing node version ${versionArg}`);
let version: string; let version: string;
if (versionArg === 'stable') { if (versionArg === 'stable') {
version = '9'; version = '10';
} else if (versionArg === 'lts') { } else if (versionArg === 'lts') {
version = '8'; version = '8';
} else if (versionArg === 'legacy') { } else if (versionArg === 'legacy') {
version = '8'; version = '9';
} else { } else {
version = versionArg; version = versionArg;
} }
@@ -49,6 +50,7 @@ export let install = async versionArg => {
} }
await bash('node -v'); await bash('node -v');
await bash('npm -v'); await bash('npm -v');
await bash(`npm config set cache ${paths.NpmciCacheDir} --global `);
// lets look for further config // lets look for further config
await npmciConfig.getConfig().then(async configArg => { await npmciConfig.getConfig().then(async configArg => {
plugins.beautylog.log('Now checking for needed global npm tools...'); plugins.beautylog.log('Now checking for needed global npm tools...');
@@ -60,11 +62,7 @@ export let install = async versionArg => {
plugins.beautylog.log(`Tool ${npmTool} is available`); plugins.beautylog.log(`Tool ${npmTool} is available`);
} else { } else {
plugins.beautylog.info(`globally installing ${npmTool} from npm`); plugins.beautylog.info(`globally installing ${npmTool} from npm`);
if (await yarnAvailable.promise) { await bash(`npm install ${npmTool} -q -g`);
await bash(`yarn global add ${npmTool}`);
} else {
await bash(`npm install ${npmTool} -q -g`);
}
} }
} }
plugins.beautylog.success('all global npm tools specified in npmextra.json are now available!'); plugins.beautylog.success('all global npm tools specified in npmextra.json are now available!');

View File

@@ -1,6 +1,6 @@
import * as plugins from './mod.plugins'; import * as plugins from './mod.plugins';
import * as configModule from '../npmci.config'; import * as configModule from '../npmci.config';
import { bash, bashNoError, nvmAvailable, yarnAvailable } from '../npmci.bash'; import { bash, bashNoError, nvmAvailable } from '../npmci.bash';
/** /**
* handle cli input * handle cli input
@@ -66,26 +66,35 @@ let publish = async () => {
npmAccessCliString = `--access=${config.npmAccessLevel}`; npmAccessCliString = `--access=${config.npmAccessLevel}`;
} }
// -> build it // -> preparing
await bash(`yarn run build`); plugins.beautylog.log(`now preparing environment:`);
// -> make sure npm is authenticated
prepare(); prepare();
await bash(`npm -v`);
// -> build it
await bash(`npm install`);
await bash(`npm run build`);
plugins.beautylog.success(`Nice!!! The build for the publication was successfull!`);
plugins.beautylog.log(`Lets clean up so we don't publish any packages that don't belong to us:`);
// -> clean up before we publish stuff
await bashNoError(`rm -r ./.npmci_cache`);
await bash(`rm -r ./node_modules`);
plugins.beautylog.success(`Cleaned up!:`);
// -> publish it // -> publish it
plugins.beautylog.log(`now invoking npm to publish the package!`);
await bash(`npm publish ${npmAccessCliString}`); await bash(`npm publish ${npmAccessCliString}`);
plugins.beautylog.success(`Package was successfully published!`);
}; };
let install = async (): Promise<void> => { let install = async (): Promise<void> => {
plugins.beautylog.info('now installing dependencies:'); plugins.beautylog.info('now installing dependencies:');
if (await yarnAvailable.promise) { await bash('npm install');
await bash('yarn install');
} else {
await bash('npm install');
}
}; };
export let test = async (): Promise<void> => { export let test = async (): Promise<void> => {
plugins.beautylog.info('now starting tests:'); plugins.beautylog.info('now starting tests:');
await bash('yarn test'); await bash('npm test');
}; };

View File

@@ -1,13 +1,12 @@
import * as plugins from './npmci.plugins'; import * as plugins from './npmci.plugins';
import * as paths from './npmci.paths'; import * as paths from './npmci.paths';
import * as smartq from 'smartq'; import * as smartpromise from '@pushrocks/smartpromise';
/** /**
* wether nvm is available or not * wether nvm is available or not
*/ */
export let nvmAvailable = smartq.defer<boolean>(); export let nvmAvailable = smartpromise.defer<boolean>();
export let yarnAvailable = smartq.defer<boolean>();
/** /**
* the smartshell instance for npmci * the smartshell instance for npmci
*/ */
@@ -23,34 +22,20 @@ let checkToolsAvailable = async () => {
// check for nvm // check for nvm
if (!process.env.NPMTS_TEST) { if (!process.env.NPMTS_TEST) {
if ( if (
(await plugins.smartshell.execSilent(`bash -c "source /usr/local/nvm/nvm.sh"`)).exitCode === 0 (await npmciSmartshell.execSilent(`bash -c "source /usr/local/nvm/nvm.sh"`)).exitCode === 0
) { ) {
npmciSmartshell.addSourceFiles([`/usr/local/nvm/nvm.sh`]); npmciSmartshell.shellEnv.addSourceFiles([`/usr/local/nvm/nvm.sh`]);
nvmAvailable.resolve(true); nvmAvailable.resolve(true);
} else if ( } else if (
(await plugins.smartshell.execSilent(`bash -c "source ~/.nvm/nvm.sh"`)).exitCode === 0 (await npmciSmartshell.execSilent(`bash -c "source ~/.nvm/nvm.sh"`)).exitCode === 0
) { ) {
npmciSmartshell.addSourceFiles([`~/.nvm/nvm.sh`]); npmciSmartshell.shellEnv.addSourceFiles([`~/.nvm/nvm.sh`]);
nvmAvailable.resolve(true); nvmAvailable.resolve(true);
} else { } else {
nvmAvailable.resolve(false); nvmAvailable.resolve(false);
} }
// check for yarn
await plugins.smartshell.which('yarn').then(
async () => {
await plugins.smartshell.exec(
`yarn config set cache-folder ${plugins.path.join(paths.cwd, '.yarn')}`
);
yarnAvailable.resolve(true);
},
() => {
yarnAvailable.resolve(false);
}
);
} else { } else {
nvmAvailable.resolve(true); nvmAvailable.resolve(true);
yarnAvailable.resolve(true);
} }
}; };
checkToolsAvailable(); checkToolsAvailable();

View File

@@ -9,114 +9,102 @@ plugins.beautylog.log('npmci version: ' + npmciInfo.version);
import * as NpmciEnv from './npmci.env'; import * as NpmciEnv from './npmci.env';
import * as npmciMods from './npmci.mods'; const npmciSmartcli = new plugins.smartcli.Smartcli();
npmciSmartcli.addVersion(npmciInfo.version);
let smartcli = new plugins.smartcli.Smartcli();
smartcli.addVersion(npmciInfo.version);
// clean // clean
smartcli npmciSmartcli.addCommand('clean').subscribe(
.addCommand('clean') async argv => {
.then(async argv => { let modClean = await import('./mod_clean/index');
let modClean = await npmciMods.modClean.load();
await modClean.clean(); await modClean.clean();
}) },
.catch(err => { err => {
console.log(err); console.log(err);
process.exit(1); process.exit(1);
}); }
);
// cloudflare
smartcli
.addCommand('cloudflare')
.then(async argvArg => {
let modPurge = await npmciMods.modCloudflare.load();
await modPurge.handleCli(argvArg);
})
.catch(err => {
console.log(err);
});
// command // command
smartcli npmciSmartcli.addCommand('command').subscribe(
.addCommand('command') async argv => {
.then(async argv => { let modCommand = await import('./mod_command/index');
let modCommand = await npmciMods.modCommand.load();
await modCommand.command(); await modCommand.command();
}) },
.catch(err => { err => {
console.log(err); console.log(err);
process.exit(1); process.exit(1);
}); }
);
// command // command
smartcli npmciSmartcli.addCommand('git').subscribe(
.addCommand('git') async argvArg => {
.then(async argvArg => { let modGit = await import('./mod_git/index');
let modGit = await npmciMods.modGit.load();
await modGit.handleCli(argvArg); await modGit.handleCli(argvArg);
}) },
.catch(err => { err => {
console.log(err); console.log(err);
process.exit(1); process.exit(1);
}); }
);
// build // build
smartcli npmciSmartcli.addCommand('docker').subscribe(
.addCommand('docker') async argvArg => {
.then(async argvArg => { let modDocker = await import('./mod_docker/index');
let modDocker = await npmciMods.modDocker.load();
await modDocker.handleCli(argvArg); await modDocker.handleCli(argvArg);
}) },
.catch(err => { err => {
console.log(err); console.log(err);
process.exit(1); process.exit(1);
}); }
);
// node // node
smartcli npmciSmartcli.addCommand('node').subscribe(
.addCommand('node') async argvArg => {
.then(async argvArg => { let modNode = await import('./mod_node/index');
let modNode = await npmciMods.modNode.load();
await modNode.handleCli(argvArg); await modNode.handleCli(argvArg);
}) },
.catch(err => { err => {
console.log(err); console.log(err);
}); process.exit(1);
}
);
// npm // npm
smartcli npmciSmartcli.addCommand('npm').subscribe(
.addCommand('npm') async argvArg => {
.then(async argvArg => { let modNpm = await import('./mod_npm/index');
let modNpm = await npmciMods.modNpm.load();
await modNpm.handleCli(argvArg); await modNpm.handleCli(argvArg);
}) },
.catch(err => { err => {
console.log(err); console.log(err);
}); }
);
// trigger // trigger
smartcli npmciSmartcli.addCommand('ssh').subscribe(
.addCommand('ssh') async argvArg => {
.then(async argvArg => { let modSsh = await import('./mod_ssh/index');
let modSsh = await npmciMods.modSsh.load();
await modSsh.handleCli(argvArg); await modSsh.handleCli(argvArg);
}) },
.catch(err => { err => {
console.log(err); console.log(err);
process.exit(1); process.exit(1);
}); }
);
// trigger // trigger
smartcli npmciSmartcli.addCommand('trigger').subscribe(
.addCommand('trigger') async argv => {
.then(async argv => { let modTrigger = await import('./mod_trigger/index');
let modTrigger = await npmciMods.modTrigger.load();
await modTrigger.trigger(); await modTrigger.trigger();
}) },
.catch(err => { err => {
console.log(err); console.log(err);
process.exit(1); process.exit(1);
}); }
);
smartcli.startParse(); npmciSmartcli.startParse();

View File

@@ -5,7 +5,7 @@ import * as paths from './npmci.paths';
import { repo } from './npmci.env'; import { repo } from './npmci.env';
import { KeyValueStore } from 'npmextra'; import { KeyValueStore } from '@pushrocks/npmextra';
export interface INpmciOptions { export interface INpmciOptions {
npmGlobalTools: string[]; npmGlobalTools: string[];

View File

@@ -1,24 +0,0 @@
import * as _modClean from './mod_clean/index';
import * as _modCloudflare from './mod_cloudflare/index';
import * as _modCommand from './mod_command/index';
import * as _modDocker from './mod_docker/index';
import * as _modGit from './mod_git/index';
import * as _modNpm from './mod_npm/index';
import * as _modNode from './mod_node/index';
import * as _modSsh from './mod_ssh/index';
import * as _modTrigger from './mod_trigger/index';
import { LazyModule } from 'smartsystem';
export let modClean = new LazyModule<typeof _modClean>('./mod_clean/index', __dirname);
export let modCloudflare = new LazyModule<typeof _modCloudflare>(
'./mod_cloudflare/index',
__dirname
);
export let modCommand = new LazyModule<typeof _modCommand>('./mod_command/index', __dirname);
export let modGit = new LazyModule<typeof _modGit>('./mod_git/index', __dirname);
export let modDocker = new LazyModule<typeof _modDocker>('./mod_docker/index', __dirname);
export let modNode = new LazyModule<typeof _modNode>('./mod_node/index', __dirname);
export let modNpm = new LazyModule<typeof _modNpm>('./mod_npm/index', __dirname);
export let modSsh = new LazyModule<typeof _modSsh>('./mod_ssh/index', __dirname);
export let modTrigger = new LazyModule<typeof _modTrigger>('./mod_trigger/index', __dirname);

View File

@@ -6,3 +6,4 @@ export let NpmciPackageRoot = plugins.path.join(__dirname, '../');
export let NpmciPackageConfig = plugins.path.join(NpmciPackageRoot, './config.json'); export let NpmciPackageConfig = plugins.path.join(NpmciPackageRoot, './config.json');
export let NpmciProjectDir = cwd; export let NpmciProjectDir = cwd;
export let NpmciTestDir = plugins.path.join(cwd, './test'); export let NpmciTestDir = plugins.path.join(cwd, './test');
export let NpmciCacheDir = plugins.path.join(cwd, './.npmci_cache');

View File

@@ -1,19 +1,21 @@
export import beautylog = require('beautylog'); // node native
export import lodash = require('lodash');
export import npmextra = require('npmextra');
export import path = require('path'); export import path = require('path');
export import projectinfo = require('projectinfo');
export import q = require('smartq'); // @pushrocks
export let request = require('request'); export import beautylog = require('beautylog');
export import smartcli = require('smartcli'); export import projectinfo = require('@pushrocks/projectinfo');
export import smartdelay = require('smartdelay'); export import npmextra = require('@pushrocks/npmextra');
export import smartfile = require('smartfile'); export import smartdelay = require('@pushrocks/smartdelay');
export import shelljs = require('shelljs'); export import smartfile = require('@pushrocks/smartfile');
export import smartcli = require('@pushrocks/smartcli');
export import smartparam = require('smartparam'); export import smartparam = require('smartparam');
export import smartq = require('smartq'); export import smartpromise = require('@pushrocks/smartpromise');
export import smartshell = require('smartshell'); export import smartshell = require('@pushrocks/smartshell');
export import smartsocket = require('smartsocket'); export import smartsocket = require('smartsocket');
export import smartsystem = require('smartsystem'); export import smartssh = require('@pushrocks/smartssh');
export import smartssh = require('smartssh'); export import smartstring = require('@pushrocks/smartstring');
export import smartstring = require('smartstring');
// third party
export import lodash = require('lodash');
export import through2 = require('through2'); export import through2 = require('through2');
export import request = require('@pushrocks/smartrequest');

1836
yarn.lock

File diff suppressed because it is too large Load Diff