forked from gardener/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
161 lines (144 loc) · 5.81 KB
/
Makefile
File metadata and controls
161 lines (144 loc) · 5.81 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# SPDX-FileCopyrightText: 2018 SAP SE or an SAP affiliate company and Gardener contributors
#
# SPDX-License-Identifier: Apache-2.0
.PHONY: docforge-download
docforge-download: ## Download the appropriate docforge binary for the current OS if not present
@echo "Creating bin directory if it doesn't exist..."
@mkdir -p bin
@echo "Detecting OS and architecture..."
@if [ "$$(uname)" = "Darwin" ]; then \
if [ "$$(uname -m)" = "arm64" ]; then \
if [ -f bin/docforge ] && [ -x bin/docforge ]; then \
echo "Docforge for macOS ARM64 already exists and is executable."; \
else \
echo "Downloading docforge for macOS ARM64..."; \
curl -L -o bin/docforge https://github.com/gardener/docforge/releases/download/v0.55.0/docforge-darwin-arm64; \
echo "Making docforge executable..."; \
chmod +x bin/docforge; \
echo "Docforge binary downloaded and is ready to use."; \
fi; \
else \
if [ -f bin/docforge ] && [ -x bin/docforge ]; then \
echo "Docforge for macOS AMD64 already exists and is executable."; \
else \
echo "Downloading docforge for macOS AMD64..."; \
curl -L -o bin/docforge https://github.com/gardener/docforge/releases/download/v0.55.0/docforge-darwin-amd64; \
echo "Making docforge executable..."; \
chmod +x bin/docforge; \
echo "Docforge binary downloaded and is ready to use."; \
fi; \
fi; \
elif [ "$$(uname)" = "Linux" ]; then \
if [ "$$(uname -m)" = "aarch64" ] || [ "$$(uname -m)" = "arm64" ]; then \
if [ -f bin/docforge ] && [ -x bin/docforge ]; then \
echo "Docforge for Linux ARM64 already exists and is executable."; \
else \
echo "Downloading docforge for Linux ARM64..."; \
curl -L -o bin/docforge https://github.com/gardener/docforge/releases/download/v0.55.0/docforge-linux-arm64; \
echo "Making docforge executable..."; \
chmod +x bin/docforge; \
echo "Docforge binary downloaded and is ready to use."; \
fi; \
else \
if [ -f bin/docforge ] && [ -x bin/docforge ]; then \
echo "Docforge for Linux AMD64 already exists and is executable."; \
else \
echo "Downloading docforge for Linux AMD64..."; \
curl -L -o bin/docforge https://github.com/gardener/docforge/releases/download/v0.55.0/docforge-linux-amd64; \
echo "Making docforge executable..."; \
chmod +x bin/docforge; \
echo "Docforge binary downloaded and is ready to use."; \
fi; \
fi; \
elif [[ "$$(uname -s)" == MINGW* ]] || [[ "$$(uname -s)" == CYGWIN* ]]; then \
if [ -f bin/docforge.exe ]; then \
echo "Docforge for Windows already exists."; \
else \
echo "Downloading docforge for Windows..."; \
curl -L -o bin/docforge.exe https://github.com/gardener/docforge/releases/download/v0.55.0/docforge-windows-386.exe; \
echo "Docforge binary downloaded and is ready to use."; \
fi; \
else \
echo "Unsupported OS. Please download docforge manually from https://github.com/gardener/docforge/releases"; \
exit 1; \
fi
.PHONY: docforge-run
docforge-run: docforge-download ## Check environment and run docforge with custom parameters
@echo "Checking environment variables for docforge..."
@if [ -z "$$DOCFORGE_CONFIG" ]; then \
echo "ERROR: DOCFORGE_CONFIG environment variable is not set."; \
echo "Please add the following to your ~/.bashrc or ~/.zshrc:"; \
echo " export DOCFORGE_CONFIG=.docforge/config.yaml"; \
echo "Then run: source ~/.bashrc (or ~/.zshrc)"; \
exit 1; \
fi
@if [ -z "$$GITHUB_OAUTH_TOKEN" ]; then \
echo "ERROR: GITHUB_OAUTH_TOKEN environment variable is not set."; \
echo "Please create a token (see docs/resources/github-token-guide.md)"; \
echo "Then add it to your ~/.bashrc or ~/.zshrc:"; \
echo " export GITHUB_OAUTH_TOKEN=your_token"; \
echo "Then run: source ~/.bashrc (or ~/.zshrc)"; \
exit 1; \
fi
@echo "Environment check passed:"
@if [ -d "content" ]; then \
read -p "Content directory already exists. Do you want to run docforge again to update it? (y/n): " confirm; \
if [ "$$confirm" = "y" ] || [ "$$confirm" = "Y" ]; then \
echo "Running docforge..."; \
./bin/docforge; \
else \
echo "Skipping docforge execution."; \
fi; \
else \
echo "Content directory does not exist. Running docforge..."; \
./bin/docforge; \
fi
.PHONY: docker-preview
docker-preview:
@chmod +x hack/preview.sh
@hack/preview.sh
.PHONY: install
install: ## Install npm dependencies
npm ci
.PHONY: dev
dev:
npx vitepress dev
.PHONY: local-preview
local-preview:
docforge-ci install post-process npx vitepress preview
.PHONY: post-processing-part-1
post-processing-part-1:
node post-processing/part-1.js --rename-images --add-h1-title --youtube --fix-titles --fix-network-doc --add-missing-index
.PHONY: post-processing-part-2
post-processing-part-2:
node post-processing/part-2.js --migrate-alerts --clean-layouts --flatten-single-dirs --add-navigation-frontmatter
.PHONY: post-processing-part-index
post-processing-part-index:
node post-processing/part-index.js ./hugo/content
.PHONY: post-processing-part-3
post-processing-part-3:
node post-processing/part-3.js --add-empty-metadata --update-report-link --process-api-html
.PHONY: post-process
post-process: ## Run post-processing scripts
@$(MAKE) post-processing-part-1
@$(MAKE) post-processing-part-2
@$(MAKE) post-processing-part-index
@$(MAKE) post-processing-part-3
.PHONY: build
build: ## Build the documentation site
VITE_PUBLIC_BASE_PATH='' npx vitepress build
.PHONY: test
test: ## Run tests
npx vitest run
.PHONY: test-watch
test-watch:
npx vitest
.PHONY: docforge-ci
docforge-ci: docforge-download ## Run docforge in CI mode (non-interactive)
@echo "Running docforge (CI)..."
@export DOCFORGE_CONFIG=.docforge/config.yaml && \
./bin/docforge
.PHONY: ci-build
ci-build: docforge-ci install post-process build ## Run all steps for building in CI
.PHONY: ci-test
ci-test: docforge-ci install post-process test ## Run all steps for testing in CI