UNPKG

sb-mig

Version:

CLI to rule the world. (and handle stuff related to Storyblok CMS)

20 lines (19 loc) 961 B
export const sanitizeOutputFileBaseName = (value) => { const sanitized = value .trim() .replace(/[\\/]/g, "-") .replace(/\s+/g, "-") .replace(/[^a-zA-Z0-9._-]/g, "-") .replace(/-+/g, "-") .replace(/^[-.]+|[-.]+$/g, ""); return sanitized || "migration-output"; }; export const resolveOutputFileBaseName = ({ from, fileName, }) => { if (typeof fileName === "string" && fileName.trim().length > 0) { return sanitizeOutputFileBaseName(fileName); } return sanitizeOutputFileBaseName(from); }; export const shouldUseDatestampForArtifacts = (fileName) => !(typeof fileName === "string" && fileName.trim().length > 0); export const buildPreMigrationBackupBaseName = ({ from, fileName, }) => `before__${resolveOutputFileBaseName({ from, fileName })}`; export const buildStoryBackupBaseName = ({ from, fileName, }) => `${resolveOutputFileBaseName({ from, fileName })}--backup-before-migration`;