Compare commits

...

15 Commits

Author SHA1 Message Date
6fec1a00ea 1.2.27 2018-10-29 01:09:46 +01:00
e1f2c28718 fix(ci): remove npmts from build process 2018-10-29 01:09:45 +01:00
9efab07424 1.2.26 2018-10-29 01:07:40 +01:00
18d16feaa9 fix(core): update 2018-10-29 01:07:39 +01:00
df09ff0f9b 1.2.25 2018-10-28 21:40:32 +01:00
7b50ceb69f fix(clean): images are now cleaned in a more thorough way 2018-10-28 21:40:31 +01:00
d1fd76e8d0 1.2.24 2018-09-16 23:14:33 +02:00
b71fa1bc36 fix(core): update 2018-09-16 23:14:33 +02:00
068d28b95d 1.2.23 2018-09-16 21:08:14 +02:00
ecb458f5cd fix(dependencies): update 2018-09-16 21:08:13 +02:00
9f6fb8aedd 1.2.22 2018-07-21 13:32:51 +02:00
f21df13b7c fix(update to latest standards): update 2018-07-21 13:32:51 +02:00
9c56942739 1.2.21 2018-05-18 13:22:08 +02:00
5f4ab33069 1.2.20 2018-05-18 13:17:52 +02:00
14761a442e fix(ci): add build command to package.json 2018-05-18 13:17:52 +02:00
29 changed files with 1975 additions and 1722 deletions

3
cli.js Normal file
View File

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

4
cli.ts.js Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env node
process.env.CLI_CALL = 'true';
require('@gitzone/tsrun');
require('./ts/index');

3
dist/cli.js vendored
View File

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

1
dist/index.d.ts vendored
View File

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

5
dist/index.js vendored
View File

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

View File

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

83
dist/npmdocker.cli.js vendored
View File

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

View File

@ -1,9 +0,0 @@
import { IKeyValueObject } from 'qenv';
export interface IConfig {
baseImage: string;
command: string;
dockerSock: boolean;
exitCode?: number;
keyValueObjectArray: IKeyValueObject[];
}
export declare let run: () => Promise<IConfig>;

View File

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

View File

@ -1,2 +0,0 @@
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,4 +0,0 @@
export declare let cwd: string;
export declare let packageBase: string;
export declare let assets: string;
export declare let npmdockerFile: string;

View File

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

View File

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

View File

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

View File

@ -1,5 +0,0 @@
export interface IDockerfileSnippet {
baseImage: string;
command: string;
}
export declare let dockerfileSnippet: (optionsArg: IDockerfileSnippet) => string;

View File

@ -1,32 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./npmdocker.plugins");
let getMountSolutionString = (optionsArg) => {
if (process.env.CI) {
return 'COPY ./ /workspace';
}
else {
return '# not copying workspcae since not in CI';
}
};
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

View File

@ -4,10 +4,7 @@
"cli": true "cli": true
}, },
"npmci": { "npmci": {
"npmGlobalTools": [ "npmGlobalTools": [],
"@gitzone/npmts",
"ts-node"
],
"npmAccessLevel": "public" "npmAccessLevel": "public"
} }
} }

