Skip to content

Commit 8e9c165

Browse files
committed
extract cloud env to a constant
1 parent e10fc83 commit 8e9c165

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

packages/server/lib/StudioLifecycleManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { CloudRequest } from './cloud/api/cloud_request'
1212
import { isRetryableError } from './cloud/network/is_retryable_error'
1313
import { asyncRetry } from './util/async_retry'
1414
import { postStudioSession } from './cloud/api/studio/post_studio_session'
15+
import { CLOUD_ENV } from './cloud/constants'
1516

1617
const debug = Debug('cypress:server:studio-lifecycle-manager')
1718
const routes = require('./cloud/routes')
@@ -52,8 +53,7 @@ export class StudioLifecycleManager {
5253
}).catch(async (error) => {
5354
debug('Error during studio manager setup: %o', error)
5455

55-
const cloudEnv = (process.env.CYPRESS_CONFIG_ENV || process.env.CYPRESS_INTERNAL_ENV || 'production') as 'development' | 'staging' | 'production'
56-
const cloudUrl = ctx.cloud.getCloudUrl(cloudEnv)
56+
const cloudUrl = ctx.cloud.getCloudUrl(CLOUD_ENV)
5757
const cloudHeaders = await ctx.cloud.additionalHeaders()
5858

5959
reportStudioError({

packages/server/lib/cloud/api/studio/get_and_initialize_studio_manager.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import fetch from 'cross-fetch'
1010
import { agent } from '@packages/network'
1111
import { asyncRetry, linearDelay } from '../../../util/async_retry'
1212
import { isRetryableError } from '../../network/is_retryable_error'
13-
import { PUBLIC_KEY_VERSION } from '../../constants'
13+
import { CLOUD_ENV, PUBLIC_KEY_VERSION } from '../../constants'
1414
import { CloudRequest } from '../cloud_request'
1515
import type { CloudDataSource } from '@packages/data-context/src/sources'
1616

@@ -125,8 +125,7 @@ export const retrieveAndExtractStudioBundle = async ({ studioUrl, projectId }: O
125125
export const getAndInitializeStudioManager = async ({ studioUrl, projectId, cloudDataSource }: { studioUrl: string, projectId?: string, cloudDataSource: CloudDataSource }): Promise<StudioManager> => {
126126
let script: string
127127

128-
const cloudEnv = (process.env.CYPRESS_CONFIG_ENV || process.env.CYPRESS_INTERNAL_ENV || 'production') as 'development' | 'staging' | 'production'
129-
const cloudUrl = cloudDataSource.getCloudUrl(cloudEnv)
128+
const cloudUrl = cloudDataSource.getCloudUrl(CLOUD_ENV)
130129
const cloudHeaders = await cloudDataSource.additionalHeaders()
131130

132131
let studioHash: string | undefined
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export const PUBLIC_KEY_VERSION = '1'
2+
3+
export const CLOUD_ENV = (process.env.CYPRESS_CONFIG_ENV || process.env.CYPRESS_INTERNAL_ENV || 'production') as 'development' | 'staging' | 'production'

packages/server/lib/project-base.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { reportStudioError } from './cloud/api/studio/report_studio_error'
2929
import { CloudRequest } from './cloud/api/cloud_request'
3030
import { isRetryableError } from './cloud/network/is_retryable_error'
3131
import { asyncRetry } from './util/async_retry'
32+
import { CLOUD_ENV } from './cloud/constants'
3233

3334
export interface Cfg extends ReceivedCypressOptions {
3435
projectId?: string
@@ -407,8 +408,7 @@ export class ProjectBase extends EE {
407408

408409
if (!isStudioReady) {
409410
debug('User entered studio mode before cloud studio was initialized')
410-
const cloudEnv = (process.env.CYPRESS_CONFIG_ENV || process.env.CYPRESS_INTERNAL_ENV || 'production') as 'development' | 'staging' | 'production'
411-
const cloudUrl = this.ctx.cloud.getCloudUrl(cloudEnv)
411+
const cloudUrl = this.ctx.cloud.getCloudUrl(CLOUD_ENV)
412412
const cloudHeaders = await this.ctx.cloud.additionalHeaders()
413413

414414
reportStudioError({

0 commit comments

Comments
 (0)