From 7b30bc234df6c6b6c59b5def3acb23a9d70f9fef Mon Sep 17 00:00:00 2001 From: Mykola Fant Date: Tue, 26 Nov 2024 16:18:53 +0200 Subject: [PATCH] dynamically rewrite collided versions --- .github/actions/validate/action.yml | 2 +- check-links-playbook.yml | 410 +++++++++++++++++++++++++++ hazelcast-docs/antora-playbook.yml | 413 ++++++++++++++++++++++++++++ lib/load-check-links-playbook.js | 153 ++++++++--- load-check-links-playbook.js | 142 ++++++++++ package.json | 1 - 6 files changed, 1074 insertions(+), 47 deletions(-) create mode 100644 check-links-playbook.yml create mode 100644 hazelcast-docs/antora-playbook.yml create mode 100644 load-check-links-playbook.js diff --git a/.github/actions/validate/action.yml b/.github/actions/validate/action.yml index 3ee5c35b..fbd25c3e 100644 --- a/.github/actions/validate/action.yml +++ b/.github/actions/validate/action.yml @@ -25,6 +25,6 @@ runs: run: | cp "./hazelcast-docs/lib/load-check-links-playbook.js" "./load-check-links-playbook.js" npm i - npm i -D yaml@2.6.0 @jcahills/antora-link-checker@1.0.1 + npm i -D yaml@2.6.0 @jcahills/antora-link-checker@1.0.1 matcher@3.0.0 node load-check-links-playbook.js $GITHUB_REPOSITORY $GITHUB_BASE_REF ./node_modules/.bin/antora --fetch --to-dir test --log-level=error --log-failure-level=error --extension=@jcahills/antora-link-checker check-links-playbook.yml diff --git a/check-links-playbook.yml b/check-links-playbook.yml new file mode 100644 index 00000000..fbc1229d --- /dev/null +++ b/check-links-playbook.yml @@ -0,0 +1,410 @@ +site: + title: Documentation + start_page: home::index.adoc + url: https://docs.hazelcast.com + keys: + google_analytics: GTM-MQ59XD6 + docsearch_id: QK2EAH8GB0 + docsearch_api: ef7bd9485eafbd75d6e8425949eda1f5 + docsearch_index: prod_hazelcast_docs + ai_search_id: 6b326171-dd1e-40c6-a948-1f9bb6c0ed52 +urls: + html_extension_style: drop +content: + sources: + - url: . + branches: HEAD + start_path: docs + - url: https://github.com/hazelcast/hazelcast-docs + start_paths: + - home + - tutorials + - templates + branches: HEAD + - url: https://github.com/hazelcast/hz-docs + branches: + - main + - v/* + start_path: docs + - url: https://github.com/hazelcast/hz-flow-docs + branches: + - main + - "!mai" + start_path: docs + - url: https://github.com/hazelcast/imdg-docs + branches: + - v/* + start_path: docs + - url: https://github.com/hazelcast/imdg-docs + branches: + - archived-versions + start_paths: docs/* + - url: https://github.com/hazelcast/management-center-docs + branches: + - main + - v/* + start_path: docs + - url: https://github.com/hazelcast/management-center-docs + branches: + - archived-versions + start_paths: docs/* + - url: https://github.com/hazelcast/clc-docs + branches: + - v/* + start_path: docs + - url: https://github.com/hazelcast/hazelcast-platform-operator-docs + branches: + - main + - v/* + start_path: docs + - url: https://github.com/hazelcast-guides/user-code-namespaces + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/cpsubsystem + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/stream-processing-fundamentals + branches: main + start_path: docs + - url: https://github.com/hazelcast-guides/airline-connections + branches: main + start_path: docs + - url: https://github.com/hazelcast-guides/Generating-Data-using-SQL + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/sql_stock_ticker_cloud + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/Stream-Processing-Intro + branches: master + start_path: docs + - url: https://github.com/hazelcast/cloud-docs + branches: + - main + start_paths: + - docs + - tutorials + - url: https://github.com/hazelcast-guides/client-failover + branches: master + start_paths: docs + - url: https://github.com/hazelcast-guides/spring-boot-sample + branches: master + start_paths: docs + - url: https://github.com/hazelcast-guides/serverless-fraud-detection + branches: master + start_paths: docs + - url: https://github.com/hazelcast-guides/write-through-cache-mongodb-mapstore + branches: master + start_paths: docs + - url: https://github.com/hazelcast-guides/standard-deviation-parallel-processing + branches: master + start_paths: docs + - url: https://github.com/hazelcast-guides/stream-to-stream-joins + branches: master + start_paths: docs + - url: https://github.com/hazelcast/hazelcast-cloud-maven-plugin + branches: main + start_path: docs + - url: https://github.com/hazelcast-guides/caching-springboot-jcache + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-embedded-springboot + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/springboot-hibernate + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hibernate-jcache + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/istio + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/caching-micronaut + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes-embedded + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-embedded-microprofile + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-client-quarkus + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/springboot-webfilter-session-replication + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/caching-springboot + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/ecs-embedded + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/springboot-tomcat-session-replication + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/terraform-quickstarts + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes-external-client + branches: main + start_path: docs + - url: https://github.com/hazelcast-guides/active-directory-authentication + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes-sidecar + branches: main + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes-hpa + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes-ssl + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes-wan + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/spring-session-hazelcast + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/ec2-cluster + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/Hazelcast-Embedded-with-Eureka-discovery + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/linkerd + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/consul + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/openfaas-hz-client + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-expose-externally + branches: main + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-external-backup-restore + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-wan-replication + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-wan-sync + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-jet + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-jet-job-snapshot + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-tls + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-user-code-namespace + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kafka-kerberos + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/serverless-trade-monitor-dashboard + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/csharp-client-getting-started + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/python-client-getting-started + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/java-client-getting-started + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/nodejs-client-getting-started + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/go-client-getting-started + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/cpp-client-getting-started + branches: master + start_path: docs +ui: + bundle: + url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip + snapshot: true + supplemental_files: + - path: netlify.toml + contents: | + [[headers]] + for = "/api/*" + [headers.values] + Access-Control-Allow-Origin = "*" + - path: ui.yml + contents: | + static_files: [ netlify.toml ] +antora: + extensions: + - require: "@djencks/antora-aggregate-collector" + trace: true + componentversions: + - name: management-center + version: 6.0-snapshot + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - "**/hazelcast/management-center" + branch: + includes: + - master + - name: hazelcast + version: 6.0-snapshot + mappings: + - module: maintain-cluster + family: attachment + origin: + url: + include: + - "**/hazelcast/hazelcast-mono" + branch: + includes: + - master + - name: management-center + version: "5.6" + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - "**/hazelcast/management-center" + branch: + includes: + - 5.6.0 + - name: management-center + version: "5.5" + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - "**/hazelcast/management-center" + branch: + includes: + - 5.5.2 + - name: hazelcast + version: "5.5" + mappings: + - module: maintain-cluster + family: attachment + origin: + url: + include: + - "**/hazelcast/hazelcast-mono" + branch: + includes: + - 5.5.z + - name: management-center + version: "5.4" + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - "**/hazelcast/management-center" + branch: + includes: + - 5.4.1 + - name: management-center + version: "5.3" + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - "**/hazelcast/management-center" + branch: + includes: + - 5.3.4 + - name: management-center + version: "5.2" + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - "**/hazelcast/management-center" + branch: + includes: + - 5.2.1 + - name: management-center + version: "5.1" + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - "**/hazelcast/management-center" + branch: + includes: + - 5.1.4 + - require: ./lib/api_json.js + tags: + - Favorites + - Videos + - Get Started + - Whitepapers + - Use cases + - Case studies + - Documentation + - Develop Applications + - Organizations and Accounts + - Manage Accounts + - Manage Organizations + - Manage Clusters + data: + - title: What is a client? + url: https://www.youtube.com/embed/lkQEAdgxvbE + type: video + order: 8 + tags: Videos, Get Started + - title: What is the Hazelcast Platform? + url: https://www.youtube.com/embed/UpIgHzKbMp0 + type: video + order: 9 + tags: Videos, Get Started +asciidoc: + attributes: + page-component-order: hazelcast, management-center, cloud, * + page-pagination: true@ + page-experimental: true + idprefix: "" + idseparator: "-" + imdg-javadoc: https://docs.hazelcast.org/docs/latest-dev/javadoc + imdg-samples: https://github.com/hazelcast/hazelcast-code-samples + imdg-core: https://github.com/hazelcast/hazelcast/tree/master/hazelcast/src/main/java/com/hazelcast + imdg-docs: https://docs.hazelcast.org/docs/latest/manual/html-single/index.html + imdg-ops-guide: https://hazelcast.com/resources/hazelcast-deployment-operations-guide/ + jet-docs: https://jet-start.sh/ + docs-archive: https://hazelcast.org/imdg/download/archives/ + hazelcast-cloud: Cloud + page-cloud-console: https://cloud.hazelcast.com/ + ucn: User Code Namespaces + ucd: User Code Deployment + extensions: + - ./lib/tabs-block.js + - ./lib/swagger-ui-block-macro.js + - asciidoctor-kroki diff --git a/hazelcast-docs/antora-playbook.yml b/hazelcast-docs/antora-playbook.yml new file mode 100644 index 00000000..e570a74a --- /dev/null +++ b/hazelcast-docs/antora-playbook.yml @@ -0,0 +1,413 @@ +site: + # https://docs.antora.org/antora/latest/playbook/set-up-playbook/#configure-your-sites-properties + title: Documentation + start_page: home::index.adoc + url: https://docs.hazelcast.com + keys: + google_analytics: 'GTM-MQ59XD6' + # The following 3 parameters: id, api and index are used for + # Algolia docsearch setup in the hazelcast-docs-ui repo + docsearch_id: 'QK2EAH8GB0' + docsearch_api: 'ef7bd9485eafbd75d6e8425949eda1f5' + docsearch_index: 'prod_hazelcast_docs' + # KapaAI Website ID + ai_search_id: '6b326171-dd1e-40c6-a948-1f9bb6c0ed52' +urls: + # https://docs.antora.org/antora/latest/playbook/urls-html-extension-style/ + html_extension_style: drop +content: + sources: + - url: . + start_paths: [home, tutorials, templates] + branches: HEAD + - url: https://github.com/hazelcast/hz-docs + branches: [main, v/*] + start_path: docs + - url: https://github.com/hazelcast/hz-flow-docs + branches: main + start_path: docs + - url: https://github.com/hazelcast/imdg-docs + branches: [v/*] + start_path: docs + - url: https://github.com/hazelcast/imdg-docs + branches: [archived-versions] + start_paths: docs/* + - url: https://github.com/hazelcast/management-center-docs + branches: [main, v/*] + start_path: docs + - url: https://github.com/hazelcast/management-center-docs + branches: [archived-versions] + start_paths: docs/* + - url: https://github.com/hazelcast/clc-docs + branches: [v/*] + start_path: docs + - url: https://github.com/hazelcast/hazelcast-platform-operator-docs + branches: [main, v/*] + start_path: docs + - url: https://github.com/hazelcast-guides/user-code-namespaces + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/cpsubsystem + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/stream-processing-fundamentals + branches: main + start_path: docs + - url: https://github.com/hazelcast-guides/airline-connections + branches: main + start_path: docs + - url: https://github.com/hazelcast-guides/Generating-Data-using-SQL + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/sql_stock_ticker_cloud + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/Stream-Processing-Intro + branches: master + start_path: docs + - url: https://github.com/hazelcast/cloud-docs + branches: [main] + start_paths: [docs, tutorials] + - url: https://github.com/hazelcast-guides/client-failover + branches: master + start_paths: docs + - url: https://github.com/hazelcast-guides/spring-boot-sample + branches: master + start_paths: docs + - url: https://github.com/hazelcast-guides/serverless-fraud-detection + branches: master + start_paths: docs + - url: https://github.com/hazelcast-guides/write-through-cache-mongodb-mapstore + branches: master + start_paths: docs + - url: https://github.com/hazelcast-guides/standard-deviation-parallel-processing + branches: master + start_paths: docs + - url: https://github.com/hazelcast-guides/stream-to-stream-joins + branches: master + start_paths: docs + - url: https://github.com/hazelcast/hazelcast-cloud-maven-plugin + branches: main + start_path: docs + - url: https://github.com/hazelcast-guides/caching-springboot-jcache + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-embedded-springboot + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/springboot-hibernate + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hibernate-jcache + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/istio + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/caching-micronaut + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes-embedded + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-embedded-microprofile + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-client-quarkus + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/springboot-webfilter-session-replication + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/caching-springboot + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/ecs-embedded + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/springboot-tomcat-session-replication + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/terraform-quickstarts + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes-external-client + branches: main + start_path: docs + - url: https://github.com/hazelcast-guides/active-directory-authentication + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes-sidecar + branches: main + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes-hpa + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes-ssl + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes-wan + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kubernetes + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/spring-session-hazelcast + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/ec2-cluster + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/Hazelcast-Embedded-with-Eureka-discovery + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/linkerd + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/consul + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/openfaas-hz-client + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-expose-externally + branches: main + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-external-backup-restore + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-wan-replication + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-wan-sync + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-jet + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-jet-job-snapshot + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-tls + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/hazelcast-platform-operator-user-code-namespace + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/kafka-kerberos + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/serverless-trade-monitor-dashboard + branches: master + start_path: docs + - url: https://github.com/hazelcast/hazelcast-mono + branches: [master, 5.5.z] + start_path: docs/rest + - url: https://github.com/hazelcast/management-center + branches: [master, 5.4.1, 5.5.2, 5.6.0] + start_path: hazelcast-management-center/src/openapi/external + - url: https://github.com/hazelcast/management-center + branches: [5.1.4, 5.2.1, 5.3.4] + start_path: openapi/external + - url: https://github.com/hazelcast-guides/csharp-client-getting-started + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/python-client-getting-started + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/java-client-getting-started + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/nodejs-client-getting-started + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/go-client-getting-started + branches: master + start_path: docs + - url: https://github.com/hazelcast-guides/cpp-client-getting-started + branches: master + start_path: docs +ui: + bundle: + url: https://github.com/hazelcast/hazelcast-docs-ui/releases/latest/download/ui-bundle.zip + # https://docs.antora.org/antora/latest/playbook/set-up-playbook/#configure-your-sites-ui-bundle + # When snapshot is set to true, Antora will download the UI bundle + # whenever fetch is activated in the playbook or from the CLI. + snapshot: true + # Needed for API calls from Cloud Web App (Learning Centre page) + supplemental_files: + - path: netlify.toml + contents: | + [[headers]] + for = "/api/*" + [headers.values] + Access-Control-Allow-Origin = "*" + - path: ui.yml + contents: | + static_files: [ netlify.toml ] +antora: + extensions: + - require: '@djencks/antora-aggregate-collector' + trace: true + componentversions: + - name: management-center + version: '6.0-snapshot' + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - '**/hazelcast/management-center' + branch: + includes: + - 'master' + - name: hazelcast + version: '6.0-snapshot' + mappings: + - module: maintain-cluster + family: attachment + origin: + url: + include: + - '**/hazelcast/hazelcast-mono' + branch: + includes: + - 'master' + - name: management-center + version: '5.6' + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - '**/hazelcast/management-center' + branch: + includes: + - '5.6.0' + - name: management-center + version: '5.5' + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - '**/hazelcast/management-center' + branch: + includes: + - '5.5.2' + - name: hazelcast + version: '5.5' + mappings: + - module: maintain-cluster + family: attachment + origin: + url: + include: + - '**/hazelcast/hazelcast-mono' + branch: + includes: + - '5.5.z' + - name: management-center + version: '5.4' + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - '**/hazelcast/management-center' + branch: + includes: + - '5.4.1' + - name: management-center + version: '5.3' + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - '**/hazelcast/management-center' + branch: + includes: + - '5.3.4' + - name: management-center + version: '5.2' + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - '**/hazelcast/management-center' + branch: + includes: + - '5.2.1' + - name: management-center + version: '5.1' + mappings: + - module: integrate + family: attachment + origin: + url: + include: + - '**/hazelcast/management-center' + branch: + includes: + - '5.1.4' + - require: ./lib/api_json.js + tags: + - Favorites + - Videos + - Get Started + - Whitepapers + - Use cases + - Case studies + - Documentation + - Develop Applications + - Organizations and Accounts + - Manage Accounts + - Manage Organizations + - Manage Clusters + data: + - title: What is a client? + url: https://www.youtube.com/embed/lkQEAdgxvbE + type: video + order: 8 + tags: Videos, Get Started + - title: What is the Hazelcast Platform? + url: https://www.youtube.com/embed/UpIgHzKbMp0 + type: video + order: 9 + tags: Videos, Get Started +asciidoc: + attributes: + # Order the products in the version selector dropdown. + # Use * to list all remaining products in alphabetical order. + page-component-order: 'hazelcast, management-center, cloud, *' + # https://docs.antora.org/antora/latest/playbook/asciidoc-attributes/#precedence-rules + # page-pagination is soft-set to true + page-pagination: true@ + # Allows us to use UI macros. See https://docs.asciidoctor.org/asciidoc/latest/macros/ui-macros/ + page-experimental: true + # AsciiDoc ID settings https://docs.asciidoctor.org/asciidoc/latest/sections/id-prefix-and-separator/ + idprefix: '' + idseparator: '-' + imdg-javadoc: https://docs.hazelcast.org/docs/latest-dev/javadoc + imdg-samples: https://github.com/hazelcast/hazelcast-code-samples + imdg-core: https://github.com/hazelcast/hazelcast/tree/master/hazelcast/src/main/java/com/hazelcast + imdg-docs: https://docs.hazelcast.org/docs/latest/manual/html-single/index.html + imdg-ops-guide: https://hazelcast.com/resources/hazelcast-deployment-operations-guide/ + jet-docs: https://jet-start.sh/ + docs-archive: 'https://hazelcast.org/imdg/download/archives/' + hazelcast-cloud: Cloud + page-cloud-console: https://cloud.hazelcast.com/ + ucn: User Code Namespaces + ucd: User Code Deployment + extensions: + - ./lib/tabs-block.js + - ./lib/swagger-ui-block-macro.js + - asciidoctor-kroki diff --git a/lib/load-check-links-playbook.js b/lib/load-check-links-playbook.js index b0859592..8905f912 100644 --- a/lib/load-check-links-playbook.js +++ b/lib/load-check-links-playbook.js @@ -1,64 +1,127 @@ const YAML = require('yaml'); const fs = require('fs'); +const { isMatch } = require('matcher'); -const [currentRepoName, baseBranchName] = process.argv.slice(-2); +function main() { + const { currentRepoName, baseBranchName } = parseInputArgs(); -console.log('Checking links...'); + // 1. Load and parse local antora-playbook.yml + const localAntoraPlaybook = loadLocalAntoraPlaybook(); -if (currentRepoName.endsWith('.js') || baseBranchName.endsWith('.js')) { - throw new Error('GitHub repository name and base branch should be passed as arguments'); + // 2. Load and parse global antora-playbook.yml's content.sources + const globalSources = loadGlobalContentSources(); + + // 3. Modify global content.sources + // - add hazelcast-docs GitHub URL + addHazelcastDocsUrl(globalSources); + + // - exclude current target branch from the global content list by adding the branch name with the "!" prefix + const currentRepoSource = excludeBaseBranch(globalSources, currentRepoName, baseBranchName); + + // - add current branch + addCurrentBranch(currentRepoSource, globalSources); + + // 4. Replace local content.sources with the modified content.sources + writeCheckLinksPlaybookFile(localAntoraPlaybook, globalSources); } -console.log('Repository name: ', currentRepoName); -console.log('Base branch: ', baseBranchName); +function parseInputArgs() { + const [currentRepoName, baseBranchName] = process.argv.slice(-2); + + console.log('Checking links...'); + + // check whether there are arguments after the filename + if (currentRepoName.includes('load-check-links-playbook') || baseBranchName.includes('load-check-links-playbook')) { + throw new Error('GitHub repository name and base branch should be passed as arguments'); + } -// 1. Load and parse local antora-playbook.yml -const localAntoraPlaybookContent = fs.readFileSync('./antora-playbook.yml', 'utf8'); -const localAntoraPlaybook = YAML.parse(localAntoraPlaybookContent); + console.log('Repository name: ', currentRepoName); + console.log('Base branch: ', baseBranchName); -// 2. Load and parse global antora-playbook.yml's content.sources -const globalAntoraPlaybookContent = fs.readFileSync('./hazelcast-docs/antora-playbook.yml', 'utf8'); -const globalAntoraPlaybook = YAML.parse(globalAntoraPlaybookContent); -let globalSources = globalAntoraPlaybook.content.sources; + return { currentRepoName, baseBranchName }; +} -// 3. Modify global content.sources -// - add hazelcast-docs GitHub URL -const hazelcastDocsSource = globalSources.find(source => source.url === '.'); -hazelcastDocsSource.url = 'https://github.com/hazelcast/hazelcast-docs'; +function loadLocalAntoraPlaybook() { + const localAntoraPlaybookContent = fs.readFileSync('./antora-playbook.yml', 'utf8'); + return YAML.parse(localAntoraPlaybookContent); +} -// - remove hazelcast-mono & management-center, -// because they have only Swagger docs thus will never have links to the current -// and also they require authentication -globalSources = globalSources.filter(source => - !(source.url === 'https://github.com/hazelcast/hazelcast-mono') - && !(source.url === 'https://github.com/hazelcast/management-center')); +function removeProtectedSources(sources) { + return sources.filter(source => + !(source.url === 'https://github.com/hazelcast/hazelcast-mono') + && !(source.url === 'https://github.com/hazelcast/management-center')); +} -// - remove current target branch from the global content list by adding the branch name with the "!" prefix -const currentRepoSource = globalSources.find(source => source.url.endsWith(currentRepoName)); -currentRepoSource.branches.push(`!${baseBranchName}`); +function loadGlobalContentSources() { + const globalAntoraPlaybookContent = fs.readFileSync('./hazelcast-docs/antora-playbook.yml', 'utf8'); + const globalAntoraPlaybook = YAML.parse(globalAntoraPlaybookContent); -// - add current branch -const currentBranchSource = { - url: '.', - branches: 'HEAD', -}; + // - remove hazelcast-mono & management-center, + // because they have only Swagger docs thus will never have links to the current + // and also they require authentication + return removeProtectedSources(globalAntoraPlaybook.content.sources); +} -// - copy start_path(s) from the currentRepoSource -if (currentRepoSource.start_path) { - currentBranchSource.start_path = currentRepoSource.start_path.slice(); +function addHazelcastDocsUrl(sources) { + // in the global playbook it's declared with a dot `.` + const hazelcastDocsSource = sources.find(source => source.url === '.'); + hazelcastDocsSource.url = 'https://github.com/hazelcast/hazelcast-docs'; +} + +function rewriteCurrentVersion() { + +} + +function excludeBaseBranch(sources, repoName, branchName) { + const matchedRepos = sources.filter(source => source.url.endsWith(repoName)); + if (matchedRepos.length === 0) { + throw new Error(`There is no repository ${repoName} among the playbook sources!`); + } + let currentSource = matchedRepos.find(source => isMatch(branchName, source.branches)); + if (!currentSource) { + console.debug(`No matching base branch found. Rewriting version to omit version collision!`); + rewriteCurrentVersion(); + currentSource = matchedRepos[0]; + } + const excludedBranch = `!${branchName}`; + + if (Array.isArray(currentSource.branches)) { + currentSource.branches.push(excludedBranch); + } else { + currentSource.branches = [currentSource.branches, excludedBranch]; + } + + return currentSource; } -if (currentRepoSource.start_paths) { - currentBranchSource.start_paths = currentRepoSource.start_paths.slice(); + +function addCurrentBranch(repoSource, sources) { + const currentBranchSource = { + url: '.', + branches: 'HEAD', + }; + +// - copy start_path(s) from the currentRepoSource + if (repoSource.start_path) { + currentBranchSource.start_path = repoSource.start_path.slice(); + } + if (repoSource.start_paths) { + currentBranchSource.start_paths = repoSource.start_paths.slice(); + } + + sources.unshift(currentBranchSource); } -globalSources.unshift(currentBranchSource); +function writeCheckLinksPlaybookFile(localPlaybook, sources) { + localPlaybook.content.sources = sources; + const checkLinksPlaybook = YAML.stringify(localPlaybook); + + console.debug(checkLinksPlaybook); -// 4. Replace local content.sources with the modified content.sources -localAntoraPlaybook.content.sources = globalSources; -const checkLinksPlaybook = YAML.stringify(localAntoraPlaybook); + fs.writeFileSync( + './check-links-playbook.yml', + checkLinksPlaybook, + { encoding: 'utf8' }, + ); +} -fs.writeFileSync( - './check-links-playbook.yml', - checkLinksPlaybook, - { encoding: 'utf8' }, -); +main(); diff --git a/load-check-links-playbook.js b/load-check-links-playbook.js new file mode 100644 index 00000000..351b05e8 --- /dev/null +++ b/load-check-links-playbook.js @@ -0,0 +1,142 @@ +const YAML = require('yaml'); +const fs = require('fs'); +const { isMatch } = require('matcher'); + +function main() { + const { currentRepoName, baseBranchName } = parseInputArgs(); + + // 1. Load and parse local antora-playbook.yml + const localAntoraPlaybook = loadLocalAntoraPlaybook(); + + // 2. Load and parse global antora-playbook.yml's content.sources + const globalSources = loadGlobalContentSources(); + + // 3. Modify global content.sources + // - add hazelcast-docs GitHub URL + addHazelcastDocsUrl(globalSources); + + // - exclude current target branch from the global content list by adding the branch name with the "!" prefix + const currentRepoSource = excludeBaseBranch(globalSources, currentRepoName, baseBranchName); + + // - add current branch + addCurrentBranch(currentRepoSource, globalSources); + + // 4. Replace local content.sources with the modified content.sources + writeCheckLinksPlaybookFile(localAntoraPlaybook, globalSources); +} + +function parseInputArgs() { + const [currentRepoName, baseBranchName] = process.argv.slice(-2); + + console.log('Checking links...'); + + // check whether there are arguments after the filename + if (currentRepoName.includes('load-check-links-playbook') || baseBranchName.includes('load-check-links-playbook')) { + throw new Error('GitHub repository name and base branch should be passed as arguments'); + } + + console.log('Repository name: ', currentRepoName); + console.log('Base branch: ', baseBranchName); + + return { currentRepoName, baseBranchName }; +} + +function loadLocalAntoraPlaybook() { + const localAntoraPlaybookContent = fs.readFileSync('./antora-playbook.yml', 'utf8'); + return YAML.parse(localAntoraPlaybookContent); +} + +function removeProtectedSources(sources) { + return sources.filter(source => + !(source.url === 'https://github.com/hazelcast/hazelcast-mono') + && !(source.url === 'https://github.com/hazelcast/management-center')); +} + +function loadGlobalContentSources() { + const globalAntoraPlaybookContent = fs.readFileSync('./hazelcast-docs/antora-playbook.yml', 'utf8'); + const globalAntoraPlaybook = YAML.parse(globalAntoraPlaybookContent); + + // - remove hazelcast-mono & management-center, + // because they have only Swagger docs thus will never have links to the current + // and also they require authentication + return removeProtectedSources(globalAntoraPlaybook.content.sources); +} + +function addHazelcastDocsUrl(sources) { + // in the global playbook it's declared with a dot `.` + const hazelcastDocsSource = sources.find(source => source.url === '.'); + hazelcastDocsSource.url = 'https://github.com/hazelcast/hazelcast-docs'; +} + +function rewriteCurrentVersion() { + const antoraYmlPath = './docs/antora.yml'; + try { + const antoraYml = YAML.parse(fs.readFileSync(antoraYmlPath, 'utf8')); + const version = 'snapshot_ci'; + antoraYml.version = version; + antoraYml.display_version = version; + antoraYml.asciidoc.attributes['full-version'] = version; + fs.writeFileSync( + antoraYmlPath, + YAML.stringify(antoraYml), + { encoding: 'utf8' }, + ); + } catch (err) { + console.debug(err); + console.warn('Could not rewrite version. There might be an error with version collision!'); + } +} + +function excludeBaseBranch(sources, repoName, branchName) { + const matchedRepos = sources.filter(source => source.url.endsWith(repoName)); + if (matchedRepos.length === 0) { + throw new Error(`There is no repository ${repoName} among the playbook sources!`); + } + let currentSource = matchedRepos.find(source => isMatch(branchName, source.branches)); + if (!currentSource) { + console.debug(`No matching base branch found. Rewriting version to omit version collision!`); + rewriteCurrentVersion(); + currentSource = matchedRepos[0]; + } + const excludedBranch = `!${branchName}`; + + if (Array.isArray(currentSource.branches)) { + currentSource.branches.push(excludedBranch); + } else { + currentSource.branches = [currentSource.branches, excludedBranch]; + } + + return currentSource; +} + +function addCurrentBranch(repoSource, sources) { + const currentBranchSource = { + url: '.', + branches: 'HEAD', + }; + +// - copy start_path(s) from the currentRepoSource + if (repoSource.start_path) { + currentBranchSource.start_path = repoSource.start_path.slice(); + } + if (repoSource.start_paths) { + currentBranchSource.start_paths = repoSource.start_paths.slice(); + } + + sources.unshift(currentBranchSource); +} + +function writeCheckLinksPlaybookFile(localPlaybook, sources) { + localPlaybook.content.sources = sources; + const checkLinksPlaybook = YAML.stringify(localPlaybook); + + // console.debug(checkLinksPlaybook); + + fs.writeFileSync( + './check-links-playbook.yml', + checkLinksPlaybook, + { encoding: 'utf8' }, + ); +} + +main(); diff --git a/package.json b/package.json index 7331ebf3..405d68fc 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "@antora/cli": "^3.1.1", "@antora/site-generator": "^3.1.1", "@jcahills/antora-link-checker": "^1.0.1", - "@djencks/antora-aggregate-collector": "^0.1.0-beta.1", "asciidoctor-kroki": "^0.15.0", "ngrok": "^4.2.2", "serve": "^13.0.2"