From 56af9bd97552517d1cd09dc56c7afa9ac18f481c Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 27 Jan 2026 12:48:23 -0400 Subject: [PATCH] [WIP] Deploy an "enterprise" image Signed-off-by: Juan Cruz Viotti --- .github/actions/sandbox/action.yml | 12 ++++ .github/workflows/ci.yml | 16 ++++- .github/workflows/deploy.yml | 20 ++++++- CMakeLists.txt | 18 +++++- Dockerfile | 12 +++- LICENSE | 13 +++- LICENSE-COMMERCIAL | 9 +-- Makefile | 11 +++- README.markdown | 17 +++--- collections/CMakeLists.txt | 5 +- .../configuration/configuration.test.json | 18 ------ docs/commercial.md | 24 ++++---- docs/index.md | 17 +++--- .../sourcemeta/std/v0/jsonschema.in.json | 0 .../collections}/sourcemeta/std/v0/one.cmake | 0 .../collections}/sourcemeta/std/v0/one.json | 0 src/index/index.cc | 3 +- src/server/server.cc | 3 +- src/shared/CMakeLists.txt | 5 ++ .../include/sourcemeta/one/shared_version.h | 1 + src/shared/version.cc | 8 +++ src/web/page.h | 11 ++-- test/cli/CMakeLists.txt | 59 +++++++++++-------- .../{ => common}/bundle-ref-no-fragment.sh | 0 .../directory-schema-same-name.sh | 0 .../{ => common}/extend-builtin-not-found.sh | 0 .../index/{ => common}/external-reference.sh | 0 .../extra-directories-on-rebuild.sh | 0 .../{ => common}/extra-files-on-rebuild.sh | 0 .../{ => common}/invalid-configuration.sh | 0 .../invalid-schema-top-level-ref-draft7.sh | 0 .../invalid-schema-uri-percentage.sh | 0 test/cli/index/{ => common}/invalid-schema.sh | 0 .../invalid-url-option-no-value.sh | 0 .../invalid-url-option-non-http.sh | 0 .../invalid-url-option-relative.sh | 0 .../{ => common}/invalid-url-option-urn.sh | 0 test/cli/index/{ => common}/no-base-uri.sh | 0 .../{ => common}/output-non-directory.sh | 0 test/cli/index/{ => common}/rebuild-cache.sh | 0 .../index/{ => common}/rebuild-to-empty.sh | 0 test/cli/index/{ => common}/verbose-long.sh | 0 test/cli/index/{ => common}/verbose-short.sh | 0 test/cli/index/{ => community}/no-options.sh | 2 +- test/cli/index/{ => community}/no-output.sh | 2 +- test/cli/index/community/sourcemeta-std.sh | 29 +++++++++ test/cli/index/enterprise/no-options.sh | 20 +++++++ test/cli/index/enterprise/no-output.sh | 36 +++++++++++ test/e2e/html/html.hurl | 1 + 49 files changed, 268 insertions(+), 104 deletions(-) rename {collections => enterprise/collections}/sourcemeta/std/v0/jsonschema.in.json (100%) rename {collections => enterprise/collections}/sourcemeta/std/v0/one.cmake (100%) rename {collections => enterprise/collections}/sourcemeta/std/v0/one.json (100%) rename test/cli/index/{ => common}/bundle-ref-no-fragment.sh (100%) rename test/cli/index/{ => common}/directory-schema-same-name.sh (100%) rename test/cli/index/{ => common}/extend-builtin-not-found.sh (100%) rename test/cli/index/{ => common}/external-reference.sh (100%) rename test/cli/index/{ => common}/extra-directories-on-rebuild.sh (100%) rename test/cli/index/{ => common}/extra-files-on-rebuild.sh (100%) rename test/cli/index/{ => common}/invalid-configuration.sh (100%) rename test/cli/index/{ => common}/invalid-schema-top-level-ref-draft7.sh (100%) rename test/cli/index/{ => common}/invalid-schema-uri-percentage.sh (100%) rename test/cli/index/{ => common}/invalid-schema.sh (100%) rename test/cli/index/{ => common}/invalid-url-option-no-value.sh (100%) rename test/cli/index/{ => common}/invalid-url-option-non-http.sh (100%) rename test/cli/index/{ => common}/invalid-url-option-relative.sh (100%) rename test/cli/index/{ => common}/invalid-url-option-urn.sh (100%) rename test/cli/index/{ => common}/no-base-uri.sh (100%) rename test/cli/index/{ => common}/output-non-directory.sh (100%) rename test/cli/index/{ => common}/rebuild-cache.sh (100%) rename test/cli/index/{ => common}/rebuild-to-empty.sh (100%) rename test/cli/index/{ => common}/verbose-long.sh (100%) rename test/cli/index/{ => common}/verbose-short.sh (100%) rename test/cli/index/{ => community}/no-options.sh (90%) rename test/cli/index/{ => community}/no-output.sh (94%) create mode 100755 test/cli/index/community/sourcemeta-std.sh create mode 100755 test/cli/index/enterprise/no-options.sh create mode 100755 test/cli/index/enterprise/no-output.sh diff --git a/.github/actions/sandbox/action.yml b/.github/actions/sandbox/action.yml index 726de9a5..161f9785 100644 --- a/.github/actions/sandbox/action.yml +++ b/.github/actions/sandbox/action.yml @@ -8,6 +8,13 @@ inputs: - html - headless - empty + edition: + description: Edition + required: true + type: choice + options: + - community + - enterprise port: description: Port required: true @@ -21,6 +28,7 @@ runs: env: SANDBOX_CONFIGURATION: ${{ inputs.configuration }} SANDBOX_PORT: ${{ inputs.port }} + ENTERPRISE: ${{ inputs.edition == 'enterprise' && 'ON' || 'OFF' }} PARALLEL: 2 - name: Up Sandbox (${{ inputs.configuration }}) run: make docker-sandbox-up @@ -28,12 +36,14 @@ runs: env: SANDBOX_CONFIGURATION: ${{ inputs.configuration }} SANDBOX_PORT: ${{ inputs.port }} + ENTERPRISE: ${{ inputs.edition == 'enterprise' && 'ON' || 'OFF' }} - name: Test Sandbox - E2E (${{ inputs.configuration }}) run: make test-e2e PRESET=Release shell: bash env: SANDBOX_CONFIGURATION: ${{ inputs.configuration }} SANDBOX_PORT: ${{ inputs.port }} + ENTERPRISE: ${{ inputs.edition == 'enterprise' && 'ON' || 'OFF' }} HURL: 'docker run --rm --network=host --volume \$(PWD):/workspace --workdir /workspace ghcr.io/orange-opensource/hurl:7.0.0' - name: Test Sandbox - UI (${{ inputs.configuration }}) run: make test-ui PRESET=Release @@ -42,9 +52,11 @@ runs: env: SANDBOX_CONFIGURATION: ${{ inputs.configuration }} SANDBOX_PORT: ${{ inputs.port }} + ENTERPRISE: ${{ inputs.edition == 'enterprise' && 'ON' || 'OFF' }} - name: Down Sandbox (${{ inputs.configuration }}) run: make docker-sandbox-down shell: bash env: SANDBOX_CONFIGURATION: ${{ inputs.configuration }} SANDBOX_PORT: ${{ inputs.port }} + ENTERPRISE: ${{ inputs.edition == 'enterprise' && 'ON' || 'OFF' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b939ff0..d5f93d2b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,33 +16,45 @@ jobs: - run: codespell docs *.markdown docs/*.md test: + strategy: + fail-fast: false + matrix: + edition: + - name: community + options: ENTERPRISE=OFF + - name: enterprise + options: ENTERPRISE=ON + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Build One - run: make docker PRESET=Release + - run: make docker PRESET=Release ${{ matrix.edition.options }} - name: Sandbox (headless) uses: ./.github/actions/sandbox with: configuration: headless + edition: ${{ matrix.edition.name }} port: 8000 - name: Sandbox (html) uses: ./.github/actions/sandbox with: configuration: html + edition: ${{ matrix.edition.name }} port: 8000 - name: Sandbox (empty) uses: ./.github/actions/sandbox with: configuration: empty + edition: ${{ matrix.edition.name }} port: 8000 # Public instance - run: docker build . --file public/Dockerfile --progress plain + if: matrix.edition.name == 'enterprise' website: runs-on: ubuntu-latest diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 37a2cf62..872ace11 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,9 +23,23 @@ jobs: - package: one os: ubuntu-24.04 arch: amd64 + enterprise: OFF + license: BUSL-1.1 - package: one os: ubuntu-24.04-arm arch: arm64 + enterprise: OFF + license: BUSL-1.1 + - package: one-enterprise + os: ubuntu-24.04 + arch: amd64 + enterprise: ON + license: LicenseRef-Commercial + - package: one-enterprise + os: ubuntu-24.04-arm + arch: arm64 + enterprise: ON + license: LicenseRef-Commercial runs-on: ${{ matrix.edition.os }} steps: @@ -57,6 +71,9 @@ jobs: with: context: . file: Dockerfile + build-args: | + SOURCEMETA_ONE_ENTERPRISE=${{ matrix.edition.enterprise }} + SOURCEMETA_ONE_LICENSE=${{ matrix.edition.license }} platforms: linux/${{ matrix.edition.arch }} labels: ${{ steps.meta.outputs.labels }} annotations: ${{ steps.meta.outputs.annotations }} @@ -86,6 +103,7 @@ jobs: matrix: edition: - package: one + - package: one-enterprise steps: - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 @@ -175,7 +193,7 @@ jobs: with: context: . file: public/Dockerfile - build-args: "SOURCEMETA_ONE=ghcr.io/sourcemeta/one:main" + build-args: "SOURCEMETA_ONE=ghcr.io/sourcemeta/one-enterprise:main" push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ef32dbb..e06b2365 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,15 @@ if(NOT ONE_PREFIX_IS_ABSOLUTE) message(FATAL_ERROR "ONE_PREFIX must be an absolute path but it was: ${ONE_PREFIX}") endif() +# Commercial editions require a paid license +# See https://one.sourcemeta.com/commercial/ +option(ONE_ENTERPRISE "Build the One Enterprise edition (commercial)" OFF) +if(ONE_ENTERPRISE) + message(STATUS "Sourcemeta One edition: Enterprise") +else() + message(STATUS "Sourcemeta One edition: Community") +endif() + find_package(Core REQUIRED) find_package(Blaze REQUIRED) find_package(Codegen REQUIRED) @@ -90,9 +99,16 @@ add_custom_target(jsonschema_lint if(ONE_TESTS) enable_testing() + + set(SCHEMA_TEST_DIRECTORIES "${PROJECT_SOURCE_DIR}/collections") + + if(ONE_ENTERPRISE) + list(APPEND SCHEMA_TEST_DIRECTORIES "${PROJECT_SOURCE_DIR}/enterprise/collections") + endif() + add_test(NAME one.schemas COMMAND "$" test --extension .test.json - "${PROJECT_SOURCE_DIR}/collections/sourcemeta") + ${SCHEMA_TEST_DIRECTORIES}) add_subdirectory(test/js) diff --git a/Dockerfile b/Dockerfile index 6d50ac27..089b5ef8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,7 @@ COPY contrib /source/contrib COPY collections /source/collections COPY vendor /source/vendor COPY CMakeLists.txt /source/CMakeLists.txt +COPY enterprise /source/enterprise # For testing COPY test/cli /source/test/cli @@ -23,6 +24,10 @@ COPY test/js /source/test/js RUN cd /source && npm ci +# Commercial editions require a paid license +# See https://one.sourcemeta.com/commercial/ +ARG SOURCEMETA_ONE_ENTERPRISE=OFF + ARG SOURCEMETA_ONE_BUILD_TYPE=Release ARG SOURCEMETA_ONE_PARALLEL=2 @@ -32,6 +37,7 @@ RUN cmake -S /source -B ./build \ -DONE_INDEX:BOOL=ON \ -DONE_SERVER:BOOL=ON \ -DONE_TESTS:BOOL=ON \ + -DONE_ENTERPRISE:BOOL=${SOURCEMETA_ONE_ENTERPRISE} \ -DBUILD_SHARED_LIBS:BOOL=OFF RUN cmake --build /build \ @@ -58,14 +64,16 @@ RUN ctest --test-dir /build --build-config ${SOURCEMETA_ONE_BUILD_TYPE} \ FROM debian:bookworm-slim +ARG SOURCEMETA_ONE_LICENSE=LicenseRef-Commercial + # See https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys LABEL org.opencontainers.image.url="https://one.sourcemeta.com" LABEL org.opencontainers.image.documentation="https://one.sourcemeta.com" LABEL org.opencontainers.image.source="https://github.com/sourcemeta/one" LABEL org.opencontainers.image.vendor="Sourcemeta" -LABEL org.opencontainers.image.licenses="BUSL-1.1 AND LicenseRef-Commercial" +LABEL org.opencontainers.image.licenses="${SOURCEMETA_ONE_LICENSE}" LABEL org.opencontainers.image.title="Sourcemeta One" -LABEL org.opencontainers.image.description="The JSON Schema platform. Commercial license available at hello@sourcemeta.com" +LABEL org.opencontainers.image.description="The JSON Schema platform" LABEL org.opencontainers.image.authors="Sourcemeta " COPY --from=builder /usr/bin/sourcemeta-one-index \ diff --git a/LICENSE b/LICENSE index 15642011..7b8a1ac1 100644 --- a/LICENSE +++ b/LICENSE @@ -4,9 +4,16 @@ Licensor: Sourcemeta OU Licensed Work: Sourcemeta One -Additional Use Grant: You may make use of the Licensed Work, provided that you -may not use the Licensed Work for a hosting solution that competes with -Licensor. +Additional Use Grant: You may make use of the Licensed Work as if under the +terms of the AGPL-3.0, provided that you may not use the Licensed Work for a +hosting solution that competes with Licensor. + +The `enterprise/` directory of the source repository contains code specific to +the Enterprise edition of Sourcemeta One. This code is not available under the +Business Source License and requires a separate Commercial License from +Sourcemeta. You may not use the Enterprise image, nor circumvent the build +configuration or the software in any way to access or use Enterprise edition +features without a valid Commercial License. Change Date: Change date is four years from release date. Please see [GitHub releases](https://github.com/sourcemeta/one/releases/) for exact dates diff --git a/LICENSE-COMMERCIAL b/LICENSE-COMMERCIAL index cfe6c3a0..4626ff71 100644 --- a/LICENSE-COMMERCIAL +++ b/LICENSE-COMMERCIAL @@ -16,16 +16,13 @@ non-transferable license to use, copy, modify, and distribute the Software, including the Enterprise edition, without the restrictions of the BUSL-1.1 or AGPL-3.0 licenses. This includes: -1. Unrestricted Production Use: Deploy the Software in production environments, - including hosting solutions that may compete with Sourcemeta - -2. Proprietary Integration: Integrate the Software into proprietary products +1. Proprietary Integration: Integrate the Software into proprietary products and services without open-source disclosure requirements. -3. Enterprise Edition: Access to the Enterprise edition of Sourcemeta One, +2. Enterprise Edition: Access to the Enterprise edition of Sourcemeta One, which includes additional features not available in the open-source release. -4. Private Modifications: Create and maintain modifications to the Software +3. Private Modifications: Create and maintain modifications to the Software without the obligation to disclose or open-source your changes. PREMIUM SUPPORT: diff --git a/Makefile b/Makefile index 08722c66..df568526 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,8 @@ SANDBOX_PORT ?= 8000 SANDBOX_URL ?= http://localhost:$(SANDBOX_PORT) PUBLIC ?= ./public PARALLEL ?= 4 +# Only for local development +ENTERPRISE ?= ON .PHONY: all all: configure compile test @@ -36,6 +38,7 @@ configure: node_modules -DONE_TESTS:BOOL=ON \ -DONE_INDEX:BOOL=$(INDEX) \ -DONE_SERVER:BOOL=$(SERVER) \ + -DONE_ENTERPRISE:BOOL=$(ENTERPRISE) \ -DONE_PREFIX:STRING=$(or $(realpath $(PREFIX)),$(abspath $(PREFIX))) \ -DBUILD_SHARED_LIBS:BOOL=OFF @@ -66,7 +69,10 @@ HURL_TESTS += test/e2e/populated/schemas/*.hurl HURL_TESTS += test/e2e/populated/api/*.hurl endif test-e2e: - $(HURL) --test --variable base=$(SANDBOX_URL) $(HURL_TESTS) + $(HURL) --test \ + --variable base=$(SANDBOX_URL) \ + --variable edition=$(if $(filter ON,$(ENTERPRISE)),Enterprise,Community) \ + $(HURL_TESTS) .PHONY: test-ui test-ui: node_modules @@ -97,7 +103,8 @@ sandbox-manifest-refresh: configure compile docker: Dockerfile $(DOCKER) build --tag one . --file $< --progress plain \ --build-arg SOURCEMETA_ONE_BUILD_TYPE=$(PRESET) \ - --build-arg SOURCEMETA_ONE_PARALLEL=$(PARALLEL) + --build-arg SOURCEMETA_ONE_PARALLEL=$(PARALLEL) \ + --build-arg SOURCEMETA_ONE_ENTERPRISE=$(ENTERPRISE) .PHONY: docker-sandbox-build docker-sandbox-build: test/sandbox/compose.yaml diff --git a/README.markdown b/README.markdown index 94478e47..dce7a349 100644 --- a/README.markdown +++ b/README.markdown @@ -29,16 +29,13 @@ catalogs with enterprise-grade governance capabilities. ## :page_facing_up: License -While the project is publicly available on GitHub, it operates under a -[source-available -license](https://github.com/sourcemeta/one/blob/main/LICENSE) rather than -a traditional open-source model. Commercial use requires a [paid commercial -license](https://one.sourcemeta.com/commercial/). Reach out to -[hello@sourcemeta.com](mailto:hello@sourcemeta.com) to discuss. - -> We are typically happy to provide free commercial licenses to open-source -> projects, non-profits, educational institutions, and research projects. -> [Reach out](mailto:hello@sourcemeta.com) if you think you qualify! +This project is dual-licensed. See +[LICENSE](https://github.com/sourcemeta/one/blob/main/LICENSE) for the +open-source offering and +[LICENSE-COMMERCIAL](https://github.com/sourcemeta/one/blob/main/LICENSE-COMMERCIAL) +for the enterprise offering. Reach out to +[hello@sourcemeta.com](mailto:hello@sourcemeta.com) to discuss commercial +licensing. ## :handshake: Contributing diff --git a/collections/CMakeLists.txt b/collections/CMakeLists.txt index 8a22921a..b680b2cf 100644 --- a/collections/CMakeLists.txt +++ b/collections/CMakeLists.txt @@ -1,6 +1,9 @@ set(ONE_COLLECTION_SOURCES) -include("./sourcemeta/std/v0/one.cmake") +if(ONE_ENTERPRISE) + include("../enterprise/collections/sourcemeta/std/v0/one.cmake") +endif() + include("./self/v1/one.cmake") add_custom_target(sourcemeta_one_collections DEPENDS ${ONE_COLLECTION_SOURCES}) diff --git a/collections/self/v1/tests/configuration/configuration.test.json b/collections/self/v1/tests/configuration/configuration.test.json index ac96dad3..5bd46ef1 100644 --- a/collections/self/v1/tests/configuration/configuration.test.json +++ b/collections/self/v1/tests/configuration/configuration.test.json @@ -130,24 +130,6 @@ } } }, - { - "description": "Self top-level entry", - "valid": false, - "data": { - "url": "http://localhost:8000", - "html": { - "name": "Title", - "description": "Description" - }, - "contents": { - "self": { - "title": "A sample schema folder", - "description": "For testing purposes", - "github": "sourcemeta/one" - } - } - } - }, { "description": "Self nested entry", "valid": true, diff --git a/docs/commercial.md b/docs/commercial.md index 33be5f14..10491dac 100644 --- a/docs/commercial.md +++ b/docs/commercial.md @@ -12,22 +12,22 @@ technology.* Sourcemeta One is [publicly available on GitHub](https://github.com/sourcemeta/one) with full source code transparency, -enabling comprehensive auditing and community contributions. While the -codebase is accessible for review and collaboration, Sourcemeta One operates -under a [source-available -license](https://github.com/sourcemeta/one/blob/main/LICENSE) rather than a -traditional open-source model. +enabling comprehensive auditing and community contributions. ## Editions -You can use the Sourcemeta One commercial edition at no cost with all features -included for non-commercial and evaluation purposes. However, commercial -deployments require a license from Sourcemeta. This licensing model enables us -to: +Sourcemeta One is available in two editions: -- Maintain and enhance the service's advanced capabilities -- Provide enterprise-grade support and reliability -- Continue investing in cutting-edge JSON Schema tooling development +- **Community**: Licensed under the [Business Source License + 1.1](https://github.com/sourcemeta/one/blob/main/LICENSE). You may use it as + if under the terms of AGPL-3.0, provided that you may not use it for a + hosting solution that competes with Sourcemeta. After four years from each + release, the code transitions to AGPL-3.0. + +- **Enterprise**: Includes additional features not available in the Community + edition. Requires a [commercial + license](https://github.com/sourcemeta/one/blob/main/LICENSE-COMMERCIAL) + from Sourcemeta. ## Our Commitment to Excellence diff --git a/docs/index.md b/docs/index.md index 379099fe..fbcf446f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -95,13 +95,13 @@ as databases. Perfect for highly-regulated industries, compliance requirements, and airgapped environments where every dependency creates security and operational risk. -**Source-available**: Sourcemeta One is source-available (though not -open-source) on [GitHub](https://github.com/sourcemeta/one), providing complete -code transparency for security audits, compliance reviews, internal -assessments, and modification. Enterprises can examine every line of code, -eliminating black-box concerns and ensuring no vendor lock-in. If Sourcemeta -would ever cease operations, you retain full access to continue running and -maintaining your instances. +**Source-available**: Sourcemeta One is publicly available on +[GitHub](https://github.com/sourcemeta/one), providing complete code +transparency for security audits, compliance reviews, internal assessments, and +modification. Enterprises can examine every line of code, eliminating black-box +concerns and ensuring no vendor lock-in. If Sourcemeta would ever cease +operations, you retain full access to continue running and maintaining your +instances. **Expert commercial support & training**: [Commercial Licenses](./commercial.md) give you access to world-class JSON Schema expertise @@ -123,9 +123,6 @@ solution the industry needs. - **Schema evolution and transforms**: Convert data between schema versions and formats. Includes schema evolution (i.e. v1 to v2) to arbitrary data transformations (i.e. Celsius to Fahrenheit) -- **Standard Library of Schemas**: Expertly crafted OEM schema collections - covering diverse domains, so that you can stop reinventing the wheel and - build other schemas and API specifications on proven foundations - **Step-through Online Schema Debugger**: Visual schema evaluation debugger that highlights validation logic line-by-line in both schema and instance data for faster troubleshooting diff --git a/collections/sourcemeta/std/v0/jsonschema.in.json b/enterprise/collections/sourcemeta/std/v0/jsonschema.in.json similarity index 100% rename from collections/sourcemeta/std/v0/jsonschema.in.json rename to enterprise/collections/sourcemeta/std/v0/jsonschema.in.json diff --git a/collections/sourcemeta/std/v0/one.cmake b/enterprise/collections/sourcemeta/std/v0/one.cmake similarity index 100% rename from collections/sourcemeta/std/v0/one.cmake rename to enterprise/collections/sourcemeta/std/v0/one.cmake diff --git a/collections/sourcemeta/std/v0/one.json b/enterprise/collections/sourcemeta/std/v0/one.json similarity index 100% rename from collections/sourcemeta/std/v0/one.json rename to enterprise/collections/sourcemeta/std/v0/one.json diff --git a/src/index/index.cc b/src/index/index.cc index 7f6eb9ea..6d741d99 100644 --- a/src/index/index.cc +++ b/src/index/index.cc @@ -76,7 +76,8 @@ DISPATCH(const std::filesystem::path &destination, static auto index_main(const std::string_view &program, const sourcemeta::core::Options &app) -> int { - std::cout << "Sourcemeta One v" << sourcemeta::one::version() << "\n"; + std::cout << "Sourcemeta One " << sourcemeta::one::edition() << " v" + << sourcemeta::one::version() << "\n"; if (app.positional().size() != 2) { std::cout << "Usage: " << std::filesystem::path{program}.filename().string() diff --git a/src/server/server.cc b/src/server/server.cc index 968f2b94..669a0882 100644 --- a/src/server/server.cc +++ b/src/server/server.cc @@ -308,7 +308,8 @@ auto terminate(int signal) -> void { auto main(int argc, char *argv[]) noexcept -> int { const auto timestamp_start{std::chrono::steady_clock::now()}; - std::cout << "Sourcemeta One v" << sourcemeta::one::version() << "\n"; + std::cout << "Sourcemeta One " << sourcemeta::one::edition() << " v" + << sourcemeta::one::version() << "\n"; // Mainly for Docker Compose std::signal(SIGINT, terminate); diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt index 9a743a7e..54f40edd 100644 --- a/src/shared/CMakeLists.txt +++ b/src/shared/CMakeLists.txt @@ -9,6 +9,11 @@ target_link_libraries(sourcemeta_one_shared PRIVATE sourcemeta::core::md5) target_link_libraries(sourcemeta_one_shared PRIVATE sourcemeta::core::time) target_link_libraries(sourcemeta_one_shared PRIVATE sourcemeta::one::gzip) +if(ONE_ENTERPRISE) + target_compile_definitions(sourcemeta_one_shared + PRIVATE SOURCEMETA_ONE_ENTERPRISE) +endif() + configure_file(configure.h.in configure.h @ONLY) target_include_directories(sourcemeta_one_shared PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/src/shared/include/sourcemeta/one/shared_version.h b/src/shared/include/sourcemeta/one/shared_version.h index 743b3a2e..fa71b733 100644 --- a/src/shared/include/sourcemeta/one/shared_version.h +++ b/src/shared/include/sourcemeta/one/shared_version.h @@ -7,6 +7,7 @@ namespace sourcemeta::one { auto stamp() noexcept -> std::string_view; auto version() noexcept -> std::string_view; +auto edition() noexcept -> std::string_view; } // namespace sourcemeta::one diff --git a/src/shared/version.cc b/src/shared/version.cc index 41e48903..61bb9b05 100644 --- a/src/shared/version.cc +++ b/src/shared/version.cc @@ -13,4 +13,12 @@ auto stamp() noexcept -> std::string_view { auto version() noexcept -> std::string_view { return PROJECT_VERSION; } +auto edition() noexcept -> std::string_view { +#if defined(SOURCEMETA_ONE_ENTERPRISE) + return "Enterprise"; +#else + return "Community"; +#endif +} + } // namespace sourcemeta::one diff --git a/src/web/page.h b/src/web/page.h index 5f4f5e9d..e2de84b1 100644 --- a/src/web/page.h +++ b/src/web/page.h @@ -5,11 +5,10 @@ #include #include -#include // std::optional -#include // std::ostringstream -#include // std::string -#include // std::string_view -#include // std::vector +#include // std::optional +#include // std::ostringstream +#include // std::string +#include // std::vector namespace sourcemeta::one::html { @@ -55,7 +54,7 @@ inline auto make_navigation(const Configuration &configuration) inline auto make_footer() -> sourcemeta::core::HTML { std::ostringstream information; - information << " v" << version() << " © 2025 "; + information << " " << edition() << " v" << version() << " © 2026 "; return div( {{"class", "container-fluid px-4 mb-2"}}, diff --git a/test/cli/CMakeLists.txt b/test/cli/CMakeLists.txt index a233c720..f5571957 100644 --- a/test/cli/CMakeLists.txt +++ b/test/cli/CMakeLists.txt @@ -1,36 +1,43 @@ -macro(sourcemeta_one_test_cli program name) +macro(sourcemeta_one_test_cli directory program name) if(UNIX) - add_test(NAME one.${program}.${name} COMMAND - "${CMAKE_CURRENT_SOURCE_DIR}/${program}/${name}.sh" + add_test(NAME one.${program}.${directory}.${name} COMMAND + "${CMAKE_CURRENT_SOURCE_DIR}/${program}/${directory}/${name}.sh" "$" "${ONE_VERSION}" WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}") - set_tests_properties(one.${program}.${name} PROPERTIES + set_tests_properties(one.${program}.${directory}.${name} PROPERTIES ENVIRONMENT "ONE_PREFIX=${ONE_PREFIX}") endif() endmacro() if(ONE_INDEX) - sourcemeta_one_test_cli(index bundle-ref-no-fragment) - sourcemeta_one_test_cli(index extend-builtin-not-found) - sourcemeta_one_test_cli(index external-reference) - sourcemeta_one_test_cli(index invalid-configuration) - sourcemeta_one_test_cli(index invalid-schema) - sourcemeta_one_test_cli(index invalid-schema-top-level-ref-draft7) - sourcemeta_one_test_cli(index invalid-schema-uri-percentage) - sourcemeta_one_test_cli(index invalid-url-option-relative) - sourcemeta_one_test_cli(index invalid-url-option-urn) - sourcemeta_one_test_cli(index invalid-url-option-non-http) - sourcemeta_one_test_cli(index invalid-url-option-no-value) - sourcemeta_one_test_cli(index output-non-directory) - sourcemeta_one_test_cli(index extra-files-on-rebuild) - sourcemeta_one_test_cli(index extra-directories-on-rebuild) - sourcemeta_one_test_cli(index directory-schema-same-name) - sourcemeta_one_test_cli(index rebuild-cache) - sourcemeta_one_test_cli(index rebuild-to-empty) - sourcemeta_one_test_cli(index verbose-long) - sourcemeta_one_test_cli(index verbose-short) - sourcemeta_one_test_cli(index no-base-uri) - sourcemeta_one_test_cli(index no-options) - sourcemeta_one_test_cli(index no-output) + sourcemeta_one_test_cli(common index bundle-ref-no-fragment) + sourcemeta_one_test_cli(common index extend-builtin-not-found) + sourcemeta_one_test_cli(common index external-reference) + sourcemeta_one_test_cli(common index invalid-configuration) + sourcemeta_one_test_cli(common index invalid-schema) + sourcemeta_one_test_cli(common index invalid-schema-top-level-ref-draft7) + sourcemeta_one_test_cli(common index invalid-schema-uri-percentage) + sourcemeta_one_test_cli(common index invalid-url-option-relative) + sourcemeta_one_test_cli(common index invalid-url-option-urn) + sourcemeta_one_test_cli(common index invalid-url-option-non-http) + sourcemeta_one_test_cli(common index invalid-url-option-no-value) + sourcemeta_one_test_cli(common index output-non-directory) + sourcemeta_one_test_cli(common index extra-files-on-rebuild) + sourcemeta_one_test_cli(common index extra-directories-on-rebuild) + sourcemeta_one_test_cli(common index directory-schema-same-name) + sourcemeta_one_test_cli(common index rebuild-cache) + sourcemeta_one_test_cli(common index rebuild-to-empty) + sourcemeta_one_test_cli(common index verbose-long) + sourcemeta_one_test_cli(common index verbose-short) + sourcemeta_one_test_cli(common index no-base-uri) + + if(ONE_ENTERPRISE) + sourcemeta_one_test_cli(enterprise index no-options) + sourcemeta_one_test_cli(enterprise index no-output) + else() + sourcemeta_one_test_cli(community index no-options) + sourcemeta_one_test_cli(community index no-output) + sourcemeta_one_test_cli(community index sourcemeta-std) + endif() endif() diff --git a/test/cli/index/bundle-ref-no-fragment.sh b/test/cli/index/common/bundle-ref-no-fragment.sh similarity index 100% rename from test/cli/index/bundle-ref-no-fragment.sh rename to test/cli/index/common/bundle-ref-no-fragment.sh diff --git a/test/cli/index/directory-schema-same-name.sh b/test/cli/index/common/directory-schema-same-name.sh similarity index 100% rename from test/cli/index/directory-schema-same-name.sh rename to test/cli/index/common/directory-schema-same-name.sh diff --git a/test/cli/index/extend-builtin-not-found.sh b/test/cli/index/common/extend-builtin-not-found.sh similarity index 100% rename from test/cli/index/extend-builtin-not-found.sh rename to test/cli/index/common/extend-builtin-not-found.sh diff --git a/test/cli/index/external-reference.sh b/test/cli/index/common/external-reference.sh similarity index 100% rename from test/cli/index/external-reference.sh rename to test/cli/index/common/external-reference.sh diff --git a/test/cli/index/extra-directories-on-rebuild.sh b/test/cli/index/common/extra-directories-on-rebuild.sh similarity index 100% rename from test/cli/index/extra-directories-on-rebuild.sh rename to test/cli/index/common/extra-directories-on-rebuild.sh diff --git a/test/cli/index/extra-files-on-rebuild.sh b/test/cli/index/common/extra-files-on-rebuild.sh similarity index 100% rename from test/cli/index/extra-files-on-rebuild.sh rename to test/cli/index/common/extra-files-on-rebuild.sh diff --git a/test/cli/index/invalid-configuration.sh b/test/cli/index/common/invalid-configuration.sh similarity index 100% rename from test/cli/index/invalid-configuration.sh rename to test/cli/index/common/invalid-configuration.sh diff --git a/test/cli/index/invalid-schema-top-level-ref-draft7.sh b/test/cli/index/common/invalid-schema-top-level-ref-draft7.sh similarity index 100% rename from test/cli/index/invalid-schema-top-level-ref-draft7.sh rename to test/cli/index/common/invalid-schema-top-level-ref-draft7.sh diff --git a/test/cli/index/invalid-schema-uri-percentage.sh b/test/cli/index/common/invalid-schema-uri-percentage.sh similarity index 100% rename from test/cli/index/invalid-schema-uri-percentage.sh rename to test/cli/index/common/invalid-schema-uri-percentage.sh diff --git a/test/cli/index/invalid-schema.sh b/test/cli/index/common/invalid-schema.sh similarity index 100% rename from test/cli/index/invalid-schema.sh rename to test/cli/index/common/invalid-schema.sh diff --git a/test/cli/index/invalid-url-option-no-value.sh b/test/cli/index/common/invalid-url-option-no-value.sh similarity index 100% rename from test/cli/index/invalid-url-option-no-value.sh rename to test/cli/index/common/invalid-url-option-no-value.sh diff --git a/test/cli/index/invalid-url-option-non-http.sh b/test/cli/index/common/invalid-url-option-non-http.sh similarity index 100% rename from test/cli/index/invalid-url-option-non-http.sh rename to test/cli/index/common/invalid-url-option-non-http.sh diff --git a/test/cli/index/invalid-url-option-relative.sh b/test/cli/index/common/invalid-url-option-relative.sh similarity index 100% rename from test/cli/index/invalid-url-option-relative.sh rename to test/cli/index/common/invalid-url-option-relative.sh diff --git a/test/cli/index/invalid-url-option-urn.sh b/test/cli/index/common/invalid-url-option-urn.sh similarity index 100% rename from test/cli/index/invalid-url-option-urn.sh rename to test/cli/index/common/invalid-url-option-urn.sh diff --git a/test/cli/index/no-base-uri.sh b/test/cli/index/common/no-base-uri.sh similarity index 100% rename from test/cli/index/no-base-uri.sh rename to test/cli/index/common/no-base-uri.sh diff --git a/test/cli/index/output-non-directory.sh b/test/cli/index/common/output-non-directory.sh similarity index 100% rename from test/cli/index/output-non-directory.sh rename to test/cli/index/common/output-non-directory.sh diff --git a/test/cli/index/rebuild-cache.sh b/test/cli/index/common/rebuild-cache.sh similarity index 100% rename from test/cli/index/rebuild-cache.sh rename to test/cli/index/common/rebuild-cache.sh diff --git a/test/cli/index/rebuild-to-empty.sh b/test/cli/index/common/rebuild-to-empty.sh similarity index 100% rename from test/cli/index/rebuild-to-empty.sh rename to test/cli/index/common/rebuild-to-empty.sh diff --git a/test/cli/index/verbose-long.sh b/test/cli/index/common/verbose-long.sh similarity index 100% rename from test/cli/index/verbose-long.sh rename to test/cli/index/common/verbose-long.sh diff --git a/test/cli/index/verbose-short.sh b/test/cli/index/common/verbose-short.sh similarity index 100% rename from test/cli/index/verbose-short.sh rename to test/cli/index/common/verbose-short.sh diff --git a/test/cli/index/no-options.sh b/test/cli/index/community/no-options.sh similarity index 90% rename from test/cli/index/no-options.sh rename to test/cli/index/community/no-options.sh index 010a5e10..8d0a4240 100755 --- a/test/cli/index/no-options.sh +++ b/test/cli/index/community/no-options.sh @@ -13,7 +13,7 @@ test "$CODE" = "1" || exit 1 VERSION="$2" cat << EOF > "$TMP/expected.txt" -Sourcemeta One v$VERSION +Sourcemeta One Community v$VERSION Usage: sourcemeta-one-index EOF diff --git a/test/cli/index/no-output.sh b/test/cli/index/community/no-output.sh similarity index 94% rename from test/cli/index/no-output.sh rename to test/cli/index/community/no-output.sh index 05f98746..0838495a 100755 --- a/test/cli/index/no-output.sh +++ b/test/cli/index/community/no-output.sh @@ -29,7 +29,7 @@ test "$CODE" = "1" || exit 1 VERSION="$2" cat << EOF > "$TMP/expected.txt" -Sourcemeta One v$VERSION +Sourcemeta One Community v$VERSION Usage: sourcemeta-one-index EOF diff --git a/test/cli/index/community/sourcemeta-std.sh b/test/cli/index/community/sourcemeta-std.sh new file mode 100755 index 00000000..9a8e471f --- /dev/null +++ b/test/cli/index/community/sourcemeta-std.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +set -o errexit +set -o nounset + +TMP="$(mktemp -d)" +clean() { rm -rf "$TMP"; } +trap clean EXIT + +cat << EOF > "$TMP/one.json" +{ + "url": "https://example.com/", + "extends": [ "@sourcemeta/std/v0" ] +} +EOF + +"$1" "$TMP/one.json" "$TMP/output" 2> "$TMP/output.txt" && CODE="$?" || CODE="$?" +test "$CODE" = "1" || exit 1 + +cat << EOF > "$TMP/expected.txt" +Writing output to: $(realpath "$TMP")/output +Using configuration: $(realpath "$TMP")/one.json +error: Could not locate built-in collection + from $(realpath "$TMP")/one.json + at "/extends" + to @sourcemeta/std/v0 +EOF + +diff "$TMP/output.txt" "$TMP/expected.txt" diff --git a/test/cli/index/enterprise/no-options.sh b/test/cli/index/enterprise/no-options.sh new file mode 100755 index 00000000..e5d1b802 --- /dev/null +++ b/test/cli/index/enterprise/no-options.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +set -o errexit +set -o nounset + +TMP="$(mktemp -d)" +clean() { rm -rf "$TMP"; } +trap clean EXIT + +"$1" > "$TMP/output.txt" && CODE="$?" || CODE="$?" +test "$CODE" = "1" || exit 1 + +VERSION="$2" + +cat << EOF > "$TMP/expected.txt" +Sourcemeta One Enterprise v$VERSION +Usage: sourcemeta-one-index +EOF + +diff "$TMP/output.txt" "$TMP/expected.txt" diff --git a/test/cli/index/enterprise/no-output.sh b/test/cli/index/enterprise/no-output.sh new file mode 100755 index 00000000..7f056c3e --- /dev/null +++ b/test/cli/index/enterprise/no-output.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +set -o errexit +set -o nounset + +TMP="$(mktemp -d)" +clean() { rm -rf "$TMP"; } +trap clean EXIT + +cat << EOF > "$TMP/one.json" +{ + "url": "http://localhost:8000", + "contents": { + "example": { + "contents": { + "schemas": { + "baseUri": "https://example.com/schemas", + "path": "./schemas/example/folder" + } + } + } + } +} +EOF + +"$1" "$TMP/one.json" > "$TMP/output.txt" && CODE="$?" || CODE="$?" +test "$CODE" = "1" || exit 1 + +VERSION="$2" + +cat << EOF > "$TMP/expected.txt" +Sourcemeta One Enterprise v$VERSION +Usage: sourcemeta-one-index +EOF + +diff "$TMP/output.txt" "$TMP/expected.txt" diff --git a/test/e2e/html/html.hurl b/test/e2e/html/html.hurl index fb6fc506..03342d13 100644 --- a/test/e2e/html/html.hurl +++ b/test/e2e/html/html.hurl @@ -9,6 +9,7 @@ Content-Type: text/html xpath "string(/html/head/title)" == "Sourcemeta Schemas" xpath "count(//script[not(contains(@src, '?v='))])" == 0 xpath "count(//link[@rel='stylesheet' and not(contains(@href, '?v='))])" == 0 +xpath "boolean(//footer//small[contains(., '{{edition}}')])" == true header "Access-Control-Allow-Origin" not exists # This is a Safari Accept header