Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
13 changes: 7 additions & 6 deletions internal/cli/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package cli
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/url"
"os"
Expand Down Expand Up @@ -65,7 +66,7 @@ func newAuthLoginCmd(flags *rootFlags) *cobra.Command {
Short: "Automated login using a browser (requires Python + Playwright)",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println("Attempting automated session refresh...")

// Check if script exists
scriptPath := "scripts/refresh_auth.js"
if _, err := os.Stat(scriptPath); os.IsNotExist(err) {
Expand All @@ -91,7 +92,7 @@ func newAuthLoginCmd(flags *rootFlags) *cobra.Command {
}

cookieString := strings.TrimSpace(matches[1])

// Save the token
cfg, err := config.Load(flags.configPath)
if err != nil {
Expand Down Expand Up @@ -317,7 +318,7 @@ How to get a HAR file:

var bestCookie string
bestHeaders := make(map[string]string)

// Pass 1: Aggregate all bot-detection headers found anywhere in the HAR
for _, entry := range har.Log.Entries {
for _, header := range entry.Request.Headers {
Expand All @@ -334,7 +335,7 @@ How to get a HAR file:
if err != nil {
continue
}

isSkool := strings.Contains(u.Host, "skool.com")
if isSkool {
for _, header := range entry.Request.Headers {
Expand All @@ -355,7 +356,6 @@ How to get a HAR file:
}
found:


if bestCookie == "" {
msg := "no session cookies found in HAR file.\n"
if len(har.Log.Entries) == 0 {
Expand All @@ -364,7 +364,8 @@ How to get a HAR file:
msg += fmt.Sprintf("Found %d requests, but none contained Skool authentication material.\n", len(har.Log.Entries))
msg += "Ensure you REFRESH the page while the Network tab is open before exporting."
}
return fmt.Errorf(msg)
// PATCH: Return dynamic prose as an error value without treating it as a format string.
return errors.New(msg)
}

cfg, err := config.Load(flags.configPath)
Expand Down
9 changes: 5 additions & 4 deletions internal/cli/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ This avoids the need for sudo/root permissions.`,
}

target := filepath.Join(binDir, "skool-pp-cli")

// Copy binary
input, err := os.ReadFile(exe)
if err != nil {
return fmt.Errorf("reading current binary: %w", err)
}
if err := os.WriteFile(target, input, 0755); err != nil {
return fmt.Errorf("writing binary to %s: %w", target, binDir)
// PATCH: Wrap the write error rather than passing the destination directory to %w.
return fmt.Errorf("writing binary to %s: %w", target, err)
}

fmt.Printf("✓ Binary installed to %s\n", target)
Expand All @@ -51,15 +52,15 @@ This avoids the need for sudo/root permissions.`,
if !strings.Contains(pathEnv, binDir) {
fmt.Println("\n⚠ This directory is not in your PATH.")
fmt.Println("To add it, run the following command or add it to your shell profile (.zshrc or .bash_profile):")

shell := filepath.Base(os.Getenv("SHELL"))
if shell == "" {
shell = "your shell"
}

exportCmd := fmt.Sprintf("export PATH=\"%s:$PATH\"", binDir)
fmt.Printf("\n %s\n\n", exportCmd)

if runtime.GOOS == "darwin" || runtime.GOOS == "linux" {
profile := ".zshrc"
if strings.Contains(shell, "bash") {
Expand Down