GT2/Ejectable/node_modules/@expo/configure-splash-screen/build/validators/utils.js.map

1 line
4.4 KiB
Plaintext
Raw Normal View History

2021-08-16 00:14:59 +00:00
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/validators/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAkD;AAClD,6CAA+B;AAC/B,mCAA6B;AAC7B,gDAAwB;AAIxB;;;GAGG;AACH,SAAgB,iBAAiB,CAC/B,KAAa,EACb,eAAkB;IAElB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAS,eAAe,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QAC3D,MAAM,IAAI,KAAK,CACb,kBAAkB,KAAK,2BAA2B,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC;aAC7E,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC;aAClB,IAAI,CAAC,KAAK,CAAC,GAAG,CAClB,CAAC;KACH;IACD,OAAO,KAAmB,CAAC;AAC7B,CAAC;AAZD,8CAYC;AAED;;;GAGG;AACI,KAAK,UAAU,iBAAiB,CAAC,QAAgB;IACtD,MAAM,YAAY,GAAG,MAAM,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAExD,gDAAgD;IAChD,IAAI,cAAI,CAAC,OAAO,CAAC,YAAY,CAAC,KAAK,MAAM,EAAE;QACzC,MAAM,IAAI,KAAK,CACb,iBAAiB,QAAQ,4EAA4E,CACtG,CAAC;KACH;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAVD,8CAUC;AAED;;;GAGG;AACI,KAAK,UAAU,kBAAkB,CAAC,QAAgB;IACvD,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5C,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,EAAE;QACxC,MAAM,IAAI,KAAK,CACb,iBAAiB,QAAQ,8DAA8D,CACxF,CAAC;KACH;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AARD,gDAQC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,KAAa;;IACzC,MAAM,MAAM,SAAG,sBAAW,CAAC,GAAG,CAAC,KAAK,CAAC,0CAAE,KAAK,CAAC;IAC7C,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CACb,kBAAkB,KAAK,gEAAgE,CACxF,CAAC;KACH;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AARD,sCAQC;AAED,SAAgB,yBAAyB,CAAmC,eAAkB;IAC5F,OAAO,CAAC,KAAa,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;AACtE,CAAC;AAFD,8DAEC;AAED,SAAgB,oBAAoB,CAKlC,MAAS,EAAE,YAAkD;IAC7D,MAAM,KAAK,GAAG,YAAG,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,CAAC,CAAC;IACnD,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,MAAM,IAAI,KAAK,CACb,uCAAuC,YAAY,CAAC,IAAI,CACtD,GAAG,CACJ,0DAA0D,CAC5D,CAAC;KACH;AACH,CAAC;AAdD,oDAcC","sourcesContent":["import colorString, { Color } from 'color-string';\nimport * as fs from 'fs-extra';\nimport { get } from 'lodash';\nimport path from 'path';\n\nimport { NonPrimitiveAndNonArrayKeys, DeepRequired } from './types';\n\n/**\n * @param value Value to be checked.\n * @param availableValues Object storing all available options as values.\n */\nexport function validateEnumValue<T extends Record<string, string>>(\n value: string,\n availableValues: T\n): T[keyof T] {\n if (!Object.values<string>(availableValues).includes(value)) {\n throw new Error(\n `Invalid value '${value}'. Available values are ${Object.values(availableValues)\n .map(v => `\"${v}\"`)\n .join(' | ')}.`\n );\n }\n return value as T[keyof T];\n}\n\n/**\n * @param filePath Relative or absolute path to a file.\n * @returns Absolute path to the valid image file.\n */\nexport async function validateFileIsPng(filePath: string): Promise<string> {\n const resolvedPath = await validateFileExists(filePath);\n\n // check if resolvedPath is a readable .png file\n if (path.extname(resolvedPath) !== '.png') {\n throw new Error(\n `Invalid path '${filePath}' - file is not a .png file. Provide a path to a file with .png extension.`\n );\n }\n return resolvedPath;\n}\n\n/**\n * @param filePath Relative or absolute path to a file.\n * @returns Absolute path to the resolved file.\n */\nexport async function validateFileExists(filePath: string): Promise<string> {\n const resolvedPath = path.resolve(filePath);\n if (!(await fs.pathExists(resolvedPath))) {\n throw new Error(\n `Invalid path '${filePath}' - file does not exist. Provide a path to an existing file.`\n );\n }\n return resolvedPath;\n}\n\n/**\n * @param value Value to be checked.\n */\nexport function validateColor(value: string): Color {\n const result = colorString.get(value)?.value;\n if (!result) {\n throw new Error(\n `Invalid value '${value}' - value is not a color string. Provide a valid color string.`\n );\n }\n return result;\n}\n\nexport function generateValidateEnumValue<T extends Record<string, string>>(availableValues: T) {\n return (value: string) => validateEnumValue(value, availableValues);\n}\n\nexport function ensurePropertyExists<\n T extends object,\n TK1 extends NonPrimitiveAndNonArrayKeys<DeepRequired<T>>,\n TK2 extends NonPrimitiveAndNonArrayKeys<D