From 8096ab5ec6264d256d367d3220e952563045a1d7 Mon Sep 17 00:00:00 2001 From: Arthur Andrade Date: Fri, 20 Dec 2024 18:42:22 -0300 Subject: [PATCH] feat: Add copy plugin public files --- packages/cli/src/utils/plugins.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/cli/src/utils/plugins.ts b/packages/cli/src/utils/plugins.ts index 6f8a21d0a4..cf188825cb 100644 --- a/packages/cli/src/utils/plugins.ts +++ b/packages/cli/src/utils/plugins.ts @@ -96,6 +96,29 @@ const copyPluginsSrc = async (basePath: string, plugins: Plugin[]) => { }) } +const copyPluginPublicFiles = async (basePath: string, plugins: Plugin[]) => { + const { tmpDir, getPackagePath } = withBasePath(basePath) + + logger.log('Copying plugin public files') + + plugins.forEach(async (plugin) => { + const pluginName = getPluginName(plugin) + const pluginPath = getPackagePath(getPluginName(pluginName)) + + try { + if (existsSync(`${pluginPath}/public`)) { + copySync(`${pluginPath}/public`, `${tmpDir}/public`, { + dereference: true, + overwrite: true, + }) + logger.log(`Plugin public files copied`) + } + } catch (e) { + logger.error(e) + } + }) +} + const getPluginPageFileContent = ( pluginName: string, pageName: string, @@ -285,6 +308,7 @@ export const installPlugins = async (basePath: string) => { const plugins = await getPluginsList(basePath) copyPluginsSrc(basePath, plugins) + copyPluginPublicFiles(basePath, plugins) generatePluginPages(basePath, plugins) addPluginsSections(basePath, plugins) addPluginsOverrides(basePath, plugins)