Skip to content

Commit

Permalink
Merge pull request #1315 from polywrap/pileks/chore-fixup-cli-logging…
Browse files Browse the repository at this point in the history
…-refactor

Chore: cli logging refactor cleanup
  • Loading branch information
dOrgJelli authored Oct 11, 2022
2 parents e747961 + 61dd785 commit e98546f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
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

0 comments on commit e98546f

Please sign in to comment.