105 lines
1.7 KiB
Go
105 lines
1.7 KiB
Go
|
package template
|
||
|
|
||
|
const templateGitignore = `.idea
|
||
|
{{.Name}}
|
||
|
{{.Name}}.exe
|
||
|
{{.Name}}.exe~
|
||
|
`
|
||
|
|
||
|
const templateMakefile = `.PHONY : clean all ui api gen wire
|
||
|
gen:
|
||
|
ifeq ($(wildcard "webui/node_modules"),)
|
||
|
buf generate
|
||
|
else
|
||
|
buf generate --exclude-path webui/node_modules
|
||
|
endif
|
||
|
|
||
|
wire:
|
||
|
go mod tidy
|
||
|
cd gen/wire && wire
|
||
|
|
||
|
ui:
|
||
|
cd webui && npm install && npm run build
|
||
|
|
||
|
api:
|
||
|
go mod tidy && go build .
|
||
|
./{{.Name}} api
|
||
|
|
||
|
build: gen wire ui api
|
||
|
|
||
|
run: gen wire ui api
|
||
|
./{{.Name}} api
|
||
|
|
||
|
all: gen wire ui api
|
||
|
|
||
|
docker:
|
||
|
podman build -t images.internal/{{.Name}}:latest .
|
||
|
podman push images.internal/{{.Name}}:latest
|
||
|
`
|
||
|
|
||
|
const templateDockerfile = `FROM images.internal/devel:latest
|
||
|
|
||
|
WORKDIR /app
|
||
|
|
||
|
COPY . /app
|
||
|
|
||
|
RUN make build
|
||
|
|
||
|
EXPOSE 38001
|
||
|
|
||
|
ENTRYPOINT [ "./{{.Name}}", "api" ]
|
||
|
`
|
||
|
|
||
|
const templateDockerCompose = `version: "3"
|
||
|
|
||
|
services:
|
||
|
server:
|
||
|
image: images.internal/{{.Name}}:latest
|
||
|
container_name: {{.Name}}
|
||
|
restart: always
|
||
|
volumes:
|
||
|
- /data/containers/{{.Name}}:/app/data
|
||
|
ports:
|
||
|
- "30001:38080"
|
||
|
`
|
||
|
|
||
|
const templateBuf = `version: v1
|
||
|
breaking:
|
||
|
use:
|
||
|
- FILE
|
||
|
lint:
|
||
|
use:
|
||
|
- DEFAULT
|
||
|
except:
|
||
|
- MINIMAL
|
||
|
`
|
||
|
|
||
|
const templateBufGen = `version: v1
|
||
|
plugins:
|
||
|
- plugin: buf.build/protocolbuffers/go
|
||
|
out: gen
|
||
|
opt: paths=source_relative
|
||
|
- plugin: coco
|
||
|
out: gen
|
||
|
opt:
|
||
|
- paths=source_relative
|
||
|
- prefix=proto
|
||
|
- project_name={{.Name}}
|
||
|
- plugin: buf.build/community/stephenh-ts-proto
|
||
|
out: ./webui/src/gen
|
||
|
opt:
|
||
|
- paths=source_relative
|
||
|
- snakeToCamel=json
|
||
|
- esModuleInterop=true
|
||
|
- plugin: buf.build/grpc/go:v1.3.0
|
||
|
out: gen
|
||
|
opt:
|
||
|
- paths=source_relative
|
||
|
- require_unimplemented_servers=false
|
||
|
`
|
||
|
|
||
|
const templateBufWork = `version: v1
|
||
|
directories:
|
||
|
- proto
|
||
|
`
|