diff --git a/packages/eas-json/schema/eas.schema.json b/packages/eas-json/schema/eas.schema.json index a8724609fe..2339d2a338 100644 --- a/packages/eas-json/schema/eas.schema.json +++ b/packages/eas-json/schema/eas.schema.json @@ -512,7 +512,9 @@ "markdownDescription": "Path to the JSON file with service account key used to authenticate with Google Play. [Learn more](https://expo.fyi/creating-google-service-account)" }, "track": { - "enum": ["beta", "alpha", "internal", "production"], + "type": "string", + "minLength": 1, + "maxLength": 50, "description": "The track of the application to use. Learn more: https://support.google.com/googleplay/android-developer/answer/9859348?hl=en", "markdownDescription": "The [track of the application](https://support.google.com/googleplay/android-developer/answer/9859348?hl=en) to use.", "markdownEnumDescriptions": [ diff --git a/packages/eas-json/src/__tests__/submitProfiles-test.ts b/packages/eas-json/src/__tests__/submitProfiles-test.ts index 8a030c4ae0..b1d7da88a8 100644 --- a/packages/eas-json/src/__tests__/submitProfiles-test.ts +++ b/packages/eas-json/src/__tests__/submitProfiles-test.ts @@ -100,6 +100,99 @@ test('android config with serviceAccountKeyPath set to env var', async () => { } }); +test('android config without track name', async () => { + await fs.writeJson('/project/eas.json', { + submit: { + production: { + android: { + serviceAccountKeyPath: './path.json', + releaseStatus: 'completed', + }, + }, + }, + }); + + const accessor = EasJsonAccessor.fromProjectPath('/project'); + const androidProfile = await EasJsonUtils.getSubmitProfileAsync( + accessor, + Platform.ANDROID, + 'production' + ); + + expect(androidProfile).toEqual({ + serviceAccountKeyPath: './path.json', + track: 'internal', + releaseStatus: 'completed', + changesNotSentForReview: false, + }); +}); + +test('android config with non-empty string track name within 50 characters', async () => { + await fs.writeJson('/project/eas.json', { + submit: { + production: { + android: { + serviceAccountKeyPath: './path.json', + track: 'my-custom-track', + releaseStatus: 'completed', + }, + }, + }, + }); + + const accessor = EasJsonAccessor.fromProjectPath('/project'); + const androidProfile = await EasJsonUtils.getSubmitProfileAsync( + accessor, + Platform.ANDROID, + 'production' + ); + + expect(androidProfile).toEqual({ + serviceAccountKeyPath: './path.json', + track: 'my-custom-track', + changesNotSentForReview: false, + releaseStatus: 'completed', + }); +}); + +test('android config with non-empty string track name over 50 characters', async () => { + await fs.writeJson('/project/eas.json', { + submit: { + production: { + android: { + serviceAccountKeyPath: './path.json', + track: + 'lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua', + releaseStatus: 'completed', + }, + }, + }, + }); + + const accessor = EasJsonAccessor.fromProjectPath('/project'); + const promise = EasJsonUtils.getSubmitProfileAsync(accessor, Platform.ANDROID, 'production'); + + await expect(promise).rejects.toThrow(InvalidEasJsonError); +}); + +test('android config with empty string track value', async () => { + await fs.writeJson('/project/eas.json', { + submit: { + production: { + android: { + serviceAccountKeyPath: './path.json', + track: '', + releaseStatus: 'completed', + }, + }, + }, + }); + + const accessor = EasJsonAccessor.fromProjectPath('/project'); + const promise = EasJsonUtils.getSubmitProfileAsync(accessor, Platform.ANDROID, 'production'); + await expect(promise).rejects.toThrow(InvalidEasJsonError); +}); + test('ios config with all required values', async () => { await fs.writeJson('/project/eas.json', { submit: { diff --git a/packages/eas-json/src/submit/schema.ts b/packages/eas-json/src/submit/schema.ts index a27af46a05..891f729dcb 100644 --- a/packages/eas-json/src/submit/schema.ts +++ b/packages/eas-json/src/submit/schema.ts @@ -4,9 +4,7 @@ import { AndroidReleaseStatus, AndroidReleaseTrack } from './types'; export const AndroidSubmitProfileSchema = Joi.object({ serviceAccountKeyPath: Joi.string(), - track: Joi.string() - .valid(...Object.values(AndroidReleaseTrack)) - .default(AndroidReleaseTrack.internal), + track: Joi.string().min(1).max(50).default(AndroidReleaseTrack.internal), releaseStatus: Joi.string() .valid(...Object.values(AndroidReleaseStatus)) .default(AndroidReleaseStatus.completed),