Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
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
7 changes: 4 additions & 3 deletions packages/cli/src/commands/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { getClient } from "#utils/client.ts";
import { defineCommand } from "citty";
import consola from "consola";

/**
* Parses a `key=value` field string. Values are auto-converted:
Expand Down Expand Up @@ -145,13 +144,15 @@ export default defineCommand({
}

if (!args.silent) {
consola.log(JSON.stringify(allResults, null, 2));
const json = process.stdout.isTTY ? JSON.stringify(allResults, null, 2) : JSON.stringify(allResults);
process.stdout.write(`${json}\n`);
}
} else {
const result = await client<unknown>(endpoint, fetchOptions);

if (!args.silent) {
consola.log(JSON.stringify(result, null, 2));
const json = process.stdout.isTTY ? JSON.stringify(result, null, 2) : JSON.stringify(result);
process.stdout.write(`${json}\n`);
}
}
},
Expand Down
30 changes: 17 additions & 13 deletions packages/cli/src/commands/space/activities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { SpacesGetActivitiesData } from "@repo/openapi-client";

import { getClient } from "#utils/client.ts";
import { formatDate, getActivityLabel, padEnd } from "#utils/format.ts";
import { outputArgs, outputResult } from "#utils/output.ts";
import { defineCommand } from "citty";
import consola from "consola";

Expand All @@ -12,6 +13,7 @@ export default defineCommand({
description: "Show space activities",
},
args: {
...outputArgs,
limit: {
type: "string",
alias: "L",
Expand All @@ -38,19 +40,21 @@ export default defineCommand({
query,
});

if (activities.length === 0) {
consola.info("No activities found.");
return;
}
outputResult(activities, args, (data) => {
if (data.length === 0) {
consola.info("No activities found.");
return;
}

const header = `${padEnd("ID", 12)}${padEnd("TYPE", 24)}${padEnd("DATE", 12)}PROJECT`;
consola.log(header);
for (const activity of activities) {
const id = padEnd(`${activity.id}`, 12);
const type = padEnd(getActivityLabel(activity.type), 24);
const date = padEnd(formatDate(activity.created), 12);
const project = activity.project.projectKey;
consola.log(`${id}${type}${date}${project}`);
}
const header = `${padEnd("ID", 12)}${padEnd("TYPE", 24)}${padEnd("DATE", 12)}PROJECT`;
consola.log(header);
for (const activity of data) {
const id = padEnd(`${activity.id}`, 12);
const type = padEnd(getActivityLabel(activity.type), 24);
const date = padEnd(formatDate(activity.created), 12);
const project = activity.project.projectKey;
consola.log(`${id}${type}${date}${project}`);
}
});
},
});
14 changes: 10 additions & 4 deletions packages/integration-tests/src/commands/config/get-set.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,30 @@ import { describe, expect, it } from "vitest";
import { expectSuccess } from "../../helpers/assertions.ts";
import { runCli } from "../../helpers/cli.ts";

// config get/set operates on global settings (not space-specific).
// BACKLOG_SPACE must be unset to avoid space-specific config lookup/rejection.
const envWithoutSpace = { BACKLOG_SPACE: "" };

describe("config get/set", () => {
it("設定値を取得する", async () => {
const result = await runCli(["config", "get", "default_space"]);
const result = await runCli(["config", "get", "default_space"], { env: envWithoutSpace });
// This may or may not have a value, but should not error
expectSuccess(result);
});

it("設定値を設定して取得できる", async () => {
// Set a test value
const result = await runCli(["config", "set", "default_space", "test-space.backlog.com"]);
const result = await runCli(["config", "set", "default_space", "test-space.backlog.com"], {
env: envWithoutSpace,
});
expectSuccess(result);

// Read it back
const getResult = await runCli(["config", "get", "default_space"]);
const getResult = await runCli(["config", "get", "default_space"], { env: envWithoutSpace });
expectSuccess(getResult);
expect(getResult.stdout).toContain("test-space.backlog.com");

// Reset - set to empty to clean up
await runCli(["config", "set", "default_space", ""]);
await runCli(["config", "set", "default_space", ""], { env: envWithoutSpace });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ describe("project activities", () => {
const { project } = getEnv();

it("プロジェクトの活動を表示する", async () => {
const result = await runCliWithRetry(["project", "activities", "-p", project]);
const result = await runCliWithRetry(["project", "activities", project]);
expectSuccess(result);
});

it("--json でプロジェクト活動を JSON 配列で出力する", async () => {
const result = await runCliWithRetry(["project", "activities", "-p", project, "--json"]);
const result = await runCliWithRetry(["project", "activities", project, "--json"]);
expectJsonArray(result);
});
});
4 changes: 2 additions & 2 deletions packages/integration-tests/src/commands/project/users.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ describe("project users", () => {
const { project } = getEnv();

it("プロジェクトメンバーを表示する", async () => {
const result = await runCliWithRetry(["project", "users", "-p", project]);
const result = await runCliWithRetry(["project", "users", project]);
expectSuccess(result);
});

it("--json でプロジェクトメンバーを JSON 配列で出力する", async () => {
const result = await runCliWithRetry(["project", "users", "-p", project, "--json"]);
const result = await runCliWithRetry(["project", "users", project, "--json"]);
expectJsonArray(result);
});
});
4 changes: 2 additions & 2 deletions packages/integration-tests/src/commands/repo/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ describe("repo list", () => {
const { project } = getEnv();

it("リポジトリ一覧を表示する", async () => {
const result = await runCliWithRetry(["repo", "list", "-p", project]);
const result = await runCliWithRetry(["repo", "list", project]);
expectSuccess(result);
});

it("--json でリポジトリ一覧を JSON 配列で出力する", async () => {
const result = await runCliWithRetry(["repo", "list", "-p", project, "--json"]);
const result = await runCliWithRetry(["repo", "list", project, "--json"]);
expectJsonArray(result);
});
});
6 changes: 1 addition & 5 deletions packages/integration-tests/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export default defineConfig({
concurrent: false,
},
pool: "forks",
poolOptions: {
forks: {
singleFork: true,
},
},
fileParallelism: false,
},
});
Loading