generated from meshery/meshery
-
Notifications
You must be signed in to change notification settings - Fork 106
Expand file tree
/
Copy pathMakefile
More file actions
140 lines (112 loc) · 4.7 KB
/
Makefile
File metadata and controls
140 lines (112 loc) · 4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Copyright Meshery Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include build/Makefile.core.mk
include build/Makefile.show-help.mk
#-----------------------------------------------------------------------------
# Schemas Site and public reference
#-----------------------------------------------------------------------------
.PHONY: site
jekyll = bundle exec jekyll
## Build and run schemas.meshery.io website
site:
bundle install; $(jekyll) serve --drafts --incremental --livereload
#-----------------------------------------------------------------------------
# OpenAPI spec
#-----------------------------------------------------------------------------
.PHONY: setup docs-build generate-ts publish-ts bundle-openapi generate-golang generate-rtk golangci validate-schemas
## (Re)Initialize Golang (go.mod) and Node (package.json) manifests
setup:
go mod tidy
npm install --legacy-peer-deps
## Build API docs with redocly
docs-build: dep-check
redocly bundle --output openapi/bundled-schema.yml
redocly build-docs openapi/bundled-schema.yml --output=openapi/index.html
rm openapi/bundled-schema.yml
## Generate typescript library, json templates, yaml templates
generate-ts:
npm run generate:types
## Bundle Typescript library, json templates, yaml templates
build-ts: generate-ts
npm run build
## Publish schemas package to @meshery/schemas on npmjs.com
publish-ts: build-ts
npm run publish-ts-lib
## Bundle and merge OpenAPI specifications into _openapi_build/
bundle-openapi: dep-check
node build/bundle-openapi.js
## Generate Golang Models (requires bundle-openapi)
generate-golang: bundle-openapi
node build/generate-golang.js
## Generate RTK Query clients (requires bundle-openapi)
generate-rtk: bundle-openapi
node build/generate-rtk.js
## Generate Golang Models (legacy alias for generate-golang)
golang-generate: generate-golang
#-----------------------------------------------------------------------------
# Permissions
#-----------------------------------------------------------------------------
.PHONY: generate-permissions generate-permissions-go generate-permissions-ts test-golang
## Generate Go permission key constants from permissions.csv
generate-permissions-go:
node build/generate-permission-golang.js
## Generate TypeScript permission key constants from permissions.csv
generate-permissions-ts:
node build/generate-permissions-ts.js
## Generate both Go and TypeScript permission key constants
generate-permissions: generate-permissions-go generate-permissions-ts
## Run Go tests
test-golang:
go build ./...
go test ./... -v
## Lint check Meshery Server.
golangci: dep-check
golangci-lint run
## Validate schema design rules (Dual-Schema Pattern, additionalProperties)
validate-schemas:
node build/validate-schemas.js
## Generate and bundle schema package (bundles OpenAPI, generates Go, RTK, TypeScript, and permissions)
build: validate-schemas bundle-openapi generate-golang generate-rtk generate-ts generate-permissions build-ts test-golang
#-----------------------------------------------------------------------------
# Dependencies
#-----------------------------------------------------------------------------
.PHONY: dep-check
#.SILENT: dep-check
INSTALLED_GO_VERSION = $(shell go version)
## Check local system for required dependencies
dep-check:
# golang
ifeq (,$(findstring $(GOVERSION), $(INSTALLED_GO_VERSION)))
# Only send a warning.
@echo "Dependency missing: go$(GOVERSION). Ensure 'go$(GOVERSION).x' is installed and available in your 'PATH'"
@echo "GOVERSION: " $(GOVERSION)
@echo "INSTALLED_GO_VERSION: " $(INSTALLED_GO_VERSION)
# Force error and stop.
# $(error Found $(INSTALLED_GO_VERSION). \
# Required golang version is: 'go$(GOVERSION).x'. \
# Ensure go '$(GOVERSION).x' is installed and available in your 'PATH'.)
endif
# redocly cli
ifeq (,$(shell command -v redocly))
@echo "Dependency missing: redocly. Install redocly cli from https://redoc.ly/docs/cli/installation/"
@echo "installing redocly"
npm install -g @redocly/cli
endif
# oapi-codegen
ifeq (,$(shell command -v oapi-codegen))
@echo "Dependency missing: oapi-codegen. Install oapi-codegen"
@echo "installing oapi-codegen"
# for the binary install
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@latest
endif