mirror of
https://github.com/vercel/commerce.git
synced 2025-05-19 07:56:59 +00:00
tweaks
This commit is contained in:
parent
914d75dc8d
commit
3906917161
@ -11,14 +11,17 @@ const agilityConfig = {
|
||||
};
|
||||
|
||||
const getSyncClient = ({ isPreview, isDevelopmentMode }) => {
|
||||
let cachePath = `node_modules/@agility/content-sync/cache/${
|
||||
|
||||
const rootPath = process.cwd()
|
||||
|
||||
let cachePath = `${rootPath}/.next/cache/agility/${
|
||||
isPreview ? "preview" : "live"
|
||||
}`;
|
||||
|
||||
if (!isDevelopmentMode) {
|
||||
//we are in prod and need to use a different directory that Vercel understands
|
||||
cachePath = `/tmp/agilitycache/${isPreview ? "preview" : "live"}`;
|
||||
}
|
||||
// if (!isDevelopmentMode) {
|
||||
// //we are in prod and need to use a different directory that Vercel understands
|
||||
// cachePath = `/tmp/agilitycache/${isPreview ? "preview" : "live"}`;
|
||||
// }
|
||||
|
||||
console.log(`Agility CMS => Content cache path is ${cachePath}`);
|
||||
const apiKey = isPreview
|
||||
|
@ -22,6 +22,27 @@ const runSync = async () => {
|
||||
await agilitySyncClient.runSync();
|
||||
}
|
||||
|
||||
const syncAll = async () => {
|
||||
|
||||
//sync preview mode
|
||||
let agilitySyncClient = getSyncClient({ isPreview: true, isDevelopmentMode: false })
|
||||
if (! agilitySyncClient) {
|
||||
console.log("Agility CMS => Sync client could not be accessed.")
|
||||
return;
|
||||
}
|
||||
|
||||
await agilitySyncClient.runSync();
|
||||
|
||||
//sync production mode
|
||||
agilitySyncClient = getSyncClient({ isPreview: false, isDevelopmentMode: false })
|
||||
if (! agilitySyncClient) {
|
||||
console.log("Agility CMS => Sync client could not be accessed.")
|
||||
return;
|
||||
}
|
||||
|
||||
await agilitySyncClient.runSync();
|
||||
}
|
||||
|
||||
const clearSync = async () => {
|
||||
|
||||
const agilitySyncClient = getSyncClient({ isPreview: true, isDevelopmentMode: true })
|
||||
@ -42,6 +63,10 @@ if (process.argv[2]) {
|
||||
//run the sync
|
||||
return runSync()
|
||||
|
||||
} else if (process.argv[2] === "sync-all") {
|
||||
//sync both staging and live content
|
||||
return syncAll()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,8 @@
|
||||
"name": "nextjs-commerce",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"dev": "next dev",
|
||||
"prebuild": "node framework/agility/agility.sync.js sync-all",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"analyze": "BUNDLE_ANALYZE=both yarn build",
|
||||
|
Loading…
x
Reference in New Issue
Block a user