mirror of
https://github.com/vercel/commerce.git
synced 2025-03-31 09:15:53 +00:00
Monorepo with Turborepo (#651)
* Moved everything * Figuring out how to make imports work * Updated exports * Added missing exports * Added @vercel/commerce-local to `site` * Updated commerce config * Updated exports and commerce config * Updated commerce hoc * Fixed exports in local * Added publish config * Updated imports in site * It's actually working * Don't use debugger in dev for better speeds * Improved DX when editing packages * Set up eslint with husky * Updated prettier config * Added prettier setup to every package * Moved bigcommerce * Moved Bigcommerce to src and package updates * Updated setup of bigcommerce * Moved definitions script * Moved commercejs * Move to src * Fixed types in commercejs * Moved kibocommerce * Moved kibocommerce to src * Added package/tsconfig to kibocommerce * Fixed imports and other things * Moved ordercloud * Moved ordercloud to src * Fixed imports * Added missing prettier files * Moved Saleor * Moved Saleor to src * Fixed imports * Replaced all imports to @commerce * Added prettierignore/rc to all providers * Moved shopify to src * Build shopify in packages * Moved Spree * Moved spree to src * Updated spree * Moved swell * Moved swell to src * Fixed type imports in swell * Moved Vendure to packages * Moved vendure to src * Fixed imports in vendure * Added codegen to saleor * Updated codegen setup for shopify * Added codegen to vendure * Added codegen to kibocommerce * Added all packages to site's deps * Updated codegen setup in bigcommerce * Minor fixes * Updated providers' names in site * Updated packages based on Bel's changes * Updated turbo to latest * Fixed ts complains * Set npm engine in root * New lockfile install * remove engines * Regen lockfile * Switched from npm to yarn * Updated typesVersions in all packages * Moved dep * Updated SWR to the just released 1.2.0 * Removed "isolatedModules" from packages * Updated list of providers and default * Updated swell declaration * Removed next import from kibocommerce * Added COMMERCE_PROVIDER log * Added another log * Updated turbo config * Updated docs * Removed test logs Co-authored-by: Jared Palmer <jared@jaredpalmer.com>
This commit is contained in:
parent
d0ef346189
commit
0afe686fe9
14
.gitignore
vendored
14
.gitignore
vendored
@ -2,18 +2,19 @@
|
|||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
node_modules
|
node_modules
|
||||||
/.pnp
|
.pnp
|
||||||
.pnp.js
|
.pnp.js
|
||||||
|
|
||||||
# testing
|
# testing
|
||||||
/coverage
|
coverage
|
||||||
|
|
||||||
# next.js
|
# next.js
|
||||||
.next/
|
.next
|
||||||
out/
|
out
|
||||||
|
|
||||||
# production
|
# production
|
||||||
/build
|
build
|
||||||
|
dist
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
@ -34,3 +35,6 @@ yarn-error.log*
|
|||||||
|
|
||||||
# vercel
|
# vercel
|
||||||
.vercel
|
.vercel
|
||||||
|
|
||||||
|
# Turborepo
|
||||||
|
.turbo
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
# Every package defines its prettier config
|
||||||
node_modules
|
node_modules
|
||||||
.next
|
packages
|
||||||
public
|
site
|
||||||
|
10
.prettierrc
10
.prettierrc
@ -2,13 +2,5 @@
|
|||||||
"semi": false,
|
"semi": false,
|
||||||
"singleQuote": true,
|
"singleQuote": true,
|
||||||
"tabWidth": 2,
|
"tabWidth": 2,
|
||||||
"useTabs": false,
|
"useTabs": false
|
||||||
"overrides": [
|
|
||||||
{
|
|
||||||
"files": ["framework/saleor/**/*"],
|
|
||||||
"options": {
|
|
||||||
"printWidth": 120
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
7
.vscode/extensions.json
vendored
7
.vscode/extensions.json
vendored
@ -1,3 +1,8 @@
|
|||||||
{
|
{
|
||||||
"recommendations": ["esbenp.prettier-vscode", "csstools.postcss", "bradlc.vscode-tailwindcss"]
|
"recommendations": [
|
||||||
|
"esbenp.prettier-vscode",
|
||||||
|
"csstools.postcss",
|
||||||
|
"bradlc.vscode-tailwindcss",
|
||||||
|
"ms-vscode.vscode-typescript-next"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
22
README.md
22
README.md
@ -35,11 +35,10 @@ Next.js Commerce integrates out-of-the-box with BigCommerce, Shopify, Swell, Sal
|
|||||||
|
|
||||||
## Considerations
|
## Considerations
|
||||||
|
|
||||||
- `framework/commerce` contains all types, helpers and functions to be used as base to build a new **provider**.
|
- `packages/commerce` contains all types, helpers and functions to be used as base to build a new **provider**.
|
||||||
- **Providers** live under `framework`'s root folder and they will extend Next.js Commerce types and functionality (`framework/commerce`).
|
- **Providers** live under `packages`'s root folder and they will extend Next.js Commerce types and functionality (`packages/commerce`).
|
||||||
- We have a **Features API** to ensure feature parity between the UI and the Provider. The UI should update accordingly and no extra code should be bundled. All extra configuration for features will live under `features` in `commerce.config.json` and if needed it can also be accessed programatically.
|
- We have a **Features API** to ensure feature parity between the UI and the Provider. The UI should update accordingly and no extra code should be bundled. All extra configuration for features will live under `features` in `commerce.config.json` and if needed it can also be accessed programatically.
|
||||||
- Each **provider** should add its corresponding `next.config.js` and `commerce.config.json` adding specific data related to the provider. For example in case of BigCommerce, the images CDN and additional API routes.
|
- Each **provider** should add its corresponding `next.config.js` and `commerce.config.json` adding specific data related to the provider. For example in case of BigCommerce, the images CDN and additional API routes.
|
||||||
- **Providers don't depend on anything that's specific to the application they're used in**. They only depend on `framework/commerce`, on their own framework folder and on some dependencies included in `package.json`
|
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
@ -55,18 +54,9 @@ NEXT_PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|||||||
NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN=xxxxxxx.myshopify.com
|
NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN=xxxxxxx.myshopify.com
|
||||||
```
|
```
|
||||||
|
|
||||||
And check that the `tsconfig.json` resolves to the chosen provider:
|
|
||||||
|
|
||||||
```
|
|
||||||
"@framework": ["framework/shopify"],
|
|
||||||
"@framework/*": ["framework/shopify/*"]
|
|
||||||
```
|
|
||||||
|
|
||||||
That's it!
|
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
||||||
Every provider defines the features that it supports under `framework/{provider}/commerce.config.json`
|
Every provider defines the features that it supports under `packages/{provider}/src/commerce.config.json`
|
||||||
|
|
||||||
#### Features Available
|
#### Features Available
|
||||||
|
|
||||||
@ -98,9 +88,7 @@ For example: Turning `cart` off will disable Cart capabilities.
|
|||||||
|
|
||||||
### How to create a new provider
|
### How to create a new provider
|
||||||
|
|
||||||
🔔 New providers are on hold [until we have a new API for commerce](https://github.com/vercel/commerce/pull/252) 🔔
|
Follow our docs for [Adding a new Commerce Provider](packages/commerce/new-provider.md).
|
||||||
|
|
||||||
Follow our docs for [Adding a new Commerce Provider](framework/commerce/new-provider.md).
|
|
||||||
|
|
||||||
If you succeeded building a provider, submit a PR with a valid demo and we'll review it asap.
|
If you succeeded building a provider, submit a PR with a valid demo and we'll review it asap.
|
||||||
|
|
||||||
@ -119,7 +107,7 @@ Our commitment to Open Source can be found [here](https://vercel.com/oss).
|
|||||||
|
|
||||||
We're using Github Projects to keep track of issues in progress and todo's. Here is our [Board](https://github.com/vercel/commerce/projects/1)
|
We're using Github Projects to keep track of issues in progress and todo's. Here is our [Board](https://github.com/vercel/commerce/projects/1)
|
||||||
|
|
||||||
People actively working on this project: @okbel & @lfades.
|
People actively working on this project: @okbel, @lfades, @dominiksipowicz, @gbibeaul.
|
||||||
|
|
||||||
## Troubleshoot
|
## Troubleshoot
|
||||||
|
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
export * from '@commerce/product/use-price'
|
|
||||||
export { default } from '@commerce/product/use-price'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/checkout'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/common'
|
|
@ -1,5 +0,0 @@
|
|||||||
import * as Core from '@commerce/types/customer'
|
|
||||||
|
|
||||||
export * from '@commerce/types/customer'
|
|
||||||
|
|
||||||
export type CustomerSchema = Core.CustomerSchema
|
|
@ -1,8 +0,0 @@
|
|||||||
import * as Core from '@commerce/types/login'
|
|
||||||
import type { LoginMutationVariables } from '../schema'
|
|
||||||
|
|
||||||
export * from '@commerce/types/login'
|
|
||||||
|
|
||||||
export type LoginOperation = Core.LoginOperation & {
|
|
||||||
variables: LoginMutationVariables
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/logout'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/product'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/signup'
|
|
@ -1,92 +0,0 @@
|
|||||||
/**
|
|
||||||
* This file is expected to be used in next.config.js only
|
|
||||||
*/
|
|
||||||
|
|
||||||
const path = require('path')
|
|
||||||
const fs = require('fs')
|
|
||||||
const merge = require('deepmerge')
|
|
||||||
const prettier = require('prettier')
|
|
||||||
|
|
||||||
const PROVIDERS = [
|
|
||||||
'local',
|
|
||||||
'bigcommerce',
|
|
||||||
'saleor',
|
|
||||||
'shopify',
|
|
||||||
'swell',
|
|
||||||
'vendure',
|
|
||||||
'ordercloud',
|
|
||||||
'kibocommerce',
|
|
||||||
'spree',
|
|
||||||
'commercejs',
|
|
||||||
]
|
|
||||||
|
|
||||||
function getProviderName() {
|
|
||||||
return (
|
|
||||||
process.env.COMMERCE_PROVIDER ||
|
|
||||||
(process.env.BIGCOMMERCE_STOREFRONT_API_URL
|
|
||||||
? 'bigcommerce'
|
|
||||||
: process.env.NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN
|
|
||||||
? 'shopify'
|
|
||||||
: process.env.NEXT_PUBLIC_SWELL_STORE_ID
|
|
||||||
? 'swell'
|
|
||||||
: 'local')
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function withCommerceConfig(nextConfig = {}) {
|
|
||||||
const commerce = nextConfig.commerce || {}
|
|
||||||
const name = commerce.provider || getProviderName()
|
|
||||||
|
|
||||||
if (!name) {
|
|
||||||
throw new Error(
|
|
||||||
`The commerce provider is missing, please add a valid provider name or its environment variables`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (!PROVIDERS.includes(name)) {
|
|
||||||
throw new Error(
|
|
||||||
`The commerce provider "${name}" can't be found, please use one of "${PROVIDERS.join(
|
|
||||||
', '
|
|
||||||
)}"`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const commerceNextConfig = require(path.join('../', name, 'next.config'))
|
|
||||||
const config = merge(nextConfig, commerceNextConfig)
|
|
||||||
|
|
||||||
config.env = config.env || {}
|
|
||||||
|
|
||||||
Object.entries(config.commerce.features).forEach(([k, v]) => {
|
|
||||||
if (v) config.env[`COMMERCE_${k.toUpperCase()}_ENABLED`] = true
|
|
||||||
})
|
|
||||||
|
|
||||||
// Update paths in `tsconfig.json` to point to the selected provider
|
|
||||||
if (config.commerce.updateTSConfig !== false) {
|
|
||||||
const tsconfigPath = path.join(process.cwd(), 'tsconfig.json')
|
|
||||||
const tsconfig = require(tsconfigPath)
|
|
||||||
|
|
||||||
tsconfig.compilerOptions.paths['@framework'] = [`framework/${name}`]
|
|
||||||
tsconfig.compilerOptions.paths['@framework/*'] = [`framework/${name}/*`]
|
|
||||||
|
|
||||||
// When running for production it may be useful to exclude the other providers
|
|
||||||
// from TS checking
|
|
||||||
if (process.env.VERCEL) {
|
|
||||||
const exclude = tsconfig.exclude.filter(
|
|
||||||
(item) => !item.startsWith('framework/')
|
|
||||||
)
|
|
||||||
|
|
||||||
tsconfig.exclude = PROVIDERS.reduce((exclude, current) => {
|
|
||||||
if (current !== name) exclude.push(`framework/${current}`)
|
|
||||||
return exclude
|
|
||||||
}, exclude)
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFileSync(
|
|
||||||
tsconfigPath,
|
|
||||||
prettier.format(JSON.stringify(tsconfig), { parser: 'json' })
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return config
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = { withCommerceConfig, getProviderName }
|
|
@ -1,2 +0,0 @@
|
|||||||
export * from '@commerce/product/use-price'
|
|
||||||
export { default } from '@commerce/product/use-price'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/common'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/customer'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/logout'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/page'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/signup'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/wishlist'
|
|
@ -1,14 +0,0 @@
|
|||||||
import { SWRHook } from '@commerce/utils/types'
|
|
||||||
import useCheckout, { UseCheckout } from '@commerce/checkout/use-checkout'
|
|
||||||
|
|
||||||
export default useCheckout as UseCheckout<typeof handler>
|
|
||||||
|
|
||||||
export const handler: SWRHook<any> = {
|
|
||||||
fetchOptions: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
async fetcher({ input, options, fetch }) {},
|
|
||||||
useHook:
|
|
||||||
({ useData }) =>
|
|
||||||
async (input) => ({}),
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
import useAddItem, { UseAddItem } from '@commerce/customer/address/use-add-item'
|
|
||||||
import { MutationHook } from '@commerce/utils/types'
|
|
||||||
|
|
||||||
export default useAddItem as UseAddItem<typeof handler>
|
|
||||||
|
|
||||||
export const handler: MutationHook<any> = {
|
|
||||||
fetchOptions: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
async fetcher({ input, options, fetch }) {},
|
|
||||||
useHook:
|
|
||||||
({ fetch }) =>
|
|
||||||
() =>
|
|
||||||
async () => ({}),
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
import useAddItem, { UseAddItem } from '@commerce/customer/card/use-add-item'
|
|
||||||
import { MutationHook } from '@commerce/utils/types'
|
|
||||||
|
|
||||||
export default useAddItem as UseAddItem<typeof handler>
|
|
||||||
|
|
||||||
export const handler: MutationHook<any> = {
|
|
||||||
fetchOptions: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
async fetcher({ input, options, fetch }) {},
|
|
||||||
useHook:
|
|
||||||
({ fetch }) =>
|
|
||||||
() =>
|
|
||||||
async () => ({}),
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
export * from '@commerce/product/use-price'
|
|
||||||
export { default } from '@commerce/product/use-price'
|
|
@ -1,8 +0,0 @@
|
|||||||
import * as Core from '@commerce/types/login'
|
|
||||||
import type { CustomerUserAuthInfoInput } from '../schema'
|
|
||||||
|
|
||||||
export * from '@commerce/types/login'
|
|
||||||
|
|
||||||
export type LoginOperation = Core.LoginOperation & {
|
|
||||||
variables: CustomerUserAuthInfoInput
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/logout'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/signup'
|
|
@ -1,2 +0,0 @@
|
|||||||
export * from '@commerce/product/use-price'
|
|
||||||
export { default } from '@commerce/product/use-price'
|
|
@ -1,2 +0,0 @@
|
|||||||
export * from '@commerce/product/use-price'
|
|
||||||
export { default } from '@commerce/product/use-price'
|
|
@ -1,15 +0,0 @@
|
|||||||
import useAddItem, { UseAddItem } from '@commerce/customer/address/use-add-item'
|
|
||||||
import { MutationHook } from '@commerce/utils/types'
|
|
||||||
|
|
||||||
export default useAddItem as UseAddItem<typeof handler>
|
|
||||||
|
|
||||||
export const handler: MutationHook<any> = {
|
|
||||||
fetchOptions: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
async fetcher({ input, options, fetch }) {},
|
|
||||||
useHook:
|
|
||||||
({ fetch }) =>
|
|
||||||
() =>
|
|
||||||
async () => ({}),
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
import useAddItem, { UseAddItem } from '@commerce/customer/card/use-add-item'
|
|
||||||
import { MutationHook } from '@commerce/utils/types'
|
|
||||||
|
|
||||||
export default useAddItem as UseAddItem<typeof handler>
|
|
||||||
|
|
||||||
export const handler: MutationHook<any> = {
|
|
||||||
fetchOptions: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
async fetcher({ input, options, fetch }) {},
|
|
||||||
useHook:
|
|
||||||
({ fetch }) =>
|
|
||||||
() =>
|
|
||||||
async () => ({}),
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
export * from '@commerce/product/use-price'
|
|
||||||
export { default } from '@commerce/product/use-price'
|
|
@ -1,15 +0,0 @@
|
|||||||
import useAddItem, { UseAddItem } from '@commerce/customer/address/use-add-item'
|
|
||||||
import { MutationHook } from '@commerce/utils/types'
|
|
||||||
|
|
||||||
export default useAddItem as UseAddItem<typeof handler>
|
|
||||||
|
|
||||||
export const handler: MutationHook<any> = {
|
|
||||||
fetchOptions: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
async fetcher({ input, options, fetch }) {},
|
|
||||||
useHook:
|
|
||||||
({ fetch }) =>
|
|
||||||
() =>
|
|
||||||
async () => ({}),
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
import useAddItem, { UseAddItem } from '@commerce/customer/card/use-add-item'
|
|
||||||
import { MutationHook } from '@commerce/utils/types'
|
|
||||||
|
|
||||||
export default useAddItem as UseAddItem<typeof handler>
|
|
||||||
|
|
||||||
export const handler: MutationHook<any> = {
|
|
||||||
fetchOptions: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
async fetcher({ input, options, fetch }) {},
|
|
||||||
useHook:
|
|
||||||
({ fetch }) =>
|
|
||||||
() =>
|
|
||||||
async () => ({}),
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
export * from '@commerce/product/use-price'
|
|
||||||
export { default } from '@commerce/product/use-price'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/checkout'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/common'
|
|
@ -1,5 +0,0 @@
|
|||||||
import * as Core from '@commerce/types/customer'
|
|
||||||
|
|
||||||
export * from '@commerce/types/customer'
|
|
||||||
|
|
||||||
export type CustomerSchema = Core.CustomerSchema
|
|
@ -1,8 +0,0 @@
|
|||||||
import * as Core from '@commerce/types/login'
|
|
||||||
import type { CustomerAccessTokenCreateInput } from '../schema'
|
|
||||||
|
|
||||||
export * from '@commerce/types/login'
|
|
||||||
|
|
||||||
export type LoginOperation = Core.LoginOperation & {
|
|
||||||
variables: CustomerAccessTokenCreateInput
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/logout'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/product'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/signup'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/site'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/wishlist'
|
|
@ -1,2 +0,0 @@
|
|||||||
export * from '@commerce/product/use-price'
|
|
||||||
export { default } from '@commerce/product/use-price'
|
|
@ -1,14 +0,0 @@
|
|||||||
import { SWRHook } from '@commerce/utils/types'
|
|
||||||
import useCheckout, { UseCheckout } from '@commerce/checkout/use-checkout'
|
|
||||||
|
|
||||||
export default useCheckout as UseCheckout<typeof handler>
|
|
||||||
|
|
||||||
export const handler: SWRHook<any> = {
|
|
||||||
fetchOptions: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
async fetcher({ input, options, fetch }) {},
|
|
||||||
useHook:
|
|
||||||
({ useData }) =>
|
|
||||||
async (input) => ({}),
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
import useAddItem, { UseAddItem } from '@commerce/customer/address/use-add-item'
|
|
||||||
import { MutationHook } from '@commerce/utils/types'
|
|
||||||
|
|
||||||
export default useAddItem as UseAddItem<typeof handler>
|
|
||||||
|
|
||||||
export const handler: MutationHook<any> = {
|
|
||||||
fetchOptions: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
async fetcher({ input, options, fetch }) {},
|
|
||||||
useHook:
|
|
||||||
({ fetch }) =>
|
|
||||||
() =>
|
|
||||||
async () => ({}),
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
import useAddItem, { UseAddItem } from '@commerce/customer/card/use-add-item'
|
|
||||||
import { MutationHook } from '@commerce/utils/types'
|
|
||||||
|
|
||||||
export default useAddItem as UseAddItem<typeof handler>
|
|
||||||
|
|
||||||
export const handler: MutationHook<any> = {
|
|
||||||
fetchOptions: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
async fetcher({ input, options, fetch }) {},
|
|
||||||
useHook:
|
|
||||||
({ fetch }) =>
|
|
||||||
() =>
|
|
||||||
async () => ({}),
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
export * from '@commerce/product/use-price'
|
|
||||||
export { default } from '@commerce/product/use-price'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/cart'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/checkout'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/common'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/customer'
|
|
@ -1,11 +0,0 @@
|
|||||||
import * as Core from '@commerce/types/login'
|
|
||||||
import { LoginBody, LoginTypes } from '@commerce/types/login'
|
|
||||||
|
|
||||||
export * from '@commerce/types/login'
|
|
||||||
|
|
||||||
export type LoginHook<T extends LoginTypes = LoginTypes> = {
|
|
||||||
data: null
|
|
||||||
actionInput: LoginBody
|
|
||||||
fetcherInput: LoginBody
|
|
||||||
body: T['body']
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/logout'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/page'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/product'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/signup'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/site'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/wishlist'
|
|
@ -1,14 +0,0 @@
|
|||||||
import { SWRHook } from '@commerce/utils/types'
|
|
||||||
import useCheckout, { UseCheckout } from '@commerce/checkout/use-checkout'
|
|
||||||
|
|
||||||
export default useCheckout as UseCheckout<typeof handler>
|
|
||||||
|
|
||||||
export const handler: SWRHook<any> = {
|
|
||||||
fetchOptions: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
async fetcher({ input, options, fetch }) {},
|
|
||||||
useHook:
|
|
||||||
({ useData }) =>
|
|
||||||
async (input) => ({}),
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
import useAddItem, { UseAddItem } from '@commerce/customer/address/use-add-item'
|
|
||||||
import { MutationHook } from '@commerce/utils/types'
|
|
||||||
|
|
||||||
export default useAddItem as UseAddItem<typeof handler>
|
|
||||||
|
|
||||||
export const handler: MutationHook<any> = {
|
|
||||||
fetchOptions: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
async fetcher({ input, options, fetch }) {},
|
|
||||||
useHook:
|
|
||||||
({ fetch }) =>
|
|
||||||
() =>
|
|
||||||
async () => ({}),
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
import useAddItem, { UseAddItem } from '@commerce/customer/card/use-add-item'
|
|
||||||
import { MutationHook } from '@commerce/utils/types'
|
|
||||||
|
|
||||||
export default useAddItem as UseAddItem<typeof handler>
|
|
||||||
|
|
||||||
export const handler: MutationHook<any> = {
|
|
||||||
fetchOptions: {
|
|
||||||
query: '',
|
|
||||||
},
|
|
||||||
async fetcher({ input, options, fetch }) {},
|
|
||||||
useHook:
|
|
||||||
({ fetch }) =>
|
|
||||||
() =>
|
|
||||||
async () => ({}),
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
export * from '@commerce/product/use-price'
|
|
||||||
export { default } from '@commerce/product/use-price'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/cart'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/checkout'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/common'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/customer'
|
|
@ -1,12 +0,0 @@
|
|||||||
import * as Core from '@commerce/types/login'
|
|
||||||
import type { LoginMutationVariables } from '../schema'
|
|
||||||
import { LoginBody, LoginTypes } from '@commerce/types/login'
|
|
||||||
|
|
||||||
export * from '@commerce/types/login'
|
|
||||||
|
|
||||||
export type LoginHook<T extends LoginTypes = LoginTypes> = {
|
|
||||||
data: null
|
|
||||||
actionInput: LoginBody
|
|
||||||
fetcherInput: LoginBody
|
|
||||||
body: T['body']
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/logout'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/page'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/product'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/signup'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/site'
|
|
@ -1 +0,0 @@
|
|||||||
export * from '@commerce/types/wishlist'
|
|
17895
package-lock.json
generated
17895
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
165
package.json
165
package.json
@ -1,127 +1,62 @@
|
|||||||
{
|
{
|
||||||
"name": "nextjs-commerce",
|
"name": "commerce",
|
||||||
"version": "1.0.0",
|
|
||||||
"scripts": {
|
|
||||||
"dev": "NODE_OPTIONS='--inspect' next dev",
|
|
||||||
"build": "next build",
|
|
||||||
"start": "next start",
|
|
||||||
"analyze": "BUNDLE_ANALYZE=both next build",
|
|
||||||
"lint": "next lint",
|
|
||||||
"prettier-fix": "prettier --write .",
|
|
||||||
"find:unused": "npx next-unused",
|
|
||||||
"generate": "graphql-codegen",
|
|
||||||
"generate:shopify": "DOTENV_CONFIG_PATH=./.env.local graphql-codegen -r dotenv/config --config framework/shopify/codegen.json",
|
|
||||||
"generate:vendure": "graphql-codegen --config framework/vendure/codegen.json",
|
|
||||||
"generate:definitions": "node framework/bigcommerce/scripts/generate-definitions.js",
|
|
||||||
"generate:kibocommerce": "graphql-codegen --config framework/kibocommerce/codegen.json"
|
|
||||||
},
|
|
||||||
"sideEffects": false,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"private": true,
|
||||||
"node": ">=14.x"
|
"workspaces": [
|
||||||
|
"site",
|
||||||
|
"packages/*"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"prettier-fix": "prettier --write ."
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"turbo": {
|
||||||
"@chec/commerce.js": "^2.8.0",
|
"baseBranch": "origin/main",
|
||||||
"@react-spring/web": "^9.4.1",
|
"pipeline": {
|
||||||
"@spree/storefront-api-v2-sdk": "^5.1.1",
|
"build": {
|
||||||
"@vercel/fetch": "^6.1.1",
|
"dependsOn": [
|
||||||
"autoprefixer": "^10.4.2",
|
"^build"
|
||||||
"body-scroll-lock": "^4.0.0-beta.0",
|
],
|
||||||
"classnames": "^2.3.1",
|
"outputs": [
|
||||||
"cookie": "^0.4.1",
|
"dist/**"
|
||||||
"email-validator": "^2.0.4",
|
]
|
||||||
"immutability-helper": "^3.1.1",
|
},
|
||||||
"js-cookie": "^3.0.1",
|
"next-commerce#build": {
|
||||||
"keen-slider": "^6.6.3",
|
"dependsOn": [
|
||||||
"lodash.debounce": "^4.0.8",
|
"^build",
|
||||||
"lodash.random": "^3.2.0",
|
"$COMMERCE_PROVIDER"
|
||||||
"lodash.throttle": "^4.1.1",
|
],
|
||||||
"next": "^12.0.8",
|
"outputs": [
|
||||||
"next-seo": "^4.28.1",
|
".next/**"
|
||||||
"next-themes": "^0.0.15",
|
]
|
||||||
"postcss": "^8.4.5",
|
},
|
||||||
"react": "^17.0.2",
|
"test": {
|
||||||
"react-dom": "^17.0.2",
|
"dependsOn": [
|
||||||
"react-fast-marquee": "^1.3.1",
|
"^build"
|
||||||
"react-merge-refs": "^1.1.0",
|
],
|
||||||
"react-use-measure": "^2.1.1",
|
"outputs": []
|
||||||
"stripe": "^8.196.0",
|
},
|
||||||
"swell-js": "^4.0.0-next.0",
|
"lint": {
|
||||||
"swr": "^1.1.2",
|
"outputs": []
|
||||||
"tabbable": "^5.2.1",
|
},
|
||||||
"tailwindcss": "^3.0.13",
|
"prettier-fix": {
|
||||||
"uuidv4": "^6.2.12"
|
"outputs": []
|
||||||
|
},
|
||||||
|
"dev": {
|
||||||
|
"cache": false
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"cache": false
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@graphql-codegen/cli": "^1.21.5",
|
|
||||||
"@graphql-codegen/schema-ast": "^1.18.3",
|
|
||||||
"@graphql-codegen/typescript": "^1.22.2",
|
|
||||||
"@graphql-codegen/typescript-operations": "^1.18.1",
|
|
||||||
"@next/bundle-analyzer": "^12.0.8",
|
|
||||||
"@types/body-scroll-lock": "^3.1.0",
|
|
||||||
"@types/chec__commerce.js": "^2.8.4",
|
|
||||||
"@types/cookie": "^0.4.1",
|
|
||||||
"@types/js-cookie": "^3.0.1",
|
|
||||||
"@types/lodash.debounce": "^4.0.6",
|
|
||||||
"@types/lodash.random": "^3.2.6",
|
|
||||||
"@types/lodash.throttle": "^4.1.6",
|
|
||||||
"@types/node": "^17.0.8",
|
|
||||||
"@types/react": "^17.0.38",
|
|
||||||
"deepmerge": "^4.2.2",
|
|
||||||
"eslint": "^8.6.0",
|
|
||||||
"eslint-config-next": "^12.0.8",
|
|
||||||
"eslint-config-prettier": "^8.3.0",
|
|
||||||
"graphql": "^15.5.1",
|
|
||||||
"husky": "^7.0.4",
|
"husky": "^7.0.4",
|
||||||
"lint-staged": "^12.1.7",
|
|
||||||
"postcss-flexbugs-fixes": "^5.0.2",
|
|
||||||
"postcss-preset-env": "^7.2.3",
|
|
||||||
"prettier": "^2.5.1",
|
"prettier": "^2.5.1",
|
||||||
"typescript": "4.5.4"
|
"turbo": "^1.0.28"
|
||||||
},
|
},
|
||||||
"husky": {
|
"husky": {
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"pre-commit": "lint-staged"
|
"pre-commit": "turbo run lint"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"lint-staged": {
|
|
||||||
"**/*.{js,jsx,ts,tsx}": [
|
|
||||||
"eslint",
|
|
||||||
"prettier --write",
|
|
||||||
"git add"
|
|
||||||
],
|
|
||||||
"**/*.{md,mdx,json}": [
|
|
||||||
"prettier --write",
|
|
||||||
"git add"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"next-unused": {
|
|
||||||
"alias": {
|
|
||||||
"@lib/*": [
|
|
||||||
"lib/*"
|
|
||||||
],
|
|
||||||
"@assets/*": [
|
|
||||||
"assets/*"
|
|
||||||
],
|
|
||||||
"@config/*": [
|
|
||||||
"config/*"
|
|
||||||
],
|
|
||||||
"@components/*": [
|
|
||||||
"components/*"
|
|
||||||
],
|
|
||||||
"@utils/*": [
|
|
||||||
"utils/*"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"debug": true,
|
|
||||||
"include": [
|
|
||||||
"components",
|
|
||||||
"lib",
|
|
||||||
"pages"
|
|
||||||
],
|
|
||||||
"exclude": [],
|
|
||||||
"entrypoints": [
|
|
||||||
"pages"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
packages/bigcommerce/.prettierignore
Normal file
2
packages/bigcommerce/.prettierignore
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
6
packages/bigcommerce/.prettierrc
Normal file
6
packages/bigcommerce/.prettierrc
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"semi": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"tabWidth": 2,
|
||||||
|
"useTabs": false
|
||||||
|
}
|
@ -9,7 +9,7 @@ With the deploy button below you'll be able to have a [BigCommerce](https://www.
|
|||||||
If you already have a BigCommerce account and want to use your current store, then copy the `.env.template` file in this directory to `.env.local` in the main directory (which will be ignored by Git):
|
If you already have a BigCommerce account and want to use your current store, then copy the `.env.template` file in this directory to `.env.local` in the main directory (which will be ignored by Git):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cp framework/bigcommerce/.env.template .env.local
|
cp packages/bigcommerce/.env.template .env.local
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, set the environment variables in `.env.local` to match the ones from your store.
|
Then, set the environment variables in `.env.local` to match the ones from your store.
|
@ -8,16 +8,16 @@
|
|||||||
},
|
},
|
||||||
"documents": [
|
"documents": [
|
||||||
{
|
{
|
||||||
"./framework/bigcommerce/api/**/*.ts": {
|
"./src/api/**/*.ts": {
|
||||||
"noRequire": true
|
"noRequire": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"generates": {
|
"generates": {
|
||||||
"./framework/bigcommerce/schema.d.ts": {
|
"./schema.d.ts": {
|
||||||
"plugins": ["typescript", "typescript-operations"]
|
"plugins": ["typescript", "typescript-operations"]
|
||||||
},
|
},
|
||||||
"./framework/bigcommerce/schema.graphql": {
|
"./schema.graphql": {
|
||||||
"plugins": ["schema-ast"]
|
"plugins": ["schema-ast"]
|
||||||
}
|
}
|
||||||
},
|
},
|
80
packages/bigcommerce/package.json
Normal file
80
packages/bigcommerce/package.json
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
{
|
||||||
|
"name": "@vercel/commerce-bigcommerce",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"license": "MIT",
|
||||||
|
"scripts": {
|
||||||
|
"build": "rm -fr dist/* && tsc",
|
||||||
|
"dev": "npm run build -- --watch",
|
||||||
|
"prettier-fix": "prettier --write .",
|
||||||
|
"generate:definitions": "node scripts/generate-definitions.js"
|
||||||
|
},
|
||||||
|
"sideEffects": false,
|
||||||
|
"type": "module",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist/index.js",
|
||||||
|
"./*": [
|
||||||
|
"./dist/*.js",
|
||||||
|
"./dist/*/index.js"
|
||||||
|
],
|
||||||
|
"./next.config": "./dist/next.config.cjs"
|
||||||
|
},
|
||||||
|
"typesVersions": {
|
||||||
|
"*": {
|
||||||
|
"*": [
|
||||||
|
"src/*",
|
||||||
|
"src/*/index"
|
||||||
|
],
|
||||||
|
"next.config": [
|
||||||
|
"dist/next.config.d.cts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"publishConfig": {
|
||||||
|
"typesVersions": {
|
||||||
|
"*": {
|
||||||
|
"*": [
|
||||||
|
"dist/*.d.ts",
|
||||||
|
"dist/*/index.d.ts"
|
||||||
|
],
|
||||||
|
"config": [
|
||||||
|
"dist/next.config.d.cts"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@vercel/fetch": "^6.1.1",
|
||||||
|
"cookie": "^0.4.1",
|
||||||
|
"immutability-helper": "^3.1.1",
|
||||||
|
"jsonwebtoken": "^8.5.1",
|
||||||
|
"lodash.debounce": "^4.0.8",
|
||||||
|
"uuidv4": "^6.2.12"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"next": "^12",
|
||||||
|
"react": "^17",
|
||||||
|
"react-dom": "^17"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/cookie": "^0.4.1",
|
||||||
|
"@types/jsonwebtoken": "^8.5.7",
|
||||||
|
"@types/lodash.debounce": "^4.0.6",
|
||||||
|
"@types/node": "^17.0.8",
|
||||||
|
"@types/react": "^17.0.38",
|
||||||
|
"lint-staged": "^12.1.7",
|
||||||
|
"next": "^12.0.8",
|
||||||
|
"prettier": "^2.5.1",
|
||||||
|
"react": "^17.0.2",
|
||||||
|
"react-dom": "^17.0.2",
|
||||||
|
"typescript": "^4.5.4"
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"**/*.{js,jsx,ts,tsx,json}": [
|
||||||
|
"prettier --write",
|
||||||
|
"git add"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import cartEndpoint from '@commerce/api/endpoints/cart'
|
import cartEndpoint from '@vercel/commerce/api/endpoints/cart'
|
||||||
import type { CartSchema } from '../../../types/cart'
|
import type { CartSchema } from '../../../types/cart'
|
||||||
import type { BigcommerceAPI } from '../..'
|
import type { BigcommerceAPI } from '../..'
|
||||||
import getCart from './get-cart'
|
import getCart from './get-cart'
|
@ -1,4 +1,4 @@
|
|||||||
import { Product } from '@commerce/types/product'
|
import { Product } from '@vercel/commerce/types/product'
|
||||||
import { ProductsEndpoint } from '.'
|
import { ProductsEndpoint } from '.'
|
||||||
|
|
||||||
const SORT: { [key: string]: string | undefined } = {
|
const SORT: { [key: string]: string | undefined } = {
|
@ -1,5 +1,5 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import productsEndpoint from '@commerce/api/endpoints/catalog/products'
|
import productsEndpoint from '@vercel/commerce/api/endpoints/catalog/products'
|
||||||
import type { ProductsSchema } from '../../../../types/product'
|
import type { ProductsSchema } from '../../../../types/product'
|
||||||
import type { BigcommerceAPI } from '../../..'
|
import type { BigcommerceAPI } from '../../..'
|
||||||
import getProducts from './get-products'
|
import getProducts from './get-products'
|
@ -1,5 +1,5 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@commerce/api'
|
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
||||||
import checkoutEndpoint from '@commerce/api/endpoints/checkout'
|
import checkoutEndpoint from '@vercel/commerce/api/endpoints/checkout'
|
||||||
import type { CheckoutSchema } from '../../../types/checkout'
|
import type { CheckoutSchema } from '../../../types/checkout'
|
||||||
import type { BigcommerceAPI } from '../..'
|
import type { BigcommerceAPI } from '../..'
|
||||||
import getCheckout from './get-checkout'
|
import getCheckout from './get-checkout'
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user