-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[eas-cli] Create dynamic logged in context field and clean up erroneo…
…us SessionManager context field uses (#2648)
- Loading branch information
Showing
12 changed files
with
78 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/eas-cli/src/commandUtils/context/DynamicLoggedInContextField.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import ContextField, { ContextOptions } from './ContextField'; | ||
import { ExpoGraphqlClient, createGraphqlClient } from './contextUtils/createGraphqlClient'; | ||
import { LoggedInAuthenticationInfo } from '../../user/SessionManager'; | ||
import { Actor } from '../../user/User'; | ||
import FeatureGateEnvOverrides from '../gating/FeatureGateEnvOverrides'; | ||
import FeatureGating from '../gating/FeatureGating'; | ||
|
||
export type DynamicLoggedInContextFn = () => Promise<{ | ||
actor: Actor; | ||
featureGating: FeatureGating; | ||
graphqlClient: ExpoGraphqlClient; | ||
authenticationInfo: LoggedInAuthenticationInfo; | ||
}>; | ||
|
||
export default class DynamicLoggedInContextField extends ContextField<DynamicLoggedInContextFn> { | ||
async getValueAsync({ | ||
nonInteractive, | ||
sessionManager, | ||
}: ContextOptions): Promise<DynamicLoggedInContextFn> { | ||
return async () => { | ||
const { actor, authenticationInfo } = await sessionManager.ensureLoggedInAsync({ | ||
nonInteractive, | ||
}); | ||
const featureGateServerValues: { [key: string]: boolean } = actor?.featureGates ?? {}; | ||
|
||
const graphqlClient = createGraphqlClient(authenticationInfo); | ||
|
||
return { | ||
actor, | ||
featureGating: new FeatureGating(featureGateServerValues, new FeatureGateEnvOverrides()), | ||
graphqlClient, | ||
authenticationInfo, | ||
}; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters