forked from lthn/blockchain
Update Go SDK build process and package config
Enhances the Go SDK Makefile target to fix import paths in generated files and sets the correct Go module path. Updates go.json to use 'utils/sdk/client/go' for package, API, and model paths, and adds additional OpenAPI generator properties.
This commit is contained in:
parent
2852702a4b
commit
7a751142e8
2 changed files with 16 additions and 9 deletions
|
|
@ -17,7 +17,11 @@ POST_BUILD_HOOK = @true
|
||||||
echo "go.sum" >> $(BUILD_DIR)/go/.openapi-generator-ignore
|
echo "go.sum" >> $(BUILD_DIR)/go/.openapi-generator-ignore
|
||||||
|
|
||||||
# For the 'go' target, define specific post-build steps.
|
# For the 'go' target, define specific post-build steps.
|
||||||
go: POST_BUILD_HOOK = (cd $(BUILD_DIR)/go && go mod edit -module github.com/letheanVPN/blockchain/utils/sdk/client/go && go mod tidy)
|
go: POST_BUILD_HOOK = @echo "--> Setting Go module path..."; \
|
||||||
|
echo "--> Fixing import paths in generated Go files..."; \
|
||||||
|
find "$(BUILD_DIR)/go" -type f -name '*.go' -exec sed -i '' 's|github.com/letheanVPN/blockchain/lthn|github.com/letheanVPN/blockchain/utils/sdk/client/go|g' {} +; \
|
||||||
|
find "$(BUILD_DIR)/go" -type f -name '*.md' -exec sed -i '' 's|github.com/letheanVPN/blockchain/lthn|github.com/letheanVPN/blockchain/utils/sdk/client/go|g' {} +; \
|
||||||
|
echo "--> Tidying Go module...";(cd $(BUILD_DIR)/go && go mod edit -module github.com/letheanVPN/blockchain/utils/sdk/client/go && go mod tidy)
|
||||||
|
|
||||||
# For the 'go' target, set the generator name correctly.
|
# For the 'go' target, set the generator name correctly.
|
||||||
go: GENERATOR_NAME=go
|
go: GENERATOR_NAME=go
|
||||||
|
|
@ -35,6 +39,7 @@ build: $(SDK_TARGETS)
|
||||||
$(SDK_TARGETS): %: packages/%.json
|
$(SDK_TARGETS): %: packages/%.json
|
||||||
# Default generator name is the target name itself.
|
# Default generator name is the target name itself.
|
||||||
$(eval GENERATOR_NAME = $@)
|
$(eval GENERATOR_NAME = $@)
|
||||||
|
rm -rf "$(BUILD_DIR)/$@"
|
||||||
# Ensure the output directory exists, cross-platform.
|
# Ensure the output directory exists, cross-platform.
|
||||||
@cmake -E make_directory "$(BUILD_DIR)/$@"
|
@cmake -E make_directory "$(BUILD_DIR)/$@"
|
||||||
@echo "--> Creating .openapi-generator-ignore file"
|
@echo "--> Creating .openapi-generator-ignore file"
|
||||||
|
|
@ -45,17 +50,16 @@ $(SDK_TARGETS): %: packages/%.json
|
||||||
@echo "--- Building package $@ with version $(PACKAGE_VERSION) ---"
|
@echo "--- Building package $@ with version $(PACKAGE_VERSION) ---"
|
||||||
# Run pre-build hook
|
# Run pre-build hook
|
||||||
$(PRE_BUILD_HOOK)
|
$(PRE_BUILD_HOOK)
|
||||||
rm -rf "$(BUILD_DIR)/$@/*"
|
|
||||||
export TS_POST_PROCESS_FILE="/usr/local/bin/prettier --write" && \
|
export TS_POST_PROCESS_FILE="/usr/local/bin/prettier --write" && \
|
||||||
openapi-generator generate --minimal-update --git-host "github.com" --git-repo-id "blockchain" --git-user-id "letheanVPN" \
|
openapi-generator generate --minimal-update --git-host "github.com" --git-repo-id "blockchain" --git-user-id "letheanVPN" \
|
||||||
-i "$(BASE_DIR)/spec/oas-3.0.0.json" --group-id "lthn" \
|
-i "$(BASE_DIR)/spec/oas-3.0.0.json" \
|
||||||
|
-p 'developerEmail=support@lt.hn,developerName=Lethean Community,developerOrganization=lethean,developerOrganizationUrl=https://lt.hn' \
|
||||||
|
-p "packageName=lthn,licenseName=EUPL-1.2" \
|
||||||
-g "$(GENERATOR_NAME)" \
|
-g "$(GENERATOR_NAME)" \
|
||||||
-o "$(BUILD_DIR)/$@" \
|
-o "$(BUILD_DIR)/$@" \
|
||||||
-c "$<" \
|
-c "$<" \
|
||||||
--artifact-version "$(PACKAGE_VERSION)" \
|
--artifact-version "$(PACKAGE_VERSION)"
|
||||||
--package-name "lthn"
|
|
||||||
# Run post-build hook
|
# Run post-build hook
|
||||||
@echo "--> Running Post Build..."
|
|
||||||
$(POST_BUILD_HOOK)
|
$(POST_BUILD_HOOK)
|
||||||
|
|
||||||
# Phony targets to avoid conflicts with file names and to ensure they always run.
|
# Phony targets to avoid conflicts with file names and to ensure they always run.
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
{
|
{
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
"packageName": "lthn",
|
"packageName": "utils/sdk/client/go",
|
||||||
"generateInterfaces": true,
|
"apiNameSuffix": "utils/sdk/client/go",
|
||||||
"isGoSubmodule": true
|
"apiPackage": "utils/sdk/client/go",
|
||||||
|
"modelPackage": "utils/sdk/client/go",
|
||||||
|
"isGoSubmodule": true,
|
||||||
|
"disallowAdditionalPropertiesIfNotPresent": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue