Skip to content

Commit 2b13ea7

Browse files
authored
Merge pull request #17 from Azuyamat/feat/templates
feat: Scaffold templating system
2 parents ad39bee + ffb41ff commit 2b13ea7

57 files changed

Lines changed: 3915 additions & 1834 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 116 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,34 @@ Download the appropriate binary for your platform from the [releases page](https
6363

6464
## Quick Start
6565

66-
Create a `config.pace` file in your project root:
66+
### Auto-generate Configuration (Recommended)
67+
68+
Let Pace automatically generate a configuration for your project:
69+
70+
```bash
71+
cd your-project
72+
pace init
73+
```
74+
75+
Pace will detect your project type (Go, Node.js, Python, Rust) and create an optimized `config.pace` with appropriate tasks, caching, and file patterns.
76+
77+
### Manual Configuration
78+
79+
Alternatively, create a `config.pace` file in your project root:
6780

6881
```pace
6982
default build
7083
71-
task build {
84+
task build [b] {
7285
description "Build the project"
7386
command "go build -o bin/app main.go"
74-
before ["test"]
75-
inputs ["**/*.go"]
76-
outputs ["bin/app"]
87+
requires [test]
88+
inputs [**/*.go]
89+
outputs [bin/app]
90+
cache true
7791
}
7892
79-
hook "test" {
93+
hook test {
8094
description "Run tests"
8195
command "go test ./..."
8296
}
@@ -111,7 +125,26 @@ task build {
111125

112126
### Aliases
113127

114-
Create shortcuts for tasks:
128+
Create shortcuts for tasks using inline syntax:
129+
130+
```pace
131+
task build [b] {
132+
description "Build the application"
133+
command "go build -o bin/app main.go"
134+
}
135+
136+
task test [t] {
137+
description "Run tests"
138+
command "go test ./..."
139+
}
140+
141+
task dev [d] {
142+
description "Start development server"
143+
command "go run main.go"
144+
}
145+
```
146+
147+
Or use standalone alias statements:
115148

116149
```pace
117150
alias b build
@@ -128,35 +161,55 @@ pace run b # same as: pace run build
128161
### Task Properties
129162

130163
```pace
131-
task example {
132-
description "Example task"
164+
task example [ex] {
165+
description "Example task with all properties"
133166
command "echo 'Hello World'"
134167
135-
before ["setup"]
136-
after ["cleanup"]
137-
on_success ["notify"]
138-
on_failure ["alert"]
139-
140-
inputs ["src/**/*.go", "go.mod"]
141-
outputs ["bin/app"]
142-
143-
cache true
144-
timeout "10m"
145-
retry 3
146-
retry_delay "5s"
147-
148-
working_dir "src"
168+
# Dependencies and hooks
169+
depends-on [other-task] # Tasks that must complete before this one
170+
requires [setup] # Hooks to run before task
171+
triggers [cleanup] # Hooks to run after task
172+
on_success [notify] # Hooks to run on success
173+
on_failure [alert] # Hooks to run on failure
174+
175+
# File tracking for caching
176+
inputs [src/**/*.go, go.mod]
177+
outputs [bin/app]
178+
179+
# Performance and behavior
180+
cache true # Enable smart caching
181+
timeout "10m" # Maximum execution time
182+
retry 3 # Number of retry attempts
183+
retry_delay "5s" # Delay between retries
184+
185+
# Execution environment
186+
working_dir "src" # Working directory for command
149187
env {
150-
"NODE_ENV" "production"
151-
"DEBUG" "false"
188+
NODE_ENV = production
189+
DEBUG = false
152190
}
153191
154-
silent false
155-
parallel false
156-
continue_on_error false
192+
# Conditional execution
193+
when "platform == linux" # Only run on Linux
194+
195+
# Flags
196+
silent false # Suppress output
197+
parallel false # Run dependencies in parallel
198+
continue_on_error false # Continue if task fails
199+
watch false # Enable file watching
157200
}
158201
```
159202

203+
**Property Defaults:**
204+
- `cache`: false
205+
- `parallel`: false
206+
- `silent`: false
207+
- `continue_on_error`: false
208+
- `watch`: false
209+
- `retry`: 0
210+
211+
**Note:** You can use identifiers or strings in arrays. Arrays support both `[item1, item2]` and `["item1", "item2"]` syntax.
212+
160213
### Arguments
161214

162215
Pass arguments to tasks:
@@ -245,48 +298,68 @@ Syntax highlighting for `.pace` files is available. Check the [vscode-pace](vsco
245298
default all
246299
247300
task all {
248-
before ["backend", "frontend"]
301+
description "Build all components"
302+
depends-on [backend, frontend]
249303
command "echo 'Build complete'"
250304
}
251305
252-
task backend {
306+
task backend [be] {
307+
description "Build Go backend"
253308
command "go build -o bin/server cmd/server/main.go"
254-
inputs ["cmd/**/*.go", "internal/**/*.go"]
255-
outputs ["bin/server"]
309+
inputs [cmd/**/*.go, internal/**/*.go]
310+
outputs [bin/server]
256311
cache true
257312
}
258313
259-
task frontend {
314+
task frontend [fe] {
315+
description "Build React frontend"
260316
command "npm run build"
261317
working_dir "frontend"
262-
inputs ["frontend/src/**/*"]
263-
outputs ["frontend/dist/**/*"]
318+
inputs [frontend/src/**/*]
319+
outputs [frontend/dist/**/*]
264320
cache true
265321
}
266322
```
267323

268324
### Development Workflow
269325

270326
```pace
271-
task dev {
272-
description "Start development server"
273-
before ["generate"]
327+
var app_name = "myapp"
328+
329+
task dev [d] {
330+
description "Start development server with hot reload"
331+
requires [generate]
274332
command "go run cmd/server/main.go"
333+
watch true
334+
inputs [**/*.go]
275335
}
276336
277-
hook "generate" {
337+
hook generate {
338+
description "Generate code"
278339
command "go generate ./..."
279340
}
280341
281-
task test {
342+
task test [t] {
343+
description "Run all tests"
282344
command "go test -v ./..."
283-
inputs ["**/*.go"]
345+
inputs [**/*.go]
284346
cache true
285347
}
286348
287-
task lint {
349+
task lint [l] {
350+
description "Lint Go code"
288351
command "golangci-lint run"
289-
inputs ["**/*.go"]
352+
inputs [**/*.go]
353+
cache true
354+
}
355+
356+
task build [b] {
357+
description "Build production binary"
358+
command "go build -o bin/${app_name} cmd/server/main.go"
359+
requires [test, lint]
360+
inputs [**/*.go]
361+
outputs [bin/${app_name}]
362+
cache true
290363
}
291364
```
292365

cmd/pace/main.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
package main
22

33
import (
4-
"fmt"
54
"os"
65

76
"github.com/azuyamat/pace/internal/command"
7+
"github.com/azuyamat/pace/internal/logger"
88
)
99

10-
const ConfigFile = "config.pace"
11-
1210
func main() {
1311
err := command.RootCommand.Run(os.Args[1:])
1412
if err != nil {
15-
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
13+
logger.Error("%s", err.Error())
1614
os.Exit(1)
1715
}
1816
}

config.pace

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,46 @@
11
default build
2-
import "extra.pace"
3-
4-
var output = "bin/pace.exe"
52

63
task build {
7-
command "go build -o ${output} cmd/pace/main.go"
8-
description "Build the project"
4+
command "go build -o bin/pace ./cmd\pace"
5+
description "Build the application"
6+
inputs ["**/*.go", "go.mod", "go.sum"]
7+
outputs ["bin/pace"]
8+
cache true
9+
}
10+
11+
task run {
12+
command "go run ./cmd\pace"
13+
description "Run the application"
14+
inputs ["**/*.go"]
15+
watch true
16+
}
917

10-
before ["tidy", "test"]
11-
after ["tidy"]
12-
18+
task test {
19+
command "go test ./..."
20+
description "Run tests"
1321
inputs ["**/*.go"]
14-
outputs ["${output}"]
22+
cache true
23+
}
1524

16-
retry 2
17-
retry_delay "3s"
25+
task tidy {
26+
command "go mod tidy"
27+
description "Tidy go.mod and go.sum"
28+
inputs ["go.mod"]
1829
}
1930

20-
hook tidy {
21-
description "Format the code"
22-
command "gofmt -s -w ."
31+
task vet {
32+
command "go vet ./..."
33+
description "Run go vet"
34+
inputs ["**/*.go"]
35+
cache true
2336
}
2437

25-
hook test {
26-
description "Run tests"
27-
command "go test ./..."
38+
hook clean {
39+
command "if exist bin rmdir /s /q bin"
40+
description "Clean build artifacts"
2841
}
2942

30-
task ts {
31-
command "echo 'This is a task named ts'"
32-
dependencies ["extra"]
33-
description "task ts description"
34-
}
43+
hook fmt {
44+
command "go fmt ./..."
45+
description "Format code"
46+
}

0 commit comments

Comments
 (0)