Skip to content

Commit dcc8cd9

Browse files
committed
doc(sites): adding sites
1 parent f2cc941 commit dcc8cd9

8 files changed

Lines changed: 79 additions & 162 deletions

File tree

examples/.DS_Store

6 KB
Binary file not shown.

examples/.builder.yml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
version: 1
22
name: example
3+
4+
# Root directory for the builder configuration and output.
5+
root: .builder
6+
7+
# Sites is a deployment target for the builder CLI.
8+
sites:
9+
path: .
10+
name: fizzy-buzzy
11+
ignore:
12+
- .builder
13+
14+
# Rules define the builder's behavior and code generation rules.
315
rules:
416
design:
517
- Document any platform-specific behavior or limitations
@@ -34,12 +46,6 @@ constitution: |
3446
- Tests must use path.join() for expected path values, not hardcoded strings
3547
- Consider case sensitivity differences in file systems
3648
37-
deploy:
38-
path: .
39-
ignore:
40-
- .builder
41-
site: fizzy-buzzy
42-
4349
tasks:
4450
feature:
4551
id: feature
@@ -243,4 +249,3 @@ tasks:
243249
244250
- [ ] 2.1 <!-- Task description -->
245251
- [ ] 2.2 <!-- Task description -->
246-
root: .builder

examples/index.html

Lines changed: 0 additions & 130 deletions
This file was deleted.

internal/ui/models/sites/check.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,19 +114,19 @@ func (m checkSiteModel) View() tea.View {
114114
}
115115

116116
if m.siteExists {
117-
fmt.Fprintf(&s, "%s %s exists.\n", checkMark, m.cfg.Spec.Deploy.Site)
117+
fmt.Fprintf(&s, "%s %s exists.\n", checkMark, m.cfg.Spec.Sites.Site)
118118
}
119119

120120
if !m.siteExists {
121-
fmt.Fprintf(&s, "%s %s does not exist.\n", errorMark, m.cfg.Spec.Deploy.Site)
121+
fmt.Fprintf(&s, "%s %s does not exist.\n", errorMark, m.cfg.Spec.Sites.Name)
122122
}
123123

124124
return tea.NewView(s.String())
125125
}
126126

