From 28a6d82a407ed547b5c4abf16a0dec2bda8335a0 Mon Sep 17 00:00:00 2001 From: Pkmmte Xeleon Date: Sat, 7 Oct 2023 00:34:29 -0700 Subject: [PATCH] fix(build): always use native slashes when merging manifest plugins Simply because that's the syntax that Node expects for imports in non-Windows platforms. This ensures that they're always native to the host being run on. Yay for portability! --- .changeset/dull-flies-doubt.md | 5 +++++ packages/robo/src/cli/utils/manifest.ts | 10 ++++++++-- packages/robo/src/core/config.ts | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 .changeset/dull-flies-doubt.md diff --git a/.changeset/dull-flies-doubt.md b/.changeset/dull-flies-doubt.md new file mode 100644 index 000000000..131e18b2b --- /dev/null +++ b/.changeset/dull-flies-doubt.md @@ -0,0 +1,5 @@ +--- +'@roboplay/robo.js': patch +--- + +fix(build): always use native slashes when merging manifest plugins diff --git a/packages/robo/src/cli/utils/manifest.ts b/packages/robo/src/cli/utils/manifest.ts index bf1bd0295..d045f4845 100644 --- a/packages/robo/src/cli/utils/manifest.ts +++ b/packages/robo/src/cli/utils/manifest.ts @@ -214,6 +214,7 @@ export async function loadManifest(name = '', basePath = ''): Promise Object.keys(manifest.api ?? {}).forEach((key) => { manifest.api[key].__auto = true + manifest.api[key].__path = manifest.api[key].__path.replaceAll('\\', path.sep) manifest.api[key].__plugin = { name, path: basePath @@ -221,6 +222,7 @@ export async function loadManifest(name = '', basePath = ''): Promise }) Object.keys(manifest.commands).forEach((key) => { manifest.commands[key].__auto = true + manifest.commands[key].__path = manifest.commands[key].__path.replaceAll('\\', path.sep) manifest.commands[key].__plugin = { name, path: basePath @@ -228,6 +230,7 @@ export async function loadManifest(name = '', basePath = ''): Promise }) Object.keys(manifest.context?.message ?? {}).forEach((key) => { manifest.context.message[key].__auto = true + manifest.context.message[key].__path = manifest.context.message[key].__path.replaceAll('\\', path.sep) manifest.context.message[key].__plugin = { name, path: basePath @@ -235,6 +238,7 @@ export async function loadManifest(name = '', basePath = ''): Promise }) Object.keys(manifest.context?.user ?? {}).forEach((key) => { manifest.context.user[key].__auto = true + manifest.context.user[key].__path = manifest.context.user[key].__path.replaceAll('\\', path.sep) manifest.context.user[key].__plugin = { name, path: basePath @@ -243,12 +247,14 @@ export async function loadManifest(name = '', basePath = ''): Promise Object.keys(manifest.events).forEach((key) => { manifest.events[key] = manifest.events[key].map((eventConfig) => ({ ...pluginInfo, - ...eventConfig + ...eventConfig, + __path: eventConfig.__path.replaceAll('\\', path.sep) })) }) manifest.middleware = manifest.middleware?.map((middleware) => ({ ...pluginInfo, - ...middleware + ...middleware, + __path: middleware.__path.replaceAll('\\', path.sep) })) } diff --git a/packages/robo/src/core/config.ts b/packages/robo/src/core/config.ts index 68bdf57b6..8e9a8f31d 100644 --- a/packages/robo/src/core/config.ts +++ b/packages/robo/src/core/config.ts @@ -26,6 +26,7 @@ export async function loadConfig(file = 'robo'): Promise { // Load plugin files when using "/config" directory if (configPath.includes(path.sep + 'config' + path.sep)) { logger.debug('Scanning for plugin files...') + config.plugins = config.plugins ?? [] await scanPlugins(fileURLToPath(configPath), (plugin, pluginConfig) => { // Remove existing plugin config if it exists