update dependencies and README
This commit is contained in:
parent
74374e99d7
commit
eab75f03da
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,6 +1,8 @@
|
||||
node_modules/
|
||||
coverage/
|
||||
docs/
|
||||
pages/
|
||||
public/
|
||||
|
||||
test/
|
||||
assets/
|
||||
.nogit/
|
||||
|
56
README.md
56
README.md
@ -1,5 +1,59 @@
|
||||
# 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 | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
|
||||
[![npm](https://gitzone.gitlab.io/assets/repo-footer.svg)](https://git.zone)
|
||||
|
@ -2,4 +2,4 @@ FROM hosttoday/ht-docker-node:npmts
|
||||
COPY ./buildContextDir /workspace
|
||||
WORKDIR /workspace
|
||||
ENV CI=true
|
||||
CMD ["npm","run","npmdocker"];
|
||||
CMD ["npmci","test","stable"];
|
||||
|
2
dist/cli.js
vendored
2
dist/cli.js
vendored
@ -1,2 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
var index = require("./index.js");
|
||||
var index = require("../dist/index.js");
|
2
dist/index.js
vendored
2
dist/index.js
vendored
@ -11,4 +11,4 @@ promisechain.run()
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0scUJBQXFCLENBQUMsQ0FBQTtBQUMvQyxNQUFZLFlBQVksV0FBTSwwQkFBMEIsQ0FBQyxDQUFBO0FBSXpELFlBQVksQ0FBQyxHQUFHLEVBQUU7S0FDYixJQUFJLENBQUMsQ0FBQyxTQUE4QjtJQUNqQyxFQUFFLENBQUEsQ0FBQyxTQUFTLENBQUMsUUFBUSxJQUFJLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDeEIsT0FBTyxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMsNEJBQTRCLENBQUMsQ0FBQztJQUM1RCxDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyw2QkFBNkIsQ0FBQyxDQUFDO1FBQ3ZELE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFDcEIsQ0FBQztBQUNMLENBQUMsQ0FBQyxDQUFDIn0=
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsK0NBQStDO0FBQy9DLHlEQUF5RDtBQUl6RCxZQUFZLENBQUMsR0FBRyxFQUFFO0tBQ2IsSUFBSSxDQUFDLENBQUMsU0FBOEI7SUFDakMsRUFBRSxDQUFBLENBQUMsU0FBUyxDQUFDLFFBQVEsSUFBSSxDQUFDLENBQUMsQ0FBQSxDQUFDO1FBQ3hCLE9BQU8sQ0FBQyxTQUFTLENBQUMsT0FBTyxDQUFDLDRCQUE0QixDQUFDLENBQUM7SUFDNUQsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0osT0FBTyxDQUFDLFNBQVMsQ0FBQyxLQUFLLENBQUMsNkJBQTZCLENBQUMsQ0FBQztRQUN2RCxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyxDQUFDO0lBQ3BCLENBQUM7QUFDTCxDQUFDLENBQUMsQ0FBQyJ9
|
6
dist/npmdocker.config.d.ts
vendored
6
dist/npmdocker.config.d.ts
vendored
@ -1,6 +1,4 @@
|
||||
/// <reference types="q" />
|
||||
import * as plugins from "./npmdocker.plugins";
|
||||
import { IKeyValueObject } from "qenv";
|
||||
import { IKeyValueObject } from 'qenv';
|
||||
export interface IConfig {
|
||||
baseImage: string;
|
||||
command: string;
|
||||
@ -8,4 +6,4 @@ export interface IConfig {
|
||||
exitCode?: number;
|
||||
keyValueObjectArray: IKeyValueObject[];
|
||||
}
|
||||
export declare let run: () => plugins.q.Promise<{}>;
|
||||
export declare let run: () => Promise<{}>;
|
||||
|
16
dist/npmdocker.config.js
vendored
16
dist/npmdocker.config.js
vendored
@ -5,8 +5,8 @@ const paths = require("./npmdocker.paths");
|
||||
let getQenvKeyValueObject = () => {
|
||||
let done = plugins.q.defer();
|
||||
let qenvKeyValueObjectArray;
|
||||
if (plugins.smartfile.fs.fileExistsSync(plugins.path.join(paths.cwd, "qenv.yml"))) {
|
||||
qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, ".nogit/").keyValueObjectArray;
|
||||
if (plugins.smartfile.fs.fileExistsSync(plugins.path.join(paths.cwd, 'qenv.yml'))) {
|
||||
qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, '.nogit/').keyValueObjectArray;
|
||||
}
|
||||
else {
|
||||
qenvKeyValueObjectArray = [];
|
||||
@ -17,14 +17,12 @@ let getQenvKeyValueObject = () => {
|
||||
};
|
||||
let buildConfig = (qenvKeyValueObjectArrayArg) => {
|
||||
let done = plugins.q.defer();
|
||||
let config = plugins.npmextra.dataFor({
|
||||
toolName: "npmdocker",
|
||||
defaultSettings: {
|
||||
baseImage: "hosttoday/ht-docker-node:npmts",
|
||||
command: "npm run npmdocker",
|
||||
let npmextra = new plugins.npmextra.Npmextra(paths.cwd);
|
||||
let config = npmextra.dataFor('npmdocker', {
|
||||
baseImage: 'hosttoday/ht-docker-node:npmts',
|
||||
command: 'npm test',
|
||||
dockerSock: false,
|
||||
keyValueObjectArray: qenvKeyValueObjectArrayArg
|
||||
}
|
||||
});
|
||||
done.resolve(config);
|
||||
return done.promise;
|
||||
@ -36,4 +34,4 @@ exports.run = () => {
|
||||
.then(done.resolve);
|
||||
return done.promise;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFDL0MsTUFBWSxLQUFLLFdBQU0sbUJBQW1CLENBQUMsQ0FBQTtBQVcxQyxDQUFDO0FBRUYsSUFBSSxxQkFBcUIsR0FBRztJQUN4QixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLElBQUksdUJBQXlDLENBQUM7SUFDOUMsRUFBRSxDQUFBLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsY0FBYyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxHQUFHLEVBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFBLENBQU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UcsQ0FBQywwQkFBMkM7SUFDNUQsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtJQUM1QixJQUFJLFFBQVEsR0FBRyxJQUFJLE9BQU8sQ0FBQyxRQUFRLENBQUMsUUFBUSxDQUFDLEtBQUssQ0FBQyxHQUFHLENBQUMsQ0FBQTtJQUN2RCxJQUFJLE1BQU0sR0FBRyxRQUFRLENBQUMsT0FBTyxDQUMzQixXQUFXLEVBQ1g7UUFDRSxTQUFTLEVBQUUsZ0NBQWdDO1FBQzNDLE9BQU8sRUFBRSxVQUFVO1FBQ25CLFVBQVUsRUFBRSxLQUFLO1FBQ2pCLG1CQUFtQixFQUFFLDBCQUEwQjtLQUNoRCxDQUNGLENBQUE7SUFDRCxJQUFJLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFBO0lBQ3BCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0FBQ3JCLENBQUMsQ0FBQTtBQUVVLFFBQUEsR0FBRyxHQUFHO0lBQ2YsSUFBSSxJQUFJLEdBQUcsT0FBTyxDQUFDLENBQUMsQ0FBQyxLQUFLLEVBQUUsQ0FBQTtJQUM1QixxQkFBcUIsRUFBRTtTQUNwQixJQUFJLENBQUMsV0FBVyxDQUFDO1NBQ2pCLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLENBQUE7SUFDckIsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7QUFDckIsQ0FBQyxDQUFBIn0=
|
4
dist/npmdocker.docker.d.ts
vendored
4
dist/npmdocker.docker.d.ts
vendored
@ -1,3 +1 @@
|
||||
/// <reference types="q" />
|
||||
import * as plugins from "./npmdocker.plugins";
|
||||
export declare let run: (configArg: any) => plugins.q.Promise<{}>;
|
||||
export declare let run: (configArg: any) => Promise<{}>;
|
||||
|
54
dist/npmdocker.docker.js
vendored
54
dist/npmdocker.docker.js
vendored
File diff suppressed because one or more lines are too long
2
dist/npmdocker.paths.js
vendored
2
dist/npmdocker.paths.js
vendored
@ -9,4 +9,4 @@ 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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxxQkFBcUIsQ0FBQyxDQUFBO0FBRS9DLGNBQWM7QUFDSCxXQUFHLEdBQUcsT0FBTyxDQUFDLEdBQUcsRUFBRSxDQUFDO0FBQ3BCLG1CQUFXLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFFLEtBQUssQ0FBQyxDQUFDO0FBQ2xELGNBQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxtQkFBVyxFQUFFLFNBQVMsQ0FBQyxDQUFDO0FBQzlELE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLGFBQWEsQ0FBQyxjQUFNLENBQUMsQ0FBQztBQUVoQyx1QkFBZSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLGNBQU0sRUFBQyxpQkFBaUIsQ0FBQyxDQUFDO0FBQ3pFLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLGFBQWEsQ0FBQyx1QkFBZSxDQUFDLENBQUM7QUFFcEQsUUFBUTtBQUNHLGtCQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsY0FBTSxFQUFFLFlBQVksQ0FBQyxDQUFDIn0=
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwrQ0FBK0M7QUFFL0MsY0FBYztBQUNILFFBQUEsR0FBRyxHQUFHLE9BQU8sQ0FBQyxHQUFHLEVBQUUsQ0FBQztBQUNwQixRQUFBLFdBQVcsR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUUsS0FBSyxDQUFDLENBQUM7QUFDbEQsUUFBQSxNQUFNLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsbUJBQVcsRUFBRSxTQUFTLENBQUMsQ0FBQztBQUM5RCxPQUFPLENBQUMsU0FBUyxDQUFDLEVBQUUsQ0FBQyxhQUFhLENBQUMsY0FBTSxDQUFDLENBQUM7QUFFaEMsUUFBQSxlQUFlLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsY0FBTSxFQUFDLGlCQUFpQixDQUFDLENBQUM7QUFDekUsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsYUFBYSxDQUFDLHVCQUFlLENBQUMsQ0FBQztBQUVwRCxRQUFRO0FBQ0csUUFBQSxVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsY0FBTSxFQUFFLFlBQVksQ0FBQyxDQUFDIn0=
|
2
dist/npmdocker.plugins.d.ts
vendored
2
dist/npmdocker.plugins.d.ts
vendored
@ -3,7 +3,7 @@ export import beautylog = require("beautylog");
|
||||
export import npmextra = require("npmextra");
|
||||
export import path = require("path");
|
||||
export import projectinfo = require("projectinfo");
|
||||
export import q = require("q");
|
||||
export import q = require("smartq");
|
||||
export import qenv = require("qenv");
|
||||
export import shelljs = require("shelljs");
|
||||
export import smartfile = require("smartfile");
|
||||
|
4
dist/npmdocker.plugins.js
vendored
4
dist/npmdocker.plugins.js
vendored
@ -4,9 +4,9 @@ exports.beautylog = require("beautylog");
|
||||
exports.npmextra = require("npmextra");
|
||||
exports.path = require("path");
|
||||
exports.projectinfo = require("projectinfo");
|
||||
exports.q = require("q");
|
||||
exports.q = require("smartq");
|
||||
exports.qenv = require("qenv");
|
||||
exports.shelljs = require("shelljs");
|
||||
exports.smartfile = require("smartfile");
|
||||
exports.smartstring = require("smartstring");
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9ucG1kb2NrZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ1YsaUJBQVMsV0FBVyxXQUFXLENBQUMsQ0FBQztBQUNqQyxnQkFBUSxXQUFXLFVBQVUsQ0FBQyxDQUFDO0FBQy9CLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixtQkFBVyxXQUFXLGFBQWEsQ0FBQyxDQUFDO0FBQ3JDLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQztBQUNqQixZQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDdkIsZUFBTyxXQUFXLFNBQVMsQ0FBQyxDQUFDO0FBQzdCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsbUJBQVcsV0FBVyxhQUFhLENBQUMsQ0FBQyJ9
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9ucG1kb2NrZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsMEJBQXdCO0FBQ3hCLHlDQUErQztBQUMvQyx1Q0FBNkM7QUFDN0MsK0JBQXFDO0FBQ3JDLDZDQUFtRDtBQUNuRCw4QkFBb0M7QUFDcEMsK0JBQXFDO0FBQ3JDLHFDQUEyQztBQUMzQyx5Q0FBK0M7QUFDL0MsNkNBQW1EIn0=
|
6
dist/npmdocker.promisechain.d.ts
vendored
6
dist/npmdocker.promisechain.d.ts
vendored
@ -1,5 +1 @@
|
||||
/// <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<{}>;
|
||||
export declare let run: () => Promise<{}>;
|
||||
|
6
dist/npmdocker.promisechain.js
vendored
6
dist/npmdocker.promisechain.js
vendored
@ -1,11 +1,9 @@
|
||||
"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();
|
||||
plugins.beautylog.ora.start();
|
||||
exports.run = () => {
|
||||
let done = plugins.q.defer();
|
||||
ConfigModule.run()
|
||||
@ -15,4 +13,4 @@ exports.run = () => {
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnByb21pc2VjaGFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5wcm9taXNlY2hhaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBT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HLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsWUFBWSxDQUFDLEdBQUcsRUFBRTtTQUNiLElBQUksQ0FBQyxZQUFZLENBQUMsR0FBRyxDQUFDO1NBQ3RCLElBQUksQ0FBQyxDQUFDLFNBQVM7UUFDWixJQUFJLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0lBQzVCLENBQUMsQ0FBQyxDQUFBO0lBQ04sTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7QUFDeEIsQ0FBQyxDQUFBIn0=
|
2
dist/npmdocker.snippets.js
vendored
2
dist/npmdocker.snippets.js
vendored
@ -18,4 +18,4 @@ exports.dockerfileSnippet = (optionsArg) => {
|
||||
CMD [${commandString}];
|
||||
`);
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnNuaXBwZXRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnNuaXBwZXRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxxQkFBcUIsQ0FBQyxDQUFBO0FBT3BDLHlCQUFpQixHQUFHLENBQUMsVUFBNkI7SUFDekQsSUFBSSxZQUFZLEdBQUcsVUFBVSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDbEQsSUFBSSxhQUFhLEdBQVUsRUFBRSxDQUFDO0lBQzlCLEdBQUcsQ0FBQSxDQUFDLElBQUksVUFBVSxJQUFJLFlBQVksQ0FBQyxDQUFBLENBQUM7UUFDaEMsRUFBRSxDQUFBLENBQUMsQ0FBQyxDQUFDLGFBQWEsSUFBSSxFQUFFLENBQUMsQ0FBQyxDQUFBLENBQUM7WUFDdkIsYUFBYSxHQUFHLGFBQWEsR0FBRyxH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BQyxXQUFXLENBQUMsTUFBTSxDQUFDLFNBQVMsQ0FBQztlQUNqQyxVQUFVLENBQUMsU0FBUzs7OztlQUlwQixhQUFhO0tBQ3ZCLENBQUMsQ0FBQztBQUNQLENBQUMsQ0FBQSJ9
|
28
package.json
28
package.json
@ -12,6 +12,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"test": "(npm run clean && npm run compile && npm run setupCheck && npm run check)",
|
||||
"testDev": "(npm run compile && npm run check)",
|
||||
"clean": "(rm -rf test/)",
|
||||
"compile": "(npmts --notest)",
|
||||
"setupCheck": "(git clone https://gitlab.com/sandboxzone/sandbox-npmts.git test/)",
|
||||
@ -19,7 +20,7 @@
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@gitlab.com/pushrocks/npmdocker.git"
|
||||
"url": "git+ssh://git@gitlab.com/gitzone/npmdocker.git"
|
||||
},
|
||||
"keywords": [
|
||||
"docker"
|
||||
@ -27,23 +28,22 @@
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://gitlab.com/pushrocks/npmdocker/issues"
|
||||
"url": "https://gitlab.com/gitzone/npmdocker/issues"
|
||||
},
|
||||
"homepage": "https://gitlab.com/pushrocks/npmdocker#README",
|
||||
"homepage": "https://gitlab.com/gitzone/npmdocker#README",
|
||||
"devDependencies": {
|
||||
"npmts-g": "^5.2.8"
|
||||
"npmts-g": "^6.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/q": "0.x.x",
|
||||
"@types/shelljs": "0.x.x",
|
||||
"beautylog": "^5.0.20",
|
||||
"npmextra": "^1.0.8",
|
||||
"projectinfo": "^1.0.3",
|
||||
"q": "^1.4.1",
|
||||
"qenv": "^1.1.1",
|
||||
"shelljs": "^0.7.3",
|
||||
"smartfile": "^4.0.13",
|
||||
"smartstring": "^2.0.17",
|
||||
"typings-global": "^1.0.6"
|
||||
"beautylog": "^6.1.1",
|
||||
"npmextra": "^2.0.3",
|
||||
"projectinfo": "^3.0.1",
|
||||
"qenv": "^1.1.3",
|
||||
"shelljs": "^0.7.6",
|
||||
"smartfile": "^4.1.5",
|
||||
"smartq": "^1.1.0",
|
||||
"smartstring": "^2.0.22",
|
||||
"typings-global": "^1.0.14"
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +1,49 @@
|
||||
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";
|
||||
import { IKeyValueObject } from 'qenv'
|
||||
|
||||
export interface IConfig {
|
||||
baseImage: string;
|
||||
command: string;
|
||||
dockerSock: boolean;
|
||||
exitCode?: number;
|
||||
keyValueObjectArray: IKeyValueObject[];
|
||||
baseImage: string
|
||||
command: string
|
||||
dockerSock: boolean
|
||||
exitCode?: number
|
||||
keyValueObjectArray: IKeyValueObject[]
|
||||
};
|
||||
|
||||
let getQenvKeyValueObject = () => {
|
||||
let done = plugins.q.defer();
|
||||
let qenvKeyValueObjectArray:IKeyValueObject[];
|
||||
if(plugins.smartfile.fs.fileExistsSync(plugins.path.join(paths.cwd,"qenv.yml"))){
|
||||
qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, ".nogit/").keyValueObjectArray;
|
||||
let done = plugins.q.defer()
|
||||
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 = [];
|
||||
};
|
||||
done.resolve(qenvKeyValueObjectArray);
|
||||
return done.promise;
|
||||
qenvKeyValueObjectArray = []
|
||||
};
|
||||
done.resolve(qenvKeyValueObjectArray)
|
||||
return done.promise
|
||||
}
|
||||
|
||||
let buildConfig = (qenvKeyValueObjectArrayArg: IKeyValueObject) => {
|
||||
let done = plugins.q.defer();
|
||||
let config: IConfig = plugins.npmextra.dataFor({
|
||||
toolName: "npmdocker",
|
||||
defaultSettings: {
|
||||
baseImage: "hosttoday/ht-docker-node:npmts",
|
||||
command: "npm run npmdocker",
|
||||
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,
|
||||
keyValueObjectArray: qenvKeyValueObjectArrayArg
|
||||
}
|
||||
});
|
||||
done.resolve(config);
|
||||
)
|
||||
done.resolve(config)
|
||||
return done.promise
|
||||
};
|
||||
}
|
||||
|
||||
export let run = () => {
|
||||
let done = plugins.q.defer();
|
||||
let done = plugins.q.defer()
|
||||
getQenvKeyValueObject()
|
||||
.then(buildConfig)
|
||||
.then(done.resolve);
|
||||
return done.promise;
|
||||
.then(done.resolve)
|
||||
return done.promise
|
||||
}
|
@ -1,170 +1,197 @@
|
||||
import * as plugins from "./npmdocker.plugins";
|
||||
import * as paths from "./npmdocker.paths";
|
||||
import * as snippets from "./npmdocker.snippets";
|
||||
|
||||
import { npmdockerOra } from "./npmdocker.promisechain";
|
||||
import * as plugins from './npmdocker.plugins';
|
||||
import * as paths from './npmdocker.paths';
|
||||
import * as snippets from './npmdocker.snippets'
|
||||
|
||||
// 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
|
||||
*/
|
||||
let dockerData = {
|
||||
imageTag: "npmdocker-temp-image:latest",
|
||||
containerName: "npmdocker-temp-container",
|
||||
dockerProjectMountString: "",
|
||||
dockerSockString: "",
|
||||
dockerEnvString: ""
|
||||
};
|
||||
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();
|
||||
let done = plugins.q.defer()
|
||||
plugins.beautylog.ora.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"));
|
||||
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
|
||||
*/
|
||||
let buildDockerFile = () => {
|
||||
let done = plugins.q.defer();
|
||||
npmdockerOra.text("building Dockerfile...");
|
||||
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, paths.dockerfile);
|
||||
plugins.beautylog.ok("Dockerfile created!");
|
||||
done.resolve();
|
||||
})
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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}`, {
|
||||
let done = plugins.q.defer()
|
||||
plugins.beautylog.ora.text('pulling latest base image from registry...')
|
||||
plugins.shelljs.exec(
|
||||
`docker pull ${config.baseImage}`,
|
||||
{
|
||||
silent: true
|
||||
}, () => {
|
||||
npmdockerOra.text("building Dockerimage...");
|
||||
},
|
||||
() => {
|
||||
plugins.beautylog.ora.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);
|
||||
if (process.env.CI === 'true') {
|
||||
plugins.beautylog.ora.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}`, {
|
||||
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
|
||||
},
|
||||
() => {
|
||||
plugins.beautylog.ok('Dockerimage built!')
|
||||
done.resolve()
|
||||
}
|
||||
)
|
||||
}
|
||||
) // first pull latest version of baseImage
|
||||
return done.promise
|
||||
};
|
||||
}
|
||||
|
||||
let buildDockerProjectMountString = () => {
|
||||
let done = plugins.q.defer();
|
||||
if (process.env.CI != "true") {
|
||||
dockerData.dockerProjectMountString = `-v ${paths.cwd}:/workspace`;
|
||||
let done = plugins.q.defer()
|
||||
if (process.env.CI !== 'true') {
|
||||
dockerData.dockerProjectMountString = `-v ${paths.cwd}:/workspace`
|
||||
};
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* builds an environment string that docker cli understands
|
||||
*/
|
||||
let buildDockerEnvString = () => {
|
||||
let done = plugins.q.defer();
|
||||
let done = plugins.q.defer()
|
||||
for (let keyValueObjectArg of config.keyValueObjectArray) {
|
||||
let envString = dockerData.dockerEnvString = dockerData.dockerEnvString + `-e ${keyValueObjectArg.key}=${keyValueObjectArg.value} `
|
||||
};
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* creates string to mount the docker.sock inside the testcontainer
|
||||
*/
|
||||
let buildDockerSockString = () => {
|
||||
let done = plugins.q.defer();
|
||||
let done = plugins.q.defer()
|
||||
if (config.dockerSock) {
|
||||
dockerData.dockerSockString = `-v /var/run/docker.sock:/var/run/docker.sock`
|
||||
};
|
||||
done.resolve()
|
||||
return done;
|
||||
};
|
||||
return done
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a container by running the built Dockerimage
|
||||
*/
|
||||
let runDockerImage = () => {
|
||||
let done = plugins.q.defer();
|
||||
npmdockerOra.text("starting Container...");
|
||||
npmdockerOra.end();
|
||||
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;
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
let done = plugins.q.defer()
|
||||
plugins.beautylog.ora.text('starting Container...')
|
||||
plugins.beautylog.ora.end()
|
||||
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
|
||||
done.resolve()
|
||||
return done.promise
|
||||
}
|
||||
|
||||
/**
|
||||
* cleans up: deletes the test container
|
||||
*/
|
||||
let deleteDockerContainer = () => {
|
||||
let done = plugins.q.defer();
|
||||
let done = plugins.q.defer()
|
||||
plugins.shelljs.exec(`docker rm -f ${dockerData.containerName}`, {
|
||||
silent: true
|
||||
});
|
||||
done.resolve();
|
||||
})
|
||||
done.resolve()
|
||||
return done.promise
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* cleans up deletes the test image
|
||||
*/
|
||||
let deleteDockerImage = () => {
|
||||
let done = plugins.q.defer();
|
||||
let done = plugins.q.defer()
|
||||
plugins.shelljs.exec(`docker rmi ${dockerData.imageTag}`, {
|
||||
silent: true
|
||||
});
|
||||
done.resolve();
|
||||
})
|
||||
done.resolve()
|
||||
return done.promise
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* cleans up, deletes the build context
|
||||
*/
|
||||
let deleteBuildContext = () => {
|
||||
let done = plugins.q.defer();
|
||||
let done = plugins.q.defer()
|
||||
plugins.smartfile.fs.remove(paths.buildContextDir)
|
||||
.then(done.resolve);
|
||||
return done.promise;
|
||||
};
|
||||
.then(() => {
|
||||
done.resolve()
|
||||
})
|
||||
return done.promise
|
||||
}
|
||||
|
||||
let preClean = () => {
|
||||
let done = plugins.q.defer();
|
||||
let done = plugins.q.defer()
|
||||
deleteDockerImage()
|
||||
.then(deleteDockerContainer)
|
||||
.then(() => {
|
||||
plugins.beautylog.ok("ensured clean Docker environment!");
|
||||
done.resolve();
|
||||
});
|
||||
};
|
||||
plugins.beautylog.ok('ensured clean Docker environment!')
|
||||
done.resolve()
|
||||
})
|
||||
}
|
||||
|
||||
let postClean = () => {
|
||||
let done = plugins.q.defer();
|
||||
let done = plugins.q.defer()
|
||||
deleteDockerContainer()
|
||||
.then(deleteDockerImage)
|
||||
.then(deleteBuildContext)
|
||||
.then(() => {
|
||||
plugins.beautylog.ok("cleaned up!");
|
||||
done.resolve();
|
||||
});
|
||||
plugins.beautylog.ok('cleaned up!')
|
||||
done.resolve()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
export let run = (configArg) => {
|
||||
let done = plugins.q.defer();
|
||||
config = configArg;
|
||||
let done = plugins.q.defer()
|
||||
config = configArg
|
||||
checkDocker()
|
||||
.then(preClean)
|
||||
.then(buildDockerFile)
|
||||
@ -176,6 +203,6 @@ export let run = (configArg) => {
|
||||
.then(postClean)
|
||||
.then(() => {
|
||||
done.resolve(config);
|
||||
}).catch(err => {console.log(err)});
|
||||
return done.promise;
|
||||
}).catch(err => { console.log(err) })
|
||||
return done.promise
|
||||
}
|
@ -3,7 +3,7 @@ export import beautylog = require("beautylog");
|
||||
export import npmextra = require("npmextra");
|
||||
export import path = require("path");
|
||||
export import projectinfo = require("projectinfo");
|
||||
export import q = require("q");
|
||||
export import q = require("smartq");
|
||||
export import qenv = require("qenv");
|
||||
export import shelljs = require("shelljs");
|
||||
export import smartfile = require("smartfile");
|
||||
|
@ -1,12 +1,11 @@
|
||||
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();
|
||||
plugins.beautylog.ora.start();
|
||||
export let run = () => {
|
||||
let done = plugins.q.defer();
|
||||
ConfigModule.run()
|
||||
|
3
tslint.json
Normal file
3
tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "tslint-config-standard"
|
||||
}
|
Loading…
Reference in New Issue
Block a user