feat: including version in CYPRESS_DOWNLOAD_PATH_TEMPLATE (refs #5141 #16976 #22864) (#23194)

Co-authored-by: Blue F <blue@cypress.io>
Co-authored-by: Matt Henkes <mjhenkes@gmail.com>
This commit is contained in:
Tomas Bjerre
2022-08-16 15:49:56 +02:00
committed by GitHub
parent 7dd4a142dd
commit 7489561fbf
3 changed files with 16 additions and 2 deletions
+4
View File
@@ -45,6 +45,10 @@ exports['desktop url from template'] = `
https://download.cypress.io/desktop/0.20.2/OS-ARCH/cypress.zip
`
exports['desktop url from template with version'] = `
https://mycompany/0.20.2/OS-ARCH/cypress.zip
`
exports['desktop url from template with escaped dollar sign'] = `
https://download.cypress.io/desktop/0.20.2/OS-ARCH/cypress.zip
`
+5 -2
View File
@@ -60,7 +60,7 @@ const getCA = () => {
})
}
const prepend = (arch, urlPath) => {
const prepend = (arch, urlPath, version) => {
const endpoint = url.resolve(getBaseUrl(), urlPath)
const platform = os.platform()
const pathTemplate = util.getEnv('CYPRESS_DOWNLOAD_PATH_TEMPLATE', true)
@@ -71,6 +71,7 @@ const prepend = (arch, urlPath) => {
.replace(/\\?\$\{endpoint\}/, endpoint)
.replace(/\\?\$\{platform\}/, platform)
.replace(/\\?\$\{arch\}/, arch)
.replace(/\\?\$\{version\}/, version)
)
: `${endpoint}?platform=${platform}&arch=${arch}`
}
@@ -82,7 +83,9 @@ const getUrl = (arch, version) => {
return version
}
return version ? prepend(arch, `desktop/${version}`) : prepend(arch, 'desktop')
const urlPath = version ? `desktop/${version}` : 'desktop'
return prepend(arch, urlPath, version)
}
const statusMessage = (err) => {
+7
View File
@@ -74,6 +74,13 @@ describe('lib/tasks/download', function () {
snapshot('desktop url from template', normalize(url))
})
it('returns custom url from template with version', () => {
process.env.CYPRESS_DOWNLOAD_PATH_TEMPLATE = 'https://mycompany/${version}/${platform}-${arch}/cypress.zip'
const url = download.getUrl('ARCH', '0.20.2')
snapshot('desktop url from template with version', normalize(url))
})
it('returns custom url from template with escaped dollar sign', () => {
process.env.CYPRESS_DOWNLOAD_PATH_TEMPLATE = '\\${endpoint}/\\${platform}-\\${arch}/cypress.zip'
const url = download.getUrl('ARCH', '0.20.2')