From b78c9cc04032b39e67cdd4523bbd096c598e823e Mon Sep 17 00:00:00 2001 From: Daniel Lautzenheiser Date: Tue, 5 Mar 2024 09:11:47 -0500 Subject: [PATCH 01/10] Update renovate.json --- renovate.json | 1 + 1 file changed, 1 insertion(+) diff --git a/renovate.json b/renovate.json index 429cdfe9c..0c61c6e00 100644 --- a/renovate.json +++ b/renovate.json @@ -1,6 +1,7 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": ["config:base", ":semanticCommits"], + "enabled": false, "labels": ["dependencies"], "packageRules": [ { From 79fab796ce924c5a5e7fdc7acd1e6b7e1bd74c17 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 09:12:56 -0500 Subject: [PATCH 02/10] chore(deps): bump follow-redirects from 1.15.2 to 1.15.4 (#1066) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/yarn.lock b/yarn.lock index 74461b08d..9ec07e8f8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10113,12 +10113,7 @@ flatted@^3.1.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== -follow-redirects@^1.0.0: - version "1.15.2" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" - integrity sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA== - -follow-redirects@^1.15.4: +follow-redirects@^1.0.0, follow-redirects@^1.15.4: version "1.15.4" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.4.tgz#cdc7d308bf6493126b17ea2191ea0ccf3e535adf" integrity sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw== From 38d54ee8e0bf1f72878c6e3aee2447c9fa1417f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 09:13:04 -0500 Subject: [PATCH 03/10] chore(deps-dev): bump vite from 5.0.10 to 5.0.12 (#1072) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- packages/demo/package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/demo/package.json b/packages/demo/package.json index ea044368a..865b1380c 100644 --- a/packages/demo/package.json +++ b/packages/demo/package.json @@ -32,7 +32,7 @@ "postcss": "8.4.32", "postcss-scss": "4.0.9", "prettier": "3.1.1", - "vite": "5.0.10", + "vite": "5.0.12", "vite-plugin-svgr": "4.2.0", "webpack": "5.89.0" }, diff --git a/yarn.lock b/yarn.lock index 9ec07e8f8..9ed90a550 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19550,10 +19550,10 @@ vite-plugin-svgr@4.2.0: "@svgr/core" "^8.1.0" "@svgr/plugin-jsx" "^8.1.0" -vite@5.0.10: - version "5.0.10" - resolved "https://registry.yarnpkg.com/vite/-/vite-5.0.10.tgz#1e13ef5c3cf5aa4eed81f5df6d107b3c3f1f6356" - integrity sha512-2P8J7WWgmc355HUMlFrwofacvr98DAjoE52BfdbwQtyLH06XKwaL/FMnmKM2crF0iX4MpmMKoDlNCB1ok7zHCw== +vite@5.0.12: + version "5.0.12" + resolved "https://registry.yarnpkg.com/vite/-/vite-5.0.12.tgz#8a2ffd4da36c132aec4adafe05d7adde38333c47" + integrity sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w== dependencies: esbuild "^0.19.3" postcss "^8.4.32" From 58cf84d667f76633b754ca5bf914a5e23257296c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 09:13:12 -0500 Subject: [PATCH 04/10] chore(deps-dev): bump vite from 5.0.10 to 5.0.12 in /packages/demo (#1076) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> From dcdc49232d4b8e48a3705dd91abc3d5ad2a8d4a0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 09:13:23 -0500 Subject: [PATCH 05/10] chore(deps): bump ip from 2.0.0 to 2.0.1 (#1087) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 9ed90a550..f3f14f8ca 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11462,9 +11462,9 @@ invariant@^2.2.2, invariant@^2.2.4: loose-envify "^1.0.0" ip@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.0.tgz#4cf4ab182fee2314c75ede1276f8c80b479936da" - integrity sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ== + version "2.0.1" + resolved "https://registry.yarnpkg.com/ip/-/ip-2.0.1.tgz#e8f3595d33a3ea66490204234b77636965307105" + integrity sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ== ipaddr.js@1.9.1: version "1.9.1" From 17b32f090292c20749327ffbd7f509363cab9869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9amus=20=C3=93=20Ceanainn?= Date: Tue, 5 Mar 2024 16:06:15 +0000 Subject: [PATCH 06/10] feat: Support custom auth schemes for Github API (#1086) --- packages/core/src/backends/github/API.ts | 7 +++-- .../src/backends/github/__tests__/API.spec.ts | 29 +++++++++++++++++++ .../src/backends/github/implementation.tsx | 14 +++++---- packages/core/src/interface.ts | 3 ++ 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/packages/core/src/backends/github/API.ts b/packages/core/src/backends/github/API.ts index a5b70bfd3..e9b04749a 100644 --- a/packages/core/src/backends/github/API.ts +++ b/packages/core/src/backends/github/API.ts @@ -33,7 +33,7 @@ import { } from '@staticcms/core/lib/util/APIUtils'; import { GitHubCommitStatusState, PullRequestState } from './types'; -import type { DataFile, PersistOptions, UnpublishedEntry } from '@staticcms/core'; +import type { AuthScheme, DataFile, PersistOptions, UnpublishedEntry } from '@staticcms/core'; import type { ApiRequest, FetchError } from '@staticcms/core/lib/util'; import type AssetProxy from '@staticcms/core/valueObjects/AssetProxy'; import type { Semaphore } from 'semaphore'; @@ -75,6 +75,7 @@ export const MOCK_PULL_REQUEST = -1; export interface Config { apiRoot?: string; token?: string; + authScheme?: AuthScheme; branch?: string; useOpenAuthoring?: boolean; openAuthoringEnabled?: boolean; @@ -162,6 +163,7 @@ export type Diff = { export default class API { apiRoot: string; token: string; + authScheme: AuthScheme; branch: string; useOpenAuthoring?: boolean; openAuthoringEnabled?: boolean; @@ -185,6 +187,7 @@ export default class API { constructor(config: Config) { this.apiRoot = config.apiRoot || 'https://api.github.com'; this.token = config.token || ''; + this.authScheme = config.authScheme || 'token'; this.branch = config.branch || 'main'; this.useOpenAuthoring = config.useOpenAuthoring; this.repo = config.repo || ''; @@ -242,7 +245,7 @@ export default class API { }; if (this.token) { - baseHeader.Authorization = `token ${this.token}`; + baseHeader.Authorization = `${this.authScheme} ${this.token}`; return Promise.resolve(baseHeader); } diff --git a/packages/core/src/backends/github/__tests__/API.spec.ts b/packages/core/src/backends/github/__tests__/API.spec.ts index 5b8d87404..dc658ef4a 100644 --- a/packages/core/src/backends/github/__tests__/API.spec.ts +++ b/packages/core/src/backends/github/__tests__/API.spec.ts @@ -103,6 +103,35 @@ describe('github API', () => { }); }); + it('should fetch url with authorization header using custom auth scheme', async () => { + const api = new API({ + branch: 'gh-pages', + repo: 'my-repo', + token: 'token', + authScheme: 'Bearer', + squashMerges: false, + initialWorkflowStatus: WorkflowStatus.DRAFT, + cmsLabelPrefix: '', + }); + + fetch.mockResolvedValue({ + text: jest.fn().mockResolvedValue('some response'), + ok: true, + status: 200, + headers: { get: () => '' }, + }); + const result = await api.request('/some-path'); + expect(result).toEqual('some response'); + expect(fetch).toHaveBeenCalledTimes(1); + expect(fetch).toHaveBeenCalledWith('https://api.github.com/some-path', { + cache: 'no-cache', + headers: { + Authorization: 'Bearer token', + 'Content-Type': 'application/json; charset=utf-8', + }, + }); + }); + it('should throw error on not ok response', async () => { const api = new API({ branch: 'gh-pages', diff --git a/packages/core/src/backends/github/implementation.tsx b/packages/core/src/backends/github/implementation.tsx index 65dce4ec2..fb6eaee28 100644 --- a/packages/core/src/backends/github/implementation.tsx +++ b/packages/core/src/backends/github/implementation.tsx @@ -25,6 +25,7 @@ import API, { API_NAME } from './API'; import AuthenticationPage from './AuthenticationPage'; import type { + AuthScheme, BackendClass, BackendEntry, ConfigWithDefaults, @@ -75,6 +76,7 @@ export default class GitHub implements BackendClass { mediaFolder?: string; previewContext: string; token: string | null; + authScheme: AuthScheme; squashMerges: boolean; cmsLabelPrefix: string; _currentUserPromise?: Promise; @@ -114,6 +116,7 @@ export default class GitHub implements BackendClass { this.branch = config.backend.branch?.trim() || 'main'; this.apiRoot = config.backend.api_root || 'https://api.github.com'; this.token = ''; + this.authScheme = config.backend.auth_scheme || 'token'; this.squashMerges = config.backend.squash_merges || false; this.cmsLabelPrefix = config.backend.cms_label_prefix || ''; this.mediaFolder = config.media_folder; @@ -171,7 +174,7 @@ export default class GitHub implements BackendClass { let repoExists = false; while (!repoExists) { repoExists = await fetch(`${this.apiRoot}/repos/${repo}`, { - headers: { Authorization: `token ${token}` }, + headers: { Authorization: `${this.authScheme} ${token}` }, }) .then(() => true) .catch(err => { @@ -194,7 +197,7 @@ export default class GitHub implements BackendClass { if (!this._currentUserPromise) { this._currentUserPromise = fetch(`${this.apiRoot}/user`, { headers: { - Authorization: `token ${token}`, + Authorization: `${this.authScheme} ${token}`, }, }).then(res => res.json()); } @@ -215,7 +218,7 @@ export default class GitHub implements BackendClass { `${this.apiRoot}/repos/${this.originRepo}/collaborators/${username}/permission`, { headers: { - Authorization: `token ${token}`, + Authorization: `${this.authScheme} ${token}`, }, }, ) @@ -232,7 +235,7 @@ export default class GitHub implements BackendClass { const repo = await fetch(`${this.apiRoot}/repos/${currentUser.login}/${repoName}`, { method: 'GET', headers: { - Authorization: `token ${token}`, + Authorization: `${this.authScheme} ${token}`, }, }).then(res => res.json()); @@ -276,7 +279,7 @@ export default class GitHub implements BackendClass { const fork = await fetch(`${this.apiRoot}/repos/${this.originRepo}/forks`, { method: 'POST', headers: { - Authorization: `token ${token}`, + Authorization: `${this.authScheme} ${token}`, }, }).then(res => res.json()); this.useOpenAuthoring = true; @@ -289,6 +292,7 @@ export default class GitHub implements BackendClass { const apiCtor = API; this.api = new apiCtor({ token: this.token, + authScheme: this.authScheme, branch: this.branch, repo: this.repo, originRepo: this.originRepo, diff --git a/packages/core/src/interface.ts b/packages/core/src/interface.ts index 5479331c0..47fa3f91c 100644 --- a/packages/core/src/interface.ts +++ b/packages/core/src/interface.ts @@ -698,6 +698,8 @@ export interface SelectWidgetOptionObject { export type AuthScope = 'repo' | 'public_repo'; +export type AuthScheme = 'token' | 'Bearer'; + export type SlugEncoding = 'unicode' | 'ascii'; export type RenderedField = F & { @@ -1025,6 +1027,7 @@ export interface Backend { identity_url?: string; gateway_url?: string; auth_scope?: AuthScope; + auth_scheme?: AuthScheme; commit_messages?: { create?: string; update?: string; From 4b09d595b7202773c31913428e64cb5d99833792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Almeida?= Date: Tue, 5 Mar 2024 17:06:23 +0100 Subject: [PATCH 07/10] docs: fixing version listed (#1090) --- packages/docs/content/docs/updating-your-cms.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docs/content/docs/updating-your-cms.mdx b/packages/docs/content/docs/updating-your-cms.mdx index 6c67f3a2a..497087f93 100644 --- a/packages/docs/content/docs/updating-your-cms.mdx +++ b/packages/docs/content/docs/updating-your-cms.mdx @@ -16,7 +16,7 @@ If you are using Static CMS through a CDN like Unpkg, then that depends on the v - (Recommended) If you use `^4.0.0`, Static CMS does all updates except major versions automatically. - It upgrades to `4.0.1`, `4.1.0`, `4.1.1`. - - It does not upgrade to `4.0.0` or higher. + - It does not upgrade to `5.0.0` or higher. - It does not upgrade to beta versions. - If you use `~4.0.0`, Static CMS will do only patch updates automatically. From 95ae12df7051c98fc824f70e565aec9e1bbe75f7 Mon Sep 17 00:00:00 2001 From: Daniel Lautzenheiser Date: Wed, 13 Mar 2024 08:47:25 -0400 Subject: [PATCH 08/10] v4.1.3 --- lerna.json | 2 +- packages/app/package.json | 4 ++-- packages/core/package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lerna.json b/lerna.json index 1d8599342..3ce1e42a7 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "4.1.2" + "version": "4.1.3" } diff --git a/packages/app/package.json b/packages/app/package.json index 341759831..f4a1b2eac 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -1,6 +1,6 @@ { "name": "@staticcms/app", - "version": "4.1.2", + "version": "4.1.3", "license": "MIT", "description": "Static CMS application.", "repository": "https://github.com/StaticJsCMS/static-cms", @@ -39,7 +39,7 @@ "dependencies": { "@babel/eslint-parser": "7.23.3", "@babel/runtime": "7.23.7", - "@staticcms/core": "^4.1.2", + "@staticcms/core": "^4.1.3", "buffer": "6.0.3", "react": "18.2.0", "react-dom": "18.2.0", diff --git a/packages/core/package.json b/packages/core/package.json index d19fca57d..d3f933548 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@staticcms/core", - "version": "4.1.2", + "version": "4.1.3", "license": "MIT", "description": "Static CMS core application.", "repository": "https://github.com/StaticJsCMS/static-cms", From 05ff1a104efabd0b87c1026e771dea365684153d Mon Sep 17 00:00:00 2001 From: Daniel Lautzenheiser Date: Wed, 13 Mar 2024 08:52:05 -0400 Subject: [PATCH 09/10] chore: add 4.1.3 release --- packages/docs/content/releases.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/docs/content/releases.json b/packages/docs/content/releases.json index 76416cf08..9a7726558 100644 --- a/packages/docs/content/releases.json +++ b/packages/docs/content/releases.json @@ -1,5 +1,10 @@ { "releases": [ + { + "date": "2024-03-13T10:00:00.000Z", + "version": "v4.1.3", + "type": "patch" + }, { "date": "2024-02-08T10:00:00.000Z", "version": "v4.1.2", From 734cecd9b44e32b319621e141ae57b93cb6dc134 Mon Sep 17 00:00:00 2001 From: Daniel Lautzenheiser Date: Wed, 13 Mar 2024 08:58:25 -0400 Subject: [PATCH 10/10] chore: remove references to discord --- README.md | 5 ----- packages/docs/content/community.json | 5 ----- packages/docs/next.config.js | 1 - 3 files changed, 11 deletions(-) diff --git a/README.md b/README.md index d903d5ec2..344423c93 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ [Docs](https://staticcms.org/) | [Demo](https://demo.staticcms.org/) | [Issues](https://github.com/StaticJsCMS/static-cms/issues) -| [Discord](https://discord.gg/ZWJM9pBMjj) @@ -113,7 +112,3 @@ Please make sure you understand its [implications and guarantees](https://writin # Decap Static CMS is a fork of [Decap](https://github.com/decaporg/decap-cms) (previously Netlify CMS) focusing on the core product over adding massive, scope expanding, new features. - -## Support - -For help with integrating Static CMS with your site, check out the community [Discord](https://discord.com/invite/ZWJM9pBMjj). diff --git a/packages/docs/content/community.json b/packages/docs/content/community.json index 46654546c..29906f1d9 100644 --- a/packages/docs/content/community.json +++ b/packages/docs/content/community.json @@ -15,11 +15,6 @@ { "title": "Support", "links": [ - { - "title": "Static CMS Discord", - "description": "Live community chat for all things Static CMS", - "url": "https://discord.gg/ZWJM9pBMjj" - }, { "title": "Static CMS Community", "description": "Ask and answer questions on GitHub discussions tab", diff --git a/packages/docs/next.config.js b/packages/docs/next.config.js index 303c711e7..405c89195 100644 --- a/packages/docs/next.config.js +++ b/packages/docs/next.config.js @@ -9,7 +9,6 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({ const redirects = [ { source: '/docs', destination: '/docs/intro', permanent: true }, - { source: '/chat', destination: 'https://discord.gg/ZWJM9pBMjj', permanent: true }, ]; /** @type {import('next').NextConfig} */