1862
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +1,19 @@
{ {
"name": "@gitzone/npmdocker", "name": "@gitzone/npmdocker",
"version": "1.2.19", "version": "1.2.27",
"private": false,
"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",
"bin": { "bin": {
"npmdocker": "dist/cli.js" "npmdocker": "cli.js"
},
"directories": {
"test": "test"
}, },
"scripts": { "scripts": {
"test": "(npm run clean && npm run compile && npm run setupCheck && npm run testStandard && npm run testSpeed)", "test": "(npm run clean && npm run setupCheck && npm run testStandard && npm run testSpeed)",
"testStandard": "(cd test/ && node ../dist/index.js)", "build": "(tsbuild)",
"testSpeed": "(cd test/ && node ../dist/index.js speedtest)", "testStandard": "(cd test/ && node ../cli.ts.js)",
"testClean": "(cd test/ && node ../dist/index.js clean --all)", "testSpeed": "(cd test/ && node ../cli.ts.js speedtest)",
"testClean": "(cd test/ && node ../cli.ts.js clean --all)",
"clean": "(rm -rf test/)", "clean": "(rm -rf test/)",
"compile": "(npmts --notest)", "compile": "(npmts --notest)",
"setupCheck": "(git clone https://gitlab.com/sandboxzone/sandbox-npmts.git test/)" "setupCheck": "(git clone https://gitlab.com/sandboxzone/sandbox-npmts.git test/)"
@ -32,19 +31,26 @@
"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": {
"@gitzone/tsbuild": "^2.0.22",
"@gitzone/tsrun": "^1.1.13",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.12.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": { "dependencies": {
"@types/shelljs": "0.x.x", "@pushrocks/npmextra": "^3.0.1",
"beautylog": "^6.1.10", "@pushrocks/projectinfo": "^4.0.2",
"npmextra": "^2.0.9", "@pushrocks/qenv": "^2.0.2",
"projectinfo": "^3.0.4", "@pushrocks/smartanalytics": "^2.0.15",
"qenv": "^1.1.7", "@pushrocks/smartcli": "^3.0.6",
"smartanalytics": "^2.0.9", "@pushrocks/smartfile": "^6.0.8",
"smartcli": "^2.0.7", "@pushrocks/smartpromise": "^2.0.5",
"smartfile": "^4.2.26", "@pushrocks/smartshell": "^2.0.8",
"smartq": "^1.1.6", "@pushrocks/smartstring": "^3.0.4",
"smartshell": "^1.0.18", "@types/shelljs": "^0.8.0",
"smartstring": "^2.0.24", "beautylog": "^6.1.10"
"typings-global": "^1.0.20"
} }
} }

20
ts/analytics.ts Normal file
View File

@ -0,0 +1,20 @@
/**
* smartanalytics:
* We count executions of this tool to keep track which of our tools are really used.
* This insight is used to plan spending our limited resources for improving them.
* Any submitted analytics data is fully anonymized (no Ips or any other personal information is tracked).
* 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
* The privacy policy is also linked in the readme, so we hope this behaviour does not come as a surprise to you.
* Have a nice day and regards
* Your Open Source team at Lossless GmbH :)
*/
import * as smartanalytics from '@pushrocks/smartanalytics';
let npmdockerAnalytics = new smartanalytics.Analytics({
apiEndPoint: 'https://pubapi.lossless.one',
appName: 'npmdocker',
projectId: 'gitzone'
});
npmdockerAnalytics.recordEvent('npmtoolexecution', {
somedata: 'somedata'
});

View File

@ -1,3 +1,4 @@
import './analytics';
import * as plugins from './npmdocker.plugins'; import * as plugins from './npmdocker.plugins';
import * as cli from './npmdocker.cli'; import * as cli from './npmdocker.cli';

View File

@ -5,29 +5,10 @@ import * as paths from './npmdocker.paths';
import * as ConfigModule from './npmdocker.config'; import * as ConfigModule from './npmdocker.config';
import * as DockerModule from './npmdocker.docker'; import * as DockerModule from './npmdocker.docker';
/**
* smartanalytics
* this data is fully anonymized (no Ips or any other personal information is tracked).
* It just keeps track which of our tools are really used...
* ... so we know where to spend our limited resources for improving them.
* Since yarn is out and there is heavy caching going on,
* pure download stats are just not reliable enough for us anymore
* Feel free to dig into the smartanalytics package, if you are interested in how it works.
* 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();
export let run = () => { export let run = () => {
npmdockerCli.standardTask().then(async argvArg => { npmdockerCli.standardTask().subscribe(async argvArg => {
plugins.beautylog.figletSync('npmdocker'); plugins.beautylog.figletSync('npmdocker');
let configArg = await ConfigModule.run().then(DockerModule.run); let configArg = await ConfigModule.run().then(DockerModule.run);
if (configArg.exitCode === 0) { if (configArg.exitCode === 0) {
@ -41,43 +22,52 @@ export let run = () => {
/** /**
* this command is executed inside docker and meant for use from outside docker * this command is executed inside docker and meant for use from outside docker
*/ */
npmdockerCli.addCommand('runinside').then(async argvArg => { npmdockerCli.addCommand('runinside').subscribe(async argvArg => {
plugins.beautylog.ok('Allright. We are now in Docker!'); plugins.beautylog.ok('Allright. We are now in Docker!');
plugins.beautylog.log('now trying to run your specified command'); plugins.beautylog.log('now trying to run your specified command');
let configArg = await ConfigModule.run(); let configArg = await ConfigModule.run();
await plugins.smartshell.exec(configArg.command).then(response => { const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
});
await smartshellInstance.exec(configArg.command).then(response => {
if (response.exitCode !== 0) { if (response.exitCode !== 0) {
process.exit(1); process.exit(1);
} }
}); });
}); });
npmdockerCli.addCommand('clean').then(async argvArg => { npmdockerCli.addCommand('clean').subscribe(async argvArg => {
plugins.beautylog.ora.start(); 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) {
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
});
plugins.beautylog.ora.text('killing any running docker containers...'); plugins.beautylog.ora.text('killing any running docker containers...');
await plugins.smartshell.exec(`docker kill $(docker ps -q)`); await smartshellInstance.exec(`docker kill $(docker ps -q)`);
plugins.beautylog.ora.text('removing stopped containers...'); plugins.beautylog.ora.text('removing stopped containers...');
await plugins.smartshell.exec(`docker rm $(docker ps -a -q)`); await smartshellInstance.exec(`docker rm $(docker ps -a -q)`);
plugins.beautylog.ora.text('removing images...'); plugins.beautylog.ora.text('removing images...');
await plugins.smartshell.exec(`docker rmi $(docker images -q -f dangling=true)`); await smartshellInstance.exec(`docker rmi -f $(docker images -q -f dangling=true)`);
plugins.beautylog.ora.text('removing all other images...'); plugins.beautylog.ora.text('removing all other images...');
await plugins.smartshell.exec(`docker rmi $(docker images -a -q)`); await smartshellInstance.exec(`docker rmi $(docker images -a -q)`);
plugins.beautylog.ora.text('removing all volumes...'); plugins.beautylog.ora.text('removing all volumes...');
await plugins.smartshell.exec(`docker volume rm $(docker volume ls -f dangling=true -q)`); await smartshellInstance.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(async argvArg => { npmdockerCli.addCommand('speedtest').subscribe(async argvArg => {
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
});
plugins.beautylog.figletSync('npmdocker'); plugins.beautylog.figletSync('npmdocker');
plugins.beautylog.ok('Starting speedtest'); plugins.beautylog.ok('Starting speedtest');
await plugins.smartshell.exec( await smartshellInstance.exec(
`docker pull tianon/speedtest && docker run --rm tianon/speedtest` `docker pull tianon/speedtest && docker run --rm tianon/speedtest`
); );
}); });

