diff --git a/.github/workflows/publish-cli.yml b/.github/workflows/publish-cli.yml index e1696b80ed8..6b7f24c90a7 100644 --- a/.github/workflows/publish-cli.yml +++ b/.github/workflows/publish-cli.yml @@ -1,49 +1,13 @@ -name: Publish CLI +name: Publish Dev + Prod CLIs on: - workflow_call: - inputs: - version: - description: "The version of the CLI to release" - required: true - type: string - workflow_dispatch: - inputs: - version: - description: "The version of the CLI to release" - required: true - type: string - -# Add this permissions block -permissions: - contents: write - pull-requests: write + push: + branches: + - main jobs: - live-test: - environment: Fern Prod - runs-on: ubuntu-latest - steps: - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Install - uses: ./.github/actions/install - - - name: Check API definition is valid - env: - FORCE_COLOR: "2" - FERN_TOKEN: ${{ secrets.FERN_TOKEN }} - AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }} - AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }} - POSTHOG_API_KEY: ${{ secrets.POSTHOG_PROJECT_API_KEY }} - run: | - pnpm --filter @fern-api/cli dist:cli:prod - cli_path="$(pwd)/packages/cli/cli/dist/prod/bundle.cjs" - ./scripts/live-test.sh "$cli_path" "$FERN_TOKEN" - - publish-rc: - if: contains(inputs.version, '-rc') + publish-dev: + if: github.ref == 'refs/heads/main' runs-on: ubuntu-latest env: NPM_TOKEN: ${{ secrets.FERN_NPM_TOKEN }} @@ -62,13 +26,13 @@ jobs: - name: Print version run: | - git_version=${{ inputs.version }} + git_version="$(./scripts/git-version.sh)" echo Publishing version: "${git_version}" - name: Add version to dev package.json's run: | - git_version=${{ inputs.version }} - + git_version="$(./scripts/git-version.sh)" + cd packages/cli/cli mv package.json package.json.tmp version_replace="s/0.0.0/${git_version}/" @@ -83,12 +47,33 @@ jobs: - name: Compile run: pnpm --filter @fern-api/cli compile - - name: Publish fern-api CLI - run: pnpm --filter @fern-api/cli publish:cli:prod --tag prerelease + - name: Publish fern-api-dev CLI + run: pnpm --filter @fern-api/cli publish:cli:dev --access restricted + + # Test prod and try to publish, the publish command will handle if there's no diff + live-test: + environment: Fern Prod + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install + uses: ./.github/actions/install + + - name: Check API definition is valid + env: + FORCE_COLOR: "2" + FERN_TOKEN: ${{ secrets.FERN_TOKEN }} + AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }} + AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }} + POSTHOG_API_KEY: ${{ secrets.POSTHOG_PROJECT_API_KEY }} + run: | + pnpm --filter @fern-api/cli dist:cli:prod + cli_path="$(pwd)/packages/cli/cli/dist/prod/bundle.cjs" + ./scripts/live-test.sh "$cli_path" "$FERN_TOKEN" publish: - if: "!contains(inputs.version, '-rc')" - needs: live-test runs-on: ubuntu-latest env: NPM_TOKEN: ${{ secrets.FERN_NPM_TOKEN }} @@ -105,28 +90,10 @@ jobs: - name: Install uses: ./.github/actions/install - - name: Print version + - name: Publish CLI run: | - git_version=${{ inputs.version }} - echo Publishing version: "${git_version}" - - - name: Add version to package.json's - run: | - git_version=${{ inputs.version }} - - cd packages/cli/cli - mv package.json package.json.tmp - version_replace="s/0.0.0/${git_version}/" - cat package.json.tmp| sed "${version_replace}" > package.json - rm -rf package.json.tmp - - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc - - - name: Update pnpm lock with new versions - run: pnpm install - - - name: Compile - run: pnpm --filter @fern-api/cli compile + git show HEAD~1:packages/cli/cli/versions.yml > tmp_cli_previous_versions.yml + pnpm seed:local publish generator cli --versions-file packages/cli/cli/versions.yml --previous-versions-file tmp_cli_previous_versions.yml --log-level debug - - name: Publish fern-api CLI - run: pnpm --filter @fern-api/cli publish:cli:prod --tag latest + - name: Register CLI + run: pnpm seed:local register cli diff --git a/.github/workflows/publish-dev-cli.yml b/.github/workflows/publish-dev-cli.yml deleted file mode 100644 index 0d82081dd29..00000000000 --- a/.github/workflows/publish-dev-cli.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Publish Dev CLI - -on: - push: - branches: - - main - -jobs: - publish-dev: - if: github.ref == 'refs/heads/main' - runs-on: ubuntu-latest - env: - NPM_TOKEN: ${{ secrets.FERN_NPM_TOKEN }} - AUTH0_DOMAIN: ${{ secrets.AUTH0_DOMAIN }} - AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }} - POSTHOG_API_KEY: ${{ secrets.POSTHOG_PROJECT_API_KEY }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - - name: Install - uses: ./.github/actions/install - - - name: Print version - run: | - git_version="$(./scripts/git-version.sh)" - echo Publishing version: "${git_version}" - - - name: Add version to dev package.json's - run: | - git_version="$(./scripts/git-version.sh)" - - cd packages/cli/cli - mv package.json package.json.tmp - version_replace="s/0.0.0/${git_version}/" - cat package.json.tmp| sed "${version_replace}" > package.json - rm -rf package.json.tmp - - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc - - - name: Update pnpm lock with new versions - run: pnpm install - - - name: Compile - run: pnpm --filter @fern-api/cli compile - - - name: Publish fern-api-dev CLI - run: pnpm --filter @fern-api/cli publish:cli:dev --access restricted diff --git a/.github/workflows/publish-generator.yml b/.github/workflows/publish-generator.yml index 7477c4d596c..539fecd5a65 100644 --- a/.github/workflows/publish-generator.yml +++ b/.github/workflows/publish-generator.yml @@ -1,49 +1,26 @@ -name: publish-generators +# Generators are registered within seed.yml, once their tests are passing +name: publish-and-register-generators on: push: branches: - main paths: - - "generators/openapi/VERSION" - - "generators/python/sdk/VERSION" - - "generators/python/fastapi/VERSION" - - "generators/python/pydantic/VERSION" - - "generators/postman/VERSION" - - "generators/ruby/model/VERSION" - - "generators/ruby/sdk/VERSION" - - "generators/java/sdk/VERSION" - - "generators/java/model/VERSION" - - "generators/java/spring/VERSION" - - "generators/typescript/sdk/VERSION" - - "generators/typescript/express/VERSION" - - "generators/go/VERSION" - - "generators/csharp/sdk/VERSION" - - "generators/csharp/model/VERSION" - workflow_dispatch: - inputs: - generator: - description: "The generator to publish a dev release for" - required: true - type: choice - options: - - openapi - - python-sdk - - fastapi - - pydantic - - postman - - ruby-sdk - - ruby-model - - java-sdk - - java-model - - java-spring - - typescript-sdk - - typescript-express - - go-sdk - - go-model - - go-fiber - - csharp-sdk - - csharp-model + - "generators/openapi/versions.yml" + - "generators/python/sdk/versions.yml" + - "generators/python/fastapi/versions.yml" + - "generators/python/pydantic/versions.yml" + - "generators/postman/versions.yml" + - "generators/ruby/model/versions.yml" + - "generators/ruby/sdk/versions.yml" + - "generators/java/sdk/versions.yml" + - "generators/java/model/versions.yml" + - "generators/java/spring/versions.yml" + - "generators/typescript/sdk/versions.yml" + - "generators/typescript/express/versions.yml" + - "generators/go/versions.yml" + - "generators/csharp/sdk/versions.yml" + - "generators/csharp/model/versions.yml" env: DOCKER_BUILDKIT: 1 @@ -52,269 +29,42 @@ jobs: versions-changed: runs-on: ubuntu-latest outputs: - openapi: ${{ steps.filter.outputs.openapi }} - python-sdk: ${{ steps.filter.outputs.python-sdk }} - fastapi: ${{ steps.filter.outputs.fastapi }} - pydantic: ${{ steps.filter.outputs.pydantic }} - postman: ${{ steps.filter.outputs.postman }} - ruby-model: ${{ steps.filter.outputs.ruby-model }} - ruby-sdk: ${{ steps.filter.outputs.ruby-sdk }} - java-sdk: ${{ steps.filter.outputs.java-sdk }} - java-model: ${{ steps.filter.outputs.java-model }} - spring: ${{ steps.filter.outputs.spring }} - ts-sdk: ${{ steps.filter.outputs.ts-sdk }} - ts-express: ${{ steps.filter.outputs.ts-express }} - go-sdk: ${{ steps.filter.outputs.go-sdk }} - go-model: ${{ steps.filter.outputs.go-model }} - go-fiber: ${{ steps.filter.outputs.go-fiber }} - csharp-sdk: ${{ steps.filter.outputs.csharp-sdk }} - csharp-model: ${{ steps.filter.outputs.csharp-model }} + generators: ${{ steps.filter.outputs.changes }} steps: - uses: actions/checkout@v2 - - uses: dorny/paths-filter@v2 + - uses: dorny/paths-filter@v3 id: filter with: + # Pass in the list of files that have changed + list-files: json filters: | - openapi: 'generators/openapi/VERSION' - python-sdk: 'generators/python/sdk/VERSION' - fastapi: 'generators/python/fastapi/VERSION' - pydantic: 'generators/python/pydantic/VERSION' - postman: 'generators/postman/VERSION' - ruby-model: 'generators/ruby/model/VERSION' - ruby-sdk: 'generators/ruby/sdk/VERSION' - java-sdk: 'generators/java/sdk/VERSION' - java-model: 'generators/java/model/VERSION' - spring: 'generators/java/spring/VERSION' - ts-sdk: 'generators/typescript/sdk/VERSION' - ts-express: 'generators/typescript/express/VERSION' - go-sdk: 'generators/go/VERSION' - go-model: 'generators/go/VERSION' - go-fiber: 'generators/go/VERSION' - csharp-sdk: 'generators/csharp/sdk/VERSION' - csharp-model: 'generators/csharp/model/VERSION' + openapi: 'generators/openapi/versions.yml' + python-sdk: 'generators/python/sdk/versions.yml' + fastapi: 'generators/python/fastapi/versions.yml' + pydantic: 'generators/python/pydantic/versions.yml' + postman: 'generators/postman/versions.yml' + ruby-model: 'generators/ruby/model/versions.yml' + ruby-sdk: 'generators/ruby/sdk/versions.yml' + java-sdk: 'generators/java/sdk/versions.yml' + java-model: 'generators/java/model/versions.yml' + spring: 'generators/java/spring/versions.yml' + ts-sdk: 'generators/typescript/sdk/versions.yml' + ts-express: 'generators/typescript/express/versions.yml' + go-sdk: 'generators/go/versions.yml' + go-model: 'generators/go/versions.yml' + go-fiber: 'generators/go/versions.yml' + csharp-sdk: 'generators/csharp/sdk/versions.yml' + csharp-model: 'generators/csharp/model/versions.yml' - pydantic-model: + # Test, publish and register generators + publish-changed-generators: runs-on: ubuntu-latest needs: versions-changed - if: ${{ needs.versions-changed.outputs.pydantic == 'true' || inputs.generator == 'pydantic' }} + strategy: + matrix: + generator: ${{ fromJSON(needs.versions-changed.outputs.generators) }} steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install Poetry - uses: snok/install-poetry@v1 - - - name: Install - working-directory: ./generators/python - run: poetry install - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Print Version - if: ${{ inputs.generator != 'pydantic' }} - run: | - projectVersion=$(cat generators/python/pydantic/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - - name: Print Version Dev - if: ${{ inputs.generator == 'pydantic' }} - run: | - projectVersion=$(cat generators/python/pydantic/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ./generators/python - file: ./generators/python/pydantic/Dockerfile - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-pydantic-model:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-pydantic-model:latest') || '' }} - - fastapi: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.fastapi == 'true' || inputs.generator == 'fastapi' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install Poetry - uses: snok/install-poetry@v1 - - - name: Install - working-directory: ./generators/python - run: poetry install - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Print Version - if: ${{ inputs.generator != 'fastapi' }} - run: | - projectVersion=$(cat generators/python/fastapi/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - - name: Print Version Dev - if: ${{ inputs.generator == 'fastapi' }} - run: | - projectVersion=$(cat generators/python/fastapi/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ./generators/python - file: ./generators/python/fastapi/Dockerfile - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-fastapi-server:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-fastapi-server:latest') || '' }} - - python-sdk: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.python-sdk == 'true' || inputs.generator == 'python-sdk' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install Poetry - uses: snok/install-poetry@v1 - - - name: Install - working-directory: ./generators/python - run: poetry install - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Print Version - if: ${{ inputs.generator != 'python-sdk' }} - run: | - projectVersion=$(cat generators/python/sdk/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - - name: Print Version Dev - if: ${{ inputs.generator == 'python-sdk' }} - run: | - projectVersion=$(cat generators/python/sdk/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ./generators/python - file: ./generators/python/sdk/Dockerfile - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-python-sdk:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-python-sdk:latest') || '' }} - - openapi: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.openapi == 'true' || inputs.generator == 'openapi' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install - uses: ./.github/actions/install - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Build CLI - working-directory: ./generators/openapi - run: pnpm dist:cli - - - name: Print Version - if: ${{ inputs.generator != 'openapi' }} - run: | - projectVersion=$(cat generators/openapi/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - - name: Print Version Dev - if: ${{ inputs.generator == 'openapi' }} - run: | - projectVersion=$(cat generators/openapi/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ./generators/openapi - file: ./generators/openapi/Dockerfile - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-openapi:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-openapi:latest') || '' }} - - postman: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.postman == 'true' || inputs.generator == 'postman' }} - steps: - - name: Checkout repo + - name: Checkout repo at current ref uses: actions/checkout@v4 with: fetch-depth: 0 @@ -322,688 +72,69 @@ jobs: - name: Install uses: ./.github/actions/install - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Build CLI - working-directory: ./generators/postman - run: pnpm dist:cli - - - name: Print Version - if: ${{ inputs.generator != 'postman' }} + - name: Run publish + env: + DOCKER_USERNAME: fernapi + DOCKER_PASSWORD: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} run: | - projectVersion=$(cat generators/postman/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV + # This is wack and redundant, but the path filter Github Action above does not let you easily see + # the modified file once in the matrix, you have to access it at the filter (e.g. output.openapi_files) + # So as a workaround, we are doing this switch statement to set the VERSIONS_FILE variable and use that to publish - - name: Print Version Dev - if: ${{ inputs.generator == 'postman' }} - run: | - projectVersion=$(cat generators/postman/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV + if [ ${{ matrix.generator }} = "openapi" ]; then + VERSIONS_FILE="generators/openapi/versions.yml" - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + elif [ ${{ matrix.generator }} = "python-sdk" ]; then + VERSIONS_FILE="generators/python/sdk/versions.yml" - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ./generators/postman - file: ./generators/postman/Dockerfile - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-postman:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-postman:latest') || '' }} + elif [ ${{ matrix.generator }} = "fastapi" ]; then + VERSIONS_FILE="generators/python/fastapi/versions.yml" - ruby-model: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.ruby-model == 'true' || inputs.generator == 'ruby-model' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 + elif [ ${{ matrix.generator }} = "pydantic" ]; then + VERSIONS_FILE="generators/python/pydantic/versions.yml" - - name: Install - uses: ./.github/actions/install + elif [ ${{ matrix.generator }} = "postman" ]; then + VERSIONS_FILE="generators/postman/versions.yml" - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Build CLI - working-directory: ./generators/ruby/model - run: pnpm dist:cli - - - name: Print Version - if: ${{ inputs.generator != 'ruby-model' }} - run: | - projectVersion=$(cat generators/ruby/model/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV + elif [ ${{ matrix.generator }} = "ruby-model" ]; then + VERSIONS_FILE="generators/ruby/model/versions.yml" - - name: Print Version Dev - if: ${{ inputs.generator == 'ruby-model' }} - run: | - projectVersion=$(cat generators/ruby/model/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV + elif [ ${{ matrix.generator }} = "ruby-sdk" ]; then + VERSIONS_FILE="generators/ruby/sdk/versions.yml" - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + elif [ ${{ matrix.generator }} = "java-sdk" ]; then + VERSIONS_FILE="generators/java/sdk/versions.yml" - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: . - file: ./generators/ruby/model/Dockerfile - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-ruby-model:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-ruby-model:latest') || '' }} + elif [ ${{ matrix.generator }} = "java-model" ]; then + VERSIONS_FILE="generators/java/model/versions.yml" - ruby-sdk: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.ruby-sdk == 'true' || inputs.generator == 'ruby-sdk' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 + elif [ ${{ matrix.generator }} = "java-spring" ]; then + VERSIONS_FILE="generators/java/spring/versions.yml" - - name: Install - uses: ./.github/actions/install + elif [ ${{ matrix.generator }} = "ts-sdk" ]; then + VERSIONS_FILE="generators/typescript/sdk/versions.yml" - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} + elif [ ${{ matrix.generator }} = "ts-express" ]; then + VERSIONS_FILE="generators/typescript/express/versions.yml" - - name: Build CLI - working-directory: ./generators/ruby/sdk - run: pnpm dist:cli + elif [ ${{ matrix.generator }} = "go-sdk" ]; then + VERSIONS_FILE="generators/go/versions.yml" - - name: Print Version - if: ${{ inputs.generator != 'ruby-sdk' }} - run: | - projectVersion=$(cat generators/ruby/sdk/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV + elif [ ${{ matrix.generator }} = "go-model" ]; then + VERSIONS_FILE="generators/go/versions.yml" - - name: Print Version Dev - if: ${{ inputs.generator == 'ruby-sdk' }} - run: | - projectVersion=$(cat generators/ruby/sdk/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV + elif [ ${{ matrix.generator }} = "go-fiber" ]; then + VERSIONS_FILE="generators/go/versions.yml" - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 + elif [ ${{ matrix.generator }} = "csharp-sdk" ]; then + VERSIONS_FILE="generators/csharp/sdk/versions.yml" - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: . - file: ./generators/ruby/sdk/Dockerfile - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-ruby-sdk:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-ruby-sdk:latest') || '' }} + elif [ ${{ matrix.generator }} = "csharp-model" ]; then + VERSIONS_FILE="generators/csharp/model/versions.yml" + done - java-sdk: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.java-sdk == 'true' || inputs.generator == 'java-sdk' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Build tar - working-directory: ./generators/java - run: ./gradlew :sdk:distTar - - - name: Print Version - if: ${{ inputs.generator != 'java-sdk' }} - run: | - projectVersion=$(cat generators/java/sdk/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - - name: Print Version Dev - if: ${{ inputs.generator == 'java-sdk' }} - run: | - projectVersion=$(cat generators/java/sdk/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ./generators/java/sdk - file: ./generators/java/sdk/Dockerfile - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-java-sdk:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-java-sdk:latest') || '' }} - - java-model: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.java-model == 'true' || inputs.generator == 'java-model' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Build tar - working-directory: ./generators/java - run: ./gradlew :model:distTar - - - name: Print Version - if: ${{ inputs.generator != 'java-model' }} - run: | - projectVersion=$(cat generators/java/model/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - - name: Print Version Dev - if: ${{ inputs.generator == 'java-model' }} - run: | - projectVersion=$(cat generators/java/model/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ./generators/java/model - file: ./generators/java/model/Dockerfile - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/java-model:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/java-model:latest') || '' }} - - java-spring: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.java-model == 'true' || inputs.generator == 'java-spring' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} + git show HEAD~1:${VERSIONS_FILE} > tmp_${{ matrix.generator }}_previous_versions.yml - - name: Build tar - working-directory: ./generators/java - run: ./gradlew :spring:distTar - - - name: Print Version - if: ${{ inputs.generator != 'java-spring' }} - run: | - projectVersion=$(cat generators/java/spring/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - - name: Print Version Dev - if: ${{ inputs.generator == 'java-spring' }} - run: | - projectVersion=$(cat generators/java/spring/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ./generators/java/spring - file: ./generators/java/spring/Dockerfile - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-java-spring:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-java-spring:latest') || '' }} - - ts-express: - runs-on: ubuntu-latest - if: ${{ needs.versions-changed.outputs.ts-express == 'true' || inputs.generator == 'typescript-express' }} - needs: versions-changed - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install - uses: ./.github/actions/install - - - name: Print Version - if: ${{ inputs.generator != 'ts-sdk' }} - run: | - projectVersion=$(cat generators/typescript/express/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - - name: Print Version Dev - if: ${{ inputs.generator == 'ts-sdk' }} - run: | - projectVersion=$(cat generators/typescript/express/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Publish fernapi/fern-typescript-express-sdk docker - run: | - pnpm --filter @fern-typescript/express-generator-cli dockerTagVersion "$VERSION" - docker push fernapi/fern-typescript-express:"$VERSION" - - ts-browser-sdk: - runs-on: ubuntu-latest - if: ${{ needs.versions-changed.outputs.ts-sdk == 'true' || inputs.generator == 'typescript-sdk' }} - needs: versions-changed - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install - uses: ./.github/actions/install - - - name: Print Version - if: ${{ inputs.generator != 'ts-sdk' }} - run: | - projectVersion=$(cat generators/typescript/sdk/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - - name: Print Version Dev - if: ${{ inputs.generator == 'ts-sdk' }} - run: | - projectVersion=$(cat generators/typescript/sdk/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Publish fernapi/fern-typescript-node-sdk docker - run: | - pnpm --filter @fern-typescript/sdk-generator-cli dockerTagVersion:browser "$VERSION" - docker push fernapi/fern-typescript-browser-sdk:"$VERSION" - - ts-node-sdk: - runs-on: ubuntu-latest - if: ${{ needs.versions-changed.outputs.ts-sdk == 'true' || inputs.generator == 'typescript-sdk' }} - needs: versions-changed - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install - uses: ./.github/actions/install - - - name: Print Version - if: ${{ inputs.generator != 'ts-sdk' }} - run: | - projectVersion=$(cat generators/typescript/sdk/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - - name: Print Version Dev - if: ${{ inputs.generator == 'ts-sdk' }} - run: | - projectVersion=$(cat generators/typescript/sdk/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Publish fernapi/fern-typescript-node-sdk docker - run: | - pnpm --filter @fern-typescript/sdk-generator-cli dockerTagVersion:node "$VERSION" - docker push fernapi/fern-typescript-node-sdk:"$VERSION" - - go-sdk: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.go-sdk == 'true' || inputs.generator == 'go-sdk' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Build CLI - working-directory: ./generators/go - run: go build ./... - - - name: Print Version - if: ${{ inputs.generator != 'go-sdk' }} - run: | - projectVersion=$(cat generators/go/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - name: Print Version Dev - if: ${{ inputs.generator == 'go-sdk' }} - run: | - projectVersion=$(cat generators/go/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ./generators/go - file: ./generators/go/docker/Dockerfile.sdk - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-go-sdk:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-go-sdk:latest') || '' }} - - go-model: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.go-model == 'true' || inputs.generator == 'go-model' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Build CLI - working-directory: ./generators/go - run: go build ./... - - - name: Print Version - if: ${{ inputs.generator != 'go-model' }} - run: | - projectVersion=$(cat generators/go/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - name: Print Version Dev - if: ${{ inputs.generator == 'go-model' }} - run: | - projectVersion=$(cat generators/go/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ./generators/go - file: ./generators/go/docker/Dockerfile.model - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-go-model:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-go-model:latest') || '' }} - - go-fiber: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.go-fiber == 'true' || inputs.generator == 'go-fiber' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Build CLI - working-directory: ./generators/go - run: go build ./... - - - name: Print Version - if: ${{ inputs.generator != 'go-fiber' }} - run: | - projectVersion=$(cat generators/go/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - name: Print Version Dev - if: ${{ inputs.generator == 'go-fiber' }} - run: | - projectVersion=$(cat generators/go/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: ./generators/go - file: ./generators/go/docker/Dockerfile.fiber - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-go-fiber:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-go-fiber:latest') || '' }} - - csharp-model: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.csharp-model == 'true' || inputs.generator == 'csharp-model' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install - uses: ./.github/actions/install - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Build CLI - working-directory: ./generators/csharp/model - run: pnpm dist:cli - - - name: Print Version - if: ${{ inputs.generator != 'csharp-model' }} - run: | - projectVersion=$(cat generators/csharp/model/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - - name: Print Version Dev - if: ${{ inputs.generator == 'ruby-model' }} - run: | - projectVersion=$(cat generators/csharp/model/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: . - file: ./generators/csharp/model/Dockerfile - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-csharp-model:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-csharp-model:latest') || '' }} - - csharp-sdk: - runs-on: ubuntu-latest - needs: versions-changed - if: ${{ needs.versions-changed.outputs.csharp-sdk == 'true' || inputs.generator == 'csharp-sdk' }} - steps: - - name: Checkout repo - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Install - uses: ./.github/actions/install - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: fernapi - password: ${{ secrets.FERN_API_DOCKERHUB_PASSWORD }} - - - name: Build CLI - working-directory: ./generators/csharp/sdk - run: pnpm dist:cli - - - name: Print Version - if: ${{ inputs.generator != 'csharp-sdk' }} - run: | - projectVersion=$(cat generators/csharp/sdk/VERSION) - echo $projectVersion - echo "VERSION=$projectVersion" >> $GITHUB_ENV - - - name: Print Version Dev - if: ${{ inputs.generator == 'csharp-sdk' }} - run: | - projectVersion=$(cat generators/csharp/sdk/VERSION) - commitNumber=$(git log --oneline | wc -l ) - sha_short=$(git rev-parse --short HEAD) - echo $projectVersion-$commitNumber-$sha_short - echo "VERSION=$projectVersion-$commitNumber-$sha_short" >> $GITHUB_ENV - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: . - file: ./generators/csharp/sdk/Dockerfile - platforms: linux/amd64,linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=min - push: true - labels: version=${{env.VERSION}} - tags: fernapi/fern-csharp-sdk:${{env.VERSION}}${{ (!contains(env.VERSION, '-rc') && ', fernapi/fern-csharp-sdk:latest') || '' }} + pnpm seed:local test --generators ${{ matrix.generator }} + pnpm seed:local publish generator ${{ matrix.generator }} --changelog $VERSIONS_FILE --previous-changelog tmp_${{ matrix.generator }}_previous_versions.yml --log-level debug + pnpm seed:local register generator --generators ${{ matrix.generator }} diff --git a/.github/workflows/seed.yml b/.github/workflows/seed.yml index f0297543d12..8b95d465ae6 100644 --- a/.github/workflows/seed.yml +++ b/.github/workflows/seed.yml @@ -1,9 +1,6 @@ name: seed on: - push: - branches: - - main pull_request: branches: - main @@ -90,7 +87,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -99,7 +96,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator ruby-model + pnpm seed:local test --generators ruby-model - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -121,7 +118,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -130,7 +127,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator ruby-sdk + pnpm seed:local test --generators ruby-sdk - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -152,7 +149,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -168,7 +165,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator pydantic + pnpm seed:local test --generators pydantic - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -190,7 +187,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -206,7 +203,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator python-sdk --parallel 10 + pnpm seed:local test --generators python-sdk --parallel 10 - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -228,7 +225,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -244,7 +241,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator fastapi + pnpm seed:local test --generators fastapi - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -266,7 +263,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -275,7 +272,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator openapi + pnpm seed:local test --generators openapi - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -297,7 +294,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -306,7 +303,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator postman + pnpm seed:local test --generators postman - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -328,7 +325,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -337,7 +334,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator java-sdk --parallel 10 + pnpm seed:local test --generators java-sdk --parallel 10 - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -359,7 +356,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -368,7 +365,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator java-model --parallel 10 + pnpm seed:local test --generators java-model --parallel 10 - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -390,7 +387,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -399,7 +396,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator java-spring + pnpm seed:local test --generators java-spring - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -421,7 +418,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -430,7 +427,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator ts-sdk --parallel 10 + pnpm seed:local test --generators ts-sdk --parallel 10 - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -452,7 +449,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -461,7 +458,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator ts-express --parallel 10 + pnpm seed:local test --generators ts-express --parallel 10 - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -483,7 +480,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -492,7 +489,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator go-fiber --parallel 16 + pnpm seed:local test --generators go-fiber --parallel 16 - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -514,7 +511,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -523,7 +520,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator go-model --parallel 16 + pnpm seed:local test --generators go-model --parallel 16 - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -545,7 +542,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -554,7 +551,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator go-sdk --parallel 16 + pnpm seed:local test --generators go-sdk --parallel 16 - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -576,7 +573,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -585,7 +582,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator csharp-model --parallel 16 + pnpm seed:local test --generators csharp-model --parallel 16 - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" @@ -607,7 +604,7 @@ jobs: - uses: actions/setup-go@v5 with: - go-version: 'stable' + go-version: "stable" - name: Install protoc-gen-openapi run: go install github.com/google/gnostic/cmd/protoc-gen-openapi@v0.7.0 @@ -616,7 +613,7 @@ jobs: env: FORCE_COLOR: "2" run: | - pnpm seed:local test --generator csharp-sdk --parallel 16 + pnpm seed:local test --generators csharp-sdk --parallel 16 - name: Ensure no changes to git-tracked files run: git --no-pager diff --exit-code -- ":(exclude)seed/*/.mock/*" diff --git a/generators/python/fastapi/versions.yml b/generators/python/fastapi/versions.yml new file mode 100644 index 00000000000..13ba10dfe38 --- /dev/null +++ b/generators/python/fastapi/versions.yml @@ -0,0 +1,249 @@ +- version: 1.4.6 + created_at: '2024-08-16' + changelog_entry: + - type: internal + summary: >- + Upgrade intermediate representation dependency to safely parse null + unknown types. + ir_version: 53 + +- version: 1.4.5 + created_at: '2024-08-14' + changelog_entry: + - type: chore + summary: Improve performance of Pydantic `.dict` calls + changed: + - >- + `.dict` performance is improved, consolidating to a single call to + Pydantic's `.dict` instead of 2 in attempts to remove unset optional + values. + ir_version: 53 + +- version: 1.4.4 + created_at: '2024-08-13' + changelog_entry: + - type: fix + summary: Unions with utils now update forward refs again + ir_version: 53 + +- version: 1.4.3 + created_at: '2024-08-09' + changelog_entry: + - type: fix + summary: >- + Add back kwargs to validator decorators, a regression introduced in + 1.0.0. + ir_version: 53 + +- version: 1.4.2 + created_at: '2024-08-09' + changelog_entry: + - type: fix + summary: >- + Remove functools.wrap from validator decorators, a regression introduced + in 1.0.0. + ir_version: 53 + +- version: 1.4.1 + created_at: '2024-08-05' + changelog_entry: + - type: fix + summary: >- + The root type for unions with visitors now has it's parent typed + correctly. This allows auto-complete to work once again on the union + when it's nested within other pydantic models. + ir_version: 53 + +- version: 1.4.0 + created_at: '2024-08-05' + changelog_entry: + - type: fix + summary: Auto-completion for unions leveraging union utils now works as expected. + changed: + - >- + The root type for unions with visitors now has it's parent typed + correctly. This allows auto-complete to work once again on the union + when it's nested within other pydantic models. + fixed: + - >- + Partial classes created for validation now appropriately ignore the + universal root model and only create partials off true extended + classes. + ir_version: 53 + +- version: 1.3.0 + created_at: '2024-08-04' + changelog_entry: + - type: internal + summary: Generator code now uses Pydantic V2, no changes to generated code. + changed: + - >- + The generator has now been upgraded to use Pydantic V2 internally. + Note that there is no change to the generated code, however by + leveraging Pydantic V2 you should notice an improvement in `fern + generate` times. + ir_version: 53 + +- version: 1.2.0 + created_at: '2024-07-31' + changelog_entry: + - type: feat + summary: >- + The FastAPI `async_handlers` configuration now accepts a list of string + or a boolean so that users can turn on async handlers for specific + endpoints. + ir_version: 53 + +- version: 1.1.0-rc0 + created_at: '2024-07-31' + changelog_entry: + - type: internal + summary: The generator now consumes IRv53. + ir_version: 53 + +- version: 1.0.0-rc0 + created_at: '2024-07-16' + changelog_entry: + - type: break + summary: >- + The generated models now support Pydantic V2 outright, it no longer uses + `pydantic.v1` models. + changed: + - >- + The generated server stubs now support Pydantic V2 outright, it no + longer uses `pydantic.v1` models. + - >- + Public fields previously prefixed with `_` are now prefixed with `f_` + (Pydantic V2 does not allow for `_` prefixes on public fields and + Python does not allow for a numeric prefix) + removed: + - wrapped aliases outside of Pydantic V1 + - custom root validators outside of Pydantic V1 + ir_version: 49 + +- version: 0.11.1 + created_at: '2024-07-10' + changelog_entry: + - type: fix + summary: Expose the `use_str_enums` flag. + fixed: + - >- + The generator now respects the `use_str_enums` flag, and defaults it + to `False`. + ir_version: 49 + +- version: 0.11.0 + created_at: '2024-07-10' + changelog_entry: + - type: fix + summary: Correctly sanitize parameter descriptions. + fixed: + - >- + The generator now correctly sanitizes parameter descriptions. + Previously it was duplicating strings. + ir_version: 49 + +- version: 0.11.0-rc0 + created_at: '2024-06-24' + changelog_entry: + - type: internal + summary: The generator now consumes IRV49. + ir_version: 49 + +- version: 0.10.1 + created_at: '2024-06-19' + changelog_entry: + - type: internal + summary: The generator now consumes IRV46. + ir_version: 46 + +- version: 0.10.0 + created_at: '2024-06-19' + changelog_entry: + - type: chore + summary: Expose the `extra_fields` configuration. + ir_version: 39 + +- version: 0.9.3 + created_at: '2024-06-06' + changelog_entry: + - type: fix + summary: >- + Leveraged pydantic utilities are copied over for use within the FastAPI + server. + ir_version: 39 + +- version: 0.9.2 + created_at: '2024-05-27' + changelog_entry: + - type: fix + summary: Paths are no longer prefixed with double forward slashes. + ir_version: 39 + +- version: 0.9.1 + created_at: '2024-05-09' + changelog_entry: + - type: internal + summary: Release Generator + ir_version: 39 + +- version: 0.9.1-rc0 + created_at: '2024-04-22' + changelog_entry: + - type: fix + summary: >- + Leveraged pydantic utilities are copied over for use within the FastAPI + server. + ir_version: 39 + +- version: 0.9.0-rc1 + created_at: '2024-06-19' + changelog_entry: + - type: internal + summary: The generator now consumes IRV39. + ir_version: 39 + +- version: 0.9.0-rc0 + created_at: '2024-01-29' + changelog_entry: + - type: internal + summary: The generator now consumes IRV38. + - type: break + summary: The generator no longer supports Python 3.7 + removed: + - The generator no longer supports Python 3.7 + - The `backports` dependency has been removed + ir_version: 38 + +- version: 0.8.1-rc0 + created_at: '2024-01-29' + changelog_entry: + - type: fix + summary: >- + Increase allowed recursion depth to account for highly nested and + complex examples. + fixed: + - >- + Recursion depth is increased to allow for highly nested and complex + examples, this is a temporary solution while the example datamodel is + further refined. + ir_version: 31 + +- version: 0.8.0-rc0 + created_at: '2024-01-28' + changelog_entry: + - type: fix + summary: The SDK now better handles cyclical references. + fixed: + - >- + The SDK now better handles cyclical references. In particular, + cyclical references are tracked for undiscriminated unions, and + update_forward_refs is always called with object references. + ir_version: 31 + +- version: 0.7.7 + created_at: '2024-01-21' + changelog_entry: + - type: internal + summary: Initialize the changelog + ir_version: 31 diff --git a/generators/python/pydantic/versions.yml b/generators/python/pydantic/versions.yml new file mode 100644 index 00000000000..ab1847bfc86 --- /dev/null +++ b/generators/python/pydantic/versions.yml @@ -0,0 +1,180 @@ +- version: 1.4.3 + created_at: '2024-08-16' + changelog_entry: + - type: fix + summary: >- + Upgrade intermediate representation dependency to safely parse null + unknown types. + ir_version: 53 + +- version: 1.4.2 + created_at: '2024-08-14' + changelog_entry: + - type: chore + summary: Improve performance of Pydantic `.dict` calls + changed: + - >- + `.dict` performance is improved, consolidating to a single call to + Pydantic's `.dict` instead of 2 in attempts to remove unset optional + values. + ir_version: 53 + +- version: 1.4.1 + created_at: '2024-08-13' + changelog_entry: + - type: fix + summary: Unions with utils now update forward refs again + ir_version: 53 + +- version: 1.4.0 + created_at: '2024-08-06' + changelog_entry: + - type: feat + summary: Exposes `package_name` configuration option + added: + - >- + Exposes `package_name` configuration option for pydantic models. This + field controls the package from which users will import your client, + for example, the following config would allow users to use: `from + my_custom_package import Client` + ir_version: 53 + +- version: 1.3.1 + created_at: '2024-08-05' + changelog_entry: + - type: fix + summary: Auto-completion for unions leveraging union utils now works as expected. + fixed: + - >- + The root type for unions with visitors now has it's parent typed + correctly. This allows auto-complete to work once again on the union + when it's nested within other pydantic models. + ir_version: 53 + +- version: 1.3.0 + created_at: '2024-08-05' + changelog_entry: + - type: feat + summary: Generated code now respects the pydantic version configuration flag. + changed: + - >- + The generated server code now respects the pydantic version flag, + generating V1 only code and V2 only code if specified. If not, the + server is generated as it is today, with compatibility for BOTH + Pydantic versions. This cleans up the generated code, and brings back + features liked wrapped aliases and custom root validators for V1-only + servers. + ir_version: 53 + +- version: 1.2.0 + created_at: '2024-08-04' + changelog_entry: + - type: internal + summary: Generator code now uses Pydantic V2, no changes to generated code. + changed: + - >- + The generator has now been upgraded to use Pydantic V2 internally. + Note that there is no change to the generated code, however by + leveraging Pydantic V2 you should notice an improvement in `fern + generate` times. + ir_version: 53 + +- version: 1.1.0-rc0 + created_at: '2024-07-31' + changelog_entry: + - type: internal + summary: The generator now consumes IRv53. + ir_version: 53 + +- version: 1.0.0-rc0 + created_at: '2024-07-16' + changelog_entry: + - type: break + summary: >- + The generated models now support Pydantic V2 outright, it no longer uses + `pydantic.v1` models. + changed: + - >- + The generated models now support Pydantic V2 outright, it no longer + uses `pydantic.v1` models. + - >- + Public fields previously prefixed with `_` are now prefixed with `f_` + (Pydantic V2 does not allow for `_` prefixes on public fields and + Python does not allow for a numeric prefix) + removed: + - wrapped aliases outside of Pydantic V1 + - custom root validators outside of Pydantic V1 + ir_version: 49 + +- version: 0.10.0-rc0 + created_at: '2024-06-24' + changelog_entry: + - type: internal + summary: The generator now consumes IRV49. + ir_version: 49 + +- version: 0.9.1 + created_at: '2024-06-19' + changelog_entry: + - type: internal + summary: The generator now consumes IRV46. + ir_version: 46 + +- version: 0.9.0 + created_at: '2024-05-09' + changelog_entry: + - type: internal + summary: Release Generator + ir_version: 39 + +- version: 0.9.0-rc1 + created_at: '2024-04-22' + changelog_entry: + - type: internal + summary: The generator now consumes IRV39. + ir_version: 39 + +- version: 0.9.0-rc0 + created_at: '2024-01-29' + changelog_entry: + - type: internal + summary: The generator now consumes IRV38. + - type: break + summary: The generator no longer supports Python 3.7 + removed: + - The generator no longer supports Python 3.7 + - The `backports` dependency has been removed + ir_version: 38 + +- version: 0.8.1-rc0 + created_at: '2024-01-29' + changelog_entry: + - type: fix + summary: >- + Increase allowed recursion depth to account for highly nested and + complex examples. + fixed: + - >- + Recursion depth is increased to allow for highly nested and complex + examples, this is a temporary solution while the example datamodel is + further refined. + ir_version: 31 + +- version: 0.8.0-rc0 + created_at: '2024-01-28' + changelog_entry: + - type: fix + summary: The SDK now better handles cyclical references. + fixed: + - >- + The SDK now better handles cyclical references. In particular, + cyclical references are tracked for undiscriminated unions, and + update_forward_refs is always called with object references. + ir_version: 31 + +- version: 0.7.7 + created_at: '2024-01-21' + changelog_entry: + - type: internal + summary: Initialize the changelog + ir_version: 31 diff --git a/generators/python/sdk/versions.yml b/generators/python/sdk/versions.yml index 9061000122d..e0b0a9f2c78 100644 --- a/generators/python/sdk/versions.yml +++ b/generators/python/sdk/versions.yml @@ -1,10 +1,1477 @@ # TODO: It'd be great if we generated YAML schemas so people had validation on these files - version: 3.10.6 - ir_version: v53 + ir_version: 53 changelog_entry: - type: "fix" - fixed: - - Cursor-based pagination also assumes `""` is a terminal signal for pagination, same as if the next cursor were `None`. + - type: fix + summary: Pagination utilities assume `""` is a terminal signal for pagination. + fixed: + - >- + Cursor-based pagination also assumes `""` is a terminal signal for + pagination, same as if the next cursor were `None`. # This field is optional and can be omitted outside of the backfilling usecase # here it will default to the day the record was written to the DB - created_at: 2024-08-16 + created_at: '2024-08-16' + +- version: 3.10.3 + created_at: '2024-08-16' + ir_version: 53 + changelog_entry: + - type: fix + summary: Upgrade intermediate representation dependency to safely parse null unknown types. + +- version: 3.10.4 + created_at: '2024-08-14' + changelog_entry: + - type: chore + summary: Improve performance of Pydantic `.dict` calls + changed: + - "`.dict` performance is improved, consolidating to a single call to Pydantic's `.dict` instead of 2 in attempts to remove unset optional values." + ir_version: 53 + +- version: 3.10.3 + created_at: '2024-08-14' + changelog_entry: + - type: fix + summary: Query encoding now appropriately takes arrays of deep objects into account. + ir_version: 53 + +- version: 3.10.2 + created_at: '2024-08-13' + changelog_entry: + - type: fix + summary: Unions with utils now update forward refs again, a regression that was introduced in version 3.7.0 + ir_version: 53 + +- version: 3.10.1 + created_at: '2024-08-13' + changelog_entry: + - type: fix + summary: If there are no autogenerated examples present, the Python SDK generator no longer fails. + ir_version: 53 + +- version: 3.10.0 + created_at: '2024-08-09' + changelog_entry: + - type: feat + summary: Introduce forward compatible Python enums + added: + - >- + Adds a new flag to generate forward compatible Python enums, as opposed + to leveraging raw string enums as literals. This works through addding + an "_UNKNOWN" member to your enum set, the value of which is the raw + value of the unrecognized enum. + ir_version: 53 + +- version: 3.9.0 + created_at: '2024-08-09' + changelog_entry: + - type: feat + summary: Introduce Pythonic naming for discriminated union members through `union_naming` configuration flag. + added: + - >- + A new configuration is introduced to make discriminated union member + naming more Pythonic. With V1 union naming, member names change from + `_` to ``. + Concretely, union members previously named `Chat_User` will now be named + `UserChat` under the new configuration. + ir_version: 53 + +- version: 3.8.0 + created_at: '2024-08-09' + changelog_entry: + - type: chore + summary: Generated SDKs now use ruff for linting and formatting instead of Black. + ir_version: 53 + +- version: 3.7.0 + created_at: '2024-08-08' + changelog_entry: + - type: chore + summary: Python circular referencing types are more robust. + ir_version: 53 + +- version: 3.6.0 + created_at: '2024-08-08' + changelog_entry: + - type: feat + summary: The generator now respects returning nested properties from the returned object + ir_version: 53 + +- version: 3.5.1 + created_at: '2024-08-05' + changelog_entry: + - type: fix + summary: Auto-completion for unions leveraging union utils now works as expected. + fixed: + - >- + The root type for unions with visitors now has it's parent typed + correctly. This allows auto-complete to work once again on the union + when it's nested within other pydantic models. + ir_version: 53 + +- version: 3.5.0 + created_at: '2024-08-05' + changelog_entry: + - type: chore + summary: Generated code now respects the pydantic version configuration flag. + changed: + - >- + Improvement: The generated SDK now respects the pydantic version flag, + generating V1 only code and V2 only code if specified. If not, the SDK + is generated as it is today, with compatibility for BOTH Pydantic + versions. This cleans up the generated code, and brings back features + liked wrapped aliases for V1-only SDKs. + ir_version: 53 + +- version: 3.4.2 + created_at: '2024-08-05' + changelog_entry: + - type: fix + summary: The Python generator now instantiates `Any` types as `Optional[Any]` to be able to mitigate breaks in Pydantic V2. + ir_version: 53 + +- version: 3.4.1 + created_at: '2024-08-04' + changelog_entry: + - type: chore + summary: Literal templates are generated if they are union members + ir_version: 53 + +- version: 3.4.0 + created_at: '2024-08-02' + changelog_entry: + - type: internal + summary: Generator code now uses Pydantic V2, no changes to generated code. + changed: + - >- + Internal: The SDK generator has now been upgraded to use Pydantic V2 + internally. Note that there is no change to the generated code, however + by leveraging Pydantic V2 you should notice an improvement in `fern + generate` times. + ir_version: 53 + +- version: 3.3.4 + created_at: '2024-08-02' + changelog_entry: + - type: chore + summary: Address a number of issues within generated unit tests. + changed: + - >- + Improvement: Aliased literals are also defaulted within Pydantic models, + whereas previously only direct literals were defaulted. + - >- + Improvement: Snippets now provide optional literals in functions and + models. + fixed: + - >- + Generated tests that expect an empty result when they are of type `text` + (not JSON) now appropriately expect an empty string instead of `None`. + ir_version: 53 + +- version: 3.3.3 + created_at: '2024-08-02' + changelog_entry: + - type: fix + summary: The generator now allows you to extend aliased types (as long as they're objects). + ir_version: 53 + +- version: 3.3.2 + created_at: '2024-08-02' + changelog_entry: + - type: fix + summary: Regression in readme generation introduced in 3.3.1 + ir_version: 53 + +- version: 3.3.1 + created_at: '2024-08-02' + changelog_entry: + - type: fix + summary: Generated READMEs now reference RequestOptions as TypedDicts correctly. + ir_version: 53 + +- version: 3.3.0-rc1 + created_at: '2024-08-01' + changelog_entry: + - type: fix + summary: TypedDict snippets now include literals where available. + ir_version: 53 + +- version: 3.3.0-rc0 + created_at: '2024-07-31' + changelog_entry: + - type: internal + summary: Upgrade to IR 53.1.0 + changed: + - 'Upgrade to IR 53.1.0' + - The Python generator now creates snippet templates for undiscriminated unions. + ir_version: 53 + +- version: 3.2.0-rc1 + created_at: '2024-07-29' + changelog_entry: + - type: fix + summary: The generated README now imports `ApiError` as if it were from outside the module. + ir_version: 49 + +- version: 3.2.0-rc0 + created_at: '2024-07-25' + changelog_entry: + - type: feat + summary: The Python SDK can now be generated with TypedDicts as inputs. + added: + - >- + The Python SDK can now be generated such that inputs to requests are + TypedDicts, instead of Pydantic models. This allows for consumers of the + SDK to continue to have type hinting and autocomplete, but not need to + import new object types when creating requests. + ir_version: 49 + +- version: 3.1.0-rc0 + created_at: '2024-07-24' + changelog_entry: + - type: chore + summary: The root client is now exported from the main `__init__.py`. + changed: + - >- + Improvement: The root client users interact with is now exported from + the main `__init__.py`, this allows users to access the client via `from + my_sdk import my_sdk_client` as opposed to `from my_sdk.client import + my_sdk_client`. + removed: + - >- + Note this comes with an edge-case break. In the unlikely event you have + a type that conflicts in naming with the exported root client, that type + model is post-fixed with "Model". e.g. a type `Merge` in an SDK + exporting a client `Merge` becomes `MergeModel`. + ir_version: 49 + +- version: 3.0.0-rc2 + created_at: '2024-07-24' + changelog_entry: + - type: fix + summary: "`update_forward_refs` no longer raises errors, preserving original behavior, pre-3.x." + ir_version: 49 + +- version: 3.0.0-rc1 + created_at: '2024-07-23' + changelog_entry: + - type: fix + summary: "`expected_types` within our test suite are now typed as `Tuple[typing.Any, typing.Any]`." + fixed: + - >- + Sometimes mypy will error on the typing of `expected_types` within our + test suite, despite them being labeled as `typing.Any`. This updates the + types for tuples to `typing.Tuple[tying.Any, typing.Any]` to appease + mypy. + ir_version: 49 + +- version: 3.0.0-rc0 + created_at: '2024-07-23' + changelog_entry: + - type: break + summary: The generated models now support Pydantic V2 outright, it no longer uses `pydantic.v1` models. + changed: + - The generated models now support Pydantic V2 outright, it no longer uses `pydantic.v1` models. + - Public fields previously prefixed with `_` are now prefixed with `f_` (Pydantic V2 does not allow for `_` prefixes on public fields and Python does not allow for a numeric prefix) + removed: + - wrapped aliases outside of Pydantic V1 + - custom root validators outside of Pydantic V1 + ir_version: 49 + +- version: 2.16.0 + created_at: '2024-07-16' + changelog_entry: + - type: feat + summary: The generated SDK now allows for specifying whether or not to generate `streaming` functions as overloaded functions or separate functions. + ir_version: 49 + +- version: 2.15.6 + created_at: '2024-07-17' + changelog_entry: + - type: fix + summary: The generated python SDK now requires an environment be specified if a default is not provided. + ir_version: 49 + +- version: 2.15.5 + created_at: '2024-07-17' + changelog_entry: + - type: fix + summary: The generated python SDK Oauth client now no longer checks for an expiry when getting the access token if an expiry field is not configured. + ir_version: 49 + +- version: 2.15.4 + created_at: '2024-07-10' + changelog_entry: + - type: fix + summary: The generated python SDK now serializes bytes within JSON as a utf-8 encoded string. + ir_version: 49 + +- version: 2.15.3 + created_at: '2024-07-10' + changelog_entry: + - type: fix + summary: The generated python SDK no longer runs into a recursion error during snippet generation. + ir_version: 49 + +- version: 2.15.2 + created_at: '2024-07-10' + changelog_entry: + - type: fix + summary: The generated python SDK no longer treats `set` as a reserved word for method names. + ir_version: 49 + +- version: 2.15.1 + created_at: '2024-07-09' + changelog_entry: + - type: fix + summary: The unchecked base model no longer coerces None to a type. + fixed: + - The unchecked base model no longer coerces None to a type. + - >- + The http client appropriately defaults empty fields within + RequestOptions. + ir_version: 49 + +- version: 2.15.0 + created_at: '2024-07-03' + changelog_entry: + - type: feat + summary: The generated python SDK now respects configured defaults from the API spec. + ir_version: 49 + +- version: 2.14.1 + created_at: '2024-07-01' + changelog_entry: + - type: fix + summary: typing within the Sync and AsyncPagers is now correctly passed through to the BasePager. + fixed: + - >- + Sync and AsyncPage now pass through the generic type to BasePage, + allowing the use of `.items`, etc. to be appropriately typed within your + type checking system. + ir_version: 49 + +- version: 2.14.0 + created_at: '2024-07-01' + changelog_entry: + - type: fix + summary: The offset page now allows for the usage of 0 as a page start. + fixed: + - >- + offset page now allows for the usage of 0 as a page start, previously + the use of `page or 1` made Python coerce booleans and become 1, + ignoring the user-provided 0. + ir_version: 49 + +- version: 2.14.0-rc3 + created_at: '2024-07-01' + changelog_entry: + - type: feat + summary: Generated readmes now include an "advanced" section. + changed: + - >- + Generated readmes now include an "advanced" section, + outlining usage of retries, timeouts, error handling and usage of a + custom client. + ir_version: 49 + +- version: 2.14.0-rc2 + created_at: '2024-07-01' + changelog_entry: + - type: chore + summary: Async snippets now run the async function leveraging asyncio.run to be more copy-pastable. + ir_version: 49 + +- version: 2.14.0-rc1 + created_at: '2024-06-27' + changelog_entry: + - type: fix + summary: The fix from 2.5.2 is now case-insentitive + fixed: + - >- + the fix from 2.5.2 is now case-insentitive Recap of 2.5.2: `Fix: Support + `list`SDK method names instead of defaulting to`list\_`.` + ir_version: 49 + +- version: 2.14.0-rc0 + created_at: '2024-06-26' + changelog_entry: + - type: feat + summary: The Python SDK now generates an accompanying SDK reference (`reference.md`) for users to review the SDK methods at a glance within the SDK's GitHub repository. + ir_version: 49 + +- version: 2.13.1-rc0 + created_at: '2024-06-20' + changelog_entry: + - type: fix + summary: The Python SDK now does not send additional properties via JSON or data if the request is leveraging the other field. + fixed: + - >- + the Python SDK now does not send additional properties via JSON or data + if the request is leveraging the other field. + changed: + - >- + Improvement: the Python SDK now copies unit tests over to the generated + SDK for additional unit testing (separate from wire-format testing). + ir_version: 49 + +- version: 2.13.0-rc0 + created_at: '2024-06-20' + changelog_entry: + - type: internal + summary: The Python SDK generator is now upgraded to IR V49. + ir_version: 49 + +- version: 2.12.0-rc0 + created_at: '2024-06-25' + changelog_entry: + - type: feat + summary: README generation now supports a section dedicated to streaming usage, as well as one for paginated endpoints. + added: + - >- + Feature: README generation now supports a section dedicated to streaming + usage, as well as one for paginated endpoints. + changed: + - 'Improvement: Paginated endpoint snippets now show using an iterator:' + ir_version: 49 + +- version: 2.11.0-rc0 + created_at: '2024-06-25' + changelog_entry: + - type: chore + summary: Snippet templates now support auth variables within the root client. + changed: + - >- + Improvement: The SDK now produces templates for the root clients within + snippet-template.json. This allows users of the Templates API to pass in + data for the auth variables present within the root client. + ir_version: 49 + +- version: 2.10.2 + created_at: '2024-06-20' + changelog_entry: + - type: fix + summary: The SDK now handles stream termination sequences like `[DONE]`. + fixed: + - >- + The SDK now handles stream termination sequences like `[DONE]`. This is + a typical way for LLM providers to communicate when the stream has + ended. + ir_version: 46 + +- version: 2.10.1 + created_at: '2024-06-20' + changelog_entry: + - type: fix + summary: Improve the SDK to not leak `JSONDecodeError` to SDK users. Instead, an `ApiError` will be thrown with the text content of the response. + ir_version: 46 + +- version: 2.10.0 + created_at: '2024-06-20' + changelog_entry: + - type: feat + summary: Add support for higher quality `README.md` generation. + ir_version: 46 + +- version: 2.9.10 + created_at: '2024-06-20' + changelog_entry: + - type: fix + summary: The generator now only specifies the readme location within pyproject.toml if one was successfully created. + ir_version: 46 + +- version: 2.9.9 + created_at: '2024-06-19' + changelog_entry: + - type: internal + summary: The generator now consumes IRv46. + ir_version: 46 + +- version: 2.9.8 + created_at: '2024-06-18' + changelog_entry: + - type: chore + summary: The python generator only adds a publish step in github actions if credentials are specified. + ir_version: 39 + +- version: 2.9.7 + created_at: '2024-06-12' + changelog_entry: + - type: fix + summary: The unchecked base model stops special casing defaults and pydantic v2. + ir_version: 39 + +- version: 2.9.6 + created_at: '2024-06-11' + changelog_entry: + - type: fix + summary: Offset based pagination is now 1-based, as opposed to 0 based + fixed: + - Offset based pagination is now 1-based, as opposed to 0 based + - >- + The HTTP client now passes in additional body properties from the + request options, even if the body is empty (regression from the client + migration in 2.8.0) + ir_version: 39 + +- version: 2.9.5 + created_at: '2024-06-10' + changelog_entry: + - type: fix + summary: Unions with elements that specify no properties are generated correctly. + fixed: + - Unions with elements that specify no properties are generated correctly. + - >- + Unions with a single type now have a valid type alias (rather than an + invalid `typing.Union`). + ir_version: 39 + +- version: 2.9.4 + created_at: '2024-06-07' + changelog_entry: + - type: fix + summary: The unchecked base model now handles pulling the discriminant from a dict, not just a model/object. + ir_version: 39 + +- version: 2.9.3 + created_at: '2024-06-06' + changelog_entry: + - type: fix + summary: Snippet templates for discrminated unions now specify the `template_input` property which is required to actually see snippets of instantiating discrminated unions. + ir_version: 39 + +- version: 2.9.2 + created_at: '2024-06-06' + changelog_entry: + - type: fix + summary: downgrades mypy so we can run it over all our files without concern for their pydantic bug + fixed: + - >- + downgrades mypy so we can run it over all our files without concern for + their pydantic bug + - adds typehint to the response variable + ir_version: 39 + +- version: 2.9.1 + created_at: '2024-06-06' + changelog_entry: + - type: fix + summary: The SDK removes unset query parameters from requests (regression from the client migration in 2.8.0) + fixed: + - >- + The SDK removes unset query parameters from requests (regression from + the client migration in 2.8.0) + - >- + The SDK fixes it's type for `files` parameters to the http client + (regression from the client migration in 2.8.0) + ir_version: 39 + +- version: 2.9.0 + created_at: '2024-06-05' + changelog_entry: + - type: fix + summary: Snippets preserve trailing slashes + ir_version: 39 + +- version: 2.9.0-rc1 + created_at: '2024-06-05' + changelog_entry: + - type: fix + summary: The new http client abstraction ensures a slash is postfixed to the baseurl + ir_version: 39 + +- version: 2.9.0-rc0 + created_at: '2024-06-04' + changelog_entry: + - type: chore + summary: The Python generator now runs custom unit tests in CI if configured. + ir_version: 39 + +- version: 2.8.2 + created_at: '2024-06-04' + changelog_entry: + - type: fix + summary: The none-filtering function now supports mypy's invariance check. + ir_version: 39 + +- version: 2.8.1 + created_at: '2024-06-04' + changelog_entry: + - type: fix + summary: The parameter comment/documentation for timeouts on the root client now reflects the custom timeout passed through within configuration. + ir_version: 39 + +- version: 2.8.0 + created_at: '2024-06-03' + changelog_entry: + - type: chore + summary: >- + Endpoint function request logic has been abstracted into + the request function of the wrapped httpx client. + ir_version: 39 + +- version: 2.7.0 + created_at: '2024-05-30' + changelog_entry: + - type: internal + summary: >- + Improvement: The generator now outputs an `exampleId` alongside each + generated snippet so that we can correlate snippets with the relevant + examples. This is useful for retrieving examples from Fern's API and + making sure that you can show multiple snippets in the generated docs. + ir_version: 39 + +- version: 2.6.1 + created_at: '2024-05-31' + changelog_entry: + - type: internal + summary: >- + this adds a back door token getter function to OAuth clients to better + test the functionality. + ir_version: 39 + +- version: 2.6.0 + created_at: '2024-05-30' + changelog_entry: + - type: chore + summary: Support adding optional dependencies and extras to your generated `pyproject.toml`. + changed: + - >- + Improvement: Support adding optional dependencies and extras to your + generated `pyproject.toml`. To use this configuration, please add the + following: + ir_version: 39 + +- version: 2.5.7 + created_at: '2024-05-30' + changelog_entry: + - type: fix + summary: tests now carry a type annotation for `expected_types` variable. + ir_version: 39 + +- version: 2.5.6 + created_at: '2024-05-29' + changelog_entry: + - type: chore + summary: >- + Literal values are now all defaulted such that users are + not required to plug in a redundant value. + ir_version: 39 + +- version: 2.5.5 + created_at: '2024-05-29' + changelog_entry: + - type: fix + summary: Auto-Pagination now respects optional return values + fixed: + - >- + Optional lists returned from pagination endpoints are now appropriately + flattened such that the `Pager` return types are correctly + `Pager[ListItem]` as opposed to `Pager[List[ListItem]]`. + ir_version: 39 + +- version: 2.5.4 + created_at: '2024-05-28' + changelog_entry: + - type: internal + summary: Add typing library for dateutils in testing lib to satisfy mypy errors. + ir_version: 39 + +- version: 2.5.3 + created_at: '2024-05-24' + changelog_entry: + - type: chore + summary: Stops specifying custom licenses manually, lets poetry handle adding them. + ir_version: 39 + +- version: 2.5.2 + created_at: '2024-05-23' + changelog_entry: + - type: feat + summary: Support `list` SDK method names instead of defaulting to `list_`. + ir_version: 39 + +- version: 2.5.1-rc0 + created_at: '2024-05-23' + changelog_entry: + - type: fix + summary: Literal parameters are added back to the request body. + ir_version: 39 + +- version: 2.5.0-rc2 + created_at: '2024-05-23' + changelog_entry: + - type: fix + summary: Do not attempt to run `fern test` in CI until the command is more widely rolled out. + ir_version: 39 + +- version: 2.5.0-rc1 + created_at: '2024-05-22' + changelog_entry: + - type: chore + summary: Address `propogate` -> `propagate` typo in python codegen. + ir_version: 39 + +- version: 2.5.0-rc0 + created_at: '2024-05-22' + changelog_entry: + - type: fix + summary: This version addresses issues in unit test generation and reenables the creation of unit tests. + ir_version: 39 + +- version: 2.4.0-rc0 + created_at: '2024-05-21' + changelog_entry: + - type: fix + summary: >- + The Python SDK generator now uses safe names wherever string concat is + not used (like in client generation naming), so this will update module + and parameter names. + ir_version: 39 + +- version: 2.3.4 + created_at: '2024-05-21' + changelog_entry: + - type: fix + summary: >- + Snippets and unit tests now correctly write optional request bodies when + `inline_request_params` is set to `True`. + fixed: + - >- + Snippets and unit tests now correctly write optional request bodies when + `inline_request_params` is set to `True`. Previously the generator wrote + snippets that inlined these parameters, which does not match the + generated SDK itself. + ir_version: 39 + +- version: 2.3.3 + created_at: '2024-05-21' + changelog_entry: + - type: fix + summary: Inlined body parameters now deconflict in naming with header and query parameters by prefixing the request objects name. + ir_version: 39 + +- version: 2.3.2 + created_at: '2024-05-21' + changelog_entry: + - type: fix + summary: The query encoder now correctly handles none values + fixed: + - >- + The `pyproject.toml` generator now writes authors in a valid format for + `tool.poetry`, not just `project` + - The query encoder now correctly handles none values + ir_version: 39 + +- version: 2.3.1 + created_at: '2024-05-21' + changelog_entry: + - type: fix + summary: The `pyproject.toml` generator now includes project URLs when specified. + ir_version: 39 + +- version: 2.3.0 + created_at: '2024-05-21' + changelog_entry: + - type: chore + summary: Users can now specify information that will appear in their pypi record. + ir_version: 39 + +- version: 2.2.2 + created_at: '2024-05-20' + changelog_entry: + - type: fix + summary: Inline request parameters now deconflict in naming with the unnamed path parameter arguments. + fixed: + - >- + Inline request parameters now deconflict in naming with the unnamed path + parameter arguments. Previously, when inlining request parameters into + the method signature, we would not deconflict naming with the unnamed + args preceeding them. Now, conflicting unnamed parameters are post-fixed + with an "_". + ir_version: 39 + +- version: 2.2.1 + created_at: '2024-05-17' + changelog_entry: + - type: internal + summary: The generator now uses the latest FDR SDK. + ir_version: 39 + +- version: 2.2.0 + created_at: '2024-05-16' + changelog_entry: + - type: chore + summary: The generated SDK will now correctly encode deep object query parameters + changed: + - >- + The generated SDK will now correctly encode deep object + query parameters. For example, if you have an object `{"test": + {"nested": "object"}}` as a query parameter, we will now encode it as + `test[nested]=object`. + ir_version: 39 + +- version: 2.1.1 + created_at: '2024-05-15' + changelog_entry: + - type: chore + summary: add enhanced snippet support for streaming endpoints. + ir_version: 39 + +- version: 2.1.0 + created_at: '2024-05-14' + changelog_entry: + - type: feat + summary: Add support for cursor and offset pagination ("auto-pagination"). + ir_version: 39 + +- version: 2.0.1 + created_at: '2024-05-14' + changelog_entry: + - type: fix + summary: The python generator now only excludes unset fields that are not required. + fixed: + - >- + the python generator previously used `exclude_unset` on pydantic models, + however this would remove defaulted values. This change updates this to + only exclude none fields that were not required. + ir_version: 39 + +- version: 2.0.0 + created_at: '2024-05-09' + changelog_entry: + - type: break + summary: Release of the Python SDK generator version 2, updating default configuration. + changed: + - >- + The python SDK is now on major version 2, there are no + substantial logic changes, however default configuration has changed. To + take this upgrade without any breaks, please add the below configuration + to your `generators.yml` file: + ir_version: 39 + +- version: 1.7.0-rc0 + created_at: '2024-05-09' + changelog_entry: + - type: chore + summary: you can now declare a new python version range for your `pyproject.toml`, which will declare a new version range for your pip package. + ir_version: 39 + +- version: 1.6.0-rc0 + created_at: '2024-05-09' + changelog_entry: + - type: chore + summary: You can now specify dev dependencies from your `generators.yml` file + ir_version: 39 + +- version: 1.5.3-rc0 + created_at: '2024-05-02' + changelog_entry: + - type: fix + summary: the unchecked basemodel no longer tries to dereference an object if it's null. + ir_version: 39 + +- version: 1.5.2-rc0 + created_at: '2024-05-02' + changelog_entry: + - type: chore + summary: The python generator now produces sync snippet templates, as opposed to just async templates as it was before + ir_version: 39 + +- version: 1.5.1-rc5 + created_at: '2024-05-01' + changelog_entry: + - type: fix + summary: Snippet templates now generate the correct imports for object types. + ir_version: 39 + +- version: 1.5.1-rc4 + created_at: '2024-05-01' + changelog_entry: + - type: fix + summary: The SDK now generates discriminated union snippet templates correctly. + ir_version: 39 + +- version: 1.5.1-rc3 + created_at: '2024-05-01' + changelog_entry: + - type: chore + summary: Union types leverage the fern aware base model to include JSON and Dict function overrides. + ir_version: 39 + +- version: 1.5.1-rc2 + created_at: '2024-05-01' + changelog_entry: + - type: fix + summary: The vanilla pydantic base model now respects the `require_optional_fields` + fixed: + - >- + The vanilla pydantic base model now respects the + `require_optional_fields`, this became a regression in 1.5.1-rc0 when we + started to inline union properties which leverages the vanilla base + model. + ir_version: 39 + +- version: 1.5.1-rc1 + created_at: '2024-05-01' + changelog_entry: + - type: fix + summary: Improve formatting within snippet templates. + fixed: + - >- + Address formatting issues with snippet templates, we now strip newlines + off OG snippets as well as plumb through indentation metadata to places + that were previously missing it. + ir_version: 39 + +- version: 1.5.1-rc0 + created_at: '2024-04-26' + changelog_entry: + - type: fix + summary: Discriminated union variants that are objects now have inlined properties instead of extending a base type. + ir_version: 39 + +- version: 1.5.0-rc0 + created_at: '2024-04-30' + changelog_entry: + - type: feat + summary: The generator now supports inlining top-level request parameters instead of requiring users create a request object. + ir_version: 39 + +- version: 1.4.0 + created_at: '2024-04-29' + changelog_entry: + - type: feat + summary: keyword arguments are now ordered such that required params are ordered before optional params + changed: + - >- + keyword arguments are now ordered such that required params + are ordered before optional params. Note that since these are kwargs, + this is a non-breaking change. + - 'docstrings now match numpydoc/PEP257 format' + ir_version: 39 + +- version: 1.4.0-rc3 + created_at: '2024-04-24' + changelog_entry: + - type: fix + summary: pin mypy dependency to 1.9.0 to prevent introducing upstream bugs + fixed: + - >- + Set `mypy` dev depenency in generated `pyproject.toml` to `1.9.0`. This + prevents upstream `mypy` bugs from affecting user builds. Note that this + is only a dev dependency, so it does not affect the behavior of the SDK. + - Temporarily disable unit test generation. + changed: + - 'Improvement: Use named parameters for all `httpx` request params.' + ir_version: 39 + +- version: 1.4.0-rc2 + created_at: '2024-04-23' + changelog_entry: + - type: fix + summary: Initialize the OAuth token provider member variables to their default values before they are set. + ir_version: 39 + +- version: 1.4.0-rc1 + created_at: '2024-04-22' + changelog_entry: + - type: feat + summary: The python SDK generator now supports OAuth client generation for the client-credentials flow. + ir_version: 39 + +- version: 1.4.0-rc0 + created_at: '2024-04-22' + changelog_entry: + - type: chore + summary: Generated clients now follow redirects by default. + changed: + - >- + Default generated clients to follow redirects by default, this + effectively flips the `follow_redirects_by_default` flag to `True` and + can be reverted with the following configuration: + ir_version: 38 + +- version: 1.3.1-rc0 + created_at: '2024-04-22' + changelog_entry: + - type: fix + summary: the python SDK generator now checks to make sure a header is not null before casting it to a string. + ir_version: 38 + +- version: 1.3.0-rc1 + created_at: '2024-04-22' + changelog_entry: + - type: internal + summary: add logging for python snippet template generation. + ir_version: 38 + +- version: 1.3.0-rc0 + created_at: '2024-04-21' + changelog_entry: + - type: feat + summary: "Beta: The generator now registers snippet templates which can be used for dynamic SDK code snippet generation." + ir_version: 38 + +- version: 1.2.0-rc2 + created_at: '2024-04-10' + changelog_entry: + - type: fix + summary: The generator now correctly imports `json` when deserializing server sent events. + ir_version: 38 + +- version: 1.2.0-rc0 + created_at: '2024-04-10' + changelog_entry: + - type: internal + summary: Consume IR v38 + added: + - >- + The generator now depends on v38 of Intermediate Representation which + requires the latest CLI. As part of this, the generator now supports + server sent events using `httpx-sse`. + ir_version: 38 + +- version: 1.1.0-rc3 + created_at: '2024-04-04' + changelog_entry: + - type: fix + summary: The skip validation code now works as expected. + fixed: + - >- + There are a number of fixes to the skip validation code as well as tests + to reflect those updates. + ir_version: 37 + +- version: 1.1.0-rc2 + created_at: '2024-04-04' + changelog_entry: + - type: fix + summary: The generator now writes the skipped-validation `cast` with a suffixing new line so that the code compiles. + ir_version: 37 + +- version: 1.1.0-rc1 + created_at: '2024-04-04' + changelog_entry: + - type: fix + summary: The generator no longer attempts to create a version file if Fern does not own generating the full package (e.g. in local generation). + fixed: + - >- + The generator no longer attempts to create a version file if Fern does + not own generating the full package (e.g. in local generation). It's too + confusing for to make the relevant changes to the package set up, and is + also arguably not even needed in local generation. + ir_version: 37 + +- version: 1.1.0-rc0 + created_at: '2024-04-03' + changelog_entry: + - type: feat + summary: The python SDK now includes a configuration option to skip pydantic validation. + added: + - >- + [EXPERIMENTAL]: The python SDK now includes a configuration + option to skip pydantic validation. This ensures that Pydantic does not + immediately fail if the model being returned from an API does not + exactly match the Pydantic model. This is meant to add flexibility, + should your SDK fall behind your API, but should be used sparringly, as + the type-hinting for users will still reflect the Pydantic model + exactly. + ir_version: 37 + +- version: 1.0.1 + created_at: '2024-04-03' + changelog_entry: + - type: fix + summary: Address Pydantic break when introducing `pydantic.v1` import within Pydantic V1 + fixed: + - >- + Pydantic introduced a "break" to their 1.x libs by adding in a .v1 + submodule that does not mirror the one that comes with pydantic v2. To + get around this we now force the usage of the v1 submodule only if the + pydantic version is v2. + ir_version: 37 + +- version: 1.0.0 + created_at: '2024-04-02' + changelog_entry: + - type: break + summary: The python SDK now defaults new (breaking configuration) to introduce general improvements. + changed: + - >- + Break: The python SDK now defaults new (breaking configuration) to + introduce general improvements. + - >- + Improvement: The python SDK now supports specifying whether or not to + follow redirects in requests by default, and exposes an option to + override that functionality for consumers. + ir_version: 37 + +- version: 0.13.4 + created_at: '2024-04-03' + changelog_entry: + - type: fix + summary: revert changes introduced within 0.12.2 + fixed: + - >- + revert the change from 0.13.2, the stream call returns a context + manager, which is not awaited. The issue that this was meant to solve + was actually fixed in version `0.12.2`. + ir_version: 37 + +- version: 0.13.3 + created_at: '2024-03-28' + changelog_entry: + - type: fix + summary: Github workflows for publishing now work again (previously the trigger was incorrect). + ir_version: 37 + +- version: 0.13.2 + created_at: '2024-03-28' + changelog_entry: + - type: fix + summary: Asynchronous calls to `httpx.stream` are now awaited. This is applicable to any file download or JSON streaming (chat completion) endpoints. + ir_version: 37 + +- version: 0.13.1 + created_at: '2024-03-26' + changelog_entry: + - type: feat + summary: discriminant values in unions are now defaulted such that callers no longer need to specify the discriminant + ir_version: 37 + +- version: 0.13.0 + created_at: '2024-03-25' + changelog_entry: + - type: feat + summary: the python SDK now exposes it's version through `__version__` to match module standards and expectations. + ir_version: 37 + +- version: 0.12.5 + created_at: '2024-03-22' + changelog_entry: + - type: fix + summary: the python SDK uses the timeout provided to the top level client as the default per-request + fixed: + - >- + the python SDK uses the timeout provided to the top level client as the + default per-request, previously if there was no timeout override in the + RequestOptions, we'd default to 60s, even if a timeout was provided at + the client level. + ir_version: 37 + +- version: 0.12.4 + created_at: '2024-03-19' + changelog_entry: + - type: chore + summary: Allow full forward compat with enums while keeping intellisense by unioning enum literals with `typing.AnyStr`. + ir_version: 37 + +- version: 0.12.3 + created_at: '2024-03-18' + changelog_entry: + - type: feat + summary: Allow bytes requests to take in iterators of bytes, mirroring the types allowed by HTTPX. + ir_version: 37 + +- version: 0.12.2 + created_at: '2024-03-18' + changelog_entry: + - type: fix + summary: Fix the returned type and value contained within the retrying wrapper for the HTTPX client (http_client.py). + ir_version: 37 + +- version: 0.12.1 + created_at: '2024-03-14' + changelog_entry: + - type: chore + summary: Improves example generation and snippets for union types, as well as multi-url environments. + changed: + - >- + Improves example generation and snippets for union types, as well as + multi-url environments. + fixed: + - >- + Stringifies header arguments, HTTPX was previously hard failing for + certain types + ir_version: 37 + +- version: 0.12.0 + created_at: '2024-03-11' + changelog_entry: + - type: feat + summary: Auto-generated unit and integration tests against a mock server. + added: + - >- + Beta: The SDK now generates tests leveraging auto-generated + data to test typing, as well as wire-formatting (e.g. the SDKs are + sending and receiving data as expected). This comes out of the box + within the generated github workflow, as well as through the fern cli: + `fern test --command "your test command"`. + ir_version: 37 + +- version: 0.11.10 + created_at: '2024-03-08' + changelog_entry: + - type: feat + summary: Expose a feature flag to pass through additional properties not specified within your pydantic model from your SDK. + added: + - >- + Expose a feature flag to pass through additional properties not + specified within your pydantic model from your SDK. This allows for + easier forward compatibility should your SDK drift behind your spec. + ir_version: 36 + +- version: 0.11.9 + created_at: '2024-03-04' + changelog_entry: + - type: chore + summary: use docstrings instead of Pydantic field descriptions. + ir_version: 36 + +- version: 0.11.8-rc1 + created_at: '2024-03-02' + changelog_entry: + - type: feat + summary: Introduces a `max_retries` parameter to the RequestOptions dict accepted by all requests. + changed: + - >- + Beta: Introduces a `max_retries` parameter to the + RequestOptions dict accepted by all requests. This parameter will retry + requests automatically, with exponential backoff and a jitter. The + client will automatically retry requests of a 5XX status code, or + certain 4XX codes (429, 408, 409). + ir_version: 36 + +- version: 0.11.8-rc0 + created_at: '2024-02-27' + changelog_entry: + - type: feat + summary: introduces additional configuration to customize the client class and file name. + changed: + - >- + Beta: Introduce a `client` custom config that allows you to specify + class_name and filename for the client. This configuration can be used + in several ways: + ir_version: 36 + +- version: 0.11.7 + created_at: '2024-02-27' + changelog_entry: + - type: feat + summary: Introduces a flag `use_str_enums` to swap from using proper Enum classes to using Literals to represent enums. + changed: + - >- + Introduces a flag `use_str_enums` to swap from using proper + Enum classes to using Literals to represent enums. This change allows + for forward compatibility of enums, since the user will receive the + string back. + ir_version: 36 + +- version: 0.11.6 + created_at: '2024-02-26' + changelog_entry: + - type: feat + summary: You can now specify envvars to scan for headers, not just auth scheme headers. + ir_version: 36 + +- version: 0.11.5 + created_at: '2024-02-23' + changelog_entry: + - type: fix + summary: Fix the usage of ApiError when leveraging auth envvars, when the schema for ApiError was changed, this usage was missed in the update. + ir_version: 34 + +- version: 0.11.4 + created_at: '2024-02-23' + changelog_entry: + - type: fix + summary: We now grab enum values appropriately when enums are within unions. + ir_version: 34 + +- version: 0.11.3 + created_at: '2024-02-22' + changelog_entry: + - type: fix + summary: Transition from lists to sequences within function calls + fixed: + - >- + Transition from lists to sequences within function calls, this is a fix + as a result of how mypy handles type variance. This fix is only for + function calls as testing shows that we do not hit the same issue within + mypy with list[union[*]] fields on pydantic objects. + changed: + - >- + Improvement: The Python SDK generator now defaults to + `require_optional_fields = False`. This means that any requests that + have optional fields no longer require a user to input data (or a `None` + value) in. + ir_version: 34 + +- version: 0.11.2 + created_at: '2024-02-21' + changelog_entry: + - type: feat + summary: introduce configuration to flatten the directory structure + changed: + - >- + Improvement (Beta): The Python generator now supports a configuration + option called `improved_imports`. + ir_version: 34 + +- version: 0.11.1 + created_at: '2024-02-20' + changelog_entry: + - type: feat + summary: Python now supports specifying files to auto-export from the root `__init__.py` file + changed: + - >- + Python now supports specifying files to auto-export from + the root `__init__.py` file, this means you can export custom classes + and functions from your package for users to access like so: + - 'Add a docstring for base clients to explain usage, example:' + ir_version: 34 + +- version: 0.11.0 + created_at: '2024-02-19' + changelog_entry: + - type: feat + summary: Python now supports a wider range of types for file upload + changed: + - >- + Python now supports a wider range of types for file upload, + mirroring the `httpx` library used under the hood, these are grouped + under a new type `File`: + fixed: + - >- + Python now supports API specifications that leverage lists for file + upload. Previously, Fern incorrectly made all `list` type requests + simply `file`. + ir_version: 34 + +- version: 0.10.3 + created_at: '2024-02-19' + changelog_entry: + - type: fix + summary: Several bugfixes were made to related to literal properties + fixed: + - >- + Several bugfixes were made to related to literal properties. If a + literal is used as a query parameeter, header, path parameter, or + request parameter, the user no longer has to explicitly pass it in. + ir_version: 31 + +- version: 0.10.2 + created_at: '2024-02-18' + changelog_entry: + - type: fix + summary: The SDK always sends the enum wire value instead of the name of the enum. + fixed: + - >- + The SDK always sends the enum wire value instead of the name of the + enum. + - >- + Revert #2719 which introduced additional issues with circular references + within our Python types. + ir_version: 31 + +- version: 0.10.1 + created_at: '2024-02-14' + changelog_entry: + - type: feat + summary: Add support for a RequestOptions object for each generated function within Python SDKs + changed: + - >- + Add support for a RequestOptions object for each generated + function within Python SDKs. This parameter is an optional final + parameter that allows for configuring timeout, as well as pass in + arbitrary data through to the request. RequestOptions is a TypedDict, + with optional fields, so there's no need to instantiate an object, just + pass in the relevant keys within a dict! + ir_version: 31 + +- version: 0.10.0 + created_at: '2024-02-13' + changelog_entry: + - type: break + summary: The generator no longer supports Python 3.7 + removed: + - The generator no longer supports Python 3.7 + - The `backports` dependency has been removed + ir_version: 31 + +- version: 0.9.1 + created_at: '2024-02-11' + changelog_entry: + - type: fix + summary: Remove literals from SDK function signatures, as they are not modifiable for end users + fixed: + - >- + Remove literals from SDK function signatures, as they are not modifiable + for end users. + - >- + Acknowledge the optionality of a `File` property, previously we were + requiring all `File` type inputs, even if they were specified as + optional within the OpenAPI or Fern definition. Now, we check if the + parameter is required and make the parameter optional if it is not. + ir_version: 31 + +- version: 0.9.0 + created_at: '2024-02-11' + changelog_entry: + - type: feat + summary: The SDK generator now supports whitelabelling + added: + - >- + The SDK generator now supports whitelabelling. When this is turned on, + there will be no mention of Fern in the generated code. + ir_version: 31 + +- version: 0.8.3-rc0 + created_at: '2024-01-29' + changelog_entry: + - type: fix + summary: Increase recursion depth to allow for highly nested and complex examples + fixed: + - >- + Increase recursion depth to allow for highly nested and complex + examples, this is a temporary solution while the example datamodel is + further refined. + ir_version: 31 + +- version: 0.8.2-rc0 + created_at: '2024-01-28' + changelog_entry: + - type: fix + summary: The Python SDK better handles cyclical references + fixed: + - >- + The Python SDK better handles cyclical references. In particular, + cyclical references are tracked for undiscriminated unions, and + update_forward_refs is always called with object references. + ir_version: 31 + +- version: 0.8.1 + created_at: '2024-01-26' + changelog_entry: + - type: feat + summary: The generated SDK respects environment variables for authentication if specified + added: + - >- + If the auth scheme has environment variables specified, the generated + python client will scan those environment variables. + ir_version: 31 + +- version: 0.8.0 + created_at: '2024-01-25' + changelog_entry: + - type: fix + summary: Enums in inlined requests send the appropriate value. + ir_version: 31 + +- version: 0.7.7 + created_at: '2024-01-21' + changelog_entry: + - type: internal + summary: Initialize the changelog + ir_version: 31 \ No newline at end of file diff --git a/generators/ruby/model/versions.yml b/generators/ruby/model/versions.yml new file mode 100644 index 00000000000..21b64b33bc4 --- /dev/null +++ b/generators/ruby/model/versions.yml @@ -0,0 +1,21 @@ +# For unreleased changes, use unreleased.yml +- version: 0.0.8 + created_at: '2024-03-22' + changelog_entry: + - type: internal + summary: Leverage shared generator notification and config parsing logic. + ir_version: 32 + +- version: 0.0.7 + created_at: '2024-03-22' + changelog_entry: + - type: internal + summary: Ensure the Ruby generators do not have strict dependencies on the IR + ir_version: 32 + +- version: 0.0.6 + created_at: '2024-01-24' + changelog_entry: + - type: internal + summary: Initialize the changelog + ir_version: 32 diff --git a/generators/ruby/model/versions.yml.new b/generators/ruby/model/versions.yml.new new file mode 100644 index 00000000000..99c5599b2b3 --- /dev/null +++ b/generators/ruby/model/versions.yml.new @@ -0,0 +1,20 @@ +- version: 0.0.8 + created_at: '2024-03-22' + changelog_entry: + - type: internal + summary: Leverage shared generator notification and config parsing logic. + ir_version: 32 + +- version: 0.0.7 + created_at: '2024-03-22' + changelog_entry: + - type: internal + summary: Ensure the Ruby generators do not have strict dependencies on the IR + ir_version: 32 + +- version: 0.0.6 + created_at: '2024-01-24' + changelog_entry: + - type: internal + summary: Initialize the changelog + ir_version: 32 diff --git a/generators/ruby/sdk/versions.yml b/generators/ruby/sdk/versions.yml new file mode 100644 index 00000000000..5cb6e03ec3f --- /dev/null +++ b/generators/ruby/sdk/versions.yml @@ -0,0 +1,346 @@ +# For unreleased changes, use unreleased.yml +- version: 0.8.2 + created_at: '2024-08-05' + changelog_entry: + - type: fix + summary: >- + The generated endpoint functions no long include object utilities such + as `_field_set` or `additional_properties`. + ir_version: 39 + +- version: 0.8.1 + created_at: '2024-07-22' + changelog_entry: + - type: fix + summary: Address serialization issues within iterable types + fixed: + - >- + Nested `hash` types are recursively resolved in `from_json` such that + they come back as true hashes, as opposed to structs + - >- + Pass through additional params from request options even if the + original request did not have those types of params (ex: query + parameters) + ir_version: 39 + +- version: 0.8.0 + created_at: '2024-07-03' + changelog_entry: + - type: fix + summary: >- + Date snippets now wrap their examples in quotation marks to correctly + use `.parse` + ir_version: 39 + +- version: 0.8.0-rc0 + created_at: '2024-07-01' + changelog_entry: + - type: feat + summary: >- + allow users to specify additional dependencies and dev dependencies for + Ruby SDKs. + ir_version: 39 + +- version: 0.7.0-rc5 + created_at: '2024-04-08' + changelog_entry: + - type: feat + summary: >- + additional fix for the same issue within 0.7.0-rc4 (regression + introduced within the 0.7.0 RCs where the token prefix was dropped from + requests). + ir_version: 39 + +- version: 0.7.0-rc4 + created_at: '2024-04-08' + changelog_entry: + - type: feat + summary: >- + fixes regression introduced within the 0.7.0 RCs where the token prefix + was dropped from requests. + ir_version: 39 + +- version: 0.7.0-rc3 + created_at: '2024-04-08' + changelog_entry: + - type: fix + summary: >- + Module references are now consistent throughout the generated SDK, this + was a regression in the previous release. + ir_version: 39 + +- version: 0.7.0-rc2 + created_at: '2024-04-08' + changelog_entry: + - type: feat + summary: >- + the ruby generator now nests types under a type module to avoid naming + conflicts, this is behind a configuration flag + ir_version: 39 + +- version: 0.7.0-rc1 + created_at: '2024-04-08' + changelog_entry: + - type: feat + summary: Address serialization issues within iterable types + fixed: + - nested loops leverage different variable names to deconflict + - nested loops do not call to_json prior to the subsequent loop + ir_version: 39 + +- version: 0.7.0-rc0 + created_at: '2024-06-13' + changelog_entry: + - type: feat + summary: Introduce automatic token refresh for OAuth credentials + added: + - The Ruby SDK now generates an OAuth client to automate token refresh. + fixed: + - >- + The Ruby SDK now no longer requires users specify literals in method + signatures + ir_version: 39 + +- version: 0.6.3 + created_at: '2024-05-27' + changelog_entry: + - type: feat + summary: Generated SDK snippets now leverage the full function module path. + ir_version: 32 + +- version: 0.6.2 + created_at: '2024-05-17' + changelog_entry: + - type: internal + summary: The generator now uses the latest FDR SDK + ir_version: 32 + +- version: 0.6.1 + created_at: '2024-04-08' + changelog_entry: + - type: internal + summary: Release Generator + ir_version: 32 + +- version: 0.6.1-rc0 + created_at: '2024-04-08' + changelog_entry: + - type: internal + summary: Improve logging within the Ruby generator + ir_version: 32 + +- version: 0.6.0-rc1 + created_at: '2024-04-08' + changelog_entry: + - type: fix + summary: >- + fix regression where sometimes the parsed_json variable would not be + instantiated, and so there'd be a nil ref in the generated code + ir_version: 32 + +- version: 0.6.0-rc0 + created_at: '2024-04-08' + changelog_entry: + - type: feat + summary: Introduce code snippets and examples for Ruby SDKs + ir_version: 32 + +- version: 0.5.0-rc2 + created_at: '2024-04-08' + changelog_entry: + - type: fix + summary: Call JSON.parse prior to iterating through an iterable response + ir_version: 32 + +- version: 0.5.0-rc0 + created_at: '2024-04-09' + changelog_entry: + - type: feat + summary: >- + The generated SDK now includes a rakefile to run any tests prefixed with + `test_` in the `test` directory + added: + - >- + Consumers of the SDK can now pass in a base URL override into the root + client, as well as the request's RequestOptions + fixed: + - >- + This PR includes a number of typing annotation and cleanliness/QOL + fixes. + ir_version: 32 + +- version: 0.4.0 + created_at: '2024-04-08' + changelog_entry: + - type: feat + summary: >- + The generated SDK now includes a rakefile to run any tests prefixed with + `test_` in the `test` directory + added: + - >- + The generators now create a rakefile to run any tests prefixed with + `test_` in the `test` directory. A step is also added to CI to run + these test. The dummy test now running also provides a sanity check on + the health of the build of the gem, even if no tests are added given + the gem is imported. + ir_version: 32 + +- version: 0.3.3 + created_at: '2024-03-22' + changelog_entry: + - type: internal + summary: Leverage shared generator notification and config parsing logic. + ir_version: 32 + +- version: 0.3.2 + created_at: '2024-03-18' + changelog_entry: + - type: feat + summary: >- + type bytes requests to also take in IO types, indicating to users that + they may pass in a stream of bytes + ir_version: 32 + +- version: 0.3.1 + created_at: '2024-03-12' + changelog_entry: + - type: fix + summary: use strings instead of UUIDs, which are helper classes in Ruby + ir_version: 32 + +- version: 0.3.0 + created_at: '2024-02-27' + changelog_entry: + - type: fix + summary: >- + Generated yardoc now appropriately reflects the typehint of the value + type in maps + fixed: + - >- + Ensure the name passed into the 'X-Fern-SDK-Name' header is the name + of the gem, not the client class + - >- + If an envvar is specified as a fallback for an auth header, the SDK + will now mark that parameter as optional to allow fallback to actually + happen + - >- + Generated yardoc now appropriately reflects the typehint of the value + type in maps + ir_version: 32 + +- version: 0.2.0 + created_at: '2024-02-20' + changelog_entry: + - type: feat + summary: Add support for idempotency headers + changed: + - >- + Ruby enum construct now leverages class constants instead of hashes to + support better autocomplete + - >- + Discriminated unions are no longer wrapped within a parent object, + rather, any field or parameter that depends on a discriminated union + now explicitly references the member types in support of better + autocomplete. + - >- + Undiscriminated unions are no longer allowed as hashes as input to SDK + functions, this is in support of better autocomplete as well. + - >- + The generated Ruby SDKs now support idempotency headers, users may + specify idempotency headers within the RequestOptions object + ir_version: 32 + +- version: 0.1.1 + created_at: '2024-02-15' + changelog_entry: + - type: internal + summary: Ensure the Ruby generators do not have strict dependencies on the IR + ir_version: 32 + +- version: 0.1.0-rc0 + created_at: '2024-03-22' + changelog_entry: + - type: chore + summary: Loosen the Faraday dependencies within the generated SDKs + changed: null + ir_version: 32 + +- version: 0.1.0-rc0 + created_at: '2024-03-22' + changelog_entry: + - type: chore + summary: Loosen the Faraday dependencies within the generated SDKs + changed: + - >- + loosen the Faraday dependencies within the generated SDKs, now we are + supporting Faraday 1.x, while continuing to support the same + upperbound (specifically supporting the latest major version as well). + - >- + release a minor version as the Ruby generator is now being used in + beta! + ir_version: 32 + +- version: 0.0.6 + created_at: '2024-03-22' + changelog_entry: + - type: feat + summary: >- + license files are now specified within the gem config if they are + provided + ir_version: 32 + +- version: 0.0.5 + created_at: '2024-03-22' + changelog_entry: + - type: fix + summary: Address parsing issues within the SDK + fixed: + - >- + Syntactic error in block parameter usage: we now ensure block + parameters are the final parameter for functions + - >- + Add properties to subpackages: previously properties on subpackages + were not being exposed + - Ensure optional properties in from_json are only parsed if present + ir_version: 32 + +- version: 0.0.4 + created_at: '2024-03-22' + changelog_entry: + - type: fix + summary: >- + ensures files are written at the gem name path over client name, and + addresses string escaping on one of the Fern headers + ir_version: 32 + +- version: 0.0.3 + created_at: '2024-03-22' + changelog_entry: + - type: fix + summary: >- + addresses a number of typos and other issues previously contained within + the generation code + ir_version: 32 + +- version: 0.0.2 + created_at: '2024-03-22' + changelog_entry: + - type: feat + summary: Support rubygems output type within `generators.yml` + ir_version: 32 + +- version: 0.0.1 + created_at: '2024-02-01' + changelog_entry: + - type: feat + summary: >- + Support client generation (async and sync) as well as most endpoint + types (except streaming) + ir_version: 32 + +- version: 0.0.0 + created_at: '2024-01-30' + changelog_entry: + - type: internal + summary: Initialize the changelog + ir_version: 32 diff --git a/generators/ruby/sdk/versions.yml.new b/generators/ruby/sdk/versions.yml.new new file mode 100644 index 00000000000..ee577cda43f --- /dev/null +++ b/generators/ruby/sdk/versions.yml.new @@ -0,0 +1,345 @@ +- version: 0.8.2 + created_at: '2024-08-05' + changelog_entry: + - type: fix + summary: >- + The generated endpoint functions no long include object utilities such + as `_field_set` or `additional_properties`. + ir_version: 39 + +- version: 0.8.1 + created_at: '2024-07-22' + changelog_entry: + - type: fix + summary: Address serialization issues within iterable types + fixed: + - >- + Nested `hash` types are recursively resolved in `from_json` such that + they come back as true hashes, as opposed to structs + - >- + Pass through additional params from request options even if the + original request did not have those types of params (ex: query + parameters) + ir_version: 39 + +- version: 0.8.0 + created_at: '2024-07-03' + changelog_entry: + - type: fix + summary: >- + Date snippets now wrap their examples in quotation marks to correctly + use `.parse` + ir_version: 39 + +- version: 0.8.0-rc0 + created_at: '2024-07-01' + changelog_entry: + - type: feat + summary: >- + allow users to specify additional dependencies and dev dependencies for + Ruby SDKs. + ir_version: 39 + +- version: 0.7.0-rc5 + created_at: '2024-04-08' + changelog_entry: + - type: feat + summary: >- + additional fix for the same issue within 0.7.0-rc4 (regression + introduced within the 0.7.0 RCs where the token prefix was dropped from + requests). + ir_version: 39 + +- version: 0.7.0-rc4 + created_at: '2024-04-08' + changelog_entry: + - type: feat + summary: >- + fixes regression introduced within the 0.7.0 RCs where the token prefix + was dropped from requests. + ir_version: 39 + +- version: 0.7.0-rc3 + created_at: '2024-04-08' + changelog_entry: + - type: fix + summary: >- + Module references are now consistent throughout the generated SDK, this + was a regression in the previous release. + ir_version: 39 + +- version: 0.7.0-rc2 + created_at: '2024-04-08' + changelog_entry: + - type: feat + summary: >- + the ruby generator now nests types under a type module to avoid naming + conflicts, this is behind a configuration flag + ir_version: 39 + +- version: 0.7.0-rc1 + created_at: '2024-04-08' + changelog_entry: + - type: feat + summary: Address serialization issues within iterable types + fixed: + - nested loops leverage different variable names to deconflict + - nested loops do not call to_json prior to the subsequent loop + ir_version: 39 + +- version: 0.7.0-rc0 + created_at: '2024-06-13' + changelog_entry: + - type: feat + summary: Introduce automatic token refresh for OAuth credentials + added: + - The Ruby SDK now generates an OAuth client to automate token refresh. + fixed: + - >- + The Ruby SDK now no longer requires users specify literals in method + signatures + ir_version: 39 + +- version: 0.6.3 + created_at: '2024-05-27' + changelog_entry: + - type: feat + summary: Generated SDK snippets now leverage the full function module path. + ir_version: 32 + +- version: 0.6.2 + created_at: '2024-05-17' + changelog_entry: + - type: internal + summary: The generator now uses the latest FDR SDK + ir_version: 32 + +- version: 0.6.1 + created_at: '2024-04-08' + changelog_entry: + - type: internal + summary: Release Generator + ir_version: 32 + +- version: 0.6.1-rc0 + created_at: '2024-04-08' + changelog_entry: + - type: internal + summary: Improve logging within the Ruby generator + ir_version: 32 + +- version: 0.6.0-rc1 + created_at: '2024-04-08' + changelog_entry: + - type: fix + summary: >- + fix regression where sometimes the parsed_json variable would not be + instantiated, and so there'd be a nil ref in the generated code + ir_version: 32 + +- version: 0.6.0-rc0 + created_at: '2024-04-08' + changelog_entry: + - type: feat + summary: Introduce code snippets and examples for Ruby SDKs + ir_version: 32 + +- version: 0.5.0-rc2 + created_at: '2024-04-08' + changelog_entry: + - type: fix + summary: Call JSON.parse prior to iterating through an iterable response + ir_version: 32 + +- version: 0.5.0-rc0 + created_at: '2024-04-09' + changelog_entry: + - type: feat + summary: >- + The generated SDK now includes a rakefile to run any tests prefixed with + `test_` in the `test` directory + added: + - >- + Consumers of the SDK can now pass in a base URL override into the root + client, as well as the request's RequestOptions + fixed: + - >- + This PR includes a number of typing annotation and cleanliness/QOL + fixes. + ir_version: 32 + +- version: 0.4.0 + created_at: '2024-04-08' + changelog_entry: + - type: feat + summary: >- + The generated SDK now includes a rakefile to run any tests prefixed with + `test_` in the `test` directory + added: + - >- + The generators now create a rakefile to run any tests prefixed with + `test_` in the `test` directory. A step is also added to CI to run + these test. The dummy test now running also provides a sanity check on + the health of the build of the gem, even if no tests are added given + the gem is imported. + ir_version: 32 + +- version: 0.3.3 + created_at: '2024-03-22' + changelog_entry: + - type: internal + summary: Leverage shared generator notification and config parsing logic. + ir_version: 32 + +- version: 0.3.2 + created_at: '2024-03-18' + changelog_entry: + - type: feat + summary: >- + type bytes requests to also take in IO types, indicating to users that + they may pass in a stream of bytes + ir_version: 32 + +- version: 0.3.1 + created_at: '2024-03-12' + changelog_entry: + - type: fix + summary: use strings instead of UUIDs, which are helper classes in Ruby + ir_version: 32 + +- version: 0.3.0 + created_at: '2024-02-27' + changelog_entry: + - type: fix + summary: >- + Generated yardoc now appropriately reflects the typehint of the value + type in maps + fixed: + - >- + Ensure the name passed into the 'X-Fern-SDK-Name' header is the name + of the gem, not the client class + - >- + If an envvar is specified as a fallback for an auth header, the SDK + will now mark that parameter as optional to allow fallback to actually + happen + - >- + Generated yardoc now appropriately reflects the typehint of the value + type in maps + ir_version: 32 + +- version: 0.2.0 + created_at: '2024-02-20' + changelog_entry: + - type: feat + summary: Add support for idempotency headers + changed: + - >- + Ruby enum construct now leverages class constants instead of hashes to + support better autocomplete + - >- + Discriminated unions are no longer wrapped within a parent object, + rather, any field or parameter that depends on a discriminated union + now explicitly references the member types in support of better + autocomplete. + - >- + Undiscriminated unions are no longer allowed as hashes as input to SDK + functions, this is in support of better autocomplete as well. + - >- + The generated Ruby SDKs now support idempotency headers, users may + specify idempotency headers within the RequestOptions object + ir_version: 32 + +- version: 0.1.1 + created_at: '2024-02-15' + changelog_entry: + - type: internal + summary: Ensure the Ruby generators do not have strict dependencies on the IR + ir_version: 32 + +- version: 0.1.0-rc0 + created_at: '2024-03-22' + changelog_entry: + - type: chore + summary: Loosen the Faraday dependencies within the generated SDKs + changed: null + ir_version: 32 + +- version: 0.1.0-rc0 + created_at: '2024-03-22' + changelog_entry: + - type: chore + summary: Loosen the Faraday dependencies within the generated SDKs + changed: + - >- + loosen the Faraday dependencies within the generated SDKs, now we are + supporting Faraday 1.x, while continuing to support the same + upperbound (specifically supporting the latest major version as well). + - >- + release a minor version as the Ruby generator is now being used in + beta! + ir_version: 32 + +- version: 0.0.6 + created_at: '2024-03-22' + changelog_entry: + - type: feat + summary: >- + license files are now specified within the gem config if they are + provided + ir_version: 32 + +- version: 0.0.5 + created_at: '2024-03-22' + changelog_entry: + - type: fix + summary: Address parsing issues within the SDK + fixed: + - >- + Syntactic error in block parameter usage: we now ensure block + parameters are the final parameter for functions + - >- + Add properties to subpackages: previously properties on subpackages + were not being exposed + - Ensure optional properties in from_json are only parsed if present + ir_version: 32 + +- version: 0.0.4 + created_at: '2024-03-22' + changelog_entry: + - type: fix + summary: >- + ensures files are written at the gem name path over client name, and + addresses string escaping on one of the Fern headers + ir_version: 32 + +- version: 0.0.3 + created_at: '2024-03-22' + changelog_entry: + - type: fix + summary: >- + addresses a number of typos and other issues previously contained within + the generation code + ir_version: 32 + +- version: 0.0.2 + created_at: '2024-03-22' + changelog_entry: + - type: feat + summary: Support rubygems output type within `generators.yml` + ir_version: 32 + +- version: 0.0.1 + created_at: '2024-02-01' + changelog_entry: + - type: feat + summary: >- + Support client generation (async and sync) as well as most endpoint + types (except streaming) + ir_version: 32 + +- version: 0.0.0 + created_at: '2024-01-30' + changelog_entry: + - type: internal + summary: Initialize the changelog + ir_version: 32 diff --git a/packages/cli/cli/versions.yml b/packages/cli/cli/versions.yml index 0a967b8aea2..61e99b72891 100644 --- a/packages/cli/cli/versions.yml +++ b/packages/cli/cli/versions.yml @@ -1,4 +1,4 @@ - version: 0.39.10 - ir_version: v53 + ir_version: 53 changelog_entry: type: chore diff --git a/packages/cli/generation/ir-migrations/package.json b/packages/cli/generation/ir-migrations/package.json index 9d5a16e53b4..08522e2f202 100644 --- a/packages/cli/generation/ir-migrations/package.json +++ b/packages/cli/generation/ir-migrations/package.json @@ -89,10 +89,12 @@ "@fern-fern/ir-v7-model": "0.0.2", "@fern-fern/ir-v8-model": "0.0.1", "@fern-fern/ir-v9-model": "0.0.1", + "js-yaml": "^4.1.0", "lodash-es": "^4.17.21" }, "devDependencies": { "@types/jest": "^29.5.12", + "@types/js-yaml": "^4.0.8", "@types/lodash-es": "^4.17.12", "@types/node": "^18.7.18", "depcheck": "^1.4.6", diff --git a/packages/cli/generation/ir-migrations/src/IntermediateRepresentationMigrator.ts b/packages/cli/generation/ir-migrations/src/IntermediateRepresentationMigrator.ts index 0adabc8b9c5..ae4feab4eac 100644 --- a/packages/cli/generation/ir-migrations/src/IntermediateRepresentationMigrator.ts +++ b/packages/cli/generation/ir-migrations/src/IntermediateRepresentationMigrator.ts @@ -46,6 +46,7 @@ import { V46_TO_V45_MIGRATION } from "./migrations/v46-to-v45/migrateFromV46ToV4 import { V47_TO_V46_MIGRATION } from "./migrations/v47-to-v46/migrateFromV47ToV46"; import { V48_TO_V47_MIGRATION } from "./migrations/v48-to-v47/migrateFromV48ToV47"; import { V49_TO_V48_MIGRATION } from "./migrations/v49-to-v48/migrateFromV49ToV48"; +import { convertExampleTypeReference } from "./migrations/v5-to-v4/convertExampleTypeReference"; import { V5_TO_V4_MIGRATION } from "./migrations/v5-to-v4/migrateFromV5ToV4"; import { V50_TO_V49_MIGRATION } from "./migrations/v50-to-v49/migrateFromV50ToV49"; import { V51_TO_V50_MIGRATION } from "./migrations/v51-to-v50/migrateFromV51ToV50"; @@ -80,6 +81,10 @@ export interface IntermediateRepresentationMigrator { context: TaskContext; targetGenerator?: GeneratorNameAndVersion; }): MigratedIntermediateMigration; + justGetIRVersionForGenerator: (args: { + context: TaskContext; + targetGenerator: GeneratorNameAndVersion; + }) => string | undefined; } export interface MigratedIntermediateMigration { @@ -126,6 +131,24 @@ class BuildaleIntermediateRepresentationMigratorBuilderImpl class IntermediateRepresentationMigratorImpl implements IntermediateRepresentationMigrator { // eslint-disable-next-line @typescript-eslint/no-explicit-any constructor(public readonly migrations: IrMigration[]) {} + public justGetIRVersionForGenerator(args: { + context: TaskContext; + targetGenerator: GeneratorNameAndVersion; + }): string | undefined { + let lastIrVersion = this.migrations[0]!.laterVersion; + for (const migration of this.migrations) { + if (this.shouldRunMigration({ migration, targetGenerator: args.targetGenerator })) { + lastIrVersion = migration.earlierVersion; + } else { + break; + } + } + + if (lastIrVersion == null) { + args.context.failAndThrow("No IR version found for generator"); + } + return lastIrVersion; + } public migrateForGenerator({ intermediateRepresentation, diff --git a/packages/cli/generation/ir-migrations/src/index.ts b/packages/cli/generation/ir-migrations/src/index.ts index 1b79391c042..9b477ec7286 100644 --- a/packages/cli/generation/ir-migrations/src/index.ts +++ b/packages/cli/generation/ir-migrations/src/index.ts @@ -1,6 +1,7 @@ export { getMinimumVersionForGenerator } from "./getMinimumVersionForGenerator"; export { migrateIntermediateRepresentationForGenerator, - migrateIntermediateRepresentationToVersionForGenerator + migrateIntermediateRepresentationToVersionForGenerator, + getIrVersionForGeneratorVersion } from "./migrateIntermediateRepresentationForGenerator"; export { migrateIntermediateRepresentationThroughVersion } from "./migrateIntermediateRepresentationThroughVersion"; diff --git a/packages/cli/generation/ir-migrations/src/migrateIntermediateRepresentationForGenerator.ts b/packages/cli/generation/ir-migrations/src/migrateIntermediateRepresentationForGenerator.ts index 6c436bf5fb0..b467f8c78dd 100644 --- a/packages/cli/generation/ir-migrations/src/migrateIntermediateRepresentationForGenerator.ts +++ b/packages/cli/generation/ir-migrations/src/migrateIntermediateRepresentationForGenerator.ts @@ -39,3 +39,16 @@ export function migrateIntermediateRepresentationToVersionForGenerator({ }); return migrated.jsonify(); } + +export async function getIrVersionForGeneratorVersion({ + targetGenerator, + context +}: { + targetGenerator: GeneratorNameAndVersion; + context: TaskContext; +}): Promise { + return getIntermediateRepresentationMigrator().justGetIRVersionForGenerator({ + targetGenerator, + context + }); +} diff --git a/packages/seed/fern/definition/config.yml b/packages/seed/fern/definition/config.yml index f94565fd4b0..c02901121f6 100644 --- a/packages/seed/fern/definition/config.yml +++ b/packages/seed/fern/definition/config.yml @@ -3,22 +3,28 @@ imports: types: CliSeedWorkspaceConfiguration: properties: + publishGa: PublishCommand + publishRc: PublishCommand changelogLocation: type: optional docs: | The location of the changelog file, the schema of which must follow FDR's `GeneratorReleaseRequest` object. SeedWorkspaceConfiguration: - extends: CliSeedWorkspaceConfiguration properties: irVersion: string + test: TestConfiguration + publish: PublishConfiguration + changelogLocation: + type: optional + docs: | + The location of the changelog file, the schema of which must follow FDR's `GeneratorReleaseRequest` object. + language: optional defaultCustomConfig: optional> defaultOutputMode: OutputMode generatorType: GeneratorType - docker: string - dockerCommand: optional - local: optional + customFixtureConfig: type: optional docs: | @@ -33,6 +39,48 @@ types: just list the fixture name. For configured fixture list {fixture}:{outputFolder}. features: optional + PublishDockerConfiguration: + properties: + context: string + image: string + file: string + + PublishDocker: + docs: | + Configuration for publishing from a docker image, assuming a vanilla docker deployment. + properties: + workingDirectory: optional + preBuildCommands: optional + docker: PublishDockerConfiguration + + PublishCommand: + docs: | + Configuration for publishing from a command, assuming something packaged up, like with the TypeScript generator. + ex. `pnpm --filter @fern-typescript/express-generator-cli dockerTagVersion "$VERSION"` + Commands can be multi-line, we'll run them all! + properties: + versionSubstitution: + type: optional + docs: | + The string to substitute for the version in the command. ex. `"$VERSION"` + command: DockerCommand + + PublishConfiguration: + discriminated: false + union: + - PublishDocker + - PublishCommand + + TestDockerConfiguration: + properties: + image: string + command: optional + + TestConfiguration: + properties: + docker: TestDockerConfiguration + local: optional + LocalBuildInfo: properties: workingDirectory: diff --git a/packages/seed/package.json b/packages/seed/package.json index 5bf09e160df..401765aa170 100644 --- a/packages/seed/package.json +++ b/packages/seed/package.json @@ -21,8 +21,8 @@ "scripts": { "clean": "rm -rf ./lib && tsc --build --clean", "compile": "tsc --build", - "test": "jest --passWithNoTests", - "test:update": "jest --passWithNoTests -u", + "test": "vitest --run", + "test:update": "vitest --run -u", "lint:eslint": "eslint --max-warnings 0 . --ignore-path=../../.eslintignore", "lint:eslint:fix": "yarn lint:eslint --fix", "format": "prettier --write --ignore-unknown --ignore-path ../../shared/.prettierignore \"**\"", @@ -42,12 +42,13 @@ "@fern-api/local-workspace-runner": "workspace:*", "@fern-api/logger": "workspace:*", "@fern-api/logging-execa": "workspace:*", + "@fern-api/login": "workspace:*", "@fern-api/task-context": "workspace:*", "@fern-api/workspace-loader": "workspace:*", - "@fern-api/login": "workspace:*", - "@fern-fern/generators-sdk": "0.0.5596", + "@fern-api/ir-migrations": "workspace:*", "@fern-fern/fiddle-sdk": "0.0.584", "@fern-fern/generator-exec-sdk": "^0.0.898", + "@fern-fern/generators-sdk": "0.105.0-79c5d1764", "@types/pretty-ms": "^5.0.1", "chalk": "^5.3.0", "console-table-printer": "^2.12.0", @@ -55,26 +56,26 @@ "js-yaml": "^4.1.0", "lodash-es": "^4.17.21", "pretty-ms": "^9.0.0", + "semver": "^7.6.2", "tmp-promise": "^3.0.3", - "yaml": "^2.4.5", "yargs": "^17.4.1" }, "devDependencies": { "@types/find-up": "^4.0.0", - "@types/jest": "^29.5.12", + "globals": "link:@types/vitest/globals", "@types/js-yaml": "^4.0.8", "@types/lodash-es": "^4.17.12", "@types/node": "^18.7.18", + "@types/semver": "^7.5.8", "@types/yargs": "^17.0.28", "@yarnpkg/esbuild-plugin-pnp": "^3.0.0-rc.14", "depcheck": "^1.4.6", "env-cmd": "toddbluhm/env-cmd", "esbuild": "^0.15.7", "eslint": "^8.56.0", - "jest": "^29.7.0", "organize-imports-cli": "^0.10.0", "prettier": "^2.7.1", - "ts-jest": "^29.2.4", - "typescript": "4.6.4" + "typescript": "4.6.4", + "vitest": "^2.0.5" } } \ No newline at end of file diff --git a/packages/seed/src/__test__/assets/add-multiple-versions.yml b/packages/seed/src/__test__/assets/add-multiple-versions.yml new file mode 100644 index 00000000000..42cad869387 --- /dev/null +++ b/packages/seed/src/__test__/assets/add-multiple-versions.yml @@ -0,0 +1,12 @@ +- version: 0.39.10 + ir_version: 53 + changelog_entry: + type: chore +- version: 0.39.11 + ir_version: 53 + changelog_entry: + type: chore +- version: 0.40.10 + ir_version: 53 + changelog_entry: + type: chore diff --git a/packages/seed/src/__test__/assets/latest-isnt-global-max-versions.yml b/packages/seed/src/__test__/assets/latest-isnt-global-max-versions.yml new file mode 100644 index 00000000000..704ccf1737d --- /dev/null +++ b/packages/seed/src/__test__/assets/latest-isnt-global-max-versions.yml @@ -0,0 +1,8 @@ +- version: 0.39.11 + ir_version: 53 + changelog_entry: + type: chore +- version: 0.39.12 + ir_version: 53 + changelog_entry: + type: chore diff --git a/packages/seed/src/__test__/assets/no-versions.yml b/packages/seed/src/__test__/assets/no-versions.yml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/packages/seed/src/__test__/assets/simple-versions.yml b/packages/seed/src/__test__/assets/simple-versions.yml new file mode 100644 index 00000000000..61e99b72891 --- /dev/null +++ b/packages/seed/src/__test__/assets/simple-versions.yml @@ -0,0 +1,4 @@ +- version: 0.39.10 + ir_version: 53 + changelog_entry: + type: chore diff --git a/packages/seed/src/__test__/getNewVersion.test.ts b/packages/seed/src/__test__/getNewVersion.test.ts new file mode 100644 index 00000000000..ac0a4b74af4 --- /dev/null +++ b/packages/seed/src/__test__/getNewVersion.test.ts @@ -0,0 +1,69 @@ +import { createMockTaskContext } from "@fern-api/task-context"; +import { join } from "path"; +import { getNewVersion } from "../commands/publish/publishGenerator"; + +describe("Test getNewVersion", () => { + it("get only version", async () => { + const version = await getNewVersion({ + generatorId: "test", + versionFilePair: { + latestChangelogPath: join(__dirname, "assets/simple-versions.yml"), + previousChangelogPath: join(__dirname, "assets/no-versions.yml") + }, + context: createMockTaskContext() + }); + + expect(version).toEqual("0.39.10"); + }); + + it("get max version", async () => { + const version = await getNewVersion({ + generatorId: "test", + versionFilePair: { + latestChangelogPath: join(__dirname, "assets/add-multiple-versions.yml"), + previousChangelogPath: join(__dirname, "assets/no-versions.yml") + }, + context: createMockTaskContext() + }); + + expect(version).toEqual("0.40.10"); + }); + + it("get max version with diff", async () => { + const version = await getNewVersion({ + generatorId: "test", + versionFilePair: { + latestChangelogPath: join(__dirname, "assets/add-multiple-versions.yml"), + previousChangelogPath: join(__dirname, "assets/simple-versions.yml") + }, + context: createMockTaskContext() + }); + expect(version).toEqual("0.40.10"); + }); + + it("no update", async () => { + const version = await getNewVersion({ + generatorId: "test", + versionFilePair: { + // After this diff, there should be no versions coming from "latest" (e.g. ./assets/simple-versions.yml) + latestChangelogPath: join(__dirname, "assets/simple-versions.yml"), + previousChangelogPath: join(__dirname, "assets/add-multiple-versions.yml") + }, + context: createMockTaskContext() + }); + expect(version).toEqual(undefined); + }); + + // This test makes sure that we take the max latest version, even if it's not the max between the two files + it("latest is not global max", async () => { + const version = await getNewVersion({ + generatorId: "test", + versionFilePair: { + latestChangelogPath: join(__dirname, "assets/latest-isnt-global-max-versions.yml"), + previousChangelogPath: join(__dirname, "assets/add-multiple-versions.yml") + }, + context: createMockTaskContext() + }); + expect(version).toEqual("0.39.12"); + }); +}); diff --git a/packages/seed/src/cli.ts b/packages/seed/src/cli.ts index 0fc739cab32..dc66d658c43 100644 --- a/packages/seed/src/cli.ts +++ b/packages/seed/src/cli.ts @@ -4,6 +4,9 @@ import { askToLogin } from "@fern-api/login"; import { FernRegistryClient as FdrClient } from "@fern-fern/generators-sdk"; import yargs, { Argv } from "yargs"; import { hideBin } from "yargs/helpers"; +import { publishCli } from "./commands/publish/publishCli"; +import { publishGenerator } from "./commands/publish/publishGenerator"; +import { getIrVersionForGeneratorVersion } from "../../cli/generation/ir-migrations/src"; import { registerCliRelease } from "./commands/register/registerCliRelease"; import { registerGenerator } from "./commands/register/registerGenerator"; import { runWithCustomFixture } from "./commands/run/runWithCustomFixture"; @@ -13,6 +16,7 @@ import { DockerTestRunner, LocalTestRunner } from "./commands/test/test-runner"; import { FIXTURES, testGenerator } from "./commands/test/testWorkspaceFixtures"; import { GeneratorWorkspace, loadGeneratorWorkspaces } from "./loadGeneratorWorkspaces"; import { Semaphore } from "./Semaphore"; +import { enrichChangelogWithIr } from "./commands/enrichIr/enrichIr"; void tryRunCli(); @@ -31,6 +35,8 @@ export async function tryRunCli(): Promise { addTestCommand(cli); addRunCommand(cli); addRegisterCommands(cli); + addPublishCommands(cli); + addEnrichChangelogWithIr(cli); await cli.parse(); @@ -105,7 +111,7 @@ function addTestCommand(cli: Argv) { } let testRunner; const scriptRunner = new ScriptRunner(generator, argv.skipScripts); - if (argv.local && generator.workspaceConfig.local != null) { + if (argv.local && generator.workspaceConfig.test.local != null) { testRunner = new LocalTestRunner({ generator, lock, @@ -197,6 +203,131 @@ function addRunCommand(cli: Argv) { ); } +function addPublishCommands(cli: Argv) { + cli.command("publish", "Publish releases", (yargs) => { + yargs + .command( + "cli", + "Publishes all latest versions the CLI to NPM.", + (yargs) => + yargs + // Version is a reserved option in yargs... + .option("ver", { + type: "string", + demandOption: false + }) + .option("changelog", { + type: "string", + demandOption: false, + description: + "Path to the latest changelog file, used along side `previous-changelog` to the most recent new version to publish." + }) + .option("previous-changelog", { + type: "string", + demandOption: false, + description: + "Path to the previous changelog file, used along side `changelog` to the most recent new version to publish." + }) + .option("log-level", { + default: LogLevel.Info, + choices: LOG_LEVELS + }) + .check((argv) => { + return ( + // Check: Either version or changelog and previousChangelog must be provided + argv.ver || (argv.changelog && argv.previousChangelog) + ); + }), + async (argv) => { + const taskContextFactory = new TaskContextFactory(argv["log-level"]); + const context = taskContextFactory.create("Publish"); + + await publishCli({ + version: argv.ver + ? argv.ver + : { + // These assertions should be safe given the check with `yargs` above + // + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + latestChangelogPath: argv.changelog!, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + previousChangelogPath: argv.previousChangelog! + }, + context + }); + } + ) + .command( + "generator ", + "Publishes all latest versions of the generators to DockerHub unless otherwise specified. To filter to certain generators pass in the generator IDs as a positional, space delimited list.", + (yargs) => + yargs + .positional("generator", { + type: "string", + demandOption: true, + description: "Generator(s) to register" + }) + // Version is a reserved option in yargs... + .option("ver", { + type: "string", + demandOption: false + }) + .option("changelog", { + type: "string", + demandOption: false, + description: + "Path to the latest changelog file, used along side `previous-changelog` to the most recent new version to publish." + }) + .option("previous-changelog", { + type: "string", + demandOption: false, + description: + "Path to the previous changelog file, used along side `changelog` to the most recent new version to publish." + }) + .option("log-level", { + default: LogLevel.Info, + choices: LOG_LEVELS + }) + .check((argv) => { + return ( + // Check: Either version or changelog and previousChangelog must be provided + argv.ver || (argv.changelog && argv.previousChangelog) + ); + }), + async (argv) => { + const generators = await loadGeneratorWorkspaces(); + if (argv.generators != null) { + throwIfGeneratorDoesNotExist({ seedWorkspaces: generators, generators: [argv.generator] }); + } + + const taskContextFactory = new TaskContextFactory(argv["log-level"]); + const context = taskContextFactory.create("Publish"); + + const maybeGeneratorWorkspace = generators.find((g) => g.workspaceName === argv.generator); + if (maybeGeneratorWorkspace == null) { + context.failAndThrow(`Specified generator ${argv.generator} not found.`); + return; + } + + await publishGenerator({ + generator: maybeGeneratorWorkspace, + version: argv.ver + ? argv.ver + : { + // These assertions should be safe given the check with `yargs` above + // + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + latestChangelogPath: argv.changelog!, + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + previousChangelogPath: argv.previousChangelog! + }, + context + }); + } + ); + }); +} + function addRegisterCommands(cli: Argv) { cli.command("register", "Register releases within FDR's database", (yargs) => { yargs @@ -217,16 +348,17 @@ function addRegisterCommands(cli: Argv) { await registerCliRelease({ fdrClient, - context: taskContextFactory.create("Register") + context }); } ) .command( - "generator ", - "Registers all of the generators to FDR unless otherwise specified. To filter to certain generators pass in the generator IDs as a positional, space delimited list.", + "generator", + "Registers all of the generators to FDR unless otherwise specified. To filter to certain generators pass in the generator ids to `--generators`, space delimited list.", (yargs) => yargs - .positional("generators", { + // This would ideally be positional, but you can't have positional arguments that are arrays with yargs + .option("generators", { array: true, type: "string", demandOption: false, @@ -264,6 +396,43 @@ function addRegisterCommands(cli: Argv) { }); } +function addEnrichChangelogWithIr(cli: Argv) { + cli.command( + "enrich-with-ir ", + "Enriches the changelog with IR data", + (yargs) => + yargs + .option("generator", { + type: "string", + demandOption: true, + description: "Generator(s) to register" + }) + .option("log-level", { + default: LogLevel.Info, + choices: LOG_LEVELS + }), + async (argv) => { + const generators = await loadGeneratorWorkspaces(); + if (argv.generators != null) { + throwIfGeneratorDoesNotExist({ seedWorkspaces: generators, generators: [argv.generator] }); + } + const taskContextFactory = new TaskContextFactory(argv["log-level"]); + const context = taskContextFactory.create("Register"); + + const maybeGeneratorWorkspace = generators.find((g) => g.workspaceName === argv.generator); + if (maybeGeneratorWorkspace == null) { + context.failAndThrow(`Specified generator ${argv.generator} not found.`); + return; + } + + await enrichChangelogWithIr({ + generator: maybeGeneratorWorkspace, + context + }); + } + ); +} + function throwIfGeneratorDoesNotExist({ seedWorkspaces, generators diff --git a/packages/seed/src/commands/enrichIr/enrichIr.ts b/packages/seed/src/commands/enrichIr/enrichIr.ts new file mode 100644 index 00000000000..c16e0956d75 --- /dev/null +++ b/packages/seed/src/commands/enrichIr/enrichIr.ts @@ -0,0 +1,98 @@ +import { doesPathExist, join, RelativeFilePath } from "@fern-api/fs-utils"; +import { TaskContext } from "@fern-api/task-context"; +import { getIrVersionForGeneratorVersion } from "../../../../cli/generation/local-generation/local-workspace-runner/node_modules/@fern-api/ir-migrations/src"; +import { GeneratorWorkspace } from "../../loadGeneratorWorkspaces"; +import { parseGeneratorReleasesFile } from "../../utils/convertVersionsFileToReleases"; +import yaml from "js-yaml"; +import { writeFile } from "fs/promises"; +import { GeneratorName } from "@fern-api/configuration"; + +export async function enrichChangelogWithIr({ + generator, + context +}: { + generator: GeneratorWorkspace; + context: TaskContext; +}): Promise { + const generatorConfig = generator.workspaceConfig; + const generatorName = getGeneratorNameFromWorkspaceName(generator.workspaceName); + context.logger.info(`Enriching changelog with IR data for generator ${generator.workspaceName}`); + if (generatorName && generatorConfig.changelogLocation) { + const absolutePathToChangelogLocation = join( + generator.absolutePathToWorkspace, + RelativeFilePath.of(generatorConfig.changelogLocation) + ); + if (!(await doesPathExist(absolutePathToChangelogLocation))) { + context.logger.error( + `Specified changelog location (${absolutePathToChangelogLocation}) not found, continuing without registering versions for generator ${generator.workspaceName}.` + ); + return undefined; + } + const enrichedReleases: unknown[] = []; + await parseGeneratorReleasesFile({ + generatorId: generator.workspaceName, + changelogPath: absolutePathToChangelogLocation, + context, + action: async (release, rawRelease) => { + const ver = await getIrVersionForGeneratorVersion({ + targetGenerator: { + name: generatorName, + version: release.version + }, + context + }); + if (!ver) { + context.logger.warn( + `Failed to get IR version for generator version ${release.version}, continuing without enriching release.` + ); + return; + } + + enrichedReleases.push({ ...rawRelease, ir_version: Number.parseInt(ver.replace("v", "")) }); + } + }); + + const enrichedChangelog = yaml.dump(enrichedReleases); + await writeFile(absolutePathToChangelogLocation + ".new", enrichedChangelog); + } +} + +function getGeneratorNameFromWorkspaceName(workspaceName: string): GeneratorName | undefined { + switch (workspaceName) { + case "csharp-model": + return GeneratorName.CSHARP_MODEL; + case "csharp-sdk": + return GeneratorName.CSHARP_SDK; + case "fastapi": + return GeneratorName.PYTHON_FASTAPI; + case "go-fiber": + return GeneratorName.GO_FIBER; + case "go-model": + return GeneratorName.GO_MODEL; + case "go-sdk": + return GeneratorName.GO_SDK; + case "java-model": + return GeneratorName.JAVA_MODEL; + case "java-sdk": + return GeneratorName.JAVA_SDK; + case "java-spring": + return GeneratorName.JAVA_SPRING; + case "openapi": + return GeneratorName.OPENAPI; + case "postman": + return GeneratorName.POSTMAN; + case "pydantic": + return GeneratorName.PYTHON_PYDANTIC; + case "python-sdk": + return GeneratorName.PYTHON_SDK; + case "ruby-model": + return GeneratorName.RUBY_MODEL; + case "ruby-sdk": + return GeneratorName.RUBY_SDK; + case "ts-sdk": + return GeneratorName.TYPESCRIPT_SDK; + case "ts-express": + return GeneratorName.TYPESCRIPT_EXPRESS; + } + return undefined; +} diff --git a/packages/seed/src/commands/publish/publishCli.ts b/packages/seed/src/commands/publish/publishCli.ts new file mode 100644 index 00000000000..1a8dbedb604 --- /dev/null +++ b/packages/seed/src/commands/publish/publishCli.ts @@ -0,0 +1,111 @@ +import { TaskContext } from "@fern-api/task-context"; +import { CliReleaseRequest } from "@fern-fern/generators-sdk/api/resources/generators"; +import semver from "semver"; +import { PublishCommand } from "../../config/api"; +import { loadCliWorkspace } from "../../loadGeneratorWorkspaces"; +import { parseCliReleasesFile } from "../../utils/convertVersionsFileToReleases"; +import { runCommands, subVersion } from "../../utils/publishUtilities"; + +interface VersionFilePair { + latestChangelogPath: string; + previousChangelogPath: string; +} + +export async function publishCli({ + version, + context +}: { + version: string | VersionFilePair; + context: TaskContext; +}): Promise { + const cliWorkspace = await loadCliWorkspace(); + context.logger.info(`Publishing CLI@${version}...`); + + let publishVersion: string; + if (typeof version !== "string") { + // We were given two version files, so we need to compare them to find if any new + // versions have been added since the last publish. + const maybeNewVersion = await getNewVersion({ + versionFilePair: version, + context + }); + + if (maybeNewVersion == null) { + context.failWithoutThrowing( + "No version to publish! There must not have been a new version since the last publish." + ); + return; + } + publishVersion = maybeNewVersion; + } else { + publishVersion = version; + } + + let publishConfig: PublishCommand; + if (publishVersion.includes("rc")) { + publishConfig = cliWorkspace.workspaceConfig.publishRc; + } else { + publishConfig = cliWorkspace.workspaceConfig.publishGa; + } + + // Instance of PublishCommand configuration, leverage these commands outright + const unparsedCommands = publishConfig.command; + const commands = Array.isArray(unparsedCommands) ? unparsedCommands : [unparsedCommands]; + const versionSubsitution = publishConfig.versionSubstitution; + const subbedCommands = commands.map((command) => subVersion(command, publishVersion, versionSubsitution)); + await runCommands(subbedCommands, context, cliWorkspace.absolutePathToWorkspace); +} + +// This function is just different enough from the equivalent in publishGenerator.ts that it's worth keeping them separate +// +// Take two files, traditionally the latest version file (e.g. the file on the branch merging to main), +// and the previous version file (e.g. the file on the main branch), and compare them to find the most recent version +// +// The most recent version is defined here as the most recent version in the latest version file that is not in the previous version file +export async function getNewVersion({ + versionFilePair, + context +}: { + versionFilePair: VersionFilePair; + context: TaskContext; +}): Promise { + // Our action performed on each generator release in the file is to + // simply collect the version ID within a set for comparison later + const collectVersions = (versionsSet: Set) => { + return async (release: CliReleaseRequest) => { + versionsSet.add(release.version); + }; + }; + + const latestVersionGeneratorReleasesVersions = new Set(); + await parseCliReleasesFile({ + changelogPath: versionFilePair.latestChangelogPath, + context, + action: collectVersions(latestVersionGeneratorReleasesVersions) + }); + const previousVersionGeneratorReleaseVersions = new Set(); + await parseCliReleasesFile({ + changelogPath: versionFilePair.previousChangelogPath, + context, + action: collectVersions(previousVersionGeneratorReleaseVersions) + }); + + // Get generator versions not in the previous version file + // + // Sadly TS does not have a set difference function, so we manually filter the "latest" + // array for versions explicitly not in the previous versions set + const newVersions = Array.from(latestVersionGeneratorReleasesVersions).filter( + (item) => !previousVersionGeneratorReleaseVersions.has(item) + ); + + // Sort the resultant array of new versions by semantic version and return the largest / "most recent" + return ( + newVersions + .map((ver) => semver.parse(ver)) + .filter((ver): ver is semver.SemVer => ver != null) + // Here we compare semantic versions to try to get the largest version that's new + // We negate the number to get the largest version first + .sort((a, b) => -a.compare(b))[0] + ?.toString() + ); +} diff --git a/packages/seed/src/commands/publish/publishGenerator.ts b/packages/seed/src/commands/publish/publishGenerator.ts new file mode 100644 index 00000000000..30d1bb08b2d --- /dev/null +++ b/packages/seed/src/commands/publish/publishGenerator.ts @@ -0,0 +1,170 @@ +import { loggingExeca } from "@fern-api/logging-execa"; +import { TaskContext } from "@fern-api/task-context"; +import { GeneratorReleaseRequest } from "@fern-fern/generators-sdk/api/resources/generators"; +import semver from "semver"; +import { PublishDockerConfiguration } from "../../config/api"; +import { GeneratorWorkspace } from "../../loadGeneratorWorkspaces"; +import { parseGeneratorReleasesFile } from "../../utils/convertVersionsFileToReleases"; +import { runCommands, subVersion } from "../../utils/publishUtilities"; + +interface VersionFilePair { + latestChangelogPath: string; + previousChangelogPath: string; +} + +export async function publishGenerator({ + generator, + version, + context +}: { + generator: GeneratorWorkspace; + version: string | VersionFilePair; + context: TaskContext; +}): Promise { + const generatorId = generator.workspaceName; + context.logger.info(`Publishing generator ${generatorId}@${version}...`); + + let publishVersion: string; + if (typeof version !== "string") { + // We were given two version files, so we need to compare them to find if any new + // versions have been added since the last publish. + const maybeNewVersion = await getNewVersion({ + generatorId, + versionFilePair: version, + context + }); + + if (maybeNewVersion == null) { + context.failWithoutThrowing( + "No version to publish! There must not have been a new version since the last publish." + ); + return; + } + publishVersion = maybeNewVersion; + } else { + publishVersion = version; + } + + const publishConfig = generator.workspaceConfig.publish; + // Instance of PublishDocker configuration, leverage docker CLI here + if ("docker" in publishConfig) { + const unparsedCommands = publishConfig.preBuildCommands; + const preBuildCommands = Array.isArray(unparsedCommands) + ? unparsedCommands + : unparsedCommands + ? [unparsedCommands] + : []; + + await runCommands(preBuildCommands, context, publishConfig.workingDirectory); + await buildAndPushDockerImage(publishConfig.docker, publishVersion, context); + } else { + // Instance of PublishCommand configuration, leverage these commands outright + const unparsedCommands = publishConfig.command; + const commands = Array.isArray(unparsedCommands) ? unparsedCommands : [unparsedCommands]; + const versionSubsitution = publishConfig.versionSubstitution; + const subbedCommands = commands.map((command) => subVersion(command, publishVersion, versionSubsitution)); + await runCommands(subbedCommands, context, generator.absolutePathToWorkspace); + } +} + +async function buildAndPushDockerImage( + dockerConfig: PublishDockerConfiguration, + version: string, + context: TaskContext +) { + // Push the Docker image to the registry + const dockerHubUsername = process?.env?.DOCKER_USERNAME; + const dockerHubPassword = process?.env?.DOCKER_PASSWORD; + if (!dockerHubUsername || !dockerHubPassword) { + context.failAndThrow("Docker Hub credentials not found within your environment variables."); + } + + context.logger.debug(`Logging into Docker Hub...`); + await loggingExeca(context.logger, "docker", ["login", "-u", dockerHubUsername, "--password-stdin"], { + doNotPipeOutput: true, + input: dockerHubPassword + }); + + // Build and push the Docker image, now that you've run the pre-build commands + const imageTag = `${dockerConfig.image}:${version}`; + context.logger.debug(`Pushing Docker image ${imageTag} to Docker Hub...`); + const standardBuildOptions = [ + "build", + "--push", + "--platform", + "linux/amd64,linux/arm64", + "-f", + dockerConfig.file, + "-t", + imageTag, + dockerConfig.context + ]; + try { + await loggingExeca(context.logger, "docker", standardBuildOptions, { doNotPipeOutput: true }); + } catch (e) { + if (e instanceof Error && e.message.includes("Multi-platform build is not supported for the docker driver")) { + context.logger.error( + "Docker cannot build multi-platform images with the current driver, trying `docker buildx`." + ); + await loggingExeca(context.logger, "docker", ["buildx", ...standardBuildOptions], { + doNotPipeOutput: false + }); + } + } +} + +// Take two files, traditionally the latest version file (e.g. the file on the branch merging to main), +// and the previous version file (e.g. the file on the main branch), and compare them to find the most recent version +// +// The most recent version is defined here as the most recent version in the latest version file that is not in the previous version file +export async function getNewVersion({ + generatorId, + versionFilePair, + context +}: { + generatorId: string; + versionFilePair: VersionFilePair; + context: TaskContext; +}): Promise { + // Our action performed on each generator release in the file is to + // simply collect the version ID within a set for comparison later + const collectVersions = (versionsSet: Set) => { + return async (release: GeneratorReleaseRequest) => { + versionsSet.add(release.version); + }; + }; + + const latestVersionGeneratorReleasesVersions = new Set(); + await parseGeneratorReleasesFile({ + generatorId, + changelogPath: versionFilePair.latestChangelogPath, + context, + action: collectVersions(latestVersionGeneratorReleasesVersions) + }); + const previousVersionGeneratorReleaseVersions = new Set(); + await parseGeneratorReleasesFile({ + generatorId, + changelogPath: versionFilePair.previousChangelogPath, + context, + action: collectVersions(previousVersionGeneratorReleaseVersions) + }); + + // Get generator versions not in the previous version file + // + // Sadly TS does not have a set difference function, so we manually filter the "latest" + // array for versions explicitly not in the previous versions set + const newVersions = Array.from(latestVersionGeneratorReleasesVersions).filter( + (item) => !previousVersionGeneratorReleaseVersions.has(item) + ); + + // Sort the resultant array of new versions by semantic version and return the largest / "most recent" + return ( + newVersions + .map((ver) => semver.parse(ver)) + .filter((ver): ver is semver.SemVer => ver != null) + // Here we compare semantic versions to try to get the largest version that's new + // We negate the number to get the largest version first + .sort((a, b) => -a.compare(b))[0] + ?.toString() + ); +} diff --git a/packages/seed/src/commands/register/registerCliRelease.ts b/packages/seed/src/commands/register/registerCliRelease.ts index e794ff67000..a23d5f5fc04 100644 --- a/packages/seed/src/commands/register/registerCliRelease.ts +++ b/packages/seed/src/commands/register/registerCliRelease.ts @@ -3,7 +3,7 @@ import { TaskContext } from "@fern-api/task-context"; import { FernRegistryClient as FdrClient } from "@fern-fern/generators-sdk"; import * as serializers from "@fern-fern/generators-sdk/serialization"; import { readFile } from "fs/promises"; -import YAML from "yaml"; +import yaml from "js-yaml"; import { loadCliWorkspace } from "../../loadGeneratorWorkspaces"; export async function registerCliRelease({ @@ -36,19 +36,16 @@ export async function registerCliRelease({ } // We've found a versions file, let's read it and register all the versions - const changelogs = YAML.parseDocument((await readFile(absolutePathToChangelogLocation)).toString()); + const changelogs = yaml.load((await readFile(absolutePathToChangelogLocation)).toString()); context.logger.info("Registering CLI releases..."); - if (YAML.isSeq(changelogs)) { - for (const entry of changelogs.items) { - if (!YAML.isMap(entry)) { - continue; - } + if (Array.isArray(changelogs)) { + for (const entry of changelogs) { try { const release = serializers.generators.CliReleaseRequest.parseOrThrow(entry); context.logger.debug(`Registering CLI release: ${release.version}`); - fdrClient.generators.cli.upsertCliRelease(release); + await fdrClient.generators.cli.upsertCliRelease(release); } catch (e) { - context.logger.error(`Error parsing release: ${e}`); + context.logger.error(`Error parsing release: ${(e as Error)?.message}`); } } } diff --git a/packages/seed/src/commands/register/registerGenerator.ts b/packages/seed/src/commands/register/registerGenerator.ts index 118548ab735..add60f27fbe 100644 --- a/packages/seed/src/commands/register/registerGenerator.ts +++ b/packages/seed/src/commands/register/registerGenerator.ts @@ -1,11 +1,9 @@ import { doesPathExist, join, RelativeFilePath } from "@fern-api/fs-utils"; import { TaskContext } from "@fern-api/task-context"; import { FernRegistry, FernRegistryClient as FdrClient } from "@fern-fern/generators-sdk"; -import * as serializers from "@fern-fern/generators-sdk/serialization"; -import { readFile } from "fs/promises"; -import YAML from "yaml"; import { GeneratorType } from "../../config/api"; import { GeneratorWorkspace } from "../../loadGeneratorWorkspaces"; +import { parseGeneratorReleasesFile } from "../../utils/convertVersionsFileToReleases"; // TODO: we should share the language and generator type with the FDR definition export async function registerGenerator({ @@ -26,7 +24,7 @@ export async function registerGenerator({ id: generatorId, generatorType: convertGeneratorType(generatorConfig.generatorType), generatorLanguage: generatorConfig.language, - dockerImage: generatorConfig.docker + dockerImage: generatorConfig.test.docker.image }); // Register generator versions @@ -43,25 +41,17 @@ export async function registerGenerator({ } // We've found a versions file, let's read it and register all the versions - const changelogs = YAML.parseDocument((await readFile(absolutePathToChangelogLocation)).toString()); - context.logger.info(`Registering generator ${generatorId} releases...`); - if (YAML.isSeq(changelogs)) { - for (const entry of changelogs.items) { - if (!YAML.isMap(entry)) { - continue; - } - try { - const release = serializers.generators.GeneratorReleaseRequest.parseOrThrow({ - generator_id: generatorId, - ...entry - }); - context.logger.debug(`Registering generator ${generatorId} release: ${release.version}`); - fdrClient.generators.versions.upsertGeneratorRelease(release); - } catch (e) { - context.logger.error(`Error parsing release: ${e}`); - } + context.logger.info(`Registering generator ${generatorId} releases from ${absolutePathToChangelogLocation}...`); + await parseGeneratorReleasesFile({ + generatorId, + changelogPath: absolutePathToChangelogLocation, + context, + action: async (release) => { + context.logger.info(`Registering generator ${generatorId} release: ${release.version}`); + await fdrClient.generators.versions.upsertGeneratorRelease(release); } - } + }); + context.logger.info(`Registration complete.`); } } diff --git a/packages/seed/src/commands/test/test-runner/DockerTestRunner.ts b/packages/seed/src/commands/test/test-runner/DockerTestRunner.ts index f8c4003526f..4a47f049bef 100644 --- a/packages/seed/src/commands/test/test-runner/DockerTestRunner.ts +++ b/packages/seed/src/commands/test/test-runner/DockerTestRunner.ts @@ -10,9 +10,9 @@ import { TestRunner } from "./TestRunner"; export class DockerTestRunner extends TestRunner { async build(): Promise { const dockerCommands = - typeof this.generator.workspaceConfig.dockerCommand === "string" - ? [this.generator.workspaceConfig.dockerCommand] - : this.generator.workspaceConfig.dockerCommand; + typeof this.generator.workspaceConfig.test.docker.command === "string" + ? [this.generator.workspaceConfig.test.docker.command] + : this.generator.workspaceConfig.test.docker.command; if (dockerCommands == null) { throw new Error(`Failed. No docker command for ${this.generator.workspaceName}`); } diff --git a/packages/seed/src/commands/test/test-runner/LocalTestRunner.ts b/packages/seed/src/commands/test/test-runner/LocalTestRunner.ts index e5d671fc744..f7578327141 100644 --- a/packages/seed/src/commands/test/test-runner/LocalTestRunner.ts +++ b/packages/seed/src/commands/test/test-runner/LocalTestRunner.ts @@ -156,12 +156,12 @@ export class LocalTestRunner extends TestRunner { } private async getLocalConfigOrthrow(): Promise { - if (this.generator.workspaceConfig.local == null) { + if (this.generator.workspaceConfig.test.local == null) { throw new Error( `Attempted to run ${this.generator.workspaceName} locally. No local configuration in seed.yml found.` ); } - return this.generator.workspaceConfig.local; + return this.generator.workspaceConfig.test.local; } private getSourceConfig(workspace: FernWorkspace): SourceConfig { diff --git a/packages/seed/src/commands/test/test-runner/TestRunner.ts b/packages/seed/src/commands/test/test-runner/TestRunner.ts index 594ec288b39..c0e5adf17fe 100644 --- a/packages/seed/src/commands/test/test-runner/TestRunner.ts +++ b/packages/seed/src/commands/test/test-runner/TestRunner.ts @@ -244,7 +244,7 @@ export abstract class TestRunner { public abstract runGenerator(args: TestRunner.DoRunArgs): Promise; protected getParsedDockerName(): ParsedDockerName { - return parseDockerOrThrow(this.generator.workspaceConfig.docker); + return parseDockerOrThrow(this.generator.workspaceConfig.test.docker.image); } } diff --git a/packages/seed/src/config/api/resources/config/types/CliSeedWorkspaceConfiguration.ts b/packages/seed/src/config/api/resources/config/types/CliSeedWorkspaceConfiguration.ts index b801646b18a..a7ae83a5505 100644 --- a/packages/seed/src/config/api/resources/config/types/CliSeedWorkspaceConfiguration.ts +++ b/packages/seed/src/config/api/resources/config/types/CliSeedWorkspaceConfiguration.ts @@ -2,7 +2,11 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as FernSeedConfig from "../../.."; + export interface CliSeedWorkspaceConfiguration { + publishGa: FernSeedConfig.PublishCommand; + publishRc: FernSeedConfig.PublishCommand; /** The location of the changelog file, the schema of which must follow FDR's `GeneratorReleaseRequest` object. */ changelogLocation?: string; } diff --git a/packages/seed/src/config/api/resources/config/types/PublishCommand.ts b/packages/seed/src/config/api/resources/config/types/PublishCommand.ts new file mode 100644 index 00000000000..a5730d7af86 --- /dev/null +++ b/packages/seed/src/config/api/resources/config/types/PublishCommand.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as FernSeedConfig from "../../.."; + +/** + * Configuration for publishing from a command, assuming something packaged up, like with the TypeScript generator. + * ex. `pnpm --filter @fern-typescript/express-generator-cli dockerTagVersion "$VERSION"` + * Commands can be multi-line, we'll run them all! + */ +export interface PublishCommand { + /** The string to substitute for the version in the command. ex. `"$VERSION"` */ + versionSubstitution?: string; + command: FernSeedConfig.DockerCommand; +} diff --git a/packages/seed/src/config/api/resources/config/types/PublishConfiguration.ts b/packages/seed/src/config/api/resources/config/types/PublishConfiguration.ts new file mode 100644 index 00000000000..679815bd1cc --- /dev/null +++ b/packages/seed/src/config/api/resources/config/types/PublishConfiguration.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as FernSeedConfig from "../../.."; + +export type PublishConfiguration = FernSeedConfig.PublishDocker | FernSeedConfig.PublishCommand; diff --git a/packages/seed/src/config/api/resources/config/types/PublishDocker.ts b/packages/seed/src/config/api/resources/config/types/PublishDocker.ts new file mode 100644 index 00000000000..3c0ddbad91f --- /dev/null +++ b/packages/seed/src/config/api/resources/config/types/PublishDocker.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as FernSeedConfig from "../../.."; + +/** + * Configuration for publishing from a docker image, assuming a vanilla docker deployment. + */ +export interface PublishDocker { + workingDirectory?: string; + preBuildCommands?: FernSeedConfig.DockerCommand; + docker: FernSeedConfig.PublishDockerConfiguration; +} diff --git a/packages/seed/src/config/api/resources/config/types/PublishDockerConfiguration.ts b/packages/seed/src/config/api/resources/config/types/PublishDockerConfiguration.ts new file mode 100644 index 00000000000..a540f63e59c --- /dev/null +++ b/packages/seed/src/config/api/resources/config/types/PublishDockerConfiguration.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PublishDockerConfiguration { + context: string; + image: string; + file: string; +} diff --git a/packages/seed/src/config/api/resources/config/types/SeedWorkspaceConfiguration.ts b/packages/seed/src/config/api/resources/config/types/SeedWorkspaceConfiguration.ts index 107d3c60b19..1ac77b4d8fb 100644 --- a/packages/seed/src/config/api/resources/config/types/SeedWorkspaceConfiguration.ts +++ b/packages/seed/src/config/api/resources/config/types/SeedWorkspaceConfiguration.ts @@ -4,15 +4,16 @@ import * as FernSeedConfig from "../../.."; -export interface SeedWorkspaceConfiguration extends FernSeedConfig.CliSeedWorkspaceConfiguration { +export interface SeedWorkspaceConfiguration { irVersion: string; + test: FernSeedConfig.TestConfiguration; + publish: FernSeedConfig.PublishConfiguration; + /** The location of the changelog file, the schema of which must follow FDR's `GeneratorReleaseRequest` object. */ + changelogLocation?: string; language?: FernSeedConfig.Language; defaultCustomConfig?: Record; defaultOutputMode: FernSeedConfig.OutputMode; generatorType: FernSeedConfig.GeneratorType; - docker: string; - dockerCommand?: FernSeedConfig.DockerCommand; - local?: FernSeedConfig.LocalBuildInfo; /** Configuration that will be used for any custom fixture specified by --custom-fixture */ customFixtureConfig?: FernSeedConfig.FixtureConfigurations; fixtures?: Record; diff --git a/packages/seed/src/config/api/resources/config/types/TestConfiguration.ts b/packages/seed/src/config/api/resources/config/types/TestConfiguration.ts new file mode 100644 index 00000000000..0a9c55c15a4 --- /dev/null +++ b/packages/seed/src/config/api/resources/config/types/TestConfiguration.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as FernSeedConfig from "../../.."; + +export interface TestConfiguration { + docker: FernSeedConfig.TestDockerConfiguration; + local?: FernSeedConfig.LocalBuildInfo; +} diff --git a/packages/seed/src/config/api/resources/config/types/TestDockerConfiguration.ts b/packages/seed/src/config/api/resources/config/types/TestDockerConfiguration.ts new file mode 100644 index 00000000000..22ece3219b2 --- /dev/null +++ b/packages/seed/src/config/api/resources/config/types/TestDockerConfiguration.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as FernSeedConfig from "../../.."; + +export interface TestDockerConfiguration { + image: string; + command?: FernSeedConfig.DockerCommand; +} diff --git a/packages/seed/src/config/api/resources/config/types/index.ts b/packages/seed/src/config/api/resources/config/types/index.ts index c2d25cb19b8..d480c6c22e4 100644 --- a/packages/seed/src/config/api/resources/config/types/index.ts +++ b/packages/seed/src/config/api/resources/config/types/index.ts @@ -1,5 +1,11 @@ export * from "./CliSeedWorkspaceConfiguration"; export * from "./SeedWorkspaceConfiguration"; +export * from "./PublishDockerConfiguration"; +export * from "./PublishDocker"; +export * from "./PublishCommand"; +export * from "./PublishConfiguration"; +export * from "./TestDockerConfiguration"; +export * from "./TestConfiguration"; export * from "./LocalBuildInfo"; export * from "./DockerCommand"; export * from "./ScriptConfig"; diff --git a/packages/seed/src/utils/convertVersionsFileToReleases.ts b/packages/seed/src/utils/convertVersionsFileToReleases.ts new file mode 100644 index 00000000000..70d0de80a70 --- /dev/null +++ b/packages/seed/src/utils/convertVersionsFileToReleases.ts @@ -0,0 +1,57 @@ +import { TaskContext } from "@fern-api/task-context"; +import { CliReleaseRequest, GeneratorReleaseRequest } from "@fern-fern/generators-sdk/api/resources/generators"; +import * as serializers from "@fern-fern/generators-sdk/serialization"; +import { readFile } from "fs/promises"; +import yaml from "js-yaml"; + +export async function parseGeneratorReleasesFile({ + generatorId, + changelogPath, + context, + action +}: { + generatorId: string; + changelogPath: string; + context: TaskContext; + action: (release: GeneratorReleaseRequest, rawRelease: object) => Promise; +}): Promise { + context.logger.debug(`Parsing versions file ${changelogPath}`); + const changelogs = yaml.load((await readFile(changelogPath)).toString()); + if (Array.isArray(changelogs)) { + for (const entry of changelogs) { + try { + const release = serializers.generators.GeneratorReleaseRequest.parseOrThrow({ + generator_id: generatorId, + ir_version: 0, + ...entry + }); + await action(release, entry); + } catch (e) { + context.logger.error(`Failed to parse and run action on release: ${(e as Error)?.message}`); + } + } + } +} + +export async function parseCliReleasesFile({ + changelogPath, + context, + action +}: { + changelogPath: string; + context: TaskContext; + action: (release: CliReleaseRequest) => Promise; +}): Promise { + context.logger.debug(`Parsing versions file ${changelogPath}`); + const changelogs = yaml.load((await readFile(changelogPath)).toString()); + if (Array.isArray(changelogs)) { + for (const entry of changelogs) { + try { + const release = serializers.generators.CliReleaseRequest.parseOrThrow(entry); + await action(release); + } catch (e) { + context.logger.error(`Failed to parse and run action on release: ${(e as Error)?.message}`); + } + } + } +} diff --git a/packages/seed/src/utils/publishUtilities.ts b/packages/seed/src/utils/publishUtilities.ts new file mode 100644 index 00000000000..ca99ccd92a1 --- /dev/null +++ b/packages/seed/src/utils/publishUtilities.ts @@ -0,0 +1,14 @@ +import { loggingExeca } from "@fern-api/logging-execa"; +import { TaskContext } from "@fern-api/task-context"; + +// Replace the version string within the command, if one is specified +// The idea here is to turn a command like "npm publish --tag $VERSION" into "npm publish --tag v1.0.0" +export function subVersion(command: string, version: string, versionSubsitution?: string): string { + return versionSubsitution ? command.replace(versionSubsitution, version) : command; +} + +export async function runCommands(commands: string[], context: TaskContext, cwd: string | undefined) { + for (const command of commands) { + await loggingExeca(context.logger, "cd", [cwd ?? ".", "&&", command]); + } +} diff --git a/packages/seed/vitest.config.ts b/packages/seed/vitest.config.ts new file mode 100644 index 00000000000..0652c358cb4 --- /dev/null +++ b/packages/seed/vitest.config.ts @@ -0,0 +1 @@ +export { default } from "../../shared/vitest.config"; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5dcb06e9f69..a6312069083 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3179,6 +3179,8 @@ importers: packages/cli/cli/dist/dev: {} + packages/cli/cli/dist/prod: {} + packages/cli/configuration: dependencies: '@fern-api/core-utils': @@ -3814,6 +3816,9 @@ importers: '@fern-fern/ir-v9-model': specifier: 0.0.1 version: 0.0.1 + js-yaml: + specifier: ^4.1.0 + version: 4.1.0 lodash-es: specifier: ^4.17.21 version: 4.17.21 @@ -3821,6 +3826,9 @@ importers: '@types/jest': specifier: ^29.5.12 version: 29.5.12 + '@types/js-yaml': + specifier: ^4.0.8 + version: 4.0.8 '@types/lodash-es': specifier: ^4.17.12 version: 4.17.12 @@ -5558,6 +5566,9 @@ importers: '@fern-api/fs-utils': specifier: workspace:* version: link:../commons/fs-utils + '@fern-api/ir-migrations': + specifier: workspace:* + version: link:../cli/generation/ir-migrations '@fern-api/ir-sdk': specifier: workspace:* version: link:../ir-sdk @@ -5586,8 +5597,8 @@ importers: specifier: ^0.0.898 version: 0.0.898 '@fern-fern/generators-sdk': - specifier: 0.0.5596 - version: 0.0.5596 + specifier: 0.105.0-79c5d1764 + version: 0.105.0-79c5d1764 '@types/pretty-ms': specifier: ^5.0.1 version: 5.0.1 @@ -5609,12 +5620,12 @@ importers: pretty-ms: specifier: ^9.0.0 version: 9.0.0 + semver: + specifier: ^7.6.2 + version: 7.6.2 tmp-promise: specifier: ^3.0.3 version: 3.0.3 - yaml: - specifier: 2.3.3 - version: 2.3.3 yargs: specifier: ^17.4.1 version: 17.7.2 @@ -5622,9 +5633,6 @@ importers: '@types/find-up': specifier: ^4.0.0 version: 4.0.0 - '@types/jest': - specifier: ^29.5.12 - version: 29.5.12 '@types/js-yaml': specifier: ^4.0.8 version: 4.0.8 @@ -5634,6 +5642,9 @@ importers: '@types/node': specifier: ^18.7.18 version: 18.7.18 + '@types/semver': + specifier: ^7.5.8 + version: 7.5.8 '@types/yargs': specifier: ^17.0.28 version: 17.0.28 @@ -5652,21 +5663,21 @@ importers: eslint: specifier: ^8.56.0 version: 8.56.0 - jest: - specifier: ^29.7.0 - version: 29.7.0(@types/node@18.7.18)(ts-node@10.9.2(@types/node@18.7.18)(typescript@4.6.4)) + globals: + specifier: link:@types/vitest/globals + version: link:@types/vitest/globals organize-imports-cli: specifier: ^0.10.0 version: 0.10.0 prettier: specifier: ^2.7.1 version: 2.7.1 - ts-jest: - specifier: ^29.2.4 - version: 29.2.4(@babel/core@7.25.2)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.25.2))(esbuild@0.15.7)(jest@29.7.0(@types/node@18.7.18)(ts-node@10.9.2(@types/node@18.7.18)(typescript@4.6.4)))(typescript@4.6.4) typescript: specifier: 4.6.4 version: 4.6.4 + vitest: + specifier: ^2.0.5 + version: 2.0.5(@types/node@18.7.18)(jsdom@20.0.3)(sass@1.72.0)(terser@5.31.5) packages: @@ -6708,8 +6719,8 @@ packages: '@fern-fern/generator-exec-sdk@0.0.898': resolution: {integrity: sha512-VQYn32CkAd437deesaGk4LKikbVptxrWINAwUwiAUWOy77LelX1zWNKihjU2XDgIPv3VXK07aJwoPR5BDYD46Q==} - '@fern-fern/generators-sdk@0.0.5596': - resolution: {integrity: sha512-fALUrEDTlwTiNVipcxNuqdMp9vheVbjNEP7owMg5neoZEByazHOyarQUY7+K1X/zo0PFXdm1bYTtX36BxUT+ww==} + '@fern-fern/generators-sdk@0.105.0-79c5d1764': + resolution: {integrity: sha512-39wwxMQpgmViQhvCBtrT3Cn0Erxd18YiWztS/ieRiE9agS6QIjkEEAGd1t9RFXg9+xsrsmv35EYa19LIZ9F4rg==} '@fern-fern/ir-sdk@0.0.2828': resolution: {integrity: sha512-qFZZHyw0cuHtoR9v7KsrPpz0PFH0V6/ORSMHdTKU/82KcaNCMjk0BbzicK8jjrMD0mYS4JxNUzEjcUOvgeuqaA==} @@ -13783,7 +13794,7 @@ snapshots: transitivePeerDependencies: - encoding - '@fern-fern/generators-sdk@0.0.5596': + '@fern-fern/generators-sdk@0.105.0-79c5d1764': dependencies: form-data: 4.0.0 formdata-node: 6.0.3 diff --git a/seed/csharp-model/seed.yml b/seed/csharp-model/seed.yml index faec345d86f..aa52d7d8b6d 100644 --- a/seed/csharp-model/seed.yml +++ b/seed/csharp-model/seed.yml @@ -1,6 +1,22 @@ irVersion: v53 -docker: fernapi/fern-csharp-model:latest -dockerCommand: pnpm --filter @fern-api/fern-csharp-model dockerTagLatest +publish: + preBuildCommands: + - ./.github/actions/install + - pnpm --filter @fern-api/fern-csharp-model dist:cli + docker: + file: ./generators/csharp/model/Dockerfile + image: fernapi/fern-csharp-model + context: . +test: + docker: + image: fernapi/fern-csharp-model:latest + command: pnpm --filter @fern-api/fern-csharp-model dockerTagLatest + local: + workingDirectory: generators/csharp + buildCommand: + - pnpm --filter @fern-api/fern-csharp-model dist:cli + runCommand: node model/dist/bundle.cjs + language: csharp generatorType: SDK defaultOutputMode: github @@ -16,10 +32,8 @@ scripts: - docker: bitnami/dotnet-sdk:8 commands: - dotnet build src -c Release /p:ContinuousIntegrationBuild=true -local: - workingDirectory: generators/csharp - buildCommand: - - pnpm --filter @fern-api/fern-csharp-model dist:cli - runCommand: node model/dist/bundle.cjs allowedFailures: - - objects-with-imports \ No newline at end of file + - objects-with-imports + # TODO: Add support for recursive undiscriminated unions. + - grpc + - grpc-proto diff --git a/seed/csharp-sdk/seed.yml b/seed/csharp-sdk/seed.yml index cc4524a9fd3..e62257a3c04 100644 --- a/seed/csharp-sdk/seed.yml +++ b/seed/csharp-sdk/seed.yml @@ -1,7 +1,22 @@ irVersion: v53 -docker: fernapi/fern-csharp-sdk:latest -dockerCommand: pnpm --filter @fern-api/fern-csharp-sdk dockerTagLatest +publish: + preBuildCommands: + - pnpm --filter @fern-api/fern-csharp-sdk dist:cli + docker: + file: ./generators/csharp/sdk/Dockerfile + image: fernapi/fern-csharp-sdk + context: . +test: + docker: + image: fernapi/fern-csharp-sdk:latest + command: pnpm --filter @fern-api/fern-csharp-sdk dockerTagLatest + local: + workingDirectory: generators/csharp + buildCommand: + - pnpm --filter @fern-api/fern-csharp-sdk dist:cli + runCommand: node sdk/dist/bundle.cjs + language: csharp generatorType: SDK defaultOutputMode: github @@ -9,11 +24,6 @@ scripts: - docker: bitnami/dotnet-sdk:8 commands: - dotnet build src -c Release /p:ContinuousIntegrationBuild=true -local: - workingDirectory: generators/csharp - buildCommand: - - pnpm --filter @fern-api/fern-csharp-sdk dist:cli - runCommand: node sdk/dist/bundle.cjs fixtures: imdb: - customConfig: null diff --git a/seed/fastapi/seed.yml b/seed/fastapi/seed.yml index a16d1a3494d..2b9e4a7ac92 100644 --- a/seed/fastapi/seed.yml +++ b/seed/fastapi/seed.yml @@ -1,6 +1,18 @@ irVersion: v53 -docker: fernapi/fern-fastapi-server:latest -dockerCommand: docker build -f ./generators/python/fastapi/Dockerfile -t fernapi/fern-fastapi-server:latest ./generators/python +changelogLocation: ../../generators/python/fastapi/versions.yml +publish: + workingDirectory: generators/python + preBuildCommands: + - chmod +x setup-python.sh && ./setup-python.sh + - poetry install + docker: + file: ./generators/python/fastapi/Dockerfile + image: fernapi/fern-fastapi-server + context: ./generators/python +test: + docker: + image: fernapi/fern-fastapi-server:latest + command: docker build -f ./generators/python/fastapi/Dockerfile -t fernapi/fern-fastapi-server:latest ./generators/python language: python generatorType: Server defaultOutputMode: local_files diff --git a/seed/fern-cli/seed.yml b/seed/fern-cli/seed.yml index ca5f4ed53ec..2a3c3f61c93 100644 --- a/seed/fern-cli/seed.yml +++ b/seed/fern-cli/seed.yml @@ -1 +1,25 @@ changelogLocation: ../../packages/cli/cli/versions.yml +publishGa: + versionSubstitution: $VERSION + command: + - cd packages/cli/cli + - mv package.json package.json.tmp + - version_replace="s/0.0.0/$VERSION/" + - cat package.json.tmp| sed "$VERSION" > package.json + - rm -rf package.json.tmp + - pnpm install + - pnpm --filter @fern-api/cli compile + # Should likely include this within the script itself + - pnpm --filter @fern-api/cli publish:cli:prod --tag latest +publishRc: + versionSubstitution: $VERSION + command: + - cd packages/cli/cli + - mv package.json package.json.tmp + - version_replace="s/0.0.0/$VERSION/" + - cat package.json.tmp| sed "$VERSION" > package.json + - rm -rf package.json.tmp + - pnpm install + - pnpm --filter @fern-api/cli compile + # Should likely include this within the script itself + - pnpm --filter @fern-api/cli publish:cli:prod --tag prerelease diff --git a/seed/go-fiber/seed.yml b/seed/go-fiber/seed.yml index 750a8425dca..c32037a8a40 100644 --- a/seed/go-fiber/seed.yml +++ b/seed/go-fiber/seed.yml @@ -1,6 +1,16 @@ irVersion: v40 -docker: fernapi/fern-go-fiber:latest -dockerCommand: docker build -f ./generators/go/docker/Dockerfile.fiber -t fernapi/fern-go-fiber:latest ./generators/go +publish: + workingDirectory: generators/go + preBuildCommands: + - go build ./... + docker: + file: ./generators/go/docker/Dockerfile.fiber + image: fernapi/fern-go-fiber + context: ./generators/go +test: + docker: + image: fernapi/fern-go-fiber:latest + command: docker build -f ./generators/go/docker/Dockerfile.fiber -t fernapi/fern-go-fiber:latest ./generators/go language: go generatorType: sdk defaultOutputMode: github diff --git a/seed/go-model/seed.yml b/seed/go-model/seed.yml index fb7ef9c9730..85f958fa732 100644 --- a/seed/go-model/seed.yml +++ b/seed/go-model/seed.yml @@ -1,6 +1,16 @@ irVersion: v40 -docker: fernapi/fern-go-model:latest -dockerCommand: docker build -f ./generators/go/docker/Dockerfile.model -t fernapi/fern-go-model:latest ./generators/go +publish: + workingDirectory: generators/go + preBuildCommands: + - go build ./... + docker: + file: ./generators/go/docker/Dockerfile.model + image: fernapi/fern-go-model + context: ./generators/go +test: + docker: + image: fernapi/fern-go-model:latest + command: docker build -f ./generators/go/docker/Dockerfile.model -t fernapi/fern-go-model:latest ./generators/go language: go generatorType: sdk defaultOutputMode: github diff --git a/seed/go-sdk/seed.yml b/seed/go-sdk/seed.yml index 3132e8d9f50..272a338abca 100644 --- a/seed/go-sdk/seed.yml +++ b/seed/go-sdk/seed.yml @@ -1,6 +1,16 @@ irVersion: v40 -docker: fernapi/fern-go-sdk:latest -dockerCommand: docker build -f ./generators/go/docker/Dockerfile.sdk -t fernapi/fern-go-sdk:latest ./generators/go +publish: + workingDirectory: generators/go + preBuildCommands: + - go build ./... + docker: + file: ./generators/go/docker/Dockerfile.sdk + image: fernapi/fern-go-sdk + context: ./generators/go +test: + docker: + image: fernapi/fern-go-sdk:latest + command: docker build -f ./generators/go/docker/Dockerfile.sdk -t fernapi/fern-go-sdk:latest ./generators/go language: go generatorType: sdk defaultOutputMode: github diff --git a/seed/java-model/seed.yml b/seed/java-model/seed.yml index 0d5de55c930..a11b5aaae2b 100644 --- a/seed/java-model/seed.yml +++ b/seed/java-model/seed.yml @@ -1,17 +1,27 @@ irVersion: v46 -docker: fernapi/fern-java-model:latest -dockerCommand: - - cd generators/java - - ./gradlew :model:distTar - - docker build -f model/Dockerfile -t fernapi/fern-java-model:latest model/ -local: +publish: workingDirectory: generators/java - buildCommand: + preBuildCommands: - ./gradlew :model:distTar - - chmod +x install-gradle.sh && ./install-gradle.sh - - cd model - - tar -xvf build/distributions/model.tar -C . - runCommand: cd model/model && java -cp model.jar:lib/* com.fern.java.model.Cli + docker: + file: ./generators/java/model/Dockerfile + image: fernapi/fern-java-model + context: ./generators/java/model +test: + docker: + image: fernapi/fern-java-model:latest + command: + - cd generators/java + - ./gradlew :model:distTar + - docker build -f model/Dockerfile -t fernapi/fern-java-model:latest model/ + local: + workingDirectory: generators/java + buildCommand: + - ./gradlew :model:distTar + - chmod +x install-gradle.sh && ./install-gradle.sh + - cd model + - tar -xvf build/distributions/model.tar -C . + runCommand: cd model/model && java -cp model.jar:lib/* com.fern.java.model.Cli env: {} language: java generatorType: Model diff --git a/seed/java-sdk/seed.yml b/seed/java-sdk/seed.yml index 2ba6c4283ce..b01fcf7534b 100644 --- a/seed/java-sdk/seed.yml +++ b/seed/java-sdk/seed.yml @@ -1,21 +1,32 @@ irVersion: v46 -docker: fernapi/fern-java-sdk:latest -dockerCommand: - - cd generators/java - - ./gradlew :sdk:distTar - - docker build -f sdk/Dockerfile -t fernapi/fern-java-sdk:latest sdk/ +publish: + workingDirectory: generators/java + preBuildCommands: + - ./gradlew :sdk:distTar + docker: + file: ./generators/java/sdk/Dockerfile + image: fernapi/fern-java-sdk + context: ./generators/java/sdk +test: + docker: + image: fernapi/fern-java-sdk:latest + command: + - cd generators/java + - ./gradlew :sdk:distTar + - docker build -f sdk/Dockerfile -t fernapi/fern-java-sdk:latest sdk/ + local: + workingDirectory: generators/java + buildCommand: + - ./gradlew :sdk:distTar + - chmod +x install-gradle.sh && ./install-gradle.sh + - cd sdk + - tar -xvf build/distributions/sdk.tar -C . + runCommand: cd sdk/sdk && java -cp sdk.jar:lib/* com.fern.java.client.Cli + env: {} + language: java generatorType: SDK defaultOutputMode: github -local: - workingDirectory: generators/java - buildCommand: - - ./gradlew :sdk:distTar - - chmod +x install-gradle.sh && ./install-gradle.sh - - cd sdk - - tar -xvf build/distributions/sdk.tar -C . - runCommand: cd sdk/sdk && java -cp sdk.jar:lib/* com.fern.java.client.Cli - env: {} fixtures: exhaustive: - customConfig: null diff --git a/seed/java-spring/seed.yml b/seed/java-spring/seed.yml index c8f91789a02..fbfd4bfa929 100644 --- a/seed/java-spring/seed.yml +++ b/seed/java-spring/seed.yml @@ -1,18 +1,29 @@ irVersion: v46 -docker: fernapi/fern-java-spring:latest -dockerCommand: - - cd generators/java - - ./gradlew :spring:distTar - - docker build -f spring/Dockerfile -t fernapi/fern-java-spring:latest spring/ -local: +publish: workingDirectory: generators/java - buildCommand: + preBuildCommands: + - cd generators/java - ./gradlew :spring:distTar - - chmod +x install-gradle.sh && ./install-gradle.sh - - cd spring - - tar -xvf build/distributions/spring.tar -C . - runCommand: cd spring/spring && java -cp spring.jar:lib/* com.fern.java.spring.Cli - env: {} + docker: + file: ./generators/java/spring/Dockerfile + image: fernapi/fern-java-spring + context: ./generators/java/spring +test: + docker: + image: fernapi/fern-java-spring:latest + command: + - cd generators/java + - ./gradlew :spring:distTar + - docker build -f spring/Dockerfile -t fernapi/fern-java-spring:latest spring/ + local: + workingDirectory: generators/java + buildCommand: + - ./gradlew :spring:distTar + - chmod +x install-gradle.sh && ./install-gradle.sh + - cd spring + - tar -xvf build/distributions/spring.tar -C . + runCommand: cd spring/spring && java -cp spring.jar:lib/* com.fern.java.spring.Cli + env: {} language: java generatorType: Server defaultOutputMode: local_files diff --git a/seed/openapi/seed.yml b/seed/openapi/seed.yml index cb16a64ab7b..e93ce66b535 100644 --- a/seed/openapi/seed.yml +++ b/seed/openapi/seed.yml @@ -1,6 +1,15 @@ irVersion: v23 -docker: fernapi/fern-openapi:latest -dockerCommand: pnpm --filter @fern-api/openapi-generator dockerTagLatest +publish: + preBuildCommands: + - pnpm --filter @fern-api/openapi-generator dist:cli + docker: + file: ./generators/openapi/Dockerfile + image: fernapi/fern-openapi + context: ./generators/openapi +test: + docker: + image: fernapi/fern-openapi:latest + command: pnpm --filter @fern-api/openapi-generator dockerTagLatest generatorType: Documentation defaultOutputMode: local_files fixtures: diff --git a/seed/postman/seed.yml b/seed/postman/seed.yml index 085c326e1fd..d63545c5fe9 100644 --- a/seed/postman/seed.yml +++ b/seed/postman/seed.yml @@ -1,5 +1,14 @@ irVersion: v23 -docker: fernapi/fern-postman:latest -dockerCommand: pnpm --filter @fern-api/postman-generator dockerTagLatest +publish: + preBuildCommands: + - pnpm --filter @fern-api/postman-generator dist:cli + docker: + file: ./generators/postman/Dockerfile + image: fernapi/fern-postman + context: ./generators/postman +test: + docker: + image: fernapi/fern-postman:latest + command: pnpm --filter @fern-api/postman-generator dockerTagLatest generatorType: Documentation defaultOutputMode: local_files diff --git a/seed/pydantic/seed.yml b/seed/pydantic/seed.yml index a11d30a2cf2..79178db81c1 100644 --- a/seed/pydantic/seed.yml +++ b/seed/pydantic/seed.yml @@ -1,6 +1,19 @@ irVersion: v53 -docker: fernapi/fern-pydantic-model:latest -dockerCommand: docker build -f ./generators/python/pydantic/Dockerfile -t fernapi/fern-pydantic-model:latest ./generators/python +changelogLocation: ../../generators/python/pydantic/versions.yml +publish: + workingDirectory: generators/python + preBuildCommands: + - chmod +x setup-python.sh && ./setup-python.sh + - poetry install + docker: + file: ./generators/python/pydantic/Dockerfile + image: fernapi/fern-pydantic-model + context: ./generators/python +test: + docker: + image: fernapi/fern-pydantic-model:latest + command: docker build -f ./generators/python/pydantic/Dockerfile -t fernapi/fern-pydantic-model:latest ./generators/python + language: python generatorType: model defaultOutputMode: github diff --git a/seed/python-sdk/seed.yml b/seed/python-sdk/seed.yml index 2f22fdd1b53..82f28a1ef51 100644 --- a/seed/python-sdk/seed.yml +++ b/seed/python-sdk/seed.yml @@ -1,20 +1,33 @@ irVersion: v53 changelogLocation: ../../generators/python/sdk/versions.yml -docker: fernapi/fern-python-sdk:latest -dockerCommand: docker build -f ./generators/python/sdk/Dockerfile -t fernapi/fern-python-sdk:latest ./generators/python -language: python -generatorType: sdk -defaultOutputMode: github -local: +publish: workingDirectory: generators/python - buildCommand: + preBuildCommands: - chmod +x setup-python.sh && ./setup-python.sh - poetry config virtualenvs.in-project true - poetry install - # The envvar is needed to trick the generator to look in the right place for the core_utils files - runCommand: poetry run python -m src.fern_python.generators.sdk.cli - env: - PYTEST_CURRENT_TEST: "some value" + docker: + file: ./generators/python/sdk/Dockerfile + image: fernapi/fern-python-sdk + context: ./generators/python +test: + docker: + image: fernapi/fern-python-sdk:latest + command: docker build -f ./generators/python/sdk/Dockerfile -t fernapi/fern-python-sdk:latest ./generators/python + local: + workingDirectory: generators/python + buildCommand: + - chmod +x setup-python.sh && ./setup-python.sh + - poetry config virtualenvs.in-project true + - poetry install + # The envvar is needed to trick the generator to look in the right place for the core_utils files + runCommand: poetry run python -m src.fern_python.generators.sdk.cli + env: + PYTEST_CURRENT_TEST: "some value" + +language: python +generatorType: sdk +defaultOutputMode: github customFixtureConfig: customConfig: use_typeddict_requests: true diff --git a/seed/ruby-model/seed.yml b/seed/ruby-model/seed.yml index a453866a659..84901ad44ee 100644 --- a/seed/ruby-model/seed.yml +++ b/seed/ruby-model/seed.yml @@ -1,6 +1,16 @@ irVersion: v39 -docker: fernapi/fern-ruby-model:latest -dockerCommand: pnpm --filter @fern-api/fern-ruby-model dockerTagLatest +changelogLocation: ../../generators/ruby/model/versions.yml +publish: + preBuildCommands: + - pnpm --filter @fern-api/fern-ruby-model dist:cli + docker: + file: ./generators/ruby/model/Dockerfile + image: fernapi/fern-ruby-model + context: . +test: + docker: + image: fernapi/fern-ruby-model:latest + command: pnpm --filter @fern-api/fern-ruby-model dockerTagLatest language: ruby generatorType: model defaultOutputMode: local_files diff --git a/seed/ruby-sdk/seed.yml b/seed/ruby-sdk/seed.yml index cfbb595b5ab..ce19f6184a6 100644 --- a/seed/ruby-sdk/seed.yml +++ b/seed/ruby-sdk/seed.yml @@ -1,6 +1,17 @@ irVersion: v39 -docker: fernapi/fern-ruby-sdk:latest -dockerCommand: pnpm --filter @fern-api/fern-ruby-sdk dockerTagLatest +changelogLocation: ../../generators/ruby/sdk/versions.yml +publish: + preBuildCommands: + - ./.github/actions/install + - pnpm --filter @fern-api/fern-ruby-sdk dist:cli + docker: + file: ./generators/ruby/sdk/Dockerfile + image: fernapi/fern-ruby-sdk + context: . +test: + docker: + image: fernapi/fern-ruby-sdk:latest + command: pnpm --filter @fern-api/fern-ruby-sdk dockerTagLatest language: ruby generatorType: sdk defaultOutputMode: github @@ -36,6 +47,7 @@ allowedFailures: # TODO: Add support for recursive undiscriminated unions. - grpc - any-auth + - trace features: requestOptions: true idempotency: false diff --git a/seed/ts-express/seed.yml b/seed/ts-express/seed.yml index b73c2890b83..a487ddf3334 100644 --- a/seed/ts-express/seed.yml +++ b/seed/ts-express/seed.yml @@ -1,19 +1,28 @@ irVersion: v53 -docker: fernapi/fern-typescript-express:local -dockerCommand: pnpm --filter @fern-typescript/express-generator-cli dockerTagLocal +publish: + versionSubstitution: "$VERSION" + # TODO: Add build here + command: + - pnpm --filter @fern-typescript/express-generator-cli dockerTagVersion "$VERSION" + - docker push fernapi/fern-typescript-express:"$VERSION" +test: + docker: + image: fernapi/fern-typescript-express:local + command: pnpm --filter @fern-typescript/express-generator-cli dockerTagLocal + local: + workingDirectory: generators/typescript + buildCommand: + - pnpm --filter @fern-typescript/express-generator-cli compile + - pnpm --filter @fern-typescript/express-generator-cli build + runCommand: node express/cli/dist/cli.cjs + env: + NODE_ENV: test + language: typescript generatorType: Server defaultOutputMode: local_files defaultCustomConfig: outputSourceFiles: true -local: - workingDirectory: generators/typescript - buildCommand: - - pnpm --filter @fern-typescript/express-generator-cli compile - - pnpm --filter @fern-typescript/express-generator-cli build - runCommand: node express/cli/dist/cli.cjs - env: - NODE_ENV: test fixtures: trace: - customConfig: null diff --git a/seed/ts-sdk/seed.yml b/seed/ts-sdk/seed.yml index 034a5523002..e6805bdb02d 100644 --- a/seed/ts-sdk/seed.yml +++ b/seed/ts-sdk/seed.yml @@ -1,17 +1,29 @@ irVersion: v53 -docker: fernapi/fern-typescript-node-sdk:local -dockerCommand: pnpm --filter @fern-typescript/sdk-generator-cli dockerTagLocal:node +publish: + workingDirectory: generators/typescript + versionSubstitution: "$VERSION" + # TODO: Add build here + command: + - pnpm --filter @fern-typescript/sdk-generator-cli dockerTagVersion:browser "$VERSION" + - docker push fernapi/fern-typescript-browser-sdk:"$VERSION" + - pnpm --filter @fern-typescript/sdk-generator-cli dockerTagVersion:node "$VERSION" + - docker push fernapi/fern-typescript-node-sdk:"$VERSION" +test: + docker: + image: fernapi/fern-typescript-node-sdk:local + command: pnpm --filter @fern-typescript/sdk-generator-cli dockerTagLocal:node + local: + workingDirectory: generators/typescript + buildCommand: + - pnpm --filter @fern-typescript/sdk-generator-cli compile + - pnpm --filter @fern-typescript/sdk-generator-cli build:node + runCommand: node sdk/cli/dist/nodeCli.cjs + env: + NODE_ENV: test + language: typescript generatorType: SDK defaultOutputMode: github -local: - workingDirectory: generators/typescript - buildCommand: - - pnpm --filter @fern-typescript/sdk-generator-cli compile - - pnpm --filter @fern-typescript/sdk-generator-cli build:node - runCommand: node sdk/cli/dist/nodeCli.cjs - env: - NODE_ENV: test fixtures: imdb: - customConfig: null