Build with Magefile #104341

Merged
Sybren A. Stüvel merged 26 commits from magefile into main 2024-10-04 21:59:46 +02:00
4 changed files with 60 additions and 17 deletions
Showing only changes of commit 9c5b32280c - Show all commits

View File

@ -151,8 +151,8 @@ clean: buildtool
devserver-website: devserver-website:
go run ${HUGO_PKG} -s web/project-website serve go run ${HUGO_PKG} -s web/project-website serve
devserver-webapp: devserver-webapp: buildtool
yarn --cwd web/app run dev --host "${BUILDTOOL_PATH}" devServerWebapp
deploy-website: deploy-website:
$(MAKE) -s check-environment $(MAKE) -s check-environment

View File

@ -18,27 +18,12 @@ const (
) )
var ( var (
generators = []string{
"github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.9.0",
"github.com/golang/mock/mockgen@v1.6.0",
}
// The directory that will contain the built webapp files, and some other // The directory that will contain the built webapp files, and some other
// files that will be served as static files by the Flamenco Manager web // files that will be served as static files by the Flamenco Manager web
// server. // server.
webStatic = filepath.Join("web", "static") webStatic = filepath.Join("web", "static")
) )
// Install code generators.
func InstallGenerators() error {
for _, pkg := range generators {
if err := sh.RunV(mg.GoCmd(), "install", pkg); err != nil {
return err
}
}
return nil
}
// Build Flamenco Manager and Flamenco Worker, including the webapp and the add-on // Build Flamenco Manager and Flamenco Worker, including the webapp and the add-on
func Build() { func Build() {
mg.Deps(FlamencoManager, FlamencoWorker) mg.Deps(FlamencoManager, FlamencoWorker)

13
magefiles/devserver.go Normal file
View File

@ -0,0 +1,13 @@
//go:build mage
package main
// SPDX-License-Identifier: GPL-3.0-or-later
import (
"github.com/magefile/mage/sh"
)
func DevServerWebapp() error {
return sh.RunV("yarn", "--cwd", "web/app", "run", "dev", "--host")
}

45
magefiles/install.go Normal file
View File

@ -0,0 +1,45 @@
//go:build mage
package main
// SPDX-License-Identifier: GPL-3.0-or-later
import (
"context"
"github.com/magefile/mage/mg"
"github.com/magefile/mage/sh"
)
var (
generators = []string{
"github.com/deepmap/oapi-codegen/cmd/oapi-codegen@v1.9.0",
"github.com/golang/mock/mockgen@v1.6.0",
}
)
// Install build-time dependencies: code generators and NodeJS dependencies.
func InstallDeps() {
mg.SerialDeps(InstallGenerators, InstallDepsWebapp)
}
// Install code generators.
func InstallGenerators(ctx context.Context) error {
r := NewRunner(ctx)
for _, pkg := range generators {
r.Run(mg.GoCmd(), "install", pkg)
}
return r.Wait()
}
// Use Yarn to install the webapp's NodeJS dependencies
func InstallDepsWebapp() error {
env := map[string]string{
"MSYS2_ARG_CONV_EXCL": "*",
}
return sh.RunWithV(env,
"yarn",
"--cwd", "web/app",
"install",
)
}