Skip to content

Commit 286be25

Browse files
committed
style(cli-mcp): prettier
1 parent 3b45611 commit 286be25

2 files changed

Lines changed: 74 additions & 65 deletions

File tree

tools/cli/src/main.ts

Lines changed: 69 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,13 @@ const rootCommand = Command.make('ping-lf').pipe(
3434
Command.withDescription(
3535
'CLI for initializing, scaffolding, and updating Ping Login Widget and Login App custom component projects.',
3636
),
37-
Command.withSubcommands([initCommand, generateCommand, updateCommand, releasesCommand, mcpCommand]),
37+
Command.withSubcommands([
38+
initCommand,
39+
generateCommand,
40+
updateCommand,
41+
releasesCommand,
42+
mcpCommand,
43+
]),
3844
);
3945

4046
const cli = Command.run(rootCommand, {
@@ -43,66 +49,66 @@ const cli = Command.run(rootCommand, {
4349
});
4450

4551
cli(process.argv).pipe(
46-
Effect.catchTag('DirectoryConflictError', (err) =>
47-
Console.error(
48-
`\nError: "${err.path}" already contains a framework project.` +
49-
`\n Did you mean to use --local?\n` +
50-
`\n ping-lf init <new-directory> --local ${err.path}\n`,
51-
).pipe(Effect.andThen(Effect.die(err))),
52-
),
53-
Effect.catchTag('DirectoryNotEmptyError', (err) =>
54-
Console.error(
55-
`\nError: "${err.path}" already exists and is not empty.` +
56-
`\n Choose a different directory name, or delete the existing directory first.\n`,
57-
).pipe(Effect.andThen(Effect.die(err))),
58-
),
59-
Effect.catchTag('ReleaseNetworkError', (err) =>
60-
Console.error(
61-
`\nError: Could not reach GitHub to download the release.\n` +
62-
` ${err.cause}\n\n` +
63-
` • Check your network connection and try again.\n` +
64-
` • Use a local path: ping-lf init <dir> --local <path>\n` +
65-
` • Specify a version: ping-lf init <dir> --version v1.0.0\n`,
66-
).pipe(Effect.andThen(Effect.die(err))),
67-
),
68-
Effect.catchTag('ReleaseParseError', (err) =>
69-
Console.error(`\nError: Failed to parse the release data.\n ${err.cause}\n`).pipe(
70-
Effect.andThen(Effect.die(err)),
71-
),
72-
),
73-
Effect.catchTag('ReleaseFsError', (err) =>
74-
Console.error(
75-
`\nError: Filesystem error during release download (${err.operation}).\n ${err.cause}\n`,
76-
).pipe(Effect.andThen(Effect.die(err))),
77-
),
78-
Effect.catchTag('InvalidVersionError', (err) =>
79-
Console.error(
80-
`\nError: "${err.version}" is not a valid version tag.\n` +
81-
` Expected semver format like v1.0.0.\n` +
82-
` Use "ping-lf releases" to list available versions.\n`,
83-
).pipe(Effect.andThen(Effect.die(err))),
84-
),
85-
Effect.catchTag('ReleaseNotFoundError', (err) =>
86-
Console.error(
87-
`\nError: No releases found on GitHub.` +
88-
(err.cause ? `\n ${err.cause}` : '') +
89-
`\n\n • Check your network connection and try again.\n` +
90-
` • Use a local path: ping-lf init <dir> --local <path>\n`,
91-
).pipe(Effect.andThen(Effect.die(err))),
92-
),
93-
Effect.catchTag('InvalidComponentNameError', (err) =>
94-
Console.error(
95-
`\nError: "${err.name}" is not a valid component name.\n` +
96-
` Names must be PascalCase, start with an uppercase letter, and contain only letters and digits.\n` +
97-
` Examples: MyCallback, JWTLogin, DefaultStage\n`,
98-
).pipe(Effect.andThen(Effect.die(err))),
99-
),
100-
Effect.catchTag('ComponentAlreadyExistsError', (err) =>
101-
Console.error(
102-
`\nError: component directory already exists: ${err.path}\n` +
103-
` Choose a different name or delete the existing directory first.\n`,
104-
).pipe(Effect.andThen(Effect.die(err))),
52+
Effect.catchTag('DirectoryConflictError', (err) =>
53+
Console.error(
54+
`\nError: "${err.path}" already contains a framework project.` +
55+
`\n Did you mean to use --local?\n` +
56+
`\n ping-lf init <new-directory> --local ${err.path}\n`,
57+
).pipe(Effect.andThen(Effect.die(err))),
58+
),
59+
Effect.catchTag('DirectoryNotEmptyError', (err) =>
60+
Console.error(
61+
`\nError: "${err.path}" already exists and is not empty.` +
62+
`\n Choose a different directory name, or delete the existing directory first.\n`,
63+
).pipe(Effect.andThen(Effect.die(err))),
64+
),
65+
Effect.catchTag('ReleaseNetworkError', (err) =>
66+
Console.error(
67+
`\nError: Could not reach GitHub to download the release.\n` +
68+
` ${err.cause}\n\n` +
69+
` • Check your network connection and try again.\n` +
70+
` • Use a local path: ping-lf init <dir> --local <path>\n` +
71+
` • Specify a version: ping-lf init <dir> --version v1.0.0\n`,
72+
).pipe(Effect.andThen(Effect.die(err))),
73+
),
74+
Effect.catchTag('ReleaseParseError', (err) =>
75+
Console.error(`\nError: Failed to parse the release data.\n ${err.cause}\n`).pipe(
76+
Effect.andThen(Effect.die(err)),
10577
),
106-
Effect.provide(Layer.mergeAll(GithubReleaseLayer, NodeContext.layer)),
107-
(effect) => NodeRuntime.runMain(effect, { disableErrorReporting: true }),
108-
);
78+
),
79+
Effect.catchTag('ReleaseFsError', (err) =>
80+
Console.error(
81+
`\nError: Filesystem error during release download (${err.operation}).\n ${err.cause}\n`,
82+
).pipe(Effect.andThen(Effect.die(err))),
83+
),
84+
Effect.catchTag('InvalidVersionError', (err) =>
85+
Console.error(
86+
`\nError: "${err.version}" is not a valid version tag.\n` +
87+
` Expected semver format like v1.0.0.\n` +
88+
` Use "ping-lf releases" to list available versions.\n`,
89+
).pipe(Effect.andThen(Effect.die(err))),
90+
),
91+
Effect.catchTag('ReleaseNotFoundError', (err) =>
92+
Console.error(
93+
`\nError: No releases found on GitHub.` +
94+
(err.cause ? `\n ${err.cause}` : '') +
95+
`\n\n • Check your network connection and try again.\n` +
96+
` • Use a local path: ping-lf init <dir> --local <path>\n`,
97+
).pipe(Effect.andThen(Effect.die(err))),
98+
),
99+
Effect.catchTag('InvalidComponentNameError', (err) =>
100+
Console.error(
101+
`\nError: "${err.name}" is not a valid component name.\n` +
102+
` Names must be PascalCase, start with an uppercase letter, and contain only letters and digits.\n` +
103+
` Examples: MyCallback, JWTLogin, DefaultStage\n`,
104+
).pipe(Effect.andThen(Effect.die(err))),
105+
),
106+
Effect.catchTag('ComponentAlreadyExistsError', (err) =>
107+
Console.error(
108+
`\nError: component directory already exists: ${err.path}\n` +
109+
` Choose a different name or delete the existing directory first.\n`,
110+
).pipe(Effect.andThen(Effect.die(err))),
111+
),
112+
Effect.provide(Layer.mergeAll(GithubReleaseLayer, NodeContext.layer)),
113+
(effect) => NodeRuntime.runMain(effect, { disableErrorReporting: true }),
114+
);

tools/cli/src/mcp.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ function formatError(cause: Cause.Cause<unknown>): string {
5656
return `Component directory already exists: ${e['path']}`;
5757
default:
5858
try {
59-
return `Error: ${JSON.stringify(e, (_k, v) => (v instanceof Error ? { message: v.message, name: v.name } : v))}`;
59+
return `Error: ${JSON.stringify(e, (_k, v) =>
60+
v instanceof Error ? { message: v.message, name: v.name } : v,
61+
)}`;
6062
} catch {
6163
return `Error: ${String(e)}`;
6264
}
@@ -99,7 +101,8 @@ const InitTool = Tool.make('init', {
99101
.annotate(Tool.Idempotent, false);
100102

101103
const directoryParam = Schema.optional(Schema.String).annotations({
102-
description: 'Absolute path to the initialized project root. Defaults to the current working directory.',
104+
description:
105+
'Absolute path to the initialized project root. Defaults to the current working directory.',
103106
});
104107

105108
const GenerateCallbackTool = Tool.make('generate_callback', {

0 commit comments

Comments
 (0)