From c8d5d8517f6e0f85e4957740bc29ca1f24028c56 Mon Sep 17 00:00:00 2001 From: Emelia Smith Date: Fri, 14 Oct 2022 20:00:09 +0200 Subject: [PATCH 1/5] feat: include sourcemap & changelog in package contents (#694) --- package.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/package.json b/package.json index 6f45ab54..bd0b9b38 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "main": "dist/index.js", "types": "dist/src/index.d.ts", "files": [ + "CHANGELOG.md", "dist/index.js", + "dist/index.js.map", "dist/src/*", "dist/src/**/*" ], From 84056885de204caa6f7996934407caf5cd57f140 Mon Sep 17 00:00:00 2001 From: Zwifi Date: Tue, 18 Oct 2022 10:30:53 +0200 Subject: [PATCH 2/5] fix: use correct Code Of Conduct link in README.md (#689) Co-authored-by: Luke Glazebrook --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e06eaf0c..ba70a5a2 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Solid React SDK v2 - solid-ui-react -[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](code_of_conduct.md) +[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE-OF-CONDUCT.md) -This project adheres to the Contributor Covenant [code of conduct](code_of_conduct.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [engineering@inrupt.com](mailto:engineering@inrupt.com). +This project adheres to the Contributor Covenant [code of conduct](CODE-OF-CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [engineering@inrupt.com](mailto:engineering@inrupt.com). solid-ui-react is a library of React components made to make development with [Solid](https://solidproject.org/) simple. From 6980adf8f30db589648564e03684963c7216931c Mon Sep 17 00:00:00 2001 From: Emelia Smith Date: Wed, 19 Oct 2022 22:06:14 +0200 Subject: [PATCH 3/5] feat: add the ability to skip loading profiles from SessionProvider (#695) This is useful when using the React SDK to build a start/provisioning app, where the user will be able to login, but won't yet have a profile or WebID --- CHANGELOG.md | 4 ++ src/context/sessionContext/index.test.tsx | 38 +++++++++++++++++++ src/context/sessionContext/index.tsx | 36 ++++++++++++------ .../sessionProvider.stories.tsx | 8 +++- 4 files changed, 74 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0d22c51..cf0edb4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## Unreleased + +- Added the ability to prevent the automatic loading of WebID's and Profiles from SessionProvider, this is useful when building provisioning applications where the user has logged in, but doesn't yet have a WebID or Pod or Profile documents. + ## 2.8.1 ( October 10, 2022) - Upgrade Inrupt SDKs to latest versions diff --git a/src/context/sessionContext/index.test.tsx b/src/context/sessionContext/index.test.tsx index 93267af0..671fb446 100644 --- a/src/context/sessionContext/index.test.tsx +++ b/src/context/sessionContext/index.test.tsx @@ -31,6 +31,8 @@ import { onSessionRestore, } from "@inrupt/solid-client-authn-browser"; +import { getProfileAll } from "@inrupt/solid-client"; + import { SessionContext, SessionProvider } from "."; jest.mock("@inrupt/solid-client-authn-browser"); @@ -217,6 +219,42 @@ describe("SessionContext functionality", () => { expect(mockedClientModule.getProfileAll).toHaveBeenCalled(); }); + it("allows skipping fetching the user's profile if logging in succeeds", async () => { + (handleIncomingRedirect as jest.Mock).mockResolvedValueOnce({ + webId: "https://some.webid", + }); + + (getProfileAll as jest.Mock).mockResolvedValue({ + webIdProfile: null, + altProfileAll: [], + }); + + const session = { + info: { + isLoggedIn: true, + webId: "https://fakeurl.com/me", + }, + on: jest.fn(), + } as any; + + (getDefaultSession as jest.Mock).mockReturnValue(session); + + const screen = render( + + + + ); + await waitFor(async () => { + expect(screen.getByTestId("profile").textContent).toBe( + "No profile found" + ); + }); + + expect(screen.getByTestId("profile").textContent).toBe("No profile found"); + expect(getProfileAll).not.toHaveBeenCalled(); + expect(handleIncomingRedirect).toHaveBeenCalled(); + }); + it("uses the login and logout functions from session", async () => { (handleIncomingRedirect as jest.Mock).mockResolvedValueOnce(null); diff --git a/src/context/sessionContext/index.tsx b/src/context/sessionContext/index.tsx index 5e268a09..317ad312 100644 --- a/src/context/sessionContext/index.tsx +++ b/src/context/sessionContext/index.tsx @@ -75,6 +75,11 @@ export interface ISessionProvider { restorePreviousSession?: boolean; /** @since 2.3.0 */ onSessionRestore?: (url: string) => void; + /** + * @since unreleased + * @experimental + * */ + skipLoadingProfile?: boolean; } /** @@ -86,6 +91,7 @@ export const SessionProvider = ({ onError, sessionRequestInProgress: defaultSessionRequestInProgress, restorePreviousSession, + skipLoadingProfile, onSessionRestore, }: ISessionProvider): ReactElement => { const restoreSession = @@ -119,18 +125,19 @@ export const SessionProvider = ({ url: window.location.href, restorePreviousSession: restoreSession, }) - .then((sessionInfo) => + .then(async (sessionInfo) => { + if (skipLoadingProfile === true) { + return; + } + // If handleIncomingRedirect logged the session in, we know what the current // user's WebID is. - sessionInfo?.webId !== undefined - ? getProfileAll(sessionInfo?.webId, { - fetch: session.fetch, - }) - : undefined - ) - .then((foundProfile) => { - if (foundProfile !== undefined) { - setProfile(foundProfile); + if (sessionInfo?.webId !== undefined) { + const profiles = await getProfileAll(sessionInfo?.webId, { + fetch: session.fetch, + }); + + setProfile(profiles); } }) .catch((error: Error) => { @@ -149,7 +156,14 @@ export const SessionProvider = ({ // TODO force a refresh setSession(getDefaultSession()); }); - }, [session, sessionId, onError, currentLocation, restoreSession]); + }, [ + session, + sessionId, + onError, + currentLocation, + restoreSession, + skipLoadingProfile, + ]); const contextLogin = async (options: Parameters[0]) => { setSessionRequestInProgress(true); diff --git a/stories/authentication/sessionProvider.stories.tsx b/stories/authentication/sessionProvider.stories.tsx index 85478490..a7c5733b 100644 --- a/stories/authentication/sessionProvider.stories.tsx +++ b/stories/authentication/sessionProvider.stories.tsx @@ -20,6 +20,8 @@ */ import React, { ReactElement, useContext, useState } from "react"; +import { ComponentMeta } from "@storybook/react"; + import { SessionContext, SessionProvider, @@ -65,8 +67,12 @@ export default { description: `Function to be called on session restore. It is invoked with the URL of the refreshed page as its parameter`, control: { type: null }, }, + skipLoadingProfile: { + description: `**Experimental:** When set to true, prevents the SessionProvider from automatically loading the WebID / Profiles`, + defaultValue: false, + }, }, -}; +} as ComponentMeta; function Dashboard(): ReactElement { const { session, sessionRequestInProgress } = useContext(SessionContext); From 1141020f5d8f5f7978c7fb6603c2511724a8dc8b Mon Sep 17 00:00:00 2001 From: Emelia Smith Date: Wed, 19 Oct 2022 22:14:12 +0200 Subject: [PATCH 4/5] ci: remove continuous delivery workflows (#697) These were poorly implemented and resulted in us publishing thousands of versions of our packages --- .github/workflows/cd-teardown.yml | 30 ------- .github/workflows/cd.yml | 136 ------------------------------ .github/workflows/release.yml | 76 +---------------- 3 files changed, 1 insertion(+), 241 deletions(-) delete mode 100644 .github/workflows/cd-teardown.yml delete mode 100644 .github/workflows/cd.yml diff --git a/.github/workflows/cd-teardown.yml b/.github/workflows/cd-teardown.yml deleted file mode 100644 index 9c770ea2..00000000 --- a/.github/workflows/cd-teardown.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: CD - -on: delete - -env: - CI: true -jobs: - unpublish-npm: - runs-on: ubuntu-latest - if: github.event.ref_type == 'branch' - steps: - - name: Prepare for unpublication from npm - uses: actions/setup-node@v3 - with: - node-version: "16.x" - registry-url: "https://registry.npmjs.org" - - name: Determine npm tag - # Remove non-alphanumeric characters - # See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable - run: echo "TAG_SLUG=$(echo "${{ github.event.ref }}" | tr -cd '[:alnum:]-')" >> $GITHUB_ENV - - name: Remove npm tag for the deleted branch - run: | - export EXISTING_TAGS=$(npm dist-tag ls @inrupt/solid-client | grep --count $TAG_SLUG) - # Unfortunately GitHub Actions does not currently let us do something like - # if: secrets.INRUPT_NPM_TOKEN != '' - # so simply skip the command if the env var is not set: - if [ -n $NODE_AUTH_TOKEN ] && [ $EXISTING_TAGS -eq 1 ]; then npm dist-tag rm @inrupt/solid-client $TAG_SLUG; fi - env: - NODE_AUTH_TOKEN: ${{ secrets.INRUPT_NPM_TOKEN }} - - run: echo "Package tag [$TAG_SLUG] unpublished." diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index 7f6520f2..00000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,136 +0,0 @@ -name: CD - -on: - push: - branches: - - "**" - tags-ignore: - # Only create preview releases for branches - # (the `release` workflow creates actual releases for version tags): - - "**" - -env: - CI: true -jobs: - prepare-deployment: - runs-on: ubuntu-latest - outputs: - tag-slug: ${{ steps.determine-npm-tag.outputs.tag-slug }} - deployment-id: ${{ fromJson(steps.create-deployment.outputs.data || '{}').id || 'Skipped for Dependabot' }} - steps: - - name: Create GitHub Deployment - if: github.actor != 'dependabot[bot]' - id: create-deployment - uses: octokit/request-action@v2.x - with: - route: POST /repos/:repository/deployments - repository: ${{ github.repository }} - ref: ${{ github.sha }} - environment: review - transient_environment: true - auto_merge: false - mediaType: '{"previews": ["flash", "ant-man"]}' - # The deployment runs in parallel with CI, so status checks will never have succeeded yet: - required_contexts: "[]" - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - name: Determine npm tag - if: github.actor != 'dependabot[bot]' - id: determine-npm-tag - run: | - # Remove non-alphanumeric characters - # See https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable - echo "::set-output name=tag-slug::$(echo ${GITHUB_REF#refs/heads/} | tr -cd '[:alnum:]-')" - - publish-npm: - runs-on: ubuntu-latest - needs: [prepare-deployment] - outputs: - version-nr: ${{ steps.determine-npm-version.outputs.version-nr }} - steps: - - uses: actions/checkout@v3 - - name: Mark GitHub Deployment as in progress - if: github.actor != 'dependabot[bot]' - id: start-deployment - uses: octokit/request-action@v2.x - with: - route: POST /repos/:repository/deployments/:deployment/statuses - repository: ${{ github.repository }} - deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} - environment: review - description: "Publishing to npm tag [${{ needs.prepare-deployment.outputs.tag-slug }}]…" - log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - state: in_progress - mediaType: '{"previews": ["flash", "ant-man"]}' - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - uses: actions/setup-node@v3 - with: - node-version: "16.x" - registry-url: "https://registry.npmjs.org" - cache: npm - - name: Prepare prerelease version - if: github.actor != 'dependabot[bot]' - id: determine-npm-version - run: | - git config user.name $GITHUB_ACTOR - git config user.email gh-actions-${GITHUB_ACTOR}@github.com - # Unfortunately re-running a job does not change its run ID nor run number. - # To prevent re-releasing the same version when re-running the CD job, - # we incorporate a timestamp in the prerelease version: - TIMESTAMP=$(date --utc +%s) - # Make sure the prerelease is tagged with the branch name, and that they are sorted by build: - VERSION_NR=$(npm version prerelease --preid=$TAG_SLUG-$GITHUB_RUN_ID-$GITHUB_RUN_NUMBER-$TIMESTAMP) - echo "::set-output name=version-nr::$VERSION_NR" - env: - TAG_SLUG: ${{ needs.prepare-deployment.outputs.tag-slug }} - - run: npm ci - - name: Publish an npm tag for this branch - if: github.actor != 'dependabot[bot]' - run: | - # Unfortunately GitHub Actions does not currently let us do something like - # if: secrets.INRUPT_NPM_TOKEN != '' - # so simply skip the command if the env var is not set: - if [ -z $NODE_AUTH_TOKEN ]; then echo "No npm token defined; package not published."; fi - if [ -n $NODE_AUTH_TOKEN ]; then npm publish --access public --tag "$TAG_SLUG"; fi - if [ -n $NODE_AUTH_TOKEN ]; then echo "Package published. To install, run:"; fi - if [ -n $NODE_AUTH_TOKEN ]; then echo ""; fi - if [ -n $NODE_AUTH_TOKEN ]; then echo " npm install @inrupt/solid-ui-react@$TAG_SLUG"; fi - env: - NODE_AUTH_TOKEN: ${{ secrets.INRUPT_NPM_TOKEN }} - TAG_SLUG: ${{ needs.prepare-deployment.outputs.tag-slug }} - - name: Mark GitHub Deployment as successful - if: github.actor != 'dependabot[bot]' - uses: octokit/request-action@v2.x - with: - route: POST /repos/:repository/deployments/:deployment/statuses - repository: ${{ github.repository }} - deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} - environment: review - environment_url: "https://www.npmjs.com/package/@inrupt/solid-ui-react/v/${{ needs.prepare-deployment.outputs.tag-slug }}" - description: "Published to npm. To install, run: npm install @inrupt/solid-ui-react@${{ needs.prepare-deployment.outputs.tag-slug }}" - log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - mediaType: '{"previews": ["flash", "ant-man"]}' - state: success - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - name: Mark GitHub Deployment as failed - uses: octokit/request-action@v2.x - if: failure() && github.actor != 'dependabot[bot]' - with: - route: POST /repos/:repository/deployments/:deployment/statuses - repository: ${{ github.repository }} - deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} - environment: review - description: "Publication to npm failed. Review the GitHub Actions log for more information." - log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - mediaType: '{"previews": ["flash", "ant-man"]}' - state: failure - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - name: Waiting for npm CDNs to update... - if: github.actor != 'dependabot[bot]' - run: | - echo "Giving npm some time to make the newly-published package available…" - sleep 5m - echo "Done — hopefully that was enough time for the follow-up jobs to install the just-published package, to verify that everything looks OK." diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2ab4fc1c..ea77ca9f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,46 +8,10 @@ on: env: CI: true jobs: - prepare-deployment: - runs-on: ubuntu-latest - outputs: - deployment-id: ${{ fromJson(steps.create-deployment.outputs.data).id }} - steps: - - name: Create GitHub Deployment - id: create-deployment - uses: octokit/request-action@v2.x - with: - route: POST /repos/:repository/deployments - repository: ${{ github.repository }} - ref: ${{ github.sha }} - environment: review - transient_environment: true - auto_merge: false - mediaType: '{"previews": ["flash", "ant-man"]}' - # The deployment runs in parallel with CI, so status checks will never have succeeded yet: - required_contexts: "[]" - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - publish-npm: runs-on: ubuntu-latest - needs: [prepare-deployment] steps: - uses: actions/checkout@v3 - - name: Mark GitHub Deployment as in progress - id: start-deployment - uses: octokit/request-action@v2.x - with: - route: POST /repos/:repository/deployments/:deployment/statuses - repository: ${{ github.repository }} - deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} - environment: review - description: "Publishing to npm tag [${GITHUB_REF#refs/tags/v}]…" - log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - state: in_progress - mediaType: '{"previews": ["flash", "ant-man"]}' - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - name: Prepare for publication to npm uses: actions/setup-node@v3 with: @@ -55,44 +19,6 @@ jobs: registry-url: "https://registry.npmjs.org" cache: npm - run: npm ci - - name: Publish to npm - run: | - npm publish --access public - echo "Package published. To install, run:" - echo "" - echo " npm install @inrupt/solid-ui-react" + - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{ secrets.INRUPT_NPM_TOKEN }} - - name: Mark GitHub Deployment as successful - uses: octokit/request-action@v2.x - with: - route: POST /repos/:repository/deployments/:deployment/statuses - repository: ${{ github.repository }} - deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} - environment: review - environment_url: "https://www.npmjs.com/package/@inrupt/solid-ui-react/v/${GITHUB_REF#refs/tags/v}" - description: "Published to npm. To install, run: npm install @inrupt/solid-ui-react@${GITHUB_REF#refs/tags/v}" - log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - mediaType: '{"previews": ["flash", "ant-man"]}' - state: success - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - name: Mark GitHub Deployment as failed - uses: octokit/request-action@v2.x - if: failure() - with: - route: POST /repos/:repository/deployments/:deployment/statuses - repository: ${{ github.repository }} - deployment: ${{ needs.prepare-deployment.outputs.deployment-id }} - environment: review - description: "Publication to npm failed. Review the GitHub Actions log for more information." - log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - mediaType: '{"previews": ["flash", "ant-man"]}' - state: failure - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - - name: Waiting for npm CDNs to update... - run: | - echo "Giving npm some time to make the newly-published package available…" - sleep 5m - echo "Done waiting — hopefully that was enough time for the follow-up jobs to install the just-published package, to verify that everything looks OK." From 0069f974f779bda08dca2227be6abbf36fed908b Mon Sep 17 00:00:00 2001 From: Emelia Smith Date: Wed, 19 Oct 2022 22:44:12 +0200 Subject: [PATCH 5/5] release: prepare v2.8.2 (#698) --- CHANGELOG.md | 7 ++++--- package-lock.json | 4 ++-- package.json | 2 +- src/context/sessionContext/index.tsx | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf0edb4d..158f7c65 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,16 +2,17 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## Unreleased +## 2.8.2 ( October 19th, 2022 ) - Added the ability to prevent the automatic loading of WebID's and Profiles from SessionProvider, this is useful when building provisioning applications where the user has logged in, but doesn't yet have a WebID or Pod or Profile documents. +- Fixed issue with sourcemaps not being included in our package tarballs -## 2.8.1 ( October 10, 2022) +## 2.8.1 ( October 10, 2022 ) - Upgrade Inrupt SDKs to latest versions - Upgrade typescript to ^4.8.4, this should help with sporadic issues with mismatches in the `fetch` type definitions -## 2.8.0 ( June 6, 2022) +## 2.8.0 ( June 6, 2022 ) ### Breaking Changes diff --git a/package-lock.json b/package-lock.json index d47cd0b5..9d03afa4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@inrupt/solid-ui-react", - "version": "2.8.1", + "version": "2.8.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@inrupt/solid-ui-react", - "version": "2.8.1", + "version": "2.8.2", "license": "MIT", "dependencies": { "@inrupt/solid-client": "^1.23.3", diff --git a/package.json b/package.json index bd0b9b38..2c069628 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@inrupt/solid-ui-react", - "version": "2.8.1", + "version": "2.8.2", "description": "Set of UI libraries using @solid/core", "main": "dist/index.js", "types": "dist/src/index.d.ts", diff --git a/src/context/sessionContext/index.tsx b/src/context/sessionContext/index.tsx index 317ad312..be303375 100644 --- a/src/context/sessionContext/index.tsx +++ b/src/context/sessionContext/index.tsx @@ -76,7 +76,7 @@ export interface ISessionProvider { /** @since 2.3.0 */ onSessionRestore?: (url: string) => void; /** - * @since unreleased + * @since 2.8.2 * @experimental * */ skipLoadingProfile?: boolean;