@expo/eas-json 0.36.0 → 0.38.3
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.
- package/build/build/resolver.d.ts +8 -0
- package/build/build/resolver.js +67 -0
- package/build/build/schema.d.ts +2 -0
- package/build/{EasJsonSchema.js → build/schema.js} +18 -55
- package/build/{EasBuild.types.d.ts → build/types.d.ts} +6 -1
- package/build/{EasJson.types.js → build/types.js} +0 -0
- package/build/errors.d.ts +6 -0
- package/build/errors.js +10 -1
- package/build/index.d.ts +5 -4
- package/build/index.js +10 -8
- package/build/reader.d.ts +15 -0
- package/build/reader.js +75 -0
- package/build/schema.d.ts +2 -0
- package/build/schema.js +15 -0
- package/build/submit/resolver.d.ts +9 -0
- package/build/submit/resolver.js +72 -0
- package/build/submit/schema.d.ts +4 -0
- package/build/submit/schema.js +35 -0
- package/build/{EasSubmit.types.d.ts → submit/types.d.ts} +8 -1
- package/build/{EasSubmit.types.js → submit/types.js} +1 -0
- package/build/types.d.ts +20 -0
- package/build/{EasBuild.types.js → types.js} +0 -0
- package/package.json +4 -3
- package/src/__tests__/{EasJsonReader-build-test.ts → reader-build-test.ts} +60 -48
- package/src/__tests__/{EasJsonReader-submit-test.ts → reader-submit-test.ts} +49 -7
- package/src/build/resolver.ts +97 -0
- package/src/{EasJsonSchema.ts → build/schema.ts} +16 -60
- package/src/{EasBuild.types.ts → build/types.ts} +7 -5
- package/src/errors.ts +6 -0
- package/src/index.ts +6 -13
- package/src/reader.ts +87 -0
- package/src/schema.ts +13 -0
- package/src/submit/resolver.ts +114 -0
- package/src/submit/schema.ts +35 -0
- package/src/{EasSubmit.types.ts → submit/types.ts} +9 -7
- package/src/types.ts +21 -0
- package/build/EasJson.types.d.ts +0 -29
- package/build/EasJsonReader.d.ts +0 -39
- package/build/EasJsonReader.js +0 -204
- package/build/EasJsonSchema.d.ts +0 -6
- package/src/EasJson.types.ts +0 -31
- package/src/EasJsonReader.ts +0 -259
package/src/reader.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Platform } from '@expo/eas-build-job';
|
|
2
|
+
import JsonFile from '@expo/json-file';
|
|
3
|
+
import fs from 'fs-extra';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
|
|
6
|
+
import { resolveBuildProfile } from './build/resolver';
|
|
7
|
+
import { BuildProfile } from './build/types';
|
|
8
|
+
import { InvalidEasJsonError, MissingEasJsonError } from './errors';
|
|
9
|
+
import { EasJsonSchema } from './schema';
|
|
10
|
+
import { resolveSubmitProfile } from './submit/resolver';
|
|
11
|
+
import { SubmitProfile } from './submit/types';
|
|
12
|
+
import { EasJson } from './types';
|
|
13
|
+
|
|
14
|
+
export class EasJsonReader {
|
|
15
|
+
private easJson: EasJson | undefined;
|
|
16
|
+
|
|
17
|
+
constructor(private projectDir: string) {}
|
|
18
|
+
|
|
19
|
+
public static formatEasJsonPath(projectDir: string): string {
|
|
20
|
+
return path.join(projectDir, 'eas.json');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public async readAsync(): Promise<EasJson> {
|
|
24
|
+
if (this.easJson) {
|
|
25
|
+
return this.easJson;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const easJsonPath = EasJsonReader.formatEasJsonPath(this.projectDir);
|
|
30
|
+
if (!(await fs.pathExists(easJsonPath))) {
|
|
31
|
+
throw new MissingEasJsonError(
|
|
32
|
+
`eas.json could not be found at ${easJsonPath}. Learn more at https://expo.fyi/eas-json`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
const contents = JsonFile.read(easJsonPath);
|
|
36
|
+
const { value, error } = EasJsonSchema.validate(contents, {
|
|
37
|
+
allowUnknown: false,
|
|
38
|
+
abortEarly: false,
|
|
39
|
+
convert: true,
|
|
40
|
+
noDefaults: true,
|
|
41
|
+
});
|
|
42
|
+
if (error) {
|
|
43
|
+
throw new InvalidEasJsonError(`eas.json is not valid [${error.toString()}]`);
|
|
44
|
+
}
|
|
45
|
+
this.easJson = value;
|
|
46
|
+
return value;
|
|
47
|
+
} catch (err: any) {
|
|
48
|
+
if (err.code === 'EJSONPARSE') {
|
|
49
|
+
err.message = `Found invalid JSON in eas.json. ${err.message}`;
|
|
50
|
+
}
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public async getBuildProfileNamesAsync(): Promise<string[]> {
|
|
56
|
+
const easJson = await this.readAsync();
|
|
57
|
+
return Object.keys(easJson?.build ?? {});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public async getBuildProfileAsync<T extends Platform>(
|
|
61
|
+
platform: T,
|
|
62
|
+
profileName: string
|
|
63
|
+
): Promise<BuildProfile<T>> {
|
|
64
|
+
const easJson = await this.readAsync();
|
|
65
|
+
return resolveBuildProfile({ easJson, platform, profileName });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public async getCliConfigAsync(): Promise<EasJson['cli'] | null> {
|
|
69
|
+
try {
|
|
70
|
+
const easJson = await this.readAsync();
|
|
71
|
+
return easJson.cli ?? null;
|
|
72
|
+
} catch (err: any) {
|
|
73
|
+
if (err instanceof MissingEasJsonError) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
throw err;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public async getSubmitProfileAsync<T extends Platform>(
|
|
81
|
+
platform: T,
|
|
82
|
+
profileName: string
|
|
83
|
+
): Promise<SubmitProfile<T>> {
|
|
84
|
+
const easJson = await this.readAsync();
|
|
85
|
+
return resolveSubmitProfile({ easJson, platform, profileName });
|
|
86
|
+
}
|
|
87
|
+
}
|
package/src/schema.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Joi from 'joi';
|
|
2
|
+
|
|
3
|
+
import { BuildProfileSchema } from './build/schema';
|
|
4
|
+
import { SubmitProfileSchema } from './submit/schema';
|
|
5
|
+
|
|
6
|
+
export const EasJsonSchema = Joi.object({
|
|
7
|
+
cli: Joi.object({
|
|
8
|
+
version: Joi.string(),
|
|
9
|
+
requireCommit: Joi.boolean(),
|
|
10
|
+
}),
|
|
11
|
+
build: Joi.object().pattern(Joi.string(), BuildProfileSchema),
|
|
12
|
+
submit: Joi.object().pattern(Joi.string(), SubmitProfileSchema),
|
|
13
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Platform } from '@expo/eas-build-job';
|
|
2
|
+
import envString from 'env-string';
|
|
3
|
+
|
|
4
|
+
import { MissingParentProfileError, MissingProfileError } from '../errors';
|
|
5
|
+
import { EasJson } from '../types';
|
|
6
|
+
import { AndroidSubmitProfileSchema, IosSubmitProfileSchema } from './schema';
|
|
7
|
+
import {
|
|
8
|
+
AndroidSubmitProfileFieldsToEvaluate,
|
|
9
|
+
IosSubmitProfileFieldsToEvaluate,
|
|
10
|
+
SubmitProfile,
|
|
11
|
+
} from './types';
|
|
12
|
+
|
|
13
|
+
export function resolveSubmitProfile<T extends Platform>({
|
|
14
|
+
easJson,
|
|
15
|
+
platform,
|
|
16
|
+
profileName,
|
|
17
|
+
}: {
|
|
18
|
+
easJson: EasJson;
|
|
19
|
+
platform: T;
|
|
20
|
+
profileName: string;
|
|
21
|
+
}): SubmitProfile<T> {
|
|
22
|
+
const submitProfile = resolveProfile({
|
|
23
|
+
easJson,
|
|
24
|
+
platform,
|
|
25
|
+
profileName,
|
|
26
|
+
});
|
|
27
|
+
const unevaluatedProfile = mergeProfiles(getDefaultProfile(platform), submitProfile);
|
|
28
|
+
return evaluateFields(platform, unevaluatedProfile);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function resolveProfile<T extends Platform>({
|
|
32
|
+
easJson,
|
|
33
|
+
profileName,
|
|
34
|
+
depth = 0,
|
|
35
|
+
platform,
|
|
36
|
+
}: {
|
|
37
|
+
platform: T;
|
|
38
|
+
easJson: EasJson;
|
|
39
|
+
profileName: string;
|
|
40
|
+
depth?: number;
|
|
41
|
+
}): SubmitProfile<T> | undefined {
|
|
42
|
+
if (depth >= 2) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
'Too long chain of profile extensions, make sure "extends" keys do not make a cycle'
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const profile = easJson.submit?.[profileName];
|
|
49
|
+
if (!profile) {
|
|
50
|
+
if (depth === 0) {
|
|
51
|
+
throw new MissingProfileError(`There is no submit profile named ${profileName} in eas.json`);
|
|
52
|
+
} else {
|
|
53
|
+
throw new MissingParentProfileError(
|
|
54
|
+
`Extending non-existent submit profile in eas.json: ${profileName}`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const { extends: baseProfileName, ...rest } = profile;
|
|
60
|
+
const platformProfile = rest[platform] as SubmitProfile<T> | undefined;
|
|
61
|
+
if (baseProfileName) {
|
|
62
|
+
const baseProfile = resolveProfile({
|
|
63
|
+
easJson,
|
|
64
|
+
platform,
|
|
65
|
+
profileName: baseProfileName,
|
|
66
|
+
depth: depth + 1,
|
|
67
|
+
});
|
|
68
|
+
return mergeProfiles(baseProfile, platformProfile);
|
|
69
|
+
} else {
|
|
70
|
+
return platformProfile;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function mergeProfiles<T extends Platform>(
|
|
75
|
+
base: SubmitProfile<T>,
|
|
76
|
+
update?: SubmitProfile<T>
|
|
77
|
+
): SubmitProfile<T>;
|
|
78
|
+
function mergeProfiles<T extends Platform>(
|
|
79
|
+
base?: SubmitProfile<T>,
|
|
80
|
+
update?: SubmitProfile<T>
|
|
81
|
+
): SubmitProfile<T> | undefined;
|
|
82
|
+
function mergeProfiles<T extends Platform>(
|
|
83
|
+
base?: SubmitProfile<T>,
|
|
84
|
+
update?: SubmitProfile<T>
|
|
85
|
+
): SubmitProfile<T> | undefined {
|
|
86
|
+
if (!update) {
|
|
87
|
+
return base;
|
|
88
|
+
}
|
|
89
|
+
return { ...base, ...update };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function getDefaultProfile<T extends Platform>(platform: T): SubmitProfile<T> {
|
|
93
|
+
const Schema =
|
|
94
|
+
platform === Platform.ANDROID ? AndroidSubmitProfileSchema : IosSubmitProfileSchema;
|
|
95
|
+
return Schema.validate({}, { allowUnknown: false, abortEarly: false, convert: true }).value;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function evaluateFields<T extends Platform>(
|
|
99
|
+
platform: T,
|
|
100
|
+
profile: SubmitProfile<T>
|
|
101
|
+
): SubmitProfile<T> {
|
|
102
|
+
const fields =
|
|
103
|
+
platform === Platform.ANDROID
|
|
104
|
+
? AndroidSubmitProfileFieldsToEvaluate
|
|
105
|
+
: IosSubmitProfileFieldsToEvaluate;
|
|
106
|
+
const evaluatedProfile = { ...profile };
|
|
107
|
+
for (const field of fields) {
|
|
108
|
+
if (field in evaluatedProfile) {
|
|
109
|
+
// @ts-ignore
|
|
110
|
+
evaluatedProfile[field] = envString(evaluatedProfile[field], process.env);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return evaluatedProfile;
|
|
114
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Joi from 'joi';
|
|
2
|
+
|
|
3
|
+
import { AndroidReleaseStatus, AndroidReleaseTrack } from './types';
|
|
4
|
+
|
|
5
|
+
export const AndroidSubmitProfileSchema = Joi.object({
|
|
6
|
+
serviceAccountKeyPath: Joi.string(),
|
|
7
|
+
track: Joi.string()
|
|
8
|
+
.valid(...Object.values(AndroidReleaseTrack))
|
|
9
|
+
.default(AndroidReleaseTrack.internal),
|
|
10
|
+
releaseStatus: Joi.string()
|
|
11
|
+
.valid(...Object.values(AndroidReleaseStatus))
|
|
12
|
+
.default(AndroidReleaseStatus.completed),
|
|
13
|
+
changesNotSentForReview: Joi.boolean().default(false),
|
|
14
|
+
applicationId: Joi.string(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const IosSubmitProfileSchema = Joi.object({
|
|
18
|
+
ascApiKeyPath: Joi.string(),
|
|
19
|
+
ascApiKeyId: Joi.string(),
|
|
20
|
+
ascApiKeyIssuerId: Joi.string(),
|
|
21
|
+
appleId: Joi.string(),
|
|
22
|
+
ascAppId: Joi.string(),
|
|
23
|
+
appleTeamId: Joi.string(),
|
|
24
|
+
sku: Joi.string(),
|
|
25
|
+
language: Joi.string().default('en-US'),
|
|
26
|
+
companyName: Joi.string(),
|
|
27
|
+
appName: Joi.string(),
|
|
28
|
+
bundleIdentifier: Joi.string(),
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export const SubmitProfileSchema = Joi.object({
|
|
32
|
+
extends: Joi.string(),
|
|
33
|
+
android: AndroidSubmitProfileSchema,
|
|
34
|
+
ios: IosSubmitProfileSchema,
|
|
35
|
+
});
|
|
@@ -19,6 +19,7 @@ export interface AndroidSubmitProfile {
|
|
|
19
19
|
track: AndroidReleaseTrack;
|
|
20
20
|
releaseStatus: AndroidReleaseStatus;
|
|
21
21
|
changesNotSentForReview: boolean;
|
|
22
|
+
applicationId?: string;
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
export const AndroidSubmitProfileFieldsToEvaluate: (keyof AndroidSubmitProfile)[] = [
|
|
@@ -36,6 +37,7 @@ export interface IosSubmitProfile {
|
|
|
36
37
|
language: string;
|
|
37
38
|
companyName?: string;
|
|
38
39
|
appName?: string;
|
|
40
|
+
bundleIdentifier?: string;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export const IosSubmitProfileFieldsToEvaluate: (keyof IosSubmitProfile)[] = [
|
|
@@ -45,10 +47,10 @@ export const IosSubmitProfileFieldsToEvaluate: (keyof IosSubmitProfile)[] = [
|
|
|
45
47
|
];
|
|
46
48
|
|
|
47
49
|
export type SubmitProfile<TPlatform extends Platform = Platform> =
|
|
48
|
-
TPlatform extends Platform.ANDROID
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
TPlatform extends Platform.ANDROID ? AndroidSubmitProfile : IosSubmitProfile;
|
|
51
|
+
|
|
52
|
+
export interface EasJsonSubmitProfile {
|
|
53
|
+
extends?: string;
|
|
54
|
+
[Platform.ANDROID]?: AndroidSubmitProfile;
|
|
55
|
+
[Platform.IOS]?: IosSubmitProfile;
|
|
56
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EasJsonBuildProfile } from './build/types';
|
|
2
|
+
import { EasJsonSubmitProfile } from './submit/types';
|
|
3
|
+
|
|
4
|
+
export type ProfileType = 'build' | 'submit';
|
|
5
|
+
export type EasJsonProfile<T extends ProfileType> = T extends 'build'
|
|
6
|
+
? EasJsonBuildProfile
|
|
7
|
+
: EasJsonSubmitProfile;
|
|
8
|
+
|
|
9
|
+
export enum CredentialsSource {
|
|
10
|
+
LOCAL = 'local',
|
|
11
|
+
REMOTE = 'remote',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface EasJson {
|
|
15
|
+
cli?: {
|
|
16
|
+
version?: string;
|
|
17
|
+
requireCommit?: boolean;
|
|
18
|
+
};
|
|
19
|
+
build?: { [profileName: string]: EasJsonBuildProfile };
|
|
20
|
+
submit?: { [profileName: string]: EasJsonSubmitProfile };
|
|
21
|
+
}
|
package/build/EasJson.types.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Platform } from '@expo/eas-build-job';
|
|
2
|
-
import { AndroidBuildProfile, CommonBuildProfile, IosBuildProfile } from './EasBuild.types';
|
|
3
|
-
import { AndroidSubmitProfile, IosSubmitProfile } from './EasSubmit.types';
|
|
4
|
-
export declare enum CredentialsSource {
|
|
5
|
-
LOCAL = "local",
|
|
6
|
-
REMOTE = "remote"
|
|
7
|
-
}
|
|
8
|
-
export interface RawBuildProfile extends Partial<CommonBuildProfile> {
|
|
9
|
-
extends?: string;
|
|
10
|
-
[Platform.ANDROID]?: Partial<AndroidBuildProfile>;
|
|
11
|
-
[Platform.IOS]?: Partial<IosBuildProfile>;
|
|
12
|
-
}
|
|
13
|
-
export interface EasSubmitConfiguration {
|
|
14
|
-
[Platform.ANDROID]?: AndroidSubmitProfile;
|
|
15
|
-
[Platform.IOS]?: IosSubmitProfile;
|
|
16
|
-
}
|
|
17
|
-
export interface CliConfig {
|
|
18
|
-
version?: string;
|
|
19
|
-
requireCommit?: boolean;
|
|
20
|
-
}
|
|
21
|
-
export interface EasJson {
|
|
22
|
-
cli?: CliConfig;
|
|
23
|
-
build: {
|
|
24
|
-
[profile: string]: RawBuildProfile;
|
|
25
|
-
};
|
|
26
|
-
submit?: {
|
|
27
|
-
[profile: string]: EasSubmitConfiguration;
|
|
28
|
-
};
|
|
29
|
-
}
|
package/build/EasJsonReader.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Platform } from '@expo/eas-build-job';
|
|
2
|
-
import { BuildProfile } from './EasBuild.types';
|
|
3
|
-
import { CliConfig, EasJson, RawBuildProfile } from './EasJson.types';
|
|
4
|
-
import { SubmitProfile } from './EasSubmit.types';
|
|
5
|
-
interface EasJsonPreValidation {
|
|
6
|
-
cli?: object;
|
|
7
|
-
build: {
|
|
8
|
-
[profile: string]: object;
|
|
9
|
-
};
|
|
10
|
-
submit?: {
|
|
11
|
-
[profile: string]: object;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
declare type LoggerFn = (...args: any[]) => void;
|
|
15
|
-
interface Logger {
|
|
16
|
-
log: LoggerFn;
|
|
17
|
-
warn: LoggerFn;
|
|
18
|
-
}
|
|
19
|
-
export declare class EasJsonReader {
|
|
20
|
-
private projectDir;
|
|
21
|
-
private static log?;
|
|
22
|
-
static formatEasJsonPath(projectDir: string): string;
|
|
23
|
-
static setLog(log: Logger): void;
|
|
24
|
-
constructor(projectDir: string);
|
|
25
|
-
getBuildProfileNamesAsync(): Promise<string[]>;
|
|
26
|
-
getCliConfigAsync(): Promise<CliConfig | null>;
|
|
27
|
-
getSubmitProfileNamesAsync({ throwIfEasJsonDoesNotExist }?: {
|
|
28
|
-
throwIfEasJsonDoesNotExist?: boolean | undefined;
|
|
29
|
-
}): Promise<string[]>;
|
|
30
|
-
readBuildProfileAsync<T extends Platform>(platform: T, profileName: string): Promise<BuildProfile<T>>;
|
|
31
|
-
readSubmitProfileAsync<T extends Platform>(platform: T, profileNameArg?: string): Promise<SubmitProfile<T>>;
|
|
32
|
-
readAndValidateAsync(): Promise<EasJson>;
|
|
33
|
-
readRawAsync(): Promise<EasJsonPreValidation>;
|
|
34
|
-
private resolveBuildProfile;
|
|
35
|
-
private ensureBuildProfileExists;
|
|
36
|
-
private evaluateFields;
|
|
37
|
-
}
|
|
38
|
-
export declare function profileMerge(base: RawBuildProfile, update: RawBuildProfile): RawBuildProfile;
|
|
39
|
-
export {};
|
package/build/EasJsonReader.js
DELETED
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.profileMerge = exports.EasJsonReader = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const eas_build_job_1 = require("@expo/eas-build-job");
|
|
6
|
-
const json_file_1 = (0, tslib_1.__importDefault)(require("@expo/json-file"));
|
|
7
|
-
const env_string_1 = (0, tslib_1.__importDefault)(require("env-string"));
|
|
8
|
-
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
9
|
-
const EasJson_types_1 = require("./EasJson.types");
|
|
10
|
-
const EasJsonSchema_1 = require("./EasJsonSchema");
|
|
11
|
-
const EasSubmit_types_1 = require("./EasSubmit.types");
|
|
12
|
-
const errors_1 = require("./errors");
|
|
13
|
-
const defaults = {
|
|
14
|
-
distribution: 'store',
|
|
15
|
-
credentialsSource: EasJson_types_1.CredentialsSource.REMOTE,
|
|
16
|
-
};
|
|
17
|
-
class EasJsonReader {
|
|
18
|
-
constructor(projectDir) {
|
|
19
|
-
this.projectDir = projectDir;
|
|
20
|
-
}
|
|
21
|
-
static formatEasJsonPath(projectDir) {
|
|
22
|
-
return path_1.default.join(projectDir, 'eas.json');
|
|
23
|
-
}
|
|
24
|
-
static setLog(log) {
|
|
25
|
-
this.log = log;
|
|
26
|
-
}
|
|
27
|
-
async getBuildProfileNamesAsync() {
|
|
28
|
-
var _a;
|
|
29
|
-
const easJson = await this.readRawAsync();
|
|
30
|
-
return Object.keys((_a = easJson === null || easJson === void 0 ? void 0 : easJson.build) !== null && _a !== void 0 ? _a : {});
|
|
31
|
-
}
|
|
32
|
-
async getCliConfigAsync() {
|
|
33
|
-
try {
|
|
34
|
-
const easJson = await this.readRawAsync();
|
|
35
|
-
if (!easJson.cli) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
const { value, error } = EasJsonSchema_1.CliConfigSchema.validate(easJson.cli, {
|
|
39
|
-
allowUnknown: false,
|
|
40
|
-
convert: true,
|
|
41
|
-
abortEarly: false,
|
|
42
|
-
});
|
|
43
|
-
if (error) {
|
|
44
|
-
throw new Error(`"cli" field in eas.json is not valid [${error.toString()}]`);
|
|
45
|
-
}
|
|
46
|
-
return value;
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
if (err.code === 'ENOENT') {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
throw err;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async getSubmitProfileNamesAsync({ throwIfEasJsonDoesNotExist = true } = {}) {
|
|
56
|
-
var _a;
|
|
57
|
-
try {
|
|
58
|
-
const easJson = await this.readRawAsync();
|
|
59
|
-
return Object.keys((_a = easJson === null || easJson === void 0 ? void 0 : easJson.submit) !== null && _a !== void 0 ? _a : {});
|
|
60
|
-
}
|
|
61
|
-
catch (err) {
|
|
62
|
-
if (!throwIfEasJsonDoesNotExist && err.code === 'ENOENT') {
|
|
63
|
-
return [];
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
throw err;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
async readBuildProfileAsync(platform, profileName) {
|
|
71
|
-
const easJson = await this.readAndValidateAsync();
|
|
72
|
-
this.ensureBuildProfileExists(easJson, profileName);
|
|
73
|
-
const { android: resolvedAndroidSpecificValues, ios: resolvedIosSpecificValues, ...resolvedProfile } = this.resolveBuildProfile(easJson, profileName);
|
|
74
|
-
if (platform === eas_build_job_1.Platform.ANDROID) {
|
|
75
|
-
const profileWithoutDefaults = profileMerge(resolvedProfile, resolvedAndroidSpecificValues !== null && resolvedAndroidSpecificValues !== void 0 ? resolvedAndroidSpecificValues : {});
|
|
76
|
-
return profileMerge(defaults, profileWithoutDefaults);
|
|
77
|
-
}
|
|
78
|
-
else if (platform === eas_build_job_1.Platform.IOS) {
|
|
79
|
-
const profileWithoutDefaults = profileMerge(resolvedProfile, resolvedIosSpecificValues !== null && resolvedIosSpecificValues !== void 0 ? resolvedIosSpecificValues : {});
|
|
80
|
-
return profileMerge(defaults, profileWithoutDefaults);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
throw new Error(`Unknown platform ${platform}`);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async readSubmitProfileAsync(platform, profileNameArg) {
|
|
87
|
-
var _a;
|
|
88
|
-
let profileName = profileNameArg;
|
|
89
|
-
if (!profileName) {
|
|
90
|
-
const profileNames = await this.getSubmitProfileNamesAsync({
|
|
91
|
-
throwIfEasJsonDoesNotExist: false,
|
|
92
|
-
});
|
|
93
|
-
if (profileNames.includes('production')) {
|
|
94
|
-
profileName = 'production';
|
|
95
|
-
}
|
|
96
|
-
else if (profileNames.includes('release')) {
|
|
97
|
-
profileName = 'release';
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
return getDefaultSubmitProfile(platform);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const easJson = await this.readAndValidateAsync();
|
|
104
|
-
const profile = (_a = easJson === null || easJson === void 0 ? void 0 : easJson.submit) === null || _a === void 0 ? void 0 : _a[profileName];
|
|
105
|
-
if (!profile) {
|
|
106
|
-
throw new Error(`There is no profile named ${profileName} in eas.json`);
|
|
107
|
-
}
|
|
108
|
-
const platformProfile = profile[platform];
|
|
109
|
-
if (platformProfile) {
|
|
110
|
-
return this.evaluateFields(platform, platformProfile);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
return getDefaultSubmitProfile(platform);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
async readAndValidateAsync() {
|
|
117
|
-
const easJson = await this.readRawAsync();
|
|
118
|
-
const { value, error } = EasJsonSchema_1.EasJsonSchema.validate(easJson, {
|
|
119
|
-
allowUnknown: false,
|
|
120
|
-
convert: true,
|
|
121
|
-
abortEarly: false,
|
|
122
|
-
});
|
|
123
|
-
if (error) {
|
|
124
|
-
throw new errors_1.InvalidEasJsonError(`eas.json is not valid [${error.toString()}]`);
|
|
125
|
-
}
|
|
126
|
-
return value;
|
|
127
|
-
}
|
|
128
|
-
async readRawAsync() {
|
|
129
|
-
try {
|
|
130
|
-
const easJsonPath = EasJsonReader.formatEasJsonPath(this.projectDir);
|
|
131
|
-
const rawEasJson = json_file_1.default.read(easJsonPath);
|
|
132
|
-
const { value, error } = EasJsonSchema_1.MinimalEasJsonSchema.validate(rawEasJson, { abortEarly: false });
|
|
133
|
-
if (error) {
|
|
134
|
-
throw new errors_1.InvalidEasJsonError(`eas.json is not valid [${error.toString()}]`);
|
|
135
|
-
}
|
|
136
|
-
return value;
|
|
137
|
-
}
|
|
138
|
-
catch (err) {
|
|
139
|
-
if (err.code === 'EJSONPARSE') {
|
|
140
|
-
err.message = `Found invalid JSON in eas.json. ${err.message}`;
|
|
141
|
-
}
|
|
142
|
-
throw err;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
resolveBuildProfile(easJson, profileName, depth = 0) {
|
|
146
|
-
if (depth >= 2) {
|
|
147
|
-
throw new Error('Too long chain of build profile extensions, make sure "extends" keys do not make a cycle');
|
|
148
|
-
}
|
|
149
|
-
const buildProfile = easJson.build[profileName];
|
|
150
|
-
if (!buildProfile) {
|
|
151
|
-
throw new Error(`There is no profile named ${profileName} in eas.json`);
|
|
152
|
-
}
|
|
153
|
-
const { extends: baseProfileName, ...buildProfileRest } = buildProfile;
|
|
154
|
-
if (baseProfileName) {
|
|
155
|
-
return profileMerge(this.resolveBuildProfile(easJson, baseProfileName, depth + 1), buildProfileRest);
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
return buildProfileRest;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
ensureBuildProfileExists(easJson, profileName) {
|
|
162
|
-
if (!easJson.build || !easJson.build[profileName]) {
|
|
163
|
-
throw new Error(`There is no profile named ${profileName} in eas.json`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
evaluateFields(platform, profile) {
|
|
167
|
-
const fields = platform === eas_build_job_1.Platform.ANDROID
|
|
168
|
-
? EasSubmit_types_1.AndroidSubmitProfileFieldsToEvaluate
|
|
169
|
-
: EasSubmit_types_1.IosSubmitProfileFieldsToEvaluate;
|
|
170
|
-
const evaluatedProfile = { ...profile };
|
|
171
|
-
for (const field of fields) {
|
|
172
|
-
if (field in evaluatedProfile) {
|
|
173
|
-
// @ts-ignore
|
|
174
|
-
evaluatedProfile[field] = (0, env_string_1.default)(evaluatedProfile[field], process.env);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return evaluatedProfile;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
exports.EasJsonReader = EasJsonReader;
|
|
181
|
-
function profileMerge(base, update) {
|
|
182
|
-
const result = {
|
|
183
|
-
...base,
|
|
184
|
-
...update,
|
|
185
|
-
};
|
|
186
|
-
if (base.env && update.env) {
|
|
187
|
-
result.env = {
|
|
188
|
-
...base.env,
|
|
189
|
-
...update.env,
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
if (base.android && update.android) {
|
|
193
|
-
result.android = profileMerge(base.android, update.android);
|
|
194
|
-
}
|
|
195
|
-
if (base.ios && update.ios) {
|
|
196
|
-
result.ios = profileMerge(base.ios, update.ios);
|
|
197
|
-
}
|
|
198
|
-
return result;
|
|
199
|
-
}
|
|
200
|
-
exports.profileMerge = profileMerge;
|
|
201
|
-
function getDefaultSubmitProfile(platform) {
|
|
202
|
-
const Schema = platform === eas_build_job_1.Platform.ANDROID ? EasJsonSchema_1.AndroidSubmitProfileSchema : EasJsonSchema_1.IosSubmitProfileSchema;
|
|
203
|
-
return Schema.validate({}, { convert: true }).value;
|
|
204
|
-
}
|
package/build/EasJsonSchema.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import Joi from 'joi';
|
|
2
|
-
export declare const AndroidSubmitProfileSchema: Joi.ObjectSchema<any>;
|
|
3
|
-
export declare const IosSubmitProfileSchema: Joi.ObjectSchema<any>;
|
|
4
|
-
export declare const CliConfigSchema: Joi.ObjectSchema<any>;
|
|
5
|
-
export declare const MinimalEasJsonSchema: Joi.ObjectSchema<any>;
|
|
6
|
-
export declare const EasJsonSchema: Joi.ObjectSchema<any>;
|
package/src/EasJson.types.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Platform } from '@expo/eas-build-job';
|
|
2
|
-
|
|
3
|
-
import { AndroidBuildProfile, CommonBuildProfile, IosBuildProfile } from './EasBuild.types';
|
|
4
|
-
import { AndroidSubmitProfile, IosSubmitProfile } from './EasSubmit.types';
|
|
5
|
-
|
|
6
|
-
export enum CredentialsSource {
|
|
7
|
-
LOCAL = 'local',
|
|
8
|
-
REMOTE = 'remote',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface RawBuildProfile extends Partial<CommonBuildProfile> {
|
|
12
|
-
extends?: string;
|
|
13
|
-
[Platform.ANDROID]?: Partial<AndroidBuildProfile>;
|
|
14
|
-
[Platform.IOS]?: Partial<IosBuildProfile>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface EasSubmitConfiguration {
|
|
18
|
-
[Platform.ANDROID]?: AndroidSubmitProfile;
|
|
19
|
-
[Platform.IOS]?: IosSubmitProfile;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface CliConfig {
|
|
23
|
-
version?: string;
|
|
24
|
-
requireCommit?: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface EasJson {
|
|
28
|
-
cli?: CliConfig;
|
|
29
|
-
build: { [profile: string]: RawBuildProfile };
|
|
30
|
-
submit?: { [profile: string]: EasSubmitConfiguration };
|
|
31
|
-
}
|