Skip to content

Commit

Permalink
chore: move questions-remain into cypress repo (#29542)
Browse files Browse the repository at this point in the history
* chore: move questions-remain into cypress repo

* to js file

* SLASH!
  • Loading branch information
jennifer-shehane committed Jun 3, 2024
1 parent e6b422c commit ea83415
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 18 deletions.
9 changes: 9 additions & 0 deletions __snapshots__/questions-remain-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
exports['questions-remain returns object if all questions have been answered 1'] = {
'foo': 'foo is specified',
'bar': 'so is bar',
}

exports['questions-remain asks questions for missing options 1'] = {
'foo': 'foo is specified',
'bar': 'bar user answer',
}
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
"@aws-sdk/client-s3": "3.485.0",
"@aws-sdk/credential-providers": "3.53.0",
"@babel/eslint-parser": "7.24.1",
"@cypress/questions-remain": "1.0.1",
"@cypress/request": "^3.0.0",
"@cypress/request-promise": "^5.0.0",
"@electron/fuses": "1.6.1",
Expand Down Expand Up @@ -197,7 +196,7 @@
"semver": "7.5.3",
"shelljs": "0.8.5",
"sinon": "7.3.2",
"snap-shot-it": "7.9.3",
"snap-shot-it": "7.9.10",
"stop-only": "3.0.1",
"strip-ansi": "6.0.0",
"tar": "6.1.15",
Expand Down
2 changes: 1 addition & 1 deletion scripts/binary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ const minimist = require('minimist')
const la = require('lazy-ass')
const check = require('check-more-types')
const debug = require('debug')('cypress:binary')
const questionsRemain = require('@cypress/questions-remain')
const rp = require('@cypress/request-promise')

const zip = require('./zip')
const ask = require('./ask')
const meta = require('./meta')
const build = require('./build')
const upload = require('./upload')
const questionsRemain = require('./util/questions-remain')
const uploadUtils = require('./util/upload')
const { uploadArtifactToS3 } = require('./upload-build-artifact')
const { moveBinaries } = require('./move-binaries')
Expand Down
39 changes: 39 additions & 0 deletions scripts/binary/util/questions-remain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const la = require('lazy-ass')
const is = require('check-more-types')
const bluebird = require('bluebird')

// goes through the list of properties and asks relevant question
// resolves with all relevant options set
// if the property already exists, skips the question
function askMissingOptions (propertiesToQuestions) {
la(is.object(propertiesToQuestions), 'expected object property:question')

// options are collected from the CLI
return (options = {}) => {
const reducer = (memo, property) => {
if (is.has(memo, property)) {
return memo
}

const question = propertiesToQuestions[property]

if (!is.fn(question)) {
return memo
}

la(is.fn(question), 'cannot find question for property', property)

return question(memo[property]).then((answer) => {
memo[property] = answer

return memo
})
}

const properties = Object.keys(propertiesToQuestions)

return bluebird.reduce(properties, reducer, options)
}
}

module.exports = askMissingOptions
46 changes: 46 additions & 0 deletions scripts/unit/binary/util/questions-remain-spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* global sinon */
const questionsRemain = require('../../../binary/util/questions-remain')
const la = require('lazy-ass')
const snapshot = require('snap-shot-it')

describe('questions-remain', () => {
const dontAsk = () => {
throw new Error('Should not ask!')
}

it('is a function', () => {
if (typeof questionsRemain !== 'function') throw new Error('questionsRemain is not a function')
})

it('returns object if all questions have been answered', () => {
const propertiesToQuestions = {
foo: dontAsk,
bar: dontAsk,
}
const options = {
foo: 'foo is specified',
bar: 'so is bar',
}

// console.log(questionsRemain(propertiesToQuestions)(options))
return questionsRemain(propertiesToQuestions)(options).then(snapshot)
})

it('asks questions for missing options', () => {
const barStub = sinon.stub().resolves('bar user answer')
const propertiesToQuestions = {
foo: dontAsk,
bar: barStub,
}
const options = {
foo: 'foo is specified',
// notice bar is missing!
}

return questionsRemain(propertiesToQuestions)(options)
.then(snapshot)
.then(() => {
la(barStub.called, 'bar stub has not been called')
})
})
})
38 changes: 23 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2942,15 +2942,6 @@
mkdirp "^0.5.1"
npm-run-all "^4.1.5"

"@cypress/questions-remain@1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@cypress/questions-remain/-/questions-remain-1.0.1.tgz#334dc830323192995b43d7bbae9dd6db5e551a22"
integrity sha1-M03IMDIxkplbQ9e7rp3W215VGiI=
dependencies:
bluebird "3.5.0"
check-more-types "2.24.0"
lazy-ass "1.6.0"

"@cypress/react-tooltip@0.5.3":
version "0.5.3"
resolved "https://registry.yarnpkg.com/@cypress/react-tooltip/-/react-tooltip-0.5.3.tgz#3e0635304b2bf7dab5b7c251eb1ad23048b05dac"
Expand Down Expand Up @@ -10817,11 +10808,6 @@ bluebird-retry@0.11.0:
resolved "https://registry.yarnpkg.com/bluebird-retry/-/bluebird-retry-0.11.0.tgz#1289ab22cbbc3a02587baad35595351dd0c1c047"
integrity sha1-EomrIsu8OgJYe6rTVZU1HdDBwEc=

bluebird@3.5.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c"
integrity sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=

bluebird@3.5.3:
version "3.5.3"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.3.tgz#7d01c6f9616c9a51ab0f8c549a79dfe6ec33efa7"
Expand Down Expand Up @@ -26097,6 +26083,11 @@ ramda@0.27.1, ramda@^0.27.1:
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.27.1.tgz#66fc2df3ef873874ffc2da6aa8984658abacf5c9"
integrity sha512-PgIdVpn5y5Yns8vqb8FzBUEYn98V3xcPgawAkkgj0YJ0qDsnHCiNmZYfOGMgOvoB0eWFLpYbhxUR3mxfDIMvpw==

ramda@0.28.0:
version "0.28.0"
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.28.0.tgz#acd785690100337e8b063cab3470019be427cc97"
integrity sha512-9QnLuG/kPVgWvMQ4aODhsBUFKOUmnbUnsSXACv+NCQZcHbeb+v8Lodp8OVxtRULN1/xOyYLLaL6npE6dMq5QTA==

randexp@0.5.3:
version "0.5.3"
resolved "https://registry.yarnpkg.com/randexp/-/randexp-0.5.3.tgz#f31c2de3148b30bdeb84b7c3f59b0ebb9fec3738"
Expand Down Expand Up @@ -28458,6 +28449,23 @@ snap-shot-core@10.2.4:
quote "0.4.0"
ramda "0.27.1"

snap-shot-it@7.9.10, snap-shot-it@^7.9.6:
version "7.9.10"
resolved "https://registry.yarnpkg.com/snap-shot-it/-/snap-shot-it-7.9.10.tgz#6198a19f6281fa701254fabfa7c895783cee09b1"
integrity sha512-9USmsI2jc2kQslRhqkzFX+2K23o6v3VEzlQHwUNpZbbnEdU0ommReg2+Px7260sd+P/6CtaDx+LXadzt4caMVQ==
dependencies:
"@bahmutov/data-driven" "1.0.0"
check-more-types "2.24.0"
common-tags "1.8.2"
debug "4.3.4"
has-only "1.1.1"
its-name "1.0.0"
lazy-ass "1.6.0"
pluralize "8.0.0"
ramda "0.28.0"
snap-shot-compare "3.0.0"
snap-shot-core "10.2.4"

snap-shot-it@7.9.2:
version "7.9.2"
resolved "https://registry.yarnpkg.com/snap-shot-it/-/snap-shot-it-7.9.2.tgz#575302f8b3881fde851bdaa99c65e1fd9760bb98"
Expand Down Expand Up @@ -28492,7 +28500,7 @@ snap-shot-it@7.9.3:
snap-shot-compare "3.0.0"
snap-shot-core "10.2.0"

snap-shot-it@7.9.6, snap-shot-it@^7.9.6:
snap-shot-it@7.9.6:
version "7.9.6"
resolved "https://registry.yarnpkg.com/snap-shot-it/-/snap-shot-it-7.9.6.tgz#042c168980a1dc3ba7ffe2bb2beeaa8e9512772d"
integrity sha512-t/ADZfQ8EUk4J76S5cmynye7qg1ecUFqQfANiOMNy0sFmYUaqfx9K/AWwpdcpr3vFsDptM+zSuTtKD0A1EOLqA==
Expand Down

5 comments on commit ea83415

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ea83415 Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.11.0/linux-arm64/develop-ea8341563711ff16b1cf472269c9b53560f159a1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ea83415 Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.11.0/linux-x64/develop-ea8341563711ff16b1cf472269c9b53560f159a1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ea83415 Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.11.0/darwin-arm64/develop-ea8341563711ff16b1cf472269c9b53560f159a1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ea83415 Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.11.0/win32-x64/develop-ea8341563711ff16b1cf472269c9b53560f159a1/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on ea83415 Jun 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/13.11.0/darwin-x64/develop-ea8341563711ff16b1cf472269c9b53560f159a1/cypress.tgz

Please sign in to comment.