View File

@ -2,7 +2,7 @@ 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 '@pushrocks/qenv';
export interface IConfig { export interface IConfig {
baseImage: string; baseImage: string;

View File

@ -2,6 +2,10 @@ 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';
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash'
});
// interfaces // interfaces
import { IConfig } from './npmdocker.config'; import { IConfig } from './npmdocker.config';
@ -22,9 +26,10 @@ let dockerData = {
* check if docker is available * check if docker is available
*/ */
let checkDocker = () => { let checkDocker = () => {
let done = plugins.q.defer(); let done = plugins.smartpromise.defer();
plugins.beautylog.ora.text('checking docker...'); plugins.beautylog.ora.text('checking docker...');
if (plugins.smartshell.which('docker')) {
if (smartshellInstance.exec('which docker')) {
plugins.beautylog.ok('Docker found!'); plugins.beautylog.ok('Docker found!');
done.resolve(); done.resolve();
} else { } else {
@ -37,7 +42,7 @@ let checkDocker = () => {
* 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.smartpromise.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,
@ -57,9 +62,9 @@ let buildDockerFile = () => {
*/ */
let buildDockerImage = async () => { let buildDockerImage = async () => {
plugins.beautylog.info('pulling latest base image from registry...'); plugins.beautylog.info('pulling latest base image from registry...');
await plugins.smartshell.exec(`docker pull ${config.baseImage}`); await smartshellInstance.exec(`docker pull ${config.baseImage}`);
plugins.beautylog.ora.text('building Dockerimage...'); plugins.beautylog.ora.text('building Dockerimage...');
let execResult = await plugins.smartshell.execSilent( let execResult = await smartshellInstance.execSilent(
`docker build -f npmdocker -t ${dockerData.imageTag} ${paths.cwd}` `docker build -f npmdocker -t ${dockerData.imageTag} ${paths.cwd}`
); );
if (execResult.exitCode !== 0) { if (execResult.exitCode !== 0) {
@ -69,7 +74,7 @@ let buildDockerImage = async () => {
plugins.beautylog.ok('Dockerimage built!'); plugins.beautylog.ok('Dockerimage built!');
}; };
let buildDockerProjectMountString = async () => { const buildDockerProjectMountString = async () => {
if (process.env.CI !== 'true') { if (process.env.CI !== 'true') {
dockerData.dockerProjectMountString = `-v ${paths.cwd}:/workspace`; dockerData.dockerProjectMountString = `-v ${paths.cwd}:/workspace`;
} }
@ -78,7 +83,7 @@ let buildDockerProjectMountString = async () => {
/** /**
* builds an environment string that docker cli understands * builds an environment string that docker cli understands
*/ */
let buildDockerEnvString = async () => { const buildDockerEnvString = async () => {
for (let keyValueObjectArg of config.keyValueObjectArray) { for (let keyValueObjectArg of config.keyValueObjectArray) {
let envString = (dockerData.dockerEnvString = let envString = (dockerData.dockerEnvString =
dockerData.dockerEnvString + `-e ${keyValueObjectArg.key}=${keyValueObjectArg.value} `); dockerData.dockerEnvString + `-e ${keyValueObjectArg.key}=${keyValueObjectArg.value} `);
@ -88,7 +93,7 @@ let buildDockerEnvString = async () => {
/** /**
* creates string to mount the docker.sock inside the testcontainer * creates string to mount the docker.sock inside the testcontainer
*/ */
let buildDockerSockString = async () => { const buildDockerSockString = async () => {
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`;
} }
@ -98,11 +103,11 @@ let buildDockerSockString = async () => {
* creates a container by running the built Dockerimage * creates a container by running the built Dockerimage
*/ */
let runDockerImage = async () => { let runDockerImage = async () => {
let done = plugins.q.defer(); let done = plugins.smartpromise.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 = (await plugins.smartshell.exec( config.exitCode = (await smartshellInstance.exec(
`docker run ${dockerData.dockerProjectMountString} ${dockerData.dockerSockString} ${ `docker run ${dockerData.dockerProjectMountString} ${dockerData.dockerSockString} ${
dockerData.dockerEnvString dockerData.dockerEnvString
} --name ${dockerData.containerName} ${dockerData.imageTag}` } --name ${dockerData.containerName} ${dockerData.imageTag}`
@ -113,14 +118,14 @@ let runDockerImage = async () => {
* cleans up: deletes the test container * cleans up: deletes the test container
*/ */
let deleteDockerContainer = async () => { let deleteDockerContainer = async () => {
await plugins.smartshell.execSilent(`docker rm -f ${dockerData.containerName}`); await smartshellInstance.execSilent(`docker rm -f ${dockerData.containerName}`);
}; };
/** /**
* cleans up deletes the test image * cleans up deletes the test image
*/ */
let deleteDockerImage = async () => { let deleteDockerImage = async () => {
await plugins.smartshell.execSilent(`docker rmi ${dockerData.imageTag}`).then(async response => { await smartshellInstance.execSilent(`docker rmi ${dockerData.imageTag}`).then(async response => {
if (response.exitCode !== 0) { if (response.exitCode !== 0) {
console.log(response.stdout); console.log(response.stdout);
} }

View File

@ -1,23 +1,21 @@
import * as beautylog from 'beautylog'; import * as beautylog from 'beautylog';
import * as npmextra from 'npmextra'; import * as npmextra from '@pushrocks/npmextra';
import * as path from 'path'; import * as path from 'path';
import * as projectinfo from 'projectinfo'; import * as projectinfo from '@pushrocks/projectinfo';
import * as q from 'smartq'; import * as smartpromise from '@pushrocks/smartpromise';
import * as qenv from 'qenv'; import * as qenv from '@pushrocks/qenv';
import * as smartanalytics from 'smartanalytics'; import * as smartcli from '@pushrocks/smartcli';
import * as smartcli from 'smartcli'; import * as smartfile from '@pushrocks/smartfile';
import * as smartfile from 'smartfile'; import * as smartshell from '@pushrocks/smartshell';
import * as smartshell from 'smartshell'; import * as smartstring from '@pushrocks/smartstring';
import * as smartstring from 'smartstring';
export { export {
beautylog, beautylog,
npmextra, npmextra,
path, path,
projectinfo, projectinfo,
q, smartpromise,
qenv, qenv,
smartanalytics,
smartcli, smartcli,
smartfile, smartfile,
smartshell, smartshell,

View File

@ -15,7 +15,7 @@ let getMountSolutionString = (optionsArg: IDockerfileSnippet) => {
let getGlobalPreparationString = (optionsArg: IDockerfileSnippet) => { let getGlobalPreparationString = (optionsArg: IDockerfileSnippet) => {
if (optionsArg.baseImage !== 'hosttoday/ht-docker-node:npmdocker') { if (optionsArg.baseImage !== 'hosttoday/ht-docker-node:npmdocker') {
return 'RUN yarn global add npmdocker'; return 'RUN npm install -g npmdocker';
} else { } else {
return '# not installing npmdocker since it is included in the base image'; return '# not installing npmdocker since it is included in the base image';
} }

View File

@ -1,3 +1,10 @@
{ {
"extends": "tslint-config-standard" "extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false
},
"defaultSeverity": "warning"
} }

1258
yarn.lock

File diff suppressed because it is too large Load Diff