From 4ab9de1fc603f4f40c8f50ed5d0b0f7541c9efb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Thu, 25 Aug 2022 21:34:39 +0200 Subject: [PATCH] feat: deprecate `createCloudflareKVSessionStorage` --- .changeset/breezy-dancers-lie.md | 5 +++++ integration/cf-compiler-test.ts | 1 + packages/remix-cloudflare/index.ts | 20 +++++++++++++++---- .../mapNormalizedImports/packageExports.ts | 2 +- .../rules/packageExports.js | 2 +- 5 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 .changeset/breezy-dancers-lie.md diff --git a/.changeset/breezy-dancers-lie.md b/.changeset/breezy-dancers-lie.md new file mode 100644 index 00000000000..a836b093213 --- /dev/null +++ b/.changeset/breezy-dancers-lie.md @@ -0,0 +1,5 @@ +--- +"@remix-run/cloudflare": minor +--- + +Rename `createCloudflareKVSessionStorage` to `createWorkersKVSessionStorage` diff --git a/integration/cf-compiler-test.ts b/integration/cf-compiler-test.ts index a1d058e981a..10ada83fa71 100644 --- a/integration/cf-compiler-test.ts +++ b/integration/cf-compiler-test.ts @@ -155,6 +155,7 @@ test.describe("cloudflare compiler", () => { "createMemorySessionStorage", "createSessionStorage", "createSession", + "createCloudflareKVSessionStorage", "isCookie", "isSession", "json", diff --git a/packages/remix-cloudflare/index.ts b/packages/remix-cloudflare/index.ts index c78a1b1fbec..ee6d76c2fb8 100644 --- a/packages/remix-cloudflare/index.ts +++ b/packages/remix-cloudflare/index.ts @@ -1,10 +1,22 @@ import "./globals"; -export { +import {createWorkersKVSessionStorage} from './sessions/workersKVStorage'; + +const warn = (fn: T, message: string): T => + ((...args: unknown[]) => { + console.warn(message); + + return fn(...args); + }) as unknown as T; + + +/** @deprecated Use `createWorkersKVSessionStorage` instead. */ +export const createCloudflareKVSessionStorage = warn( createWorkersKVSessionStorage, - // TODO: Deprecate createCloudflareKVSessionStorage - createWorkersKVSessionStorage as createCloudflareKVSessionStorage, -} from "./sessions/workersKVStorage"; + "`createCloudflareKVSessionStorage` is deprecated. Please use `createWorkersKVSessionStorage` instead.", +); + +export { createWorkersKVSessionStorage } from "./sessions/workersKVStorage"; export { createCookie, diff --git a/packages/remix-dev/cli/migrate/migrations/replace-remix-imports/transform/mapNormalizedImports/packageExports.ts b/packages/remix-dev/cli/migrate/migrations/replace-remix-imports/transform/mapNormalizedImports/packageExports.ts index c6a34189002..27f7ec8a9d7 100644 --- a/packages/remix-dev/cli/migrate/migrations/replace-remix-imports/transform/mapNormalizedImports/packageExports.ts +++ b/packages/remix-dev/cli/migrate/migrations/replace-remix-imports/transform/mapNormalizedImports/packageExports.ts @@ -91,7 +91,7 @@ export const packageExports: Record = { type: [...defaultAdapterExports.type], }, cloudflare: { - value: [...defaultRuntimeExports.value, "createCloudflareKVSessionStorage"], + value: [...defaultRuntimeExports.value, "createCloudflareKVSessionStorage", "createWorkersKVSessionStorage"], type: [...defaultRuntimeExports.type], }, "cloudflare-pages": { diff --git a/packages/remix-eslint-config/rules/packageExports.js b/packages/remix-eslint-config/rules/packageExports.js index 690f6b425d4..8ef34ecb8ed 100644 --- a/packages/remix-eslint-config/rules/packageExports.js +++ b/packages/remix-eslint-config/rules/packageExports.js @@ -66,7 +66,7 @@ const architectSpecificExports = { }; const cloudflareSpecificExports = { - value: ["createCloudflareKVSessionStorage"], + value: ["createCloudflareKVSessionStorage", "createWorkersKVSessionStorage"], type: [], };