BREAKING CHANGE(cli): remove legacy container test runner and make the default command show the man page
This commit is contained in:
@@ -3,7 +3,6 @@ import * as paths from './tsdocker.paths.js';
|
||||
|
||||
// modules
|
||||
import * as ConfigModule from './tsdocker.config.js';
|
||||
import * as DockerModule from './tsdocker.docker.js';
|
||||
|
||||
import { logger, ora } from './tsdocker.logging.js';
|
||||
import { TsDockerManager } from './classes.tsdockermanager.js';
|
||||
@@ -14,16 +13,69 @@ import { commitinfo } from './00_commitinfo_data.js';
|
||||
const tsdockerCli = new plugins.smartcli.Smartcli();
|
||||
tsdockerCli.addVersion(commitinfo.version);
|
||||
|
||||
const printManPage = () => {
|
||||
const manPage = `
|
||||
TSDOCKER(1) User Commands TSDOCKER(1)
|
||||
|
||||
NAME
|
||||
tsdocker - build, test, and push Docker images
|
||||
|
||||
VERSION
|
||||
${commitinfo.version}
|
||||
|
||||
SYNOPSIS
|
||||
tsdocker <command> [options]
|
||||
|
||||
COMMANDS
|
||||
build [patterns...] [flags] Build Dockerfiles in dependency order
|
||||
push [patterns...] [flags] Build and push images to registries
|
||||
pull <registry-url> Pull images from a registry
|
||||
test [flags] Build and run container test scripts
|
||||
login Authenticate with configured registries
|
||||
list List discovered Dockerfiles
|
||||
clean [-y] [--all] Interactive Docker resource cleanup
|
||||
|
||||
BUILD / PUSH OPTIONS
|
||||
--platform=<p> Target platform (e.g. linux/arm64)
|
||||
--timeout=<s> Build timeout in seconds
|
||||
--no-cache Rebuild without Docker layer cache
|
||||
--cached Skip builds when Dockerfile is unchanged
|
||||
--verbose Stream raw docker build output
|
||||
--parallel[=<n>] Parallel builds (optional concurrency limit)
|
||||
--context=<name> Docker context to use
|
||||
|
||||
PUSH-ONLY OPTIONS
|
||||
--registry=<url> Push to a specific registry
|
||||
--no-build Push already-built images (skip build step)
|
||||
|
||||
CLEAN OPTIONS
|
||||
-y Auto-confirm all prompts
|
||||
--all Include all images and volumes (not just dangling)
|
||||
|
||||
CONFIGURATION
|
||||
Configure via npmextra.json under the "@git.zone/tsdocker" key:
|
||||
|
||||
registries Array of registry URLs to push to
|
||||
registryRepoMap Map of registry URL to repo path overrides
|
||||
buildArgEnvMap Map of Docker build-arg names to env var names
|
||||
platforms Array of target platforms (default: ["linux/amd64"])
|
||||
push Boolean, auto-push after build
|
||||
testDir Directory containing test_*.sh scripts
|
||||
|
||||
EXAMPLES
|
||||
tsdocker build
|
||||
tsdocker build Dockerfile_app --platform=linux/arm64
|
||||
tsdocker push --registry=ghcr.io
|
||||
tsdocker test --verbose
|
||||
tsdocker clean -y --all
|
||||
`;
|
||||
console.log(manPage);
|
||||
};
|
||||
|
||||
export let run = () => {
|
||||
// Default command: run tests in container (legacy behavior)
|
||||
tsdockerCli.standardCommand().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);
|
||||
}
|
||||
// Default command: print man page
|
||||
tsdockerCli.standardCommand().subscribe(async () => {
|
||||
printManPage();
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -228,24 +280,6 @@ export let run = () => {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 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 => {
|
||||
try {
|
||||
const autoYes = !!argvArg.y;
|
||||
@@ -443,19 +477,5 @@ export let run = () => {
|
||||
}
|
||||
});
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user