Compare commits
	
		
			45 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| fcd04415be | |||
| 1fd1899099 | |||
| 7df7f882d1 | |||
| 348b4d60fd | |||
| 37589fb5e5 | |||
| 3dd115fe42 | |||
| 01c88a6a6c | |||
| f5cacb7400 | |||
| 887da51d78 | |||
| 585703fc55 | |||
| ec3e296d73 | |||
| 33f234cf73 | |||
| e7ec765ed5 | |||
| 2f46197864 | |||
| da44233263 | |||
| cb2430f7b2 | |||
| 5fe9134f4a | |||
| 7681f09d38 | |||
| d55c77560a | |||
| 0e337a3574 | |||
| 94c5567b75 | |||
| 7b37506d4e | |||
| a401633b73 | |||
| 948a8e64d7 | |||
| 9e8fbac573 | |||
| 362740a55f | |||
| 3edc08b0ed | |||
| 15d7e6cbfc | |||
| 6824210da0 | |||
| 41d2d04958 | |||
| e490c6f730 | |||
| bdf4815145 | |||
| 84fdf8b139 | |||
| 545896821d | |||
| c7516458bd | |||
| c2f92e63c5 | |||
| d4116aefdb | |||
| 0f5f1f7772 | |||
| 7722187ea5 | |||
| 734a21c925 | |||
| bb36beb682 | |||
| 3417ca83ed | |||
| dea6264c34 | |||
| b6ca597ca5 | |||
| 1539d49426 | 
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -4,3 +4,4 @@ coverage/ | ||||
| public/ | ||||
| config.json | ||||
| .yarn/ | ||||
| .npmci_cache | ||||
|   | ||||
| @@ -3,32 +3,39 @@ image: hosttoday/ht-docker-node:npmci | ||||
|  | ||||
| cache: | ||||
|   paths: | ||||
|   - .yarn/ | ||||
|   - .npmci_cache/ | ||||
|   key: "$CI_BUILD_STAGE" | ||||
|  | ||||
| stages: | ||||
| - security | ||||
| - test | ||||
| - release | ||||
| - trigger | ||||
| - pages | ||||
| - metadata | ||||
|  | ||||
| # ==================== | ||||
| # security stage | ||||
| # ==================== | ||||
| mirror: | ||||
|   stage: security | ||||
|   script: | ||||
|   - npmci git mirror | ||||
|   tags: | ||||
|   - docker | ||||
|   - notpriv | ||||
|  | ||||
| snyk: | ||||
|   stage: security | ||||
|   script: | ||||
|     - npmci command yarn global add snyk | ||||
|     - npmci command yarn install --ignore-scripts | ||||
|     - npmci command npm install -g snyk | ||||
|     - npmci command npm install --ignore-scripts | ||||
|     - npmci command snyk test | ||||
|   tags: | ||||
|   - docker | ||||
|   - notpriv | ||||
|  | ||||
| # ==================== | ||||
| # test stage | ||||
| # ==================== | ||||
| testLEGACY: | ||||
|   stage: test | ||||
|   script: | ||||
| @@ -38,6 +45,7 @@ testLEGACY: | ||||
|   coverage: /\d+.?\d+?\%\s*coverage/ | ||||
|   tags: | ||||
|   - docker | ||||
|   - notpriv | ||||
|   allow_failure: true | ||||
|  | ||||
| testLTS: | ||||
| @@ -49,6 +57,7 @@ testLTS: | ||||
|   coverage: /\d+.?\d+?\%\s*coverage/ | ||||
|   tags: | ||||
|   - docker | ||||
|   - notpriv | ||||
|      | ||||
| testSTABLE: | ||||
|   stage: test | ||||
| @@ -59,37 +68,75 @@ testSTABLE: | ||||
|   coverage: /\d+.?\d+?\%\s*coverage/ | ||||
|   tags: | ||||
|   - docker | ||||
|   - notpriv | ||||
|  | ||||
| release: | ||||
|   stage: release | ||||
|   script: | ||||
|   - npmci npm prepare | ||||
|   - npmci node install stable | ||||
|   - npmci npm publish | ||||
|   only: | ||||
|   - tags | ||||
|   tags: | ||||
|   - 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: | ||||
|   stage: trigger | ||||
|   stage: metadata | ||||
|   script: | ||||
|   - npmci trigger | ||||
|   only: | ||||
|   - tags | ||||
|   tags: | ||||
|   - docker | ||||
|   - notpriv | ||||
|  | ||||
| pages: | ||||
|   image: hosttoday/ht-docker-node:npmci | ||||
|   stage: pages | ||||
|   stage: metadata | ||||
|   script: | ||||
|     - npmci command yarn global add npmpage | ||||
|     - npmci command npmpage | ||||
|     - npmci command npm install -g typedoc typescript | ||||
|     - npmci npm install | ||||
|     - npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/ | ||||
|   tags: | ||||
|     - docker | ||||
|     - notpriv | ||||
|   only: | ||||
|     - tags | ||||
|   artifacts: | ||||
|     expire_in: 1 week | ||||
|     paths: | ||||
|     - 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 | ||||
|   | ||||
| @@ -1,5 +0,0 @@ | ||||
| pages/ | ||||
| coverage/ | ||||
| test/ | ||||
| node_modules/ | ||||
| config.json | ||||
							
								
								
									
										21
									
								
								.snyk
									
									
									
									
									
								
							
							
						
						
									
										21
									
								
								.snyk
									
									
									
									
									
								
							| @@ -1,15 +1,28 @@ | ||||
