diff --git a/packages/cli/src/app/src/api/configuration/mutations.ts b/packages/cli/src/app/src/api/configuration/mutations.ts index a7c9cd4a..f1ca7f32 100644 --- a/packages/cli/src/app/src/api/configuration/mutations.ts +++ b/packages/cli/src/app/src/api/configuration/mutations.ts @@ -48,6 +48,7 @@ export const applyConfiguration = async ({}: apiInputFromSchema> = { configuration } diff --git a/packages/cli/src/app/src/lib/configuration/index.ts b/packages/cli/src/app/src/lib/configuration/index.ts index cd5d7745..8cf768c6 100644 --- a/packages/cli/src/app/src/lib/configuration/index.ts +++ b/packages/cli/src/app/src/lib/configuration/index.ts @@ -31,13 +31,13 @@ const webConfigToApiConfig = (webConfig: TConfiguration): z.infer { return { name: plugin.sourcePath, - paths: plugin.paths.map((p) => p.to), + paths: plugin.paths, } }), }) return content } catch (error) { - logger.error(error) + logger.error("Failed to convert the web configuration", error) throw new TRPCError({ message: `Failed to convert the web configuration`, code: "INTERNAL_SERVER_ERROR", diff --git a/packages/cli/src/functions/apply-config/index.ts b/packages/cli/src/functions/apply-config/index.ts index d1c71d89..8ac6a23a 100644 --- a/packages/cli/src/functions/apply-config/index.ts +++ b/packages/cli/src/functions/apply-config/index.ts @@ -37,6 +37,7 @@ export const applyConfig = async () => { configFileName, pluginsDirectory, root, + noTask: false, }).catch(() => { process.exit(1) }) diff --git a/packages/scripts/src/utils/template-config/apply.ts b/packages/scripts/src/utils/template-config/apply.ts index 3669daaf..95292d33 100644 --- a/packages/scripts/src/utils/template-config/apply.ts +++ b/packages/scripts/src/utils/template-config/apply.ts @@ -56,7 +56,7 @@ export const applyConfigurationTask = async ({ throw error } - //* Apply plugins + //* Verify plugins if (applyConfigTask) applyConfigTask.log("Applying plugins") else logger.info("Applying plugins") @@ -114,7 +114,8 @@ export const applyConfigurationTask = async ({ const pluginConfigPath = path.join(pluginPath, configFileName) const pluginConfig = (await fs.readJson(pluginConfigPath)) as TPluginConfig // Copy the plugin to the destination - for (const { from, to } of pluginConfig.paths) { + for (const { from, to: defaultTo } of pluginConfig.paths) { + const to = typeof plugin === "string" ? defaultTo : (plugin.paths.find((p) => p.from === from)?.to ?? defaultTo) const sourcePath = path.join(pluginPath, from) const destinationPath = path.join(root, to) if (applyConfigTask) applyConfigTask.log(`Copying the plugin ${pluginName} to the destination ${destinationPath}`) diff --git a/packages/scripts/src/utils/template-config/index.ts b/packages/scripts/src/utils/template-config/index.ts index b035d386..4f838456 100644 --- a/packages/scripts/src/utils/template-config/index.ts +++ b/packages/scripts/src/utils/template-config/index.ts @@ -17,21 +17,26 @@ export function isPathInCurrentScope(filePath: string): boolean { export const fullPluginSchema = z.object({ name: z.string(), paths: z.array( - z - .string() - .optional() - .refine( + z.object({ + from: z.string().refine( (value) => { - if (value === undefined) { - return true + if (!isPathInCurrentScope(value)) { + return false } + return true + }, + { message: "The path should be relative and in the current directory" } + ), + to: z.string().refine( + (value) => { if (!isPathInCurrentScope(value)) { return false } return true }, { message: "The path should be relative and in the current directory" } - ) + ), + }) ), })