@expo/eas-json 0.40.0 → 0.44.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.
@@ -4,6 +4,7 @@ exports.BuildProfileSchema = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const eas_build_job_1 = require("@expo/eas-build-job");
6
6
  const joi_1 = (0, tslib_1.__importDefault)(require("joi"));
7
+ const semver_1 = (0, tslib_1.__importDefault)(require("semver"));
7
8
  const CacheSchema = joi_1.default.object({
8
9
  disabled: joi_1.default.boolean(),
9
10
  key: joi_1.default.string().max(128),
@@ -17,9 +18,9 @@ const CommonBuildProfileSchema = joi_1.default.object({
17
18
  releaseChannel: joi_1.default.string().regex(/^[a-z\d][a-z\d._-]*$/),
18
19
  channel: joi_1.default.string().regex(/^[a-z\d][a-z\d._-]*$/),
19
20
  developmentClient: joi_1.default.boolean(),
20
- node: joi_1.default.string().empty(null).custom(semverSchemaCheck),
21
- yarn: joi_1.default.string().empty(null).custom(semverSchemaCheck),
22
- expoCli: joi_1.default.string().empty(null).custom(semverSchemaCheck),
21
+ node: joi_1.default.string().empty(null).custom(semverCheck),
22
+ yarn: joi_1.default.string().empty(null).custom(semverCheck),
23
+ expoCli: joi_1.default.string().empty(null).custom(semverCheck),
23
24
  env: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.string().empty(null)),
24
25
  });
25
26
  const AndroidBuildProfileSchema = CommonBuildProfileSchema.concat(joi_1.default.object({
@@ -27,7 +28,7 @@ const AndroidBuildProfileSchema = CommonBuildProfileSchema.concat(joi_1.default.
27
28
  distribution: joi_1.default.string().valid('store', 'internal'),
28
29
  withoutCredentials: joi_1.default.boolean(),
29
30
  image: joi_1.default.string().valid(...eas_build_job_1.Android.builderBaseImages),
30
- ndk: joi_1.default.string().empty(null).custom(semverSchemaCheck),
31
+ ndk: joi_1.default.string().empty(null).custom(semverCheck),
31
32
  autoIncrement: joi_1.default.alternatives().try(joi_1.default.boolean(), joi_1.default.string().valid('version', 'versionCode')),
32
33
  artifactPath: joi_1.default.string(),
33
34
  gradleCommand: joi_1.default.string(),
@@ -40,9 +41,9 @@ const IosBuildProfileSchema = CommonBuildProfileSchema.concat(joi_1.default.obje
40
41
  autoIncrement: joi_1.default.alternatives().try(joi_1.default.boolean(), joi_1.default.string().valid('version', 'buildNumber')),
41
42
  simulator: joi_1.default.boolean(),
42
43
  image: joi_1.default.string().valid(...eas_build_job_1.Ios.builderBaseImages),
43
- bundler: joi_1.default.string().empty(null).custom(semverSchemaCheck),
44
- fastlane: joi_1.default.string().empty(null).custom(semverSchemaCheck),
45
- cocoapods: joi_1.default.string().empty(null).custom(semverSchemaCheck),
44
+ bundler: joi_1.default.string().empty(null).custom(semverCheck),
45
+ fastlane: joi_1.default.string().empty(null).custom(semverCheck),
46
+ cocoapods: joi_1.default.string().empty(null).custom(semverCheck),
46
47
  artifactPath: joi_1.default.string(),
47
48
  scheme: joi_1.default.string(),
48
49
  buildConfiguration: joi_1.default.string(),
@@ -52,8 +53,8 @@ exports.BuildProfileSchema = CommonBuildProfileSchema.concat(joi_1.default.objec
52
53
  android: AndroidBuildProfileSchema,
53
54
  ios: IosBuildProfileSchema,
54
55
  }));
55
- function semverSchemaCheck(value) {
56
- if (/^[0-9]+\.[0-9]+\.[0-9]+$/.test(value)) {
56
+ function semverCheck(value) {
57
+ if (semver_1.default.valid(value)) {
57
58
  return value;
58
59
  }
59
60
  else {
package/build/reader.d.ts CHANGED
@@ -11,5 +11,6 @@ export declare class EasJsonReader {
11
11
  getBuildProfileNamesAsync(): Promise<string[]>;
12
12
  getBuildProfileAsync<T extends Platform>(platform: T, profileName: string): Promise<BuildProfile<T>>;
13
13
  getCliConfigAsync(): Promise<EasJson['cli'] | null>;
14
+ getSubmitProfileNamesAsync(): Promise<string[]>;
14
15
  getSubmitProfileAsync<T extends Platform>(platform: T, profileName: string): Promise<SubmitProfile<T>>;
15
16
  }
package/build/reader.js CHANGED
@@ -67,6 +67,11 @@ class EasJsonReader {
67
67
  throw err;
68
68
  }
69
69
  }
70
+ async getSubmitProfileNamesAsync() {
71
+ var _a;
72
+ const easJson = await this.readAsync();
73
+ return Object.keys((_a = easJson === null || easJson === void 0 ? void 0 : easJson.submit) !== null && _a !== void 0 ? _a : {});
74
+ }
70
75
  async getSubmitProfileAsync(platform, profileName) {
71
76
  const easJson = await this.readAsync();
72
77
  return (0, resolver_2.resolveSubmitProfile)({ easJson, platform, profileName });
@@ -25,7 +25,7 @@ function resolveProfile({ easJson, profileName, depth = 0, platform, }) {
25
25
  const profile = (_a = easJson.submit) === null || _a === void 0 ? void 0 : _a[profileName];
26
26
  if (!profile) {
27
27
  if (depth === 0) {
28
- throw new errors_1.MissingProfileError(`There is no submit profile named ${profileName} in eas.json`);
28
+ throw new errors_1.MissingProfileError(`Missing submit profile in eas.json: ${profileName}`);
29
29
  }
30
30
  else {
31
31
  throw new errors_1.MissingParentProfileError(`Extending non-existent submit profile in eas.json: ${profileName}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@expo/eas-json",
3
3
  "description": "A library for interacting with eas.json",
4
- "version": "0.40.0",
4
+ "version": "0.44.0",
5
5
  "author": "Expo <support@expo.dev>",
6
6
  "bugs": "https://github.com/expo/eas-cli/issues",
7
7
  "dependencies": {
@@ -12,6 +12,7 @@
12
12
  "fs-extra": "10.0.0",
13
13
  "joi": "17.4.2",
14
14
  "log-symbols": "4.1.0",
15
+ "semver": "7.3.5",
15
16
  "tslib": "2.3.1"
16
17
  },
17
18
  "devDependencies": {
@@ -38,5 +39,5 @@
38
39
  "publishConfig": {
39
40
  "access": "public"
40
41
  },
41
- "gitHead": "ddfe60a7b062736ffd724c59bb09832dd9d8df03"
42
+ "gitHead": "f46063cca55c6ccf1b2a4433fac7e7422b5c7fc8"
42
43
  }
@@ -253,14 +253,14 @@ test('empty json', async () => {
253
253
  test('invalid semver value', async () => {
254
254
  await fs.writeJson('/project/eas.json', {
255
255
  build: {
256
- production: { node: '12.0.0-alpha' },
256
+ production: { node: 'alpha' },
257
257
  },
258
258
  });
259
259
 
260
260
  const reader = new EasJsonReader('/project');
261
261
  const promise = reader.getBuildProfileAsync(Platform.ANDROID, 'production');
262
262
  await expect(promise).rejects.toThrowError(
263
- 'eas.json is not valid [ValidationError: "build.production.node" failed custom validation because 12.0.0-alpha is not a valid version]'
263
+ 'eas.json is not valid [ValidationError: "build.production.node" failed custom validation because alpha is not a valid version]'
264
264
  );
265
265
  });
266
266
 
@@ -279,7 +279,7 @@ test('invalid release channel', async () => {
279
279
  test('get profile names', async () => {
280
280
  await fs.writeJson('/project/eas.json', {
281
281
  build: {
282
- production: { node: '12.0.0' },
282
+ production: { node: '12.0.0-alpha' },
283
283
  blah: { node: '12.0.0' },
284
284
  },
285
285
  });
@@ -195,3 +195,28 @@ test('valid profile extending other profile', async () => {
195
195
  ascApiKeyId: 'ABCD',
196
196
  });
197
197
  });
198
+
199
+ test('get profile names', async () => {
200
+ await fs.writeJson('/project/eas.json', {
201
+ submit: {
202
+ production: {
203
+ android: {
204
+ serviceAccountKeyPath: './path.json',
205
+ track: 'beta',
206
+ releaseStatus: 'completed',
207
+ },
208
+ },
209
+ blah: {
210
+ android: {
211
+ serviceAccountKeyPath: './path.json',
212
+ track: 'internal',
213
+ releaseStatus: 'completed',
214
+ },
215
+ },
216
+ },
217
+ });
218
+
219
+ const reader = new EasJsonReader('/project');
220
+ const allProfileNames = await reader.getSubmitProfileNamesAsync();
221
+ expect(allProfileNames.sort()).toEqual(['production', 'blah'].sort());
222
+ });
@@ -1,5 +1,6 @@
1
1
  import { Android, Ios } from '@expo/eas-build-job';
2
2
  import Joi from 'joi';
3
+ import semver from 'semver';
3
4
 
4
5
  const CacheSchema = Joi.object({
5
6
  disabled: Joi.boolean(),
@@ -16,9 +17,9 @@ const CommonBuildProfileSchema = Joi.object({
16
17
  channel: Joi.string().regex(/^[a-z\d][a-z\d._-]*$/),
17
18
  developmentClient: Joi.boolean(),
18
19
 
19
- node: Joi.string().empty(null).custom(semverSchemaCheck),
20
- yarn: Joi.string().empty(null).custom(semverSchemaCheck),
21
- expoCli: Joi.string().empty(null).custom(semverSchemaCheck),
20
+ node: Joi.string().empty(null).custom(semverCheck),
21
+ yarn: Joi.string().empty(null).custom(semverCheck),
22
+ expoCli: Joi.string().empty(null).custom(semverCheck),
22
23
  env: Joi.object().pattern(Joi.string(), Joi.string().empty(null)),
23
24
  });
24
25
 
@@ -29,7 +30,7 @@ const AndroidBuildProfileSchema = CommonBuildProfileSchema.concat(
29
30
  withoutCredentials: Joi.boolean(),
30
31
 
31
32
  image: Joi.string().valid(...Android.builderBaseImages),
32
- ndk: Joi.string().empty(null).custom(semverSchemaCheck),
33
+ ndk: Joi.string().empty(null).custom(semverCheck),
33
34
  autoIncrement: Joi.alternatives().try(
34
35
  Joi.boolean(),
35
36
  Joi.string().valid('version', 'versionCode')
@@ -54,9 +55,9 @@ const IosBuildProfileSchema = CommonBuildProfileSchema.concat(
54
55
  simulator: Joi.boolean(),
55
56
 
56
57
  image: Joi.string().valid(...Ios.builderBaseImages),
57
- bundler: Joi.string().empty(null).custom(semverSchemaCheck),
58
- fastlane: Joi.string().empty(null).custom(semverSchemaCheck),
59
- cocoapods: Joi.string().empty(null).custom(semverSchemaCheck),
58
+ bundler: Joi.string().empty(null).custom(semverCheck),
59
+ fastlane: Joi.string().empty(null).custom(semverCheck),
60
+ cocoapods: Joi.string().empty(null).custom(semverCheck),
60
61
 
61
62
  artifactPath: Joi.string(),
62
63
  scheme: Joi.string(),
@@ -72,8 +73,8 @@ export const BuildProfileSchema = CommonBuildProfileSchema.concat(
72
73
  })
73
74
  );
74
75
 
75
- function semverSchemaCheck(value: any): any {
76
- if (/^[0-9]+\.[0-9]+\.[0-9]+$/.test(value)) {
76
+ function semverCheck(value: any): any {
77
+ if (semver.valid(value)) {
77
78
  return value;
78
79
  } else {
79
80
  throw new Error(`${value} is not a valid version`);
package/src/reader.ts CHANGED
@@ -77,6 +77,11 @@ export class EasJsonReader {
77
77
  }
78
78
  }
79
79
 
80
+ public async getSubmitProfileNamesAsync(): Promise<string[]> {
81
+ const easJson = await this.readAsync();
82
+ return Object.keys(easJson?.submit ?? {});
83
+ }
84
+
80
85
  public async getSubmitProfileAsync<T extends Platform>(
81
86
  platform: T,
82
87
  profileName: string
@@ -48,7 +48,7 @@ function resolveProfile<T extends Platform>({
48
48
  const profile = easJson.submit?.[profileName];
49
49
  if (!profile) {
50
50
  if (depth === 0) {
51
- throw new MissingProfileError(`There is no submit profile named ${profileName} in eas.json`);
51
+ throw new MissingProfileError(`Missing submit profile in eas.json: ${profileName}`);
52
52
  } else {
53
53
  throw new MissingParentProfileError(
54
54
  `Extending non-existent submit profile in eas.json: ${profileName}`