Compare commits

..

52 Commits

Author SHA1 Message Date
d3d3363e1b 1.2.17 2017-10-13 17:50:34 +02:00
ccd2cb6cbd update 2017-10-13 17:50:31 +02:00
0b0642f9e3 1.2.16 2017-10-13 16:44:31 +02:00
34753a4ae0 fix docker testing 2017-10-13 16:44:25 +02:00
977ecabb41 1.2.15 2017-10-07 16:48:47 +02:00
6d9d040a8d update ci 2017-10-07 16:48:44 +02:00
b2c08b7221 1.2.14 2017-10-07 14:15:35 +02:00
73b1a73719 update Analytics 2017-10-07 14:15:29 +02:00
449512e156 1.2.13 2017-10-07 14:02:27 +02:00
758e677bab update dependencies 2017-10-07 14:02:24 +02:00
42ffb4a8dd 1.2.12 2017-07-16 13:58:48 +02:00
9176b56035 update dependencies and greeting 2017-07-16 13:58:41 +02:00
b3d78f8ce5 1.2.11 2017-04-21 13:44:25 +02:00
b6a6aac8e5 now includes smartanalytics 2017-04-21 13:44:18 +02:00
32f5ead4f4 1.2.10 2017-04-20 21:57:47 +02:00
c29a261cb6 update to latest standards 2017-04-20 21:57:44 +02:00
de57d45947 1.2.9 2017-04-02 14:54:18 +02:00
00bf1532ca update readme 2017-04-02 14:54:15 +02:00
38fc672bf6 update ci 2017-04-02 14:51:38 +02:00
83771df11d 1.2.8 2017-04-02 14:48:27 +02:00
822e480bdf fix command execution 2017-04-02 14:48:23 +02:00
77c6ef99c1 1.2.7 2017-03-29 01:49:32 +02:00
8e3991c121 update gitlab ci yml 2017-03-29 01:49:27 +02:00
77477587b8 1.2.6 2017-03-29 01:04:43 +02:00
c7e32d6990 update ci 2017-03-29 01:04:25 +02:00
da1c2167d3 1.2.5 2017-03-29 01:01:42 +02:00
d55f7ef7f2 now running async and a lot faster 2017-03-29 01:01:37 +02:00
82f4fcceac 1.2.4 2017-02-12 16:04:30 +01:00
aa3b85314d added speedtest 2017-02-12 16:04:27 +01:00
b5145294bd add removing volumes 2017-02-12 15:17:59 +01:00
d25decd15d 1.2.3 2017-02-11 23:37:06 +01:00
abf5cd1e24 added clean --all 2017-02-11 23:37:01 +01:00
9b8636b472 1.2.2 2017-02-11 20:23:13 +01:00
eab75f03da update dependencies and README 2017-02-11 20:23:10 +01:00
74374e99d7 1.2.1 2016-08-04 22:36:05 +02:00
52294de14f remove unnecessary dependencies 2016-08-04 22:36:00 +02:00
4f395850bc 1.2.0 2016-08-04 22:25:21 +02:00
8778324e5b now supports qenv 2016-08-04 22:25:15 +02:00
30b88d36ae 1.1.6 2016-07-29 22:19:58 +02:00
2c49978674 now also removes old running containers 2016-07-29 22:19:53 +02:00
4dffa31f7d 1.1.5 2016-07-29 22:00:27 +02:00
6904088af8 now removes any previous containers to avoid name space conflicts after errors 2016-07-29 22:00:22 +02:00
b9618a86a6 1.1.4 2016-07-29 03:17:09 +02:00
f1d232a333 add right images to gitlab ci 2016-07-29 03:16:59 +02:00
aa66a3bb86 1.1.3 2016-07-29 03:16:09 +02:00
fbaeb63e4d fix gitlab ci 2016-07-29 03:16:04 +02:00
d60e6a4aa6 1.1.2 2016-07-29 03:09:51 +02:00
90e3e24803 fix gitlab.yml 2016-07-29 03:09:25 +02:00
2372ad7681 fix gitlab ci 2016-07-29 03:05:01 +02:00
02490ef011 fix gitlab ci 2016-07-29 03:03:07 +02:00
2388da50a1 fix gitlab ci 2016-07-29 00:55:11 +02:00
141358595e fix gitlab ci 2016-07-29 00:54:25 +02:00
33 changed files with 2038 additions and 428 deletions

4
.gitignore vendored
View File

@ -1,6 +1,8 @@
node_modules/
coverage/
docs/
pages/
public/
test/
assets/
.nogit/

View File

@ -1,36 +1,69 @@
image: hosttoday/ht-docker-dbase:npmts
image: hosttoday/ht-docker-dbase:npmci
services:
- docker:dind
stages:
- mirror
- test
- release
- trigger
- pages
testLEGACY:
stage: test
mirror:
image: hosttoday/ht-docker-node:npmci
stage: mirror
script:
- npmci test legacy
- npmci git mirror
tags:
- docker
testLTS:
test:
stage: test
script:
- npmci test lts
tags:
- docker
testSTABLE:
stage: test
script:
- npmci test stable
- npmci node install stable
- npmci npm install
- npmci npm test
tags:
- docker
- lossless
- priv
release:
stage: release
environment: npmjs-com_registry
script:
- npmci publish
- npmci npm prepare
- npmci npm publish
only:
- tags
tags:
- docker
- lossless
- priv
trigger:
stage: trigger
script:
- npmci trigger
only:
- tags
tags:
- docker
- lossless
- priv
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
script:
- npmci command yarn global add npmpage
- npmci command npmpage
only:
- tags
tags:
- docker
artifacts:
expire_in: 1 week
paths:
- public

4
Dockerfile Normal file
View File

@ -0,0 +1,4 @@
FROM hosttoday/ht-docker-node:stable
LABEL author="Lossless GmbH <office@lossless.com>"
RUN yarn global add npmci npmdocker npmts ts-node

View File

