diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c639c86a2..723cd2fda 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,19 +11,19 @@ jobs: if: github.repository_owner == 'visgl' + permissions: + contents: write + env: - ADMIN_TOKEN: ${{ secrets.ADMIN_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v2.1.1 - - - name: Get git tags (https://github.com/actions/checkout/issues/206) - run: git fetch --tags -f + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 with: - node-version: '16.x' + node-version: '18.x' - name: Publish release run: | @@ -33,4 +33,4 @@ jobs: -H "Accept: application/vnd.github.v3+json" \ https://api.github.com/repos/visgl/react-map-gl/releases \ -d "${body}" \ - -H "Authorization: token ${ADMIN_TOKEN}" + -H "Authorization: token ${GITHUB_TOKEN}" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 548694819..4961d28c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,26 +11,25 @@ jobs: test-node: runs-on: ubuntu-latest - env: - VITE_MAPBOX_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN_CI }} - steps: - - uses: actions/checkout@v2.1.1 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 with: - node-version: '16.x' + node-version: '18.x' - name: Install dependencies run: | yarn bootstrap - name: Run tests + env: + VITE_MAPBOX_TOKEN: ${{ secrets.MAPBOX_ACCESS_TOKEN_CI }} run: | yarn test ci - name: Coveralls - uses: coverallsapp/github-action@master + uses: coverallsapp/github-action@09b709cf6a16e30b0808ba050c7a6e8a5ef13f8d # v1.2.5 with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index dd792c6f7..b88a0211d 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -6,42 +6,51 @@ on: - '*-release' jobs: - publish-website: + check_branch: runs-on: ubuntu-latest + outputs: + should_deploy: ${{ endsWith(github.ref, steps.get_version.outputs.latest) }} - if: github.repository_owner == 'visgl' + steps: + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - name: Get version + id: get_version + run: | + LATEST=$(npm show react-map-gl version | grep -o -E "^[0-9]+\.[0-9]+") + echo "latest=${LATEST}-release" >> "$GITHUB_OUTPUT" + + deploy: + runs-on: ubuntu-latest + needs: check_branch + + permissions: + contents: write - env: - MapboxAccessToken: ${{ secrets.MAPBOX_ACCESS_TOKEN }} + if: ${{ github.repository_owner == 'visgl' && needs.check_branch.outputs.should_deploy }} steps: - - uses: actions/checkout@v2.1.1 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + token: ${{ secrets.WEBSITE_DEPLOY_TOKEN }} - name: Use Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4.0.0 with: - node-version: '16.x' - - - name: Get version - id: get-version - run: LATEST=$(npm show react-map-gl version | grep -o -E "^[0-9]+\.[0-9]+") && echo "::set-output name=latest::/${LATEST}-release" + node-version: '18.x' - - name: Check version - if: ${{ !endsWith(github.ref, steps.get-version.outputs.latest) }} + - name: Install dependencies run: | - echo "Website is only published from the latest release branch" + yarn bootstrap + (cd website && yarn) - name: Build website - if: ${{ endsWith(github.ref, steps.get-version.outputs.latest) }} - run: | - yarn bootstrap - cd website - yarn - yarn build + env: + MapboxAccessToken: ${{ secrets.MAPBOX_ACCESS_TOKEN }} + run: (cd website && yarn build) - name: Deploy - if: ${{ endsWith(github.ref, steps.get-version.outputs.latest) }} - uses: JamesIves/github-pages-deploy-action@3.7.1 + uses: JamesIves/github-pages-deploy-action@132898c54c57c7cc6b80eb3a89968de8fc283505 # 3.7.1 with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} BRANCH: gh-pages diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..446285711 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,3 @@ +# Code of Conduct + +react-map-gl is an [OpenJS Foundation](https://openjsf.org/) project. Please be mindful of and adhere to the OpenJS Foundation's [Code of Conduct](https://github.com/openjs-foundation/cross-project-council/blob/main/CODE_OF_CONDUCT.md) when contributing to react-map-gl. \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d020695b8..9197da871 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,7 +68,7 @@ react-map-gl follows the [Semantic Versioning](https://semver.org/) guidelines. ## Community Governance -vis.gl is part of the [Urban Computing Foundation](https://uc.foundation/). See the organization's [Technical Charter](https://github.com/visgl/tsc/blob/master/Technical%20Charter.md). +vis.gl is part of the [OpenJS Foundation](https://openjsf.org/). See the organization's [Technical Charter](https://github.com/visgl/tsc/blob/master/Technical%20Charter.md). ### Technical Steering Committee @@ -84,8 +84,4 @@ Maintainers of react-map-gl have commit access to this GitHub repository, and ta If you are interested in becoming a maintainer, read the [governance guidelines](https://github.com/visgl/tsc/blob/master/governance.md). The vis.gl TSC meets monthly and publishes meeting notes via a [mailing list](https://lists.uc.foundation/g/visgl). -This mailing list can also be utilized to reach out to the TSC. - -## Code of Conduct - -Please be mindful of and adhere to the Linux Foundation's [Code of Conduct](https://lfprojects.org/policies/code-of-conduct/) when contributing to react-map-gl. +This mailing list can also be utilized to reach out to the TSC. \ No newline at end of file diff --git a/docs/api-reference/map.md b/docs/api-reference/map.md index 7f1b5c20a..8d5961fca 100644 --- a/docs/api-reference/map.md +++ b/docs/api-reference/map.md @@ -1,6 +1,6 @@ # default (Map) -React component that wraps the base library's `Map` class ([Mapbox](https://docs.mapbox.com/mapbox-gl-js/api/map/) | [Maplibre](https://maplibre.org/maplibre-gl-js-docs/api/map/)). This is also the default export from react-map-gl. +React component that wraps the base library's `Map` class ([Mapbox](https://docs.mapbox.com/mapbox-gl-js/api/map/) | [Maplibre](https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/)). This is also the default export from react-map-gl. import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/scripts/github-release.js b/scripts/github-release.js index 2a450ce4f..29f1444b5 100644 --- a/scripts/github-release.js +++ b/scripts/github-release.js @@ -28,7 +28,7 @@ console.log(JSON.stringify(requestBody)); function getGitTag() { try { - return execSync('git describe --exact-match HEAD', { + return execSync('git describe --tags --exact-match HEAD', { stdio: [null, 'pipe', null], encoding: 'utf-8' }).trim(); diff --git a/src/utils/transform.ts b/src/utils/transform.ts index 5f5cefe37..63e724aa7 100644 --- a/src/utils/transform.ts +++ b/src/utils/transform.ts @@ -57,12 +57,6 @@ export function applyViewStateToTransform(tr: Transform, props: MapboxProps): bo const v: Partial = props.viewState || props; let changed = false; - if ('longitude' in v && 'latitude' in v) { - const center = tr.center; - // @ts-ignore - tr.center = new center.constructor(v.longitude, v.latitude); - changed = changed || center !== tr.center; - } if ('zoom' in v) { const zoom = tr.zoom; tr.zoom = v.zoom; @@ -82,5 +76,11 @@ export function applyViewStateToTransform(tr: Transform, props: MapboxProps): bo changed = true; tr.padding = v.padding; } + if ('longitude' in v && 'latitude' in v) { + const center = tr.center; + // @ts-ignore + tr.center = new center.constructor(v.longitude, v.latitude); + changed = changed || center !== tr.center; + } return changed; } diff --git a/test/src/utils/transform.spec.js b/test/src/utils/transform.spec.js index 28876a77d..ddd04cf75 100644 --- a/test/src/utils/transform.spec.js +++ b/test/src/utils/transform.spec.js @@ -90,5 +90,11 @@ test('applyViewStateToTransform', t => { changed = applyViewStateToTransform(tr, {viewState: {pitch: 30}}); t.notOk(changed, 'nothing changed'); + applyViewStateToTransform(tr, {longitude: 0, latitude: 0, zoom: 0}); + changed = applyViewStateToTransform(tr, {longitude: 12, latitude: 34, zoom: 15}); + t.ok(changed, 'center and zoom changed'); + t.equal(tr.zoom, 15, 'zoom is correct'); + t.equal(tr.center.lat, 34, 'center latitude is correct'); + t.end(); });