Skip to content

Commit 42d06fa

Browse files
committed
update registry
1 parent 8a5822e commit 42d06fa

12 files changed

Lines changed: 63 additions & 85 deletions

File tree

.claude/settings.local.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"allow": [
44
"Bash(go mod:*)",
55
"Bash(go test:*)",
6-
"Bash(go tool:*)"
6+
"Bash(go tool:*)",
7+
"Bash(grep:*)",
8+
"Bash(go vet:*)",
9+
"Bash(make build:*)"
710
]
811
}
912
}

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ Reuse and share module definitions:
345345

346346
```yaml
347347
modules:
348-
- from: dotular.dev/modules/neovim@1.0.0
348+
- from: neovim
349349
with:
350350
neovim_version: "0.10.2"
351351
override:
@@ -365,11 +365,11 @@ modules:
365365

366366
| Source | Trust |
367367
|--------|-------|
368-
| `dotular.dev/modules/` | Official |
369-
| `dotular.dev/community/` | Community |
370-
| GitHub / arbitrary URL | Private |
368+
| `github.com/atomikpanda/dotular/...` or bare name | Official |
369+
| Other `github.com/...` repos | GitHub |
370+
| Other URLs | External |
371371

372-
GitHub refs (`github.com/user/repo@ref`) are automatically rewritten to `raw.githubusercontent.com`.
372+
Bare names (e.g. `neovim`) expand to `github.com/atomikpanda/dotular/modules/neovim@main`. GitHub refs are automatically rewritten to `raw.githubusercontent.com`.
373373

374374
### Cache
375375

cmd/dotular/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,10 @@ func registryCmd() *cobra.Command {
649649
switch trustStr {
650650
case "official":
651651
trustStr = color.BoldGreen(trustStr)
652-
case "community":
653-
trustStr = color.Yellow(trustStr)
654-
default:
652+
case "github":
655653
trustStr = color.Dim(trustStr)
654+
case "external":
655+
trustStr = color.Yellow(trustStr)
656656
}
657657
rows = append(rows, []string{
658658
ref.Raw,

dotular.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ modules:
1313
verify: brew --version
1414

1515
# --- registry module --------------------------------------------------------
16-
# - from: dotular.dev/modules/neovim@1.0.0
16+
# - from: neovim
1717
# with:
1818
# neovim_version: "0.10.2"
1919
# override:

internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type Module struct {
3535

3636
// Registry module reference (mutually exclusive with Items in source YAML;
3737
// after resolution Items is populated from the registry module).
38-
From string `yaml:"from,omitempty"` // e.g. "dotular.dev/modules/neovim@1.0.0"
38+
From string `yaml:"from,omitempty"` // e.g. "github.com/atomikpanda/dotular/modules/neovim@main"
3939
With map[string]any `yaml:"with,omitempty"` // parameter overrides
4040
Override []Item `yaml:"override,omitempty"` // items that replace matching registry items
4141
}

internal/config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ func TestConfigModule(t *testing.T) {
268268
}
269269

270270
func TestModuleIsRegistry(t *testing.T) {
271-
m := Module{From: "dotular.dev/modules/foo"}
271+
m := Module{From: "github.com/user/repo"}
272272
if !m.IsRegistry() {
273273
t.Error("expected IsRegistry() true")
274274
}

internal/registry/fetch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ func download(ctx context.Context, url string) ([]byte, error) {
106106
func parseModule(data []byte) (*RemoteModule, TrustLevel, error) {
107107
var mod RemoteModule
108108
if err := yaml.Unmarshal(data, &mod); err != nil {
109-
return nil, Private, fmt.Errorf("parse registry module: %w", err)
109+
return nil, External, fmt.Errorf("parse registry module: %w", err)
110110
}
111-
return &mod, Private, nil
111+
return &mod, External, nil
112112
}
113113

114114
func moduleCachePath(rawRef string) string {

internal/registry/fetch_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
)
1010

1111
func TestModuleCachePath(t *testing.T) {
12-
got := moduleCachePath("dotular.dev/modules/neovim@1.0.0")
12+
got := moduleCachePath("github.com/atomikpanda/dotular/modules/neovim@main")
1313
if got == "" {
1414
t.Error("expected non-empty cache path")
1515
}
@@ -42,15 +42,15 @@ func TestCollectActiveRefs(t *testing.T) {
4242
cfg := config.Config{
4343
Modules: []config.Module{
4444
{Name: "local", Items: []config.Item{{Package: "git"}}},
45-
{Name: "remote", From: "dotular.dev/modules/neovim@1.0.0"},
45+
{Name: "remote", From: "github.com/atomikpanda/dotular/modules/neovim@main"},
4646
{Name: "remote2", From: "github.com/user/repo"},
4747
},
4848
}
4949
refs := CollectActiveRefs(cfg)
5050
if len(refs) != 2 {
5151
t.Fatalf("expected 2 refs, got %d", len(refs))
5252
}
53-
if !refs["dotular.dev/modules/neovim@1.0.0"] {
53+
if !refs["github.com/atomikpanda/dotular/modules/neovim@main"] {
5454
t.Error("missing neovim ref")
5555
}
5656
if !refs["github.com/user/repo"] {

internal/registry/lock_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ func TestSaveAndLoadLock(t *testing.T) {
3434

3535
lf := &LockFile{
3636
Registry: map[string]LockEntry{
37-
"dotular.dev/modules/neovim@1.0.0": {
37+
"github.com/atomikpanda/dotular/modules/neovim@main": {
3838
SHA256: "abc123",
3939
FetchedAt: time.Date(2024, 6, 15, 0, 0, 0, 0, time.UTC),
40-
URL: "https://dotular.dev/modules/neovim/1.0.0.yaml",
40+
URL: "https://raw.githubusercontent.com/atomikpanda/dotular/main/modules/neovim.yaml",
4141
},
4242
},
4343
}
@@ -51,14 +51,14 @@ func TestSaveAndLoadLock(t *testing.T) {
5151
t.Fatal(err)
5252
}
5353

54-
entry, ok := loaded.Registry["dotular.dev/modules/neovim@1.0.0"]
54+
entry, ok := loaded.Registry["github.com/atomikpanda/dotular/modules/neovim@main"]
5555
if !ok {
5656
t.Fatal("expected entry in loaded lock")
5757
}
5858
if entry.SHA256 != "abc123" {
5959
t.Errorf("SHA256 = %q", entry.SHA256)
6060
}
61-
if entry.URL != "https://dotular.dev/modules/neovim/1.0.0.yaml" {
61+
if entry.URL != "https://raw.githubusercontent.com/atomikpanda/dotular/main/modules/neovim.yaml" {
6262
t.Errorf("URL = %q", entry.URL)
6363
}
6464
}

internal/registry/module.go

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,22 @@ import (
1212
type TrustLevel int
1313

1414
const (
15-
// Official modules are maintained by Dotular and hosted at dotular.dev/modules.
15+
// Official modules are from the DefaultRegistry (github.com/atomikpanda/dotular).
1616
Official TrustLevel = iota
17-
// Community modules are published by third parties via dotular.dev/community.
18-
// They are not reviewed and should be treated as untrusted.
19-
Community
20-
// Private modules are hosted on arbitrary URLs or GitHub repositories.
21-
Private
17+
// GitHub modules are from other github.com repositories.
18+
GitHub
19+
// External modules are from arbitrary URLs.
20+
External
2221
)
2322

2423
func (t TrustLevel) String() string {
2524
switch t {
2625
case Official:
2726
return "official"
28-
case Community:
29-
return "community"
27+
case GitHub:
28+
return "github"
3029
default:
31-
return "private"
30+
return "external"
3231
}
3332
}
3433

@@ -46,7 +45,7 @@ type RemoteModule struct {
4645
Items []config.Item `yaml:"items"`
4746
}
4847

49-
// Ref holds a parsed registry reference string (e.g. "dotular.dev/modules/neovim@1.0.0").
48+
// Ref holds a parsed registry reference string (e.g. "github.com/atomikpanda/dotular/modules/neovim@main").
5049
type Ref struct {
5150
Raw string
5251
Host string
@@ -94,26 +93,6 @@ func ParseRef(raw string) Ref {
9493

9594
func resolveTrustAndURL(host, path, version string) (TrustLevel, string) {
9695
switch host {
97-
case "dotular.dev":
98-
if strings.HasPrefix(path, "modules/") {
99-
// Official: https://dotular.dev/modules/<name>/<version>.yaml
100-
v := version
101-
if v == "" {
102-
v = "latest"
103-
}
104-
modName := strings.TrimPrefix(path, "modules/")
105-
url := "https://dotular.dev/modules/" + modName + "/" + v + ".yaml"
106-
return Official, url
107-
}
108-
if strings.HasPrefix(path, "community/") {
109-
url := "https://dotular.dev/" + path
110-
if version != "" {
111-
url += "@" + version
112-
}
113-
return Community, url
114-
}
115-
return Private, "https://" + host + "/" + path
116-
11796
case "github.com":
11897
// github.com/user/repo@ref → raw file URL.
11998
// Supports two forms:
@@ -134,14 +113,20 @@ func resolveTrustAndURL(host, path, version string) (TrustLevel, string) {
134113
subPath := parts[2]
135114
url = "https://raw.githubusercontent.com/" + repoPath + "/" + ref + "/" + subPath + ".yaml"
136115
}
137-
return Private, url
116+
117+
// Determine trust: official if from the DefaultRegistry repo.
118+
trust := GitHub
119+
if strings.HasPrefix(path, "atomikpanda/dotular") {
120+
trust = Official
121+
}
122+
return trust, url
138123

139124
default:
140125
// Fallback: treat as a direct HTTPS URL.
141126
url := "https://" + host + "/" + path
142127
if version != "" {
143128
url += "@" + version
144129
}
145-
return Private, url
130+
return External, url
146131
}
147132
}

0 commit comments

Comments
 (0)