mirror of
https://github.com/luxfi/cli.git
synced 2026-10-30 17:01:20 +00:00
Deep audit changes: - Replace stub signature aggregator with real SDK warp implementation - Remove dead pkg/lpm package (SDK lpmintegration used instead) - Fix fs imports: use local utils.FileExists, DirExists, ExpandHome - Fix secp256k1fx imports: use node/vms/secp256k1fx - Fix platformvm imports: use node/vms/platformvm - Fix e2e test TODOs: uncomment BootstrapValidators assertions - Improve localnet stub implementations with real logic - Fix node.go fs.FileExists reference Note: Build requires GOWORK=off due to workspace dependency issues
72 lines
1.5 KiB
Go
72 lines
1.5 KiB
Go
// Copyright (C) 2022-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package lpmintegration
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
"path"
|
|
"strings"
|
|
|
|
"github.com/luxfi/cli/pkg/application"
|
|
"github.com/luxfi/cli/pkg/ux"
|
|
"github.com/luxfi/constants"
|
|
)
|
|
|
|
const gitExtension = ".git"
|
|
|
|
// AddRepo adds a new LPM repository and returns its alias.
|
|
func AddRepo(app *application.Lux, repoURL *url.URL, branch string) (string, error) {
|
|
alias, err := getAlias(repoURL)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
if alias == constants.DefaultLuxPackage {
|
|
ux.Logger.PrintToUser("Lux Plugins Core already installed, skipping...")
|
|
return "", nil
|
|
}
|
|
|
|
repoStr := repoURL.String()
|
|
|
|
if path.Ext(repoStr) != gitExtension {
|
|
repoStr += gitExtension
|
|
}
|
|
|
|
fmt.Println("Installing repo")
|
|
|
|
return alias, app.Lpm.AddRepository(alias, repoStr, branch)
|
|
}
|
|
|
|
// UpdateRepos updates all LPM repositories.
|
|
func UpdateRepos(app *application.Lux) error {
|
|
return app.Lpm.Update()
|
|
}
|
|
|
|
// InstallVM installs all VMs for a given chain from LPM.
|
|
func InstallVM(app *application.Lux, chainKey string) error {
|
|
vms, err := getVMsInChain(app, chainKey)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
splitKey := strings.Split(chainKey, ":")
|
|
if len(splitKey) != 2 {
|
|
return fmt.Errorf("invalid key: %s", chainKey)
|
|
}
|
|
|
|
repo := splitKey[0]
|
|
|
|
for _, vm := range vms {
|
|
toInstall := repo + ":" + vm
|
|
fmt.Println("Installing vm:", toInstall)
|
|
err = app.Lpm.Install(toInstall)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|