-
Notifications
You must be signed in to change notification settings - Fork 478
[expo-cli] command for syncing credentials.json and credentials on www #2460
Conversation
{ | ||
type: 'select', | ||
name: 'platform', | ||
message: 'Do you want to update credentials for both platforms?', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message: 'Do you want to update credentials for both platforms?', | |
message: 'Which platform would you like to update?', |
{ title: 'Android & iOS', value: BuildCommandPlatform.ALL }, | ||
{ title: 'only Android', value: BuildCommandPlatform.ANDROID }, | ||
{ title: 'only iOS', value: BuildCommandPlatform.IOS }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ title: 'Android & iOS', value: BuildCommandPlatform.ALL }, | |
{ title: 'only Android', value: BuildCommandPlatform.ANDROID }, | |
{ title: 'only iOS', value: BuildCommandPlatform.IOS }, | |
{ title: 'Android', value: BuildCommandPlatform.ANDROID }, | |
{ title: 'iOS', value: BuildCommandPlatform.IOS }, | |
{ title: 'both', value: BuildCommandPlatform.ALL }, |
message: 'What do you want to do?', | ||
choices: [ | ||
{ | ||
title: 'Update credentials on Expo servers with local credentials.json content', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
title: 'Update credentials on Expo servers with local credentials.json content', | |
title: 'Update credentials on the Expo servers with local credentials.json contents', |
title: 'Update credentials on Expo servers with local credentials.json content', | ||
value: 'remote', | ||
}, | ||
{ title: 'Update local credentials.json with values from Expo servers', value: 'local' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ title: 'Update local credentials.json with values from Expo servers', value: 'local' }, | |
{ title: 'Update or create local credentials.json with credentials from Expo servers', value: 'local' }, |
export { default as credentialsJson } from './credentialsJson'; | ||
export { updateLocalCredentialsJsonAsync } from './update'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the benefit of having a file like this? I think we've discussed this many time :D
const { confirm } = await prompts({ | ||
type: 'confirm', | ||
name: 'confirm', | ||
message: | ||
'Credentials on Expo servers might be invalid or incomplete. Are you sure you want to continue?', | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should ask whether the user wants to remove them from our servers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not proposing that if sth is missing when starting build so I don't think we need to that here.
To be honest, I'm not sure if there will be a case where this condition will be triggered, but I added it here because there is similiar check for ios and we could add validation for keystore in the future.
const keystorePath = | ||
rawCredentialsJsonObject?.android?.keystorePath ?? './android/keystores/keystore.jks'; | ||
await _updateFileAsync(ctx.projectDir, keystorePath, keystore.keystore); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should inform the user that we created this file so he won't be surprised that it's been created.
import log from '../../log'; | ||
import { Context } from '../context'; | ||
|
||
type Platform = 'android' | 'ios' | 'all'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can be wrong but I believe this is already defined somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't want to import it from build directory, and there it means sth else. I moved that function to credentialsSync/action.ts so Platform type is not necessary anymore
const rawFile = await fs.readFile(credentialsJsonFilePath); | ||
rawCredentialsJsonObject = JSON.parse(rawFile.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const rawFile = await fs.readFile(credentialsJsonFilePath); | |
rawCredentialsJsonObject = JSON.parse(rawFile.toString()); | |
const rawFile = await fs.readFile(credentialsJsonFilePath, 'utf-8'); | |
rawCredentialsJsonObject = JSON.parse(rawFile); |
await _updateFileAsync( | ||
ctx.projectDir, | ||
pprofilePath, | ||
appCredentials?.credentials?.provisioningProfile | ||
); | ||
await _updateFileAsync(ctx.projectDir, distCertPath, distCredentials?.certP12); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's inform the user we created these files.
500304f
to
d843712
Compare
d843712
to
66ff7e3
Compare
message: 'What do you want to do?', | ||
choices: [ | ||
{ | ||
title: 'Update credentials on the Expo servers with local credentials.json contents', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
title: 'Update credentials on the Expo servers with local credentials.json contents', | |
title: 'Update credentials on the Expo servers with the local credentials.json contents', |
value: 'remote', | ||
}, | ||
{ | ||
title: 'Update or create local credentials.json with credentials from Expo servers', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
title: 'Update or create local credentials.json with credentials from Expo servers', | |
title: 'Update or create local credentials.json with credentials from the Expo servers', |
if (!ctx.hasProjectContext) { | ||
throw new Error('project context is required'); // should be checked earlier | ||
} | ||
if (['all', 'android'].includes(platform)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (['all', 'android'].includes(platform)) { | |
if ([BuildCommandPlatform.ALL, BuildCommandPlatform.ANDROID].includes(platform)) { |
const experienceName = `@${ctx.manifest.owner || ctx.user.username}/${ctx.manifest.slug}`; | ||
await runCredentialsManager(ctx, new SetupAndroidBuildCredentialsFromLocal(experienceName)); | ||
} | ||
if (['all', 'ios'].includes(platform)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (['all', 'ios'].includes(platform)) { | |
if ([BuildCommandPlatform.ALL, BuildCommandPlatform.IOS].includes(platform)) { |
@@ -0,0 +1,70 @@ | |||
import { ExpoConfig, IOSConfig } from '@expo/config'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ios.ts
?
@@ -0,0 +1,98 @@ | |||
import CommandError from '../../../CommandError'; | |||
import { Context } from '../../../credentials/context'; | |||
import * as credentialsJson from '../../../credentials/credentialsJson/update'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import * as credentialsJson from '../../../credentials/credentialsJson/update'; | |
import * as credentialsJsonUpdateUtils from '../../../credentials/credentialsJson/update'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import * as credentialsJson from '../../../credentials/credentialsJson/update'; | |
import { updateAndroidCredentialsAsync, updateIosCredentialsAsync } from '../../../credentials/credentialsJson/update'; |
66ff7e3
to
49f6580
Compare
Why
We need a simple way to switch between different methods of providing credentials
How
Added new command
Test plan