Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
840dd8f
feat: initial provider setup (from local)
BolajiAyodeji Jul 6, 2021
d47908d
feat: add Config and fetchApi
BolajiAyodeji Jul 9, 2021
4adba68
chore: Fix types errors
acasazza Jul 9, 2021
4b27c48
feat(auth): draft auth implementation
BolajiAyodeji Jul 14, 2021
49477b6
feat: Activate cart and customerAuth
acasazza Jul 15, 2021
1201388
chore: add products data
BolajiAyodeji Aug 5, 2021
42a02d4
chore: add product images
BolajiAyodeji Aug 6, 2021
0f381d4
feat: Add customer authentication
acasazza Aug 6, 2021
bbfe3f2
docs: add framework README
BolajiAyodeji Aug 10, 2021
eaf96ba
feat: Add static prices and sales_channel auth
acasazza Aug 11, 2021
1f0c79e
refactor: update auth and fix error handling
BolajiAyodeji Aug 17, 2021
b3911fe
feat: Add update and remove item
acasazza Aug 17, 2021
4f4dd1d
fix: Update shopping bag
acasazza Aug 24, 2021
4594443
feat(checkout): add draft external checkout endpoint
BolajiAyodeji Aug 30, 2021
c2c60d9
style: update config name
BolajiAyodeji Aug 31, 2021
ce0bcfe
feat: Redirect to external checkout
acasazza Aug 31, 2021
8f2b769
refactor: add useCustomer and refactor Auth
BolajiAyodeji Sep 2, 2021
e26a149
feat: add draft logout
BolajiAyodeji Sep 2, 2021
187739c
fix: fix issue with /cart page
BolajiAyodeji Sep 2, 2021
7cc48a9
docs: update provider docs and cleanup
BolajiAyodeji Sep 9, 2021
16a9862
refactor: update external checkout and docs
BolajiAyodeji Sep 16, 2021
1cb1824
fix: Customer request without customerId
acasazza Sep 28, 2021
88dcc56
fix: Add mutate instead of revalidate
acasazza Sep 29, 2021
f33cb3f
chore: update docs and cleanup
BolajiAyodeji Oct 1, 2021
d1ea235
feat: Add search products by name
acasazza Oct 12, 2021
90fbe59
fix: Search text result
acasazza Oct 13, 2021
93d5fc0
feat: Add wishlist
acasazza Oct 14, 2021
7034460
fix: Import data
acasazza Oct 14, 2021
3c64a25
feat: Add categories
acasazza Oct 15, 2021
c4ec67a
chore: update env template variables
BolajiAyodeji Nov 23, 2021
efc8a01
fix: Remove custom code and clean all code
acasazza Dec 17, 2021
b96967a
fix: update vendor attribute
BolajiAyodeji Dec 20, 2021
5ce7688
chore: Revert wrong code clening
acasazza Dec 20, 2021
6c06058
fix: Wishlist flow
acasazza Dec 20, 2021
8d9fb87
refactor: change order of items
BolajiAyodeji Dec 20, 2021
04950c7
refactor: update env template and README
BolajiAyodeji Dec 21, 2021
8f341f9
refactor: change import from '@framework' to relative imports
BolajiAyodeji Dec 21, 2021
a5a20d9
refactor: update framework imports
BolajiAyodeji Dec 22, 2021
59d25e3
refactor: refactor index.ts and add missing files
BolajiAyodeji Dec 26, 2021
217a8f3
fix: fix type errors
BolajiAyodeji Jan 5, 2022
0f5cdf9
fix: Clean order if it is placed
acasazza Jan 5, 2022
dbecda6
fix: Clean order
acasazza Jan 5, 2022
0ea2929
chore: Revert core changes
acasazza Jan 11, 2022
4da115d
fix: Read and add wishlist items
acasazza Jan 11, 2022
5a44750
Update WishlistButton.tsx
acasazza Jan 11, 2022
5db8d15
refactor: update image source and cleanup
BolajiAyodeji Jan 25, 2022
553fbc8
chore: remove local images and domain
BolajiAyodeji Jan 26, 2022
8cac636
refactor: update normalize line items (image)
BolajiAyodeji Jan 28, 2022
4dbe8b5
refactor: fix cart items routing
BolajiAyodeji Feb 8, 2022
c9ee224
chore: remove unused import
BolajiAyodeji Feb 8, 2022
7e5896e
chore: 🤖 fix conflicts
BolajiAyodeji Feb 28, 2022
e8a12e4
refactor: 💡 update commercelayer provider structure
BolajiAyodeji Feb 28, 2022
57c8d78
chore: 🤖 revert site/tsconfig.json
BolajiAyodeji Feb 28, 2022
46fff00
fix: 🐛 fix error with checkout endpoint
BolajiAyodeji Mar 1, 2022
b9f8d09
chore: Update deps
acasazza May 10, 2022
6565266
feat: Add get content data from static file and get prices from CL
acasazza May 10, 2022
9ccbc55
chore: Update config
acasazza May 10, 2022
a9e2d75
feat: Get products from external static file
acasazza May 10, 2022
f11ff29
feat: Update hooks
acasazza May 10, 2022
9e68d2e
chore: 🤖 update env variables
BolajiAyodeji May 13, 2022
614369a
chore: 🤖 use env from CONST
BolajiAyodeji May 13, 2022
8840bb7
chore: 🤖 update ENDPOINT env in cart
BolajiAyodeji May 13, 2022
bc9866f
fix: Remove unused code and add hosted checkout url
acasazza May 13, 2022
395a21e
fix: Import sdk
acasazza May 13, 2022
6c254a6
docs: ✏️ update docs
BolajiAyodeji May 13, 2022
67f7a54
Merge branch 'main' into commercelayer-provider
BolajiAyodeji May 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Next: Chrome",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "launch",
"name": "Next: Node",
"runtimeExecutable": "yarn",
"runtimeArgs": ["run", "dev"],
"outputCapture": "std"
}
],
"compounds": [
{
"name": "Next: Full",
"configurations": ["Next: Node", "Next: Chrome"]
}
]
}
93 changes: 93 additions & 0 deletions framework/commerce/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/**
* 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',
'commercelayer'
]

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 }
Loading