Skip to content

Commit

Permalink
feat: apply adjusts in hcms
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurTriis1 committed Nov 14, 2024
1 parent f681703 commit 61a18b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
8 changes: 4 additions & 4 deletions packages/cli/src/utils/hcms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ export async function mergeCMSFile(fileName: string, basePath: string) {

const plugins = await getPluginsList(basePath)

const pluginPaths = plugins.map((plugin) =>
getPackagePath(getPluginName(plugin), 'src', 'cms', fileName)
const pluginCMSFilePaths = plugins.map((plugin) =>
getPackagePath(getPluginName(plugin), 'cms', 'faststore', fileName)
)

const customizations = [...pluginPaths, customFilePath].filter((pluginPath) =>
existsSync(pluginPath)
const customizations = [...pluginCMSFilePaths, customFilePath].filter(
(pluginCMSFilePath) => existsSync(pluginCMSFilePath)
)

// TODO: create a validation when the CMS files exist but don't have a component for them
Expand Down
11 changes: 8 additions & 3 deletions packages/cli/src/utils/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ const getPluginSrcPath = async (basePath: string, pluginName: string) => {
export const getPluginsList = async (basePath: string): Promise<Plugin[]> => {
const { tmpStoreConfigFile } = withBasePath(basePath)

const { plugins = [] } = await import(tmpStoreConfigFile)
try {
const { plugins } = await import(tmpStoreConfigFile)
return plugins
} catch (error) {
logger.error(`Could not load plugins from store config`)
}

return plugins
return []
}

const copyPluginsSrc = async (basePath: string, plugins: Plugin[]) => {
Expand Down Expand Up @@ -94,7 +99,7 @@ const getPluginPageFileContent = (
import * as page from 'src/plugins/${pluginName}/pages/${pageName}';
${appLayout ? `import GlobalSections, { getGlobalSectionsData } from 'src/components/cms/GlobalSections'` : ``}
export async function getStaticProps({previewData}) {
export async function getStaticProps(${appLayout ? '{previewData}' : ''}) {
const noop = async function() {}
const loaderData = await (page.loader || noop)()
${appLayout ? `const globalSections = await getGlobalSectionsData(previewData)` : ``}
Expand Down

0 comments on commit 61a18b3

Please sign in to comment.