Skip to content

Commit 7cf712b

Browse files
authored
Merge pull request #57 from sklevenz/dev
Dev
2 parents 5750d9c + 88abd92 commit 7cf712b

File tree

14 files changed

+593
-271
lines changed

14 files changed

+593
-271
lines changed

Makefile

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
2-
.PHONY: help all lint lint-hard lint-bundle lint-bundle-hard docs bundle release release-list \
3-
bundle-vacuum bundle-redocly split-bundle mock dashboard dashboard-bundle \
4-
dashboard-hard dashboard-bundle-hard ignore-file upgrade
1+
SHELL := /usr/bin/env bash
2+
3+
SCRIPTS_DIR := ./scripts
4+
GEN_DIR := ./gen
5+
DOCS_DIR := ./docs
6+
7+
.PHONY: \
8+
help all upgrade \
9+
lint lint-hard lint-bundle lint-bundle-hard \
10+
bundle bundle-vacuum bundle-redocly split-bundle \
11+
docs \
12+
mock \
13+
dashboard dashboard-hard dashboard-bundle dashboard-bundle-hard \
14+
ignore-file \
15+
release release-list next-version
516

617
help:
718
@echo "Available targets:"
@@ -17,13 +28,13 @@ help:
1728
@echo " make lint-bundle-hard - Run Vacuum linter in hard mode on bundled spec (./gen/openapi.yaml)"
1829
@echo ""
1930
@echo "Bundling and splitting:"
20-
@echo " make bundle - Bundle OpenAPI spec using Vacuum"
21-
@echo " make bundle-vacuum - Bundle OpenAPI spec using Vacuum (known issues with securityScheme)"
31+
@echo " make bundle - Bundle OpenAPI spec using Redocly"
32+
@echo " make bundle-vacuum - Bundle OpenAPI spec using Vacuum (known issues with securitySchemes)"
2233
@echo " make bundle-redocly - Bundle OpenAPI spec using Redocly"
2334
@echo " make split-bundle - Split bundled spec into file structure (./spec)"
2435
@echo ""
2536
@echo "Documentation:"
26-
@echo " make docs - Generate HTML documentation using Redocly (./docs/index.html)"
37+
@echo " make docs - Generate versioned HTML docs + index (./docs/index.html)"
2738
@echo ""
2839
@echo "Mock:"
2940
@echo " make mock - Start local Prism mock server"
@@ -41,59 +52,63 @@ help:
4152
@echo "Releasing:"
4253
@echo " make release - Release on github"
4354
@echo " make release-list - List available releases"
55+
@echo " make next-version - Set next version"
4456

4557

46-
all: upgrade lint bundle docs
58+
all: upgrade lint bundle docs2
4759

4860
upgrade:
49-
@./scripts/upgrade.sh
61+
@$(SCRIPTS_DIR)/upgrade.sh
5062

5163
lint:
52-
@./scripts/lint.sh source standard
64+
@$(SCRIPTS_DIR)/lint.sh source standard
5365

5466
lint-hard:
55-
@./scripts/lint.sh source hard
67+
@$(SCRIPTS_DIR)/lint.sh source hard
5668

5769
lint-bundle:
58-
@./scripts/lint.sh bundle standard
70+
@$(SCRIPTS_DIR)/lint.sh bundle standard
5971

6072
lint-bundle-hard:
61-
@./scripts/lint.sh bundle hard
73+
@$(SCRIPTS_DIR)/lint.sh bundle hard
6274

6375
docs:
64-
@./scripts/docs.sh
76+
@$(SCRIPTS_DIR)/docs.sh
6577

66-
bundle: bundle-redocly # change to vacuum as soon as securitySchemes gets rendered correctly
78+
bundle: bundle-redocly # TODO switch default to Vacuum once securitySchemes render correctly
6779

6880
bundle-vacuum:
69-
@./scripts/bundle-vacuum.sh
81+
@$(SCRIPTS_DIR)/bundle-vacuum.sh
7082

7183
bundle-redocly:
72-
@./scripts/bundle-redocly.sh
84+
@$(SCRIPTS_DIR)/bundle-redocly.sh
7385