127127
func (m *checkSiteModel) checkSiteExists() tea.Cmd {
128128
return func() tea.Msg {
129-
site := &models.Site{Name: m.cfg.Spec.Deploy.Site}
129+
site := &models.Site{Name: m.cfg.Spec.Sites.Name}
130130
exists, err := m.sitesCtrl.Exists(m.ctx, site)
131131
if utilx.NotNil(err) {
132132
return siteCheckErrorMsg{err: err}

internal/ui/models/sites/create.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (m *createSiteModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
8383

8484
// View renders the current state of the deploy model.
8585
func (m createSiteModel) View() tea.View {
86-
s := fmt.Sprintf("%s %s successfully created.\n", checkMark, m.cfg.Spec.Deploy.Site)
86+
s := fmt.Sprintf("%s %s successfully created.\n", checkMark, m.cfg.Spec.Sites.Name)
8787

8888
if utilx.NotNil(m.err) {
8989
s = fmt.Sprintf("%s %s\n", errorMark, m.err)
@@ -94,7 +94,7 @@ func (m createSiteModel) View() tea.View {
9494

9595
func (m *createSiteModel) createSite() tea.Cmd {
9696
return func() tea.Msg {
97-
site := &models.Site{Name: m.cfg.Spec.Deploy.Site}
97+
site := &models.Site{Name: m.cfg.Spec.Sites.Name}
9898
err := m.sitesCtrl.Create(m.ctx, site)
9999
if utilx.NotNil(err) {
100100
return createSiteErrorMsg{err: err}

internal/ui/models/sites/deploy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ func (m deployModel) View() tea.View {
147147
}
148148

149149
func (m *deployModel) writeFiles() tea.Cmd {
150-
files := utils.ScanDir(m.cfg.Spec.Deploy.Path, m.cfg.Spec.Deploy.Ignore)
150+
files := utils.ScanDir(m.cfg.Spec.Sites.Path, m.cfg.Spec.Sites.Ignore)
151151
cmds := make([]tea.Cmd, 0, len(files))
152152
m.total = len(files)
153153
site := &models.Site{
154-
Name: m.cfg.Spec.Deploy.Site,
154+
Name: m.cfg.Spec.Sites.Name,
155155
}
156156

157157
for _, file := range files {

pkg/specs/spec.go

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,30 @@ const (
2828
// This could be used in various contexts such as API specifications,
2929
// software design documents, etc.
3030
type Spec struct {
31-
Version int `json:"version" yaml:"version"`
32-
Name string `json:"name,omitempty" yaml:"name"`
33-
Description string `json:"description,omitempty" yaml:"description,omitempty"`
34-
Rules Rules `json:"rules" yaml:"rules"`
35-
Constitution string `json:"constitution" yaml:"constitution"`
36-
Models []Model `json:"models,omitempty" yaml:"models,omitempty"`
37-
Deploy *Deploy `json:"domain,omitempty" yaml:"domain,omitempty"`
38-
Tasks Tasks `json:"tasks" yaml:"tasks"`
39-
Root string `json:"root,omitempty" yaml:"root,omitempty"`
31+
// Version is the version of the spec.
32+
Version int `json:"version" yaml:"version"`
33+
// Name is the name of the spec.
34+
Name string `json:"name,omitempty" yaml:"name"`
35+
// Root is the root directory of the spec.
36+
Root string `json:"root,omitempty" yaml:"root,omitempty"`
37+
// Description is the description of the spec.
38+
Description string `json:"description,omitempty" yaml:"description,omitempty"`
39+
// Rules define the rules for the spec.
40+
Rules Rules `json:"rules" yaml:"rules"`
41+
// Constitution is the constitution of the spec.
42+
Constitution string `json:"constitution" yaml:"constitution"`
43+
// Models define the models for the spec.
44+
Models []Model `json:"models,omitempty" yaml:"models,omitempty"`
45+
// Sites defines the deployment configuration for the specification.
46+
Sites *Sites `json:"sites,omitempty" yaml:"sites,omitempty"`
47+
// Tasks define the tasks for the spec.
48+
Tasks Tasks `json:"tasks" yaml:"tasks"`
4049
}
4150

42-
// Deploy defines the deployment configuration for the specification.
43-
type Deploy struct {
51+
// Sites defines the deployment configuration for the specification.
52+
type Sites struct {
53+
// Name is the name of the site.
54+
Name string `json:"name" yaml:"name"`
4455
// Path is the path to the deployment configuration file.
4556
Path string `json:"path" yaml:"path"`
4657
// Site is the name of the site to deploy to.
@@ -51,12 +62,18 @@ type Deploy struct {
5162

5263
// Model specifies a model.
5364
type Model struct {
65+
// RequestOptions are the request options for the model.
5466
RequestOptions map[string]any `json:"requestOptions,omitempty" yaml:"requestOptions,omitempty"`
55-
ID string `json:"id" yaml:"id"`
56-
Name string `json:"name" yaml:"name"`
57-
URL string `json:"url" yaml:"url"`
58-
Provider Provider `json:"provider" yaml:"provider"`
59-
Roles []string `json:"roles" yaml:"roles"`
67+
// ID is the unique identifier for the model.
68+
ID string `json:"id" yaml:"id"`
69+
// Name is the name of the model.
70+
Name string `json:"name" yaml:"name"`
71+
// URL is the URL of the model.
72+
URL string `json:"url" yaml:"url"`
73+
// Provider is the provider of the model.
74+
Provider Provider `json:"provider" yaml:"provider"`
75+
// Roles are the roles of the model.
76+
Roles []string `json:"roles" yaml:"roles"`
6077
}
6178

6279
// Provider is a string that specifies the provider for a model.
@@ -151,7 +168,7 @@ func (s *Spec) UnmarshalYAML(data []byte) error {
151168
Name string `yaml:"name"`
152169
Models []Model `yaml:"models"`
153170
Version int `yaml:"version"`
154-
Deploy *Deploy `yaml:"deploy"`
171+
Sites *Sites `yaml:"deploy"`
155172
Root string `yaml:"root"`
156173
}{
157174
Version: DefaultVersion,
@@ -172,7 +189,7 @@ func (s *Spec) UnmarshalYAML(data []byte) error {
172189
s.Constitution = spec.Constitution
173190
s.Description = spec.Description
174191
s.Tasks = spec.Tasks
175-
s.Deploy = spec.Deploy
192+
s.Sites = spec.Sites
176193
s.Root = spec.Root
177194

178195
return nil
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
title: "Sites"
3+
weight: 20
4+
---
5+
6+
Sites are a deployment target specifically interacting with the Builder API.
7+
A site is self-service, citizen-development internal hosting service.
8+
9+
## Example
10+
11+
```yaml {filename=".builder.yaml"}
12+
sites:
13+
path: .
14+
name: fizzy-buzzy
15+
ignore:
16+
- .builder
17+
```
18+
19+
## Structure
20+
21+
A site is defined by the following fields:
22+
23+
- `path`: The path to the site's source code (default: current directory).
24+
- `name`: The name of the site.
25+
- `ignore`: A list of files to ignore when deploying the site.

0 commit comments

Comments
 (0)