Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/runtimes-installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ func downloadAndExtractRuntime(runtimeInfo *plugins.RuntimeInfo) error {

if strings.HasSuffix(fileName, ".zip") {
err = utils.ExtractZip(file.Name(), runtimesDir)
} else if strings.HasSuffix(fileName, ".tar.xz") || strings.HasSuffix(fileName, ".txz") {
err = utils.ExtractTarXz(file, runtimesDir)
} else {
err = utils.ExtractTarGz(file, runtimesDir)
}

if err != nil {
return fmt.Errorf("failed to extract runtime: %w", err)
}
Expand Down
18 changes: 14 additions & 4 deletions plugins/runtime-utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ func TestProcessRuntimes(t *testing.T) {
Name: "node",
Version: "18.17.1",
},
{
Name: "flutter",
Version: "3.35.7",
},
}

// Define a test runtime directory
Expand All @@ -27,9 +31,15 @@ func TestProcessRuntimes(t *testing.T) {

// Assert we have the expected runtime in the results
assert.Contains(t, runtimeInfos, "node")
assert.Contains(t, runtimeInfos, "flutter")

// Get the node runtime info
nodeInfo := runtimeInfos["node"]
flutterInfo := runtimeInfos["flutter"]

// Basic assertions for flutter
assert.Equal(t, "flutter", flutterInfo.Name)
assert.Equal(t, "3.35.7", flutterInfo.Version)
Comment on lines +40 to +42

Copilot AI Jan 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test coverage for Flutter is minimal compared to the Node test. Consider adding assertions to verify the download URL is correctly formatted, the extension is properly set based on the OS (tar.xz for Linux, zip for others), and the install directory is correct. This would help ensure the Flutter-specific configuration changes (linux extension support and removed architecture from URL) work as expected.

Copilot uses AI. Check for mistakes.

// Assert the basic runtime info is correct
assert.Equal(t, "node", nodeInfo.Name)
Expand Down Expand Up @@ -69,21 +79,21 @@ func TestProcessRuntimes(t *testing.T) {
// Assert the download URL is correctly formatted
expectedDownloadURL := "https://nodejs.org/dist/v18.17.1/" + expectedFileName + "." + expectedExtension
assert.Equal(t, expectedDownloadURL, nodeInfo.DownloadURL)

// Assert binary paths are correctly set
assert.NotNil(t, nodeInfo.Binaries)
assert.Greater(t, len(nodeInfo.Binaries), 0)

// Check if node and npm binaries are present
nodeBinary := nodeInfo.InstallDir + "/bin/node"
npmBinary := nodeInfo.InstallDir + "/bin/npm"

// Add .exe extension for Windows
if runtime.GOOS == "windows" {
nodeBinary += ".exe"
npmBinary += ".exe"
}

assert.Equal(t, nodeBinary, nodeInfo.Binaries["node"])
assert.Equal(t, npmBinary, nodeInfo.Binaries["npm"])
}
8 changes: 4 additions & 4 deletions plugins/runtimes/flutter/plugin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: flutter
description: Dart Flutterruntime

Copilot AI Jan 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a spelling error in the description. 'Flutterruntime' should be 'Flutter runtime' (with a space).

Copilot uses AI. Check for mistakes.
default_version: "3.7.2"
download:
url_template: "https://storage.googleapis.com/flutter_infra_release/releases/stable/{{.OS}}/flutter_{{.OS}}_{{.Arch}}_{{.Version}}-stable.{{.Extension}}"
url_template: "https://storage.googleapis.com/flutter_infra_release/releases/stable/{{.OS}}/flutter_{{.OS}}_{{.Version}}-stable.{{.Extension}}"
file_name_template: "flutter"
extension:
default: "zip"
linux: "tar.xz"
default: "zip"
arch_mapping:
"386": "ia32"
"amd64": "x64"
"386": ""
"amd64": ""
"arm": "arm"
"arm64": "arm64"
os_mapping:
Expand Down
4 changes: 4 additions & 0 deletions plugins/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

// ExtensionConfig defines the file extension based on OS
type ExtensionConfig struct {
Linux string `yaml:"linux"`
Windows string `yaml:"windows"`
Default string `yaml:"default"`
}
Expand Down Expand Up @@ -80,6 +81,9 @@ func GetExtension(extension ExtensionConfig, goos string) string {
if goos == "windows" {
return extension.Windows
}
if goos == "linux" && extension.Linux != "" {
return extension.Linux
}
return extension.Default
}

Expand Down
10 changes: 9 additions & 1 deletion utils/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@
)

func ExtractTarGz(archive *os.File, targetDir string) error {
return ExtractTar(archive, targetDir, archiver.Gz{})
}

func ExtractTarXz(archive *os.File, targetDir string) error {

Check notice on line 20 in utils/extract.go

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

utils/extract.go#L20

exported function ExtractTarXz should have comment or be unexported

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return ExtractTar(archive, targetDir, archiver.Xz{})
}

func ExtractTar(archive *os.File, targetDir string, compression archiver.Compression) error {

Check notice on line 24 in utils/extract.go

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

utils/extract.go#L24

exported function ExtractTar should have comment or be unexported

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format := archiver.CompressedArchive{
Compression: archiver.Gz{},
Compression: compression,
Archival: archiver.Tar{},
}

Expand Down
Loading