7486
split-bundle:
75-
@./scripts/split-bundle.sh
87+
@$(SCRIPTS_DIR)/split-bundle.sh
7688

7789
mock:
78-
@./scripts/mock.sh
90+
@$(SCRIPTS_DIR)/mock.sh
7991

8092
dashboard:
81-
@./scripts/dashboard.sh source standard
93+
@$(SCRIPTS_DIR)/dashboard.sh source standard
8294

8395
dashboard-hard:
84-
@./scripts/dashboard.sh source hard
96+
@$(SCRIPTS_DIR)/dashboard.sh source hard
8597

8698
dashboard-bundle:
87-
@./scripts/dashboard.sh bundle standard
99+
@$(SCRIPTS_DIR)/dashboard.sh bundle standard
88100

89101
dashboard-bundle-hard:
90-
@./scripts/dashboard.sh bundle hard
102+
@$(SCRIPTS_DIR)/dashboard.sh bundle hard
91103

92104
ignore-file:
93-
@./scripts/ignore-file.sh
105+
@$(SCRIPTS_DIR)/ignore-file.sh
106+
107+
release-list:
108+
@$(SCRIPTS_DIR)/release-list.sh
94109

95-
release-list:
96-
@gh release list
110+
release: lint bundle docs
111+
@$(SCRIPTS_DIR)/release.sh
97112

98-
release: bundle docs
99-
@./scripts/release.sh
113+
next-version: release-list
114+
@$(SCRIPTS_DIR)/next-version.sh

scripts/bundle-redocly.sh

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,33 @@
11
#!/usr/bin/env bash
22

3-
# Bundle OpenAPI specification using Redocly
3+
set -euo pipefail
44

5-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
# Bundle the OpenAPI specification using Redocly.
6+
# Requirements: node, npx
7+
# Output: ${BUNDLE_FILE}
8+
9+
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
610
# shellcheck source=lib.sh
7-
source "${SCRIPT_DIR}/lib.sh"
11+
source "${script_dir}/lib.sh"
812
init_common_paths
913

10-
print_step "Bundling OpenAPI specification using Redocly"
14+
if ! command -v npx >/dev/null 2>&1; then
15+
fail "npx is required to run redocly bundle"
16+
fi
17+
18+
main() {
19+
print_step "Bundling OpenAPI specification using Redocly"
20+
21+
require_file "${SPEC_FILE}"
22+
ensure_dir "${GEN_DIR}"
1123

12-
require_file "${SPEC_FILE}"
13-
ensure_dir "${GEN_DIR}"
24+
run "Running redocly bundle" \
25+
npx --yes @redocly/cli bundle "${SPEC_FILE}" -o "${BUNDLE_FILE}"
1426

15-
run "Running redocly bundle" \
16-
npx redocly bundle "${SPEC_FILE}" -o "${BUNDLE_FILE}"
27+
echo ""
28+
echo "Bundling completed"
29+
echo " Output: ${BUNDLE_FILE}"
30+
echo ""
31+
}
1732

18-
echo ""
19-
echo "Bundling completed"
20-
echo " Output: ${BUNDLE_FILE}"
21-
echo ""
33+
main "$@"

scripts/bundle-vacuum.sh

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,38 @@
11
#!/usr/bin/env bash
22

3-
# Bundle OpenAPI specification using Vacuum
3+
set -euo pipefail
44

5-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
# Bundle the OpenAPI specification using Vacuum.
6+
# Requirements: node, npx
7+
# Output: ${BUNDLE_FILE}
8+
9+
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
610
# shellcheck source=lib.sh
7-
source "${SCRIPT_DIR}/lib.sh"
11+
source "${script_dir}/lib.sh"
812

913
init_common_paths
1014

