Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Warn before ejecting that some config needs to be set on dynamic config #1761

Merged
merged 6 commits into from
Aug 26, 2020

Conversation

brentvatne
Copy link
Member

This PR adds some checks before proceeding with ejecting to ensure that it's compatible with app.config.[ts/js]

✖ We are unable to continue with ejecting until you make the following changes to app.config.ts:
- name: A project name is required.
- ios.bundleIdentifier: An iOS bundle identifier is required. Details.
- android.package: An Android package is required. Details.

@EvanBacon
Copy link
Contributor

We have some e2e tests which currently attempt to lock the old app.json modification behavior down, be sure to update those to ensure these use-cases are air-tight

it(`delete the app.json sdkVersion if it's defined`, async () => {
require('@expo/config').writeConfigJsonAsync = jest.fn((...props) => {
return jest.requireActual('@expo/config').writeConfigJsonAsync(...props);
});
const projectRoot = '/from-app-json';
await upgradeAsync(
{ projectRoot, workflow: 'bare', requestedSdkVersion: null },
{ yarn: true }
);
expect(require('@expo/config').writeConfigJsonAsync).toBeCalledTimes(1);
expect(require('@expo/config').writeConfigJsonAsync).toHaveBeenLastCalledWith(projectRoot, {
sdkVersion: undefined,
});
const { exp, rootConfig: json } = await require('@expo/config').readConfigJsonAsync(
projectRoot
);
expect(json.expo.sdkVersion).not.toBeDefined();
// Uses expo package version
expect(exp.sdkVersion).toBe('35.0.0');
}, 10000);
// Important to ensure that we don't modify the app.json extraneously
it(`skips modifying the app.json if the app.json doesn't define an sdkVersion`, async () => {
require('@expo/config').writeConfigJsonAsync = jest.fn();
const projectRoot = '/from-app-config-js';
await upgradeAsync(
{ projectRoot, workflow: 'bare', requestedSdkVersion: null },
{ yarn: true }
);
expect(require('@expo/config').writeConfigJsonAsync).toBeCalledTimes(0);
}, 10000);

appJson.expo.ios = appJson.expo.ios ?? {};
appJson.expo.ios.bundleIdentifier = bundleIdentifier;
if (entryPoint) {
warnings.push(['entryPoint', 'Remove the entryPoint field.', undefined]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be the only warning that isn't covered now

Comment on lines +291 to 294
if (exp.entryPoint) {
delete exp.entryPoint;
log(`- expo.entryPoint is not needed and has been removed.`);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've modified this so the entryPoint is simply deleted upon ejection. In a static config, this should be persisted, otherwise it won't matter because every eject will delete the field.

@EvanBacon EvanBacon merged commit 99ffde3 into master Aug 26, 2020
@EvanBacon EvanBacon deleted the @brent/warn-for-dynamic-config branch August 26, 2020 23:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants