diff --git a/.github/workflows/build-docker-image.yml b/.github/workflows/build-docker-image.yml index e05877125c..a780885588 100644 --- a/.github/workflows/build-docker-image.yml +++ b/.github/workflows/build-docker-image.yml @@ -30,6 +30,10 @@ jobs: with: fetch-depth: 0 + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -57,9 +61,10 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . - target: ${{ inputs.target }} + platforms: linux/arm64 push: true tags: ${{ inputs.tags }} + target: ${{ inputs.target }} # Temp fix # https://github.com/docker/build-push-action/issues/252 diff --git a/.github/workflows/charterafrica-deploy-dev.yml b/.github/workflows/charterafrica-deploy-dev.yml index d32133e7f5..7ddba33c54 100644 --- a/.github/workflows/charterafrica-deploy-dev.yml +++ b/.github/workflows/charterafrica-deploy-dev.yml @@ -2,7 +2,8 @@ name: charterAFRICA | Deploy | DEV on: push: - branches: [main] + branches: + - main paths: - "apps/charterafrica/**" - "Dockerfile" @@ -32,6 +33,10 @@ jobs: with: fetch-depth: 0 + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -63,6 +68,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 push: true secrets: | "sentry_auth_token=${{ secrets.SENTRY_AUTH_TOKEN }}" diff --git a/.github/workflows/charterafrica-deploy-prod.yml b/.github/workflows/charterafrica-deploy-prod.yml index e12a0130da..2b2e7b534f 100644 --- a/.github/workflows/charterafrica-deploy-prod.yml +++ b/.github/workflows/charterafrica-deploy-prod.yml @@ -2,7 +2,8 @@ name: charterAFRICA | Deploy | PROD on: push: - branches: [main] + branches: + - main # This allows a subsequently queued workflow run to interrupt previous runs concurrency: @@ -91,6 +92,8 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + # TODO(xavier): Follow up if we can switch this to arm64 + platforms: linux/amd64 push: true secrets: | "sentry_auth_token=${{ secrets.SENTRY_AUTH_TOKEN }}" diff --git a/.github/workflows/civicsignalblog-deploy-prod.yml b/.github/workflows/civicsignalblog-deploy-prod.yml index 9fef72a04e..4dacf33c1e 100644 --- a/.github/workflows/civicsignalblog-deploy-prod.yml +++ b/.github/workflows/civicsignalblog-deploy-prod.yml @@ -2,7 +2,8 @@ name: CivicSignal Blog | Deploy | PROD on: push: - branches: [main] + branches: + - main # This allows a subsequently queued workflow run to interrupt previous runs concurrency: @@ -31,6 +32,10 @@ jobs: with: fetch-depth: 0 + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + # Set up Node since it's required by version-check # https://github.com/EndBug/version-check#github-workflow - name: Setup Node.js @@ -84,6 +89,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 push: true secrets: | "sentry_auth_token=${{ secrets.SENTRY_AUTH_TOKEN }}" diff --git a/.github/workflows/climatemappedafrica-deploy-dev.yml b/.github/workflows/climatemappedafrica-deploy-dev.yml index 598474be29..9a27c3f219 100644 --- a/.github/workflows/climatemappedafrica-deploy-dev.yml +++ b/.github/workflows/climatemappedafrica-deploy-dev.yml @@ -2,7 +2,8 @@ name: Climate Mapped Africa | Deploy | DEV on: push: - branches: [main] + branches: + - main paths: - "apps/climatemappedafrica/**" - "Dockerfile" @@ -33,6 +34,10 @@ jobs: with: fetch-depth: 0 + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -60,6 +65,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 target: climatemappedafrica-runner push: true tags: "${{ env.IMAGE_NAME }}:${{ github.sha }}" diff --git a/.github/workflows/codeforafrica-deploy-dev.yml b/.github/workflows/codeforafrica-deploy-dev.yml index 85ad87fa8f..ba7006bb26 100644 --- a/.github/workflows/codeforafrica-deploy-dev.yml +++ b/.github/workflows/codeforafrica-deploy-dev.yml @@ -2,7 +2,8 @@ name: Code for Africa | Deploy | DEV on: push: - branches: [main] + branches: + - main paths: - "apps/codeforafrica/**" - "Dockerfile" @@ -34,6 +35,10 @@ jobs: with: fetch-depth: 0 + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -66,6 +71,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 push: true secrets: | "sentry_auth_token=${{ secrets.SENTRY_AUTH_TOKEN }}" diff --git a/.github/workflows/codeforafrica-deploy-prod.yml b/.github/workflows/codeforafrica-deploy-prod.yml index bf991eccf9..1051ba6769 100644 --- a/.github/workflows/codeforafrica-deploy-prod.yml +++ b/.github/workflows/codeforafrica-deploy-prod.yml @@ -2,7 +2,8 @@ name: Code for Africa | Deploy | PROD on: push: - branches: [main] + branches: + - main # This allows a subsequently queued workflow run to interrupt previous runs concurrency: @@ -32,6 +33,10 @@ jobs: with: fetch-depth: 0 + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + # Set up Node since it's required by version-check # https://github.com/EndBug/version-check#github-workflow - name: Setup Node.js @@ -87,6 +92,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 push: true secrets: | "sentry_auth_token=${{ secrets.SENTRY_AUTH_TOKEN }}" diff --git a/.github/workflows/codeforafrica-deploy-review-app.yml b/.github/workflows/codeforafrica-deploy-review-app.yml index e1353b0a12..8b1c5a09bd 100644 --- a/.github/workflows/codeforafrica-deploy-review-app.yml +++ b/.github/workflows/codeforafrica-deploy-review-app.yml @@ -66,6 +66,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 target: codeforafrica-runner push: true tags: "${{ env.IMAGE_NAME }}:${{ github.sha }}" diff --git a/.github/workflows/pesayetu-deploy-dev.yml b/.github/workflows/pesayetu-deploy-dev.yml index a955d1cb37..a694488d07 100644 --- a/.github/workflows/pesayetu-deploy-dev.yml +++ b/.github/workflows/pesayetu-deploy-dev.yml @@ -34,6 +34,10 @@ jobs: with: fetch-depth: 0 + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -68,6 +72,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 push: true tags: "${{ env.IMAGE_NAME }}:${{ github.sha }}" target: pesayetu-runner diff --git a/.github/workflows/roboshield-deploy-dev.yml b/.github/workflows/roboshield-deploy-dev.yml index 1357b59591..1390e80ab5 100644 --- a/.github/workflows/roboshield-deploy-dev.yml +++ b/.github/workflows/roboshield-deploy-dev.yml @@ -2,7 +2,9 @@ name: RoboShield | Deploy | DEV on: push: - branches: [main] + branches: + - main + paths: - "apps/roboshield/**" - "Dockerfile" @@ -34,6 +36,10 @@ jobs: with: fetch-depth: 0 + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -65,6 +71,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 push: true secrets: | "sentry_auth_token=${{ secrets.SENTRY_AUTH_TOKEN }}" diff --git a/.github/workflows/roboshield-deploy-prod.yml b/.github/workflows/roboshield-deploy-prod.yml index dd7624e977..277e049fa3 100644 --- a/.github/workflows/roboshield-deploy-prod.yml +++ b/.github/workflows/roboshield-deploy-prod.yml @@ -2,7 +2,8 @@ name: RoboShield | Deploy | PROD on: push: - branches: [main] + branches: + - main concurrency: group: "${{ github.workflow }} @ ${{ github.ref }}" @@ -30,6 +31,11 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Setup Node.js uses: actions/setup-node@v4 with: @@ -77,6 +83,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 push: true secrets: | "sentry_auth_token=${{ secrets.SENTRY_AUTH_TOKEN }}" diff --git a/.github/workflows/trustlab-deploy-dev.yml b/.github/workflows/trustlab-deploy-dev.yml index 7e7bf45dd7..d9a6aca86c 100644 --- a/.github/workflows/trustlab-deploy-dev.yml +++ b/.github/workflows/trustlab-deploy-dev.yml @@ -34,6 +34,10 @@ jobs: with: fetch-depth: 0 + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -65,6 +69,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 push: true secrets: | "mongo_url=${{ secrets.TRUSTLAB_MONGO_URL }}" diff --git a/.github/workflows/twoopstracker-deploy-dev.yml b/.github/workflows/twoopstracker-deploy-dev.yml index 5a8fb139de..6ddc655f49 100644 --- a/.github/workflows/twoopstracker-deploy-dev.yml +++ b/.github/workflows/twoopstracker-deploy-dev.yml @@ -37,6 +37,10 @@ jobs: with: fetch-depth: 0 + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -62,6 +66,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 push: true secrets: | "sentry_auth_token=${{ secrets.SENTRY_AUTH_TOKEN }}" diff --git a/.github/workflows/vpnmanager-deploy-dev.yml b/.github/workflows/vpnmanager-deploy-dev.yml index e3b26124a1..f43ad833cd 100644 --- a/.github/workflows/vpnmanager-deploy-dev.yml +++ b/.github/workflows/vpnmanager-deploy-dev.yml @@ -2,7 +2,9 @@ name: VPN Manager | Deploy | DEV on: push: - branches: [main] + branches: + - main + paths: - "apps/vpnmanager/**" - "Dockerfile.vpnmanager" @@ -31,6 +33,10 @@ jobs: with: fetch-depth: 0 + # Add support for more platforms with QEMU (optional) + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -60,6 +66,7 @@ jobs: cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache-new context: . + platforms: linux/arm64 push: true secrets: | "sentry_auth_token=${{ secrets.SENTRY_AUTH_TOKEN }}" diff --git a/Dockerfile b/Dockerfile index d8ab3809c6..24155fd043 100644 --- a/Dockerfile +++ b/Dockerfile @@ -782,11 +782,11 @@ COPY apps/roboshield ./apps/roboshield/ # When building Next.js app, Next.js needs to connect to local Payload ENV PAYLOAD_PUBLIC_APP_URL=http://localhost:3000 RUN --mount=type=secret,id=sentry_auth_token,env=SENTRY_AUTH_TOKEN \ - pnpm --filter "./apps/roboshield/" build-next + pnpm --filter "./apps/roboshield/" build # When building Payload app, Payload needs to have final app URL ENV PAYLOAD_PUBLIC_APP_URL=${NEXT_PUBLIC_APP_URL} -RUN pnpm --filter "./apps/roboshield/" build-payload +# RUN pnpm --filter "./apps/roboshield/" build-payload # # roboshield-runner: final deployable image @@ -809,28 +809,18 @@ RUN set -ex \ COPY --from=roboshield-builder --chown=nextjs:nodejs /workspace/node_modules ./node_modules COPY --from=roboshield-builder --chown=nextjs:nodejs /workspace/apps/roboshield/next.config.js ./apps/roboshield/next.config.js COPY --from=roboshield-builder --chown=nextjs:nodejs /workspace/apps/roboshield/.env ./apps/roboshield/.env -# Since we can't use output: "standalone", copy all app's dependencies -COPY --from=roboshield-builder --chown=nextjs:nodejs /workspace/apps/roboshield/node_modules ./apps/roboshield/node_modules # Next.js # Public assets COPY --from=roboshield-builder --chown=nextjs:nodejs /workspace/apps/roboshield/public ./apps/roboshield/public - -# Since we can't use output: "standalone", copy the whole app's .next folder -# TODO(kilemensi): Figure out which files in .next folder are not needed -COPY --from=roboshield-builder --chown=nextjs:nodejs /workspace/apps/roboshield/.next ./apps/roboshield/.next - -# Payload -COPY --from=roboshield-builder /workspace/apps/roboshield/dist ./apps/roboshield/dist -COPY --from=roboshield-builder /workspace/apps/roboshield/build ./apps/roboshield/build - -# Since we can't use output: "standalone", switch to specific app's folder -WORKDIR /workspace/apps/roboshield +# Copy standalone output +COPY --from=roboshield-builder --chown=nextjs:nodejs /workspace/apps/roboshield/.next/standalone ./apps/roboshield +COPY --from=roboshield-builder --chown=nextjs:nodejs /workspace/apps/roboshield/.next/static ./apps/roboshield/.next/static USER nextjs # Custom server to run Payload and Next.js in the same app -CMD ["node", "dist/server.js"] +CMD ["node", "apps/roboshield/server.js"] # ============================================================================ @@ -985,7 +975,7 @@ CMD ["node", "apps/trustlab/server.js"] # ============================================================================ -# twoopstracker +# TwoopsTracker # ============================================================================ # @@ -1000,6 +990,7 @@ RUN pnpm --filter "./apps/twoopstracker" install --offline --frozen-lockfile # # twoopstracker-builder: image that uses deps to build shippable output # ------------------------------------------------------------------ + FROM base-builder AS twoopstracker-builder ARG NEXT_TELEMETRY_DISABLED \ # Next.js / Payload (build time) @@ -1020,9 +1011,11 @@ COPY --from=twoopstracker-deps /workspace/apps/twoopstracker/node_modules ./apps COPY apps/twoopstracker ./apps/twoopstracker RUN --mount=type=secret,id=sentry_auth_token,env=SENTRY_AUTH_TOKEN \ pnpm --filter "./apps/twoopstracker" build + # # twoopstracker-runner: final deployable image # ----------------------------------------- + FROM base-runner AS twoopstracker-runner ARG TWOOPSTRACKER_API_URL diff --git a/apps/charterafrica/contrib/dokku/Dockerfile b/apps/charterafrica/contrib/dokku/Dockerfile index fceb8357aa..95e97d318f 100644 --- a/apps/charterafrica/contrib/dokku/Dockerfile +++ b/apps/charterafrica/contrib/dokku/Dockerfile @@ -1 +1 @@ -FROM codeforafrica/charterafrica-ui:0.1.33 +FROM codeforafrica/charterafrica-ui:0.1.38 diff --git a/apps/charterafrica/package.json b/apps/charterafrica/package.json index bc7f2e9135..7e47f13317 100644 --- a/apps/charterafrica/package.json +++ b/apps/charterafrica/package.json @@ -1,6 +1,6 @@ { "name": "charterafrica", - "version": "0.1.33", + "version": "0.1.38", "private": true, "author": "Code for Africa ", "description": "This is the official code for https://charter.africa site", diff --git a/apps/climatemappedafrica/contrib/dokku/Dockerfile b/apps/climatemappedafrica/contrib/dokku/Dockerfile index 3c1919c5c2..947995d6c9 100644 --- a/apps/climatemappedafrica/contrib/dokku/Dockerfile +++ b/apps/climatemappedafrica/contrib/dokku/Dockerfile @@ -1 +1 @@ -FROM codeforafrica/climatemapped-africa-ui:0.0.1 +FROM codeforafrica/climatemapped-africa-ui:0.0.5 diff --git a/apps/climatemappedafrica/package.json b/apps/climatemappedafrica/package.json index f82c9ce564..ab22f84807 100644 --- a/apps/climatemappedafrica/package.json +++ b/apps/climatemappedafrica/package.json @@ -1,6 +1,6 @@ { "name": "climatemappedafrica", - "version": "0.0.3", + "version": "0.0.5", "private": true, "author": "Code for Africa ", "description": "ClimateMapped Africa", diff --git a/apps/climatemappedafrica/src/payload/fields/HURUmapURL.js b/apps/climatemappedafrica/src/payload/fields/HURUmapURL.js index 666b9a20ae..99f40d6891 100644 --- a/apps/climatemappedafrica/src/payload/fields/HURUmapURL.js +++ b/apps/climatemappedafrica/src/payload/fields/HURUmapURL.js @@ -22,7 +22,9 @@ function HURUmapURL(props) { const { urlValid } = reduceFieldsToValues(formFields, true); const validateURL = async () => { - if (!value) return; + if (!value) { + return; + } setLoading(true); try { // For now we can use the profiles endpoint to check if the URL is valid diff --git a/apps/codeforafrica/package.json b/apps/codeforafrica/package.json index ccfb8422d2..83e71dac86 100644 --- a/apps/codeforafrica/package.json +++ b/apps/codeforafrica/package.json @@ -1,6 +1,6 @@ { "name": "codeforafrica", - "version": "1.0.56", + "version": "1.0.61", "private": true, "author": "Code for Africa ", "description": "This is the main CFA site.", diff --git a/apps/pesayetu/src/lib/wordpress/connector.js b/apps/pesayetu/src/lib/wordpress/connector.js index 6d40722871..8d7db3e1a8 100644 --- a/apps/pesayetu/src/lib/wordpress/connector.js +++ b/apps/pesayetu/src/lib/wordpress/connector.js @@ -53,10 +53,14 @@ export function initializeWpApollo(initialState = null) { const newApolloClient = initializeApollo(singletonApolloClient, initialState); // For SSG and SSR always create a new Apollo Client. - if (typeof window === "undefined") return newApolloClient; + if (typeof window === "undefined") { + return newApolloClient; + } // Create the Apollo Client once in the client. - if (!wpApolloClient) wpApolloClient = newApolloClient; + if (!wpApolloClient) { + wpApolloClient = newApolloClient; + } return newApolloClient; } diff --git a/apps/promisetracker/src/components/FormDialog/Form.js b/apps/promisetracker/src/components/FormDialog/Form.js index 9a8072d01f..cba96f3334 100644 --- a/apps/promisetracker/src/components/FormDialog/Form.js +++ b/apps/promisetracker/src/components/FormDialog/Form.js @@ -63,7 +63,9 @@ function Form({ const onFileChange = (e) => { const file = URL.createObjectURL(e.target.files[0]); const fileSize = e.target.files[0].size; - if (handleFileValidation(fileSize)) return; + if (handleFileValidation(fileSize)) { + return; + } const reader = new FileReader(); reader.onload = function loadFiles(readerEvt) { @@ -93,7 +95,9 @@ function Form({ const { files } = dt; [...files].forEach((file) => { - if (handleFileValidation(file.size)) return; + if (handleFileValidation(file.size)) { + return; + } // Get URL of image file to be used for thumbnail preview const reader = new FileReader(); diff --git a/apps/promisetracker/src/components/FormDialog/UpdateForm.js b/apps/promisetracker/src/components/FormDialog/UpdateForm.js index 2c8833242a..500ac370ba 100644 --- a/apps/promisetracker/src/components/FormDialog/UpdateForm.js +++ b/apps/promisetracker/src/components/FormDialog/UpdateForm.js @@ -58,7 +58,9 @@ function Form({ promise_act_now: promiseActNow = { update: {} }, ...props }) { const file = URL.createObjectURL(e.target.files[0]); const fileSize = e.target.files[0].size; - if (handleFileValidation(fileSize)) return; + if (handleFileValidation(fileSize)) { + return; + } setImages([file]); }; @@ -78,7 +80,9 @@ function Form({ promise_act_now: promiseActNow = { update: {} }, ...props }) { const { files } = dt; [...files].forEach((file) => { - if (handleFileValidation(file.size)) return; + if (handleFileValidation(file.size)) { + return; + } // Get URL of image file to be used for thumbnail preview const reader = new FileReader(); diff --git a/apps/promisetracker/src/pages/act-now.page.js b/apps/promisetracker/src/pages/act-now.page.js index 1870bb1332..d5578f8613 100644 --- a/apps/promisetracker/src/pages/act-now.page.js +++ b/apps/promisetracker/src/pages/act-now.page.js @@ -37,7 +37,9 @@ function ActNow({ ...props }) { }, [session]); // When rendering client side don't display anything until loading is complete - if (typeof window !== "undefined" && status === "loading") return null; + if (typeof window !== "undefined" && status === "loading") { + return null; + } // If no session exists, show default landing page if (!session) { diff --git a/apps/promisetracker/src/pages/login.page.js b/apps/promisetracker/src/pages/login.page.js index ade1c245a9..4f3ce0f46a 100644 --- a/apps/promisetracker/src/pages/login.page.js +++ b/apps/promisetracker/src/pages/login.page.js @@ -41,7 +41,9 @@ function Login({ providers: providersProp, ...props }) { }, [session]); // When rendering client side don't display anything until loading is complete - if (typeof window !== "undefined" && status === "loading") return null; + if (typeof window !== "undefined" && status === "loading") { + return null; + } return ( { - if (mapType !== "choropleth") return null; + if (mapType !== "choropleth") { + return null; + } const filteredLocations = locations.filter(({ count }) => count !== null); const counts = filteredLocations.map(({ count }) => count); @@ -112,7 +114,9 @@ export const generateChoropleth = (choroplethProps, locations, mapType) => { ); const getColor = (count) => { - if (count === 0) return zeroColor; + if (count === 0) { + return zeroColor; + } const colorRange = count > 0 ? positiveColorRange : negativeColorRange; const thresholds = count > 0 ? positiveThresholds : negativeThresholds; const index = thresholds.findIndex(