mirror of
https://github.com/vercel/commerce.git
synced 2025-07-27 04:01:23 +00:00
tweaks
This commit is contained in:
@@ -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()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user