Skip to content

Commit 06a1e18

Browse files
committed
Update version 38
1 parent 9e2a948 commit 06a1e18

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>1.0.37</Version>
3+
<Version>1.0.38</Version>
44
<AssemblyVersion>$(Version).0</AssemblyVersion>
55
<FileVersion>$(Version).0</FileVersion>
66
<InformationalVersion>$(Version)</InformationalVersion>

src/QuickCode.Cli/CliApplication.cs

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,23 @@ private static async Task HandleWithExceptionCatchingAsync(Func<Task> action)
4242
}
4343
}
4444

45-
public Task<int> RunAsync(string[] args)
45+
public async Task<int> RunAsync(string[] args)
4646
{
4747
var root = BuildRootCommand();
4848

4949
// Check for version update in background (non-blocking)
50-
_ = CheckVersionUpdateAsync();
50+
// Use Task.Run to ensure it runs on thread pool and doesn't block
51+
var versionCheckTask = Task.Run(async () =>
52+
{
53+
try
54+
{
55+
await CheckVersionUpdateAsync();
56+
}
57+
catch
58+
{
59+
// Silently ignore any errors in version check
60+
}
61+
});
5162

5263
// Handle "quickcode <project> pull/push" format by rearranging args
5364
if (args.Length >= 2)
@@ -64,11 +75,18 @@ public Task<int> RunAsync(string[] args)
6475
rearrangedArgs[0] = secondArg;
6576
rearrangedArgs[1] = firstArg;
6677
Array.Copy(args, 2, rearrangedArgs, 2, args.Length - 2);
67-
return root.InvokeAsync(rearrangedArgs);
78+
var result = await root.InvokeAsync(rearrangedArgs);
79+
// Wait a bit for version check to complete if it's still running
80+
await Task.WhenAny(versionCheckTask, Task.Delay(2000));
81+
return result;
6882
}
6983
}
7084

71-
return root.InvokeAsync(args);
85+
var resultCode = await root.InvokeAsync(args);
86+
// Wait a bit for version check to complete if it's still running
87+
// This ensures the version message is shown even for fast commands
88+
await Task.WhenAny(versionCheckTask, Task.Delay(2000));
89+
return resultCode;
7290
}
7391

7492
private async Task CheckVersionUpdateAsync()
@@ -84,8 +102,11 @@ private async Task CheckVersionUpdateAsync()
84102
// Remove any suffix like "+build" from version
85103
currentVersion = currentVersion.Split('+')[0].Split('-')[0];
86104

87-
// Fetch latest version from homebrew formula with short timeout
88-
using var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(3) };
105+
// Small delay to ensure console is ready
106+
await Task.Delay(100);
107+
108+
// Fetch latest version from homebrew formula with longer timeout
109+
using var httpClient = new HttpClient { Timeout = TimeSpan.FromSeconds(5) };
89110
var formulaContent = await httpClient.GetStringAsync(HomebrewFormulaUri);
90111

91112
// Parse version from formula (look for "version \"X.X.X\"")
@@ -97,11 +118,16 @@ private async Task CheckVersionUpdateAsync()
97118
if (!versionMatch.Success)
98119
return;
99120

100-
var latestVersion = versionMatch.Groups[1].Value;
121+
var latestVersion = versionMatch.Groups[1].Value.Trim();
101122

102123
// Compare versions
103-
if (CompareVersions(currentVersion, latestVersion) < 0)
124+
var comparison = CompareVersions(currentVersion, latestVersion);
125+
if (comparison < 0)
104126
{
127+
// Ensure we're on a new line before printing
128+
if (Console.CursorLeft > 0)
129+
Console.WriteLine();
130+
105131
Console.ForegroundColor = ConsoleColor.Yellow;
106132
Console.WriteLine($"⚠️ A new version is available: {latestVersion} (current: {currentVersion})");
107133
Console.WriteLine($" Update with: brew upgrade quickcode-cli");

0 commit comments

Comments
 (0)