Files
asconnect-service/Makefile
T

154 lines
5.0 KiB
Makefile
Raw Normal View History

2025-10-07 23:20:01 +00:00
## ===------------------------------------------------------------------------------------===
##
## This source file is part of the App Store Connect Service open source project
##
2026-03-26 01:07:23 +00:00
## Copyright (c) 2026 Röck+Cöde VoF. and the App Store Connect Service project authors
2025-10-07 23:20:01 +00:00
## Licensed under Apache license v2.0
##
## See LICENSE for license information
## See CONTRIBUTORS for the list of App Store Connect Service project authors
##
## SPDX-License-Identifier: Apache-2.0
##
## ===------------------------------------------------------------------------------------===
2025-10-05 23:16:54 +00:00
# ENVIRONMENT VARIABLES
environment ?= .env
include $(environment)
export $(shell sed 's/=.*//' $(environment))
# Uses the DocC executable from Xcode's default toolchain, as some Swift toolchains (e.g. 6.4.0) ship an x86_64-only one.
DOCC_EXEC ?= $(shell xcrun --toolchain com.apple.dt.toolchain.XcodeDefault --find docc 2>/dev/null)
export DOCC_EXEC
2025-10-05 23:16:54 +00:00
# LIBRARY
lib-build: ## Builds the library
@swift build
lib-release: ## Releases the library
@swift build -c release
lib-test: ## Runs the unit tests for the library
@swift test \
--disable-xctest \
--enable-code-coverage \
--enable-swift-testing \
--parallel
# SWIFT PACKAGE MANAGER
pkg-clean: ## Deletes built SPM artifacts of the package
@swift package clean
pkg-reset: ## Resets the complete SPM cache/build folder of the package
@swift package reset
pkg-pristine: pkg-clean pkg-reset ## Deletes all built artifacts, caches, and documentations of the package
@rm -drf $(DOCC_ARCHIVE_OUTPUT)
@rm -drf $(DOCC_GITHUB_OUTPUT)
pkg-outdated: ## Lists the SPM package dependencies that can be updated
@swift package update --dry-run
pkg-update: ## Updates the SPM package dependencies
@swift package update
# DOCUMENTATION
doc-generate: doc-generate-archive doc-generate-github ## Generates the library documentation for both Github and Xcode
doc-generate-archive: ## Generates the library documentation archive for Xcode
@ENABLE_DOCC_PLUGIN=1 swift package \
2025-10-05 23:16:54 +00:00
--allow-writing-to-directory $(DOCC_ARCHIVE_OUTPUT) \
generate-documentation \
--target $(SPM_LIBRARY_TARGET) \
--include-extended-types \
--enable-inherited-docs \
--output-path $(DOCC_ARCHIVE_OUTPUT)
doc-generate-github: ## Generates the library documentation for Github
@ENABLE_DOCC_PLUGIN=1 swift package \
2025-10-05 23:16:54 +00:00
--allow-writing-to-directory $(DOCC_GITHUB_OUTPUT) \
generate-documentation \
--target $(SPM_LIBRARY_TARGET) \
--disable-indexing \
--transform-for-static-hosting \
--include-extended-types \
--enable-inherited-docs \
--hosting-base-path $(DOCC_GITHUB_BASE_PATH) \
--output-path $(DOCC_GITHUB_OUTPUT)
doc-check: ## Checks the DocC catalog covers every generated operation and schema
@python3 -I Scripts/check-docc.py "$(OAS_GENERATE_OUTPUT)" "$(DOCC_CATALOG)"
2025-10-05 23:16:54 +00:00
doc-preview: ## Previews the library documentation in Safari
@open -a safari $(DOCC_PREVIEW_URL)
@ENABLE_DOCC_PLUGIN=1 swift package \
2025-10-05 23:16:54 +00:00
--disable-sandbox \
preview-documentation \
--target $(SPM_LIBRARY_TARGET) \
--include-extended-types \
--enable-inherited-docs
2026-03-26 01:07:23 +00:00
# OPEN API SPECIFICATION
oas-download: ## Downloads the latest App Store Connect OpenAPI specification document
@mkdir -p $(OAS_DOWNLOAD_FOLDER)
@curl -fsSL \
"$(OAS_DOWNLOAD_URL)" \
-o "$(OAS_DOWNLOAD_INPUT)"
@unzip -q "$(OAS_DOWNLOAD_INPUT)" -d "$(OAS_DOWNLOAD_FOLDER)"
@mv "$(OAS_DOWNLOAD_FILE)" "$(OAS_DOWNLOAD_OUTPUT)"
@rm -rf "$(OAS_DOWNLOAD_FOLDER)"
@# Generating the code also validates the document.
@$(MAKE) --no-print-directory oas-patch-document
@$(MAKE) --no-print-directory oas-generate
@$(MAKE) --no-print-directory doc-check
oas-patch: oas-patch-document oas-validate # Patches and validates the OpenAPI specification document
oas-patch-document: # Patches the OpenAPI specification document with Scripts/patch-oas.jq
@jq --from-file Scripts/patch-oas.jq "$(OAS_DOWNLOAD_OUTPUT)" > "$(OAS_DOWNLOAD_OUTPUT).tmp"
@mv "$(OAS_DOWNLOAD_OUTPUT).tmp" "$(OAS_DOWNLOAD_OUTPUT)"
oas-validate: ## Validates the OpenAPI specification document
@swift run \
--configuration release \
--package-path "$(OAS_GENERATE_TOOLS)" \
swift-openapi-generator generate \
--config "$(OAS_GENERATE_CONFIG)" \
--dry-run \
"$(OAS_DOWNLOAD_OUTPUT)"
oas-generate: ## Generates the library source code from the OpenAPI specification document
@mkdir -p "$(OAS_GENERATE_OUTPUT)"
@swift run \
--configuration release \
--package-path "$(OAS_GENERATE_TOOLS)" \
swift-openapi-generator generate \
--config "$(OAS_GENERATE_CONFIG)" \
--output-directory "$(OAS_GENERATE_OUTPUT)" \
"$(OAS_DOWNLOAD_OUTPUT)"
2026-03-26 01:07:23 +00:00
2025-10-05 23:16:54 +00:00
# IDE
ide-xcode: ## Opens this package with Xcode
@open -a Xcode Package.swift
ide-vscode: ## Opens this package with Visual Studio Code
@code .
# HELP
# Output the documentation for each of the defined tasks when `help` is called.
# Reference: https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help
help: ## Prints the written documentation for all the defined tasks
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help