From c150a79a6bfa9cf7205265a398d43f2efcb664b3 Mon Sep 17 00:00:00 2001 From: tniezg Date: Wed, 18 Aug 2021 18:14:49 +0200 Subject: [PATCH] Use kebab case instead of camel case --- framework/spree/api/operations/get-all-products.ts | 2 +- framework/spree/api/operations/get-product.ts | 2 +- framework/spree/api/operations/get-site-info.ts | 2 +- framework/spree/api/utils/create-api-fetch.ts | 8 ++++---- framework/spree/cart/use-add-item.tsx | 4 ++-- framework/spree/cart/use-cart.tsx | 4 ++-- framework/spree/cart/use-remove-item.tsx | 4 ++-- framework/spree/cart/use-update-item.tsx | 4 ++-- framework/spree/fetcher.ts | 8 ++++---- framework/spree/index.tsx | 2 +- .../{isomorphicConfig.ts => isomorphic-config.ts} | 6 +++--- framework/spree/product/use-search.tsx | 4 ++-- ...ror.ts => convert-spree-error-to-graph-ql-error.ts} | 0 ...chFetcher.ts => create-customized-fetch-fetcher.ts} | 0 ...uteImageUrl.ts => create-get-absolute-image-url.ts} | 2 +- .../utils/{expandOptions.ts => expand-options.ts} | 2 +- .../utils/{jsonApi.ts => find-json-api-documents.ts} | 0 ...nfigValues.ts => force-isomorphic-config-values.ts} | 2 +- .../spree/utils/{getCartToken.ts => get-cart-token.ts} | 2 +- .../spree/utils/{getImageUrl.ts => get-image-url.ts} | 0 .../utils/{getMediaGallery.ts => get-media-gallery.ts} | 0 ...h.ts => get-spree-sdk-method-from-endpoint-path.ts} | 0 framework/spree/utils/{isServer.ts => is-server.ts} | 0 .../utils/{normalizeCart.ts => normalize-cart.ts} | 8 ++++---- .../{normalizeProduct.ts => normalize-product.ts} | 10 +++++----- .../utils/{requireConfig.ts => require-config.ts} | 0 .../spree/utils/{setCartToken.ts => set-cart-token.ts} | 2 +- ...lidateCookieExpire.ts => validate-cookie-expire.ts} | 0 28 files changed, 39 insertions(+), 39 deletions(-) rename framework/spree/{isomorphicConfig.ts => isomorphic-config.ts} (84%) rename framework/spree/utils/{convertSpreeErrorToGraphQlError.ts => convert-spree-error-to-graph-ql-error.ts} (100%) rename framework/spree/utils/{createCustomizedFetchFetcher.ts => create-customized-fetch-fetcher.ts} (100%) rename framework/spree/utils/{createGetAbsoluteImageUrl.ts => create-get-absolute-image-url.ts} (90%) rename framework/spree/utils/{expandOptions.ts => expand-options.ts} (97%) rename framework/spree/utils/{jsonApi.ts => find-json-api-documents.ts} (100%) rename framework/spree/utils/{forceIsomorphicConfigValues.ts => force-isomorphic-config-values.ts} (97%) rename framework/spree/utils/{getCartToken.ts => get-cart-token.ts} (69%) rename framework/spree/utils/{getImageUrl.ts => get-image-url.ts} (100%) rename framework/spree/utils/{getMediaGallery.ts => get-media-gallery.ts} (100%) rename framework/spree/utils/{getSpreeSdkMethodFromEndpointPath.ts => get-spree-sdk-method-from-endpoint-path.ts} (100%) rename framework/spree/utils/{isServer.ts => is-server.ts} (100%) rename framework/spree/utils/{normalizeCart.ts => normalize-cart.ts} (95%) rename framework/spree/utils/{normalizeProduct.ts => normalize-product.ts} (89%) rename framework/spree/utils/{requireConfig.ts => require-config.ts} (100%) rename framework/spree/utils/{setCartToken.ts => set-cart-token.ts} (82%) rename framework/spree/utils/{validateCookieExpire.ts => validate-cookie-expire.ts} (100%) diff --git a/framework/spree/api/operations/get-all-products.ts b/framework/spree/api/operations/get-all-products.ts index a821fd15e..df9c25bd1 100644 --- a/framework/spree/api/operations/get-all-products.ts +++ b/framework/spree/api/operations/get-all-products.ts @@ -7,7 +7,7 @@ import type { import type { IProducts } from '@spree/storefront-api-v2-sdk/types/interfaces/Product' import type { SpreeApiConfig, SpreeApiProvider } from '../index' import type { SpreeSdkVariables } from 'framework/spree/types' -import normalizeProduct from 'framework/spree/utils/normalizeProduct' +import normalizeProduct from '@framework/utils/normalize-product' export default function getAllProductsOperation({ commerce, diff --git a/framework/spree/api/operations/get-product.ts b/framework/spree/api/operations/get-product.ts index 1b4bc8744..79b799d23 100644 --- a/framework/spree/api/operations/get-product.ts +++ b/framework/spree/api/operations/get-product.ts @@ -7,7 +7,7 @@ import type { import type { IProduct } from '@spree/storefront-api-v2-sdk/types/interfaces/Product' import type { SpreeSdkVariables } from 'framework/spree/types' import MissingSlugVariableError from 'framework/spree/errors/MissingSlugVariableError' -import normalizeProduct from 'framework/spree/utils/normalizeProduct' +import normalizeProduct from '@framework/utils/normalize-product' export default function getProductOperation({ commerce, diff --git a/framework/spree/api/operations/get-site-info.ts b/framework/spree/api/operations/get-site-info.ts index 64e82e358..e54964744 100644 --- a/framework/spree/api/operations/get-site-info.ts +++ b/framework/spree/api/operations/get-site-info.ts @@ -7,7 +7,7 @@ import type { ITaxons, TaxonAttr, } from '@spree/storefront-api-v2-sdk/types/interfaces/Taxon' -import { requireConfigValue } from 'framework/spree/isomorphicConfig' +import { requireConfigValue } from '@framework/isomorphic-config' import type { SpreeSdkVariables } from 'framework/spree/types' import type { SpreeApiConfig, SpreeApiProvider } from '..' diff --git a/framework/spree/api/utils/create-api-fetch.ts b/framework/spree/api/utils/create-api-fetch.ts index d9d78bb60..43227ab57 100644 --- a/framework/spree/api/utils/create-api-fetch.ts +++ b/framework/spree/api/utils/create-api-fetch.ts @@ -1,17 +1,17 @@ import { SpreeApiConfig } from '..' import { errors, makeClient } from '@spree/storefront-api-v2-sdk' -import { requireConfigValue } from 'framework/spree/isomorphicConfig' -import convertSpreeErrorToGraphQlError from 'framework/spree/utils/convertSpreeErrorToGraphQlError' +import { requireConfigValue } from '@framework/isomorphic-config' +import convertSpreeErrorToGraphQlError from '@framework/utils/convert-spree-error-to-graph-ql-error' import type { ResultResponse } from '@spree/storefront-api-v2-sdk/types/interfaces/ResultResponse' import type { JsonApiListResponse, JsonApiSingleResponse, } from '@spree/storefront-api-v2-sdk/types/interfaces/JsonApi' -import getSpreeSdkMethodFromEndpointPath from 'framework/spree/utils/getSpreeSdkMethodFromEndpointPath' +import getSpreeSdkMethodFromEndpointPath from '@framework/utils/get-spree-sdk-method-from-endpoint-path' import { SpreeSdkVariables } from 'framework/spree/types' import SpreeSdkMethodFromEndpointPathError from 'framework/spree/errors/SpreeSdkMethodFromEndpointPathError' import { GraphQLFetcher, GraphQLFetcherResult } from '@commerce/api' -import createCustomizedFetchFetcher from '../../utils/createCustomizedFetchFetcher' +import createCustomizedFetchFetcher from '@framework/utils/create-customized-fetch-fetcher' import fetch, { Request } from 'node-fetch' const createApiFetch: ( diff --git a/framework/spree/cart/use-add-item.tsx b/framework/spree/cart/use-add-item.tsx index a4f63ac13..8144baa06 100644 --- a/framework/spree/cart/use-add-item.tsx +++ b/framework/spree/cart/use-add-item.tsx @@ -4,12 +4,12 @@ import type { MutationHook } from '@commerce/utils/types' import { useCallback } from 'react' import useCart from './use-cart' import type { AddItemHook } from '@commerce/types/cart' -import normalizeCart from '@framework/utils/normalizeCart' +import normalizeCart from '@framework/utils/normalize-cart' import type { GraphQLFetcherResult } from '@commerce/api' import type { IOrder } from '@spree/storefront-api-v2-sdk/types/interfaces/Order' import type { IToken } from '@spree/storefront-api-v2-sdk/types/interfaces/Token' import type { AddItem } from '@spree/storefront-api-v2-sdk/types/interfaces/endpoints/CartClass' -import getCartToken from '@framework/utils/getCartToken' +import getCartToken from '@framework/utils/get-cart-token' export default useAddItem as UseAddItem diff --git a/framework/spree/cart/use-cart.tsx b/framework/spree/cart/use-cart.tsx index 1fd880730..a635ce0ff 100644 --- a/framework/spree/cart/use-cart.tsx +++ b/framework/spree/cart/use-cart.tsx @@ -3,11 +3,11 @@ import type { SWRHook } from '@commerce/utils/types' import useCart from '@commerce/cart/use-cart' import type { UseCart } from '@commerce/cart/use-cart' import type { GetCartHook } from '@commerce/types/cart' -import normalizeCart from '@framework/utils/normalizeCart' +import normalizeCart from '@framework/utils/normalize-cart' import type { GraphQLFetcherResult } from '@commerce/api' import type { IOrder } from '@spree/storefront-api-v2-sdk/types/interfaces/Order' import type { IToken } from '@spree/storefront-api-v2-sdk/types/interfaces/Token' -import setCartToken from '@framework/utils/setCartToken' +import setCartToken from '@framework/utils/set-cart-token' export default useCart as UseCart diff --git a/framework/spree/cart/use-remove-item.tsx b/framework/spree/cart/use-remove-item.tsx index 9ba1f45b2..eaa482727 100644 --- a/framework/spree/cart/use-remove-item.tsx +++ b/framework/spree/cart/use-remove-item.tsx @@ -4,11 +4,11 @@ import type { UseRemoveItem } from '@commerce/cart/use-remove-item' import type { RemoveItemHook } from '@commerce/types/cart' import useCart from './use-cart' import { useCallback } from 'react' -import normalizeCart from '@framework/utils/normalizeCart' +import normalizeCart from '@framework/utils/normalize-cart' import type { IOrder } from '@spree/storefront-api-v2-sdk/types/interfaces/Order' import type { GraphQLFetcherResult } from '@commerce/api' import type { IQuery } from '@spree/storefront-api-v2-sdk/types/interfaces/Query' -import getCartToken from '@framework/utils/getCartToken' +import getCartToken from '@framework/utils/get-cart-token' import type { IToken } from '@spree/storefront-api-v2-sdk/types/interfaces/Token' export default useRemoveItem as UseRemoveItem diff --git a/framework/spree/cart/use-update-item.tsx b/framework/spree/cart/use-update-item.tsx index 239cc6c98..0ae82b104 100644 --- a/framework/spree/cart/use-update-item.tsx +++ b/framework/spree/cart/use-update-item.tsx @@ -6,10 +6,10 @@ import { useCallback } from 'react' import { ValidationError } from '@commerce/utils/errors' import type { IToken } from '@spree/storefront-api-v2-sdk/types/interfaces/Token' import type { SetQuantity } from '@spree/storefront-api-v2-sdk/types/interfaces/endpoints/CartClass' -import getCartToken from '@framework/utils/getCartToken' +import getCartToken from '@framework/utils/get-cart-token' import type { GraphQLFetcherResult } from '@commerce/api' import type { IOrder } from '@spree/storefront-api-v2-sdk/types/interfaces/Order' -import normalizeCart from '@framework/utils/normalizeCart' +import normalizeCart from '@framework/utils/normalize-cart' import debounce from 'lodash.debounce' export default useUpdateItem as UseUpdateItem diff --git a/framework/spree/fetcher.ts b/framework/spree/fetcher.ts index 64797ee32..001fdb6dd 100644 --- a/framework/spree/fetcher.ts +++ b/framework/spree/fetcher.ts @@ -1,5 +1,5 @@ import type { Fetcher } from '@commerce/utils/types' -import convertSpreeErrorToGraphQlError from './utils/convertSpreeErrorToGraphQlError' +import convertSpreeErrorToGraphQlError from './utils/convert-spree-error-to-graph-ql-error' import { makeClient } from '@spree/storefront-api-v2-sdk' import type { ResultResponse } from '@spree/storefront-api-v2-sdk/types/interfaces/ResultResponse' import type { @@ -7,12 +7,12 @@ import type { JsonApiSingleResponse, } from '@spree/storefront-api-v2-sdk/types/interfaces/JsonApi' import { errors } from '@spree/storefront-api-v2-sdk' -import { requireConfigValue } from './isomorphicConfig' -import getSpreeSdkMethodFromEndpointPath from './utils/getSpreeSdkMethodFromEndpointPath' +import { requireConfigValue } from './isomorphic-config' +import getSpreeSdkMethodFromEndpointPath from './utils/get-spree-sdk-method-from-endpoint-path' import SpreeSdkMethodFromEndpointPathError from './errors/SpreeSdkMethodFromEndpointPathError' import type { SpreeSdkVariables } from './types' import type { GraphQLFetcherResult } from '@commerce/api' -import createCustomizedFetchFetcher from './utils/createCustomizedFetchFetcher' +import createCustomizedFetchFetcher from './utils/create-customized-fetch-fetcher' const client = makeClient({ host: requireConfigValue('spreeApiHost') as string, diff --git a/framework/spree/index.tsx b/framework/spree/index.tsx index 03f93cc1c..6ca5bd198 100644 --- a/framework/spree/index.tsx +++ b/framework/spree/index.tsx @@ -9,7 +9,7 @@ import { import { provider } from './provider' import type { Provider } from './provider' -import { requireConfigValue } from './isomorphicConfig' +import { requireConfigValue } from './isomorphic-config' export type SpreeProps = { children: ReactNode diff --git a/framework/spree/isomorphicConfig.ts b/framework/spree/isomorphic-config.ts similarity index 84% rename from framework/spree/isomorphicConfig.ts rename to framework/spree/isomorphic-config.ts index 8806c8b7c..ed6a9fa34 100644 --- a/framework/spree/isomorphicConfig.ts +++ b/framework/spree/isomorphic-config.ts @@ -1,6 +1,6 @@ -import forceIsomorphicConfigValues from './utils/forceIsomorphicConfigValues' -import requireConfig from './utils/requireConfig' -import validateCookieExpire from './utils/validateCookieExpire' +import forceIsomorphicConfigValues from './utils/force-isomorphic-config-values' +import requireConfig from './utils/require-config' +import validateCookieExpire from './utils/validate-cookie-expire' const isomorphicConfig = { spreeApiHost: process.env.NEXT_PUBLIC_SPREE_API_HOST, diff --git a/framework/spree/product/use-search.tsx b/framework/spree/product/use-search.tsx index efeedc2ab..7cadca277 100644 --- a/framework/spree/product/use-search.tsx +++ b/framework/spree/product/use-search.tsx @@ -2,12 +2,12 @@ import type { Fetcher, SWRHook } from '@commerce/utils/types' import useSearch from '@commerce/product/use-search' import type { Product, SearchProductsHook } from '@commerce/types/product' import type { UseSearch } from '@commerce/product/use-search' -import normalizeProduct from '../utils/normalizeProduct' +import normalizeProduct from '../utils/normalize-product' import type { GraphQLFetcherResult } from '@commerce/api' import { IProducts } from '@spree/storefront-api-v2-sdk/types/interfaces/Product' const nextToSpreeSortMap: { [key: string]: string } = { - 'trending-desc': 'updated_at', // Spree has no "trending" filter. Use updated_at. + 'trending-desc': 'updated_at', // FIXME: Spree has no "trending" filter. Using updated_at. 'latest-desc': 'updated_at', 'price-asc': 'price', 'price-desc': '-price', diff --git a/framework/spree/utils/convertSpreeErrorToGraphQlError.ts b/framework/spree/utils/convert-spree-error-to-graph-ql-error.ts similarity index 100% rename from framework/spree/utils/convertSpreeErrorToGraphQlError.ts rename to framework/spree/utils/convert-spree-error-to-graph-ql-error.ts diff --git a/framework/spree/utils/createCustomizedFetchFetcher.ts b/framework/spree/utils/create-customized-fetch-fetcher.ts similarity index 100% rename from framework/spree/utils/createCustomizedFetchFetcher.ts rename to framework/spree/utils/create-customized-fetch-fetcher.ts diff --git a/framework/spree/utils/createGetAbsoluteImageUrl.ts b/framework/spree/utils/create-get-absolute-image-url.ts similarity index 90% rename from framework/spree/utils/createGetAbsoluteImageUrl.ts rename to framework/spree/utils/create-get-absolute-image-url.ts index 37932f15d..7b75aa780 100644 --- a/framework/spree/utils/createGetAbsoluteImageUrl.ts +++ b/framework/spree/utils/create-get-absolute-image-url.ts @@ -1,5 +1,5 @@ import { SpreeProductImage } from '../types' -import getImageUrl from './getImageUrl' +import getImageUrl from './get-image-url' const createGetAbsoluteImageUrl = (host: string) => diff --git a/framework/spree/utils/expandOptions.ts b/framework/spree/utils/expand-options.ts similarity index 97% rename from framework/spree/utils/expandOptions.ts rename to framework/spree/utils/expand-options.ts index 0ea5a28a2..f9381a738 100644 --- a/framework/spree/utils/expandOptions.ts +++ b/framework/spree/utils/expand-options.ts @@ -8,7 +8,7 @@ import type { } from '@spree/storefront-api-v2-sdk/types/interfaces/JsonApi' import type { RelationType } from '@spree/storefront-api-v2-sdk/types/interfaces/Relationships' import SpreeResponseContentError from '../errors/SpreeResponseContentError' -import { findIncluded } from './jsonApi' +import { findIncluded } from './find-json-api-documents' const isColorProductOption = (productOption: ProductOption) => { return productOption.displayName === 'Color' diff --git a/framework/spree/utils/jsonApi.ts b/framework/spree/utils/find-json-api-documents.ts similarity index 100% rename from framework/spree/utils/jsonApi.ts rename to framework/spree/utils/find-json-api-documents.ts diff --git a/framework/spree/utils/forceIsomorphicConfigValues.ts b/framework/spree/utils/force-isomorphic-config-values.ts similarity index 97% rename from framework/spree/utils/forceIsomorphicConfigValues.ts rename to framework/spree/utils/force-isomorphic-config-values.ts index 359ec5167..630b6859e 100644 --- a/framework/spree/utils/forceIsomorphicConfigValues.ts +++ b/framework/spree/utils/force-isomorphic-config-values.ts @@ -1,6 +1,6 @@ import type { NonUndefined, UnknownObjectValues } from '../types' import MisconfigurationError from '../errors/MisconfigurationError' -import isServer from './isServer' +import isServer from './is-server' const generateMisconfigurationErrorMessage = ( keys: Array diff --git a/framework/spree/utils/getCartToken.ts b/framework/spree/utils/get-cart-token.ts similarity index 69% rename from framework/spree/utils/getCartToken.ts rename to framework/spree/utils/get-cart-token.ts index 81bb3a897..72fbe2618 100644 --- a/framework/spree/utils/getCartToken.ts +++ b/framework/spree/utils/get-cart-token.ts @@ -1,4 +1,4 @@ -import { requireConfigValue } from '@framework/isomorphicConfig' +import { requireConfigValue } from '@framework/isomorphic-config' import Cookies from 'js-cookie' const getCartToken = () => diff --git a/framework/spree/utils/getImageUrl.ts b/framework/spree/utils/get-image-url.ts similarity index 100% rename from framework/spree/utils/getImageUrl.ts rename to framework/spree/utils/get-image-url.ts diff --git a/framework/spree/utils/getMediaGallery.ts b/framework/spree/utils/get-media-gallery.ts similarity index 100% rename from framework/spree/utils/getMediaGallery.ts rename to framework/spree/utils/get-media-gallery.ts diff --git a/framework/spree/utils/getSpreeSdkMethodFromEndpointPath.ts b/framework/spree/utils/get-spree-sdk-method-from-endpoint-path.ts similarity index 100% rename from framework/spree/utils/getSpreeSdkMethodFromEndpointPath.ts rename to framework/spree/utils/get-spree-sdk-method-from-endpoint-path.ts diff --git a/framework/spree/utils/isServer.ts b/framework/spree/utils/is-server.ts similarity index 100% rename from framework/spree/utils/isServer.ts rename to framework/spree/utils/is-server.ts diff --git a/framework/spree/utils/normalizeCart.ts b/framework/spree/utils/normalize-cart.ts similarity index 95% rename from framework/spree/utils/normalizeCart.ts rename to framework/spree/utils/normalize-cart.ts index 0a4072738..644e5726c 100644 --- a/framework/spree/utils/normalizeCart.ts +++ b/framework/spree/utils/normalize-cart.ts @@ -5,7 +5,7 @@ import type { SelectedOption, } from '@commerce/types/cart' import MissingLineItemVariantError from '@framework/errors/MissingLineItemVariantError' -import { requireConfigValue } from '@framework/isomorphicConfig' +import { requireConfigValue } from '@framework/isomorphic-config' import type { JsonApiDocument, JsonApiListResponse, @@ -14,9 +14,9 @@ import type { import type { OrderAttr } from '@spree/storefront-api-v2-sdk/types/interfaces/Order' import { ProductAttr } from '@spree/storefront-api-v2-sdk/types/interfaces/Product' import type { RelationType } from '@spree/storefront-api-v2-sdk/types/interfaces/Relationships' -import createGetAbsoluteImageUrl from './createGetAbsoluteImageUrl' -import getMediaGallery from './getMediaGallery' -import { findIncluded, findIncludedOfType } from './jsonApi' +import createGetAbsoluteImageUrl from './create-get-absolute-image-url' +import getMediaGallery from './get-media-gallery' +import { findIncluded, findIncludedOfType } from './find-json-api-documents' const isColorProductOption = (productOptionType: any) => { // TODO: Fix type and merge with isColorProductOption in framework/spree/utils/expandOptions.ts diff --git a/framework/spree/utils/normalizeProduct.ts b/framework/spree/utils/normalize-product.ts similarity index 89% rename from framework/spree/utils/normalizeProduct.ts rename to framework/spree/utils/normalize-product.ts index bc02301ae..5c38aaffc 100644 --- a/framework/spree/utils/normalizeProduct.ts +++ b/framework/spree/utils/normalize-product.ts @@ -10,11 +10,11 @@ import type { } from '@spree/storefront-api-v2-sdk/types/interfaces/JsonApi' import type { ProductAttr } from '@spree/storefront-api-v2-sdk/types/interfaces/Product' import type { RelationType } from '@spree/storefront-api-v2-sdk/types/interfaces/Relationships' -import { requireConfigValue } from '../isomorphicConfig' -import createGetAbsoluteImageUrl from './createGetAbsoluteImageUrl' -import expandOptions from './expandOptions' -import getMediaGallery from './getMediaGallery' -import { findIncludedOfType } from './jsonApi' +import { requireConfigValue } from '@framework/isomorphic-config' +import createGetAbsoluteImageUrl from './create-get-absolute-image-url' +import expandOptions from './expand-options' +import getMediaGallery from './get-media-gallery' +import { findIncludedOfType } from './find-json-api-documents' const normalizeProduct = ( spreeSuccessResponse: JsonApiSingleResponse | JsonApiListResponse, diff --git a/framework/spree/utils/requireConfig.ts b/framework/spree/utils/require-config.ts similarity index 100% rename from framework/spree/utils/requireConfig.ts rename to framework/spree/utils/require-config.ts diff --git a/framework/spree/utils/setCartToken.ts b/framework/spree/utils/set-cart-token.ts similarity index 82% rename from framework/spree/utils/setCartToken.ts rename to framework/spree/utils/set-cart-token.ts index 68caaa19f..6cffc1e79 100644 --- a/framework/spree/utils/setCartToken.ts +++ b/framework/spree/utils/set-cart-token.ts @@ -1,4 +1,4 @@ -import { requireConfigValue } from '@framework/isomorphicConfig' +import { requireConfigValue } from '@framework/isomorphic-config' import Cookies from 'js-cookie' const setCartToken = (cartToken: string) => { diff --git a/framework/spree/utils/validateCookieExpire.ts b/framework/spree/utils/validate-cookie-expire.ts similarity index 100% rename from framework/spree/utils/validateCookieExpire.ts rename to framework/spree/utils/validate-cookie-expire.ts