Skip to content

Commit

Permalink
feat: env to use path params in download url (#19526)
Browse files Browse the repository at this point in the history
* feat: env to use path params in download url

* feat: change env to url template

* feat: fix snapshot

Co-authored-by: Matt Henkes <[email protected]>
  • Loading branch information
HarlesPilter and mjhenkes committed Jan 18, 2022
1 parent 3b23887 commit 2685f82
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cli/__snapshots__/download_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ https://download.cypress.io/desktop?platform=OS&arch=ARCH
exports['specific version desktop url 1'] = `
https://download.cypress.io/desktop/0.20.2?platform=OS&arch=ARCH
`

exports['desktop url from template'] = `
https://download.cypress.io/desktop/0.20.2/darwin-x64/cypress.zip
`
5 changes: 4 additions & 1 deletion cli/lib/tasks/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ const getCA = () => {
const prepend = (urlPath) => {
const endpoint = Url.resolve(getBaseUrl(), urlPath)
const platform = os.platform()
const pathTemplate = util.getEnv('CYPRESS_DOWNLOAD_PATH_TEMPLATE')

return `${endpoint}?platform=${platform}&arch=${arch()}`
return pathTemplate
? pathTemplate.replace('${endpoint}', endpoint).replace('${platform}', platform).replace('${arch}', arch())
: `${endpoint}?platform=${platform}&arch=${arch()}`
}

const getUrl = (version) => {
Expand Down
7 changes: 7 additions & 0 deletions cli/test/lib/tasks/download_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ describe('lib/tasks/download', function () {
snapshot('specific version desktop url 1', normalize(url))
})

it('returns custom url from template', () => {
process.env.CYPRESS_DOWNLOAD_PATH_TEMPLATE = '${endpoint}/${platform}-${arch}/cypress.zip'
const url = download.getUrl('0.20.2')

snapshot('desktop url from template', normalize(url))
})

it('returns input if it is already an https link', () => {
const url = 'https://somewhere.com'
const result = download.getUrl(url)
Expand Down

3 comments on commit 2685f82

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2685f82 Jan 18, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.3.0/circle-develop-2685f82663379e23462073ef2d637ddd690527d2/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2685f82 Jan 18, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.3.0/circle-develop-2685f82663379e23462073ef2d637ddd690527d2/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 2685f82 Jan 18, 2022

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 platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.3.0/circle-develop-2685f82663379e23462073ef2d637ddd690527d2/cypress.tgz

Please sign in to comment.