Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
refactor(cli): simplify atomic upgrade helpers
jkomyno committed
Aug 1, 2026 at 19:28 UTC
9b752b694df91d2ded58098d9c10260cf19958b7
3 files changed
+11
-12
ts/packages/cli/src/services/run-companion-modules.ts
+4
-3
@@ -340,9 +340,10 @@ export const resolveRunningCliReleaseTag = (
340
appVersion: string,
341
isReleaseBuild = IS_RELEASE_BUILD
342
): Effect.Effect<string, never, FileSystem.FileSystem | Path.Path> =>
343
- isReleaseBuild
344
- ? Effect.succeed(normalizeCliReleaseTag(appVersion))
345
- : resolveInstalledCliReleaseTag(execPath, appVersion);
343
+ Effect.map(
344
+ resolveRunningCliVersion(execPath, appVersion, isReleaseBuild),
345
+ normalizeCliReleaseTag
346
+ );
347
348
export const writeInstalledReleaseTag = (
349
installDir: string,
ts/packages/cli/src/utils/atomic-replace.ts
+1
-7
@@ -88,13 +88,7 @@ export const atomicReplaceDirectory = ({
88
yield* fs.rename(targetPath, asidePath);
89
yield* fs
90
.rename(stagedPath, targetPath)
91
- .pipe(
92
- Effect.catchAll(cause =>
93
- fs
94
- .rename(asidePath, targetPath)
95
- .pipe(Effect.ignore, Effect.zipRight(Effect.fail(cause)))
96
- )
97
- );
91
+ .pipe(Effect.tapError(() => fs.rename(asidePath, targetPath).pipe(Effect.ignore)));
92
yield* fs.remove(asidePath, { recursive: true });
93
})
94
);
ts/packages/cli/test/src/services/running-cli-version.test.ts
+6
-2
@@ -3,6 +3,7 @@ import { BunFileSystem, BunPath } from '@effect/platform-bun';
3
import { describe, expect, layer } from '@effect/vitest';
4
import { Effect, Layer } from 'effect';
5
import {
6
+ RUN_COMPANION_RELEASE_TAG_FILENAME,
7
resolveRunningCliReleaseTag,
8
resolveRunningCliVersion,
9
} from 'src/services/run-companion-modules';
@@ -19,7 +20,10 @@ describe('running CLI version authority', () => {
20
const execPath = path.join(installDirectory, 'composio');
21
22
for (const installedTag of ['@composio/cli@9.9.9', '@composio/cli@0.2.31']) {
22
- yield* fs.writeFileString(path.join(installDirectory, 'release-tag.txt'), installedTag);
23
+ yield* fs.writeFileString(
24
+ path.join(installDirectory, RUN_COMPANION_RELEASE_TAG_FILENAME),
25
+ installedTag
26
+ );
27
28
expect(yield* resolveRunningCliVersion(execPath, '0.3.0', true)).toBe('0.3.0');
29
expect(yield* resolveRunningCliReleaseTag(execPath, '0.3.0', true)).toBe(
@@ -49,7 +53,7 @@ describe('running CLI version authority', () => {
53
const path = yield* Path.Path;
54
const installDirectory = yield* fs.makeTempDirectoryScoped();
55
const execPath = path.join(installDirectory, 'composio');
52
- const releaseTagPath = path.join(installDirectory, 'release-tag.txt');
56
+ const releaseTagPath = path.join(installDirectory, RUN_COMPANION_RELEASE_TAG_FILENAME);
57
yield* fs.writeFileString(releaseTagPath, '@composio/cli@0.2.31');
58
59
expect(yield* resolveRunningCliVersion(execPath, '0.0.0-development', false)).toBe(