now working
This commit is contained in:
parent
2d5054be0b
commit
ca0ecd4e93
5
assets/Dockerfile
Normal file
5
assets/Dockerfile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
FROM hosttoday/ht-docker-node:npmts
|
||||||
|
RUN mkdir /workspace
|
||||||
|
WORKDIR /workspace
|
||||||
|
ENV CI=true
|
||||||
|
CMD ["npm","test"];
|
10
dist/index.js
vendored
10
dist/index.js
vendored
@ -1,4 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
const plugins = require("./npmdocker.plugins");
|
||||||
const promisechain = require("./npmdocker.promisechain");
|
const promisechain = require("./npmdocker.promisechain");
|
||||||
promisechain.run();
|
promisechain.run()
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQ0EsTUFBWSxZQUFZLFdBQU0sMEJBQTBCLENBQUMsQ0FBQTtBQUV6RCxZQUFZLENBQUMsR0FBRyxFQUFFLENBQUMifQ==
|
.then((configArg) => {
|
||||||
|
if (configArg.exitCode == 0) {
|
||||||
|
plugins.beautylog.success("Allright test in docker ran through");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0scUJBQXFCLENBQUMsQ0FBQTtBQUMvQyxNQUFZLFlBQVksV0FBTSwwQkFBMEIsQ0FBQyxDQUFBO0FBSXpELFlBQVksQ0FBQyxHQUFHLEVBQUU7S0FDYixJQUFJLENBQUMsQ0FBQyxTQUE4QjtJQUNqQyxFQUFFLENBQUEsQ0FBQyxTQUFTLENBQUMsUUFBUSxJQUFJLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDeEIsT0FBTyxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMscUNBQXFDLENBQUMsQ0FBQztJQUNyRSxDQUFDO0FBQ0wsQ0FBQyxDQUFDLENBQUMifQ==
|
5
dist/npmdocker.config.d.ts
vendored
5
dist/npmdocker.config.d.ts
vendored
@ -1,3 +1,8 @@
|
|||||||
/// <reference types="q" />
|
/// <reference types="q" />
|
||||||
import * as plugins from "./npmdocker.plugins";
|
import * as plugins from "./npmdocker.plugins";
|
||||||
|
export interface IConfig {
|
||||||
|
baseImage: string;
|
||||||
|
command: string;
|
||||||
|
exitCode?: number;
|
||||||
|
}
|
||||||
export declare let run: () => plugins.q.Promise<{}>;
|
export declare let run: () => plugins.q.Promise<{}>;
|
||||||
|
8
dist/npmdocker.config.js
vendored
8
dist/npmdocker.config.js
vendored
@ -2,12 +2,14 @@
|
|||||||
const plugins = require("./npmdocker.plugins");
|
const plugins = require("./npmdocker.plugins");
|
||||||
let config = plugins.npmextra.dataFor({
|
let config = plugins.npmextra.dataFor({
|
||||||
toolName: "npmdocker",
|
toolName: "npmdocker",
|
||||||
defaultSettings: {},
|
defaultSettings: {
|
||||||
cwd: ""
|
baseImage: "hosttoday/ht-docker-node:npmts",
|
||||||
|
command: "npm test"
|
||||||
|
}
|
||||||
});
|
});
|
||||||
exports.run = () => {
|
exports.run = () => {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
done.resolve(config);
|
done.resolve(config);
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5nc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UFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUEifQ==
|
5
dist/npmdocker.docker.d.ts
vendored
5
dist/npmdocker.docker.d.ts
vendored
@ -1,8 +1,3 @@
|
|||||||
/// <reference types="q" />
|
/// <reference types="q" />
|
||||||
import * as plugins from "./npmdocker.plugins";
|
import * as plugins from "./npmdocker.plugins";
|
||||||
/**
|
|
||||||
* check if docker is available
|
|
||||||
*/
|
|
||||||
export declare let checkDocker: () => plugins.q.Promise<{}>;
|
|
||||||
export declare let makeDockerReady: () => void;
|
|
||||||
export declare let run: (configArg: any) => plugins.q.Promise<{}>;
|
export declare let run: (configArg: any) => plugins.q.Promise<{}>;
|
||||||
|
89
dist/npmdocker.docker.js
vendored
89
dist/npmdocker.docker.js
vendored
@ -1,11 +1,20 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const plugins = require("./npmdocker.plugins");
|
const plugins = require("./npmdocker.plugins");
|
||||||
|
const paths = require("./npmdocker.paths");
|
||||||
|
const snippets = require("./npmdocker.snippets");
|
||||||
|
let config;
|
||||||
|
let dockerData = {
|
||||||
|
imageTag: "npmdocker-temp-image:latest",
|
||||||
|
containerName: "npmdocker-temp-container",
|
||||||
|
exitCode: 0
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* check if docker is available
|
* check if docker is available
|
||||||
*/
|
*/
|
||||||
exports.checkDocker = () => {
|
let checkDocker = () => {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
if (plugins.shelljs.which("docker")) {
|
if (plugins.shelljs.which("docker")) {
|
||||||
|
plugins.beautylog.ok("Docker found!");
|
||||||
done.resolve();
|
done.resolve();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -13,10 +22,80 @@ exports.checkDocker = () => {
|
|||||||
}
|
}
|
||||||
return done.promise;
|
return done.promise;
|
||||||
};
|
};
|
||||||
exports.makeDockerReady = () => { };
|
/**
|
||||||
exports.run = (configArg) => {
|
* builds the Dockerfile according to the config in the project
|
||||||
|
*/
|
||||||
|
let buildDockerFile = () => {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
done.resolve(configArg);
|
let dockerfile = 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;
|
return done.promise;
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmRvY2tlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5kb2NrZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFHL0M7O0dBRUc7QUFDUSxtQkFBVyxHQUFHO0lBQ3JCLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsRUFBRSxDQUFBLENBQUMsT0FBTyxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsUUFBUSxDQUFDLENBQUMsQ0FBQSxDQUFDO1FBQ2hDLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQztJQUNuQixDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixJQUFJLENBQUMsTUFBTSxDQUFDLElBQUksS0FBSyxDQUFDLGtDQUFrQyxDQUFDLENBQUMsQ0FBQztJQUMvRCxDQUFDO0lBQ0QsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7QUFDeEIsQ0FBQyxDQUFDO0FBRVMsdUJBQWUsR0FBRyxRQUFPLENBQUMsQ0FBQztBQUUzQixXQUFHLEdBQUcsQ0FBQyxTQUFTO0lBQ3ZCLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsSUFBSSxDQUFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQztJQUN4QixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUEifQ==
|
/**
|
||||||
|
* builds the Dockerimage from the built Dockerfile
|
||||||
|
*/
|
||||||
|
let buildDockerImage = () => {
|
||||||
|
let done = plugins.q.defer();
|
||||||
|
plugins.beautylog.log("pulling latest image...");
|
||||||
|
plugins.shelljs.exec(`docker pull ${config.baseImage}`, {
|
||||||
|
silent: true
|
||||||
|
}); // first pull latest version of baseImage
|
||||||
|
plugins.shelljs.exec(`docker build -f ${paths.dockerfile} -t ${dockerData.imageTag} ${paths.assets}`, {
|
||||||
|
silent: true
|
||||||
|
}, () => {
|
||||||
|
plugins.beautylog.ok("Dockerimage built!");
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* creates a container by running the built Dockerimage
|
||||||
|
*/
|
||||||
|
let runDockerImage = () => {
|
||||||
|
let done = plugins.q.defer();
|
||||||
|
plugins.beautylog.info("Now starting Container!");
|
||||||
|
dockerData.exitCode = plugins.shelljs.exec(`docker run -v ${paths.cwd}:/workspace --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
|
||||||
|
});
|
||||||
|
done.resolve();
|
||||||
|
plugins.beautylog.ok("removed test image!");
|
||||||
|
plugins.beautylog.ok("Cleaned up!");
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
exports.run = (configArg) => {
|
||||||
|
let done = plugins.q.defer();
|
||||||
|
config = configArg;
|
||||||
|
checkDocker()
|
||||||
|
.then(buildDockerFile)
|
||||||
|
.then(buildDockerImage)
|
||||||
|
.then(runDockerImage)
|
||||||
|
.then(deleteDockerContainter)
|
||||||
|
.then(deleteDockerImage)
|
||||||
|
.then(() => {
|
||||||
|
done.resolve(configArg);
|
||||||
|
});
|
||||||
|
return done.promise;
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmRvY2tlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5kb2NrZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFDL0MsTUFBWSxLQUFLLFdBQU0sbUJBQW1CLENBQUMsQ0FBQTtBQUMzQyxNQUFZLFFBQVEsV0FBTSxzQkFBc0IsQ0FBQyxDQUFBO0FBRWpELElBQUksTUFBTSxDQUFDO0FBQ1gsSUFBSSxVQUFVLEdBQUc7SUFDYixRQUFRLEVBQUUsNkJBQTZCO0lBQ3ZDLGFBQWEsRUFBRSwwQkFBMEI7SUFDekMsUUFBUSxFQUFDLENBQUM7Q0FDYixDQUFDO0FBQ0Y7O0dBRUc7QUFDSCxJQUFJLFdBQVcsR0FBRztJQUNkLElBQUksSUFBSSxHQUFHLE9BQ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Q0FBQztJQUNmLE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLHFCQUFxQixDQUFDLENBQUM7SUFDNUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsYUFBYSxDQUFDLENBQUM7SUFDcEMsTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUE7QUFDdkIsQ0FBQyxDQUFDO0FBSVMsV0FBRyxHQUFHLENBQUMsU0FBUztJQUN2QixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLE1BQU0sR0FBRyxTQUFTLENBQUM7SUFDbkIsV0FBVyxFQUFFO1NBQ1IsSUFBSSxDQUFDLGVBQWUsQ0FBQztTQUNyQixJQUFJLENBQUMsZ0JBQWdCLENBQUM7U0FDdEIsSUFBSSxDQUFDLGNBQWMsQ0FBQztTQUNwQixJQUFJLENBQUMsc0JBQXNCLENBQUM7U0FDNUIsSUFBSSxDQUFDLGlCQUFpQixDQUFDO1NBQ3ZCLElBQUksQ0FBQztRQUNGLElBQUksQ0FBQyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUM7SUFDNUIsQ0FBQyxDQUFDLENBQUE7SUFDTixNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUEifQ==
|
3
dist/npmdocker.paths.d.ts
vendored
3
dist/npmdocker.paths.d.ts
vendored
@ -1 +1,4 @@
|
|||||||
|
export declare let cwd: string;
|
||||||
export declare let packageBase: string;
|
export declare let packageBase: string;
|
||||||
|
export declare let assets: string;
|
||||||
|
export declare let dockerfile: string;
|
||||||
|
7
dist/npmdocker.paths.js
vendored
7
dist/npmdocker.paths.js
vendored
@ -1,4 +1,9 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
const plugins = require("./npmdocker.plugins");
|
const plugins = require("./npmdocker.plugins");
|
||||||
|
// directories
|
||||||
|
exports.cwd = process.cwd();
|
||||||
exports.packageBase = plugins.path.join(__dirname, "../");
|
exports.packageBase = plugins.path.join(__dirname, "../");
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxxQkFBcUIsQ0FBQyxDQUFBO0FBRXBDLG1CQUFXLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFDLEtBQUssQ0FBQyxDQUFDIn0=
|
exports.assets = plugins.path.join(exports.packageBase, "assets/");
|
||||||
|
plugins.smartfile.fs.ensureDirSync(exports.assets);
|
||||||
|
exports.dockerfile = plugins.path.join(exports.assets, "Dockerfile");
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBhdGhzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnBhdGhzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxxQkFBcUIsQ0FBQyxDQUFBO0FBRS9DLGNBQWM7QUFDSCxXQUFHLEdBQUcsT0FBTyxDQUFDLEdBQUcsRUFBRSxDQUFDO0FBQ3BCLG1CQUFXLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsU0FBUyxFQUFDLEtBQUssQ0FBQyxDQUFDO0FBQ2pELGNBQU0sR0FBRyxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxtQkFBVyxFQUFDLFNBQVMsQ0FBQyxDQUFDO0FBQzdELE9BQU8sQ0FBQyxTQUFTLENBQUMsRUFBRSxDQUFDLGFBQWEsQ0FBQyxjQUFNLENBQUMsQ0FBQztBQUNoQyxrQkFBVSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLGNBQU0sRUFBQyxZQUFZLENBQUMsQ0FBQyJ9
|
3
dist/npmdocker.plugins.d.ts
vendored
3
dist/npmdocker.plugins.d.ts
vendored
@ -3,5 +3,6 @@ export import beautylog = require("beautylog");
|
|||||||
export import npmextra = require("npmextra");
|
export import npmextra = require("npmextra");
|
||||||
export import path = require("path");
|
export import path = require("path");
|
||||||
export import q = require("q");
|
export import q = require("q");
|
||||||
export declare let shelljs: any;
|
export import shelljs = require("shelljs");
|
||||||
export import smartfile = require("smartfile");
|
export import smartfile = require("smartfile");
|
||||||
|
export import smartstring = require("smartstring");
|
||||||
|
3
dist/npmdocker.plugins.js
vendored
3
dist/npmdocker.plugins.js
vendored
@ -6,4 +6,5 @@ exports.path = require("path");
|
|||||||
exports.q = require("q");
|
exports.q = require("q");
|
||||||
exports.shelljs = require("shelljs");
|
exports.shelljs = require("shelljs");
|
||||||
exports.smartfile = require("smartfile");
|
exports.smartfile = require("smartfile");
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9ucG1kb2NrZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ1YsaUJBQVMsV0FBVyxXQUFXLENBQUMsQ0FBQztBQUNqQyxnQkFBUSxXQUFXLFVBQVUsQ0FBQyxDQUFDO0FBQy9CLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixTQUFDLFdBQVcsR0FBRyxDQUFDLENBQUM7QUFDcEIsZUFBTyxHQUFHLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FBQztBQUMxQixpQkFBUyxXQUFXLFdBQVcsQ0FBQyxDQUFDIn0=
|
exports.smartstring = require("smartstring");
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9ucG1kb2NrZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ1YsaUJBQVMsV0FBVyxXQUFXLENBQUMsQ0FBQztBQUNqQyxnQkFBUSxXQUFXLFVBQVUsQ0FBQyxDQUFDO0FBQy9CLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixTQUFDLFdBQVcsR0FBRyxDQUFDLENBQUM7QUFDakIsZUFBTyxXQUFXLFNBQVMsQ0FBQyxDQUFDO0FBQzdCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsbUJBQVcsV0FBVyxhQUFhLENBQUMsQ0FBQyJ9
|
5
dist/npmdocker.snippets.d.ts
vendored
Normal file
5
dist/npmdocker.snippets.d.ts
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export interface IDockerfileSnippet {
|
||||||
|
baseImage: string;
|
||||||
|
command: string;
|
||||||
|
}
|
||||||
|
export declare let dockerfileSnippet: (optionsArg: IDockerfileSnippet) => string;
|
21
dist/npmdocker.snippets.js
vendored
Normal file
21
dist/npmdocker.snippets.js
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
"use strict";
|
||||||
|
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 + '"';
|
||||||
|
}
|
||||||
|
;
|
||||||
|
return plugins.smartstring.indent.normalize(`
|
||||||
|
FROM ${optionsArg.baseImage}
|
||||||
|
RUN mkdir /workspace
|
||||||
|
WORKDIR /workspace
|
||||||
|
ENV CI=true
|
||||||
|
CMD [${commandString}];
|
||||||
|
`);
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnNuaXBwZXRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnNuaXBwZXRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxxQkFBcUIsQ0FBQyxDQUFBO0FBT3BDLHlCQUFpQixHQUFHLENBQUMsVUFBNkI7SUFDekQsSUFBSSxZQUFZLEdBQUcsVUFBVSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDbEQsSUFBSSxhQUFhLEdBQVUsRUFBRSxDQUFDO0lBQzlCLEdBQUcsQ0FBQSxDQUFDLElBQUksVUFBVSxJQUFJLFlBQVksQ0FBQyxDQUFBLENBQUM7UUFDaEMsRUFBRSxDQUFBLENBQUMsQ0FBQyxDQUFDLGFBQWEsSUFBSSxFQUFFLENBQUMsQ0FBQyxDQUFBLENBQUM7WUFDdkIsYUFBYSxHQUFHLGFBQWEsR0FBRyxHQUFHLENBQUM7UUFDeEMsQ0FBQztRQUNELGFBQWEsR0FBRyxhQUFhLEdBQUcsR0FBRyxHQUFHLFVBQVUsR0FBRyxHQUFHLENBQUM7SUFDM0QsQ0FBQztJQUFBLENBQUM7SUFDRixNQUFNLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDO2VBQ2pDLFVBQVUsQ0FBQyxTQUFTOzs7O2VBSXBCLGFBQWE7S0FDdkIsQ0FBQyxDQUFDO0FBQ1AsQ0FBQyxDQUFBIn0=
|
@ -7,7 +7,11 @@
|
|||||||
"test": "test"
|
"test": "test"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(npm run clean && npm run compile && npm run setupCheck && npm run check)",
|
||||||
|
"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)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -29,12 +33,14 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/q": "^0.0.27",
|
"@types/q": "^0.0.27",
|
||||||
|
"@types/shelljs": "^0.3.27",
|
||||||
"beautylog": "^5.0.14",
|
"beautylog": "^5.0.14",
|
||||||
"npmextra": "^1.0.8",
|
"npmextra": "^1.0.8",
|
||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"rxjs": "^5.0.0-beta.10",
|
"rxjs": "^5.0.0-beta.10",
|
||||||
"shelljs": "^0.7.0",
|
"shelljs": "^0.7.0",
|
||||||
"smartfile": "^4.0.11",
|
"smartfile": "^4.0.11",
|
||||||
|
"smartstring": "^2.0.15",
|
||||||
"typings-global": "^1.0.6"
|
"typings-global": "^1.0.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
test
Submodule
1
test
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 1478d1e901d2216c69e5217b84ee27bc6e56716c
|
@ -1,5 +1,12 @@
|
|||||||
import * as plugins from "./npmdocker.plugins";
|
import * as plugins from "./npmdocker.plugins";
|
||||||
import * as promisechain from "./npmdocker.promisechain";
|
import * as promisechain from "./npmdocker.promisechain";
|
||||||
|
import * as ConfigModule from "./npmdocker.config";
|
||||||
|
|
||||||
promisechain.run();
|
|
||||||
|
promisechain.run()
|
||||||
|
.then((configArg:ConfigModule.IConfig) => {
|
||||||
|
if(configArg.exitCode == 0){
|
||||||
|
plugins.beautylog.success("Allright test in docker ran through");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
@ -4,12 +4,15 @@ import * as paths from "./npmdocker.paths";
|
|||||||
export interface IConfig {
|
export interface IConfig {
|
||||||
baseImage:string;
|
baseImage:string;
|
||||||
command:string;
|
command:string;
|
||||||
|
exitCode?:number
|
||||||
}
|
}
|
||||||
|
|
||||||
let config:IConfig = plugins.npmextra.dataFor({
|
let config:IConfig = plugins.npmextra.dataFor({
|
||||||
toolName:"npmdocker",
|
toolName:"npmdocker",
|
||||||
defaultSettings: {},
|
defaultSettings: {
|
||||||
cwd: ""
|
baseImage:"hosttoday/ht-docker-node:npmts",
|
||||||
|
command:"npm test"
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export let run = () => {
|
export let run = () => {
|
||||||
|
@ -3,14 +3,18 @@ import * as paths from "./npmdocker.paths";
|
|||||||
import * as snippets from "./npmdocker.snippets";
|
import * as snippets from "./npmdocker.snippets";
|
||||||
|
|
||||||
let config;
|
let config;
|
||||||
let imageTag = "npmdocker-temp-image"
|
let dockerData = {
|
||||||
let containerName = "npmdocker-temp-container"
|
imageTag: "npmdocker-temp-image:latest",
|
||||||
|
containerName: "npmdocker-temp-container",
|
||||||
|
exitCode:0
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* check if docker is available
|
* check if docker is available
|
||||||
*/
|
*/
|
||||||
let checkDocker = () => {
|
let checkDocker = () => {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
if(plugins.shelljs.which("docker")){
|
if(plugins.shelljs.which("docker")){
|
||||||
|
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"));
|
||||||
@ -23,11 +27,15 @@ let checkDocker = () => {
|
|||||||
*/
|
*/
|
||||||
let buildDockerFile = () => {
|
let buildDockerFile = () => {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
let dockerfile = snippets.dockerfileSnippet({
|
let dockerfile:string = snippets.dockerfileSnippet({
|
||||||
baseImage:config.baseImage,
|
baseImage:config.baseImage,
|
||||||
command:config.command
|
command:config.command
|
||||||
});
|
});
|
||||||
plugins.smartfile.memory.toFsSync(JSON.stringify(dockerfile),paths.dockerfile);
|
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
|
return done.promise
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -36,9 +44,16 @@ let buildDockerFile = () => {
|
|||||||
*/
|
*/
|
||||||
let buildDockerImage = () => {
|
let buildDockerImage = () => {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
plugins.shelljs.exec(`docker pull ${config.baseImage}`); // first pull latest version of baseImage
|
plugins.beautylog.log("pulling latest image...");
|
||||||
plugins.shelljs.exec(`docker build -f ${paths.dockerfile} -v ${paths.cwd}:/workdir -t ${imageTag} ${paths.assets}`);
|
plugins.shelljs.exec(`docker pull ${config.baseImage}`,{
|
||||||
done.resolve();
|
silent:true
|
||||||
|
}); // first pull latest version of baseImage
|
||||||
|
plugins.shelljs.exec(`docker build -f ${paths.dockerfile} -t ${dockerData.imageTag} ${paths.assets}`,{
|
||||||
|
silent:true
|
||||||
|
},() => {
|
||||||
|
plugins.beautylog.ok("Dockerimage built!")
|
||||||
|
done.resolve();
|
||||||
|
});
|
||||||
return done.promise
|
return done.promise
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -47,17 +62,30 @@ let buildDockerImage = () => {
|
|||||||
*/
|
*/
|
||||||
let runDockerImage = () => {
|
let runDockerImage = () => {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
plugins.shelljs.exec(`docker run --name ${containerName} ${imageTag}`);
|
plugins.beautylog.info("Now starting Container!");
|
||||||
return done.promise
|
dockerData.exitCode = plugins.shelljs.exec(`docker run -v ${paths.cwd}:/workspace --name ${dockerData.containerName} ${dockerData.imageTag}`).code;
|
||||||
|
done.resolve();
|
||||||
|
return done.promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
let deleteDockerContainter = () => {
|
let deleteDockerContainter = () => {
|
||||||
let done = plugins.q.defer();
|
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
|
return done.promise
|
||||||
};
|
};
|
||||||
|
|
||||||
let deleteDockerImage = () => {
|
let deleteDockerImage = () => {
|
||||||
let done = plugins.q.defer();
|
let done = plugins.q.defer();
|
||||||
|
plugins.shelljs.exec(`docker rmi ${dockerData.imageTag}`,{
|
||||||
|
silent:true
|
||||||
|
});
|
||||||
|
done.resolve();
|
||||||
|
plugins.beautylog.ok("removed test image!");
|
||||||
|
plugins.beautylog.ok("Cleaned up!");
|
||||||
return done.promise
|
return done.promise
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
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 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);
|
||||||
|
@ -3,5 +3,6 @@ export import beautylog = require("beautylog");
|
|||||||
export import npmextra = require("npmextra");
|
export import npmextra = require("npmextra");
|
||||||
export import path = require("path");
|
export import path = require("path");
|
||||||
export import q = require("q");
|
export import q = require("q");
|
||||||
export let shelljs = require("shelljs");
|
export import shelljs = require("shelljs");
|
||||||
export import smartfile = require("smartfile");
|
export import smartfile = require("smartfile");
|
||||||
|
export import smartstring = require("smartstring");
|
@ -6,18 +6,19 @@ export interface IDockerfileSnippet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export let dockerfileSnippet = (optionsArg:IDockerfileSnippet):string => {
|
export let dockerfileSnippet = (optionsArg:IDockerfileSnippet):string => {
|
||||||
let commandArray = optionsArg.command.split(" ");
|
let commandArray = optionsArg.command.split(/\s/);
|
||||||
let commandString:string = "";
|
let commandString:string = "";
|
||||||
for(let stringItem of commandArray){
|
for(let stringItem of commandArray){
|
||||||
if(!(commandString == "")){
|
if(!(commandString == "")){
|
||||||
commandString = commandString + ",";
|
commandString = commandString + ",";
|
||||||
}
|
}
|
||||||
commandString = commandString + '"' + stringItem + '"';
|
commandString = commandString + '"' + stringItem + '"';
|
||||||
}
|
};
|
||||||
return `
|
return plugins.smartstring.indent.normalize(`
|
||||||
FROM ${optionsArg.baseImage}
|
FROM ${optionsArg.baseImage}
|
||||||
RUN mkdir /workspace
|
RUN mkdir /workspace
|
||||||
WORKDIR /workspace
|
WORKDIR /workspace
|
||||||
cmd[${commandString}];
|
ENV CI=true
|
||||||
`
|
CMD [${commandString}];
|
||||||
|
`);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user