Skip to content

Commit bedf092

Browse files
committed
fix: Fix registry option for ESLint
1 parent 096db1b commit bedf092

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

cmd/install.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ var installCmd = &cobra.Command{
148148
for name, tool := range cfg.Config.Tools() {
149149
if !cfg.Config.IsToolInstalled(name, tool) {
150150
progressBar.Describe(fmt.Sprintf("Installing tool: %s v%s...", name, tool.Version))
151-
err := cfg.InstallTool(name, tool)
151+
err := cfg.InstallTool(name, tool, registry)
152152
if err != nil {
153153
log.Fatal(err)
154154
}
@@ -179,15 +179,15 @@ var installCmd = &cobra.Command{
179179
}
180180

181181
func installRuntimes(config *cfg.ConfigType) {
182-
err := cfg.InstallRuntimes()
182+
err := cfg.InstallRuntimes(config)
183183
if err != nil {
184184
log.Fatal(err)
185185
}
186186
}
187187

188-
func installTools(config *cfg.ConfigType) {
188+
func installTools(config *cfg.ConfigType, registry string) {
189189
// Use the new tools-installer instead of manual installation
190-
err := cfg.InstallTools()
190+
err := cfg.InstallTools(config, registry)
191191
if err != nil {
192192
log.Fatal(err)
193193
}

config/runtimes-installer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
)
1212

1313
// InstallRuntimes installs all runtimes defined in the configuration
14-
func InstallRuntimes() error {
15-
for name, runtimeInfo := range Config.Runtimes() {
14+
func InstallRuntimes(config *ConfigType) error {
15+
for name, runtimeInfo := range config.Runtimes() {
1616
err := InstallRuntime(name, runtimeInfo)
1717
if err != nil {
1818
return fmt.Errorf("failed to install runtime %s: %w", name, err)

config/tools-installer.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import (
1414
)
1515

1616
// InstallTools installs all tools defined in the configuration
17-
func InstallTools() error {
18-
for name, toolInfo := range Config.Tools() {
17+
func InstallTools(config *ConfigType, registry string) error {
18+
for name, toolInfo := range config.Tools() {
1919
fmt.Printf("Installing tool: %s v%s...\n", name, toolInfo.Version)
20-
err := InstallTool(name, toolInfo)
20+
err := InstallTool(name, toolInfo, registry)
2121
if err != nil {
2222
return fmt.Errorf("failed to install tool %s: %w", name, err)
2323
}
@@ -27,7 +27,7 @@ func InstallTools() error {
2727
}
2828

2929
// InstallTool installs a specific tool
30-
func InstallTool(name string, toolInfo *plugins.ToolInfo) error {
30+
func InstallTool(name string, toolInfo *plugins.ToolInfo, registry string) error {
3131
// Check if the tool is already installed
3232
if isToolInstalled(toolInfo) {
3333
fmt.Printf("Tool %s v%s is already installed\n", name, toolInfo.Version)
@@ -55,10 +55,10 @@ func InstallTool(name string, toolInfo *plugins.ToolInfo) error {
5555

5656
// For runtime-based tools
5757
fmt.Printf("Installing %s using %s runtime...\n", name, toolInfo.Runtime)
58-
return installRuntimeTool(name, toolInfo)
58+
return installRuntimeTool(name, toolInfo, registry)
5959
}
6060

61-
func installRuntimeTool(name string, toolInfo *plugins.ToolInfo) error {
61+
func installRuntimeTool(name string, toolInfo *plugins.ToolInfo, registry string) error {
6262
// Get the runtime for this tool
6363
runtimeInfo, ok := Config.Runtimes()[toolInfo.Runtime]
6464
if !ok {
@@ -70,7 +70,7 @@ func installRuntimeTool(name string, toolInfo *plugins.ToolInfo) error {
7070
"InstallDir": toolInfo.InstallDir,
7171
"PackageName": toolInfo.Name,
7272
"Version": toolInfo.Version,
73-
"Registry": "", // TODO: Get registry from config
73+
"Registry": registry,
7474
}
7575

7676
// Get package manager binary based on the tool configuration
@@ -81,12 +81,14 @@ func installRuntimeTool(name string, toolInfo *plugins.ToolInfo) error {
8181
}
8282

8383
// Set registry if provided
84-
if toolInfo.RegistryCommand != "" {
84+
if registry != "" {
8585
regCmd, err := executeToolTemplate(toolInfo.RegistryCommand, templateData)
8686
if err != nil {
8787
return fmt.Errorf("failed to prepare registry command: %w", err)
8888
}
8989

90+
log.Printf("Setting registry...\n %s %s\n", packageManagerBinary, regCmd)
91+
9092
if regCmd != "" {
9193
registryCmd := exec.Command(packageManagerBinary, strings.Split(regCmd, " ")...)
9294
if output, err := registryCmd.CombinedOutput(); err != nil {

plugins/tool-utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestProcessTools(t *testing.T) {
6565

6666
// Assert installation command templates are correctly set
6767
assert.Equal(t, "install --prefix {{.InstallDir}} {{.PackageName}}@{{.Version}} @microsoft/eslint-formatter-sarif", eslintInfo.InstallCommand)
68-
assert.Equal(t, "{{if .Registry}}config set registry {{.Registry}}{{end}}", eslintInfo.RegistryCommand)
68+
assert.Equal(t, "config set registry {{.Registry}}", eslintInfo.RegistryCommand)
6969
}
7070

7171
func TestProcessToolsWithDownload(t *testing.T) {

plugins/tools/eslint/plugin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ runtime_binaries:
66
execution: node
77
installation:
88
command: "install --prefix {{.InstallDir}} {{.PackageName}}@{{.Version}} @microsoft/eslint-formatter-sarif"
9-
registry_template: "{{if .Registry}}config set registry {{.Registry}}{{end}}"
9+
registry_template: "config set registry {{.Registry}}"
1010
binaries:
1111
- name: eslint
1212
path: "node_modules/.bin/eslint"

0 commit comments

Comments
 (0)