Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: cli logging refactor cleanup #1315

Merged
merged 3 commits into from
Oct 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class DockerImageBuildStrategy extends BuildStrategy<BuildImageId> {
intlMsg.lib_helpers_docker_copyText(args),
intlMsg.lib_helpers_docker_copyError(args),
intlMsg.lib_helpers_docker_copyWarning(args),
async (_spinner) => {
async () => {
return await run();
}
);
Expand Down Expand Up @@ -306,7 +306,7 @@ export class DockerImageBuildStrategy extends BuildStrategy<BuildImageId> {
intlMsg.lib_helpers_docker_buildText(args),
intlMsg.lib_helpers_docker_buildError(args),
intlMsg.lib_helpers_docker_buildWarning(args),
async (_spinner) => {
async () => {
return await run();
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,8 @@ export class LocalBuildStrategy extends BuildStrategy<void> {
intlMsg.lib_helpers_buildText(),
intlMsg.lib_helpers_buildError(),
intlMsg.lib_helpers_buildWarning(),
async (_spinner) => {
return await runCommand(
command,
this.project.logger,
undefined,
process.cwd()
);
async (logger) => {
return await runCommand(command, logger, undefined, process.cwd());
}
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/infra/Infra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class Infra {
"./docker-compose.yaml",
];

private _dockerCompose = new DockerCompose();
private _dockerCompose = new DockerCompose(this._config.logger);
private _defaultDockerOptions: ReturnType<
typeof DockerCompose.getDefaultConfig
>;
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/lib/system/DockerCompose.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Logger } from "../logging";
import { getDockerFileLock } from "./docker";
import { FileLock } from "./file-lock";

import path from "path";
import Commands, { IDockerComposeOptions } from "docker-compose";
import { InfraManifest } from "@polywrap/polywrap-manifest-types-js";

export class DockerCompose {
private _dockerLock = getDockerFileLock(new Logger({}));
private _dockerLock: FileLock;
public commands: typeof Commands;

constructor() {
constructor(logger: Logger) {
this.commands = Object.fromEntries(
Object.entries(Commands).map(([name, func]) => [
name,
this._wrapInDockerLock(func),
])
) as typeof Commands;
this._dockerLock = getDockerFileLock(logger);
}

static getDefaultConfig(
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/system/docker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function ensureDockerDaemonRunning(logger: Logger): Promise<void> {

export function getDockerFileLock(logger: Logger): FileLock {
return new FileLock(__dirname + "/DOCKER_LOCK", (message: string) =>
logger.info(message)
logger.error(message)
);
}

Expand Down