Files
dokploy/packages/server/src/db/schema/utils.ts
Mauricio Siu d4a98eb85e refactor(templates): remove legacy template files and update project structure
- Delete all template-related files in `apps/dokploy/templates`
- Remove template image files from `apps/dokploy/public/templates`
- Update server-side template processing with new implementation
- Clean up unused configuration and utility files
2025-03-09 21:09:05 -06:00

31 lines
988 B
TypeScript

import { generatePassword } from "@dokploy/server/templates";
import { faker } from "@faker-js/faker";
import { customAlphabet } from "nanoid";
const alphabet = "abcdefghijklmnopqrstuvwxyz123456789";
const customNanoid = customAlphabet(alphabet, 6);
export const generateAppName = (type: string) => {
const verb = faker.hacker.verb().replace(/ /g, "-");
const adjective = faker.hacker.adjective().replace(/ /g, "-");
const noun = faker.hacker.noun().replace(/ /g, "-");
const randomFakerElement = `${verb}-${adjective}-${noun}`;
const nanoidPart = customNanoid();
return `${type}-${randomFakerElement}-${nanoidPart}`;
};
export const cleanAppName = (appName?: string) => {
if (!appName) {
return appName?.toLowerCase();
}
return appName.trim().replace(/ /g, "-").toLowerCase();
};
export const buildAppName = (type: string, baseAppName?: string) => {
if (baseAppName) {
return `${cleanAppName(baseAppName)}-${generatePassword(6)}`;
}
return generateAppName(type);
};