了解如何使用 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
配置文件。
¥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.
带有 production
的 eas.json 示例如下所示:
¥An example eas.json with production
is shown below:
{
"cli": {
"version": ">= 0.34.0"
},
"submit": {
"production": {
"android": {
"serviceAccountKeyPath": "../path/to/api-xxx-yyy-zzz.json",
"track": "internal"
},
"ios": {
"appleId": "john@turtle.com",
"ascAppId": "1234567890",
"appleTeamId": "AB12XYZ34S"
}
}
}
}
¥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
配置文件。例如,eas submit --platform ios --profile submit-profile-name
。
¥You can also use EAS CLI to pick up another submit
profile by specifying it with a parameter. For example, eas submit --platform ios --profile submit-profile-name
.
submit
配置文件之间共享配置¥Share configuration between submit
profiles
submit
配置文件可以使用 extends
密钥扩展另一个配置文件。例如,在 preview
配置文件中,你可能有 "extends": "production"
。这使得 preview
配置文件继承 production
配置文件的配置。
¥A submit
profile can extend another profile using the extends
key. For example, in the preview
profile you may have "extends": "production"
. This makes the preview
profile inherit the configuration of the production
profile.
¥Next step
了解 EAS Submit 的可用属性,以在项目内配置和覆盖其默认行为。