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

Allow expo start --dev-client in managed projects #3523

Merged
merged 4 commits into from
Jun 8, 2021

Conversation

fson
Copy link
Contributor

@fson fson commented May 27, 2021

Why

It should be possible to use dev client with a managed project.

How

  • Removed the "can only be used in bare workflow apps" warning
  • Added a check to look up the schema in app.json/app.config.*s when there are no native project (managed project)
  • Added a prompt for schema when it's not configured.
  • Prompt has a good default.

Screen Shot 2021-06-08 at 15 17 02

Test Plan

Created a managed project and verified that expo start --dev-client started the dev server. Tested with:

  • app.json including a schema -> started without warnings
  • no scheme -> error

Also set the scheme property in app.json to the URI scheme of an app that I had previously built and installed on my Android device. Running expod start --dev-client and pressing a opened the app.

@fson fson requested review from brentvatne and EvanBacon May 27, 2021 19:57
@linear
Copy link

linear bot commented May 27, 2021

ENG-1130 managed support for expo start --dev-client

Option --dev-client can only be used in bare workflow apps. Run expo eject and try again

We should detect the scheme (and direct the user to add a scheme if missing) based on https://docs.expo.io/versions/latest/config/app/#scheme

lower: true,
}),
});
if (staticConfigPath) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a bit more like this

export async function attemptAddingPluginsAsync(
projectRoot: string,
exp: Pick<ExpoConfig, 'plugins'>,
plugins: string[]
): Promise<void> {
if (!plugins.length) return;
const edits = {
plugins: (exp.plugins || []).concat(plugins),
};
const modification = await modifyConfigAsync(projectRoot, edits, {
skipSDKVersionRequirement: true,
});
if (modification.type === 'success') {
Log.log(`\u203A Added config plugins: ${plugins.join(', ')}`);
} else {
const exactEdits = {
plugins,
};
warnAboutConfigAndThrow(modification.type, modification.message!, exactEdits);
}
}

config.expo = { ...(config.expo as object), scheme };
await JsonFile.writeAsync(staticConfigPath, config);
Log.log(`Scheme '${scheme}' updated in ${path.basename(staticConfigPath)}`);
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

this would just ignore the dynamic config and create a potentially unused file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Existing dynamic config is handled by an earlier if – see https://github.com/expo/expo-cli/pull/3523/files#diff-ef67bc980d05133cc7b87b450cf4a04e1546cae27683bc12a749a925bb79cf09R105

If we land in this else branch it means there's no config (dynamic or static) at all so we just create an app.json.

@brentvatne
Copy link
Member

if in a managed app we run expo start --dev-client, then prompt the user to add a scheme and update it and launch the server, we will start the dev client server with a scheme that doesn't exist in an dev client build that was created prior to running that command 😮

maybe we can modify the config plugin to add a deterministic scheme derived from the project slug, and use that for expo start --dev-client? we could alternatively depend on the bundle id / package name being added to scheme -- run expo config --type introspect and notice that the bundled id / package names are added to schemes.

@fson
Copy link
Contributor Author

fson commented Jun 8, 2021

That's a good point from @brentvatne. I have now removed the prompt for scheme and instead added autogeneration of schemes in the expo-dev-client config plugin here: expo/expo#13147

I'll add support for the autogenerated schemes to the CLI in a separate pull request.

@fson fson merged commit b8807bc into master Jun 8, 2021
@fson fson deleted the ville/eng-1130-managed-support-for-expo-start---dev branch June 8, 2021 12:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
3 participants