From 32bf052f0084860623ea815ed913e94261c89070 Mon Sep 17 00:00:00 2001 From: aeneasr <3372410+aeneasr@users.noreply.github.com> Date: Fri, 11 Feb 2022 12:21:58 +0100 Subject: [PATCH] fix: resolve prettier issues --- .../flows/code/registration/index.js | 3 +- .../flows/code/verification/index.js | 12 +- docs/scripts/config.js | 156 +++++++++--------- docs/src/theme/CodeFromRemote.js | 26 +-- docs/src/theme/ketoRelationTuplesPrism.js | 3 +- package-lock.json | 28 ++-- package.json | 4 +- test/e2e/cypress/helpers/index.ts | 51 +++--- 8 files changed, 144 insertions(+), 139 deletions(-) diff --git a/docs/docs/self-service/flows/code/registration/index.js b/docs/docs/self-service/flows/code/registration/index.js index 9c227491c9bd..41589ae5479b 100644 --- a/docs/docs/self-service/flows/code/registration/index.js +++ b/docs/docs/self-service/flows/code/registration/index.js @@ -20,8 +20,7 @@ export const getFlowMethodOidcWithCompletion = { browser: { label: 'Browser UI', image: require('./images/browser-oidc-invalid.png').default, - alt: - 'User Registration HTML Form with missing or invalid fields when performing an OpenID Connect flow' + alt: 'User Registration HTML Form with missing or invalid fields when performing an OpenID Connect flow' }, missing: { label: 'Missing Website', diff --git a/docs/docs/self-service/flows/code/verification/index.js b/docs/docs/self-service/flows/code/verification/index.js index ac065261e151..5e6194bdeffd 100644 --- a/docs/docs/self-service/flows/code/verification/index.js +++ b/docs/docs/self-service/flows/code/verification/index.js @@ -2,8 +2,7 @@ export const getFlowMethodLinkWithErrors = { browser: { label: 'Browser UI', image: require('./images/browser-missing.png').default, - alt: - 'Email Verification and Account Activation HTML Form with validation errors' + alt: 'Email Verification and Account Activation HTML Form with validation errors' }, missing: { label: 'Missing Email', @@ -16,8 +15,7 @@ export const getFlowMethodLinkSuccess = { browser: { label: 'Browser UI', image: require('./images/browser-success.png').default, - alt: - 'Email Verification and Account Activation HTML Form with success message' + alt: 'Email Verification and Account Activation HTML Form with success message' }, missing: { label: 'Email Sent', @@ -30,8 +28,7 @@ export const getFlowMethodLinkInvalidChallenge = { browser: { label: 'Browser UI', image: require('./images/browser-invalid-challenge.png').default, - alt: - 'Email Verification and Account Activation HTML Form with an invalid challenge' + alt: 'Email Verification and Account Activation HTML Form with an invalid challenge' }, missing: { label: 'Invalid Challenge', @@ -44,8 +41,7 @@ export const getFlowMethodLinkChallengeDone = { browser: { label: 'Browser UI', image: require('./images/browser-challenge-completed.png').default, - alt: - 'Email Verification and Account Activation HTML Form with an invalid challenge' + alt: 'Email Verification and Account Activation HTML Form with an invalid challenge' }, missing: { label: 'Success State', diff --git a/docs/scripts/config.js b/docs/scripts/config.js index 058a030e0567..ce2bc434d818 100644 --- a/docs/scripts/config.js +++ b/docs/scripts/config.js @@ -45,98 +45,100 @@ if (process.argv.length !== 3 || process.argv[1] === 'help') { const config = require(path.resolve(process.argv[2])) -const enhance = (schema, parents = []) => (item) => { - const key = item.key.value - - const path = [ - ...parents.map((parent) => ['properties', parent]), - ['properties', key] - ].flat() - - if (['title', 'description'].find((f) => path[path.length - 1] === f)) { - return - } +const enhance = + (schema, parents = []) => + (item) => { + const key = item.key.value + + const path = [ + ...parents.map((parent) => ['properties', parent]), + ['properties', key] + ].flat() + + if (['title', 'description'].find((f) => path[path.length - 1] === f)) { + return + } - const comments = [`# ${pathOr(key, [...path, 'title'], schema)} ##`, ''] + const comments = [`# ${pathOr(key, [...path, 'title'], schema)} ##`, ''] - const description = pathOr('', [...path, 'description'], schema) - if (description) { - comments.push(' ' + description.split('\n').join('\n '), '') - } + const description = pathOr('', [...path, 'description'], schema) + if (description) { + comments.push(' ' + description.split('\n').join('\n '), '') + } - const defaultValue = pathOr('', [...path, 'default'], schema) - if (defaultValue || defaultValue === false) { - comments.push(' Default value: ' + defaultValue, '') - } + const defaultValue = pathOr('', [...path, 'default'], schema) + if (defaultValue || defaultValue === false) { + comments.push(' Default value: ' + defaultValue, '') + } - const enums = pathOr('', [...path, 'enum'], schema) - if (enums && Array.isArray(enums)) { - comments.push( - ' One of:', - ...YAML.stringify(enums) - .split('\n') - .map((i) => ` ${i}`) - ) // split always returns one empty object so no need for newline - } + const enums = pathOr('', [...path, 'enum'], schema) + if (enums && Array.isArray(enums)) { + comments.push( + ' One of:', + ...YAML.stringify(enums) + .split('\n') + .map((i) => ` ${i}`) + ) // split always returns one empty object so no need for newline + } - const min = pathOr('', [...path, 'minimum'], schema) - if (min || min === 0) { - comments.push(` Minimum value: ${min}`, '') - } + const min = pathOr('', [...path, 'minimum'], schema) + if (min || min === 0) { + comments.push(` Minimum value: ${min}`, '') + } - const max = pathOr('', [...path, 'maximum'], schema) - if (max || max === 0) { - comments.push(` Maximum value: ${max}`, '') - } + const max = pathOr('', [...path, 'maximum'], schema) + if (max || max === 0) { + comments.push(` Maximum value: ${max}`, '') + } - const examples = pathOr('', [...path, 'examples'], schema) - if (examples) { - comments.push( - ' Examples:', - ...YAML.stringify(examples) - .split('\n') - .map((i) => ` ${i}`) - ) // split always returns one empty object so no need for newline - } + const examples = pathOr('', [...path, 'examples'], schema) + if (examples) { + comments.push( + ' Examples:', + ...YAML.stringify(examples) + .split('\n') + .map((i) => ` ${i}`) + ) // split always returns one empty object so no need for newline + } - let hasChildren - if (item.value.items) { - item.value.items.forEach((item) => { - if (item.key) { - enhance(schema, [...parents, key])(item) - hasChildren = true - } - }) - } + let hasChildren + if (item.value.items) { + item.value.items.forEach((item) => { + if (item.key) { + enhance(schema, [...parents, key])(item) + hasChildren = true + } + }) + } - const showEnvVarBlockForObject = pathOr( - '', - [...path, 'showEnvVarBlockForObject'], - schema - ) - if (!hasChildren || showEnvVarBlockForObject) { - const env = [...parents, key].map((i) => i.toUpperCase()).join('_') - comments.push( - ' Set this value using environment variables on', - ' - Linux/macOS:', - ` $ export ${env}=`, - ' - Windows Command Line (CMD):', - ` > set ${env}=`, - '' + const showEnvVarBlockForObject = pathOr( + '', + [...path, 'showEnvVarBlockForObject'], + schema ) - - // Show this if the config property is an object, to call out how to specify the env var - if (hasChildren) { + if (!hasChildren || showEnvVarBlockForObject) { + const env = [...parents, key].map((i) => i.toUpperCase()).join('_') comments.push( - ' This can be set as an environment variable by supplying it as a JSON object.', + ' Set this value using environment variables on', + ' - Linux/macOS:', + ` $ export ${env}=`, + ' - Windows Command Line (CMD):', + ` > set ${env}=`, '' ) + + // Show this if the config property is an object, to call out how to specify the env var + if (hasChildren) { + comments.push( + ' This can be set as an environment variable by supplying it as a JSON object.', + '' + ) + } } - } - item.commentBefore = comments.join('\n') - item.spaceBefore = true -} + item.commentBefore = comments.join('\n') + item.spaceBefore = true + } new Promise((resolve, reject) => { parser.dereference( diff --git a/docs/src/theme/CodeFromRemote.js b/docs/src/theme/CodeFromRemote.js index a3609647f381..189028c2091d 100644 --- a/docs/src/theme/CodeFromRemote.js +++ b/docs/src/theme/CodeFromRemote.js @@ -53,21 +53,23 @@ const findLine = (needle, haystack) => { return index } -const transform = ({ startAt, endAt }) => (content) => { - let lines = content.split('\n') +const transform = + ({ startAt, endAt }) => + (content) => { + let lines = content.split('\n') - const startIndex = findLine(startAt, lines) - if (startIndex > 0) { - lines = ['// ...', ...lines.slice(startIndex, -1)] - } + const startIndex = findLine(startAt, lines) + if (startIndex > 0) { + lines = ['// ...', ...lines.slice(startIndex, -1)] + } - const endIndex = findLine(endAt, lines) - if (endIndex > 0) { - lines = [...lines.slice(0, endIndex + 1), '// ...'] - } + const endIndex = findLine(endAt, lines) + if (endIndex > 0) { + lines = [...lines.slice(0, endIndex + 1), '// ...'] + } - return lines.join('\n') -} + return lines.join('\n') + } const CodeFromRemote = (props) => { const { src, title } = props diff --git a/docs/src/theme/ketoRelationTuplesPrism.js b/docs/src/theme/ketoRelationTuplesPrism.js index 513d653dfddb..9a00e5bbf706 100644 --- a/docs/src/theme/ketoRelationTuplesPrism.js +++ b/docs/src/theme/ketoRelationTuplesPrism.js @@ -44,7 +44,8 @@ export default (prism) => (prism.languages['keto-relation-tuples'] = { comment: /\/\/.*(\n|$)/, 'relation-tuple': { - pattern: /([^:#@()\n]+:)?([^:#@()\n]+)#([^:#@()\n]+)@?((\(([^:#@()\n]+:)?([^:#@()\n]+)#([^:#@()\n]*)\))|([^:#@()\n]+))/, + pattern: + /([^:#@()\n]+:)?([^:#@()\n]+)#([^:#@()\n]+)@?((\(([^:#@()\n]+:)?([^:#@()\n]+)#([^:#@()\n]*)\))|([^:#@()\n]+))/, inside: { namespace, object, diff --git a/package-lock.json b/package-lock.json index db32ba51b043..84110d77d21c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,9 +16,9 @@ "cypress": "^9.1.1", "dayjs": "^1.10.4", "got": "^11.8.2", - "ory-prettier-styles": "1.1.1", + "ory-prettier-styles": "1.1.2", "otplib": "^12.0.1", - "prettier": "2.2.1", + "prettier": "2.3.2", "typescript": "^4.4.3", "wait-on": "5.3.0" } @@ -2236,9 +2236,9 @@ } }, "node_modules/ory-prettier-styles": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ory-prettier-styles/-/ory-prettier-styles-1.1.1.tgz", - "integrity": "sha512-Kv5GUQw0nFDO6w/HcIMNQAh75QeG4ZhrpNuRJaHSlsTvTx9rwpr+bVfeXrhXQsovUW51PF6OvLW3LA0AdDdSzw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/ory-prettier-styles/-/ory-prettier-styles-1.1.2.tgz", + "integrity": "sha512-J7YcNdGlfTKCXAHEoFl9lp5EhnIASGgM5ua9Y+8OdWtS9tXJTik5xFYCF6xS46tpI3sk8cxFguKWhZeaeb6Z/A==", "dev": true }, "node_modules/os-tmpdir": { @@ -2328,9 +2328,9 @@ } }, "node_modules/prettier": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz", - "integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz", + "integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==", "dev": true, "bin": { "prettier": "bin-prettier.js" @@ -4631,9 +4631,9 @@ } }, "ory-prettier-styles": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/ory-prettier-styles/-/ory-prettier-styles-1.1.1.tgz", - "integrity": "sha512-Kv5GUQw0nFDO6w/HcIMNQAh75QeG4ZhrpNuRJaHSlsTvTx9rwpr+bVfeXrhXQsovUW51PF6OvLW3LA0AdDdSzw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/ory-prettier-styles/-/ory-prettier-styles-1.1.2.tgz", + "integrity": "sha512-J7YcNdGlfTKCXAHEoFl9lp5EhnIASGgM5ua9Y+8OdWtS9tXJTik5xFYCF6xS46tpI3sk8cxFguKWhZeaeb6Z/A==", "dev": true }, "os-tmpdir": { @@ -4702,9 +4702,9 @@ "dev": true }, "prettier": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz", - "integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.3.2.tgz", + "integrity": "sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==", "dev": true }, "pretty-bytes": { diff --git a/package.json b/package.json index 475d3964fe6f..09c6e40a1139 100644 --- a/package.json +++ b/package.json @@ -21,9 +21,9 @@ "cypress": "^9.1.1", "dayjs": "^1.10.4", "got": "^11.8.2", - "ory-prettier-styles": "1.1.1", - "otplib": "^12.0.1", + "ory-prettier-styles": "1.1.2", "prettier": "2.3.2", + "otplib": "^12.0.1", "typescript": "^4.4.3", "wait-on": "5.3.0" }, diff --git a/test/e2e/cypress/helpers/index.ts b/test/e2e/cypress/helpers/index.ts index 8c2489a5e849..cf0ac0966c61 100644 --- a/test/e2e/cypress/helpers/index.ts +++ b/test/e2e/cypress/helpers/index.ts @@ -2,31 +2,35 @@ export const email = () => Math.random().toString(36) + '@ory.sh' export const password = () => Math.random().toString(36) -export const assertVerifiableAddress = ({ isVerified, email }) => (session) => { - const { identity } = session - expect(identity).to.have.property('verifiable_addresses') - expect(identity.verifiable_addresses).to.have.length(1) - - const address = identity.verifiable_addresses[0] - expect(address.id).to.not.be.empty - expect(address.verified).to.equal(isVerified) - expect(address.value).to.equal(email) - - if (isVerified) { - expect(address.verified_at).to.not.be.null - } else { - expect(address).to.not.have.property('verified_at') +export const assertVerifiableAddress = + ({ isVerified, email }) => + (session) => { + const { identity } = session + expect(identity).to.have.property('verifiable_addresses') + expect(identity.verifiable_addresses).to.have.length(1) + + const address = identity.verifiable_addresses[0] + expect(address.id).to.not.be.empty + expect(address.verified).to.equal(isVerified) + expect(address.value).to.equal(email) + + if (isVerified) { + expect(address.verified_at).to.not.be.null + } else { + expect(address).to.not.have.property('verified_at') + } } -} -export const assertRecoveryAddress = ({ email }) => ({ identity }) => { - expect(identity).to.have.property('recovery_addresses') - expect(identity.recovery_addresses).to.have.length(1) +export const assertRecoveryAddress = + ({ email }) => + ({ identity }) => { + expect(identity).to.have.property('recovery_addresses') + expect(identity.recovery_addresses).to.have.length(1) - const address = identity.recovery_addresses[0] - expect(address.id).to.not.be.empty - expect(address.value).to.equal(email) -} + const address = identity.recovery_addresses[0] + expect(address.id).to.not.be.empty + expect(address.value).to.equal(email) + } export const parseHtml = (html) => new DOMParser().parseFromString(html, 'text/html') @@ -71,7 +75,8 @@ export const gen = { } // Format is -export const verifyHrefPattern = /^http:.*\/self-service\/verification\?(((&|)token|(&|)flow)=([\-a-zA-Z0-9]+)){2}$/ +export const verifyHrefPattern = + /^http:.*\/self-service\/verification\?(((&|)token|(&|)flow)=([\-a-zA-Z0-9]+)){2}$/ // intervals define how long to wait for something, export const pollInterval = 250 // how long to wait before retry