Change module path from forge.lthn.ai/core/go-scm to dappco.re/go/core/scm. Update all Go source imports for migrated packages: - go-log -> dappco.re/go/core/log - go-io -> dappco.re/go/core/io - go-i18n -> dappco.re/go/core/i18n - go-ws -> dappco.re/go/core/ws - api -> dappco.re/go/core/api Non-migrated packages (cli, config) left on forge.lthn.ai paths. Replace directives use local paths (../go, ../go-io, etc.) until the dappco.re vanity URL server resolves these modules. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
61 lines
1.6 KiB
Go
61 lines
1.6 KiB
Go
package scm
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
|
|
"forge.lthn.ai/core/cli/pkg/cli"
|
|
"dappco.re/go/core/scm/marketplace"
|
|
)
|
|
|
|
func addIndexCommand(parent *cli.Command) {
|
|
var (
|
|
dirs []string
|
|
output string
|
|
baseURL string
|
|
org string
|
|
)
|
|
|
|
cmd := &cli.Command{
|
|
Use: "index",
|
|
Short: "Build marketplace index from directories",
|
|
Long: "Scan directories for core.json or .core/manifest.yaml files and generate a marketplace index.json.",
|
|
RunE: func(cmd *cli.Command, args []string) error {
|
|
if len(dirs) == 0 {
|
|
dirs = []string{"."}
|
|
}
|
|
return runIndex(dirs, output, baseURL, org)
|
|
},
|
|
}
|
|
|
|
cmd.Flags().StringArrayVarP(&dirs, "dir", "d", nil, "Directories to scan (repeatable, default: current directory)")
|
|
cmd.Flags().StringVarP(&output, "output", "o", "index.json", "Output path for the index file")
|
|
cmd.Flags().StringVar(&baseURL, "base-url", "", "Base URL for repo links (e.g. https://forge.lthn.ai)")
|
|
cmd.Flags().StringVar(&org, "org", "", "Organisation for repo links")
|
|
|
|
parent.AddCommand(cmd)
|
|
}
|
|
|
|
func runIndex(dirs []string, output, baseURL, org string) error {
|
|
b := &marketplace.Builder{
|
|
BaseURL: baseURL,
|
|
Org: org,
|
|
}
|
|
|
|
idx, err := b.BuildFromDirs(dirs...)
|
|
if err != nil {
|
|
return cli.WrapVerb(err, "build", "index")
|
|
}
|
|
|
|
absOutput, _ := filepath.Abs(output)
|
|
if err := marketplace.WriteIndex(absOutput, idx); err != nil {
|
|
return err
|
|
}
|
|
|
|
cli.Blank()
|
|
cli.Print(" %s %s\n", successStyle.Render("index built"), valueStyle.Render(output))
|
|
cli.Print(" %s %s\n", dimStyle.Render("modules:"), numberStyle.Render(fmt.Sprintf("%d", len(idx.Modules))))
|
|
cli.Blank()
|
|
|
|
return nil
|
|
}
|