feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
package generators
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
2026-03-26 17:41:53 +00:00
|
|
|
"dappco.re/go/core/build/internal/ax"
|
2026-03-22 01:34:37 +00:00
|
|
|
coreerr "dappco.re/go/core/log"
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// PHPGenerator generates PHP SDKs from OpenAPI specs.
|
2026-03-31 18:33:36 +01:00
|
|
|
//
|
|
|
|
|
// g := generators.NewPHPGenerator()
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
type PHPGenerator struct{}
|
|
|
|
|
|
|
|
|
|
// NewPHPGenerator creates a new PHP generator.
|
2026-03-31 18:33:36 +01:00
|
|
|
//
|
|
|
|
|
// g := generators.NewPHPGenerator()
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
func NewPHPGenerator() *PHPGenerator {
|
|
|
|
|
return &PHPGenerator{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Language returns the generator's target language identifier.
|
2026-03-31 18:33:36 +01:00
|
|
|
//
|
|
|
|
|
// lang := g.Language() // → "php"
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
func (g *PHPGenerator) Language() string {
|
|
|
|
|
return "php"
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-31 18:33:36 +01:00
|
|
|
// Available checks if generator dependencies are installed (requires Docker).
|
|
|
|
|
//
|
|
|
|
|
// if g.Available() { err = g.Generate(ctx, opts) }
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
func (g *PHPGenerator) Available() bool {
|
2026-03-26 14:58:13 +00:00
|
|
|
return dockerRuntimeAvailable()
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Install returns instructions for installing the generator.
|
2026-03-31 18:33:36 +01:00
|
|
|
//
|
|
|
|
|
// fmt.Println(g.Install()) // → "Docker is required for PHP SDK generation"
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
func (g *PHPGenerator) Install() string {
|
|
|
|
|
return "Docker is required for PHP SDK generation"
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-31 18:33:36 +01:00
|
|
|
// Generate creates SDK from OpenAPI spec (requires Docker).
|
|
|
|
|
//
|
|
|
|
|
// err := g.Generate(ctx, generators.Options{SpecPath: "docs/openapi.yaml", OutputDir: "sdk/php"})
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
func (g *PHPGenerator) Generate(ctx context.Context, opts Options) error {
|
2026-03-30 05:29:24 +00:00
|
|
|
if err := ctx.Err(); err != nil {
|
|
|
|
|
return coreerr.E("php.Generate", "generation cancelled", err)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !dockerRuntimeAvailableWithContext(ctx) {
|
|
|
|
|
if err := ctx.Err(); err != nil {
|
|
|
|
|
return coreerr.E("php.Generate", "generation cancelled", err)
|
|
|
|
|
}
|
2026-03-16 21:03:21 +00:00
|
|
|
return coreerr.E("php.Generate", "Docker is required but not available", nil)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-30 01:28:57 +00:00
|
|
|
dockerCommand, err := resolveDockerRuntimeCli()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return coreerr.E("php.Generate", "docker CLI not available", err)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-30 00:05:46 +00:00
|
|
|
if err := ax.MkdirAll(opts.OutputDir, 0o755); err != nil {
|
2026-03-16 21:03:21 +00:00
|
|
|
return coreerr.E("php.Generate", "failed to create output dir", err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 17:41:53 +00:00
|
|
|
specDir := ax.Dir(opts.SpecPath)
|
|
|
|
|
specName := ax.Base(opts.SpecPath)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
|
|
|
|
|
args := []string{"run", "--rm"}
|
|
|
|
|
args = append(args, dockerUserArgs()...)
|
|
|
|
|
args = append(args,
|
|
|
|
|
"-v", specDir+":/spec",
|
|
|
|
|
"-v", opts.OutputDir+":/out",
|
|
|
|
|
"openapitools/openapi-generator-cli", "generate",
|
|
|
|
|
"-i", "/spec/"+specName,
|
|
|
|
|
"-g", "php",
|
|
|
|
|
"-o", "/out",
|
|
|
|
|
"--additional-properties=invokerPackage="+opts.PackageName,
|
|
|
|
|
)
|
|
|
|
|
|
2026-03-30 01:28:57 +00:00
|
|
|
if err := ax.Exec(ctx, dockerCommand, args...); err != nil {
|
2026-03-16 21:03:21 +00:00
|
|
|
return coreerr.E("php.Generate", "docker run failed", err)
|
feat: extract build/, release/, sdk/ from go-devops
Build system (8 builders, signing, archiving), release pipeline
(7 publishers, versioning, changelog), and SDK generation
(OpenAPI diff, code gen). 18K LOC, all tests pass except Go
builder workspace isolation (pre-existing).
Co-Authored-By: Virgil <virgil@lethean.io>
2026-03-09 12:37:36 +00:00
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
}
|