Skip to content

Commit 8a2503e

Browse files
committed
chore: lint
1 parent 8e4ec55 commit 8a2503e

17 files changed

Lines changed: 77 additions & 94 deletions

File tree

packages/hydra/src/cli.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { AbstractCLI, ConfigManager } from "@r5n/cli-core";
22
import { version } from "../package.json";
3-
import { CreateCommand, InitCommand, ProfileCommand, RemoveCommand, StartCommand, StatusCommand, StopCommand } from "./commands";
3+
import {
4+
CreateCommand,
5+
InitCommand,
6+
ProfileCommand,
7+
RemoveCommand,
8+
StartCommand,
9+
StatusCommand,
10+
StopCommand,
11+
} from "./commands";
412
import { CLI_BIN, DEFAULT_CONFIG, HYDRA_CONFIG_FILE } from "./constants";
513
import type { HydraConfig } from "./types";
614

packages/hydra/src/commands/create.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { join } from "node:path";
2-
import { Exit, color, log, positionals, spinner, text } from "@r5n/cli-core";
2+
import { color, Exit, log, positionals, spinner, text } from "@r5n/cli-core";
33
import { BaseCommand, type Ctx } from "../base-command";
44
import { createProvider } from "../providers";
55
import type { RunnerEntry } from "../types";
@@ -24,7 +24,9 @@ export class CreateCommand extends BaseCommand {
2424

2525
const count = ctx.interactive
2626
? await this.promptCount(profile.numberOfMachines)
27-
: (ctx.positionals.count ? Number.parseInt(ctx.positionals.count, 10) : profile.numberOfMachines);
27+
: ctx.positionals.count
28+
? Number.parseInt(ctx.positionals.count, 10)
29+
: profile.numberOfMachines;
2830

2931
if (!count || count < 1) {
3032
throw new Exit("Runner count must be at least 1");
@@ -73,7 +75,9 @@ export class CreateCommand extends BaseCommand {
7375

7476
const isDefault = profileName === ctx.config.get("defaultProfile");
7577
const profileSuffix = isDefault ? "" : ` ${profileName}`;
76-
log.info(`${color.green("Created")} ${toCreate} runner(s) for "${profileName}". Run ${color.green(`hydra start${profileSuffix}`)} to start them.`);
78+
log.info(
79+
`${color.green("Created")} ${toCreate} runner(s) for "${profileName}". Run ${color.green(`hydra start${profileSuffix}`)} to start them.`,
80+
);
7781
}
7882

7983
private async promptCount(defaultCount: number): Promise<number> {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export { CreateCommand } from "./create";
22
export { InitCommand } from "./init";
3-
export { StatusCommand } from "./status";
43
export { ProfileCommand } from "./profile";
54
export { RemoveCommand } from "./remove";
65
export { StartCommand } from "./start";
6+
export { StatusCommand } from "./status";
77
export { StopCommand } from "./stop";

packages/hydra/src/commands/init.ts

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { existsSync } from "node:fs";
22
import { mkdir } from "node:fs/promises";
3-
import { Cancel, Exit, args, color, confirm, group, note, positionals, text } from "@r5n/cli-core";
3+
import { args, Cancel, color, confirm, Exit, group, note, positionals, text } from "@r5n/cli-core";
44
import { BaseCommand, type Ctx } from "../base-command";
55
import { CLI_BIN, DEFAULT_PROFILE, RUNNERS_DIR, SHARED_DIR } from "../constants";
66
import type { Profile } from "../types";
77

8-
const initPositionals = positionals({
9-
url: { description: "GitHub repository or organization URL" },
10-
});
8+
const initPositionals = positionals({ url: { description: "GitHub repository or organization URL" } });
119

1210
const initArgs = args({
1311
force: { alias: "f", default: false, description: "Overwrite existing config", type: "boolean" },
@@ -27,9 +25,7 @@ export class InitCommand extends BaseCommand {
2725
prompts = true;
2826

2927
async execute(ctx: InitCtx) {
30-
const profileName = ctx.interactive
31-
? await this.promptProfileName(ctx)
32-
: (ctx.args.profile ?? DEFAULT_PROFILE);
28+
const profileName = ctx.interactive ? await this.promptProfileName(ctx) : (ctx.args.profile ?? DEFAULT_PROFILE);
3329

3430
const isNewInit = !ctx.config.exists();
3531

@@ -38,7 +34,10 @@ export class InitCommand extends BaseCommand {
3834
if (!ctx.interactive) {
3935
throw new Exit(`Profile "${profileName}" already exists. Use --force to overwrite.`);
4036
}
41-
const overwrite = await confirm({ initialValue: false, message: `Profile "${profileName}" already exists. Overwrite?` });
37+
const overwrite = await confirm({
38+
initialValue: false,
39+
message: `Profile "${profileName}" already exists. Overwrite?`,
40+
});
4241
if (!overwrite) return;
4342
}
4443

@@ -70,10 +69,7 @@ export class InitCommand extends BaseCommand {
7069
}
7170

7271
private async promptProfileName(ctx: InitCtx): Promise<string> {
73-
return text({
74-
initialValue: ctx.args.profile ?? DEFAULT_PROFILE,
75-
message: "Profile name",
76-
});
72+
return text({ initialValue: ctx.args.profile ?? DEFAULT_PROFILE, message: "Profile name" });
7773
}
7874

7975
private async ensureDirectories() {
@@ -102,12 +98,7 @@ export class InitCommand extends BaseCommand {
10298
return undefined;
10399
},
104100
}),
105-
name: () =>
106-
text({
107-
initialValue: "runner",
108-
message: "Base name for runners",
109-
placeholder: "runner",
110-
}),
101+
name: () => text({ initialValue: "runner", message: "Base name for runners", placeholder: "runner" }),
111102
runners: () =>
112103
text({
113104
initialValue: "1",
@@ -121,12 +112,13 @@ export class InitCommand extends BaseCommand {
121112
},
122113
}),
123114
labels: () =>
124-
text({
125-
message: "Additional labels (comma-separated, optional)",
126-
placeholder: "self-hosted,macOS,ARM64",
127-
}),
115+
text({ message: "Additional labels (comma-separated, optional)", placeholder: "self-hosted,macOS,ARM64" }),
116+
},
117+
{
118+
onCancel: () => {
119+
throw new Cancel();
120+
},
128121
},
129-
{ onCancel: () => { throw new Cancel(); } },
130122
);
131123

132124
return {

packages/hydra/src/commands/profile/default.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import { Exit, color, log, positionals } from "@r5n/cli-core";
1+
import { color, Exit, log, positionals } from "@r5n/cli-core";
22
import { BaseCommand, type Ctx } from "../../base-command";
33
import { resolveProfile, selectProfile } from "../../utils";
44

5-
const defaultPositionals = positionals({
6-
name: { description: "Profile name to set as default" },
7-
});
5+
const defaultPositionals = positionals({ name: { description: "Profile name to set as default" } });
86

97
type DefaultCtx = Ctx<Record<string, never>, typeof defaultPositionals>;
108

@@ -14,9 +12,7 @@ export class ProfileDefaultCommand extends BaseCommand {
1412
positionals = defaultPositionals;
1513

1614
async execute(ctx: DefaultCtx) {
17-
const profileName = ctx.interactive
18-
? await selectProfile(ctx.config)
19-
: ctx.positionals.name;
15+
const profileName = ctx.interactive ? await selectProfile(ctx.config) : ctx.positionals.name;
2016

2117
if (!profileName) {
2218
throw new Exit("Profile name is required", "Usage: hydra profile default <name>");

packages/hydra/src/commands/profile/list.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Exit, color, log, note } from "@r5n/cli-core";
1+
import { color, Exit, log, note } from "@r5n/cli-core";
22
import { BaseCommand, type Ctx } from "../../base-command";
33
import { createProvider } from "../../providers";
44
import type { Profile } from "../../types";

packages/hydra/src/commands/profile/remove.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import { rm } from "node:fs/promises";
22
import { join } from "node:path";
3-
import { Exit, color, confirm, log, positionals, spinner } from "@r5n/cli-core";
3+
import { color, confirm, Exit, log, positionals, spinner } from "@r5n/cli-core";
44
import { BaseCommand, type Ctx } from "../../base-command";
55
import { createProvider } from "../../providers";
66
import type { Profile } from "../../types";
77
import { resolveProfile, selectProfile } from "../../utils";
88

9-
const removePositionals = positionals({
10-
name: { description: "Profile name to remove" },
11-
});
9+
const removePositionals = positionals({ name: { description: "Profile name to remove" } });
1210

1311
type RemoveCtx = Ctx<Record<string, never>, typeof removePositionals>;
1412

@@ -18,9 +16,7 @@ export class ProfileRemoveCommand extends BaseCommand {
1816
positionals = removePositionals;
1917

2018
async execute(ctx: RemoveCtx) {
21-
const profileName = ctx.interactive
22-
? await selectProfile(ctx.config)
23-
: ctx.positionals.name;
19+
const profileName = ctx.interactive ? await selectProfile(ctx.config) : ctx.positionals.name;
2420

2521
if (!profileName) {
2622
throw new Exit("Profile name is required", "Usage: hydra profile remove <name>");
@@ -38,7 +34,10 @@ export class ProfileRemoveCommand extends BaseCommand {
3834
});
3935
if (!proceed) return;
4036

41-
await this.removeRunners(profile, profileRunners.map((e) => e.id));
37+
await this.removeRunners(
38+
profile,
39+
profileRunners.map((e) => e.id),
40+
);
4241
const remainingEntries = entries.filter((e) => e.profile !== profileName);
4342
ctx.config.set("runners", remainingEntries);
4443
}

packages/hydra/src/commands/remove.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { rm } from "node:fs/promises";
22
import { join } from "node:path";
3-
import { Exit, color, log, multiselect, positionals, spinner } from "@r5n/cli-core";
3+
import { color, Exit, log, multiselect, positionals, spinner } from "@r5n/cli-core";
44
import { BaseCommand, type Ctx } from "../base-command";
55
import { createProvider } from "../providers";
66
import { resolveProfile, resolveRunnerIds, selectProfile } from "../utils";
@@ -30,7 +30,10 @@ export class RemoveCommand extends BaseCommand {
3030

3131
const ids = ctx.interactive
3232
? await this.promptRunnerSelection(profileEntries.map((e) => e.id))
33-
: resolveRunnerIds(ctx.positionals.ids ?? [], profileEntries.map((e) => e.id));
33+
: resolveRunnerIds(
34+
ctx.positionals.ids ?? [],
35+
profileEntries.map((e) => e.id),
36+
);
3437

3538
const provider = createProvider(profile);
3639
const s = spinner();

packages/hydra/src/commands/start.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Exit, color, log, multiselect, positionals, spinner } from "@r5n/cli-core";
1+
import { color, Exit, log, multiselect, positionals, spinner } from "@r5n/cli-core";
22
import { BaseCommand, type Ctx } from "../base-command";
33
import { createProvider } from "../providers";
44
import { resolveProfile, resolveRunnerIds, selectProfile } from "../utils";
@@ -39,7 +39,10 @@ export class StartCommand extends BaseCommand {
3939

4040
const ids = ctx.interactive
4141
? await this.promptRunnerSelection(stoppedIds)
42-
: resolveRunnerIds(ctx.positionals.ids ?? [], profileEntries.map((e) => e.id));
42+
: resolveRunnerIds(
43+
ctx.positionals.ids ?? [],
44+
profileEntries.map((e) => e.id),
45+
);
4346

4447
let started = 0;
4548
for (const id of ids) {

packages/hydra/src/commands/status.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Exit, color, log } from "@r5n/cli-core";
1+
import { color, Exit, log } from "@r5n/cli-core";
22
import { BaseCommand, type Ctx } from "../base-command";
3-
import { createProvider } from "../providers";
43
import type { RunnerInfo } from "../providers";
4+
import { createProvider } from "../providers";
55
import type { Profile } from "../types";
66

77
type ListCtx = Ctx;

0 commit comments

Comments
 (0)