diff --git a/CHANGELOG.md b/CHANGELOG.md index 98bd19a9e1..e042372b1c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ This is the log of notable changes to EAS CLI and related packages. ### ๐Ÿ› Bug fixes +- Don't prompt to set `android.package` and `ios.bundleIdentifier` values when running in non-interactive mode. ([#2336](https://github.com/expo/eas-cli/pull/2336) by [@szdziedzic](https://github.com/szdziedzic)) + ### ๐Ÿงน Chores - Amend credential removal wording. ([#2334](https://github.com/expo/eas-cli/pull/2334) by [@quinlanj](https://github.com/quinlanj)) diff --git a/packages/eas-cli/src/commands/build/version/get.ts b/packages/eas-cli/src/commands/build/version/get.ts index 050a477c72..28e29bb680 100644 --- a/packages/eas-cli/src/commands/build/version/get.ts +++ b/packages/eas-cli/src/commands/build/version/get.ts @@ -88,6 +88,7 @@ export default class BuildVersionGetView extends EasCommand { buildProfile: profile, platform, vcsClient, + nonInteractive: flags['non-interactive'], }); const remoteVersions = await AppVersionQuery.latestVersionAsync( graphqlClient, diff --git a/packages/eas-cli/src/commands/build/version/set.ts b/packages/eas-cli/src/commands/build/version/set.ts index 965699f468..ba2c02c102 100644 --- a/packages/eas-cli/src/commands/build/version/set.ts +++ b/packages/eas-cli/src/commands/build/version/set.ts @@ -77,6 +77,7 @@ export default class BuildVersionSetView extends EasCommand { buildProfile: profile, platform, vcsClient, + nonInteractive: false, }); const remoteVersions = await AppVersionQuery.latestVersionAsync( graphqlClient, diff --git a/packages/eas-cli/src/commands/build/version/sync.ts b/packages/eas-cli/src/commands/build/version/sync.ts index 5e423a41e0..252aeecf9d 100644 --- a/packages/eas-cli/src/commands/build/version/sync.ts +++ b/packages/eas-cli/src/commands/build/version/sync.ts @@ -102,6 +102,7 @@ export default class BuildVersionSyncView extends EasCommand { buildProfile: profileInfo.profile, platform: profileInfo.platform, vcsClient, + nonInteractive: false, }); const remoteVersions = await AppVersionQuery.latestVersionAsync( graphqlClient, diff --git a/packages/eas-cli/src/project/android/__tests__/applicationId-test.ts b/packages/eas-cli/src/project/android/__tests__/applicationId-test.ts index 8e2727f861..723e3e696b 100644 --- a/packages/eas-cli/src/project/android/__tests__/applicationId-test.ts +++ b/packages/eas-cli/src/project/android/__tests__/applicationId-test.ts @@ -133,9 +133,30 @@ describe(ensureApplicationIdIsDefinedForManagedProjectAsync, () => { projectId: '', exp: {} as any, vcsClient, + nonInteractive: false, }) ).rejects.toThrowError(/we can't update this file programmatically/); }); + it('throws an error in non-interactive mode', async () => { + const graphqlClient = instance(mock()); + + vol.fromJSON( + { + 'app.json': '{ "blah": {} }', + }, + '/app' + ); + await expect( + ensureApplicationIdIsDefinedForManagedProjectAsync({ + graphqlClient, + projectDir: '/app', + projectId: '', + exp: {} as any, + vcsClient, + nonInteractive: true, + }) + ).rejects.toThrowError(/non-interactive/); + }); it('prompts for the Android package if using app.json', async () => { const graphqlClient = instance(mock()); jest.mocked(AppQuery.byIdAsync).mockResolvedValue({ @@ -163,6 +184,7 @@ describe(ensureApplicationIdIsDefinedForManagedProjectAsync, () => { projectId: '', exp: {} as any, vcsClient, + nonInteractive: false, }) ).resolves.toBe('com.expo.notdominik'); expect(promptAsync).toHaveBeenCalled(); @@ -196,6 +218,7 @@ describe(ensureApplicationIdIsDefinedForManagedProjectAsync, () => { projectId: '', exp: {} as any, vcsClient, + nonInteractive: false, }) ).resolves.toBe('com.expo.notdominik'); const appJson = JSON.parse(await fs.readFile('/app/app.json', 'utf-8')); diff --git a/packages/eas-cli/src/project/android/applicationId.ts b/packages/eas-cli/src/project/android/applicationId.ts index ec7f457687..9f8761b33e 100644 --- a/packages/eas-cli/src/project/android/applicationId.ts +++ b/packages/eas-cli/src/project/android/applicationId.ts @@ -28,12 +28,14 @@ export async function ensureApplicationIdIsDefinedForManagedProjectAsync({ projectId, exp, vcsClient, + nonInteractive, }: { graphqlClient: ExpoGraphqlClient; projectDir: string; projectId: string; exp: ExpoConfig; vcsClient: Client; + nonInteractive: boolean; }): Promise { const workflow = await resolveWorkflowAsync(projectDir, Platform.ANDROID, vcsClient); assert(workflow === Workflow.MANAGED, 'This function should be called only for managed projects'); @@ -43,7 +45,13 @@ export async function ensureApplicationIdIsDefinedForManagedProjectAsync({ moduleName: gradleUtils.DEFAULT_MODULE_NAME, }); } catch { - return await configureApplicationIdAsync({ graphqlClient, projectDir, projectId, exp }); + return await configureApplicationIdAsync({ + graphqlClient, + projectDir, + projectId, + exp, + nonInteractive, + }); } } @@ -128,12 +136,22 @@ async function configureApplicationIdAsync({ projectDir, projectId, exp, + nonInteractive, }: { graphqlClient: ExpoGraphqlClient; projectDir: string; projectId: string; exp: ExpoConfig; + nonInteractive: boolean; }): Promise { + if (nonInteractive) { + throw new Error( + `The "android.package" is required to be set in app config when running in non-interactive mode. ${learnMore( + 'https://docs.expo.dev/versions/latest/config/app/#package' + )}` + ); + } + const paths = getConfigFilePaths(projectDir); // we can't automatically update app.config.js if (paths.dynamicConfigPath) { diff --git a/packages/eas-cli/src/project/applicationIdentifier.ts b/packages/eas-cli/src/project/applicationIdentifier.ts index 3060ab20ce..7a326cb345 100644 --- a/packages/eas-cli/src/project/applicationIdentifier.ts +++ b/packages/eas-cli/src/project/applicationIdentifier.ts @@ -25,6 +25,7 @@ export async function getApplicationIdentifierAsync({ buildProfile, platform, vcsClient, + nonInteractive, }: { graphqlClient: ExpoGraphqlClient; projectDir: string; @@ -33,6 +34,7 @@ export async function getApplicationIdentifierAsync({ buildProfile: BuildProfile; platform: Platform; vcsClient: Client; + nonInteractive: boolean; }): Promise { if (platform === Platform.ANDROID) { const profile = buildProfile as BuildProfile; @@ -45,6 +47,7 @@ export async function getApplicationIdentifierAsync({ projectId, exp, vcsClient, + nonInteractive, }); } @@ -60,6 +63,7 @@ export async function getApplicationIdentifierAsync({ projectId, exp, vcsClient, + nonInteractive, }); } diff --git a/packages/eas-cli/src/project/ios/__tests__/bundleIdentifier-test.ts b/packages/eas-cli/src/project/ios/__tests__/bundleIdentifier-test.ts index 0d3b418aed..d65ebb1d52 100644 --- a/packages/eas-cli/src/project/ios/__tests__/bundleIdentifier-test.ts +++ b/packages/eas-cli/src/project/ios/__tests__/bundleIdentifier-test.ts @@ -111,9 +111,29 @@ describe(ensureBundleIdentifierIsDefinedForManagedProjectAsync, () => { projectId: '1234', exp: {} as any, vcsClient, + nonInteractive: false, }) ).rejects.toThrowError(/we can't update this file programmatically/); }); + it('throws an error in non-interactive mode', async () => { + const graphqlClient = instance(mock()); + vol.fromJSON( + { + 'app.json': '{ "blah": {} }', + }, + '/app' + ); + await expect( + ensureBundleIdentifierIsDefinedForManagedProjectAsync({ + graphqlClient, + projectDir: '/app', + projectId: '1234', + exp: {} as any, + vcsClient, + nonInteractive: true, + }) + ).rejects.toThrowError(/non-interactive/); + }); it('prompts for the bundle identifier if using app.json', async () => { const graphqlClient = instance(mock()); jest.mocked(AppQuery.byIdAsync).mockResolvedValue({ @@ -141,6 +161,7 @@ describe(ensureBundleIdentifierIsDefinedForManagedProjectAsync, () => { projectId: '1234', exp: {} as any, vcsClient, + nonInteractive: false, }) ).resolves.toBe('com.expo.notdominik'); expect(promptAsync).toHaveBeenCalled(); @@ -172,6 +193,7 @@ describe(ensureBundleIdentifierIsDefinedForManagedProjectAsync, () => { projectId: '1234', exp: {} as any, vcsClient, + nonInteractive: false, }) ).resolves.toBe('com.expo.notdominik'); const appJson = JSON.parse(await fs.readFile('/app/app.json', 'utf-8')); diff --git a/packages/eas-cli/src/project/ios/bundleIdentifier.ts b/packages/eas-cli/src/project/ios/bundleIdentifier.ts index 825561d82c..6e3b9e8de5 100644 --- a/packages/eas-cli/src/project/ios/bundleIdentifier.ts +++ b/packages/eas-cli/src/project/ios/bundleIdentifier.ts @@ -21,12 +21,14 @@ export async function ensureBundleIdentifierIsDefinedForManagedProjectAsync({ projectId, exp, vcsClient, + nonInteractive, }: { graphqlClient: ExpoGraphqlClient; projectDir: string; projectId: string; exp: ExpoConfig; vcsClient: Client; + nonInteractive: boolean; }): Promise { const workflow = await resolveWorkflowAsync(projectDir, Platform.IOS, vcsClient); assert(workflow === Workflow.MANAGED, 'This function should be called only for managed projects'); @@ -39,6 +41,7 @@ export async function ensureBundleIdentifierIsDefinedForManagedProjectAsync({ projectDir, exp, projectId, + nonInteractive, }); } } @@ -120,12 +123,22 @@ async function configureBundleIdentifierAsync({ projectDir, projectId, exp, + nonInteractive, }: { graphqlClient: ExpoGraphqlClient; projectDir: string; projectId: string; exp: ExpoConfig; + nonInteractive: boolean; }): Promise { + if (nonInteractive) { + throw new Error( + `The "ios.bundleIdentifier" is required to be set in app config when running in non-interactive mode. ${learnMore( + 'https://docs.expo.dev/versions/latest/config/app/#bundleidentifier' + )}` + ); + } + const paths = getConfigFilePaths(projectDir); // we can't automatically update app.config.js if (paths.dynamicConfigPath) { @@ -148,6 +161,7 @@ async function configureBundleIdentifierAsync({ exp, projectId ); + const { bundleIdentifier } = await promptAsync({ name: 'bundleIdentifier', type: 'text',