diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml index ddac6e7..83731fb 100644 --- a/.github/workflows/build-and-push.yml +++ b/.github/workflows/build-and-push.yml @@ -51,7 +51,7 @@ jobs: CURRENT_VERSION=$(grep --only-matching --perl-regexp '"version":\s*"\K[^"]+' package.json) TARGET_VERSION="$CURRENT_VERSION-sha.${{github.sha}}" - if pnpm view multiprovider@"${TARGET_VERSION}" > /dev/null 2>&1; then + if pnpm view flat-provider@"${TARGET_VERSION}" > /dev/null 2>&1; then echo "Version already exists. Skipping publish." else pnpm version ${TARGET_VERSION} diff --git a/README.md b/README.md index 56e3e16..11cf94c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Multiprovider +# Flat Provider A simple and type-safe multiprovider implementation for React applications. @@ -27,12 +27,12 @@ export default function Layout({ children }: PropsWithChildren): ReactElement { #### Into this: ```tsx -import { Multiprovider } from "multiprovider"; +import { FlatProvider } from "flat-provider"; export default function Layout({ children }: PropsWithChildren): ReactElement { // ... - return Multiprovider + return FlatProvider .append(UserTrackingProvider, { apiKey: process.env.TRACKING_API_KEY }) .append(AuthProvider, { session }) .append(UiKitProvider) diff --git a/package.json b/package.json index 81d17aa..bad1bc4 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { - "name": "multiprovider", + "name": "flat-provider", "version": "0.1.0", "private": true, "repository": { "type": "git", - "url": "git+https://github.com/ScarletFlash/multiprovider.git" + "url": "git+https://github.com/ScarletFlash/flat-provider.git" }, "bugs": { - "url": "https://github.com/ScarletFlash/multiprovider/issues" + "url": "https://github.com/ScarletFlash/flat-provider/issues" }, "author": { "name": "Fedor Usakov", diff --git a/src/index.spec.tsx b/src/index.spec.tsx index 73dfcda..f09a078 100644 --- a/src/index.spec.tsx +++ b/src/index.spec.tsx @@ -7,7 +7,7 @@ import { PropsWithChildren, useContext, } from "react"; -import { Multiprovider } from "./index"; +import { FlatProvider } from "./index"; const testId: string = "test-wrapper"; @@ -18,7 +18,7 @@ it("should return children as is if no providers are set", () => { render(
- {Multiprovider.getLayout(<>{expectedInnerHtml})} + {FlatProvider.getLayout(<>{expectedInnerHtml})}
); @@ -64,9 +64,9 @@ it("should render React context providers in the correct order", () => {
{providers .reduce( - (multiproviderRef: Multiprovider, currentProvider: FC) => - multiproviderRef.append(currentProvider), - new Multiprovider() + (flatProvider: FlatProvider, currentProvider: FC) => + flatProvider.append(currentProvider), + new FlatProvider() ) .getLayout()}
@@ -103,7 +103,7 @@ it("should correctly handle props", () => { render(
- {Multiprovider.append(ComponentWithProps, { + {FlatProvider.append(ComponentWithProps, { payload: { timestamp }, }) .append(ComponentWithoutProps) diff --git a/src/index.ts b/src/index.ts index 9bccff0..f34a594 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,7 +23,7 @@ interface ProviderWithProps< type Children = Pick["children"]; -export class Multiprovider { +export class FlatProvider { readonly #providers: ProviderWithProps[] = []; public append(component: FC): this; @@ -50,20 +50,20 @@ export class Multiprovider { ); } - public static append(component: FC): Multiprovider; + public static append(component: FC): FlatProvider; public static append

( component: FC

, props: Omit - ): Multiprovider; + ): FlatProvider; public static append

>( component: C, props?: ComponentPropsWithoutChildren - ): Multiprovider; - public static append(component: any, props?: any): Multiprovider { - return new Multiprovider().append(component, props); + ): FlatProvider; + public static append(component: any, props?: any): FlatProvider { + return new FlatProvider().append(component, props); } public static getLayout(children?: Children): ReactNode { - return new Multiprovider().getLayout(children); + return new FlatProvider().getLayout(children); } }