📦 CreateSatisConfig
Creates a new Satis configuration file (satis.json). Generates a base configuration containing the name, homepage, default output directory, and require-all, then writes it to disk.
When to use
Use when you need to set up a private Composer repository (Satis) from scratch: first generate the base configuration with this method, then supplement repositories and dependencies with methods like AddSatisRepository / AddSatisRequire.
Signature
go
func (c *Composer) CreateSatisConfig(configPath string, name string, homepage string) errorParameters
| Parameter | Type | Description |
|---|---|---|
configPath | string | Output path of the configuration file, e.g. satis/satis.json |
name | string | Repository name, e.g. my-company/composer |
homepage | string | Repository homepage URL, from which users download packages |
Return value
| Return value | Type | Description |
|---|---|---|
| Sole return value | error | Returned when serialization, directory creation, or file writing fails |
Defaults
The generated configuration defaults OutputDir to public and RequireAll to true. The parent directory is created automatically (permission 0755) if it does not exist.
Example
go
package main
import (
"log"
"github.com/scagogogo/composer-skills/pkg/composer"
)
func main() {
comp, err := composer.New(composer.DefaultOptions())
if err != nil {
log.Fatalf("init failed: %v", err)
}
if err := comp.CreateSatisConfig(
"satis/satis.json",
"my-company/composer",
"https://composer.example.com",
); err != nil {
log.Fatalf("failed to create Satis config: %v", err)
}
}Advanced
- To initialize the directory and configuration in one step, use the more convenient InitSatis.
- After the configuration is created, build the repository artifacts with BuildSatis.
- To add repositories, dependencies, archives, etc., use companion methods like
AddSatisRepository,AddSatisRequire, andEnableSatisArchive.