11-
print_step "Bundling OpenAPI specification using Vacuum"
15+
if ! command -v npx >/dev/null 2>&1; then
16+
fail "npx is required to run vacuum bundle"
17+
fi
18+
19+
main() {
20+
print_step "Bundling OpenAPI specification using Vacuum"
21+
22+
require_file "${SPEC_FILE}"
23+
ensure_dir "${GEN_DIR}"
1224

13-
require_file "${SPEC_FILE}"
14-
ensure_dir "${GEN_DIR}"
25+
run "Running vacuum bundle" \
26+
npx --yes vacuum bundle "${SPEC_FILE}" "${BUNDLE_FILE}" --base "${SPEC_DIR}"
1527

16-
run "Running vacuum bundle" \
17-
npx vacuum bundle "${SPEC_FILE}" "${BUNDLE_FILE}" --base "${SPEC_DIR}"
28+
echo ""
29+
echo "Bundling completed"
30+
echo " Output: ${BUNDLE_FILE}"
31+
echo ""
32+
echo "Warning"
33+
echo " Vacuum may not render securitySchemes correctly"
34+
echo " Use only if Vacuum version is newer than 0.23.0"
35+
echo ""
36+
}
1837

19-
echo ""
20-
echo "Bundling completed"
21-
echo " Output: ${BUNDLE_FILE}"
22-
echo ""
23-
echo "Warning"
24-
echo " Vacuum does not render securitySchemes correctly"
25-
echo " Use only if Vacuum version is newer than 0.23.0"
26-
echo ""
38+
main "$@"

scripts/dashboard.sh

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,57 @@
11
#!/usr/bin/env bash
22

3-
# Start Vacuum dashboard for source or bundled spec
3+
set -euo pipefail
44

5-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
# Start Vacuum dashboard for the source or bundled specification.
6+
# Usage: ./dashboard.sh [source|bundle] [standard|hard]
7+
# Requirements: node, npx
8+
9+
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
610
# shellcheck source=lib.sh
7-
source "${SCRIPT_DIR}/lib.sh"
11+
source "${script_dir}/lib.sh"
812
init_common_paths
913

10-
scope="${1:-source}"
11-
mode="${2:-standard}"
12-
13-
spec_path="${SPEC_FILE}"
14-
label="source spec"
15-
16-
if [[ "${scope}" == "bundle" ]]; then
17-
spec_path="${BUNDLE_FILE}"
18-
label="bundled spec"
14+
if ! command -v npx >/dev/null 2>&1; then
15+
fail "npx is required to run vacuum dashboard"
1916
fi
2017

21-
print_step "Starting Vacuum dashboard on ${label}"
22-
echo " Mode: ${mode}"
23-
echo ""
24-
25-
require_file "${spec_path}"
26-
27-
if [[ "${mode}" == "hard" ]]; then
28-
run "vacuum dashboard" npx vacuum dashboard "${spec_path}" --ignore-file "${VACUUM_IGNORE}" --hard-mode --watch
29-
else
30-
run "vacuum dashboard" npx vacuum dashboard "${spec_path}" --ruleset="${VACUUM_RULESET}" --ignore-file "${VACUUM_IGNORE}" --watch
31-
fi
18+
main() {
19+
local scope="${1:-source}"
20+
local mode="${2:-standard}"
21+
22+
local spec_path="${SPEC_FILE}"
23+
local label="source spec"
24+
25+
if [[ "${scope}" == "bundle" ]]; then
26+
spec_path="${BUNDLE_FILE}"
27+
label="bundled spec"
28+
elif [[ "${scope}" != "source" ]]; then
29+
fail "Invalid scope: ${scope} (expected: source or bundle)"
30+
fi
31+
32+
if [[ "${mode}" != "standard" && "${mode}" != "hard" ]]; then
33+
fail "Invalid mode: ${mode} (expected: standard or hard)"
34+
fi
35+
36+
print_step "Starting Vacuum dashboard on ${label}"
37+
echo " Mode: ${mode}"
38+
echo ""
39+
40+
require_file "${spec_path}"
41+
42+
if [[ "${mode}" == "hard" ]]; then
43+
run "vacuum dashboard" \
44+
npx --yes vacuum dashboard "${spec_path}" \
45+
--ignore-file "${VACUUM_IGNORE}" \
46+
--hard-mode \
47+
--watch
48+
else
49+
run "vacuum dashboard" \
50+
npx --yes vacuum dashboard "${spec_path}" \
51+
--ruleset="${VACUUM_RULESET}" \
52+
--ignore-file "${VACUUM_IGNORE}" \
53+
--watch
54+
fi
55+
}
56+
57+
main "$@"

0 commit comments

Comments
 (0)