From e54f2f549e73a5c29f6df9549d9893bd20b19fea Mon Sep 17 00:00:00 2001 From: Max N Date: Tue, 13 Oct 2026 20:29:18 -0400 Subject: [PATCH 1/2] fix(cli): print correct init output path --- cli/src/modules/init/output.ts | 6 +++-- cli/test/modules/init/output.test.ts | 39 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 cli/test/modules/init/output.test.ts diff --git a/cli/src/modules/init/output.ts b/cli/src/modules/init/output.ts index 2257578d..f0558193 100644 --- a/cli/src/modules/init/output.ts +++ b/cli/src/modules/init/output.ts @@ -1,3 +1,4 @@ +import path from "node:path"; import { ComposeContext } from "../../context/types"; import { cyan, dim, green, yellow } from "../../utils/terminal"; import { COMPOSE_HEADER, COMPOSE_DOCS_URL } from "../../utils/metadata"; @@ -43,8 +44,9 @@ export function showSuccess(ctx: ComposeContext): void { console.log(green("Next steps:")); let stepCount = 1; - if (projectRoot !== process.cwd()) { - console.log(green(`${stepCount}.`) + ` cd ${projectName}`); + const projectPath = path.relative(process.cwd(), projectRoot); + if (projectPath) { + console.log(green(`${stepCount}.`) + ` cd "${projectPath}"`); stepCount++; } diff --git a/cli/test/modules/init/output.test.ts b/cli/test/modules/init/output.test.ts new file mode 100644 index 00000000..0c895ca2 --- /dev/null +++ b/cli/test/modules/init/output.test.ts @@ -0,0 +1,39 @@ +import path from "node:path"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import { Context } from "../../../src/context/context"; +import { showSuccess } from "../../../src/modules/init/output"; + +describe("init success output", () => { + afterEach(() => { + vi.restoreAllMocks(); + }); + + it("prints the path relative to the current directory when --out is elsewhere", () => { + const projectRoot = path.resolve(process.cwd(), "..", "generated-projects", "my-diamond"); + const ctx = Context.create(); + ctx.param = { + projectName: "my-diamond", + projectRoot, + framework: "foundry", + }; + const log = vi.spyOn(console, "log").mockImplementation(() => undefined); + + showSuccess(ctx); + + expect(log.mock.calls.flat().join("\n")).toContain('cd "../generated-projects/my-diamond"'); + }); + + it("omits the directory change when already in the project directory", () => { + const ctx = Context.create(); + ctx.param = { + projectName: "my-diamond", + projectRoot: process.cwd(), + framework: "foundry", + }; + const log = vi.spyOn(console, "log").mockImplementation(() => undefined); + + showSuccess(ctx); + + expect(log.mock.calls.flat().join("\n")).not.toContain("cd "); + }); +}); From b66b2e5dda3926608aae8e6692d6f846d71965dd Mon Sep 17 00:00:00 2001 From: "M.N" <36768771+maxnorm@users.noreply.github.com> Date: Tue, 13 Oct 2026 20:31:20 -0400 Subject: [PATCH 2/2] Fix CLI init output path in changeset --- .changeset/modern-pumas-cheer.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/modern-pumas-cheer.md diff --git a/.changeset/modern-pumas-cheer.md b/.changeset/modern-pumas-cheer.md new file mode 100644 index 00000000..e5713b1c --- /dev/null +++ b/.changeset/modern-pumas-cheer.md @@ -0,0 +1,5 @@ +--- +"@perfect-abstractions/compose-cli": patch +--- + +fix(cli): print correct init output path