Compare commits

..

35 Commits

Author SHA1 Message Date
c4ee967ca9 1.2.19 2018-05-18 13:09:14 +02:00
551b8d0cde fix(package): include npmdocker with npm @gitzone scope 2018-05-18 13:09:14 +02:00
4f23b61e14 update description 2018-01-24 23:51:31 +01:00
799320492a 1.2.18 2017-10-13 18:06:16 +02:00
d2cd294b36 now cleaning up correctly 2017-10-13 18:06:12 +02:00
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
28 changed files with 1108 additions and 1271 deletions

View File

@ -1,28 +1,40 @@
image: hosttoday/ht-docker-dbase:npmts image: hosttoday/ht-docker-dbase:npmci
services: services:
- docker:dind - docker:dind
stages: stages:
- mirror
- test - test
- release - release
- trigger - trigger
- pages
mirror:
image: hosttoday/ht-docker-node:npmci
stage: mirror
script:
- npmci git mirror
tags:
- docker
test: test:
stage: test stage: test
script: script:
- npm install - npmci node install stable
- npm test - npmci npm install
- npmci npm test
tags: tags:
- docker - docker
- lossless - lossless
- priv - priv
release: release:
image: hosttoday/ht-docker-node:npmts
stage: release stage: release
environment: npmjs-com_registry environment: npmjs-com_registry
script: script:
- npmci publish - npmci npm prepare
- npmci npm publish
only: only:
- tags - tags
tags: tags:
@ -31,7 +43,6 @@ release:
- priv - priv
trigger: trigger:
image: hosttoday/ht-docker-node:npmts
stage: trigger stage: trigger
script: script:
- npmci trigger - npmci trigger
@ -41,3 +52,18 @@ trigger:
- docker - docker
- lossless - lossless
- priv - 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,13 +1,16 @@
# npmdocker # npmdocker
develop npm modules cross platform with docker develop npm modules cross platform with docker
## Availabililty ## Availabililty
[![npm](https://gitzone.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/npmdocker) [![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-git.svg)](https://GitLab.com/gitzone/npmdocker)
[![git](https://gitzone.gitlab.io/assets/repo-button-mirror.svg)](https://github.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/) [![docs](https://gitzone.gitlab.io/assets/repo-button-docs.svg)](https://gitzone.gitlab.io/npmdocker/)
## Status for master ## Status for master
[![build status](https://GitLab.com/gitzone/npmdocker/badges/master/build.svg)](https://GitLab.com/gitzone/npmdocker/commits/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) [![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) [![npm downloads per month](https://img.shields.io/npm/dm/npmdocker.svg)](https://www.npmjs.com/package/npmdocker)
@ -19,21 +22,25 @@ develop npm modules cross platform with docker
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/) [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage ## Usage
Use TypeScript for best in class instellisense. Use TypeScript for best in class instellisense.
### Why does this package exist? ### Why does this package exist?
Sometimes you want a clean and fresh linux environment everytime you test your package. 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. Usually this is the default i CI, but locally behaviour tends to defer.
### Where does it work ### Where does it work
The npmdocker package works in everywhere where the docker cli is available. e.g.: The npmdocker package works in everywhere where the docker cli is available. e.g.:
* docker toolbox * docker toolbox
* native docker application * native docker application
* docker in docker * docker in docker
* mounted docker.sock * mounted docker.sock
### How do I use it? ### How do I use it?
create a npmextra.json in the project's root directory create a npmextra.json in the project's root directory
```json ```json
@ -46,14 +53,15 @@ create a npmextra.json in the project's root directory
} }
``` ```
option | description | option | description |
--- | --- | ----------- | ------------------------------------------------------------------------------------- |
baseImage | the base image that is the context for your project | 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 | 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 | 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. For further information read the linked docs at the top of this README.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh) > MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![npm](https://gitzone.gitlab.io/assets/repo-footer.svg)](https://git.zone) [![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 FROM hosttoday/ht-docker-node:npmci
COPY ./buildContextDir /workspace RUN yarn global add npmdocker
COPY ./ /workspace
WORKDIR /workspace WORKDIR /workspace
ENV CI=true ENV CI=true
CMD ["npmci","test","stable"]; CMD ["npmdocker","runinside"];

1
dist/cli.js vendored
View File

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

1
dist/index.d.ts vendored
View File

@ -0,0 +1 @@
export {};

3
dist/index.js vendored
View File

@ -1,4 +1,5 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const cli = require("./npmdocker.cli"); const cli = require("./npmdocker.cli");
cli.run(); cli.run();
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsdUNBQXNDO0FBRXRDLEdBQUcsQ0FBQyxHQUFHLEVBQUUsQ0FBQSJ9 //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUNBLHVDQUF1QztBQUV2QyxHQUFHLENBQUMsR0FBRyxFQUFFLENBQUMifQ==

77
dist/npmdocker.cli.js vendored
View File

@ -1,42 +1,83 @@
"use strict"; "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"); const plugins = require("./npmdocker.plugins");
// modules // modules
const ConfigModule = require("./npmdocker.config"); const ConfigModule = require("./npmdocker.config");
const DockerModule = require("./npmdocker.docker"); 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.
* 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(); let npmdockerCli = new plugins.smartcli.Smartcli();
plugins.beautylog.ora.start();
exports.run = () => { exports.run = () => {
npmdockerCli.standardTask().then(argvArg => { npmdockerCli.standardTask().then((argvArg) => __awaiter(this, void 0, void 0, function* () {
let done = plugins.q.defer(); plugins.beautylog.figletSync('npmdocker');
ConfigModule.run() let configArg = yield ConfigModule.run().then(DockerModule.run);
.then(DockerModule.run)
.then((configArg) => {
done.resolve(configArg);
});
return done.promise;
}).then((configArg) => {
if (configArg.exitCode === 0) { if (configArg.exitCode === 0) {
plugins.beautylog.success('container ended all right!'); plugins.beautylog.success('container ended all right!');
} }
else { else {
plugins.beautylog.error('container ended with error!'); 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); process.exit(1);
} }
}); });
npmdockerCli.addCommand('clean').then(argvArg => { }));
npmdockerCli.addCommand('clean').then((argvArg) => __awaiter(this, void 0, void 0, function* () {
plugins.beautylog.ora.start();
plugins.beautylog.ora.text('cleaning up docker env...'); plugins.beautylog.ora.text('cleaning up docker env...');
if (argvArg.all) { if (argvArg.all) {
plugins.beautylog.ora.text('killing any running docker containers...'); plugins.beautylog.ora.text('killing any running docker containers...');
plugins.shelljs.exec(`docker kill $(docker ps -q)`); yield plugins.smartshell.exec(`docker kill $(docker ps -q)`);
plugins.beautylog.ora.text('removing stopped containers...'); plugins.beautylog.ora.text('removing stopped containers...');
plugins.shelljs.exec(`docker rm $(docker ps -a -q)`); yield plugins.smartshell.exec(`docker rm $(docker ps -a -q)`);
plugins.beautylog.ora.text('removing images...'); plugins.beautylog.ora.text('removing images...');
plugins.shelljs.exec(`docker rmi $(docker images -q -f dangling=true)`); yield plugins.smartshell.exec(`docker rmi $(docker images -q -f dangling=true)`);
plugins.beautylog.ora.text('removing all other images...'); plugins.beautylog.ora.text('removing all other images...');
plugins.shelljs.exec(`docker rmi $(docker images -q)`); 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!'); 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(); npmdockerCli.startParse();
}; };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmNsaS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5jbGkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLCtDQUE4QztBQUc5QyxVQUFVO0FBQ1YsbURBQWtEO0FBQ2xELG1EQUFrRDtBQUVsRCxJQUFJLFlBQVksR0FBRyxJQUFJLE9BQU8sQ0FBQyxRQUFRLENBQUMsUUFBUSxFQUFFLENBQUE7QUFFbEQsT0FBTyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsS0FBSyxFQUFFLENBQUE7QUFDbEIsUUFBQSxHQUFHLEdBQUc7SUFDZixZQUFZLENBQUMsWUFBWSxFQUFFLENBQUMsSUFBSSxDQUFDLE9BQU87UU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yxDQUFBLENBQUMsQ0FBQztJQUVILFlBQVksQ0FBQyxVQUFVLEVBQUUsQ0FBQztBQUM1QixDQUFDLENBQUMifQ==

View File

@ -6,4 +6,4 @@ export interface IConfig {
exitCode?: number; exitCode?: number;
keyValueObjectArray: IKeyValueObject[]; keyValueObjectArray: IKeyValueObject[];
} }
export declare let run: () => Promise<{}>; export declare let run: () => Promise<IConfig>;

View File

@ -1,9 +1,16 @@
"use strict"; "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"); const plugins = require("./npmdocker.plugins");
const paths = require("./npmdocker.paths"); const paths = require("./npmdocker.paths");
; let getQenvKeyValueObject = () => __awaiter(this, void 0, void 0, function* () {
let getQenvKeyValueObject = () => {
let done = plugins.q.defer();
let qenvKeyValueObjectArray; let qenvKeyValueObjectArray;
if (plugins.smartfile.fs.fileExistsSync(plugins.path.join(paths.cwd, 'qenv.yml'))) { if (plugins.smartfile.fs.fileExistsSync(plugins.path.join(paths.cwd, 'qenv.yml'))) {
qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, '.nogit/').keyValueObjectArray; qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, '.nogit/').keyValueObjectArray;
@ -11,27 +18,21 @@ let getQenvKeyValueObject = () => {
else { else {
qenvKeyValueObjectArray = []; qenvKeyValueObjectArray = [];
} }
; return qenvKeyValueObjectArray;
done.resolve(qenvKeyValueObjectArray); });
return done.promise; let buildConfig = (qenvKeyValueObjectArrayArg) => __awaiter(this, void 0, void 0, function* () {
};
let buildConfig = (qenvKeyValueObjectArrayArg) => {
let done = plugins.q.defer();
let npmextra = new plugins.npmextra.Npmextra(paths.cwd); let npmextra = new plugins.npmextra.Npmextra(paths.cwd);
let config = npmextra.dataFor('npmdocker', { let config = npmextra.dataFor('npmdocker', {
baseImage: 'hosttoday/ht-docker-node:npmts', baseImage: 'hosttoday/ht-docker-node:npmdocker',
command: 'npm test', init: 'rm -rf node_nodules/ && yarn install',
command: 'npmci npm test',
dockerSock: false, dockerSock: false,
keyValueObjectArray: qenvKeyValueObjectArrayArg keyValueObjectArray: qenvKeyValueObjectArrayArg
}); });
done.resolve(config); return config;
return done.promise; });
}; exports.run = () => __awaiter(this, void 0, void 0, function* () {
exports.run = () => { let config = yield getQenvKeyValueObject().then(buildConfig);
let done = plugins.q.defer(); return config;
getQenvKeyValueObject() });
.then(buildConfig) //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7OztBQUFBLCtDQUErQztBQUMvQywyQ0FBMkM7QUFhM0MsSUFBSSxxQkFBcUIsR0FBRyxHQUFTLEVBQUU7SUFDckMsSUFBSSx1QkFBMEMsQ0FBQztJQUMvQyxJQUFJLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLGNBQWMsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxFQUFFLFVBQVUsQ0FBQyxDQUFDLEVBQUU7UUFDakYsdUJBQXVCLEdBQUcsSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxFQUFFLFNBQVMsQ0FBQyxDQUFDLG1CQUFtQixDQUFDO0tBQzNG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CLG1CQUFtQixFQUFFLDBCQUEwQjtLQUNoRCxDQUNGLENBQUE7SUFDRCxJQUFJLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFBO0lBQ3BCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0FBQ3JCLENBQUMsQ0FBQTtBQUVVLFFBQUEsR0FBRyxHQUFHO0lBQ2YsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtJQUM1QixxQkFBcUIsRUFBRTtTQUNwQixJQUFJLENBQUMsV0FBVyxDQUFDO1NBQ2pCLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUE7SUFDckIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7QUFDckIsQ0FBQyxDQUFBIn0=

View File

@ -1 +1,2 @@
export declare let run: (configArg: any) => 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 cwd: string;
export declare let packageBase: string; export declare let packageBase: string;
export declare let assets: string; export declare let assets: string;
export declare let buildContextDir: string; export declare let npmdockerFile: string;
export declare let dockerfile: string;

View File

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

View File

@ -1,12 +1,12 @@
import 'typings-global';
import * as beautylog from 'beautylog'; import * as beautylog from 'beautylog';
import * as npmextra from 'npmextra'; import * as npmextra from 'npmextra';
import * as path from 'path'; import * as path from 'path';
import * as projectinfo from 'projectinfo'; import * as projectinfo from 'projectinfo';
import * as q from 'smartq'; import * as q from 'smartq';
import * as qenv from 'qenv'; import * as qenv from 'qenv';
import * as shelljs from 'shelljs'; import * as smartanalytics from 'smartanalytics';
import * as smartcli from 'smartcli'; import * as smartcli from 'smartcli';
import * as smartfile from 'smartfile'; import * as smartfile from 'smartfile';
import * as smartshell from 'smartshell';
import * as smartstring from 'smartstring'; import * as smartstring from 'smartstring';
export { beautylog, npmextra, path, projectinfo, q, qenv, shelljs, smartcli, smartfile, smartstring }; export { beautylog, npmextra, path, projectinfo, q, qenv, smartanalytics, smartcli, smartfile, smartshell, smartstring };

View File

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

View File

@ -1,21 +1,32 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./npmdocker.plugins"); const plugins = require("./npmdocker.plugins");
exports.dockerfileSnippet = (optionsArg) => { let getMountSolutionString = (optionsArg) => {
let commandArray = optionsArg.command.split(/\s/); if (process.env.CI) {
let commandString = ""; return 'COPY ./ /workspace';
for (let stringItem of commandArray) {
if (!(commandString == "")) {
commandString = commandString + ",";
} }
commandString = commandString + '"' + stringItem + '"'; 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnNuaXBwZXRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnNuaXBwZXRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwrQ0FBK0M7QUFPcEMsUUFBQSxpQkFBaUIsR0FBRyxDQUFDLFVBQTZCO0lBQ3pELElBQUksWUFBWSxHQUFHLFVBQVUsQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQ2xELElBQUksYUFBYSxHQUFVLEVBQUUsQ0FBQztJQUM5QixHQUFHLENBQUEsQ0FBQyxJQUFJLFVBQVUsSUFBSSxZQUFZLENBQUMsQ0FBQSxDQUFDO1FBQ2hDLEVBQUUsQ0FBQSxDQUFDLENBQUMsQ0FBQyxhQUFhLElBQUksRUFBRSxDQUFDLENBQUMsQ0FBQSxDQUFDO1lBQ3ZCLGFBQWEsR0FBRyxhQUFhLEdBQUcsR0FBRyxDQUFDO1FBQ3hDLENBQUM7UUFDRCxhQUFhLEdBQUcsYUFBYSxHQUFHLEdBQUcsR0FBRyxVQUFVLEdBQUcsR0FBRyxDQUFDO0lBQzNELENBQUM7SUFBQSxDQUFDO0lBQ0YsTUFBTSxDQUFDLE9BQU8sQ0FBQyxXQUFXLENBQUMsTUFBTSxDQUFDLFNBQVMsQ0FBQztlQUNqQyxVQUFVLENBQUMsU0FBUzs7OztlQUlwQixhQUFhO0tBQ3ZCLENBQUMsQ0FBQztBQUNQLENBQUMsQ0FBQSJ9 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnNuaXBwZXRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnNuaXBwZXRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsK0NBQStDO0FBTy9DLElBQUksc0JBQXNCLEdBQUcsQ0FBQyxVQUE4QixFQUFFLEVBQUU7SUFDOUQsSUFBSSxPQUFPLENBQUMsR0FBRyxDQUFDLEVBQUUsRUFBRTtRQUNsQixPQUFPLG9CQUFvQixDQUFDO0tBQzdCO1NBQU07UUFDTCxPQUFPLHlDQUF5QyxDQUFDO0tBQ2xEO0FBQ0gsQ0FBQyxDQUFDO0FBRUYsSUFBSSwwQkFBMEIsR0FBRyxDQUFDLFVBQThCLEVBQUUsRUFBRTtJQUNsRSxJQUFJLFVBQVUsQ0FBQyxTQUFTLEtBQUssb0NBQW9DLEVBQUU7UUFDakUsT0FBTywrQkFBK0IsQ0FBQztLQUN4QztTQUFNO1FBQ0wsT0FBTyxtRUFBbUUsQ0FBQztLQUM1RTtBQUNILENBQUMsQ0FBQztBQUVTLFFBQUEsaUJBQWlCLEdBQUcsQ0FBQyxVQUE4QixFQUFVLEVBQUU7SUFDeEUsT0FBTyxPQUFPLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxTQUFTLENBQ3pDO09BQ0csVUFBVSxDQUFDLFNBQVM7O0VBRXpCLDBCQUEwQixDQUFDLFVBQVUsQ0FBQztFQUN0QyxzQkFBc0IsQ0FBQyxVQUFVLENBQUM7Ozs7O0NBS25DLENBQ0UsQ0FBQztBQUNKLENBQUMsQ0FBQyJ9

1
docs/index.md Normal file
View File

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

View File

@ -1,7 +1,13 @@
{ {
"npmts":{ "npmts": {
"mode":"default", "mode": "default",
"cli":true, "cli": true
"dockerSock":true },
"npmci": {
"npmGlobalTools": [
"@gitzone/npmts",
"ts-node"
],
"npmAccessLevel": "public"
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "npmdocker", "name": "@gitzone/npmdocker",
"version": "1.2.3", "version": "1.2.19",
"description": "develop npm modules cross platform with docker", "description": "develop npm modules cross platform with docker",
"main": "dist/index.js", "main": "dist/index.js",
"typings": "dist/index.d.ts", "typings": "dist/index.d.ts",
@ -11,8 +11,9 @@
"test": "test" "test": "test"
}, },
"scripts": { "scripts": {
"test": "(npm run clean && npm run compile && npm run setupCheck && npm run testStandard && npm run testClean)", "test": "(npm run clean && npm run compile && npm run setupCheck && npm run testStandard && npm run testSpeed)",
"testStandard": "(cd test/ && node ../dist/index.js)", "testStandard": "(cd test/ && node ../dist/index.js)",
"testSpeed": "(cd test/ && node ../dist/index.js speedtest)",
"testClean": "(cd test/ && node ../dist/index.js clean --all)", "testClean": "(cd test/ && node ../dist/index.js clean --all)",
"clean": "(rm -rf test/)", "clean": "(rm -rf test/)",
"compile": "(npmts --notest)", "compile": "(npmts --notest)",
@ -31,20 +32,19 @@
"url": "https://gitlab.com/gitzone/npmdocker/issues" "url": "https://gitlab.com/gitzone/npmdocker/issues"
}, },
"homepage": "https://gitlab.com/gitzone/npmdocker#README", "homepage": "https://gitlab.com/gitzone/npmdocker#README",
"devDependencies": { "devDependencies": {},
"npmts-g": "^6.0.0"
},
"dependencies": { "dependencies": {
"@types/shelljs": "0.x.x", "@types/shelljs": "0.x.x",
"beautylog": "^6.1.1", "beautylog": "^6.1.10",
"npmextra": "^2.0.3", "npmextra": "^2.0.9",
"projectinfo": "^3.0.1", "projectinfo": "^3.0.4",
"qenv": "^1.1.3", "qenv": "^1.1.7",
"shelljs": "^0.7.6", "smartanalytics": "^2.0.9",
"smartcli": "^2.0.1", "smartcli": "^2.0.7",
"smartfile": "^4.1.5", "smartfile": "^4.2.26",
"smartq": "^1.1.0", "smartq": "^1.1.6",
"smartstring": "^2.0.22", "smartshell": "^1.0.18",
"typings-global": "^1.0.14" "smartstring": "^2.0.24",
"typings-global": "^1.0.20"
} }
} }

View File

@ -1,4 +1,4 @@
import * as plugins from './npmdocker.plugins' import * as plugins from './npmdocker.plugins';
import * as cli from './npmdocker.cli' import * as cli from './npmdocker.cli';
cli.run() cli.run();

View File

@ -1,48 +1,86 @@
import * as plugins from './npmdocker.plugins' import * as plugins from './npmdocker.plugins';
import * as paths from './npmdocker.paths' import * as paths from './npmdocker.paths';
// modules // modules
import * as ConfigModule from './npmdocker.config' import * as ConfigModule from './npmdocker.config';
import * as DockerModule from './npmdocker.docker' import * as DockerModule from './npmdocker.docker';
let npmdockerCli = new plugins.smartcli.Smartcli() /**
* 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.
* 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();
plugins.beautylog.ora.start()
export let run = () => { export let run = () => {
npmdockerCli.standardTask().then(argvArg => { npmdockerCli.standardTask().then(async argvArg => {
let done = plugins.q.defer() plugins.beautylog.figletSync('npmdocker');
ConfigModule.run() let configArg = await ConfigModule.run().then(DockerModule.run);
.then(DockerModule.run)
.then((configArg) => {
done.resolve(configArg)
})
return done.promise
}).then((configArg: ConfigModule.IConfig) => {
if (configArg.exitCode === 0) { if (configArg.exitCode === 0) {
plugins.beautylog.success('container ended all right!') plugins.beautylog.success('container ended all right!');
} else { } else {
plugins.beautylog.error('container ended with error!') plugins.beautylog.error(`container ended with error! Exit Code is ${configArg.exitCode}`);
process.exit(1) process.exit(1);
} }
}) });
npmdockerCli.addCommand('clean').then(argvArg => { /**
plugins.beautylog.ora.text('cleaning up docker env...') * 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) { if (argvArg.all) {
plugins.beautylog.ora.text('killing any running docker containers...') plugins.beautylog.ora.text('killing any running docker containers...');
plugins.shelljs.exec(`docker kill $(docker ps -q)`) await plugins.smartshell.exec(`docker kill $(docker ps -q)`);
plugins.beautylog.ora.text('removing stopped containers...') plugins.beautylog.ora.text('removing stopped containers...');
plugins.shelljs.exec(`docker rm $(docker ps -a -q)`) await plugins.smartshell.exec(`docker rm $(docker ps -a -q)`);
plugins.beautylog.ora.text('removing images...') plugins.beautylog.ora.text('removing images...');
plugins.shelljs.exec(`docker rmi $(docker images -q -f dangling=true)`) await plugins.smartshell.exec(`docker rmi $(docker images -q -f dangling=true)`);
plugins.beautylog.ora.text('removing all other images...') plugins.beautylog.ora.text('removing all other images...');
plugins.shelljs.exec(`docker rmi $(docker images -q)`) 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!') plugins.beautylog.ora.endOk('docker environment now is clean!');
}) });
npmdockerCli.startParse() 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,49 +1,40 @@
import * as plugins from './npmdocker.plugins' import * as plugins from './npmdocker.plugins';
import * as paths from "./npmdocker.paths" import * as paths from './npmdocker.paths';
// interfaces // interfaces
import { IKeyValueObject } from 'qenv' import { IKeyValueObject } from 'qenv';
export interface IConfig { export interface IConfig {
baseImage: string baseImage: string;
command: string command: string;
dockerSock: boolean dockerSock: boolean;
exitCode?: number exitCode?: number;
keyValueObjectArray: IKeyValueObject[] 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 getQenvKeyValueObject = () => { let buildConfig = async (qenvKeyValueObjectArrayArg: IKeyValueObject[]) => {
let done = plugins.q.defer() let npmextra = new plugins.npmextra.Npmextra(paths.cwd);
let qenvKeyValueObjectArray: IKeyValueObject[] let config = npmextra.dataFor<IConfig>('npmdocker', {
if (plugins.smartfile.fs.fileExistsSync(plugins.path.join(paths.cwd, 'qenv.yml'))) { baseImage: 'hosttoday/ht-docker-node:npmdocker',
qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, '.nogit/').keyValueObjectArray init: 'rm -rf node_nodules/ && yarn install',
} else { command: 'npmci npm test',
qenvKeyValueObjectArray = []
};
done.resolve(qenvKeyValueObjectArray)
return done.promise
}
let buildConfig = (qenvKeyValueObjectArrayArg: IKeyValueObject) => {
let done = plugins.q.defer()
let npmextra = new plugins.npmextra.Npmextra(paths.cwd)
let config = npmextra.dataFor<IConfig>(
'npmdocker',
{
baseImage: 'hosttoday/ht-docker-node:npmts',
command: 'npm test',
dockerSock: false, dockerSock: false,
keyValueObjectArray: qenvKeyValueObjectArrayArg keyValueObjectArray: qenvKeyValueObjectArrayArg
} });
) return config;
done.resolve(config) };
return done.promise
}
export let run = () => { export let run = async (): Promise<IConfig> => {
let done = plugins.q.defer() let config = await getQenvKeyValueObject().then(buildConfig);
getQenvKeyValueObject() return config;
.then(buildConfig) };
.then(done.resolve)
return done.promise
}

View File

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

View File

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

View File

@ -1,14 +1,14 @@
import 'typings-global' import * as beautylog from 'beautylog';
import * as beautylog from 'beautylog' import * as npmextra from 'npmextra';
import * as npmextra from 'npmextra' import * as path from 'path';
import * as path from 'path' import * as projectinfo from 'projectinfo';
import * as projectinfo from 'projectinfo' import * as q from 'smartq';
import * as q from 'smartq' import * as qenv from 'qenv';
import * as qenv from 'qenv' import * as smartanalytics from 'smartanalytics';
import * as shelljs from 'shelljs' import * as smartcli from 'smartcli';
import * as smartcli from 'smartcli' import * as smartfile from 'smartfile';
import * as smartfile from 'smartfile' import * as smartshell from 'smartshell';
import * as smartstring from 'smartstring' import * as smartstring from 'smartstring';
export { export {
beautylog, beautylog,
@ -17,8 +17,9 @@ export {
projectinfo, projectinfo,
q, q,
qenv, qenv,
shelljs, smartanalytics,
smartcli, smartcli,
smartfile, smartfile,
smartshell,
smartstring smartstring
} };

View File

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

1374
yarn.lock

File diff suppressed because it is too large Load Diff