Skip to content

Commit

Permalink
fixes rune cli
Browse files Browse the repository at this point in the history
  • Loading branch information
0xF6 committed Aug 17, 2024
1 parent 7029d63 commit 67163fe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/projectsystem/Workload.converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist

public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var packages = (Dictionary<PackageKey, WorkloadPackage>)value;
var packages = (Dictionary<PackageKey, T>)value;
writer.WriteStartObject();

foreach (var kvp in packages)
Expand Down
13 changes: 5 additions & 8 deletions metadata/scripts/install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ $arch = if ([System.Environment]::Is64BitOperatingSystem) { "win-x64" } else { "
$apiUrl = "https://releases.vein-lang.org/api/get-release"

$outputDir = "$HOME\.vein"
$binDir = "$outputDir\bin"

function DownloadFile($url, $outputFile) {
$webClient = New-Object System.Net.WebClient
Expand All @@ -14,19 +13,17 @@ try {
$releaseInfo = Invoke-RestMethod -Uri $apiUrl
$asset = $releaseInfo.assets | Where-Object { $_.name -eq "rune.$arch.zip" }
$downloadUrl = $asset.browser_download_url
Write-Output $downloadUrl
New-Item -ItemType Directory -Force -Path $outputDir > $null
New-Item -ItemType Directory -Force -Path $binDir > $null
$zipFile = "$outputDir\rune.$arch.zip"
DownloadFile $downloadUrl $zipFile
Expand-Archive -Path $zipFile -DestinationPath $binDir -Force > $null
Expand-Archive -Path $zipFile -DestinationPath $outputDir -Force > $null
Remove-Item -Force $zipFile > $null
$env:Path += ";$binDir"
$env:Path += ";$outputDir"
[Environment]::SetEnvironmentVariable("Path", $env:Path, [EnvironmentVariableTarget]::User)

& "$binDir\rune.exe" install workload vein.runtime --version latest
& "$binDir\rune.exe" install workload vein.compiler --version latest


Invoke-Expression "$outputDir\rune.exe workload install vein.runtime"
Invoke-Expression "$outputDir\rune.exe workload install vein.compiler"
Write-Output "Rune Installed, restart your teminal for use"
}
catch {
Expand Down
4 changes: 2 additions & 2 deletions metadata/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if [ -f "$HOME/.zshrc" ]; then
source "$HOME/.zshrc"
fi

"$BIN_DIR/rune" install workload vein.runtime --version latest
"$BIN_DIR/rune" install workload vein.compiler --version latest
"$BIN_DIR/rune" workload install vein.runtime
"$BIN_DIR/rune" workload install vein.compiler

echo "Installation complete. Please restart your terminal to use the new PATH."
10 changes: 5 additions & 5 deletions tools/rune-cli/WorkloadDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public class WorkloadDb
public async Task RegistryTool(PackageKey key, WorkloadPackageTool tool, DirectoryInfo baseFolder)
{
var db = await OpenAsync();
db.tools.TryAdd(key, new Dictionary<string, FileInfo>());
db.tools.TryAdd(key, new Dictionary<string, string>());


var file = new FileInfo(Symlink.ToExec(tool.ExecPath));
var toolExec = baseFolder.Combine(file);
var name = string.IsNullOrEmpty(tool.OverrideName)
? Path.GetFileNameWithoutExtension(file.Name)
: tool.OverrideName;
db.tools[key][name] = toolExec;
db.tools[key][name] = toolExec.FullName;
await SaveAsync(db);
}

Expand All @@ -40,7 +40,7 @@ public async Task RegistrySdkAsync(string sdkTarget, string alias, DirectoryInfo
if (db.tools.TryGetValue(key, out var tools))
{
if (tools.TryGetValue(name, out var result))
return result;
return new FileInfo(result);
}
if (throwIfNotFound)
throw new NotFoundToolException(name, key);
Expand All @@ -66,7 +66,7 @@ private async Task SaveAsync(WorkloadDatabase db)

public record WorkloadDatabase
{
[JsonConverter(typeof(DictionaryWithPackageKeyConverter<Dictionary<string, FileInfo>>))]
public Dictionary<PackageKey, Dictionary<string, FileInfo>> tools = new();
[JsonConverter(typeof(DictionaryWithPackageKeyConverter<Dictionary<string, string>>))]
public Dictionary<PackageKey, Dictionary<string, string>> tools = new();
public Dictionary<string, List<string>> sdks = new();
}

0 comments on commit 67163fe

Please sign in to comment.