@next-boilerplate/cli-helpers
Version:
CLI helper for Next Boilerplate
61 lines (58 loc) • 1.66 kB
JavaScript
import { z } from 'zod';
import { isPathInCurrentScope } from '../utils/index.mjs';
import 'path';
const pluginsFolder = "plugins";
const pluginConfigFileName = "config.json";
const pluginSchema = z.object({
// The name of the plugin the a config file correspond to its relative path from the store (not it's real name)
name: z.string().max(100),
paths: z.array(
z.object({
from: z.string().refine(
(value) => {
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" }
)
})
)
});
const pluginConfigSchema = z.object({
name: z.string().max(100),
description: z.string().max(300),
paths: z.array(
z.object({
from: z.string().refine(
(value) => {
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" }
)
})
)
});
export { pluginConfigFileName, pluginConfigSchema, pluginSchema, pluginsFolder };