diff --git a/CHANGELOG.md b/CHANGELOG.md index 90f81b527d..067f33611e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ This is the log of notable changes to EAS CLI and related packages. ### ๐Ÿ› Bug fixes +- Avoid malforming `app.json` with empty `.expo` object. ([#2573](https://github.com/expo/eas-cli/pull/2573) by [@byCedric](https://github.com/byCedric)) + ### ๐Ÿงน Chores ## [12.4.1](https://github.com/expo/eas-cli/releases/tag/v12.4.1) - 2024-09-14 diff --git a/packages/eas-cli/src/project/__tests__/expoConfig.test.ts b/packages/eas-cli/src/project/__tests__/expoConfig.test.ts index 001738d998..8482629613 100644 --- a/packages/eas-cli/src/project/__tests__/expoConfig.test.ts +++ b/packages/eas-cli/src/project/__tests__/expoConfig.test.ts @@ -46,17 +46,5 @@ describe('expoConfig', () => { await createOrModifyExpoConfigAsync('/app', { owner: 'ccheever' }); expect(modifyConfigAsync).toHaveBeenCalledWith('/app', { owner: 'ccheever' }); }); - - it('adds expo key if app.json is missing it', async () => { - jest.mocked(getConfigFilePaths).mockReturnValue({ - staticConfigPath: '/app/app.json', - dynamicConfigPath: null, - }); - jest.mocked(JsonFile.readAsync).mockResolvedValue({ name: 'App' }); - - await createOrModifyExpoConfigAsync('/app', { owner: 'ccheever' }); - expect(JsonFile.writeAsync).toHaveBeenCalledWith('/app/app.json', { name: 'App', expo: {} }); - expect(modifyConfigAsync).toHaveBeenCalledWith('/app', { owner: 'ccheever' }); - }); }); }); diff --git a/packages/eas-cli/src/project/expoConfig.ts b/packages/eas-cli/src/project/expoConfig.ts index aa7223b5d7..77811d4d29 100644 --- a/packages/eas-cli/src/project/expoConfig.ts +++ b/packages/eas-cli/src/project/expoConfig.ts @@ -1,9 +1,7 @@ import { ExpoConfig, getConfig, getConfigFilePaths, modifyConfigAsync } from '@expo/config'; import { Env } from '@expo/eas-build-job'; -import JsonFile from '@expo/json-file'; import fs from 'fs-extra'; import Joi from 'joi'; -import nullthrows from 'nullthrows'; import path from 'path'; export type PublicExpoConfig = Omit< @@ -31,7 +29,6 @@ export async function createOrModifyExpoConfigAsync( readOptions?: { skipSDKVersionRequirement?: boolean } ): ReturnType { ensureExpoConfigExists(projectDir); - await ensureStaticExpoConfigIsValidAsync(projectDir); if (readOptions) { return await modifyConfigAsync(projectDir, exp, readOptions); @@ -95,20 +92,6 @@ export function ensureExpoConfigExists(projectDir: string): void { } } -async function ensureStaticExpoConfigIsValidAsync(projectDir: string): Promise { - if (isUsingStaticExpoConfig(projectDir)) { - const staticConfigPath = nullthrows(getConfigFilePaths(projectDir).staticConfigPath); - const staticConfig = await JsonFile.readAsync(staticConfigPath); - - // Add the "expo" key if it doesn't exist on app.json yet, such as in - // projects initialized with RNC CLI - if (!staticConfig?.expo) { - staticConfig.expo = {}; - await JsonFile.writeAsync(staticConfigPath, staticConfig); - } - } -} - export function isUsingStaticExpoConfig(projectDir: string): boolean { const paths = getConfigFilePaths(projectDir); return !!(paths.staticConfigPath?.endsWith('app.json') && !paths.dynamicConfigPath);