使用 eas.json 配置 EAS 提交
了解如何使用 eas.json 配置 EAS 提交项目。
eas.json 是 EAS CLI 和服务的配置文件。它是在你的项目中第一次运行 eas build:configure
命令 时生成的,位于项目根目录的 package.json 旁边。尽管 eas.json 对于使用 EAS Submit 不是必需的,但如果你需要在不同配置之间切换,它会让你的生活更轻松。
¥eas.json is the configuration file for EAS CLI and services. It is generated when the eas build:configure
command runs for the first time in your project and is located next to package.json at the root of your project. Even though eas.json is not mandatory for using EAS Submit, it makes your life easier if you need to switch between different configurations.
生产概况
¥Production profile
如果已在 eas.json 中定义了 production
配置文件来配置提交,则在不指定配置文件名称的情况下运行 eas submit
将使用 production
配置文件。如果 production
配置文件中不存在任何值,EAS CLI 将提示你以交互方式提供这些值。
¥Running eas submit
without specifying a profile name will use the production
profile if it is already defined in eas.json to configure the submission. If no values exist in the production
profile, EAS CLI will prompt you to provide the values interactively.
如下所示的 production
配置文件是在 CI/CD 流程中运行 Android 和 iOS 提交所必需的,就像 EAS 工作流程 一样:
¥The production
profile shown below is required to run Android and iOS submissions in a CI/CD process, like with EAS Workflows:
{
"cli": {
"version": ">= 0.34.0"
},
"submit": {
"production": {
"android": {
"serviceAccountKeyPath": "../path/to/api-xxx-yyy-zzz.json",
"track": "internal"
},
"ios": {
"ascAppId": "your-app-store-connect-app-id"
}
}
}
}
了解更多关于你可以使用 Android 特定选项 和 iOS 特定选项 设置的值的信息。你还可以了解如何提交到 苹果应用商店 和 谷歌应用商店。
¥Learn more about the values you can set with the Android specific options and the iOS specific options. You can also learn how to submit to the Apple App Store and the Google Play Store.
多个配置文件
¥Multiple profiles
submit
下的 JSON 对象可以包含多个提交配置文件。submit
下的每个配置文件可以有任意名称,如下例所示:
¥The JSON object under submit
can contain multiple submit profiles. Each profile under submit
can have an arbitrary name as shown in the example below:
{
"cli": {
"version": "SEMVER_RANGE",
"requireCommit": boolean
},
"build": {
// EAS Build configuration
%%placeholder-start%%... %%placeholder-end%%
},
"submit": {
"SUBMIT_PROFILE_NAME_1": {
"android": {
...ANDROID_OPTIONS
},
"ios": {
...IOS_OPTIONS
}
},
"SUBMIT_PROFILE_NAME_2": {
"extends": "SUBMIT_PROFILE_NAME_1",
"android": {
...ANDROID_OPTIONS
}
},
%%placeholder-start%%... %%placeholder-end%%
}
}
当你选择要提交的构建时,它会选择用于所选构建的配置文件。如果该配置文件不存在,则选择默认的 production
配置文件。
¥When you select a build for submission, it chooses the profile that is used for the selected build. If the profile does not exist, it selects the default production
profile.
你还可以使用 EAS CLI 通过指定参数来获取另一个 submit
配置文件,例如:
¥You can also use EAS CLI to pick up another submit
profile by specifying it with a parameter, for example:
# Replace the <profile-name> with a submit profile from the eas.json
-
eas submit --platform ios --profile <profile-name>
在 submit
配置文件之间共享配置
¥Share configuration between submit
profiles
submit
配置文件可以使用 extends
密钥扩展另一个配置文件。
¥A submit
profile can extend another profile using the extends
key.
例如,在 preview
配置文件中,你可能有 "extends": "production"
。这使得 preview
配置文件继承 production
配置文件的配置。
¥For example, in the preview
profile you may have "extends": "production"
. This makes the preview
profile inherit the configuration of the production
profile.
只要避免产生循环依赖,你就可以将配置文件扩展链接至 5 个深度。
¥You can keep chaining profile extensions up to the depth of 5 as long as you avoid making circular dependencies.
下一步
¥Next step
了解 EAS Submit 的可用属性,以在项目内配置和覆盖其默认行为。