UNPKG

roc

Version:

Build modern web applications easily

1,648 lines (1,647 loc) 166 kB
{ "type": "Program", "start": 0, "end": 3711, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 110, "column": 0 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 37, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 37 } }, "specifiers": [], "source": { "type": "Literal", "start": 7, "end": 36, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 36 } }, "value": "source-map-support/register", "rawValue": "source-map-support/register", "raw": "'source-map-support/register'" } }, { "type": "ImportDeclaration", "start": 39, "end": 65, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 3, "column": 26 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 46, "end": 51, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 12 } }, "local": { "type": "Identifier", "start": 46, "end": 51, "loc": { "start": { "line": 3, "column": 7 }, "end": { "line": 3, "column": 12 } }, "name": "chalk" } } ], "importKind": "value", "source": { "type": "Literal", "start": 57, "end": 64, "loc": { "start": { "line": 3, "column": 18 }, "end": { "line": 3, "column": 25 } }, "value": "chalk", "rawValue": "chalk", "raw": "'chalk'" } }, { "type": "ImportDeclaration", "start": 66, "end": 127, "loc": { "start": { "line": 4, "column": 0 }, "end": { "line": 4, "column": 61 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 75, "end": 88, "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 22 } }, "imported": { "type": "Identifier", "start": 75, "end": 88, "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 22 } }, "name": "isPlainObject" }, "local": { "type": "Identifier", "start": 75, "end": 88, "loc": { "start": { "line": 4, "column": 9 }, "end": { "line": 4, "column": 22 } }, "name": "isPlainObject" } }, { "type": "ImportSpecifier", "start": 90, "end": 100, "loc": { "start": { "line": 4, "column": 24 }, "end": { "line": 4, "column": 34 } }, "imported": { "type": "Identifier", "start": 90, "end": 100, "loc": { "start": { "line": 4, "column": 24 }, "end": { "line": 4, "column": 34 } }, "name": "isFunction" }, "local": { "type": "Identifier", "start": 90, "end": 100, "loc": { "start": { "line": 4, "column": 24 }, "end": { "line": 4, "column": 34 } }, "name": "isFunction" } }, { "type": "ImportSpecifier", "start": 102, "end": 110, "loc": { "start": { "line": 4, "column": 36 }, "end": { "line": 4, "column": 44 } }, "imported": { "type": "Identifier", "start": 102, "end": 110, "loc": { "start": { "line": 4, "column": 36 }, "end": { "line": 4, "column": 44 } }, "name": "isRegExp" }, "local": { "type": "Identifier", "start": 102, "end": 110, "loc": { "start": { "line": 4, "column": 36 }, "end": { "line": 4, "column": 44 } }, "name": "isRegExp" } } ], "importKind": "value", "source": { "type": "Literal", "start": 118, "end": 126, "loc": { "start": { "line": 4, "column": 52 }, "end": { "line": 4, "column": 60 } }, "value": "lodash", "rawValue": "lodash", "raw": "'lodash'" } }, { "type": "ImportDeclaration", "start": 129, "end": 175, "loc": { "start": { "line": 6, "column": 0 }, "end": { "line": 6, "column": 46 } }, "specifiers": [ { "type": "ImportSpecifier", "start": 138, "end": 148, "loc": { "start": { "line": 6, "column": 9 }, "end": { "line": 6, "column": 19 } }, "imported": { "type": "Identifier", "start": 138, "end": 148, "loc": { "start": { "line": 6, "column": 9 }, "end": { "line": 6, "column": 19 } }, "name": "errorLabel" }, "local": { "type": "Identifier", "start": 138, "end": 148, "loc": { "start": { "line": 6, "column": 9 }, "end": { "line": 6, "column": 19 } }, "name": "errorLabel" } } ], "importKind": "value", "source": { "type": "Literal", "start": 156, "end": 174, "loc": { "start": { "line": 6, "column": 27 }, "end": { "line": 6, "column": 45 } }, "value": "../helpers/style", "rawValue": "../helpers/style", "raw": "'../helpers/style'" }, "trailingComments": [ { "type": "Block", "value": "*\n * Helper to use a validator.\n *\n * @param {object} value - Something to validate.\n * @param {function|RegExp} validator - A validator.\n * @return {boolean} - If valid or not.\n ", "start": 177, "end": 360, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 14, "column": 3 } }, "range": [ 177, 360 ] } ] }, { "type": "ExportNamedDeclaration", "start": 361, "end": 742, "loc": { "start": { "line": 15, "column": 0 }, "end": { "line": 27, "column": 1 } }, "declaration": { "type": "FunctionDeclaration", "start": 368, "end": 742, "loc": { "start": { "line": 15, "column": 7 }, "end": { "line": 27, "column": 1 } }, "id": { "type": "Identifier", "start": 377, "end": 384, "loc": { "start": { "line": 15, "column": 16 }, "end": { "line": 15, "column": 23 } }, "name": "isValid", "leadingComments": null }, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 385, "end": 390, "loc": { "start": { "line": 15, "column": 24 }, "end": { "line": 15, "column": 29 } }, "name": "value" }, { "type": "Identifier", "start": 392, "end": 401, "loc": { "start": { "line": 15, "column": 31 }, "end": { "line": 15, "column": 40 } }, "name": "validator" } ], "body": { "type": "BlockStatement", "start": 403, "end": 742, "loc": { "start": { "line": 15, "column": 42 }, "end": { "line": 27, "column": 1 } }, "body": [ { "type": "IfStatement", "start": 409, "end": 656, "loc": { "start": { "line": 16, "column": 4 }, "end": { "line": 24, "column": 5 } }, "test": { "type": "CallExpression", "start": 413, "end": 434, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 29 } }, "callee": { "type": "Identifier", "start": 413, "end": 423, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 18 } }, "name": "isFunction" }, "arguments": [ { "type": "Identifier", "start": 424, "end": 433, "loc": { "start": { "line": 16, "column": 19 }, "end": { "line": 16, "column": 28 } }, "name": "validator" } ] }, "consequent": { "type": "BlockStatement", "start": 436, "end": 476, "loc": { "start": { "line": 16, "column": 31 }, "end": { "line": 18, "column": 5 } }, "body": [ { "type": "ReturnStatement", "start": 446, "end": 470, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 32 } }, "argument": { "type": "CallExpression", "start": 453, "end": 469, "loc": { "start": { "line": 17, "column": 15 }, "end": { "line": 17, "column": 31 } }, "callee": { "type": "Identifier", "start": 453, "end": 462, "loc": { "start": { "line": 17, "column": 15 }, "end": { "line": 17, "column": 24 } }, "name": "validator" }, "arguments": [ { "type": "Identifier", "start": 463, "end": 468, "loc": { "start": { "line": 17, "column": 25 }, "end": { "line": 17, "column": 30 } }, "name": "value" } ] } } ] }, "alternate": { "type": "IfStatement", "start": 482, "end": 656, "loc": { "start": { "line": 18, "column": 11 }, "end": { "line": 24, "column": 5 } }, "test": { "type": "CallExpression", "start": 486, "end": 505, "loc": { "start": { "line": 18, "column": 15 }, "end": { "line": 18, "column": 34 } }, "callee": { "type": "Identifier", "start": 486, "end": 494, "loc": { "start": { "line": 18, "column": 15 }, "end": { "line": 18, "column": 23 } }, "name": "isRegExp" }, "arguments": [ { "type": "Identifier", "start": 495, "end": 504, "loc": { "start": { "line": 18, "column": 24 }, "end": { "line": 18, "column": 33 } }, "name": "validator" } ] }, "consequent": { "type": "BlockStatement", "start": 507, "end": 656, "loc": { "start": { "line": 18, "column": 36 }, "end": { "line": 24, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 517, "end": 628, "loc": { "start": { "line": 19, "column": 8 }, "end": { "line": 21, "column": 9 } }, "test": { "type": "UnaryExpression", "start": 521, "end": 554, "loc": { "start": { "line": 19, "column": 12 }, "end": { "line": 19, "column": 45 } }, "operator": "!", "prefix": true, "argument": { "type": "CallExpression", "start": 522, "end": 554, "loc": { "start": { "line": 19, "column": 13 }, "end": { "line": 19, "column": 45 } }, "callee": { "type": "MemberExpression", "start": 522, "end": 536, "loc": { "start": { "line": 19, "column": 13 }, "end": { "line": 19, "column": 27 } }, "object": { "type": "Identifier", "start": 522, "end": 531, "loc": { "start": { "line": 19, "column": 13 }, "end": { "line": 19, "column": 22 } }, "name": "validator" }, "property": { "type": "Identifier", "start": 532, "end": 536, "loc": { "start": { "line": 19, "column": 23 }, "end": { "line": 19, "column": 27 } }, "name": "test" }, "computed": false }, "arguments": [ { "type": "CallExpression", "start": 537, "end": 553, "loc": { "start": { "line": 19, "column": 28 }, "end": { "line": 19, "column": 44 } }, "callee": { "type": "MemberExpression", "start": 537, "end": 551, "loc": { "start": { "line": 19, "column": 28 }, "end": { "line": 19, "column": 42 } }, "object": { "type": "Identifier", "start": 537, "end": 542, "loc": { "start": { "line": 19, "column": 28 }, "end": { "line": 19, "column": 33 } }, "name": "value" }, "property": { "type": "Identifier", "start": 543, "end": 551, "loc": { "start": { "line": 19, "column": 34 }, "end": { "line": 19, "column": 42 } }, "name": "toString" }, "computed": false }, "arguments": [] } ] } }, "consequent": { "type": "BlockStatement", "start": 556, "end": 628, "loc": { "start": { "line": 19, "column": 47 }, "end": { "line": 21, "column": 9 } }, "body": [ { "type": "ReturnStatement", "start": 570, "end": 618, "loc": { "start": { "line": 20, "column": 12 }, "end": { "line": 20, "column": 60 } }, "argument": { "type": "BinaryExpression", "start": 577, "end": 617, "loc": { "start": { "line": 20, "column": 19 }, "end": { "line": 20, "column": 59 } }, "left": { "type": "Literal", "start": 577, "end": 605, "loc": { "start": { "line": 20, "column": 19 }, "end": { "line": 20, "column": 47 } }, "value": "Did not match the regexp: ", "rawValue": "Did not match the regexp: ", "raw": "'Did not match the regexp: '" }, "operator": "+", "right": { "type": "Identifier", "start": 608, "end": 617, "loc": { "start": { "line": 20, "column": 50 }, "end": { "line": 20, "column": 59 } }, "name": "validator" } } } ] }, "alternate": null }, { "type": "ReturnStatement", "start": 638, "end": 650, "loc": { "start": { "line": 23, "column": 8 }, "end": { "line": 23, "column": 20 } }, "argument": { "type": "Literal", "start": 645, "end": 649, "loc": { "start": { "line": 23, "column": 15 }, "end": { "line": 23, "column": 19 } }, "value": true, "rawValue": true, "raw": "true" } } ] }, "alternate": null } }, { "type": "ThrowStatement", "start": 662, "end": 740, "loc": { "start": { "line": 26, "column": 4 }, "end": { "line": 26, "column": 82 } }, "argument": { "type": "NewExpression", "start": 668, "end": 739, "loc": { "start": { "line": 26, "column": 10 }, "end": { "line": 26, "column": 81 } }, "callee": { "type": "Identifier", "start": 672, "end": 677, "loc": { "start": { "line": 26, "column": 14 }, "end": { "line": 26, "column": 19 } }, "name": "Error" }, "arguments": [ { "type": "Literal", "start": 678, "end": 738, "loc": { "start": { "line": 26, "column": 20 }, "end": { "line": 26, "column": 80 } }, "value": "Structure of configuration does not align with validation.", "rawValue": "Structure of configuration does not align with validation.", "raw": "'Structure of configuration does not align with validation.'" } ] } } ], "trailingComments": null }, "leadingComments": [ { "type": "Block", "value": "*\n * Helper to use a validator.\n *\n * @param {object} value - Something to validate.\n * @param {function|RegExp} validator - A validator.\n * @return {boolean} - If valid or not.\n ", "start": 177, "end": 360, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 14, "column": 3 } }, "range": [ 177, 360 ] } ], "trailingComments": [ { "type": "Block", "value": "*\n * Validates the provided configuration object.\n *\n * @param {rocSettings} settings - The settings object to validate.\n * @param {rocMetaSettings} metaSettings - The meta settings object that has information about how to validate.\n * @param {array|boolean} toValidate - What groups on settings that should be validated.\n * @emits {process.exit} - If the config was invalid it will print the reason and terminate with status 1.\n ", "start": 744, "end": 1178, "loc": { "start": { "line": 29, "column": 0 }, "end": { "line": 36, "column": 3 } }, "range": [ 744, 1178 ] } ] }, "specifiers": [], "source": null, "leadingComments": [ { "type": "Block", "value": "*\n * Helper to use a validator.\n *\n * @param {object} value - Something to validate.\n * @param {function|RegExp} validator - A validator.\n * @return {boolean} - If valid or not.\n ", "start": 177, "end": 360, "loc": { "start": { "line": 8, "column": 0 }, "end": { "line": 14, "column": 3 } }, "range": [ 177, 360 ] } ], "trailingComments": [ { "type": "Block", "value": "*\n * Validates the provided configuration object.\n *\n * @param {rocSettings} settings - The settings object to validate.\n * @param {rocMetaSettings} metaSettings - The meta settings object that has information about how to validate.\n * @param {array|boolean} toValidate - What groups on settings that should be validated.\n * @emits {process.exit} - If the config was invalid it will print the reason and terminate with status 1.\n ", "start": 744, "end": 1178, "loc": { "start": { "line": 29, "column": 0 }, "end": { "line": 36, "column": 3 } }, "range": [ 744, 1178 ] } ] }, { "type": "ExportNamedDeclaration", "start": 1179, "end": 1830, "loc": { "start": { "line": 37, "column": 0 }, "end": { "line": 53, "column": 1 } }, "declaration": { "type": "FunctionDeclaration", "start": 1186, "end": 1830, "loc": { "start": { "line": 37, "column": 7 }, "end": { "line": 53, "column": 1 } }, "id": { "type": "Identifier", "start": 1195, "end": 1203, "loc": { "start": { "line": 37, "column": 16 }, "end": { "line": 37, "column": 24 } }, "name": "validate", "leadingComments": null }, "generator": false, "expression": false, "async": false, "params": [ { "type": "Identifier", "start": 1204, "end": 1212, "loc": { "start": { "line": 37, "column": 25 }, "end": { "line": 37, "column": 33 } }, "name": "settings" }, { "type": "AssignmentPattern", "start": 1214, "end": 1231, "loc": { "start": { "line": 37, "column": 35 }, "end": { "line": 37, "column": 52 } }, "operator": "=", "left": { "type": "Identifier", "start": 1214, "end": 1226, "loc": { "start": { "line": 37, "column": 35 }, "end": { "line": 37, "column": 47 } }, "name": "metaSettings" }, "right": { "type": "ObjectExpression", "start": 1229, "end": 1231, "loc": { "start": { "line": 37, "column": 50 }, "end": { "line": 37, "column": 52 } }, "properties": [] } }, { "type": "AssignmentPattern", "start": 1233, "end": 1250, "loc": { "start": { "line": 37, "column": 54 }, "end": { "line": 37, "column": 71 } }, "operator": "=", "left": { "type": "Identifier", "start": 1233, "end": 1243, "loc": { "start": { "line": 37, "column": 54 }, "end": { "line": 37, "column": 64 } }, "name": "toValidate" }, "right": { "type": "Literal", "start": 1246, "end": 1250, "loc": { "start": { "line": 37, "column": 67 }, "end": { "line": 37, "column": 71 } }, "value": true, "rawValue": true, "raw": "true" } } ], "body": { "type": "BlockStatement", "start": 1252, "end": 1830, "loc": { "start": { "line": 37, "column": 73 }, "end": { "line": 53, "column": 1 } }, "body": [ { "type": "TryStatement", "start": 1258, "end": 1828, "loc": { "start": { "line": 38, "column": 4 }, "end": { "line": 52, "column": 5 } }, "block": { "type": "BlockStatement", "start": 1262, "end": 1573, "loc": { "start": { "line": 38, "column": 8 }, "end": { "line": 46, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 1272, "end": 1567, "loc": { "start": { "line": 39, "column": 8 }, "end": { "line": 45, "column": 9 } }, "test": { "type": "BinaryExpression", "start": 1276, "end": 1295, "loc": { "start": { "line": 39, "column": 12 }, "end": { "line": 39, "column": 31 } }, "left": { "type": "Identifier", "start": 1276, "end": 1286, "loc": { "start": { "line": 39, "column": 12 }, "end": { "line": 39, "column": 22 } }, "name": "toValidate" }, "operator": "===", "right": { "type": "Literal", "start": 1291, "end": 1295, "loc": { "start": { "line": 39, "column": 27 }, "end": { "line": 39, "column": 31 } }, "value": true, "rawValue": true, "raw": "true" } }, "consequent": { "type": "BlockStatement", "start": 1297, "end": 1376, "loc": { "start": { "line": 39, "column": 33 }, "end": { "line": 41, "column": 9 } }, "body": [ { "type": "ExpressionStatement", "start": 1311, "end": 1366, "loc": { "start": { "line": 40, "column": 12 }, "end": { "line": 40, "column": 67 } }, "expression": { "type": "CallExpression", "start": 1311, "end": 1365, "loc": { "start": { "line": 40, "column": 12 }, "end": { "line": 40, "column": 66 } }, "callee": { "type": "Identifier", "start": 1311, "end": 1329, "loc": { "start": { "line": 40, "column": 12 }, "end": { "line": 40, "column": 30 } }, "name": "validateMightThrow" }, "arguments": [ { "type": "Identifier", "start": 1330, "end": 1338, "loc": { "start": { "line": 40, "column": 31 }, "end": { "line": 40, "column": 39 } }, "name": "settings" }, { "type": "MemberExpression", "start": 1340, "end": 1364, "loc": { "start": { "line": 40, "column": 41 }, "end": { "line": 40, "column": 65 } }, "object": { "type": "Identifier", "start": 1340, "end": 1352, "loc": { "start": { "line": 40, "column": 41 }, "end": { "line": 40, "column": 53 } }, "name": "metaSettings" }, "property": { "type": "Identifier", "start": 1353, "end": 1364, "loc": { "start": { "line": 40, "column": 54 }, "end": { "line": 40, "column": 65 } }, "name": "validations" }, "computed": false } ] } } ] }, "alternate": { "type": "BlockStatement", "start": 1382, "end": 1567, "loc": { "start": { "line": 41, "column": 15 }, "end": { "line": 45, "column": 9 } }, "body": [ { "type": "ExpressionStatement", "start": 1396, "end": 1557, "loc": { "start": { "line": 42, "column": 12 }, "end": { "line": 44, "column": 15 } }, "expression": { "type": "CallExpression", "start": 1396, "end": 1556, "loc": { "start": { "line": 42, "column": 12 }, "end": { "line": 44, "column": 14 } }, "callee": { "type": "MemberExpression", "start": 1396, "end": 1414, "loc": { "start": { "line": 42, "column": 12 }, "end": { "line": 42, "column": 30 } }, "object": { "type": "Identifier", "start": 1396, "end": 1406, "loc": { "start": { "line": 42, "column": 12 }, "end": { "line": 42, "column": 22 } }, "name": "toValidate" }, "property": { "type": "Identifier", "start": 1407, "end": 1414, "loc": { "start": { "line": 42, "column": 23 }, "end": { "line": 42, "column": 30