Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 03:15 UTC
refactor(cli): extract shared handleTsGenerate to eliminate handler duplication
The shouldCompile logic was duplicated between generate-ts.cmd.ts and tsCmd$Generate. Extract into a shared handleTsGenerate function to ensure the two command paths cannot silently diverge.
jkomyno committed
Mar 17, 2026 at 15:59 UTC
c3a5605644aa9a4f1421047c88bdd11b96868fd5
2 files changed
+17
-24
ts/packages/cli/src/commands/generate/generate-ts.cmd.ts
+2
-10
@@ -1,12 +1,11 @@
1
import { Command } from '@effect/cli';
2
-import { Option } from 'effect';
2
import {
4
- generateTypescriptTypeStubs,
3
outputOpt,
4
compact,
5
transpiled,
6
typeTools,
7
toolkitsOpt,
8
+ handleTsGenerate,
9
} from '../ts/commands/ts.generate.cmd';
10
11
/**
@@ -20,12 +19,5 @@ export const generateCmd$Ts = Command.make('ts', {
19
toolkitsOpt,
20
}).pipe(
21
Command.withDescription('Generate TypeScript type stubs for toolkits, tools, and triggers.'),
23
- Command.withHandler(params => {
24
- const shouldCompile = params.transpiled || !Option.isSome(params.outputOpt);
25
- return generateTypescriptTypeStubs({
26
- ...params,
27
- compact: params.compact,
28
- transpiled: shouldCompile,
29
- });
30
- })
22
+ Command.withHandler(handleTsGenerate)
23
);
ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts
+15
-14
@@ -332,20 +332,21 @@ function validateOutputDir(outputDir: string): Effect.Effect<string, Error, File
332
});
333
}
334
335
-export const tsCmd$Generate = _tsCmd$Generate.pipe(
336
- Command.withHandler(params => {
337
- // Determine if we should compile based on the rules:
338
- // - If --output-dir is specified, default transpiled to false unless overridden
339
- // - If no --output-dir, default transpiled to true unless overridden
340
- const shouldCompile = params.transpiled || !Option.isSome(params.outputOpt);
341
-
342
- return generateTypescriptTypeStubs({
343
- ...params,
344
- compact: params.compact,
345
- transpiled: shouldCompile,
346
- });
347
- })
348
-);
335
+/**
336
+ * Shared handler for TypeScript generation commands.
337
+ * Resolves the `transpiled` default based on whether `--output-dir` was provided.
338
+ */
339
+export const handleTsGenerate = (params: GetCmdParams<typeof _tsCmd$Generate>) => {
340
+ // Determine if we should compile based on the rules:
341
+ // - If --output-dir is specified, default transpiled to false unless overridden
342
+ // - If no --output-dir, default transpiled to true unless overridden
343
+ const shouldCompile = params.transpiled || !Option.isSome(params.outputOpt);
344
+
345
+ return generateTypescriptTypeStubs({
346
+ ...params,
347
+ transpiled: shouldCompile,
348
+ });
349
+};
350
351
export function generateTypescriptTypeStubs({
352
outputOpt,