Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c07f10b97b | |||
| 08d32f0370 | |||
| ac386f01e0 | |||
| 08ead4258f | |||
| f930f3a6a7 | |||
| b6d4a76c70 | |||
| 9a7ecd27e5 | |||
| 11b70b0ddf | |||
| 79f8cb5e0e | |||
| 3e1286b9ac | |||
| a8ae886959 | |||
| da1c977a62 | |||
| b99b55a05b | |||
| 133bf0abe5 | |||
| df260bbab9 | |||
| 080bd2bc48 | |||
| a0032b8168 | |||
| a09efd1125 | |||
| 4ce28c7979 | |||
| 415eaea56e | |||
| bde4597dd9 | |||
| 80946d4f0c | |||
| 2155e886ef | |||
| 8b61a90b5f | |||
| f48eadc814 | |||
| 9bdaaa0c30 | |||
| 5f681ff237 | |||
| 889a3fdc5a | |||
| 565c002127 | |||
| 6fec1a00ea | |||
| e1f2c28718 | |||
| 9efab07424 | |||
| 18d16feaa9 | |||
| df09ff0f9b | |||
| 7b50ceb69f | |||
| d1fd76e8d0 | |||
| b71fa1bc36 | |||
| 068d28b95d | |||
| ecb458f5cd | |||
| 9f6fb8aedd | |||
| f21df13b7c | |||
| 9c56942739 | |||
| 5f4ab33069 | |||
| 14761a442e | |||
| c4ee967ca9 | |||
| 551b8d0cde | |||
| 4f23b61e14 | |||
| 799320492a | |||
| d2cd294b36 | |||
| d3d3363e1b | |||
| ccd2cb6cbd | |||
| 0b0642f9e3 | |||
| 34753a4ae0 | |||
| 977ecabb41 | |||
| 6d9d040a8d | |||
| b2c08b7221 | |||
| 73b1a73719 | |||
| 449512e156 | |||
| 758e677bab | |||
| 42ffb4a8dd | |||
| 9176b56035 | |||
| b3d78f8ce5 | |||
| b6a6aac8e5 | |||
| 32f5ead4f4 | |||
| c29a261cb6 | |||
| de57d45947 | |||
| 00bf1532ca | |||
| 38fc672bf6 | |||
| 83771df11d | |||
| 822e480bdf | |||
| 77c6ef99c1 | |||
| 8e3991c121 | |||
| 77477587b8 | |||
| c7e32d6990 | |||
| da1c2167d3 | |||
| d55f7ef7f2 | |||
| 82f4fcceac | |||
| aa3b85314d | |||
| b5145294bd | |||
| d25decd15d | |||
| abf5cd1e24 | |||
| 9b8636b472 | |||
| eab75f03da |
27
.gitignore
vendored
27
.gitignore
vendored
@@ -1,6 +1,23 @@
|
||||
node_modules/
|
||||
coverage/
|
||||
docs/
|
||||
test/
|
||||
assets/
|
||||
.nogit/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_web/
|
||||
dist_serve/
|
||||
dist_ts_web/
|
||||
|
||||
# custom
|
||||
test
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
image: hosttoday/ht-docker-dbase:npmts
|
||||
services:
|
||||
- docker:dind
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
|
||||
test:
|
||||
stage: test
|
||||
script:
|
||||
- npm install
|
||||
- npm test
|
||||
tags:
|
||||
- docker
|
||||
- lossless
|
||||
- priv
|
||||
|
||||
release:
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
stage: release
|
||||
environment: npmjs-com_registry
|
||||
script:
|
||||
- npmci publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- lossless
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
image: hosttoday/ht-docker-node:npmts
|
||||
stage: trigger
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- lossless
|
||||
- priv
|
||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
||||
4
Dockerfile
Normal file
4
Dockerfile
Normal 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
|
||||
@@ -1,5 +0,0 @@
|
||||
# npmdocker
|
||||
develop npm modules cross platform with docker
|
||||
|
||||
## Usage
|
||||
npmdocker looks for a npmextra.json at the root of your directory and looks at the npmdocker portion of it.
|
||||
@@ -1,5 +1,6 @@
|
||||
FROM hosttoday/ht-docker-node:npmts
|
||||
COPY ./buildContextDir /workspace
|
||||
FROM hosttoday/ht-docker-node:npmci
|
||||
RUN yarn global add @gitzone/tsdocker
|
||||
COPY ./ /workspace
|
||||
WORKDIR /workspace
|
||||
ENV CI=true
|
||||
CMD ["npm","run","npmdocker"];
|
||||
CMD ["tsdocker","runinside"];
|
||||
|
||||
288
changelog.md
Normal file
288
changelog.md
Normal file
@@ -0,0 +1,288 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-11-22 - 1.2.41 - fix(core)
|
||||
Migrate to @git.zone / @push.rocks packages, replace smartfile with smartfs and adapt filesystem usage; update dev deps and remove CI/lint config
|
||||
|
||||
- Updated devDependencies from @gitzone/* to @git.zone/* (tsbuild, tsrun, tstest) and bumped versions
|
||||
- Re-scoped runtime dependencies from @pushrocks/* to @push.rocks/* and updated package versions
|
||||
- Replaced deprecated smartfile usage with new async smartfs API; added SmartFs instance in ts/tsdocker.plugins.ts
|
||||
- Switched sync filesystem calls to Node fs where appropriate (fs.existsSync, fs.mkdirSync) and updated code to await smartfs.file(...).write()/delete()
|
||||
- Made buildDockerFile async and awaited file write/delete operations to ensure correct async flow
|
||||
- Updated CLI bootstrap to require @git.zone/tsrun in cli.ts.js
|
||||
- Removed tslint.json and cleaned up CI configuration (.gitlab-ci.yml content removed)
|
||||
- Added readme.hints.md describing the migration and dependency changes
|
||||
|
||||
## 2021-09-30 - 1.2.40 - release (no code changes)
|
||||
Routine release tag with no recorded source changes.
|
||||
|
||||
- Tagged release only (no changelogged changes).
|
||||
|
||||
## 2021-09-30 - 1.2.39 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2019-05-28 - 1.2.38 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2019-05-27 - 1.2.37 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2019-05-27 - 1.2.36 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2019-05-21 - 1.2.35 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2019-05-21 - 1.2.34 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2019-05-12 - 1.2.33 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2019-05-12 - 1.2.32 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2019-05-12 - 1.2.31 - fix(bin name)
|
||||
Rename of the published CLI binary.
|
||||
|
||||
- Changed published binary name from "npmdocker" to "tsdocker".
|
||||
|
||||
## 2019-05-10 - 1.2.30 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2019-05-10 - 1.2.29 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2019-05-10 - 1.2.28 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2019-05-09 - 1.2.27 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2018-10-29 - 1.2.26 - fix(ci)
|
||||
CI build process change.
|
||||
|
||||
- Removed "npmts" from the build process.
|
||||
|
||||
## 2018-10-29 - 1.2.25 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2018-10-28 - 1.2.24 - fix(clean)
|
||||
Improved image cleanup.
|
||||
|
||||
- Images are now cleaned in a more thorough way.
|
||||
|
||||
## 2018-09-16 - 1.2.23 - fix(core)
|
||||
Core maintenance updates.
|
||||
|
||||
- Internal core updates and maintenance.
|
||||
|
||||
## 2018-09-16 - 1.2.22 - fix(dependencies)
|
||||
Dependency updates.
|
||||
|
||||
- Updated dependencies (maintenance).
|
||||
|
||||
## 2018-07-21 - 1.2.21 - fix(update to latest standards)
|
||||
Standards/update alignment.
|
||||
|
||||
- Updated codebase to latest standards (general maintenance).
|
||||
|
||||
## 2018-05-18 - 1.2.20 - release (no code changes)
|
||||
Tagged release with no recorded source changes.
|
||||
|
||||
- Tagged release only (no changelogged changes).
|
||||
|
||||
## 2018-05-18 - 1.2.19 - fix(ci)
|
||||
CI improvements.
|
||||
|
||||
- Added a build command to package.json to support CI builds.
|
||||
|
||||
## 2018-05-18 - 1.2.18 - fix(package)
|
||||
Packaging change for scoped publish.
|
||||
|
||||
- Include npmdocker under the @gitzone npm scope.
|
||||
|
||||
## 2018-01-24 - 1.2.18 - update
|
||||
Documentation update.
|
||||
|
||||
- Updated package description.
|
||||
|
||||
## 2017-10-13 - 1.2.17 - fix(cleanup)
|
||||
Cleanup behavior fix.
|
||||
|
||||
- Now cleans up correctly after operations.
|
||||
|
||||
## 2017-10-13 - 1.2.16 - update
|
||||
Miscellaneous updates.
|
||||
|
||||
- General maintenance and updates.
|
||||
|
||||
## 2017-10-13 - 1.2.15 - fix(test)
|
||||
Testing improvements.
|
||||
|
||||
- Fixed Docker testing.
|
||||
|
||||
## 2017-10-07 - 1.2.14 - ci
|
||||
CI improvements.
|
||||
|
||||
- Updated CI configuration.
|
||||
|
||||
## 2017-10-07 - 1.2.13 - update(analytics)
|
||||
Analytics integration.
|
||||
|
||||
- Updated Analytics integration.
|
||||
|
||||
## 2017-10-07 - 1.2.12 - update(dependencies)
|
||||
Dependency updates.
|
||||
|
||||
- Updated dependencies.
|
||||
|
||||
## 2017-07-16 - 1.2.11 - update
|
||||
Dependency and greeting update.
|
||||
|
||||
- Updated dependencies and changed greeting text.
|
||||
|
||||
## 2017-04-21 - 1.2.10 - feature
|
||||
Added analytics.
|
||||
|
||||
- Now includes SmartAnalytics.
|
||||
|
||||
## 2017-04-02 - 1.2.8 - docs & ci
|
||||
Docs and CI updates.
|
||||
|
||||
- Updated README and CI configuration.
|
||||
|
||||
## 2017-04-02 - 1.2.7 - fix(command)
|
||||
Command execution fix.
|
||||
|
||||
- Fixed command execution behavior.
|
||||
|
||||
## 2017-03-28 - 1.2.6 - ci
|
||||
CI configuration update.
|
||||
|
||||
- Updated .gitlab-ci.yml for correct images/steps.
|
||||
|
||||
## 2017-03-28 - 1.2.5 - ci
|
||||
CI improvements.
|
||||
|
||||
- Further CI updates.
|
||||
|
||||
## 2017-03-28 - 1.2.4 - perf
|
||||
Performance improvements.
|
||||
|
||||
- Now runs asynchronously and is significantly faster.
|
||||
|
||||
## 2017-02-12 - 1.2.3 - feature
|
||||
New cleanup and diagnostics features.
|
||||
|
||||
- Added speedtest utility.
|
||||
- Added removal of volumes.
|
||||
|
||||
## 2017-02-11 - 1.2.2 - feature
|
||||
Cleanup enhancement.
|
||||
|
||||
- Added "clean --all" option to remove more artifacts.
|
||||
|
||||
## 2017-02-11 - 1.2.1 - maintenance
|
||||
Docs and dependency updates.
|
||||
|
||||
- Updated README and dependencies.
|
||||
|
||||
## 2016-08-04 - 1.2.0 - maintenance
|
||||
Dependency cleanup.
|
||||
|
||||
- Removed unnecessary dependencies.
|
||||
|
||||
## 2016-07-29 - 1.1.6 - feature
|
||||
Environment support.
|
||||
|
||||
- Added support for qenv.
|
||||
|
||||
## 2016-07-29 - 1.1.5 - fix
|
||||
Container cleanup improvements.
|
||||
|
||||
- Now also removes old running containers.
|
||||
|
||||
## 2016-07-29 - 1.1.4 - fix
|
||||
Namespace conflict avoidance.
|
||||
|
||||
- Removes previous containers to avoid name-space conflicts after errors.
|
||||
|
||||
## 2016-07-29 - 1.1.3 - ci
|
||||
CI image configuration.
|
||||
|
||||
- Added correct images for GitLab CI.
|
||||
|
||||
## 2016-07-29 - 1.1.2 - ci
|
||||
CI fixes.
|
||||
|
||||
- Fixed GitLab CI configuration.
|
||||
|
||||
## 2016-07-28 - 1.1.1 - ci
|
||||
CI fixes and configuration.
|
||||
|
||||
- Fixed gitlab.yml and CI issues.
|
||||
|
||||
## 2016-07-28 - 1.1.0 - feature
|
||||
Docker-in-Docker support.
|
||||
|
||||
- Improved support for Docker-in-Docker scenarios.
|
||||
|
||||
## 2016-07-28 - 1.0.5 - feature & ci
|
||||
Docker socket option and CI update.
|
||||
|
||||
- Added dockerSock option.
|
||||
- Updated .gitlab-ci.yml.
|
||||
|
||||
## 2016-07-19 - 1.0.4 - release (no code changes)
|
||||
Tagged release with no recorded source changes.
|
||||
|
||||
- Tagged release only (no changelogged changes).
|
||||
|
||||
## 2016-07-19 - 1.0.3 - feature
|
||||
Environment tagging.
|
||||
|
||||
- Added environment tag support.
|
||||
|
||||
## 2016-07-19 - 1.0.2 - milestone
|
||||
CLI and stability improvements.
|
||||
|
||||
- Wired up CLI usage.
|
||||
- Marked as fully working.
|
||||
|
||||
## 2016-07-19 - 1.0.1 - initial improvements
|
||||
Early project refinements and Docker integration.
|
||||
|
||||
- Added/updated Docker integration and configuration.
|
||||
- Improved config handling and path management.
|
||||
- Updated Docker handling and removed test artifacts.
|
||||
|
||||
## 2016-07-13 - 1.0.0 - initial
|
||||
Initial release.
|
||||
|
||||
- Added README and initial project scaffolding.
|
||||
3
cli.js
Normal file
3
cli.js
Normal file
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.CLI_CALL = 'true';
|
||||
require('./dist/index');
|
||||
4
cli.ts.js
Normal file
4
cli.ts.js
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.CLI_CALL = 'true';
|
||||
require('@git.zone/tsrun');
|
||||
require('./ts/index');
|
||||
2
dist/cli.js
vendored
2
dist/cli.js
vendored
@@ -1,2 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
var index = require("./index.js");
|
||||
0
dist/index.d.ts
vendored
0
dist/index.d.ts
vendored
14
dist/index.js
vendored
14
dist/index.js
vendored
@@ -1,14 +0,0 @@
|
||||
"use strict";
|
||||
const plugins = require("./npmdocker.plugins");
|
||||
const promisechain = require("./npmdocker.promisechain");
|
||||
promisechain.run()
|
||||
.then((configArg) => {
|
||||
if (configArg.exitCode == 0) {
|
||||
plugins.beautylog.success("container ended all right!");
|
||||
}
|
||||
else {
|
||||
plugins.beautylog.error("container ended with error!");
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsTUFBWSxPQUFPLFdBQU0scUJBQXFCLENBQUMsQ0FBQTtBQUMvQyxNQUFZLFlBQVksV0FBTSwwQkFBMEIsQ0FBQyxDQUFBO0FBSXpELFlBQVksQ0FBQyxHQUFHLEVBQUU7S0FDYixJQUFJLENBQUMsQ0FBQyxTQUE4QjtJQUNqQyxFQUFFLENBQUEsQ0FBQyxTQUFTLENBQUMsUUFBUSxJQUFJLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDeEIsT0FBTyxDQUFDLFNBQVMsQ0FBQyxPQUFPLENBQUMsNEJBQTRCLENBQUMsQ0FBQztJQUM1RCxDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDSixPQUFPLENBQUMsU0FBUyxDQUFDLEtBQUssQ0FBQyw2QkFBNkIsQ0FBQyxDQUFDO1FBQ3ZELE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUM7SUFDcEIsQ0FBQztBQUNMLENBQUMsQ0FBQyxDQUFDIn0=
|
||||
11
dist/npmdocker.config.d.ts
vendored
11
dist/npmdocker.config.d.ts
vendored
@@ -1,11 +0,0 @@
|
||||
/// <reference types="q" />
|
||||
import * as plugins from "./npmdocker.plugins";
|
||||
import { IKeyValueObject } from "qenv";
|
||||
export interface IConfig {
|
||||
baseImage: string;
|
||||
command: string;
|
||||
dockerSock: boolean;
|
||||
exitCode?: number;
|
||||
keyValueObjectArray: IKeyValueObject[];
|
||||
}
|
||||
export declare let run: () => plugins.q.Promise<{}>;
|
||||
39
dist/npmdocker.config.js
vendored
39
dist/npmdocker.config.js
vendored
@@ -1,39 +0,0 @@
|
||||
"use strict";
|
||||
const plugins = require("./npmdocker.plugins");
|
||||
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;
|
||||
}
|
||||
else {
|
||||
qenvKeyValueObjectArray = [];
|
||||
}
|
||||
;
|
||||
done.resolve(qenvKeyValueObjectArray);
|
||||
return done.promise;
|
||||
};
|
||||
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",
|
||||
dockerSock: false,
|
||||
keyValueObjectArray: qenvKeyValueObjectArrayArg
|
||||
}
|
||||
});
|
||||
done.resolve(config);
|
||||
return done.promise;
|
||||
};
|
||||
exports.run = () => {
|
||||
let done = plugins.q.defer();
|
||||
getQenvKeyValueObject()
|
||||
.then(buildConfig)
|
||||
.then(done.resolve);
|
||||
return done.promise;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLmNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFDL0MsTUFBWSxLQUFLLFdBQU0sbUJBQW1CLENBQUMsQ0FBQTtBQVcxQyxDQUFDO0FBRUYsSUFBSSxxQkFBcUIsR0FBRztJQUN4QixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLElBQUksdUJBQXlDLENBQUM7SUFDOUMsRUFBRSxDQUFBLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFFLENBQUMsY0FBYyxDQUFDLE9BQU8sQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLEtBQUssQ0FBQyxHQUFHLEVBQUMsVUFBVSxDQUFDLENBQUMsQ0FBQyxDQUFBLENBQUM7UUFDN0UsdUJBQXVCLEdBQUcsSUFBSSxPQUFPLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxLQUFLLENBQUMsR0FBRyxFQUFFLFNBQVMsQ0FBQyxDQUFDLG1CQUFtQixDQUFDO0lBQzlGLENBQUM7SUFBQyxJQUFJLENBQUMsQ0FBQztRQUNILHVCQUF1QixHQUFHLEVBQUUsQ0FBQztJQUNsQyxDQUFDO0lBQUEsQ0FBQztJQUNGLElBQUksQ0FBQyxPQUFPLENBQUMsdUJBQXVCLENBQUMsQ0FBQztJQUN0QyxNQUFNLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQztBQUN4QixDQUFDLENBQUM7QUFFRixJQUFJLFdBQVcsR0FBRyxDQUFDLDBCQUEwQztJQUN6RCxJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsQ0FBQyxDQUFDLEtBQUssRUFBRSxDQUFDO0lBQzdCLElBQUksTUFBTSxHQUFZLE9BQU8sQ0FBQyxRQUFRLENBQUMsT0FBTyxDQUFDO1FBQzNDLFFBQVEsRUFBRSxXQUFXO1FBQ3JCLGVBQWUsRUFBRTtZQUNiLFNBQVMsRUFBRSxnQ0FBZ0M7WUFDM0MsT0FBTyxFQUFFLG1CQUFtQjtZQUM1QixVQUFVLEVBQUUsS0FBSztZQUNqQixtQkFBbUIsRUFBRSwwQkFBMEI7U0FDbEQ7S0FDSixDQUFDLENBQUM7SUFDSCxJQUFJLENBQUMsT0FBTyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBQ3JCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0FBQ3ZCLENBQUMsQ0FBQztBQUVTLFdBQUcsR0FBRztJQUNiLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IscUJBQXFCLEVBQUU7U0FDbEIsSUFBSSxDQUFDLFdBQVcsQ0FBQztTQUNqQixJQUFJLENBQUMsSUFBSSxDQUFDLE9BQU8sQ0FBQyxDQUFDO0lBQ3hCLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDO0FBQ3hCLENBQUMsQ0FBQSJ9
|
||||
3
dist/npmdocker.docker.d.ts
vendored
3
dist/npmdocker.docker.d.ts
vendored
@@ -1,3 +0,0 @@
|
||||
/// <reference types="q" />
|
||||
import * as plugins from "./npmdocker.plugins";
|
||||
export declare let run: (configArg: any) => plugins.q.Promise<{}>;
|
||||
167
dist/npmdocker.docker.js
vendored
167
dist/npmdocker.docker.js
vendored
File diff suppressed because one or more lines are too long
5
dist/npmdocker.paths.d.ts
vendored
5
dist/npmdocker.paths.d.ts
vendored
@@ -1,5 +0,0 @@
|
||||
export declare let cwd: string;
|
||||
export declare let packageBase: string;
|
||||
export declare let assets: string;
|
||||
export declare let buildContextDir: string;
|
||||
export declare let dockerfile: string;
|
||||
12
dist/npmdocker.paths.js
vendored
12
dist/npmdocker.paths.js
vendored
@@ -1,12 +0,0 @@
|
||||
"use strict";
|
||||
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.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=
|
||||
10
dist/npmdocker.plugins.d.ts
vendored
10
dist/npmdocker.plugins.d.ts
vendored
@@ -1,10 +0,0 @@
|
||||
import "typings-global";
|
||||
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 qenv = require("qenv");
|
||||
export import shelljs = require("shelljs");
|
||||
export import smartfile = require("smartfile");
|
||||
export import smartstring = require("smartstring");
|
||||
12
dist/npmdocker.plugins.js
vendored
12
dist/npmdocker.plugins.js
vendored
@@ -1,12 +0,0 @@
|
||||
"use strict";
|
||||
require("typings-global");
|
||||
exports.beautylog = require("beautylog");
|
||||
exports.npmextra = require("npmextra");
|
||||
exports.path = require("path");
|
||||
exports.projectinfo = require("projectinfo");
|
||||
exports.q = require("q");
|
||||
exports.qenv = require("qenv");
|
||||
exports.shelljs = require("shelljs");
|
||||
exports.smartfile = require("smartfile");
|
||||
exports.smartstring = require("smartstring");
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnBsdWdpbnMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9ucG1kb2NrZXIucGx1Z2lucy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ1YsaUJBQVMsV0FBVyxXQUFXLENBQUMsQ0FBQztBQUNqQyxnQkFBUSxXQUFXLFVBQVUsQ0FBQyxDQUFDO0FBQy9CLFlBQUksV0FBVyxNQUFNLENBQUMsQ0FBQztBQUN2QixtQkFBVyxXQUFXLGFBQWEsQ0FBQyxDQUFDO0FBQ3JDLFNBQUMsV0FBVyxHQUFHLENBQUMsQ0FBQztBQUNqQixZQUFJLFdBQVcsTUFBTSxDQUFDLENBQUM7QUFDdkIsZUFBTyxXQUFXLFNBQVMsQ0FBQyxDQUFDO0FBQzdCLGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUM7QUFDakMsbUJBQVcsV0FBVyxhQUFhLENBQUMsQ0FBQyJ9
|
||||
5
dist/npmdocker.promisechain.d.ts
vendored
5
dist/npmdocker.promisechain.d.ts
vendored
@@ -1,5 +0,0 @@
|
||||
/// <reference types="q" />
|
||||
import * as plugins from "./npmdocker.plugins";
|
||||
import { Ora } from "beautylog";
|
||||
export declare let npmdockerOra: Ora;
|
||||
export declare let run: () => plugins.q.Promise<{}>;
|
||||
18
dist/npmdocker.promisechain.js
vendored
18
dist/npmdocker.promisechain.js
vendored
@@ -1,18 +0,0 @@
|
||||
"use strict";
|
||||
const plugins = require("./npmdocker.plugins");
|
||||
const beautylog_1 = require("beautylog");
|
||||
//modules
|
||||
const ConfigModule = require("./npmdocker.config");
|
||||
const DockerModule = require("./npmdocker.docker");
|
||||
exports.npmdockerOra = new beautylog_1.Ora("npmdocker", "blue");
|
||||
exports.npmdockerOra.start();
|
||||
exports.run = () => {
|
||||
let done = plugins.q.defer();
|
||||
ConfigModule.run()
|
||||
.then(DockerModule.run)
|
||||
.then((configArg) => {
|
||||
done.resolve(configArg);
|
||||
});
|
||||
return done.promise;
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnByb21pc2VjaGFpbi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL25wbWRvY2tlci5wcm9taXNlY2hhaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE1BQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFFL0MsNEJBQWtCLFdBQVcsQ0FBQyxDQUFBO0FBQzlCLFNBQVM7QUFDVCxNQUFZLFlBQVksV0FBTSxvQkFBb0IsQ0FBQyxDQUFBO0FBQ25ELE1BQVksWUFBWSxXQUFNLG9CQUFvQixDQUFDLENBQUE7QUFFeEMsb0JBQVksR0FBRyxJQUFJLGVBQUcsQ0FBQyxXQUFXLEVBQUMsTUFBTSxDQUFDLENBQUM7QUFDdEQsb0JBQVksQ0FBQyxLQUFLLEVBQUUsQ0FBQztBQUNWLFdBQUcsR0FBRztJQUNiLElBQUksSUFBSSxHQUFHLE9BQU8sQ0FBQyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUM7SUFDN0IsWUFBWSxDQUFDLEdBQUcsRUFBRTtTQUNiLElBQUksQ0FBQyxZQUFZLENBQUMsR0FBRyxDQUFDO1NBQ3RCLElBQUksQ0FBQyxDQUFDLFNBQVM7UUFDWixJQUFJLENBQUMsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0lBQzVCLENBQUMsQ0FBQyxDQUFBO0lBQ04sTUFBTSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUM7QUFDeEIsQ0FBQyxDQUFBIn0=
|
||||
5
dist/npmdocker.snippets.d.ts
vendored
5
dist/npmdocker.snippets.d.ts
vendored
@@ -1,5 +0,0 @@
|
||||
export interface IDockerfileSnippet {
|
||||
baseImage: string;
|
||||
command: string;
|
||||
}
|
||||
export declare let dockerfileSnippet: (optionsArg: IDockerfileSnippet) => string;
|
||||
21
dist/npmdocker.snippets.js
vendored
21
dist/npmdocker.snippets.js
vendored
@@ -1,21 +0,0 @@
|
||||
"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}
|
||||
COPY ./buildContextDir /workspace
|
||||
WORKDIR /workspace
|
||||
ENV CI=true
|
||||
CMD [${commandString}];
|
||||
`);
|
||||
};
|
||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnBtZG9ja2VyLnNuaXBwZXRzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvbnBtZG9ja2VyLnNuaXBwZXRzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxNQUFZLE9BQU8sV0FBTSxxQkFBcUIsQ0FBQyxDQUFBO0FBT3BDLHlCQUFpQixHQUFHLENBQUMsVUFBNkI7SUFDekQsSUFBSSxZQUFZLEdBQUcsVUFBVSxDQUFDLE9BQU8sQ0FBQyxLQUFLLENBQUMsSUFBSSxDQUFDLENBQUM7SUFDbEQsSUFBSSxhQUFhLEdBQVUsRUFBRSxDQUFDO0lBQzlCLEdBQUcsQ0FBQSxDQUFDLElBQUksVUFBVSxJQUFJLFlBQVksQ0FBQyxDQUFBLENBQUM7UUFDaEMsRUFBRSxDQUFBLENBQUMsQ0FBQyxDQUFDLGFBQWEsSUFBSSxFQUFFLENBQUMsQ0FBQyxDQUFBLENBQUM7WUFDdkIsYUFBYSxHQUFHLGFBQWEsR0FBRyxHQUFHLENBQUM7UUFDeEMsQ0FBQztRQUNELGFBQWEsR0FBRyxhQUFhLEdBQUcsR0FBRyxHQUFHLFVBQVUsR0FBRyxHQUFHLENBQUM7SUFDM0QsQ0FBQztJQUFBLENBQUM7SUFDRixNQUFNLENBQUMsT0FBTyxDQUFDLFdBQVcsQ0FBQyxNQUFNLENBQUMsU0FBUyxDQUFDO2VBQ2pDLFVBQVUsQ0FBQyxTQUFTOzs7O2VBSXBCLGFBQWE7S0FDdkIsQ0FBQyxDQUFDO0FBQ1AsQ0FBQyxDQUFBIn0=
|
||||
@@ -1,7 +1,20 @@
|
||||
{
|
||||
"npmts": {
|
||||
"mode": "default",
|
||||
"cli":true,
|
||||
"dockerSock":true
|
||||
"cli": true
|
||||
},
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"gitzone": {
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "gitzone",
|
||||
"gitrepo": "npmdocker",
|
||||
"shortDescription": "develop npm modules cross platform with docker",
|
||||
"npmPackagename": "@gitzone/npmdocker",
|
||||
"license": "MIT"
|
||||
}
|
||||
}
|
||||
}
|
||||
28061
package-lock.json
generated
Normal file
28061
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
55
package.json
55
package.json
@@ -1,25 +1,27 @@
|
||||
{
|
||||
"name": "npmdocker",
|
||||
"version": "1.2.1",
|
||||
"name": "@gitzone/tsdocker",
|
||||
"version": "1.2.41",
|
||||
"private": false,
|
||||
"description": "develop npm modules cross platform with docker",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"bin": {
|
||||
"npmdocker": "dist/cli.js"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
"tsdocker": "cli.js"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "(npm run clean && npm run compile && npm run setupCheck && npm run check)",
|
||||
"test": "(npm run clean && npm run setupCheck && npm run testStandard && npm run testSpeed)",
|
||||
"build": "(tsbuild)",
|
||||
"testStandard": "(cd test/ && node ../cli.ts.js)",
|
||||
"testSpeed": "(cd test/ && node ../cli.ts.js speedtest)",
|
||||
"testClean": "(cd test/ && node ../cli.ts.js clean --all)",
|
||||
"testVscode": "(cd test/ && node ../cli.ts.js vscode)",
|
||||
"clean": "(rm -rf test/)",
|
||||
"compile": "(npmts --notest)",
|
||||
"setupCheck": "(git clone https://gitlab.com/sandboxzone/sandbox-npmts.git test/)",
|
||||
"check": "(cd test/ && node ../dist/index.js)"
|
||||
"setupCheck": "(git clone https://gitlab.com/sandboxzone/sandbox-npmts.git test/)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@gitlab.com/pushrocks/npmdocker.git"
|
||||
"url": "git+ssh://git@gitlab.com/gitzone/npmdocker.git"
|
||||
},
|
||||
"keywords": [
|
||||
"docker"
|
||||
@@ -27,23 +29,28 @@
|
||||
"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"
|
||||
"@git.zone/tsbuild": "^3.1.0",
|
||||
"@git.zone/tsrun": "^2.0.0",
|
||||
"@git.zone/tstest": "^3.1.3",
|
||||
"@types/node": "^22.10.2"
|
||||
},
|
||||
"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"
|
||||
"@push.rocks/npmextra": "^5.3.3",
|
||||
"@push.rocks/projectinfo": "^5.0.2",
|
||||
"@push.rocks/qenv": "^6.1.3",
|
||||
"@push.rocks/smartanalytics": "^2.0.15",
|
||||
"@push.rocks/smartcli": "^4.0.19",
|
||||
"@push.rocks/smartfs": "^1.1.0",
|
||||
"@push.rocks/smartlog": "^3.1.10",
|
||||
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
||||
"@push.rocks/smartlog-source-ora": "^1.0.9",
|
||||
"@push.rocks/smartopen": "^2.0.0",
|
||||
"@push.rocks/smartpromise": "^4.2.3",
|
||||
"@push.rocks/smartshell": "^3.3.0",
|
||||
"@push.rocks/smartstring": "^4.1.0"
|
||||
}
|
||||
}
|
||||
|
||||
8436
pnpm-lock.yaml
generated
Normal file
8436
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
34
readme.hints.md
Normal file
34
readme.hints.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# tsdocker Project Hints
|
||||
|
||||
## Module Purpose
|
||||
tsdocker is a tool for developing npm modules cross-platform using Docker. It allows testing in clean, reproducible Linux environments locally.
|
||||
|
||||
## Recent Upgrades (2025-11-22)
|
||||
- Updated all @gitzone/* dependencies to @git.zone/* scope (latest versions)
|
||||
- Updated all @pushrocks/* dependencies to @push.rocks/* scope (latest versions)
|
||||
- Migrated from smartfile v8 to smartfs v1.1.0
|
||||
- All filesystem operations now use smartfs fluent API
|
||||
- Operations are now async (smartfs is async-only)
|
||||
- Updated dev dependencies:
|
||||
- @git.zone/tsbuild: ^3.1.0
|
||||
- @git.zone/tsrun: ^2.0.0
|
||||
- @git.zone/tstest: ^3.1.3
|
||||
- Removed @pushrocks/tapbundle (now use @git.zone/tstest/tapbundle)
|
||||
- Updated @types/node to ^22.10.2
|
||||
- Removed tslint and tslint-config-prettier (no longer needed)
|
||||
|
||||
## SmartFS Migration Details
|
||||
The following operations were converted:
|
||||
- `smartfile.fs.fileExistsSync()` → Node.js `fs.existsSync()` (for sync needs)
|
||||
- `smartfile.fs.ensureDirSync()` → Node.js `fs.mkdirSync(..., { recursive: true })`
|
||||
- `smartfile.memory.toFsSync()` → `smartfs.file(path).write(content)` (async)
|
||||
- `smartfile.fs.removeSync()` → `smartfs.file(path).delete()` (async)
|
||||
|
||||
## Test Status
|
||||
- Build: ✅ Passes
|
||||
- The integration test requires cloning an external test repository (sandbox-npmts)
|
||||
- The external test repo uses top-level await which requires ESM module handling
|
||||
- This is not a tsdocker issue but rather the test repository's structure
|
||||
|
||||
## Dependencies
|
||||
All dependencies are now at their latest versions compatible with Node.js without introducing new Node.js-specific dependencies.
|
||||
310
readme.md
Normal file
310
readme.md
Normal file
@@ -0,0 +1,310 @@
|
||||
# @gitzone/tsdocker
|
||||
|
||||
> 🐳 Cross-platform npm module development with Docker — test your packages in clean, reproducible Linux environments every time.
|
||||
|
||||
## Issue Reporting and Security
|
||||
|
||||
For reporting bugs, issues, or security vulnerabilities, please visit [community.foss.global/](https://community.foss.global/). This is the central community hub for all issue reporting. Developers who sign and comply with our contribution agreement and go through identification can also get a [code.foss.global/](https://code.foss.global/) account to submit Pull Requests directly.
|
||||
|
||||
## What is tsdocker?
|
||||
|
||||
**tsdocker** provides containerized testing environments for npm packages, ensuring your code works consistently across different systems. It's perfect for:
|
||||
|
||||
- 🧪 **Testing in clean environments** — Every test run starts fresh, just like CI
|
||||
- 🔄 **Reproducing CI behavior locally** — No more "works on my machine" surprises
|
||||
- 🐧 **Cross-platform development** — Develop on macOS/Windows, test on Linux
|
||||
- 🚀 **Quick validation** — Spin up isolated containers for testing without polluting your system
|
||||
|
||||
## Features
|
||||
|
||||
✨ **Works Everywhere Docker Does**
|
||||
- Docker Toolbox
|
||||
- Native Docker Desktop
|
||||
- Docker-in-Docker (DinD)
|
||||
- Mounted docker.sock scenarios
|
||||
|
||||
🔧 **Flexible Configuration**
|
||||
- Custom base images
|
||||
- Configurable test commands
|
||||
- Environment variable injection via qenv
|
||||
- Optional docker.sock mounting for nested container tests
|
||||
|
||||
📦 **TypeScript-First**
|
||||
- Full TypeScript support with excellent IntelliSense
|
||||
- Type-safe configuration
|
||||
- Modern async/await patterns throughout
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install --save-dev @gitzone/tsdocker
|
||||
# or
|
||||
pnpm install --save-dev @gitzone/tsdocker
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Configure Your Project
|
||||
|
||||
Create an `npmextra.json` file in your project root:
|
||||
|
||||
```json
|
||||
{
|
||||
"npmdocker": {
|
||||
"baseImage": "hosttoday/ht-docker-node:npmts",
|
||||
"command": "npmci test stable",
|
||||
"dockerSock": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Run Your Tests
|
||||
|
||||
```bash
|
||||
npx tsdocker
|
||||
```
|
||||
|
||||
That's it! tsdocker will:
|
||||
1. ✅ Verify Docker is available
|
||||
2. 🏗️ Build a test container with your specified base image
|
||||
3. 📂 Mount your project directory
|
||||
4. 🚀 Execute your test command
|
||||
5. 🧹 Clean up automatically
|
||||
|
||||
## Configuration Options
|
||||
|
||||
| Option | Type | Description |
|
||||
|--------|------|-------------|
|
||||
| `baseImage` | `string` | Docker image to use as the test environment base |
|
||||
| `command` | `string` | CLI command to execute inside the container |
|
||||
| `dockerSock` | `boolean` | Whether to mount `/var/run/docker.sock` for Docker-in-Docker scenarios |
|
||||
|
||||
### Environment Variables
|
||||
|
||||
If you have a `qenv.yml` file in your project, tsdocker automatically loads and injects those environment variables into your test container.
|
||||
|
||||
Example `qenv.yml`:
|
||||
```yaml
|
||||
demoKey: demoValue
|
||||
API_KEY: your-key-here
|
||||
```
|
||||
|
||||
## CLI Commands
|
||||
|
||||
### Standard Test Run
|
||||
```bash
|
||||
tsdocker
|
||||
```
|
||||
Runs your configured test command in a fresh Docker container.
|
||||
|
||||
### Clean Docker Environment
|
||||
```bash
|
||||
tsdocker clean --all
|
||||
```
|
||||
⚠️ **WARNING**: This aggressively cleans your Docker environment by:
|
||||
- Killing all running containers
|
||||
- Removing all stopped containers
|
||||
- Removing dangling images
|
||||
- Removing all images
|
||||
- Removing dangling volumes
|
||||
|
||||
Use with caution!
|
||||
|
||||
### VSCode in Docker
|
||||
```bash
|
||||
tsdocker vscode
|
||||
```
|
||||
Launches a containerized VS Code instance accessible via browser at `testing-vscode.git.zone:8443`.
|
||||
|
||||
### Speed Test
|
||||
```bash
|
||||
tsdocker speedtest
|
||||
```
|
||||
Runs a network speed test inside a Docker container.
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
### Docker-in-Docker Testing
|
||||
|
||||
If you need to run Docker commands inside your test container (e.g., testing Docker-related tools):
|
||||
|
||||
```json
|
||||
{
|
||||
"npmdocker": {
|
||||
"baseImage": "docker:latest",
|
||||
"command": "docker run hello-world",
|
||||
"dockerSock": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Setting `"dockerSock": true` mounts the host's Docker socket into the container.
|
||||
|
||||
### Custom Base Images
|
||||
|
||||
You can use any Docker image as your base:
|
||||
|
||||
```json
|
||||
{
|
||||
"npmdocker": {
|
||||
"baseImage": "node:20-alpine",
|
||||
"command": "npm test"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Popular choices:
|
||||
- `node:20` — Official Node.js images
|
||||
- `node:20-alpine` — Lightweight Alpine-based images
|
||||
- `hosttoday/ht-docker-node:npmts` — Pre-configured with npmts tooling
|
||||
|
||||
### CI Integration
|
||||
|
||||
tsdocker automatically detects CI environments (via `CI=true` env var) and adjusts behavior:
|
||||
- Skips mounting project directory in CI (assumes code is already in container)
|
||||
- Optimizes for CI execution patterns
|
||||
|
||||
## Why tsdocker?
|
||||
|
||||
### The Problem
|
||||
|
||||
Local development environments drift over time. You might have:
|
||||
- Stale global packages
|
||||
- Modified system configurations
|
||||
- Cached dependencies
|
||||
- Different Node.js versions
|
||||
|
||||
Your tests pass locally but fail in CI — or vice versa.
|
||||
|
||||
### The Solution
|
||||
|
||||
tsdocker ensures every test run happens in a **clean, reproducible environment**, just like your CI pipeline. This means:
|
||||
|
||||
✅ Consistent behavior between local and CI
|
||||
✅ No dependency pollution between test runs
|
||||
✅ Easy cross-platform testing
|
||||
✅ Reproducible bug investigations
|
||||
|
||||
## TypeScript Usage
|
||||
|
||||
tsdocker is built with TypeScript and provides full type definitions:
|
||||
|
||||
```typescript
|
||||
import { IConfig } from '@gitzone/tsdocker/dist/tsdocker.config';
|
||||
|
||||
const config: IConfig = {
|
||||
baseImage: 'node:20',
|
||||
command: 'npm test',
|
||||
dockerSock: false,
|
||||
keyValueObject: {
|
||||
NODE_ENV: 'test'
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- **Docker**: Docker must be installed and accessible via CLI
|
||||
- **Node.js**: Version 14 or higher recommended
|
||||
|
||||
## How It Works
|
||||
|
||||
Under the hood, tsdocker:
|
||||
|
||||
1. 📋 Reads your `npmextra.json` configuration
|
||||
2. 🔍 Optionally loads environment variables from `qenv.yml`
|
||||
3. 🐳 Generates a temporary Dockerfile
|
||||
4. 🏗️ Builds a Docker image with your base image
|
||||
5. 📦 Mounts your project directory (unless in CI)
|
||||
6. ▶️ Runs your test command inside the container
|
||||
7. 📊 Captures the exit code
|
||||
8. 🧹 Cleans up containers and images
|
||||
9. ✅ Exits with the same code as your tests
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### "docker not found on this machine"
|
||||
|
||||
Make sure Docker is installed and the `docker` command is in your PATH:
|
||||
|
||||
```bash
|
||||
docker --version
|
||||
```
|
||||
|
||||
### Tests fail in container but work locally
|
||||
|
||||
This often indicates environment-specific issues. Check:
|
||||
- Are all dependencies in `package.json`? (not relying on global packages)
|
||||
- Does your code have hardcoded paths?
|
||||
- Are environment variables set correctly?
|
||||
|
||||
### Permission errors with docker.sock
|
||||
|
||||
If using `dockerSock: true`, ensure your user has permissions to access `/var/run/docker.sock`:
|
||||
|
||||
```bash
|
||||
sudo usermod -aG docker $USER
|
||||
# Then log out and back in
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Basic npm test
|
||||
```json
|
||||
{
|
||||
"npmdocker": {
|
||||
"baseImage": "node:20",
|
||||
"command": "npm test"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Using npmci for multiple Node versions
|
||||
```json
|
||||
{
|
||||
"npmdocker": {
|
||||
"baseImage": "hosttoday/ht-docker-node:npmts",
|
||||
"command": "npmci test stable"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Testing Docker-based tools
|
||||
```json
|
||||
{
|
||||
"npmdocker": {
|
||||
"baseImage": "docker:latest",
|
||||
"command": "sh -c 'docker version && docker ps'",
|
||||
"dockerSock": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Performance Tips
|
||||
|
||||
🚀 **Use specific base images**: `node:20-alpine` is much faster to pull than `node:latest`
|
||||
🚀 **Layer caching**: Docker caches image layers — your base image only downloads once
|
||||
🚀 **Prune regularly**: Run `docker system prune` periodically to reclaim disk space
|
||||
|
||||
## Migration from @gitzone/npmdocker
|
||||
|
||||
This package was previously published as `@gitzone/npmdocker`. The scope has been updated to `@gitzone/tsdocker` for better naming consistency. Functionality remains the same.
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@gitzone/tsdocker',
|
||||
version: '1.2.41',
|
||||
description: 'develop npm modules cross platform with docker'
|
||||
}
|
||||
17
ts/index.ts
17
ts/index.ts
@@ -1,15 +1,4 @@
|
||||
import * as plugins from "./npmdocker.plugins";
|
||||
import * as promisechain from "./npmdocker.promisechain";
|
||||
import * as ConfigModule from "./npmdocker.config";
|
||||
|
||||
|
||||
promisechain.run()
|
||||
.then((configArg:ConfigModule.IConfig) => {
|
||||
if(configArg.exitCode == 0){
|
||||
plugins.beautylog.success("container ended all right!");
|
||||
} else {
|
||||
plugins.beautylog.error("container ended with error!");
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
import * as plugins from './tsdocker.plugins';
|
||||
import * as cli from './tsdocker.cli';
|
||||
|
||||
cli.run();
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import * as plugins from "./npmdocker.plugins";
|
||||
import * as paths from "./npmdocker.paths";
|
||||
|
||||
// interfaces
|
||||
import { IKeyValueObject } from "qenv";
|
||||
|
||||
export interface IConfig {
|
||||
baseImage: string;
|
||||
command: string;
|
||||
dockerSock: boolean;
|
||||
exitCode?: number;
|
||||
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;
|
||||
} else {
|
||||
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",
|
||||
dockerSock: false,
|
||||
keyValueObjectArray: qenvKeyValueObjectArrayArg
|
||||
}
|
||||
});
|
||||
done.resolve(config);
|
||||
return done.promise
|
||||
};
|
||||
|
||||
export let run = () => {
|
||||
let done = plugins.q.defer();
|
||||
getQenvKeyValueObject()
|
||||
.then(buildConfig)
|
||||
.then(done.resolve);
|
||||
return done.promise;
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
import * as plugins from "./npmdocker.plugins";
|
||||
import * as paths from "./npmdocker.paths";
|
||||
import * as snippets from "./npmdocker.snippets";
|
||||
|
||||
import { npmdockerOra } from "./npmdocker.promisechain";
|
||||
|
||||
// interfaces
|
||||
import { IConfig } from "./npmdocker.config";
|
||||
|
||||
let config: IConfig;
|
||||
let dockerData = {
|
||||
imageTag: "npmdocker-temp-image:latest",
|
||||
containerName: "npmdocker-temp-container",
|
||||
dockerProjectMountString: "",
|
||||
dockerSockString: "",
|
||||
dockerEnvString: ""
|
||||
};
|
||||
|
||||
/**
|
||||
* check if docker is available
|
||||
*/
|
||||
let checkDocker = () => {
|
||||
let done = plugins.q.defer();
|
||||
npmdockerOra.text("checking docker...");
|
||||
if (plugins.shelljs.which("docker")) {
|
||||
plugins.beautylog.ok("Docker found!")
|
||||
done.resolve();
|
||||
} else {
|
||||
done.reject(new Error("docker not found on this machine"));
|
||||
}
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* builds the Dockerfile according to the config in the project
|
||||
*/
|
||||
let buildDockerFile = () => {
|
||||
let done = plugins.q.defer();
|
||||
npmdockerOra.text("building Dockerfile...");
|
||||
let dockerfile: string = snippets.dockerfileSnippet({
|
||||
baseImage: config.baseImage,
|
||||
command: config.command
|
||||
});
|
||||
plugins.beautylog.info(`Base image is: ${config.baseImage}`);
|
||||
plugins.beautylog.info(`Command is: ${config.command}`);
|
||||
plugins.smartfile.memory.toFsSync(dockerfile, paths.dockerfile);
|
||||
plugins.beautylog.ok("Dockerfile created!");
|
||||
done.resolve();
|
||||
return done.promise
|
||||
};
|
||||
|
||||
/**
|
||||
* builds the Dockerimage from the built Dockerfile
|
||||
*/
|
||||
let buildDockerImage = () => {
|
||||
let done = plugins.q.defer();
|
||||
npmdockerOra.text("pulling latest base image from registry...");
|
||||
plugins.shelljs.exec(`docker pull ${config.baseImage}`, {
|
||||
silent: true
|
||||
}, () => {
|
||||
npmdockerOra.text("building Dockerimage...");
|
||||
// are we creating a build context form project ?
|
||||
if (process.env.CI == "true") {
|
||||
npmdockerOra.text("creating build context...");
|
||||
plugins.smartfile.fs.copySync(paths.cwd, paths.buildContextDir);
|
||||
}
|
||||
plugins.shelljs.exec(`docker build -f ${paths.dockerfile} -t ${dockerData.imageTag} ${paths.assets}`, {
|
||||
silent: true
|
||||
}, () => {
|
||||
plugins.beautylog.ok("Dockerimage built!")
|
||||
done.resolve();
|
||||
});
|
||||
}); // first pull latest version of baseImage
|
||||
return done.promise
|
||||
};
|
||||
|
||||
let buildDockerProjectMountString = () => {
|
||||
let done = plugins.q.defer();
|
||||
if (process.env.CI != "true") {
|
||||
dockerData.dockerProjectMountString = `-v ${paths.cwd}:/workspace`;
|
||||
};
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
}
|
||||
|
||||
let buildDockerEnvString = () => {
|
||||
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;
|
||||
}
|
||||
|
||||
let buildDockerSockString = () => {
|
||||
let done = plugins.q.defer();
|
||||
if (config.dockerSock) {
|
||||
dockerData.dockerSockString = `-v /var/run/docker.sock:/var/run/docker.sock`
|
||||
};
|
||||
done.resolve()
|
||||
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 deleteDockerContainer = () => {
|
||||
let done = plugins.q.defer();
|
||||
plugins.shelljs.exec(`docker rm -f ${dockerData.containerName}`, {
|
||||
silent: true
|
||||
});
|
||||
done.resolve();
|
||||
return done.promise
|
||||
};
|
||||
|
||||
let deleteDockerImage = () => {
|
||||
let done = plugins.q.defer();
|
||||
plugins.shelljs.exec(`docker rmi ${dockerData.imageTag}`, {
|
||||
silent: true
|
||||
});
|
||||
done.resolve();
|
||||
return done.promise
|
||||
};
|
||||
|
||||
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(() => {
|
||||
plugins.beautylog.ok("ensured clean Docker environment!");
|
||||
done.resolve();
|
||||
});
|
||||
};
|
||||
|
||||
let postClean = () => {
|
||||
let done = plugins.q.defer();
|
||||
deleteDockerContainer()
|
||||
.then(deleteDockerImage)
|
||||
.then(deleteBuildContext)
|
||||
.then(() => {
|
||||
plugins.beautylog.ok("cleaned up!");
|
||||
done.resolve();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
export let run = (configArg) => {
|
||||
let done = plugins.q.defer();
|
||||
config = configArg;
|
||||
checkDocker()
|
||||
.then(preClean)
|
||||
.then(buildDockerFile)
|
||||
.then(buildDockerImage)
|
||||
.then(buildDockerProjectMountString)
|
||||
.then(buildDockerEnvString)
|
||||
.then(buildDockerSockString)
|
||||
.then(runDockerImage)
|
||||
.then(postClean)
|
||||
.then(() => {
|
||||
done.resolve(config);
|
||||
}).catch(err => {console.log(err)});
|
||||
return done.promise;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import * as plugins from "./npmdocker.plugins";
|
||||
|
||||
// directories
|
||||
export let cwd = process.cwd();
|
||||
export let packageBase = plugins.path.join(__dirname, "../");
|
||||
export let assets = plugins.path.join(packageBase, "assets/");
|
||||
plugins.smartfile.fs.ensureDirSync(assets);
|
||||
|
||||
export let buildContextDir = plugins.path.join(assets,"buildContextDir");
|
||||
plugins.smartfile.fs.ensureDirSync(buildContextDir);
|
||||
|
||||
// files
|
||||
export let dockerfile = plugins.path.join(assets, "Dockerfile");
|
||||
@@ -1,10 +0,0 @@
|
||||
import "typings-global";
|
||||
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 qenv = require("qenv");
|
||||
export import shelljs = require("shelljs");
|
||||
export import smartfile = require("smartfile");
|
||||
export import smartstring = require("smartstring");
|
||||
@@ -1,18 +0,0 @@
|
||||
import * as plugins from "./npmdocker.plugins";
|
||||
import * as paths from "./npmdocker.paths";
|
||||
import {Ora} from "beautylog";
|
||||
//modules
|
||||
import * as ConfigModule from "./npmdocker.config";
|
||||
import * as DockerModule from "./npmdocker.docker";
|
||||
|
||||
export let npmdockerOra = new Ora("npmdocker","blue");
|
||||
npmdockerOra.start();
|
||||
export let run = () => {
|
||||
let done = plugins.q.defer();
|
||||
ConfigModule.run()
|
||||
.then(DockerModule.run)
|
||||
.then((configArg) => {
|
||||
done.resolve(configArg);
|
||||
})
|
||||
return done.promise;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
import * as plugins from "./npmdocker.plugins";
|
||||
|
||||
export interface IDockerfileSnippet {
|
||||
baseImage:string;
|
||||
command:string;
|
||||
}
|
||||
|
||||
export let dockerfileSnippet = (optionsArg:IDockerfileSnippet):string => {
|
||||
let commandArray = optionsArg.command.split(/\s/);
|
||||
let commandString:string = "";
|
||||
for(let stringItem of commandArray){
|
||||
if(!(commandString == "")){
|
||||
commandString = commandString + ",";
|
||||
}
|
||||
commandString = commandString + '"' + stringItem + '"';
|
||||
};
|
||||
return plugins.smartstring.indent.normalize(`
|
||||
FROM ${optionsArg.baseImage}
|
||||
COPY ./buildContextDir /workspace
|
||||
WORKDIR /workspace
|
||||
ENV CI=true
|
||||
CMD [${commandString}];
|
||||
`);
|
||||
}
|
||||
90
ts/tsdocker.cli.ts
Normal file
90
ts/tsdocker.cli.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import * as plugins from './tsdocker.plugins';
|
||||
import * as paths from './tsdocker.paths';
|
||||
|
||||
// modules
|
||||
import * as ConfigModule from './tsdocker.config';
|
||||
import * as DockerModule from './tsdocker.docker';
|
||||
|
||||
import { logger, ora } from './tsdocker.logging';
|
||||
|
||||
const tsdockerCli = new plugins.smartcli.Smartcli();
|
||||
|
||||
export let run = () => {
|
||||
tsdockerCli.standardTask().subscribe(async argvArg => {
|
||||
const configArg = await ConfigModule.run().then(DockerModule.run);
|
||||
if (configArg.exitCode === 0) {
|
||||
logger.log('success', 'container ended all right!');
|
||||
} else {
|
||||
logger.log('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
|
||||
*/
|
||||
tsdockerCli.addCommand('runinside').subscribe(async argvArg => {
|
||||
logger.log('ok', 'Allright. We are now in Docker!');
|
||||
ora.text('now trying to run your specified command');
|
||||
const configArg = await ConfigModule.run();
|
||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash'
|
||||
});
|
||||
ora.stop();
|
||||
await smartshellInstance.exec(configArg.command).then(response => {
|
||||
if (response.exitCode !== 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
tsdockerCli.addCommand('clean').subscribe(async argvArg => {
|
||||
ora.text('cleaning up docker env...');
|
||||
if (argvArg.all) {
|
||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash'
|
||||
});
|
||||
ora.text('killing any running docker containers...');
|
||||
await smartshellInstance.exec(`docker kill $(docker ps -q)`);
|
||||
|
||||
ora.text('removing stopped containers...');
|
||||
await smartshellInstance.exec(`docker rm $(docker ps -a -q)`);
|
||||
|
||||
ora.text('removing images...');
|
||||
await smartshellInstance.exec(`docker rmi -f $(docker images -q -f dangling=true)`);
|
||||
|
||||
ora.text('removing all other images...');
|
||||
await smartshellInstance.exec(`docker rmi $(docker images -a -q)`);
|
||||
|
||||
ora.text('removing all volumes...');
|
||||
await smartshellInstance.exec(`docker volume rm $(docker volume ls -f dangling=true -q)`);
|
||||
}
|
||||
ora.finishSuccess('docker environment now is clean!');
|
||||
});
|
||||
|
||||
tsdockerCli.addCommand('speedtest').subscribe(async argvArg => {
|
||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash'
|
||||
});
|
||||
logger.log('ok', 'Starting speedtest');
|
||||
await smartshellInstance.exec(
|
||||
`docker pull tianon/speedtest && docker run --rm tianon/speedtest --accept-license --accept-gdpr`
|
||||
);
|
||||
});
|
||||
|
||||
tsdockerCli.addCommand('vscode').subscribe(async argvArg => {
|
||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash'
|
||||
});
|
||||
logger.log('ok', `Starting vscode in cwd ${paths.cwd}`);
|
||||
await smartshellInstance.execAndWaitForLine(
|
||||
`docker run -p 127.0.0.1:8443:8443 -v "${
|
||||
paths.cwd
|
||||
}:/home/coder/project" registry.gitlab.com/hosttoday/ht-docker-vscode --allow-http --no-auth`,
|
||||
/Connected to shared process/
|
||||
);
|
||||
await plugins.smartopen.openUrl('testing-vscode.git.zone:8443');
|
||||
});
|
||||
|
||||
tsdockerCli.startParse();
|
||||
};
|
||||
38
ts/tsdocker.config.ts
Normal file
38
ts/tsdocker.config.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import * as plugins from './tsdocker.plugins';
|
||||
import * as paths from './tsdocker.paths';
|
||||
import * as fs from 'fs';
|
||||
|
||||
export interface IConfig {
|
||||
baseImage: string;
|
||||
command: string;
|
||||
dockerSock: boolean;
|
||||
exitCode?: number;
|
||||
keyValueObject: {[key: string]: any};
|
||||
}
|
||||
|
||||
const getQenvKeyValueObject = async () => {
|
||||
let qenvKeyValueObjectArray: { [key: string]: string | number };
|
||||
if (fs.existsSync(plugins.path.join(paths.cwd, 'qenv.yml'))) {
|
||||
qenvKeyValueObjectArray = new plugins.qenv.Qenv(paths.cwd, '.nogit/').keyValueObject;
|
||||
} else {
|
||||
qenvKeyValueObjectArray = {};
|
||||
}
|
||||
return qenvKeyValueObjectArray;
|
||||
};
|
||||
|
||||
const buildConfig = async (qenvKeyValueObjectArg: { [key: string]: string | number }) => {
|
||||
const npmextra = new plugins.npmextra.Npmextra(paths.cwd);
|
||||
const config = npmextra.dataFor<IConfig>('npmdocker', {
|
||||
baseImage: 'hosttoday/ht-docker-node:npmdocker',
|
||||
init: 'rm -rf node_nodules/ && yarn install',
|
||||
command: 'npmci npm test',
|
||||
dockerSock: false,
|
||||
keyValueObject: qenvKeyValueObjectArg
|
||||
});
|
||||
return config;
|
||||
};
|
||||
|
||||
export let run = async (): Promise<IConfig> => {
|
||||
const config = await getQenvKeyValueObject().then(buildConfig);
|
||||
return config;
|
||||
};
|
||||
169
ts/tsdocker.docker.ts
Normal file
169
ts/tsdocker.docker.ts
Normal file
@@ -0,0 +1,169 @@
|
||||
import * as plugins from './tsdocker.plugins';
|
||||
import * as paths from './tsdocker.paths';
|
||||
import * as snippets from './tsdocker.snippets';
|
||||
|
||||
import { logger, ora } from './tsdocker.logging';
|
||||
|
||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||
executor: 'bash'
|
||||
});
|
||||
|
||||
// interfaces
|
||||
import { IConfig } from './tsdocker.config';
|
||||
|
||||
let config: IConfig;
|
||||
|
||||
/**
|
||||
* the docker data used to build the internal testing container
|
||||
*/
|
||||
const dockerData = {
|
||||
imageTag: 'npmdocker-temp-image:latest',
|
||||
containerName: 'npmdocker-temp-container',
|
||||
dockerProjectMountString: '',
|
||||
dockerSockString: '',
|
||||
dockerEnvString: ''
|
||||
};
|
||||
|
||||
/**
|
||||
* check if docker is available
|
||||
*/
|
||||
const checkDocker = () => {
|
||||
const done = plugins.smartpromise.defer();
|
||||
ora.text('checking docker...');
|
||||
|
||||
if (smartshellInstance.exec('which docker')) {
|
||||
logger.log('ok', 'Docker found!');
|
||||
done.resolve();
|
||||
} else {
|
||||
done.reject(new Error('docker not found on this machine'));
|
||||
}
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* builds the Dockerfile according to the config in the project
|
||||
*/
|
||||
const buildDockerFile = async () => {
|
||||
const done = plugins.smartpromise.defer();
|
||||
ora.text('building Dockerfile...');
|
||||
const dockerfile: string = snippets.dockerfileSnippet({
|
||||
baseImage: config.baseImage,
|
||||
command: config.command
|
||||
});
|
||||
logger.log('info', `Base image is: ${config.baseImage}`);
|
||||
logger.log('info', `Command is: ${config.command}`);
|
||||
await plugins.smartfs.file(plugins.path.join(paths.cwd, 'npmdocker')).write(dockerfile);
|
||||
logger.log('ok', 'Dockerfile created!');
|
||||
ora.stop();
|
||||
done.resolve();
|
||||
return done.promise;
|
||||
};
|
||||
|
||||
/**
|
||||
* builds the Dockerimage from the built Dockerfile
|
||||
*/
|
||||
const buildDockerImage = async () => {
|
||||
logger.log('info', 'pulling latest base image from registry...');
|
||||
await smartshellInstance.exec(`docker pull ${config.baseImage}`);
|
||||
ora.text('building Dockerimage...');
|
||||
const execResult = await smartshellInstance.execSilent(
|
||||
`docker build -f npmdocker -t ${dockerData.imageTag} ${paths.cwd}`
|
||||
);
|
||||
if (execResult.exitCode !== 0) {
|
||||
console.log(execResult.stdout);
|
||||
process.exit(1);
|
||||
}
|
||||
logger.log('ok', 'Dockerimage built!');
|
||||
};
|
||||
|
||||
const buildDockerProjectMountString = async () => {
|
||||
if (process.env.CI !== 'true') {
|
||||
dockerData.dockerProjectMountString = `-v ${paths.cwd}:/workspace`;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* builds an environment string that docker cli understands
|
||||
*/
|
||||
const buildDockerEnvString = async () => {
|
||||
for (const key of Object.keys(config.keyValueObject)) {
|
||||
const envString = (dockerData.dockerEnvString =
|
||||
dockerData.dockerEnvString + `-e ${key}=${config.keyValueObject[key]} `);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* creates string to mount the docker.sock inside the testcontainer
|
||||
*/
|
||||
const buildDockerSockString = async () => {
|
||||
if (config.dockerSock) {
|
||||
dockerData.dockerSockString = `-v /var/run/docker.sock:/var/run/docker.sock`;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* creates a container by running the built Dockerimage
|
||||
*/
|
||||
const runDockerImage = async () => {
|
||||
const done = plugins.smartpromise.defer();
|
||||
ora.text('starting Container...');
|
||||
ora.stop();
|
||||
logger.log('info', 'now running Dockerimage');
|
||||
config.exitCode = (await smartshellInstance.exec(
|
||||
`docker run ${dockerData.dockerProjectMountString} ${dockerData.dockerSockString} ${
|
||||
dockerData.dockerEnvString
|
||||
} --name ${dockerData.containerName} ${dockerData.imageTag}`
|
||||
)).exitCode;
|
||||
};
|
||||
|
||||
/**
|
||||
* cleans up: deletes the test container
|
||||
*/
|
||||
const deleteDockerContainer = async () => {
|
||||
await smartshellInstance.execSilent(`docker rm -f ${dockerData.containerName}`);
|
||||
};
|
||||
|
||||
/**
|
||||
* cleans up deletes the test image
|
||||
*/
|
||||
const deleteDockerImage = async () => {
|
||||
await smartshellInstance.execSilent(`docker rmi ${dockerData.imageTag}`).then(async response => {
|
||||
if (response.exitCode !== 0) {
|
||||
console.log(response.stdout);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const preClean = async () => {
|
||||
await deleteDockerImage()
|
||||
.then(deleteDockerContainer)
|
||||
.then(async () => {
|
||||
logger.log('ok', 'ensured clean Docker environment!');
|
||||
});
|
||||
};
|
||||
|
||||
const postClean = async () => {
|
||||
await deleteDockerContainer()
|
||||
.then(deleteDockerImage)
|
||||
.then(async () => {
|
||||
logger.log('ok', 'cleaned up!');
|
||||
});
|
||||
await plugins.smartfs.file(paths.npmdockerFile).delete();
|
||||
};
|
||||
|
||||
export let run = async (configArg: IConfig): Promise<IConfig> => {
|
||||
config = configArg;
|
||||
const resultConfig = await checkDocker()
|
||||
.then(preClean)
|
||||
.then(buildDockerFile)
|
||||
.then(buildDockerImage)
|
||||
.then(buildDockerProjectMountString)
|
||||
.then(buildDockerEnvString)
|
||||
.then(buildDockerSockString)
|
||||
.then(runDockerImage)
|
||||
.then(postClean)
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
});
|
||||
return config;
|
||||
};
|
||||
17
ts/tsdocker.logging.ts
Normal file
17
ts/tsdocker.logging.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import * as plugins from './tsdocker.plugins';
|
||||
|
||||
export const logger = new plugins.smartlog.Smartlog({
|
||||
logContext: {
|
||||
company: 'Some Company',
|
||||
companyunit: 'Some CompanyUnit',
|
||||
containerName: 'Some Containername',
|
||||
environment: 'local',
|
||||
runtime: 'node',
|
||||
zone: 'gitzone'
|
||||
},
|
||||
minimumLogLevel: 'silly'
|
||||
});
|
||||
|
||||
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());
|
||||
|
||||
export const ora = new plugins.smartlogSouceOra.SmartlogSourceOra();
|
||||
9
ts/tsdocker.paths.ts
Normal file
9
ts/tsdocker.paths.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import * as plugins from './tsdocker.plugins';
|
||||
import * as fs from 'fs';
|
||||
|
||||
// directories
|
||||
export let cwd = process.cwd();
|
||||
export let packageBase = plugins.path.join(__dirname, '../');
|
||||
export let assets = plugins.path.join(packageBase, 'assets/');
|
||||
fs.mkdirSync(assets, { recursive: true });
|
||||
export let npmdockerFile = plugins.path.join(cwd, 'npmdocker');
|
||||
32
ts/tsdocker.plugins.ts
Normal file
32
ts/tsdocker.plugins.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
// push.rocks scope
|
||||
import * as npmextra from '@push.rocks/npmextra';
|
||||
import * as path from 'path';
|
||||
import * as projectinfo from '@push.rocks/projectinfo';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
import * as qenv from '@push.rocks/qenv';
|
||||
import * as smartcli from '@push.rocks/smartcli';
|
||||
import { SmartFs, SmartFsProviderNode } from '@push.rocks/smartfs';
|
||||
import * as smartlog from '@push.rocks/smartlog';
|
||||
import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-local';
|
||||
import * as smartlogSouceOra from '@push.rocks/smartlog-source-ora';
|
||||
import * as smartopen from '@push.rocks/smartopen';
|
||||
import * as smartshell from '@push.rocks/smartshell';
|
||||
import * as smartstring from '@push.rocks/smartstring';
|
||||
|
||||
// Create smartfs instance
|
||||
export const smartfs = new SmartFs(new SmartFsProviderNode());
|
||||
|
||||
export {
|
||||
npmextra,
|
||||
path,
|
||||
projectinfo,
|
||||
smartpromise,
|
||||
qenv,
|
||||
smartcli,
|
||||
smartlog,
|
||||
smartlogDestinationLocal,
|
||||
smartlogSouceOra,
|
||||
smartopen,
|
||||
smartshell,
|
||||
smartstring
|
||||
};
|
||||
37
ts/tsdocker.snippets.ts
Normal file
37
ts/tsdocker.snippets.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import * as plugins from './tsdocker.plugins';
|
||||
|
||||
export interface IDockerfileSnippet {
|
||||
baseImage: string;
|
||||
command: string;
|
||||
}
|
||||
|
||||
let getMountSolutionString = (optionsArg: IDockerfileSnippet) => {
|
||||
if (process.env.CI) {
|
||||
return 'COPY ./ /workspace';
|
||||
} else {
|
||||
return '# not copying workspcae since not in CI';
|
||||
}
|
||||
};
|
||||
|
||||
let getGlobalPreparationString = (optionsArg: IDockerfileSnippet) => {
|
||||
if (optionsArg.baseImage !== 'hosttoday/ht-docker-node:npmdocker') {
|
||||
return 'RUN npm install -g npmdocker';
|
||||
} else {
|
||||
return '# not installing npmdocker since it is included in the base image';
|
||||
}
|
||||
};
|
||||
|
||||
export let dockerfileSnippet = (optionsArg: IDockerfileSnippet): string => {
|
||||
return plugins.smartstring.indent.normalize(
|
||||
`
|
||||
FROM ${optionsArg.baseImage}
|
||||
# For info about what npmdocker does read the docs at https://gitzone.github.io/npmdocker
|
||||
${getGlobalPreparationString(optionsArg)}
|
||||
${getMountSolutionString(optionsArg)}
|
||||
WORKDIR /workspace
|
||||
ENV CI=true
|
||||
ENTRYPOINT ["npmdocker"]
|
||||
CMD ["runinside"]
|
||||
`
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user