| # 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 | ||||
| ignore: | ||||
|   'npm:shelljs:20140723': | ||||
|     - shelljs: | ||||
|         reason: None given | ||||
|         expires: '2018-05-04T20:41:54.426Z' | ||||
|         expires: '2018-06-02T22:48:10.660Z' | ||||
|     - smartshell > shelljs: | ||||
|         reason: None given | ||||
|         expires: '2018-05-04T20:41:54.426Z' | ||||
|         expires: '2018-06-02T22:48:10.660Z' | ||||
|     - smartssh > shelljs: | ||||
|         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: {} | ||||
|   | ||||
							
								
								
									
										100
									
								
								docs/index.md
									
									
									
									
									
								
							
							
						
						
									
										100
									
								
								docs/index.md
									
									
									
									
									
								
							| @@ -1,100 +0,0 @@ | ||||
| # npmci | ||||
|  | ||||
| node and docker in gitlab ci on steroids | ||||
|  | ||||
| ## Availabililty | ||||
|  | ||||
| [](https://www.npmjs.com/package/npmci) | ||||
| [](https://GitLab.com/gitzone/npmci) | ||||
| [](https://github.com/gitzone/npmci) | ||||
| [](https://gitzone.gitlab.io/npmci/) | ||||
|  | ||||
| ## Status for master | ||||
|  | ||||
| [](https://GitLab.com/gitzone/npmci/commits/master) | ||||
| [](https://GitLab.com/gitzone/npmci/commits/master) | ||||
| [](https://www.npmjs.com/package/npmci) | ||||
| [](https://david-dm.org/gitzonetools/npmci) | ||||
| [](https://www.bithound.io/github/gitzonetools/npmci/master/dependencies/npm) | ||||
| [](https://www.bithound.io/github/gitzonetools/npmci) | ||||
| [](https://nodejs.org/dist/latest-v6.x/docs/api/) | ||||
| [](https://nodejs.org/dist/latest-v6.x/docs/api/) | ||||
| [](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) | ||||
|  | ||||
| [](https://push.rocks) | ||||
							
								
								
									
										22
									
								
								docs/ssh.md
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								docs/ssh.md
									
									
									
									
									
								
							| @@ -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 | ||||
| ``` | ||||
| @@ -5,11 +5,8 @@ | ||||
|         "cli": true | ||||
|     }, | ||||
|     "npmci": { | ||||
|         "globalNpmTools": [ | ||||
|             "npmts" | ||||
|         ], | ||||
|         "npmGlobalTools": [ | ||||
|             "npmts" | ||||
|             "@gitzone/npmts" | ||||
|         ], | ||||
|         "npmAccessLevel": "public" | ||||
|     }, | ||||
|   | ||||
							
								
								
									
										2500
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										2500
									
								
								package-lock.json
									
									
									
										generated
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										36
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								package.json
									
									
									
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "@shipzone/npmci", | ||||
|   "version": "3.0.32", | ||||
|   "version": "3.0.56", | ||||
|   "description": "node and docker in gitlab ci on steroids", | ||||
|   "main": "dist/index.js", | ||||
|   "typings": "dist/index.d.ts", | ||||
| @@ -8,7 +8,7 @@ | ||||
|     "npmci": "dist/cli.js" | ||||
|   }, | ||||
|   "scripts": { | ||||
|     "test": "(rm -f config.json) && (npmts) && (npm run testVersion)", | ||||
|     "test": "(rm -f config.json) && tsrun test/test.ts", | ||||
|     "build": "(rm -f config.json) && (npmts) && (npm run testVersion)", | ||||
|     "testVersion": "(cd test/assets/ && node ../../dist/cli.js -v)" | ||||
|   }, | ||||
| @@ -23,31 +23,33 @@ | ||||
|   }, | ||||
|   "homepage": "https://gitlab.com/gitzone/npmci#README", | ||||
|   "devDependencies": { | ||||
|     "tapbundle": "^2.0.0" | ||||
|     "@gitzone/tsrun": "^1.1.9", | ||||
|     "@pushrocks/tapbundle": "^3.0.1" | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@types/lodash": "^4.14.74", | ||||
|     "@types/shelljs": "^0.7.4", | ||||
|     "@pushrocks/smartcli": "^3.0.2", | ||||
|     "@pushrocks/smartdelay": "^2.0.1", | ||||
|     "@pushrocks/smartfile": "^6.0.3", | ||||
|     "@pushrocks/smartpromise": "^2.0.5", | ||||
|     "@types/lodash": "^4.14.112", | ||||
|     "@types/shelljs": "^0.8.0", | ||||
|     "@types/through2": "^2.0.33", | ||||
|     "beautylog": "^6.1.10", | ||||
|     "cflare": "^1.0.5", | ||||
|     "lik": "^2.0.5", | ||||
|     "lodash": "^4.17.4", | ||||
|     "lodash": "^4.17.10", | ||||
|     "npmextra": "^2.0.9", | ||||
|     "projectinfo": "^3.0.2", | ||||
|     "request": "^2.81.0", | ||||
|     "shelljs": "^0.8.1", | ||||
|     "projectinfo": "^3.0.4", | ||||
|     "request": "^2.87.0", | ||||
|     "shelljs": "^0.8.2", | ||||
|     "smartanalytics": "^2.0.9", | ||||
|     "smartcli": "^2.0.7", | ||||
|     "smartdelay": "^1.0.3", | ||||
|     "smartfile": "^4.2.20", | ||||
|     "smartparam": "^1.0.2", | ||||
|     "smartq": "^1.1.6", | ||||
|     "smartshell": "^1.0.18", | ||||
|     "smartsocket": "^1.1.10", | ||||
|     "smartshell": "^1.0.19", | ||||
|     "smartsocket": "^1.1.19", | ||||
|     "smartssh": "^1.2.2", | ||||
|     "smartstring": "^2.0.24", | ||||
|     "smartstring": "^2.0.28", | ||||
|     "smartsystem": "^2.0.2", | ||||
|     "through2": "^2.0.3" | ||||
|   } | ||||
|   }, | ||||
|   "private": false | ||||
| } | ||||
|   | ||||
							
								
								
									
										73
									
								
								readme.md
									
									
									
									
									
								
							
							
						
						
									
										73
									
								
								readme.md
									
									
									
									
									
								
							| @@ -25,6 +25,79 @@ node and docker in gitlab ci on steroids | ||||
|  | ||||
| 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. | ||||
|  | ||||
| > MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import { tap, expect } from 'tapbundle'; | ||||
| import { tap, expect } from '@pushrocks/tapbundle'; | ||||
| import * as path from 'path'; | ||||
|  | ||||
| // Setup test | ||||
|   | ||||
| @@ -34,7 +34,7 @@ export let readDockerfiles = async (): Promise<Dockerfile[]> => { | ||||
|  * @returns 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:'); | ||||
|   let sortedArray: Dockerfile[] = []; | ||||
|   let cleanTagsOriginal = cleanTagsArrayFunction(sortableArrayArg, sortedArray); | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| import * as plugins from '../npmci.plugins'; | ||||
| import * as paths from '../npmci.paths'; | ||||
| import * as npmciConfig from '../npmci.config'; | ||||
| import { bash, bashNoError, nvmAvailable, yarnAvailable } from '../npmci.bash'; | ||||
| import { bash, bashNoError, nvmAvailable } from '../npmci.bash'; | ||||
|  | ||||
| /** | ||||
|  * handle cli input | ||||
| @@ -33,11 +34,11 @@ export let install = async versionArg => { | ||||
|   plugins.beautylog.log(`now installing node version ${versionArg}`); | ||||
|   let version: string; | ||||
|   if (versionArg === 'stable') { | ||||
|     version = '9'; | ||||
|     version = '10'; | ||||
|   } else if (versionArg === 'lts') { | ||||
|     version = '8'; | ||||
|   } else if (versionArg === 'legacy') { | ||||
|     version = '8'; | ||||
|     version = '9'; | ||||
|   } else { | ||||
|     version = versionArg; | ||||
|   } | ||||
| @@ -49,6 +50,7 @@ export let install = async versionArg => { | ||||
|   } | ||||
|   await bash('node -v'); | ||||
|   await bash('npm -v'); | ||||
|   await bash(`npm config set cache ${paths.NpmciCacheDir}  --global `); | ||||
|   // lets look for further config | ||||
|   await npmciConfig.getConfig().then(async configArg => { | ||||
|     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`); | ||||
|       } else { | ||||
|         plugins.beautylog.info(`globally installing ${npmTool} from npm`); | ||||
|         if (await yarnAvailable.promise) { | ||||
|           await bash(`yarn global add ${npmTool}`); | ||||
|         } else { | ||||
|           await bash(`npm install ${npmTool} -q -g`); | ||||
|         } | ||||
|         await bash(`npm install ${npmTool} -q -g`); | ||||
|       } | ||||
|     } | ||||
|     plugins.beautylog.success('all global npm tools specified in npmextra.json are now available!'); | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import * as plugins from './mod.plugins'; | ||||
| import * as configModule from '../npmci.config'; | ||||
| import { bash, bashNoError, nvmAvailable, yarnAvailable } from '../npmci.bash'; | ||||
| import { bash, bashNoError, nvmAvailable } from '../npmci.bash'; | ||||
|  | ||||
| /** | ||||
|  * handle cli input | ||||
| @@ -66,27 +66,35 @@ let publish = async () => { | ||||
|     npmAccessCliString = `--access=${config.npmAccessLevel}`; | ||||
|   } | ||||
|  | ||||
|   // -> build it | ||||
|   await bash(`yarn install`); | ||||
|   await bash(`yarn run build`); | ||||
|  | ||||
|   // -> make sure npm is authenticated | ||||
|   // -> preparing | ||||
|   plugins.beautylog.log(`now preparing environment:`); | ||||
|   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 | ||||
|   plugins.beautylog.log(`now invoking npm to publish the package!`); | ||||
|   await bash(`npm publish ${npmAccessCliString}`); | ||||
|   plugins.beautylog.success(`Package was successfully published!`); | ||||
| }; | ||||
|  | ||||
| let install = async (): Promise<void> => { | ||||
|   plugins.beautylog.info('now installing dependencies:'); | ||||
|   if (await yarnAvailable.promise) { | ||||
|     await bash('yarn install'); | ||||
|   } else { | ||||
|     await bash('npm install'); | ||||
|   } | ||||
|   await bash('npm install'); | ||||
| }; | ||||
|  | ||||
| export let test = async (): Promise<void> => { | ||||
|   plugins.beautylog.info('now starting tests:'); | ||||
|   await bash('yarn test'); | ||||
|   await bash('npm test'); | ||||
| }; | ||||
|   | ||||
| @@ -1,13 +1,12 @@ | ||||
| import * as plugins from './npmci.plugins'; | ||||
| import * as paths from './npmci.paths'; | ||||
|  | ||||
| import * as smartq from 'smartq'; | ||||
| import * as smartpromise from '@pushrocks/smartpromise'; | ||||
|  | ||||
| /** | ||||
|  * wether nvm is available or not | ||||
|  */ | ||||
| export let nvmAvailable = smartq.defer<boolean>(); | ||||
| export let yarnAvailable = smartq.defer<boolean>(); | ||||
| export let nvmAvailable = smartpromise.defer<boolean>(); | ||||
| /** | ||||
|  * the smartshell instance for npmci | ||||
|  */ | ||||
| @@ -35,22 +34,8 @@ let checkToolsAvailable = async () => { | ||||
|     } else { | ||||
|       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 { | ||||
|     nvmAvailable.resolve(true); | ||||
|     yarnAvailable.resolve(true); | ||||
|   } | ||||
| }; | ||||
| checkToolsAvailable(); | ||||
|   | ||||
							
								
								
									
										115
									
								
								ts/npmci.cli.ts
									
									
									
									
									
								
							
							
						
						
									
										115
									
								
								ts/npmci.cli.ts
									
									
									
									
									
								
							| @@ -11,112 +11,113 @@ import * as NpmciEnv from './npmci.env'; | ||||
|  | ||||
| import * as npmciMods from './npmci.mods'; | ||||
|  | ||||
| let smartcli = new plugins.smartcli.Smartcli(); | ||||
| smartcli.addVersion(npmciInfo.version); | ||||
| const npmciSmartcli = new plugins.smartcli.Smartcli(); | ||||
| npmciSmartcli.addVersion(npmciInfo.version); | ||||
|  | ||||
| // clean | ||||
| smartcli | ||||
|   .addCommand('clean') | ||||
|   .then(async argv => { | ||||
| npmciSmartcli.addCommand('clean').subscribe( | ||||
|   async argv => { | ||||
|     let modClean = await npmciMods.modClean.load(); | ||||
|     await modClean.clean(); | ||||
|   }) | ||||
|   .catch(err => { | ||||
|   }, | ||||
|   err => { | ||||
|     console.log(err); | ||||
|     process.exit(1); | ||||
|   }); | ||||
|   } | ||||
| ); | ||||
|  | ||||
| // cloudflare | ||||
| smartcli | ||||
|   .addCommand('cloudflare') | ||||
|   .then(async argvArg => { | ||||
| npmciSmartcli.addCommand('cloudflare').subscribe( | ||||
|   async argvArg => { | ||||
|     let modPurge = await npmciMods.modCloudflare.load(); | ||||
|     await modPurge.handleCli(argvArg); | ||||
|   }) | ||||
|   .catch(err => { | ||||
|   }, | ||||
|   err => { | ||||
|     console.log(err); | ||||
|   }); | ||||
|   } | ||||
| ); | ||||
|  | ||||
| // command | ||||
| smartcli | ||||
|   .addCommand('command') | ||||
|   .then(async argv => { | ||||
| npmciSmartcli.addCommand('command').subscribe( | ||||
|   async argv => { | ||||
|     let modCommand = await npmciMods.modCommand.load(); | ||||
|     await modCommand.command(); | ||||
|   }) | ||||
|   .catch(err => { | ||||
|   }, | ||||
|   err => { | ||||
|     console.log(err); | ||||
|     process.exit(1); | ||||
|   }); | ||||
|   } | ||||
| ); | ||||
|  | ||||
| // command | ||||
| smartcli | ||||
|   .addCommand('git') | ||||
|   .then(async argvArg => { | ||||
| npmciSmartcli.addCommand('git').subscribe( | ||||
|   async argvArg => { | ||||
|     let modGit = await npmciMods.modGit.load(); | ||||
|     await modGit.handleCli(argvArg); | ||||
|   }) | ||||
|   .catch(err => { | ||||
|   }, | ||||
|   err => { | ||||
|     console.log(err); | ||||
|     process.exit(1); | ||||
|   }); | ||||
|   } | ||||
| ); | ||||
|  | ||||
| // build | ||||
| smartcli | ||||
|   .addCommand('docker') | ||||
|   .then(async argvArg => { | ||||
| npmciSmartcli.addCommand('docker').subscribe( | ||||
|   async argvArg => { | ||||
|     let modDocker = await npmciMods.modDocker.load(); | ||||
|     await modDocker.handleCli(argvArg); | ||||
|   }) | ||||
|   .catch(err => { | ||||
|   }, | ||||
|   err => { | ||||
|     console.log(err); | ||||
|     process.exit(1); | ||||
|   }); | ||||
|   } | ||||
| ); | ||||
|  | ||||
| // node | ||||
| smartcli | ||||
|   .addCommand('node') | ||||
|   .then(async argvArg => { | ||||
| npmciSmartcli.addCommand('node').subscribe( | ||||
|   async argvArg => { | ||||
|     let modNode = await npmciMods.modNode.load(); | ||||
|     await modNode.handleCli(argvArg); | ||||
|   }) | ||||
|   .catch(err => { | ||||
|   }, | ||||
|   err => { | ||||
|     console.log(err); | ||||
|   }); | ||||
|     process.exit(1); | ||||
|   } | ||||
| ); | ||||
|  | ||||
| // npm | ||||
| smartcli | ||||
|   .addCommand('npm') | ||||
|   .then(async argvArg => { | ||||
| npmciSmartcli.addCommand('npm').subscribe( | ||||
|   async argvArg => { | ||||
|     let modNpm = await npmciMods.modNpm.load(); | ||||
|     await modNpm.handleCli(argvArg); | ||||
|   }) | ||||
|   .catch(err => { | ||||
|   }, | ||||
|   err => { | ||||
|     console.log(err); | ||||
|   }); | ||||
|   } | ||||
| ); | ||||
|  | ||||
| // trigger | ||||
| smartcli | ||||
|   .addCommand('ssh') | ||||
|   .then(async argvArg => { | ||||
| npmciSmartcli.addCommand('ssh').subscribe( | ||||
|   async argvArg => { | ||||
|     let modSsh = await npmciMods.modSsh.load(); | ||||
|     await modSsh.handleCli(argvArg); | ||||
|   }) | ||||
|   .catch(err => { | ||||
|   }, | ||||
|   err => { | ||||
|     console.log(err); | ||||
|     process.exit(1); | ||||
|   }); | ||||
|   } | ||||
| ); | ||||
|  | ||||
| // trigger | ||||
| smartcli | ||||
|   .addCommand('trigger') | ||||
|   .then(async argv => { | ||||
| npmciSmartcli.addCommand('trigger').subscribe( | ||||
|   async argv => { | ||||
|     let modTrigger = await npmciMods.modTrigger.load(); | ||||
|     await modTrigger.trigger(); | ||||
|   }) | ||||
|   .catch(err => { | ||||
|   }, | ||||
|   err => { | ||||
|     console.log(err); | ||||
|     process.exit(1); | ||||
|   }); | ||||
|   } | ||||
| ); | ||||
|  | ||||
| smartcli.startParse(); | ||||
| npmciSmartcli.startParse(); | ||||
|   | ||||
| @@ -6,3 +6,4 @@ export let NpmciPackageRoot = plugins.path.join(__dirname, '../'); | ||||
| export let NpmciPackageConfig = plugins.path.join(NpmciPackageRoot, './config.json'); | ||||
| export let NpmciProjectDir = cwd; | ||||
| export let NpmciTestDir = plugins.path.join(cwd, './test'); | ||||
| export let NpmciCacheDir = plugins.path.join(cwd, './.npmci_cache'); | ||||
|   | ||||
| @@ -3,14 +3,13 @@ export import lodash = require('lodash'); | ||||
| export import npmextra = require('npmextra'); | ||||
| export import path = require('path'); | ||||
| export import projectinfo = require('projectinfo'); | ||||
| export import q = require('smartq'); | ||||
| export let request = require('request'); | ||||
| export import smartcli = require('smartcli'); | ||||
| export import smartdelay = require('smartdelay'); | ||||
| export import smartfile = require('smartfile'); | ||||
| export import smartcli = require('@pushrocks/smartcli'); | ||||
| export import smartdelay = require('@pushrocks/smartdelay'); | ||||
| export import smartfile = require('@pushrocks/smartfile'); | ||||
| export import shelljs = require('shelljs'); | ||||
| export import smartparam = require('smartparam'); | ||||
| export import smartq = require('smartq'); | ||||
| export import smartpromise = require('@pushrocks/smartpromise'); | ||||
| export import smartshell = require('smartshell'); | ||||
| export import smartsocket = require('smartsocket'); | ||||
| export import smartsystem = require('smartsystem'); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user