@expo/eas-json 0.28.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,9 @@ export declare enum CredentialsSource {
5
5
  }
6
6
  export declare type DistributionType = 'store' | 'internal';
7
7
  export declare type IosEnterpriseProvisioning = 'adhoc' | 'universal';
8
- export declare type VersionAutoIncrement = boolean | 'version' | 'buildNumber';
8
+ export declare type VersionAutoIncrement = boolean | 'version';
9
+ export declare type IosVersionAutoIncrement = VersionAutoIncrement | 'buildNumber';
10
+ export declare type AndroidVersionAutoIncrement = VersionAutoIncrement | 'versionCode';
9
11
  export interface CommonBuildProfile {
10
12
  credentialsSource: CredentialsSource;
11
13
  distribution: DistributionType;
@@ -22,13 +24,14 @@ export interface AndroidBuildProfile extends CommonBuildProfile {
22
24
  withoutCredentials?: boolean;
23
25
  image?: Android.BuilderEnvironment['image'];
24
26
  ndk?: string;
27
+ autoIncrement?: AndroidVersionAutoIncrement;
25
28
  buildType?: Android.BuildType.APK | Android.BuildType.APP_BUNDLE;
26
29
  gradleCommand?: string;
27
30
  artifactPath?: string;
28
31
  }
29
32
  export interface IosBuildProfile extends CommonBuildProfile {
30
33
  enterpriseProvisioning?: IosEnterpriseProvisioning;
31
- autoIncrement?: VersionAutoIncrement;
34
+ autoIncrement?: IosVersionAutoIncrement;
32
35
  simulator?: boolean;
33
36
  image?: Ios.BuilderEnvironment['image'];
34
37
  bundler?: string;
@@ -1,3 +1,4 @@
1
+ import { Platform } from '@expo/eas-build-job';
1
2
  import { AndroidBuildProfile, CommonBuildProfile, IosBuildProfile } from './EasBuild.types';
2
3
  import { AndroidSubmitProfile, IosSubmitProfile } from './EasSubmit.types';
3
4
  export declare enum CredentialsSource {
@@ -6,12 +7,12 @@ export declare enum CredentialsSource {
6
7
  }
7
8
  export interface RawBuildProfile extends Partial<CommonBuildProfile> {
8
9
  extends?: string;
9
- android?: Partial<AndroidBuildProfile>;
10
- ios?: Partial<IosBuildProfile>;
10
+ [Platform.ANDROID]?: Partial<AndroidBuildProfile>;
11
+ [Platform.IOS]?: Partial<IosBuildProfile>;
11
12
  }
12
13
  export interface EasSubmitConfiguration {
13
- android?: AndroidSubmitProfile;
14
- ios?: IosSubmitProfile;
14
+ [Platform.ANDROID]?: AndroidSubmitProfile;
15
+ [Platform.IOS]?: IosSubmitProfile;
15
16
  }
16
17
  export interface EasJson {
17
18
  build: {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CredentialsSource = void 0;
4
+ const eas_build_job_1 = require("@expo/eas-build-job");
4
5
  var CredentialsSource;
5
6
  (function (CredentialsSource) {
6
7
  CredentialsSource["LOCAL"] = "local";
@@ -57,7 +57,7 @@ class EasJsonReader {
57
57
  }
58
58
  }
59
59
  async readSubmitProfileAsync(platform, profileName) {
60
- var _a, _b;
60
+ var _a;
61
61
  if (!profileName) {
62
62
  const profileNames = await this.getSubmitProfileNamesAsync({
63
63
  throwIfEasJsonDoesNotExist: false,
@@ -70,11 +70,17 @@ class EasJsonReader {
70
70
  }
71
71
  }
72
72
  const easJson = await this.readAndValidateAsync();
73
- const profile = (_b = (_a = easJson === null || easJson === void 0 ? void 0 : easJson.submit) === null || _a === void 0 ? void 0 : _a[profileName]) === null || _b === void 0 ? void 0 : _b[platform];
73
+ const profile = (_a = easJson === null || easJson === void 0 ? void 0 : easJson.submit) === null || _a === void 0 ? void 0 : _a[profileName];
74
74
  if (!profile) {
75
- throw new Error(`There is no profile named ${profileName} in eas.json for ${platform}.`);
75
+ throw new Error(`There is no profile named ${profileName} in eas.json`);
76
+ }
77
+ const platformProfile = profile[platform];
78
+ if (platformProfile) {
79
+ return this.evaluateFields(platform, platformProfile);
80
+ }
81
+ else {
82
+ return getDefaultSubmitProfile(platform);
76
83
  }
77
- return this.evaluateFields(platform, profile);
78
84
  }
79
85
  async readAndValidateAsync() {
80
86
  const easJson = await this.readRawAsync();
@@ -111,7 +117,7 @@ class EasJsonReader {
111
117
  }
112
118
  const buildProfile = easJson.build[profileName];
113
119
  if (!buildProfile) {
114
- throw new Error(`There is no profile named ${profileName}`);
120
+ throw new Error(`There is no profile named ${profileName} in eas.json`);
115
121
  }
116
122
  const { extends: baseProfileName, ...buildProfileRest } = buildProfile;
117
123
  if (baseProfileName) {
@@ -123,7 +129,7 @@ class EasJsonReader {
123
129
  }
124
130
  ensureBuildProfileExists(easJson, profileName) {
125
131
  if (!easJson.build || !easJson.build[profileName]) {
126
- throw new Error(`There is no profile named ${profileName} in eas.json.`);
132
+ throw new Error(`There is no profile named ${profileName} in eas.json`);
127
133
  }
128
134
  }
129
135
  evaluateFields(platform, profile) {
@@ -35,6 +35,7 @@ const AndroidBuildProfileSchema = CommonBuildProfileSchema.concat(joi_1.default.
35
35
  withoutCredentials: joi_1.default.boolean(),
36
36
  image: joi_1.default.string().valid(...eas_build_job_1.Android.builderBaseImages),
37
37
  ndk: joi_1.default.string().empty(null).custom(semverSchemaCheck),
38
+ autoIncrement: joi_1.default.alternatives().try(joi_1.default.boolean(), joi_1.default.string().valid('version', 'versionCode')),
38
39
  artifactPath: joi_1.default.string(),
39
40
  gradleCommand: joi_1.default.string(),
40
41
  buildType: joi_1.default.string().valid('apk', 'app-bundle'),
package/build/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { AndroidSubmitProfile, AndroidReleaseStatus, AndroidReleaseTrack, IosSubmitProfile, SubmitProfile, } from './EasSubmit.types';
2
2
  export { EasJson } from './EasJson.types';
3
- export { AndroidBuildProfile, BuildProfile, CredentialsSource, DistributionType, IosBuildProfile, IosEnterpriseProvisioning, VersionAutoIncrement, } from './EasBuild.types';
3
+ export { AndroidBuildProfile, BuildProfile, CredentialsSource, DistributionType, IosBuildProfile, IosEnterpriseProvisioning, IosVersionAutoIncrement, AndroidVersionAutoIncrement, } from './EasBuild.types';
4
4
  export { EasJsonReader } from './EasJsonReader';
5
5
  export { hasMismatchedExtendsAsync, isUsingDeprecatedFormatAsync, migrateAsync } from './migrate';
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@expo/eas-json",
3
3
  "description": "A library for interacting with the eas.json",
4
- "version": "0.28.0",
4
+ "version": "0.31.0",
5
5
  "author": "Expo <support@expo.dev>",
6
6
  "bugs": "https://github.com/expo/eas-cli/issues",
7
7
  "dependencies": {
8
- "@expo/eas-build-job": "0.2.46",
8
+ "@expo/eas-build-job": "0.2.52",
9
9
  "@expo/json-file": "8.2.33",
10
10
  "env-string": "1.0.1",
11
11
  "fs-extra": "10.0.0",
@@ -33,5 +33,5 @@
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
- "gitHead": "2364ed74d724961428514bbfd9a85a13c52a1e8e"
36
+ "gitHead": "def91af01fe43106714f7782316d61270395a2ff"
37
37
  }
@@ -9,7 +9,9 @@ export type DistributionType = 'store' | 'internal';
9
9
 
10
10
  export type IosEnterpriseProvisioning = 'adhoc' | 'universal';
11
11
 
12
- export type VersionAutoIncrement = boolean | 'version' | 'buildNumber';
12
+ export type VersionAutoIncrement = boolean | 'version';
13
+ export type IosVersionAutoIncrement = VersionAutoIncrement | 'buildNumber';
14
+ export type AndroidVersionAutoIncrement = VersionAutoIncrement | 'versionCode';
13
15
 
14
16
  export interface CommonBuildProfile {
15
17
  credentialsSource: CredentialsSource;
@@ -29,6 +31,7 @@ export interface AndroidBuildProfile extends CommonBuildProfile {
29
31
  withoutCredentials?: boolean;
30
32
  image?: Android.BuilderEnvironment['image'];
31
33
  ndk?: string;
34
+ autoIncrement?: AndroidVersionAutoIncrement;
32
35
 
33
36
  buildType?: Android.BuildType.APK | Android.BuildType.APP_BUNDLE;
34
37
 
@@ -38,7 +41,7 @@ export interface AndroidBuildProfile extends CommonBuildProfile {
38
41
 
39
42
  export interface IosBuildProfile extends CommonBuildProfile {
40
43
  enterpriseProvisioning?: IosEnterpriseProvisioning;
41
- autoIncrement?: VersionAutoIncrement;
44
+ autoIncrement?: IosVersionAutoIncrement;
42
45
  simulator?: boolean;
43
46
  image?: Ios.BuilderEnvironment['image'];
44
47
  bundler?: string;
@@ -1,3 +1,5 @@
1
+ import { Platform } from '@expo/eas-build-job';
2
+
1
3
  import { AndroidBuildProfile, CommonBuildProfile, IosBuildProfile } from './EasBuild.types';
2
4
  import { AndroidSubmitProfile, IosSubmitProfile } from './EasSubmit.types';
3
5
 
@@ -8,13 +10,13 @@ export enum CredentialsSource {
8
10
 
9
11
  export interface RawBuildProfile extends Partial<CommonBuildProfile> {
10
12
  extends?: string;
11
- android?: Partial<AndroidBuildProfile>;
12
- ios?: Partial<IosBuildProfile>;
13
+ [Platform.ANDROID]?: Partial<AndroidBuildProfile>;
14
+ [Platform.IOS]?: Partial<IosBuildProfile>;
13
15
  }
14
16
 
15
17
  export interface EasSubmitConfiguration {
16
- android?: AndroidSubmitProfile;
17
- ios?: IosSubmitProfile;
18
+ [Platform.ANDROID]?: AndroidSubmitProfile;
19
+ [Platform.IOS]?: IosSubmitProfile;
18
20
  }
19
21
 
20
22
  export interface EasJson {
@@ -94,11 +94,16 @@ export class EasJsonReader {
94
94
  }
95
95
  }
96
96
  const easJson = await this.readAndValidateAsync();
97
- const profile = easJson?.submit?.[profileName]?.[platform];
97
+ const profile = easJson?.submit?.[profileName];
98
98
  if (!profile) {
99
- throw new Error(`There is no profile named ${profileName} in eas.json for ${platform}.`);
99
+ throw new Error(`There is no profile named ${profileName} in eas.json`);
100
+ }
101
+ const platformProfile = profile[platform];
102
+ if (platformProfile) {
103
+ return this.evaluateFields(platform, platformProfile as SubmitProfile<T>);
104
+ } else {
105
+ return getDefaultSubmitProfile(platform);
100
106
  }
101
- return this.evaluateFields(platform, profile as SubmitProfile<T>);
102
107
  }
103
108
 
104
109
  public async readAndValidateAsync(): Promise<EasJson> {
@@ -144,7 +149,7 @@ export class EasJsonReader {
144
149
  }
145
150
  const buildProfile = easJson.build[profileName];
146
151
  if (!buildProfile) {
147
- throw new Error(`There is no profile named ${profileName}`);
152
+ throw new Error(`There is no profile named ${profileName} in eas.json`);
148
153
  }
149
154
  const { extends: baseProfileName, ...buildProfileRest } = buildProfile;
150
155
  if (baseProfileName) {
@@ -159,7 +164,7 @@ export class EasJsonReader {
159
164
 
160
165
  private ensureBuildProfileExists(easJson: EasJson, profileName: string): void {
161
166
  if (!easJson.build || !easJson.build[profileName]) {
162
- throw new Error(`There is no profile named ${profileName} in eas.json.`);
167
+ throw new Error(`There is no profile named ${profileName} in eas.json`);
163
168
  }
164
169
  }
165
170
 
@@ -38,6 +38,10 @@ const AndroidBuildProfileSchema = CommonBuildProfileSchema.concat(
38
38
 
39
39
  image: Joi.string().valid(...Android.builderBaseImages),
40
40
  ndk: Joi.string().empty(null).custom(semverSchemaCheck),
41
+ autoIncrement: Joi.alternatives().try(
42
+ Joi.boolean(),
43
+ Joi.string().valid('version', 'versionCode')
44
+ ),
41
45
 
42
46
  artifactPath: Joi.string(),
43
47
  gradleCommand: Joi.string(),
@@ -225,7 +225,7 @@ test('valid eas.json with missing profile', async () => {
225
225
 
226
226
  const reader = new EasJsonReader('/project');
227
227
  const promise = reader.readBuildProfileAsync(Platform.ANDROID, 'debug');
228
- await expect(promise).rejects.toThrowError('There is no profile named debug in eas.json.');
228
+ await expect(promise).rejects.toThrowError('There is no profile named debug in eas.json');
229
229
  });
230
230
 
231
231
  test('invalid eas.json when using wrong buildType', async () => {
@@ -247,7 +247,7 @@ test('empty json', async () => {
247
247
 
248
248
  const reader = new EasJsonReader('/project');
249
249
  const promise = reader.readBuildProfileAsync(Platform.ANDROID, 'release');
250
- await expect(promise).rejects.toThrowError('There is no profile named release in eas.json.');
250
+ await expect(promise).rejects.toThrowError('There is no profile named release in eas.json');
251
251
  });
252
252
 
253
253
  test('invalid semver value', async () => {
@@ -14,10 +14,7 @@ beforeEach(async () => {
14
14
  test('minimal allowed eas.json for both platforms', async () => {
15
15
  await fs.writeJson('/project/eas.json', {
16
16
  submit: {
17
- release: {
18
- android: {},
19
- ios: {},
20
- },
17
+ release: {},
21
18
  },
22
19
  });
23
20
 
@@ -111,22 +108,3 @@ test('ios config with all required values', async () => {
111
108
  language: 'en-US',
112
109
  });
113
110
  });
114
-
115
- test('missing ios profile', async () => {
116
- await fs.writeJson('/project/eas.json', {
117
- submit: {
118
- release: {
119
- android: {
120
- serviceAccountKeyPath: './path.json',
121
- track: 'beta',
122
- releaseStatus: 'completed',
123
- },
124
- },
125
- },
126
- });
127
-
128
- const reader = new EasJsonReader('/project');
129
- const promise = reader.readSubmitProfileAsync(Platform.IOS, 'release');
130
-
131
- expect(promise).rejects.toThrow('There is no profile named release in eas.json for ios.');
132
- });
package/src/index.ts CHANGED
@@ -13,7 +13,8 @@ export {
13
13
  DistributionType,
14
14
  IosBuildProfile,
15
15
  IosEnterpriseProvisioning,
16
- VersionAutoIncrement,
16
+ IosVersionAutoIncrement,
17
+ AndroidVersionAutoIncrement,
17
18
  } from './EasBuild.types';
18
19
  export { EasJsonReader } from './EasJsonReader';
19
20
  export { hasMismatchedExtendsAsync, isUsingDeprecatedFormatAsync, migrateAsync } from './migrate';