@ -1,5 +1,60 @@
# npmdocker
develop npm modules cross platform with docker
## Availabililty
[![npm](https://gitzone.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/npmdocker)
[![git](https://gitzone.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/gitzone/npmdocker)
[![git](https://gitzone.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/gitzone/npmdocker)
[![docs](https://gitzone.gitlab.io/assets/repo-button-docs.svg)](https://gitzone.gitlab.io/npmdocker/)
## Status for master
[![build status](https://GitLab.com/gitzone/npmdocker/badges/master/build.svg)](https://GitLab.com/gitzone/npmdocker/commits/master)
[![coverage report](https://GitLab.com/gitzone/npmdocker/badges/master/coverage.svg)](https://GitLab.com/gitzone/npmdocker/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/npmdocker.svg)](https://www.npmjs.com/package/npmdocker)
[![Dependency Status](https://david-dm.org/gitzonetools/npmdocker.svg)](https://david-dm.org/gitzonetools/npmdocker)
[![bitHound Dependencies](https://www.bithound.io/github/gitzonetools/npmdocker/badges/dependencies.svg)](https://www.bithound.io/github/gitzonetools/npmdocker/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/gitzonetools/npmdocker/badges/code.svg)](https://www.bithound.io/github/gitzonetools/npmdocker)
[![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
npmdocker looks for a npmextra.json at the root of your directory and looks at the npmdocker portion of it.
Use TypeScript for best in class instellisense.
### Why does this package exist?
Sometimes you want a clean and fresh linux environment everytime you test your package.
Usually this is the default i CI, but locally behaviour tends to defer.
### Where does it work
The npmdocker package works in everywhere where the docker cli is available. e.g.:
* docker toolbox
* native docker application
* docker in docker
* mounted docker.sock
### How do I use it?
create a npmextra.json in the project's root directory
```json
{
"npmdocker": {
"baseImage": "hosttoday/ht-docker-node:npmts",
"command": "npmci test stable",
"dockerSock": false
}
}
```
option | description
--- | ---
baseImage | the base image that is the context for your project
command | the cli command to run within the the project's directory inside the docker container
dockersSock | wether or not the testcontainer will have access to the docker.sock of the host
For further information read the linked docs at the top of this README.
> MIT licensed | **&copy;** [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://git.zone)

View File

@ -1,5 +1,6 @@
FROM hosttoday/ht-docker-node:npmts
COPY ./buildContextDir /workspace
FROM hosttoday/ht-docker-node:npmci
RUN yarn global add npmdocker
COPY ./ /workspace
WORKDIR /workspace
ENV CI=true
CMD ["npm","test"];
CMD ["npmdocker","runinside"];

3
dist/cli.js vendored
View File

@ -1,2 +1,3 @@
#!/usr/bin/env node
var index = require("./index.js");
process.env.CLI_CALL = 'true'
var index = require("../dist/index.js");

17
dist/index.js vendored
View File

@ -1,14 +1,5 @@
"use strict";
const plugins = require("./npmdocker.plugins");
const promisechain = require("./npmdocker.promisechain");
promisechain.run()
.then((configArg) => {
if (configArg.exitCode == 0) {
plugins.beautylog.success("container ended all right!");
}
else {
plugins.beautylog.error("container ended with error!");
process.exit(1);
}
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0scUJBQXFCLENBQUMsQ0FBQTtBQUMvQyxNQUFZLFlBQVksV0FBTSwwQkFBMEIsQ0FBQyxDQUFBO0FBSXpELFlBQVksQ0FBQyxHQUFHLEVBQUU7S0FDYixJQUFJLENBQUMsQ0FBQyxTQUE4QjtJQUNqQyxFQUFFLENBQUEsQ0FBQyxTQUFTLENBQUMsUUFBUSxJQUFJLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDeEIsT0FBTyxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMsNEJBQTRCLENBQUMsQ0FBQztJQUM1RCxDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyw2QkFBNkIsQ0FBQyxDQUFDO1FBQ3ZELE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFDcEIsQ0FBQztBQUNMLENBQUMsQ0FBQyxDQUFDIn0=
Object.defineProperty(exports, "__esModule", { value: true });
const cli = require("./npmdocker.cli");
cli.run();
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUNBLHVDQUFzQztBQUV0QyxHQUFHLENBQUMsR0FBRyxFQUFFLENBQUEifQ==

1
dist/npmdocker.cli.d.ts vendored Normal file
View File

@ -0,0 +1 @@
export declare let run: () => void;

85
dist/npmdocker.cli.js vendored Normal file
View File

@ -0,0 +1,85 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./npmdocker.plugins");
// modules
const ConfigModule = require("./npmdocker.config");
const DockerModule = require("./npmdocker.docker");
/**
* smartanalytics
* this data is fully anonymized (no Ips or any other personal information is tracked).
* It just keeps track which of our tools are really used...
* ... so we know where to spend our limited resources for improving them.
* Since yarn is out and there is heavy caching going on,
* pure download stats are just not reliable enough for us anymore
* Feel free to dig into the smartanalytics package, if you are interested in how it works.
* It is just an https call to Google Analytics.
* Our privacy policy can be found here: https://lossless.gmbh/privacy.html
*/
let npmdockerAnalytics = new plugins.smartanalytics.Analytics({
apiEndPoint: 'https://pubapi.lossless.one',
appName: 'npmdocker',
projectId: 'gitzone'
});
npmdockerAnalytics.recordEvent('npmtoolexecution', {
somedata: 'somedata'
});
let npmdockerCli = new plugins.smartcli.Smartcli();
exports.run = () => {
npmdockerCli.standardTask().then((argvArg) => __awaiter(this, void 0, void 0, function* () {
plugins.beautylog.figletSync('npmdocker');
let configArg = yield ConfigModule.run()
.then(DockerModule.run);
if (configArg.exitCode === 0) {
plugins.beautylog.success('container ended all right!');
}
else {
plugins.beautylog.error(`container ended with error! Exit Code is ${configArg.exitCode}`);
process.exit(1);
}
}));
/**
* this command is executed inside docker and meant for use from outside docker
*/
npmdockerCli.addCommand('runinside').then((argvArg) => __awaiter(this, void 0, void 0, function* () {
plugins.beautylog.ok('Allright. We are now in Docker!');
plugins.beautylog.log('now trying to run your specified command');
let configArg = yield ConfigModule.run();
yield plugins.smartshell.exec(configArg.command).then(response => {
if (response.exitCode !== 0) {
process.exit(1);
}
});
}));
npmdockerCli.addCommand('clean').then((argvArg) => __awaiter(this, void 0, void 0, function* () {
plugins.beautylog.ora.start();
plugins.beautylog.ora.text('cleaning up docker env...');
if (argvArg.all) {
plugins.beautylog.ora.text('killing any running docker containers...');
yield plugins.smartshell.exec(`docker kill $(docker ps -q)`);
plugins.beautylog.ora.text('removing stopped containers...');
yield plugins.smartshell.exec(`docker rm $(docker ps -a -q)`);
plugins.beautylog.ora.text('removing images...');
yield plugins.smartshell.exec(`docker rmi $(docker images -q -f dangling=true)`);
plugins.beautylog.ora.text('removing all other images...');
yield plugins.smartshell.exec(`docker rmi $(docker images -a -q)`);
plugins.beautylog.ora.text('removing all volumes...');
yield plugins.smartshell.exec(`docker volume rm $(docker volume ls -f dangling=true -q)`);
}
plugins.beautylog.ora.endOk('docker environment now is clean!');
}));
npmdockerCli.addCommand('speedtest').then((argvArg) => __awaiter(this, void 0, void 0, function* () {
plugins.beautylog.figletSync('npmdocker');
plugins.beautylog.ok('Starting speedtest');
yield plugins.smartshell.exec(`docker pull tianon/speedtest && docker run --rm tianon/speedtest`);
}));
npmdockerCli.startParse();
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmNsaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5jbGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLCtDQUE4QztBQUc5QyxVQUFVO0FBQ1YsbURBQWtEO0FBQ2xELG1EQUFrRDtBQUdsRDs7Ozs7Ozs7OztHQVVHO0FBQ0gsSUFBSSxrQkFBa0IsR0FBRyxJQUFJLE9BQU8sQ0FBQyxjQUFjLENBQUMsU0FBUyxDQUFDO0lBQzVELFdBQVcsRUFBRSw2QkFBNkI7SUFDMUMsT0FBTyxFQUFFLFdBQVc7SUFDcEIsU0FBUyxFQ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QyxrRUFBa0UsQ0FBQyxDQUFBO0lBQ25HLENBQUMsQ0FBQSxDQUFDLENBQUE7SUFFRixZQUFZLENBQUMsVUFBVSxFQUFFLENBQUE7QUFDM0IsQ0FBQyxDQUFBIn0=

View File

@ -1,9 +1,9 @@
/// <reference types="q" />
import * as plugins from "./npmdocker.plugins";
import { IKeyValueObject } from 'qenv';
export interface IConfig {
baseImage: string;
command: string;
dockerSock: boolean;
exitCode?: number;
keyValueObjectArray: IKeyValueObject[];
}
export declare let run: () => plugins.q.Promise<{}>;
export declare let run: () => Promise<IConfig>;

View File

@ -1,16 +1,38 @@
"use strict";
const plugins = require("./npmdocker.plugins");
let config = plugins.npmextra.dataFor({
toolName: "npmdocker",
defaultSettings: {
baseImage: "hosttoday/ht-docker-node:npmts",
command: "npm test",
dockerSock: false
}
});
exports.run = () => {
let done = plugins.q.defer();
done.resolve(config);
return done.promise;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFVL0MsSUFBSSxNQUFNLEdBQVcsT0FBTyxDQUFDLFFBQVEsQ0FBQyxPQUFPLENBQUM7SUFDMUMsUUFBUSxFQUFDLFdBQVc7SUFDcEIsZUFBZSxFQUFFO1FBQ2IsU0FBUyxFQUFDLGdDQUFnQztRQUMxQyxPQUFPLEVBQUMsVUFBVTtRQUNsQixVQUFVLEVBQUUsS0FBSztLQUNwQjtDQUNKLENBQUMsQ0FBQztBQUVRLFdBQUcsR0FBRztJQUNiLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsSUFBSSxDQUFDLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQztJQUNyQixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUEifQ==
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./npmdocker.plugins");
const paths = require("./npmdocker.paths");
;
let getQenvKeyValueObject = () => __awaiter(this, void 0, void 0, function* () {
let qenvKeyValueObjectArray;
if (plugins.smartfile.fs.fileExistsSync(plugins.path.join(paths.cwd, 'qenv.yml'))) {
qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, '.nogit/').keyValueObjectArray;
}
else {
qenvKeyValueObjectArray = [];
}
return qenvKeyValueObjectArray;
});
let buildConfig = (qenvKeyValueObjectArrayArg) => __awaiter(this, void 0, void 0, function* () {
let npmextra = new plugins.npmextra.Npmextra(paths.cwd);
let config = npmextra.dataFor('npmdocker', {
baseImage: 'hosttoday/ht-docker-node:npmci',
command: 'npmci test stable',
dockerSock: false,
keyValueObjectArray: qenvKeyValueObjectArrayArg
});
return config;
});
exports.run = () => __awaiter(this, void 0, void 0, function* () {
let config = yield getQenvKeyValueObject().then(buildConfig);
return config;
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLCtDQUE4Q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LEdBQUcsR0FBMkIsRUFBRTtJQUM1QyxJQUFJLE1BQU0sR0FBRyxNQUFNLHFCQUFxQixFQUFFLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxDQUFBO0lBQzVELE1BQU0sQ0FBQyxNQUFNLENBQUE7QUFDZixDQUFDLENBQUEsQ0FBQSJ9

View File

@ -1,3 +1,2 @@
/// <reference types="q" />
import * as plugins from "./npmdocker.plugins";
export declare let run: (configArg: any) => plugins.q.Promise<{}>;
import { IConfig } from './npmdocker.config';
export declare let run: (configArg: IConfig) => Promise<IConfig>;

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,4 @@
export declare let cwd: string;
export declare let packageBase: string;
export declare let assets: string;
export declare let buildContextDir: string;
export declare let dockerfile: string;
export declare let npmdockerFile: string;

View File

@ -1,12 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./npmdocker.plugins");
// directories
exports.cwd = process.cwd();
exports.packageBase = plugins.path.join(__dirname, "../");
exports.assets = plugins.path.join(exports.packageBase, "assets/");
exports.packageBase = plugins.path.join(__dirname, '../');
exports.assets = plugins.path.join(exports.packageBase, 'assets/');
plugins.smartfile.fs.ensureDirSync(exports.assets);
exports.buildContextDir = plugins.path.join(exports.assets, "buildContextDir");
plugins.smartfile.fs.ensureDirSync(exports.buildContextDir);
// files
exports.dockerfile = plugins.path.join(exports.assets, "Dockerfile");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxxQkFBcUIsQ0FBQyxDQUFBO0FBRS9DLGNBQWM7QUFDSCxXQUFHLEdBQUcsT0FBTyxDQUFDLEdBQUcsRUFBRSxDQUFDO0FBQ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FDLG1CQUFXLEVBQUUsU0FBUyxDQUFDLENBQUE7QUFDN0QsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsYUFBYSxDQUFDLGNBQU0sQ0FBQyxDQUFBO0FBQy9CLFFBQUEsYUFBYSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLFdBQUcsRUFBRSxXQUFXLENBQUMsQ0FBQSJ9

View File

@ -1,8 +1,13 @@
import "typings-global";
export import beautylog = require("beautylog");
export import npmextra = require("npmextra");
export import path = require("path");
export import q = require("q");
export import shelljs = require("shelljs");
export import smartfile = require("smartfile");
export import smartstring = require("smartstring");
import 'typings-global';
import * as beautylog from 'beautylog';
import * as npmextra from 'npmextra';
import * as path from 'path';
import * as projectinfo from 'projectinfo';
import * as q from 'smartq';
import * as qenv from 'qenv';
import * as smartanalytics from 'smartanalytics';
import * as smartcli from 'smartcli';
import * as smartfile from 'smartfile';
import * as smartshell from 'smartshell';
import * as smartstring from 'smartstring';
export { beautylog, npmextra, path, projectinfo, q, qenv, smartanalytics, smartcli, smartfile, smartshell, smartstring };

View File

@ -1,10 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
exports.beautylog = require("beautylog");
exports.npmextra = require("npmextra");
exports.path = require("path");
exports.q = require("q");
exports.shelljs = require("shelljs");
exports.smartfile = require("smartfile");
exports.smartstring = require("smartstring");
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9ucG1kb2NrZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ1YsaUJBQVMsV0FBVyxXQUFXLENBQUMsQ0FBQztBQUNqQyxnQkFBUSxXQUFXLFVBQVUsQ0FBQyxDQUFDO0FBQy9CLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixTQUFDLFdBQVcsR0FBRyxDQUFDLENBQUM7QUFDakIsZUFBTyxXQUFXLFNBQVMsQ0FBQyxDQUFDO0FBQzdCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsbUJBQVcsV0FBVyxhQUFhLENBQUMsQ0FBQyJ9
const beautylog = require("beautylog");
exports.beautylog = beautylog;
const npmextra = require("npmextra");
exports.npmextra = npmextra;
const path = require("path");
exports.path = path;
const projectinfo = require("projectinfo");
exports.projectinfo = projectinfo;
const q = require("smartq");
exports.q = q;
const qenv = require("qenv");
exports.qenv = qenv;
const smartanalytics = require("smartanalytics");
exports.smartanalytics = smartanalytics;
const smartcli = require("smartcli");
exports.smartcli = smartcli;
const smartfile = require("smartfile");
exports.smartfile = smartfile;
const smartshell = require("smartshell");
exports.smartshell = smartshell;
const smartstring = require("smartstring");
exports.smartstring = smartstring;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9ucG1kb2NrZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDBCQUF1QjtBQUN2Qix1Q0FBc0M7QUFhcEMsOEJBQVM7QUFaWCxxQ0FBb0M7QUFhbEMsNEJBQVE7QUFaViw2QkFBNEI7QUFhMUIsb0JBQUk7QUFaTiwyQ0FBMEM7QUFheEMsa0NBQVc7QUFaYiw0QkFBMkI7QUFhekIsY0FBQztBQVpILDZCQUE0QjtBQWExQixvQkFBSTtBQVpOLGlEQUFnRDtBQWE5Qyx3Q0FBYztBQVpoQixxQ0FBb0M7QUFhbEMsNEJBQVE7QUFaVix1Q0FBc0M7QUFhcEMsOEJBQVM7QUFaWCx5Q0FBd0M7QUFhdEMsZ0NBQVU7QUFaWiwyQ0FBMEM7QUFheEMsa0NBQVcifQ==

View File

@ -1,5 +0,0 @@
/// <reference types="q" />
import * as plugins from "./npmdocker.plugins";
import { Ora } from "beautylog";
export declare let npmdockerOra: Ora;
export declare let run: () => plugins.q.Promise<{}>;

View File

@ -1,18 +0,0 @@
"use strict";
const plugins = require("./npmdocker.plugins");
const beautylog_1 = require("beautylog");
//modules
const ConfigModule = require("./npmdocker.config");
const DockerModule = require("./npmdocker.docker");
exports.npmdockerOra = new beautylog_1.Ora("npmdocker", "blue");
exports.npmdockerOra.start();
exports.run = () => {
let done = plugins.q.defer();
ConfigModule.run()
.then(DockerModule.run)
.then((configArg) => {
done.resolve(configArg);
});
return done.promise;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnByb21pc2VjaGFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5wcm9taXNlY2hhaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFFL0MsNEJBQWtCLFdBQVcsQ0FBQyxDQUFBO0FBQzlCLFNBQVM7QUFDVCxNQUFZLFlBQVksV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBQ25ELE1BQVksWUFBWSxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFeEMsb0JBQVksR0FBRyxJQUFJLGVBQUcsQ0FBQyxXQUFXLEVBQUMsTUFBTSxDQUFDLENBQUM7QUFDdEQsb0JBQVksQ0FBQyxLQUFLLEVBQUUsQ0FBQztBQUNWLFdBQUcsR0FBRztJQUNiLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsWUFBWSxDQUFDLEdBQUcsRUFBRTtTQUNiLElBQUksQ0FBQyxZQUFZLENBQUMsR0FBRyxDQUFDO1NBQ3RCLElBQUksQ0FBQyxDQUFDLFNBQVM7UUFDWixJQUFJLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0lBQzVCLENBQUMsQ0FBQyxDQUFBO0lBQ04sTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7QUFDeEIsQ0FBQyxDQUFBIn0=

View File

@ -1,21 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./npmdocker.plugins");
exports.dockerfileSnippet = (optionsArg) => {
let commandArray = optionsArg.command.split(/\s/);
let commandString = "";
for (let stringItem of commandArray) {
if (!(commandString == "")) {
commandString = commandString + ",";
}
commandString = commandString + '"' + stringItem + '"';
let getMountSolutionString = (optionsArg) => {
if (process.env.CI) {
return 'COPY ./ /workspace';
}
else {
return '# not copying workspcae since not in CI';
}
;
return plugins.smartstring.indent.normalize(`
FROM ${optionsArg.baseImage}
COPY ./buildContextDir /workspace
WORKDIR /workspace
ENV CI=true
CMD [${commandString}];
`);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnNuaXBwZXRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnNuaXBwZXRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxxQkFBcUIsQ0FBQyxDQUFBO0FBT3BDLHlCQUFpQixHQUFHLENBQUMsVUFBNkI7SUFDekQsSUFBSSxZQUFZLEdBQUcsVUFBVSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDbEQsSUFBSSxhQUFhLEdBQVUsRUFBRSxDQUFDO0lBQzlCLEdBQUcsQ0FBQSxDQUFDLElBQUksVUFBVSxJQUFJLFlBQVksQ0FBQyxDQUFBLENBQUM7UUFDaEMsRUFBRSxDQUFBLENBQUMsQ0FBQyxDQUFDLGFBQWEsSUFBSSxFQUFFLENBQUMsQ0FBQyxDQUFBLENBQUM7WUFDdkIsYUFBYSxHQUFHLGFBQWEsR0FBRyxHQUFHLENBQUM7UUFDeEMsQ0FBQztRQUNELGFBQWEsR0FBRyxhQUFhLEdBQUcsR0FBRyxHQUFHLFVBQVUsR0FBRyxHQUFHLENBQUM7SUFDM0QsQ0FBQztJQUFBLENBQUM7SUFDRixNQUFNLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDO2VBQ2pDLFVBQVUsQ0FBQyxTQUFTOzs7O2VBSXBCLGFBQWE7S0FDdkIsQ0FBQyxDQUFDO0FBQ1AsQ0FBQyxDQUFBIn0=
let getGlobalPreparationString = (optionsArg) => {
if (optionsArg.baseImage !== 'hosttoday/ht-docker-node:npmdocker') {
return 'RUN yarn global add npmdocker';
}
else {
return '# not installing npmdocker since it is included in the base image';
}
};
exports.dockerfileSnippet = (optionsArg) => {
return plugins.smartstring.indent.normalize(`
FROM ${optionsArg.baseImage}
# For info about what npmdocker does read the docs at https://gitzone.github.io/npmdocker
${getGlobalPreparationString(optionsArg)}
${getMountSolutionString(optionsArg)}
WORKDIR /workspace
ENV CI=true
ENTRYPOINT ["npmdocker"]
CMD ["runinside"]
`);
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnNuaXBwZXRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnNuaXBwZXRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsK0NBQStDO0FBTy9DLElBQUksc0JBQXNCLEdBQUcsQ0FBQyxVQUE4QixFQUFFLEVBQUU7SUFDOUQsRUFBRSxDQUFDLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsQ0FBQyxDQUFDO1FBQ25CLE1BQU0sQ0FBQyxvQkFBb0IsQ0FBQTtJQUM3QixDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDTixNQUFNLENBQUMseUNBQXlDLENBQUE7SUFDbEQsQ0FBQztBQUNILENBQUMsQ0FBQTtBQUVELElBQUksMEJBQTBCLEdBQUcsQ0FBQyxVQUE4QixFQUFFLEVBQUU7SUFDbEUsRUFBRSxDQUFDLENBQUMsVUFBVSxDQUFDLFNBQVMsS0FBSyxvQ0FBb0MsQ0FBQyxDQUFDLENBQUM7UUFDbEUsTUFBTSxDQUFDLCtCQUErQixDQUFBO0lBQ3hDLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNOLE1BQU0sQ0FBQyxtRUFBbUUsQ0FBQTtJQUM1RSxDQUFDO0FBQ0gsQ0FBQyxDQUFBO0FBRVUsUUFBQSxpQkFBaUIsR0FBRyxDQUFDLFVBQThCLEVBQVUsRUFBRTtJQUN4RSxNQUFNLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUN6QztPQUNHLFVBQVUsQ0FBQyxTQUFTOztFQUV6QiwwQkFBMEIsQ0FBQyxVQUFVLENBQUM7RUFDdEMsc0JBQXNCLENBQUMsVUFBVSxDQUFDOzs7OztDQUtuQyxDQUNFLENBQUE7QUFDSCxDQUFDLENBQUEifQ==

1
docs/index.md Normal file
View File

@ -0,0 +1 @@
Docs for npmpage coming soon.

View File

@ -1,7 +1,11 @@
{
"npmts":{
"mode":"default",
"cli":true,
"dockerSock":true
"cli":true
},
"npmci": {
"npmGlobalTools": [
"npmts"
]
}
}

View File

@ -1,6 +1,6 @@
{
"name": "npmdocker",
"version": "1.1.1",
"version": "1.2.17",
"description": "develop npm modules cross platform with docker",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
@ -11,15 +11,17 @@
"test": "test"
},
"scripts": {
"test": "(npm run clean && npm run compile && npm run setupCheck && npm run check)",
"test": "(npm run clean && npm run compile && npm run setupCheck && npm run testStandard && npm run testSpeed)",
"testStandard": "(cd test/ && node ../dist/index.js)",
"testSpeed": "(cd test/ && node ../dist/index.js speedtest)",
"testClean": "(cd test/ && node ../dist/index.js clean --all)",
"clean": "(rm -rf test/)",
"compile": "(npmts --notest)",
"setupCheck": "(git clone https://gitlab.com/sandboxzone/sandbox-npmts.git test/)",
"check": "(cd test/ && node ../dist/index.js)"
"setupCheck": "(git clone https://gitlab.com/sandboxzone/sandbox-npmts.git test/)"
},
"repository": {
"type": "git",
"url": "git+ssh://git@gitlab.com/pushrocks/npmdocker.git"
"url": "git+ssh://git@gitlab.com/gitzone/npmdocker.git"
},
"keywords": [
"docker"
@ -27,24 +29,22 @@
"author": "Lossless GmbH",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/pushrocks/npmdocker/issues"
},
"homepage": "https://gitlab.com/pushrocks/npmdocker#README",
"devDependencies": {
"npmts-g": "^5.2.6",
"should": "^10.0.0",
"typings-test": "^1.0.1"
"url": "https://gitlab.com/gitzone/npmdocker/issues"
},
"homepage": "https://gitlab.com/gitzone/npmdocker#README",
"devDependencies": {},
"dependencies": {
"@types/q": "^0.0.27",
"@types/shelljs": "^0.3.27",
"beautylog": "^5.0.14",
"npmextra": "^1.0.8",
"q": "^1.4.1",
"rxjs": "^5.0.0-beta.10",
"shelljs": "^0.7.0",
"smartfile": "^4.0.11",
"smartstring": "^2.0.15",
"typings-global": "^1.0.6"
"@types/shelljs": "0.x.x",
"beautylog": "^6.1.10",
"npmextra": "^2.0.9",
"projectinfo": "^3.0.4",
"qenv": "^1.1.7",
"smartanalytics": "^2.0.9",
"smartcli": "^2.0.7",
"smartfile": "^4.2.26",
"smartq": "^1.1.6",
"smartshell": "^1.0.18",
"smartstring": "^2.0.24",
"typings-global": "^1.0.20"
}
}

View File

@ -1,15 +1,4 @@
import * as plugins from "./npmdocker.plugins";
import * as promisechain from "./npmdocker.promisechain";
import * as ConfigModule from "./npmdocker.config";
promisechain.run()
.then((configArg:ConfigModule.IConfig) => {
if(configArg.exitCode == 0){
plugins.beautylog.success("container ended all right!");
} else {
plugins.beautylog.error("container ended with error!");
process.exit(1);
}
});
import * as plugins from './npmdocker.plugins'
import * as cli from './npmdocker.cli'
cli.run()

87
ts/npmdocker.cli.ts Normal file
View File

@ -0,0 +1,87 @@
import * as plugins from './npmdocker.plugins'
import * as paths from './npmdocker.paths'
// modules
import * as ConfigModule from './npmdocker.config'
import * as DockerModule from './npmdocker.docker'
/**
* smartanalytics
* this data is fully anonymized (no Ips or any other personal information is tracked).
* It just keeps track which of our tools are really used...
* ... so we know where to spend our limited resources for improving them.
* Since yarn is out and there is heavy caching going on,
* pure download stats are just not reliable enough for us anymore
* Feel free to dig into the smartanalytics package, if you are interested in how it works.
* It is just an https call to Google Analytics.
* Our privacy policy can be found here: https://lossless.gmbh/privacy.html
*/
let npmdockerAnalytics = new plugins.smartanalytics.Analytics({
apiEndPoint: 'https://pubapi.lossless.one',
appName: 'npmdocker',
projectId: 'gitzone'
})
npmdockerAnalytics.recordEvent('npmtoolexecution', {
somedata: 'somedata'
})
let npmdockerCli = new plugins.smartcli.Smartcli()
export let run = () => {
npmdockerCli.standardTask().then(async (argvArg) => {
plugins.beautylog.figletSync('npmdocker')
let configArg = await ConfigModule.run()
.then(DockerModule.run)
if (configArg.exitCode === 0) {
plugins.beautylog.success('container ended all right!')
} else {
plugins.beautylog.error(`container ended with error! Exit Code is ${configArg.exitCode}`)
process.exit(1)
}
})
/**
* this command is executed inside docker and meant for use from outside docker
*/
npmdockerCli.addCommand('runinside').then(async (argvArg) => {
plugins.beautylog.ok('Allright. We are now in Docker!')
plugins.beautylog.log('now trying to run your specified command')
let configArg = await ConfigModule.run()
await plugins.smartshell.exec(configArg.command).then(response => {
if (response.exitCode !== 0) {
process.exit(1)
}
})
})
npmdockerCli.addCommand('clean').then(async (argvArg) => {
plugins.beautylog.ora.start()
plugins.beautylog.ora.text('cleaning up docker env...')
if (argvArg.all) {
plugins.beautylog.ora.text('killing any running docker containers...')
await plugins.smartshell.exec(`docker kill $(docker ps -q)`)
plugins.beautylog.ora.text('removing stopped containers...')
await plugins.smartshell.exec(`docker rm $(docker ps -a -q)`)
plugins.beautylog.ora.text('removing images...')
await plugins.smartshell.exec(`docker rmi $(docker images -q -f dangling=true)`)
plugins.beautylog.ora.text('removing all other images...')
await plugins.smartshell.exec(`docker rmi $(docker images -a -q)`)
plugins.beautylog.ora.text('removing all volumes...')
await plugins.smartshell.exec(`docker volume rm $(docker volume ls -f dangling=true -q)`)
}
plugins.beautylog.ora.endOk('docker environment now is clean!')
})
npmdockerCli.addCommand('speedtest').then(async (argvArg) => {
plugins.beautylog.figletSync('npmdocker')
plugins.beautylog.ok('Starting speedtest')
await plugins.smartshell.exec(`docker pull tianon/speedtest && docker run --rm tianon/speedtest`)
})
npmdockerCli.startParse()
}

View File

@ -1,24 +1,42 @@
import * as plugins from "./npmdocker.plugins";
import * as paths from "./npmdocker.paths";
import * as plugins from './npmdocker.plugins'
import * as paths from "./npmdocker.paths"
// interfaces
import { IKeyValueObject } from 'qenv'
export interface IConfig {
baseImage:string;
command:string;
dockerSock:boolean;
exitCode?:number
baseImage: string
command: string
dockerSock: boolean
exitCode?: number
keyValueObjectArray: IKeyValueObject[]
};
let getQenvKeyValueObject = async () => {
let qenvKeyValueObjectArray: IKeyValueObject[]
if (plugins.smartfile.fs.fileExistsSync(plugins.path.join(paths.cwd, 'qenv.yml'))) {
qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, '.nogit/').keyValueObjectArray
} else {
qenvKeyValueObjectArray = []
}
return qenvKeyValueObjectArray
}
let config:IConfig = plugins.npmextra.dataFor({
toolName:"npmdocker",
defaultSettings: {
baseImage:"hosttoday/ht-docker-node:npmts",
command:"npm test",
dockerSock: false
let buildConfig = async (qenvKeyValueObjectArrayArg: IKeyValueObject[]) => {
let npmextra = new plugins.npmextra.Npmextra(paths.cwd)
let config = npmextra.dataFor<IConfig>(
'npmdocker',
{
baseImage: 'hosttoday/ht-docker-node:npmci',
command: 'npmci test stable',
dockerSock: false,
keyValueObjectArray: qenvKeyValueObjectArrayArg
}
});
)
return config
}
export let run = () => {
let done = plugins.q.defer();
done.resolve(config);
return done.promise;
}
export let run = async (): Promise<IConfig> => {
let config = await getQenvKeyValueObject().then(buildConfig)
return config
}

View File

@ -1,137 +1,158 @@
import * as plugins from "./npmdocker.plugins";
import * as paths from "./npmdocker.paths";
import * as snippets from "./npmdocker.snippets";
import * as plugins from './npmdocker.plugins'
import * as paths from './npmdocker.paths'
import * as snippets from './npmdocker.snippets'
import {npmdockerOra} from "./npmdocker.promisechain";
// interfaces
import { IConfig } from './npmdocker.config'
let config;
let config: IConfig
/**
* the docker data used to build the internal testing container
*/
let dockerData = {
imageTag: "npmdocker-temp-image:latest",
containerName: "npmdocker-temp-container"
};
imageTag: 'npmdocker-temp-image:latest',
containerName: 'npmdocker-temp-container',
dockerProjectMountString: '',
dockerSockString: '',
dockerEnvString: ''
}
/**
* check if docker is available
*/
let checkDocker = () => {
let done = plugins.q.defer();
npmdockerOra.text("checking docker...");
if(plugins.shelljs.which("docker")){
plugins.beautylog.ok("Docker found!")
done.resolve();
} else {
done.reject(new Error("docker not found on this machine"));
}
return done.promise;
};
let done = plugins.q.defer()
plugins.beautylog.ora.text('checking docker...')
if (plugins.smartshell.which('docker')) {
plugins.beautylog.ok('Docker found!')
done.resolve()
} else {
done.reject(new Error('docker not found on this machine'))
}
return done.promise
}
/**
* builds the Dockerfile according to the config in the project
*/
let buildDockerFile = () => {
let done = plugins.q.defer();
npmdockerOra.text("building Dockerfile...");
let dockerfile:string = snippets.dockerfileSnippet({
baseImage:config.baseImage,
command:config.command
});
plugins.beautylog.info(`Base image is: ${config.baseImage}`);
plugins.beautylog.info(`Command is: ${config.command}`);
plugins.smartfile.memory.toFsSync(dockerfile,paths.dockerfile);
plugins.beautylog.ok("Dockerfile created!");
done.resolve();
return done.promise
};
let done = plugins.q.defer()
plugins.beautylog.ora.text('building Dockerfile...')
let dockerfile: string = snippets.dockerfileSnippet({
baseImage: config.baseImage,
command: config.command
})
plugins.beautylog.info(`Base image is: ${config.baseImage}`)
plugins.beautylog.info(`Command is: ${config.command}`)
plugins.smartfile.memory.toFsSync(dockerfile, plugins.path.join(paths.cwd, 'npmdocker'))
plugins.beautylog.ok('Dockerfile created!')
plugins.beautylog.ora.stop()
done.resolve()
return done.promise
}
/**
* builds the Dockerimage from the built Dockerfile
*/
let buildDockerImage = () => {
let done = plugins.q.defer();
npmdockerOra.text("pulling latest base image from registry...");
plugins.shelljs.exec(`docker pull ${config.baseImage}`,{
silent:true
},() => {
npmdockerOra.text("building Dockerimage...");
// are we creating a build context form project ?
if(process.env.CI == "true"){
npmdockerOra.text("creating build context...");
plugins.smartfile.fs.copySync(paths.cwd,paths.buildContextDir);
}
plugins.shelljs.exec(`docker build -f ${paths.dockerfile} -t ${dockerData.imageTag} ${paths.assets}`,{
silent:true
},() => {
plugins.beautylog.ok("Dockerimage built!")
done.resolve();
});
}); // first pull latest version of baseImage
return done.promise
};
let buildDockerImage = async () => {
plugins.beautylog.info('pulling latest base image from registry...')
await plugins.smartshell.exec(
`docker pull ${config.baseImage}`
)
plugins.beautylog.ora.text('building Dockerimage...')
let execResult = await plugins.smartshell.execSilent(
`docker build -f npmdocker -t ${dockerData.imageTag} ${paths.cwd}`
)
if (execResult.exitCode !== 0) {
console.log(execResult.stdout)
process.exit(1)
}
plugins.beautylog.ok('Dockerimage built!')
}
let buildDockerProjectMountString = async () => {
if (process.env.CI !== 'true') {
dockerData.dockerProjectMountString = `-v ${paths.cwd}:/workspace`
};
}
/**
* builds an environment string that docker cli understands
*/
let buildDockerEnvString = async () => {
for (let keyValueObjectArg of config.keyValueObjectArray) {
let envString = dockerData.dockerEnvString = dockerData.dockerEnvString + `-e ${keyValueObjectArg.key}=${keyValueObjectArg.value} `
}
}
/**
* creates string to mount the docker.sock inside the testcontainer
*/
let buildDockerSockString = async () => {
if (config.dockerSock) {
dockerData.dockerSockString = `-v /var/run/docker.sock:/var/run/docker.sock`
};
}
/**
* creates a container by running the built Dockerimage
*/
let runDockerImage = () => {
let done = plugins.q.defer();
npmdockerOra.text("starting Container...");
npmdockerOra.end();
// Are we mounting the project directory?
let dockerProjectMountString:string = "";
if(process.env.CI != "true"){
dockerProjectMountString = `-v ${paths.cwd}:/workspace`
};
// Are we mounting docker.sock?
let dockerSockString:string = "";
if(config.dockerSock){
dockerSockString = `-v /var/run/docker.sock:/var/run/docker.sock`
};
config.exitCode = plugins.shelljs.exec(`docker run ${dockerProjectMountString} ${dockerSockString} --name ${dockerData.containerName} ${dockerData.imageTag}`).code;
done.resolve();
return done.promise;
};
let deleteDockerContainter = () => {
let done = plugins.q.defer();
plugins.shelljs.exec(`docker rm ${dockerData.containerName}`,{
silent:true
});
done.resolve();
plugins.beautylog.ok("removed test container!");
return done.promise
};
let deleteDockerImage = () => {
let done = plugins.q.defer();
plugins.shelljs.exec(`docker rmi ${dockerData.imageTag}`,{
silent:true
});
plugins.beautylog.ok("removed test image!");
plugins.beautylog.ok("Cleaned up!");
done.resolve();
return done.promise
};
let deleteBuildContext = () => {
let done = plugins.q.defer();
plugins.smartfile.fs.removeSync(paths.buildContextDir);
done.resolve();
return done.promise;
let runDockerImage = async () => {
let done = plugins.q.defer()
plugins.beautylog.ora.text('starting Container...')
plugins.beautylog.ora.end()
plugins.beautylog.log('now running Dockerimage')
config.exitCode = (await plugins.smartshell.exec(`docker run ${dockerData.dockerProjectMountString} ${dockerData.dockerSockString} ${dockerData.dockerEnvString} --name ${dockerData.containerName} ${dockerData.imageTag}`)).exitCode
}
/**
* cleans up: deletes the test container
*/
let deleteDockerContainer = async () => {
await plugins.smartshell.execSilent(`docker rm -f ${dockerData.containerName}`)
}
/**
* cleans up deletes the test image
*/
let deleteDockerImage = async () => {
await plugins.smartshell.execSilent(`docker rmi ${dockerData.imageTag}`).then(async (response) => {
if (response.exitCode !== 0) {
console.log(response.stdout)
}
})
}
export let run = (configArg) => {
let done = plugins.q.defer();
config = configArg;
checkDocker()
.then(buildDockerFile)
.then(buildDockerImage)
.then(runDockerImage)
.then(deleteDockerContainter)
.then(deleteDockerImage)
.then(deleteBuildContext)
.then(() => {
done.resolve(config);
})
return done.promise;
}
let preClean = async () => {
await deleteDockerImage()
.then(deleteDockerContainer)
.then(async () => {
plugins.beautylog.ok('ensured clean Docker environment!')
})
}
let postClean = async () => {
await deleteDockerContainer()
.then(deleteDockerImage)
.then(async () => {
plugins.beautylog.ok('cleaned up!')
})
await plugins.smartfile.fs.remove(paths.npmdockerFile)
}
export let run = async (configArg: IConfig): Promise<IConfig> => {
plugins.beautylog.ora.start()
config = configArg
let resultConfig = await checkDocker()
.then(preClean)
.then(buildDockerFile)
.then(buildDockerImage)
.then(buildDockerProjectMountString)
.then(buildDockerEnvString)
.then(buildDockerSockString)
.then(runDockerImage)
.then(postClean)
.catch(err => { console.log(err) })
return config
}

View File

@ -1,13 +1,8 @@
import * as plugins from "./npmdocker.plugins";
import * as plugins from "./npmdocker.plugins"
// directories
export let cwd = process.cwd();
export let packageBase = plugins.path.join(__dirname, "../");
export let assets = plugins.path.join(packageBase, "assets/");
plugins.smartfile.fs.ensureDirSync(assets);
export let buildContextDir = plugins.path.join(assets,"buildContextDir");
plugins.smartfile.fs.ensureDirSync(buildContextDir);
// files
export let dockerfile = plugins.path.join(assets, "Dockerfile");
export let cwd = process.cwd()
export let packageBase = plugins.path.join(__dirname, '../')
export let assets = plugins.path.join(packageBase, 'assets/')
plugins.smartfile.fs.ensureDirSync(assets)
export let npmdockerFile = plugins.path.join(cwd, 'npmdocker')

View File

@ -1,8 +1,26 @@
import "typings-global";
export import beautylog = require("beautylog");
export import npmextra = require("npmextra");
export import path = require("path");
export import q = require("q");
export import shelljs = require("shelljs");
export import smartfile = require("smartfile");
export import smartstring = require("smartstring");
import 'typings-global'
import * as beautylog from 'beautylog'
import * as npmextra from 'npmextra'
import * as path from 'path'
import * as projectinfo from 'projectinfo'
import * as q from 'smartq'
import * as qenv from 'qenv'
import * as smartanalytics from 'smartanalytics'
import * as smartcli from 'smartcli'
import * as smartfile from 'smartfile'
import * as smartshell from 'smartshell'
import * as smartstring from 'smartstring'
export {
beautylog,
npmextra,
path,
projectinfo,
q,
qenv,
smartanalytics,
smartcli,
smartfile,
smartshell,
smartstring
}

View File

@ -1,18 +0,0 @@
import * as plugins from "./npmdocker.plugins";
import * as paths from "./npmdocker.paths";
import {Ora} from "beautylog";
//modules
import * as ConfigModule from "./npmdocker.config";
import * as DockerModule from "./npmdocker.docker";
export let npmdockerOra = new Ora("npmdocker","blue");
npmdockerOra.start();
export let run = () => {
let done = plugins.q.defer();
ConfigModule.run()
.then(DockerModule.run)
.then((configArg) => {
done.resolve(configArg);
})
return done.promise;
}

View File

@ -1,24 +1,37 @@
import * as plugins from "./npmdocker.plugins";
export interface IDockerfileSnippet {
baseImage:string;
command:string;
baseImage: string
command: string
}
export let dockerfileSnippet = (optionsArg:IDockerfileSnippet):string => {
let commandArray = optionsArg.command.split(/\s/);
let commandString:string = "";
for(let stringItem of commandArray){
if(!(commandString == "")){
commandString = commandString + ",";
}
commandString = commandString + '"' + stringItem + '"';
};
return plugins.smartstring.indent.normalize(`
FROM ${optionsArg.baseImage}
COPY ./buildContextDir /workspace
WORKDIR /workspace
ENV CI=true
CMD [${commandString}];
`);
let getMountSolutionString = (optionsArg: IDockerfileSnippet) => {
if (process.env.CI) {
return 'COPY ./ /workspace'
} else {
return '# not copying workspcae since not in CI'
}
}
let getGlobalPreparationString = (optionsArg: IDockerfileSnippet) => {
if (optionsArg.baseImage !== 'hosttoday/ht-docker-node:npmdocker') {
return 'RUN yarn global add npmdocker'
} else {
return '# not installing npmdocker since it is included in the base image'
}
}
export let dockerfileSnippet = (optionsArg: IDockerfileSnippet): string => {
return plugins.smartstring.indent.normalize(
`
FROM ${optionsArg.baseImage}
# For info about what npmdocker does read the docs at https://gitzone.github.io/npmdocker
${getGlobalPreparationString(optionsArg)}
${getMountSolutionString(optionsArg)}
WORKDIR /workspace
ENV CI=true
ENTRYPOINT ["npmdocker"]
CMD ["runinside"]
`
)
}

3
tslint.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "tslint-config-standard"
}

1258
yarn.lock Normal file

File diff suppressed because it is too large Load Diff