Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | 1x 1x 1x 1x 1x 51x 1x 4x 1x 4x 50x 50x 3x 3x 3x 2x 3x 3x 3x 1x 3x 3x 3x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import path from 'path'; import { ensureDirSync } from 'fs-extra'; import { constants } from '../../../tools'; import { existsMustBeDir, dumpJSON, loadJSON, isFile } from '../../../utils'; import { DirectoryHandler } from '.'; import DirectoryContext from '..'; import { ParsedAsset } from '../../../types'; import { Prompts, PromptSettings, AllPromptsByLanguage, } from '../../../tools/auth0/handlers/prompts'; type ParsedPrompts = ParsedAsset<'prompts', Prompts>; const getPromptsDirectory = (filePath: string) => { return path.join(filePath, constants.PROMPTS_DIRECTORY); }; const getPromptsSettingsFile = (promptsDirectory: string) => { return path.join(promptsDirectory, 'prompts.json'); }; const getCustomTextFile = (promptsDirectory: string) => { return path.join(promptsDirectory, 'custom-text.json'); }; function parse(context: DirectoryContext): ParsedPrompts { const promptsDirectory = getPromptsDirectory(context.filePath); if (!existsMustBeDir(promptsDirectory)) return { prompts: null }; // Skip const promptsSettings = (() => { const promptsSettingsFile = getPromptsSettingsFile(promptsDirectory); if (!isFile(promptsSettingsFile)) return {}; return loadJSON(promptsSettingsFile, { mappings: context.mappings, disableKeywordReplacement: context.disableKeywordReplacement, }) as PromptSettings; })(); const customText = (() => { const customTextFile = getCustomTextFile(promptsDirectory); if (!isFile(customTextFile)) return {}; return loadJSON(customTextFile, { mappings: context.mappings, disableKeywordReplacement: context.disableKeywordReplacement, }) as AllPromptsByLanguage; })(); return { prompts: { ...promptsSettings, customText, }, }; } async function dump(context: DirectoryContext): Promise<void> { const { prompts } = context.assets; if (!prompts) return; const { customText, ...promptsSettings } = prompts; const promptsDirectory = getPromptsDirectory(context.filePath); ensureDirSync(promptsDirectory); Iif (!promptsSettings) return; const promptsSettingsFile = getPromptsSettingsFile(promptsDirectory); dumpJSON(promptsSettingsFile, promptsSettings); Iif (!customText) return; const customTextFile = getCustomTextFile(promptsDirectory); dumpJSON(customTextFile, customText); } const promptsHandler: DirectoryHandler<ParsedPrompts> = { parse, dump, }; export default promptsHandler; |