From 2bf061081e20033f9462b8a10988a030e222362a Mon Sep 17 00:00:00 2001 From: Johan Petersson Date: Tue, 16 Nov 2021 14:46:06 +0100 Subject: [PATCH] Release 1.0.0 (#23) * Updates modules to 1.0.0 * Update README.md * Add a launch URL to sample backend * Updates to released dependencies * Updates documentation --- CODE_OF_CONDUCT.md | 2 +- CONTRIBUTING.md | 2 +- README.md | 33 ++++++++++--------- .../music-festival-vue-decoupled/README.md | 13 +++++--- .../backend/MusicFestival.Backend.csproj | 10 +++--- .../backend/Startup.cs | 21 +++++------- .../backend/properties/launchSettings.json | 1 + .../frontend/package-lock.json | 4 +-- .../src/components/EpiContentArea.vue | 2 +- .../frontend/src/components/EpiLink.vue | 2 +- .../src/components/EpiViewModeLink.vue | 2 +- .../frontend/src/main.js | 2 +- .../frontend/src/store/index.js | 2 +- .../src/views/pages/ArtistContainerPage.vue | 4 +-- .../frontend/src/views/pages/LandingPage.vue | 2 +- .../music-festival-vue-decoupled/nuget.config | 1 - src/@episerver/content-definitions/README.md | 4 +-- .../content-definitions/package-lock.json | 4 +-- .../content-definitions/package.json | 4 +-- src/@episerver/content-delivery/README.md | 4 +-- .../content-delivery/package-lock.json | 4 +-- src/@episerver/content-delivery/package.json | 4 +-- .../test/contentLoader.tests.mjs | 14 ++++---- .../test/contentResolver.tests.mjs | 6 ++-- .../test/siteLoader.tests.mjs | 2 +- .../test-setup/backend/Backend.csproj | 10 +++--- src/@episerver/test-setup/backend/Startup.cs | 10 +++--- .../test-setup/backend/nuget.config | 1 - src/@episerver/test-setup/src/index.mjs | 2 +- 29 files changed, 89 insertions(+), 83 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 3476ec9..bd3f602 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -55,7 +55,7 @@ further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at support@episerver.com. All +reported by contacting the project team at support@optimizely.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c1546b6..ed75e7b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ ## Did you find a bug? -* Do not open up a GitHub issue if the bug is a security vulnerability, instead contact support@episerver.com. +* Do not open up a GitHub issue if the bug is a security vulnerability, instead contact support@optimizely.com. * Ensure the bug was not already reported by searching on GitHub under [Issues](https://github.com/episerver/content-delivery-js-sdk/issues). diff --git a/README.md b/README.md index 08f0e40..70dd1d6 100644 --- a/README.md +++ b/README.md @@ -3,19 +3,21 @@ [![Npm publish](https://github.com/episerver/content-delivery-js-sdk/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/episerver/content-delivery-js-sdk/actions/workflows/npm-publish.yml) [![Continuous integration](https://github.com/episerver/content-delivery-js-sdk/actions/workflows/ci.yml/badge.svg)](https://github.com/episerver/content-delivery-js-sdk/actions/workflows/ci.yml) -This repository contains the source code for the Content Delivery SDKs and samples. - -> Note the SDK is in preview. Please provide feedback and report issues. - -Visit [Optimizely World](https://world.optimizely.com/documentation/developer-guides/content-delivery-api/) for full documentation of the REST APIs. +This repository contains the source code for the Content Delivery JavaScript SDKs and samples. ## Content Definitions -[Source code and documentation](https://github.com/episerver/content-delivery-js-sdk/tree/master/src/%40episerver/content-definitions). +* [Source code and documentation](https://github.com/episerver/content-delivery-js-sdk/tree/master/src/%40episerver/content-definitions) +* [REST API documentation](https://world.optimizely.com/documentation/developer-guides/content-definitions-api/) ## Content Delivery -[Source code and documentation](https://github.com/episerver/content-delivery-js-sdk/tree/master/src/%40episerver/content-delivery). +* [Source code and documentation](https://github.com/episerver/content-delivery-js-sdk/tree/master/src/%40episerver/content-delivery) +* [REST API documentation](https://world.optimizely.com/documentation/developer-guides/content-delivery-api/) + +## Samples + +* [Vue.js](https://github.com/episerver/content-delivery-js-sdk/tree/master/samples/music-festival-vue-decoupled) ## Prerequisites for building and testing the SDKs @@ -25,15 +27,16 @@ This project uses: * .NET SDK 5+ * SQL Server 2016 Express LocalDB ([download here](https://www.microsoft.com/en-us/sql-server/sql-server-downloads)) -## Creating a release +## Create a release - 1. Update version in all SDK package.json files. - 2. Merge to master branch. - 3. Create new Github release based of master branch. - 4. Tag version with following format: v1.2.0. - 5. Give the release a title and write an optional description. - 6. Publish. + 1. Update the version in all modules with `npm version 1.2.3`. + 2. Run `npm install` in all samples to update their package-lock.json files. + 3. Commit, push, and create PR to `master` branch. + 4. Create new Github release based of `master` branch. + 5. Tag version with following format `v1.2.3`. + 6. Give the release a title and write an optional description. + 7. Publish. ## Contributing -The easiest way to contribute is to join in with the discussions on Github issues or create new issues with questions, suggestions or any other feedback. If you want to contribute code or documentation, you are more than welcome to create pull-requests, but make sure that you read the contribution page first. \ No newline at end of file +The easiest way to contribute is to join in with the discussions on Github issues or create new issues with questions, suggestions or any other feedback. If you want to contribute code or documentation, you are more than welcome to create pull-requests, but make sure that you read the contribution page first. diff --git a/samples/music-festival-vue-decoupled/README.md b/samples/music-festival-vue-decoupled/README.md index 1c4f63f..004a44b 100644 --- a/samples/music-festival-vue-decoupled/README.md +++ b/samples/music-festival-vue-decoupled/README.md @@ -1,10 +1,10 @@ -# Episerver Content Delivery - Decoupled +# Optimizely Content Delivery - Decoupled -This sample site demonstrates one approach to render Episerver content in a client side framework that is using client side routing for navigation with a working On Page Edit (OPE) mode in the Episerver UI, where the frontend and backend are hosted separately. +This sample site demonstrates one approach to render Optimizely content in a client side framework that is using client side routing for navigation with a working On Page Edit (OPE) mode in the Optimizely UI, where the frontend and backend are hosted separately. This particular solution uses [Vue CLI](https://cli.vuejs.org/) with [Vuex](https://next.vuex.vuejs.org/) to handle the state of the app in a `single source of truth`. Most of the techniques are framework agnostic and can be used with any other framework, such as React or Angular. -Content is fetched from Episerver using the Content Delivery API: https://world.optimizely.com/documentation/developer-guides/cms/content/content-delivery-api/ +Content is fetched from Optimizely using the Content Delivery API: https://world.optimizely.com/documentation/developer-guides/cms/content/content-delivery-api/ ## Prerequisites @@ -19,7 +19,10 @@ This project uses: 1. Run `setup.cmd`. You can re-run `setup.cmd` at any time to reset the backend with a fresh database. 2. Open terminal for `./backend` and run `dotnet run`. * sign in with either `bob/bob` (admin) or `alice/alice` (editor). -3. Open terminal for `./frontend` and run `npm install` (only needed first run) and then `npm run serve`. +3. Since we reference two NPM modules locally, we need to install them first. Note that this is not needed if you install the modules from npmjs.com. + * Open terminal for `../../src/@episerver/content-definitions` and run `npm install` (only needed first run). + * Open terminal for `../../src/@episerver/content-delivery` and run `npm install` (only needed first run). +4. Open terminal for `./frontend` and run `npm install` (only needed first run) and then `npm run serve`. ## Notable files @@ -43,4 +46,4 @@ This project uses: ## Debugging Vuex state -Using the [Vue-devtools](https://github.com/vuejs/vue-devtools) to see the state changes in the store in view mode works as expected. There are however some limitations to follow state changes when you are editing in Episerver edit mode because of the site is running inside an iframe. To be able to see the vuex state while editing you need to run the stand alone electron app as described on the github page: [Vue standalone Electron app](https://github.com/vuejs/vue-devtools/blob/master/shells/electron/README.md). \ No newline at end of file +Using the [Vue-devtools](https://github.com/vuejs/vue-devtools) to see the state changes in the store in view mode works as expected. There are however some limitations to follow state changes when you are editing in Optimizely edit mode because of the site is running inside an iframe. To be able to see the vuex state while editing you need to run the stand alone electron app as described on the github page: [Vue standalone Electron app](https://github.com/vuejs/vue-devtools/blob/master/shells/electron/README.md). diff --git a/samples/music-festival-vue-decoupled/backend/MusicFestival.Backend.csproj b/samples/music-festival-vue-decoupled/backend/MusicFestival.Backend.csproj index 6484f5d..dd86948 100644 --- a/samples/music-festival-vue-decoupled/backend/MusicFestival.Backend.csproj +++ b/samples/music-festival-vue-decoupled/backend/MusicFestival.Backend.csproj @@ -6,10 +6,12 @@ - - - - + + + + + + diff --git a/samples/music-festival-vue-decoupled/backend/Startup.cs b/samples/music-festival-vue-decoupled/backend/Startup.cs index de4aaff..6933cbd 100644 --- a/samples/music-festival-vue-decoupled/backend/Startup.cs +++ b/samples/music-festival-vue-decoupled/backend/Startup.cs @@ -1,10 +1,9 @@ using EPiServer.Cms.UI.AspNetIdentity; -using EPiServer.ContentApi.Cms.Configuration; -using EPiServer.ContentApi.Core.Configuration; +using EPiServer.ContentApi.Cms; +using EPiServer.ContentApi.Core.DependencyInjection; using EPiServer.ContentDefinitionsApi; using EPiServer.Core; using EPiServer.Data; -using EPiServer.DependencyInjection; using EPiServer.OpenIDConnect; using EPiServer.ServiceLocation; using EPiServer.Web; @@ -70,7 +69,7 @@ public void ConfigureServices(IServiceCollection services) options.Applications.Add(new OpenIDConnectApplication { ClientId = "frontend", - Scopes = { "openid", "offline_access", "profile", "email", "roles", ContentDeliveryAuthorizationOptionsDefaults.Scope }, + Scopes = { "openid", "offline_access", "profile", "email", "roles", ContentDeliveryApiOptionsDefaults.Scope }, PostLogoutRedirectUris = { _frontendUri }, RedirectUris = { @@ -87,14 +86,9 @@ public void ConfigureServices(IServiceCollection services) }); }); - services.AddContentDeliveryApi(OpenIDConnectOptionsDefaults.AuthenticationScheme, options => - { - options.ExpandedBehavior = ExpandedLanguageBehavior.RequestedLanguage; - options.FlattenPropertyModel = true; - options.ForceAbsolute = true; - }); - services.AddContentDefinitionsApi(OpenIDConnectOptionsDefaults.AuthenticationScheme); + services.AddContentDeliveryApi(OpenIDConnectOptionsDefaults.AuthenticationScheme); + services.ConfigureForContentDeliveryClient(); services.AddHostedService(); } @@ -109,10 +103,11 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseStaticFiles(); app.UseRouting(); - // TODO: Enable CORS for all APIs with our own method app.UseCors(b => b .WithOrigins(new[] { "http://localhost:8080" }) - .AllowAnyHeader() + .WithExposedContentDeliveryApiHeaders() + .WithExposedContentDefinitionApiHeaders() + .WithHeaders("Authorization") .AllowAnyMethod() .AllowCredentials()); diff --git a/samples/music-festival-vue-decoupled/backend/properties/launchSettings.json b/samples/music-festival-vue-decoupled/backend/properties/launchSettings.json index e36bf07..e81ead4 100644 --- a/samples/music-festival-vue-decoupled/backend/properties/launchSettings.json +++ b/samples/music-festival-vue-decoupled/backend/properties/launchSettings.json @@ -5,6 +5,7 @@ "dotnetRunMessages": "true", "launchBrowser": true, "applicationUrl": "http://localhost:8081", + "launchUrl": "episerver/cms", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/samples/music-festival-vue-decoupled/frontend/package-lock.json b/samples/music-festival-vue-decoupled/frontend/package-lock.json index f5c237b..ada9ce6 100644 --- a/samples/music-festival-vue-decoupled/frontend/package-lock.json +++ b/samples/music-festival-vue-decoupled/frontend/package-lock.json @@ -35,7 +35,7 @@ } }, "../../../src/@episerver/content-definitions": { - "version": "1.0.0-pre.1", + "version": "1.0.0", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -55,7 +55,7 @@ } }, "../../../src/@episerver/content-delivery": { - "version": "1.0.0-pre.1", + "version": "1.0.0", "license": "Apache-2.0", "dependencies": { "cross-fetch": "^3.1.4" diff --git a/samples/music-festival-vue-decoupled/frontend/src/components/EpiContentArea.vue b/samples/music-festival-vue-decoupled/frontend/src/components/EpiContentArea.vue index 0b00c00..4cc5f47 100644 --- a/samples/music-festival-vue-decoupled/frontend/src/components/EpiContentArea.vue +++ b/samples/music-festival-vue-decoupled/frontend/src/components/EpiContentArea.vue @@ -4,7 +4,7 @@ By setting the `data-epi-block-id` attribute the block becomes editable during On-Page Edit. It will not be set in View mode to not leak out too - much info about Episerver to visitors. + much info about Optimizely to visitors. The model property is provided by the page or block that owns the ContentArea. diff --git a/samples/music-festival-vue-decoupled/frontend/src/components/EpiLink.vue b/samples/music-festival-vue-decoupled/frontend/src/components/EpiLink.vue index d31c95c..dfbd83a 100644 --- a/samples/music-festival-vue-decoupled/frontend/src/components/EpiLink.vue +++ b/samples/music-festival-vue-decoupled/frontend/src/components/EpiLink.vue @@ -29,7 +29,7 @@ export default { // There is an open feature-request for making 'router-link' support absolute links. // https://github.com/vuejs/vue-router/issues/1280 // - // Always user an 'a' tag in edit mode to update the Episerver UI + // Always user an 'a' tag in edit mode to update the Optimizely UI if (state.epiContext.inEditMode) { return 'a'; diff --git a/samples/music-festival-vue-decoupled/frontend/src/components/EpiViewModeLink.vue b/samples/music-festival-vue-decoupled/frontend/src/components/EpiViewModeLink.vue index c6f4ddb..4244948 100644 --- a/samples/music-festival-vue-decoupled/frontend/src/components/EpiViewModeLink.vue +++ b/samples/music-festival-vue-decoupled/frontend/src/components/EpiViewModeLink.vue @@ -1,6 +1,6 @@ diff --git a/samples/music-festival-vue-decoupled/frontend/src/main.js b/samples/music-festival-vue-decoupled/frontend/src/main.js index d4aa310..9bcdf31 100644 --- a/samples/music-festival-vue-decoupled/frontend/src/main.js +++ b/samples/music-festival-vue-decoupled/frontend/src/main.js @@ -11,7 +11,7 @@ const app = createApp(App) .use(store) .use(router); -// Register all Episerver view components globally. This requires webpack! +// Register all Optimizely view components globally. This requires webpack! // Otherwise we need to register all components manually here in main.js. const requireComponent = require.context('./views', true, /.vue$/); diff --git a/samples/music-festival-vue-decoupled/frontend/src/store/index.js b/samples/music-festival-vue-decoupled/frontend/src/store/index.js index 243c49a..a9e4727 100644 --- a/samples/music-festival-vue-decoupled/frontend/src/store/index.js +++ b/samples/music-festival-vue-decoupled/frontend/src/store/index.js @@ -5,7 +5,7 @@ import { createStore } from 'vuex'; import appContext from './modules/appContext'; // Module handling app specific state -import epiContext from './modules/epiContext'; // Module handling Episerver specific state +import epiContext from './modules/epiContext'; // Module handling Optimizely specific state import epiDataModel from './modules/epiDataModel'; // Module handling model state export default createStore({ diff --git a/samples/music-festival-vue-decoupled/frontend/src/views/pages/ArtistContainerPage.vue b/samples/music-festival-vue-decoupled/frontend/src/views/pages/ArtistContainerPage.vue index 62e7a6b..0a686ea 100644 --- a/samples/music-festival-vue-decoupled/frontend/src/views/pages/ArtistContainerPage.vue +++ b/samples/music-festival-vue-decoupled/frontend/src/views/pages/ArtistContainerPage.vue @@ -31,12 +31,12 @@