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