@expo/eas-json 0.30.0 → 0.34.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.
- package/build/EasJson.types.d.ts +5 -0
- package/build/EasJsonReader.d.ts +11 -2
- package/build/EasJsonReader.js +36 -5
- package/build/EasJsonSchema.d.ts +1 -0
- package/build/EasJsonSchema.js +10 -1
- package/build/EasSubmit.types.d.ts +3 -0
- package/build/EasSubmit.types.js +5 -1
- package/build/errors.d.ts +2 -0
- package/build/errors.js +6 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +3 -5
- package/package.json +5 -3
- package/src/EasJson.types.ts +6 -0
- package/src/EasJsonReader.ts +51 -6
- package/src/EasJsonSchema.ts +10 -0
- package/src/EasSubmit.types.ts +8 -1
- package/src/__tests__/EasJsonReader-build-test.ts +15 -15
- package/src/__tests__/EasJsonReader-submit-test.ts +54 -9
- package/src/errors.ts +1 -0
- package/src/index.ts +1 -1
- package/build/DeprecatedConfig.types.d.ts +0 -45
- package/build/DeprecatedConfig.types.js +0 -8
- package/build/DeprecatedEasJsonReader.d.ts +0 -33
- package/build/DeprecatedEasJsonReader.js +0 -145
- package/build/DeprecatedEasJsonSchema.d.ts +0 -3
- package/build/DeprecatedEasJsonSchema.js +0 -84
- package/build/migrate.d.ts +0 -6
- package/build/migrate.js +0 -161
- package/src/DeprecatedConfig.types.ts +0 -58
- package/src/DeprecatedEasJsonReader.ts +0 -190
- package/src/DeprecatedEasJsonSchema.ts +0 -95
- package/src/__tests__/migrate-test.ts +0 -297
- package/src/migrate.ts +0 -182
|
@@ -14,13 +14,13 @@ 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
|
-
|
|
17
|
+
production: {},
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
const reader = new EasJsonReader('/project');
|
|
22
|
-
const iosProfile = await reader.readSubmitProfileAsync(Platform.IOS, '
|
|
23
|
-
const androidProfile = await reader.readSubmitProfileAsync(Platform.ANDROID, '
|
|
22
|
+
const iosProfile = await reader.readSubmitProfileAsync(Platform.IOS, 'production');
|
|
23
|
+
const androidProfile = await reader.readSubmitProfileAsync(Platform.ANDROID, 'production');
|
|
24
24
|
|
|
25
25
|
expect(androidProfile).toEqual({
|
|
26
26
|
changesNotSentForReview: false,
|
|
@@ -35,7 +35,7 @@ test('minimal allowed eas.json for both platforms', async () => {
|
|
|
35
35
|
test('android config with all required values', async () => {
|
|
36
36
|
await fs.writeJson('/project/eas.json', {
|
|
37
37
|
submit: {
|
|
38
|
-
|
|
38
|
+
production: {
|
|
39
39
|
android: {
|
|
40
40
|
serviceAccountKeyPath: './path.json',
|
|
41
41
|
track: 'beta',
|
|
@@ -46,7 +46,7 @@ test('android config with all required values', async () => {
|
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
const reader = new EasJsonReader('/project');
|
|
49
|
-
const androidProfile = await reader.readSubmitProfileAsync(Platform.ANDROID, '
|
|
49
|
+
const androidProfile = await reader.readSubmitProfileAsync(Platform.ANDROID, 'production');
|
|
50
50
|
|
|
51
51
|
expect(androidProfile).toEqual({
|
|
52
52
|
serviceAccountKeyPath: './path.json',
|
|
@@ -59,7 +59,7 @@ test('android config with all required values', async () => {
|
|
|
59
59
|
test('android config with serviceAccountKeyPath set to env var', async () => {
|
|
60
60
|
await fs.writeJson('/project/eas.json', {
|
|
61
61
|
submit: {
|
|
62
|
-
|
|
62
|
+
production: {
|
|
63
63
|
android: {
|
|
64
64
|
serviceAccountKeyPath: '$GOOGLE_SERVICE_ACCOUNT',
|
|
65
65
|
track: 'beta',
|
|
@@ -72,7 +72,7 @@ test('android config with serviceAccountKeyPath set to env var', async () => {
|
|
|
72
72
|
try {
|
|
73
73
|
process.env.GOOGLE_SERVICE_ACCOUNT = './path.json';
|
|
74
74
|
const reader = new EasJsonReader('/project');
|
|
75
|
-
const androidProfile = await reader.readSubmitProfileAsync(Platform.ANDROID, '
|
|
75
|
+
const androidProfile = await reader.readSubmitProfileAsync(Platform.ANDROID, 'production');
|
|
76
76
|
|
|
77
77
|
expect(androidProfile).toEqual({
|
|
78
78
|
serviceAccountKeyPath: './path.json',
|
|
@@ -88,23 +88,68 @@ test('android config with serviceAccountKeyPath set to env var', async () => {
|
|
|
88
88
|
test('ios config with all required values', async () => {
|
|
89
89
|
await fs.writeJson('/project/eas.json', {
|
|
90
90
|
submit: {
|
|
91
|
-
|
|
91
|
+
production: {
|
|
92
92
|
ios: {
|
|
93
93
|
appleId: 'some@email.com',
|
|
94
94
|
ascAppId: '1223423523',
|
|
95
95
|
appleTeamId: 'QWERTY',
|
|
96
|
+
ascApiKeyPath: './path-ABCD.p8',
|
|
97
|
+
ascApiKeyIssuerId: 'abc-123-def-456',
|
|
98
|
+
ascApiKeyId: 'ABCD',
|
|
96
99
|
},
|
|
97
100
|
},
|
|
98
101
|
},
|
|
99
102
|
});
|
|
100
103
|
|
|
101
104
|
const reader = new EasJsonReader('/project');
|
|
102
|
-
const iosProfile = await reader.readSubmitProfileAsync(Platform.IOS, '
|
|
105
|
+
const iosProfile = await reader.readSubmitProfileAsync(Platform.IOS, 'production');
|
|
103
106
|
|
|
104
107
|
expect(iosProfile).toEqual({
|
|
105
108
|
appleId: 'some@email.com',
|
|
106
109
|
appleTeamId: 'QWERTY',
|
|
107
110
|
ascAppId: '1223423523',
|
|
111
|
+
ascApiKeyPath: './path-ABCD.p8',
|
|
112
|
+
ascApiKeyIssuerId: 'abc-123-def-456',
|
|
113
|
+
ascApiKeyId: 'ABCD',
|
|
108
114
|
language: 'en-US',
|
|
109
115
|
});
|
|
110
116
|
});
|
|
117
|
+
|
|
118
|
+
test('ios config with ascApiKey fields set to env var', async () => {
|
|
119
|
+
await fs.writeJson('/project/eas.json', {
|
|
120
|
+
submit: {
|
|
121
|
+
release: {
|
|
122
|
+
ios: {
|
|
123
|
+
appleId: 'some@email.com',
|
|
124
|
+
ascAppId: '1223423523',
|
|
125
|
+
appleTeamId: 'QWERTY',
|
|
126
|
+
ascApiKeyPath: '$ASC_API_KEY_PATH',
|
|
127
|
+
ascApiKeyIssuerId: '$ASC_API_KEY_ISSUER_ID',
|
|
128
|
+
ascApiKeyId: '$ASC_API_KEY_ID',
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
process.env.ASC_API_KEY_PATH = './path-ABCD.p8';
|
|
136
|
+
process.env.ASC_API_KEY_ISSUER_ID = 'abc-123-def-456';
|
|
137
|
+
process.env.ASC_API_KEY_ID = 'ABCD';
|
|
138
|
+
const reader = new EasJsonReader('/project');
|
|
139
|
+
const iosProfile = await reader.readSubmitProfileAsync(Platform.IOS, 'release');
|
|
140
|
+
|
|
141
|
+
expect(iosProfile).toEqual({
|
|
142
|
+
appleId: 'some@email.com',
|
|
143
|
+
ascAppId: '1223423523',
|
|
144
|
+
appleTeamId: 'QWERTY',
|
|
145
|
+
ascApiKeyPath: './path-ABCD.p8',
|
|
146
|
+
ascApiKeyIssuerId: 'abc-123-def-456',
|
|
147
|
+
ascApiKeyId: 'ABCD',
|
|
148
|
+
language: 'en-US',
|
|
149
|
+
});
|
|
150
|
+
} finally {
|
|
151
|
+
process.env.ASC_API_KEY_PATH = undefined;
|
|
152
|
+
process.env.ASC_API_KEY_ISSUER_ID = undefined;
|
|
153
|
+
process.env.ASC_API_KEY_ID = undefined;
|
|
154
|
+
}
|
|
155
|
+
});
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class InvalidEasJsonError extends Error {}
|
package/src/index.ts
CHANGED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Android, Cache, Ios } from '@expo/eas-build-job';
|
|
2
|
-
export declare enum CredentialsSource {
|
|
3
|
-
LOCAL = "local",
|
|
4
|
-
REMOTE = "remote"
|
|
5
|
-
}
|
|
6
|
-
export declare type AndroidDistributionType = 'store' | 'internal';
|
|
7
|
-
export declare type IosDistributionType = 'store' | 'internal' | 'simulator';
|
|
8
|
-
export declare type DistributionType = AndroidDistributionType | IosDistributionType;
|
|
9
|
-
export declare type IosEnterpriseProvisioning = 'adhoc' | 'universal';
|
|
10
|
-
export declare type VersionAutoIncrement = boolean | 'version' | 'buildNumber';
|
|
11
|
-
interface IosBuilderEnvironment extends Omit<Ios.BuilderEnvironment, 'image'> {
|
|
12
|
-
image?: Ios.BuilderEnvironment['image'];
|
|
13
|
-
}
|
|
14
|
-
export interface AndroidBuildProfile extends Android.BuilderEnvironment {
|
|
15
|
-
credentialsSource: CredentialsSource;
|
|
16
|
-
releaseChannel?: string;
|
|
17
|
-
channel?: string;
|
|
18
|
-
distribution: AndroidDistributionType;
|
|
19
|
-
cache: Cache;
|
|
20
|
-
withoutCredentials?: boolean;
|
|
21
|
-
buildType?: Android.BuildType;
|
|
22
|
-
gradleCommand?: string;
|
|
23
|
-
artifactPath?: string;
|
|
24
|
-
}
|
|
25
|
-
export interface IosBuildProfile extends IosBuilderEnvironment {
|
|
26
|
-
credentialsSource: CredentialsSource;
|
|
27
|
-
releaseChannel?: string;
|
|
28
|
-
channel?: string;
|
|
29
|
-
distribution: IosDistributionType;
|
|
30
|
-
enterpriseProvisioning?: IosEnterpriseProvisioning;
|
|
31
|
-
autoIncrement: VersionAutoIncrement;
|
|
32
|
-
cache: Cache;
|
|
33
|
-
artifactPath?: string;
|
|
34
|
-
scheme?: string;
|
|
35
|
-
schemeBuildConfiguration?: string;
|
|
36
|
-
buildType?: Ios.BuildType;
|
|
37
|
-
}
|
|
38
|
-
export declare type BuildProfile = AndroidBuildProfile | IosBuildProfile;
|
|
39
|
-
export interface EasConfig {
|
|
40
|
-
builds: {
|
|
41
|
-
android?: AndroidBuildProfile;
|
|
42
|
-
ios?: IosBuildProfile;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CredentialsSource = void 0;
|
|
4
|
-
var CredentialsSource;
|
|
5
|
-
(function (CredentialsSource) {
|
|
6
|
-
CredentialsSource["LOCAL"] = "local";
|
|
7
|
-
CredentialsSource["REMOTE"] = "remote";
|
|
8
|
-
})(CredentialsSource = exports.CredentialsSource || (exports.CredentialsSource = {}));
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Workflow } from '@expo/eas-build-job';
|
|
2
|
-
import { EasConfig } from './DeprecatedConfig.types';
|
|
3
|
-
export interface EasJson {
|
|
4
|
-
builds: {
|
|
5
|
-
android?: {
|
|
6
|
-
[key: string]: BuildProfilePreValidation;
|
|
7
|
-
};
|
|
8
|
-
ios?: {
|
|
9
|
-
[key: string]: BuildProfilePreValidation;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
interface BuildProfilePreValidation {
|
|
14
|
-
workflow?: Workflow;
|
|
15
|
-
extends?: string;
|
|
16
|
-
}
|
|
17
|
-
export declare class EasJsonReader {
|
|
18
|
-
private projectDir;
|
|
19
|
-
private platform;
|
|
20
|
-
constructor(projectDir: string, platform: 'android' | 'ios' | 'all');
|
|
21
|
-
/**
|
|
22
|
-
* Return build profile names for a particular platform.
|
|
23
|
-
* If platform is 'all', return common build profiles for all platforms
|
|
24
|
-
*/
|
|
25
|
-
getBuildProfileNamesAsync(): Promise<string[]>;
|
|
26
|
-
readAsync(buildProfileName: string): Promise<EasConfig>;
|
|
27
|
-
validateAsync(): Promise<void>;
|
|
28
|
-
readRawAsync(): Promise<EasJson>;
|
|
29
|
-
private validateBuildProfile;
|
|
30
|
-
private resolveBuildProfile;
|
|
31
|
-
}
|
|
32
|
-
export declare function deepMerge(base: Record<string, any>, update: Record<string, any>): Record<string, any>;
|
|
33
|
-
export {};
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deepMerge = exports.EasJsonReader = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const eas_build_job_1 = require("@expo/eas-build-job");
|
|
6
|
-
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
7
|
-
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
8
|
-
const DeprecatedEasJsonSchema_1 = require("./DeprecatedEasJsonSchema");
|
|
9
|
-
function intersect(setA, setB) {
|
|
10
|
-
return new Set([...setA].filter(i => setB.has(i)));
|
|
11
|
-
}
|
|
12
|
-
class EasJsonReader {
|
|
13
|
-
constructor(projectDir, platform) {
|
|
14
|
-
this.projectDir = projectDir;
|
|
15
|
-
this.platform = platform;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Return build profile names for a particular platform.
|
|
19
|
-
* If platform is 'all', return common build profiles for all platforms
|
|
20
|
-
*/
|
|
21
|
-
async getBuildProfileNamesAsync() {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
23
|
-
const easJson = await this.readRawAsync();
|
|
24
|
-
if (this.platform === 'android') {
|
|
25
|
-
return Object.keys((_b = (_a = easJson === null || easJson === void 0 ? void 0 : easJson.builds) === null || _a === void 0 ? void 0 : _a.android) !== null && _b !== void 0 ? _b : {});
|
|
26
|
-
}
|
|
27
|
-
else if (this.platform === 'ios') {
|
|
28
|
-
return Object.keys((_d = (_c = easJson === null || easJson === void 0 ? void 0 : easJson.builds) === null || _c === void 0 ? void 0 : _c.ios) !== null && _d !== void 0 ? _d : {});
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
const intersectingProfileNames = intersect(new Set(Object.keys((_f = (_e = easJson === null || easJson === void 0 ? void 0 : easJson.builds) === null || _e === void 0 ? void 0 : _e.ios) !== null && _f !== void 0 ? _f : {})), new Set(Object.keys((_h = (_g = easJson === null || easJson === void 0 ? void 0 : easJson.builds) === null || _g === void 0 ? void 0 : _g.android) !== null && _h !== void 0 ? _h : {})));
|
|
32
|
-
return Array.from(intersectingProfileNames);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
async readAsync(buildProfileName) {
|
|
36
|
-
var _a, _b;
|
|
37
|
-
const easJson = await this.readRawAsync();
|
|
38
|
-
let androidConfig;
|
|
39
|
-
if (['android', 'all'].includes(this.platform)) {
|
|
40
|
-
androidConfig = this.validateBuildProfile(eas_build_job_1.Platform.ANDROID, buildProfileName, ((_a = easJson.builds) === null || _a === void 0 ? void 0 : _a.android) || {});
|
|
41
|
-
}
|
|
42
|
-
let iosConfig;
|
|
43
|
-
if (['ios', 'all'].includes(this.platform)) {
|
|
44
|
-
iosConfig = this.validateBuildProfile(eas_build_job_1.Platform.IOS, buildProfileName, ((_b = easJson.builds) === null || _b === void 0 ? void 0 : _b.ios) || {});
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
builds: {
|
|
48
|
-
...(androidConfig ? { android: androidConfig } : {}),
|
|
49
|
-
...(iosConfig ? { ios: iosConfig } : {}),
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
async validateAsync() {
|
|
54
|
-
var _a, _b, _c, _d;
|
|
55
|
-
const easJson = await this.readRawAsync();
|
|
56
|
-
const androidProfiles = (_b = (_a = easJson.builds) === null || _a === void 0 ? void 0 : _a.android) !== null && _b !== void 0 ? _b : {};
|
|
57
|
-
for (const name of Object.keys(androidProfiles)) {
|
|
58
|
-
try {
|
|
59
|
-
this.validateBuildProfile(eas_build_job_1.Platform.ANDROID, name, androidProfiles);
|
|
60
|
-
}
|
|
61
|
-
catch (err) {
|
|
62
|
-
err.message = `Failed to validate Android build profile "${name}"\n${err.message}`;
|
|
63
|
-
throw err;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
const iosProfiles = (_d = (_c = easJson.builds) === null || _c === void 0 ? void 0 : _c.ios) !== null && _d !== void 0 ? _d : {};
|
|
67
|
-
for (const name of Object.keys(iosProfiles)) {
|
|
68
|
-
try {
|
|
69
|
-
this.validateBuildProfile(eas_build_job_1.Platform.IOS, name, iosProfiles);
|
|
70
|
-
}
|
|
71
|
-
catch (err) {
|
|
72
|
-
err.message = `Failed to validate iOS build profile "${name}"\n${err.message}`;
|
|
73
|
-
throw err;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
async readRawAsync() {
|
|
78
|
-
const rawFile = await fs_extra_1.default.readFile(path_1.default.join(this.projectDir, 'eas.json'), 'utf8');
|
|
79
|
-
const json = JSON.parse(rawFile);
|
|
80
|
-
const { value, error } = DeprecatedEasJsonSchema_1.EasJsonSchema.validate(json, {
|
|
81
|
-
abortEarly: false,
|
|
82
|
-
});
|
|
83
|
-
if (error) {
|
|
84
|
-
throw new Error(`eas.json is not valid [${error.toString()}]`);
|
|
85
|
-
}
|
|
86
|
-
return value;
|
|
87
|
-
}
|
|
88
|
-
validateBuildProfile(platform, buildProfileName, buildProfiles) {
|
|
89
|
-
const buildProfile = this.resolveBuildProfile(platform, buildProfileName, buildProfiles);
|
|
90
|
-
const schema = DeprecatedEasJsonSchema_1.schemaBuildProfileMap[platform];
|
|
91
|
-
const { value, error } = schema.validate(buildProfile, {
|
|
92
|
-
stripUnknown: true,
|
|
93
|
-
convert: true,
|
|
94
|
-
abortEarly: false,
|
|
95
|
-
});
|
|
96
|
-
if (error) {
|
|
97
|
-
throw new Error(`Object "${platform}.${buildProfileName}" in eas.json is not valid [${error.toString()}]`);
|
|
98
|
-
}
|
|
99
|
-
return value;
|
|
100
|
-
}
|
|
101
|
-
resolveBuildProfile(platform, buildProfileName, buildProfiles, depth = 0) {
|
|
102
|
-
if (depth >= 2) {
|
|
103
|
-
throw new Error('Too long chain of build profile extensions, make sure "extends" keys do not make a cycle');
|
|
104
|
-
}
|
|
105
|
-
const buildProfile = buildProfiles[buildProfileName];
|
|
106
|
-
if (!buildProfile) {
|
|
107
|
-
throw new Error(`There is no profile named ${buildProfileName} for platform ${platform}`);
|
|
108
|
-
}
|
|
109
|
-
const { extends: baseProfileName, ...buildProfileRest } = buildProfile;
|
|
110
|
-
if (baseProfileName) {
|
|
111
|
-
return deepMerge(this.resolveBuildProfile(platform, baseProfileName, buildProfiles, depth + 1), buildProfileRest);
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
return buildProfileRest;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
exports.EasJsonReader = EasJsonReader;
|
|
119
|
-
function isObject(value) {
|
|
120
|
-
return typeof value === 'object' && value !== null;
|
|
121
|
-
}
|
|
122
|
-
function deepMerge(base, update) {
|
|
123
|
-
const result = {};
|
|
124
|
-
Object.keys(base).forEach(key => {
|
|
125
|
-
const oldValue = base[key];
|
|
126
|
-
const newValue = update[key];
|
|
127
|
-
if (isObject(newValue) && isObject(oldValue)) {
|
|
128
|
-
result[key] = deepMerge(oldValue, newValue);
|
|
129
|
-
}
|
|
130
|
-
else if (newValue !== undefined) {
|
|
131
|
-
result[key] = isObject(newValue) ? deepMerge({}, newValue) : newValue;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
result[key] = isObject(oldValue) ? deepMerge({}, oldValue) : oldValue;
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
Object.keys(update).forEach(key => {
|
|
138
|
-
const newValue = update[key];
|
|
139
|
-
if (result[key] === undefined) {
|
|
140
|
-
result[key] = isObject(newValue) ? deepMerge({}, newValue) : newValue;
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
return result;
|
|
144
|
-
}
|
|
145
|
-
exports.deepMerge = deepMerge;
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EasJsonSchema = exports.schemaBuildProfileMap = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const eas_build_job_1 = require("@expo/eas-build-job");
|
|
6
|
-
const joi_1 = (0, tslib_1.__importDefault)(require("joi"));
|
|
7
|
-
const semverSchemaCheck = (value, helpers) => {
|
|
8
|
-
if (/^[0-9]+\.[0-9]+\.[0-9]+$/.test(value)) {
|
|
9
|
-
return value;
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
throw new Error(`${value} is not a valid version`);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const AndroidBuilderEnvironmentSchema = joi_1.default.object({
|
|
16
|
-
image: joi_1.default.string()
|
|
17
|
-
.valid(...eas_build_job_1.Android.builderBaseImages)
|
|
18
|
-
.default('default'),
|
|
19
|
-
node: joi_1.default.string().empty(null).custom(semverSchemaCheck),
|
|
20
|
-
yarn: joi_1.default.string().empty(null).custom(semverSchemaCheck),
|
|
21
|
-
ndk: joi_1.default.string().empty(null).custom(semverSchemaCheck),
|
|
22
|
-
expoCli: joi_1.default.string().empty(null).custom(semverSchemaCheck),
|
|
23
|
-
env: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.string().empty(null)).default({}),
|
|
24
|
-
});
|
|
25
|
-
const IosBuilderEnvironmentSchema = joi_1.default.object({
|
|
26
|
-
image: joi_1.default.string().valid(...eas_build_job_1.Ios.builderBaseImages),
|
|
27
|
-
node: joi_1.default.string().empty(null).custom(semverSchemaCheck),
|
|
28
|
-
yarn: joi_1.default.string().empty(null).custom(semverSchemaCheck),
|
|
29
|
-
bundler: joi_1.default.string().empty(null).custom(semverSchemaCheck),
|
|
30
|
-
fastlane: joi_1.default.string().empty(null).custom(semverSchemaCheck),
|
|
31
|
-
cocoapods: joi_1.default.string().empty(null).custom(semverSchemaCheck),
|
|
32
|
-
expoCli: joi_1.default.string().empty(null).custom(semverSchemaCheck),
|
|
33
|
-
env: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.string().empty(null)).default({}),
|
|
34
|
-
});
|
|
35
|
-
const CacheSchema = joi_1.default.object({
|
|
36
|
-
disabled: joi_1.default.boolean().default(false),
|
|
37
|
-
key: joi_1.default.string().max(128),
|
|
38
|
-
cacheDefaultPaths: joi_1.default.boolean().default(true),
|
|
39
|
-
customPaths: joi_1.default.array().items(joi_1.default.string()).default([]),
|
|
40
|
-
});
|
|
41
|
-
const AndroidSchema = joi_1.default.object({
|
|
42
|
-
workflow: joi_1.default.string(),
|
|
43
|
-
credentialsSource: joi_1.default.string().valid('local', 'remote').default('remote'),
|
|
44
|
-
releaseChannel: joi_1.default.string(),
|
|
45
|
-
channel: joi_1.default.string(),
|
|
46
|
-
distribution: joi_1.default.string().valid('store', 'internal').default('store'),
|
|
47
|
-
cache: CacheSchema.default(),
|
|
48
|
-
withoutCredentials: joi_1.default.boolean().default(false),
|
|
49
|
-
artifactPath: joi_1.default.string(),
|
|
50
|
-
gradleCommand: joi_1.default.string(),
|
|
51
|
-
buildType: joi_1.default.alternatives().conditional('distribution', {
|
|
52
|
-
is: 'internal',
|
|
53
|
-
then: joi_1.default.string().valid('apk', 'development-client'),
|
|
54
|
-
otherwise: joi_1.default.string().valid('apk', 'app-bundle', 'development-client'),
|
|
55
|
-
}),
|
|
56
|
-
}).concat(AndroidBuilderEnvironmentSchema);
|
|
57
|
-
const IosSchema = joi_1.default.object({
|
|
58
|
-
workflow: joi_1.default.string(),
|
|
59
|
-
credentialsSource: joi_1.default.string().valid('local', 'remote').default('remote'),
|
|
60
|
-
releaseChannel: joi_1.default.string(),
|
|
61
|
-
channel: joi_1.default.string(),
|
|
62
|
-
distribution: joi_1.default.string().valid('store', 'internal', 'simulator').default('store'),
|
|
63
|
-
enterpriseProvisioning: joi_1.default.string().valid('adhoc', 'universal'),
|
|
64
|
-
autoIncrement: joi_1.default.alternatives()
|
|
65
|
-
.try(joi_1.default.boolean(), joi_1.default.string().valid('version', 'buildNumber'))
|
|
66
|
-
.default(false),
|
|
67
|
-
cache: CacheSchema.default(),
|
|
68
|
-
artifactPath: joi_1.default.string(),
|
|
69
|
-
scheme: joi_1.default.string(),
|
|
70
|
-
schemeBuildConfiguration: joi_1.default.string(),
|
|
71
|
-
buildType: joi_1.default.string().valid('release', 'development-client'),
|
|
72
|
-
}).concat(IosBuilderEnvironmentSchema);
|
|
73
|
-
exports.schemaBuildProfileMap = {
|
|
74
|
-
android: AndroidSchema,
|
|
75
|
-
ios: IosSchema,
|
|
76
|
-
};
|
|
77
|
-
exports.EasJsonSchema = joi_1.default.object({
|
|
78
|
-
builds: joi_1.default.object({
|
|
79
|
-
android: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.object({}).unknown(true) // profile is validated further only if build is for that platform
|
|
80
|
-
),
|
|
81
|
-
ios: joi_1.default.object().pattern(joi_1.default.string(), joi_1.default.object({}).unknown(true) // profile is validated further only if build is for that platform
|
|
82
|
-
),
|
|
83
|
-
}),
|
|
84
|
-
});
|
package/build/migrate.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { EasJson as DeprecatedEasJson } from './DeprecatedEasJsonReader';
|
|
2
|
-
import { RawBuildProfile } from './EasJson.types';
|
|
3
|
-
export declare function isUsingDeprecatedFormatAsync(projectDir: string): Promise<boolean>;
|
|
4
|
-
export declare function hasMismatchedExtendsAsync(projectDir: string): Promise<boolean>;
|
|
5
|
-
export declare function migrateAsync(projectDir: string): Promise<void>;
|
|
6
|
-
export declare function migrateProfile(rawEasJson: DeprecatedEasJson, profileName: string): RawBuildProfile;
|
package/build/migrate.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.migrateProfile = exports.migrateAsync = exports.hasMismatchedExtendsAsync = exports.isUsingDeprecatedFormatAsync = 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 fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
8
|
-
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
9
|
-
const DeprecatedEasJsonReader_1 = require("./DeprecatedEasJsonReader");
|
|
10
|
-
async function isUsingDeprecatedFormatAsync(projectDir) {
|
|
11
|
-
const easJsonPath = path_1.default.join(projectDir, 'eas.json');
|
|
12
|
-
if (!(await fs_extra_1.default.pathExists(easJsonPath))) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
const json = await readEasJsonAsync(projectDir);
|
|
16
|
-
return !!(json === null || json === void 0 ? void 0 : json.builds);
|
|
17
|
-
}
|
|
18
|
-
exports.isUsingDeprecatedFormatAsync = isUsingDeprecatedFormatAsync;
|
|
19
|
-
async function hasMismatchedExtendsAsync(projectDir) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
const rawEasJson = (await readEasJsonAsync(projectDir));
|
|
22
|
-
const profiles = new Set();
|
|
23
|
-
Object.keys((_a = rawEasJson.builds.android) !== null && _a !== void 0 ? _a : {}).forEach(profile => profiles.add(profile));
|
|
24
|
-
Object.keys((_b = rawEasJson.builds.ios) !== null && _b !== void 0 ? _b : {}).forEach(profile => profiles.add(profile));
|
|
25
|
-
let hasMismatchedExtendsKeys = false;
|
|
26
|
-
profiles.forEach(profileName => {
|
|
27
|
-
var _a, _b, _c, _d, _e, _f;
|
|
28
|
-
if (((_c = (_b = (_a = rawEasJson === null || rawEasJson === void 0 ? void 0 : rawEasJson.builds) === null || _a === void 0 ? void 0 : _a.ios) === null || _b === void 0 ? void 0 : _b[profileName]) === null || _c === void 0 ? void 0 : _c.extends) !==
|
|
29
|
-
((_f = (_e = (_d = rawEasJson === null || rawEasJson === void 0 ? void 0 : rawEasJson.builds) === null || _d === void 0 ? void 0 : _d.android) === null || _e === void 0 ? void 0 : _e[profileName]) === null || _f === void 0 ? void 0 : _f.extends)) {
|
|
30
|
-
hasMismatchedExtendsKeys = true;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return hasMismatchedExtendsKeys;
|
|
34
|
-
}
|
|
35
|
-
exports.hasMismatchedExtendsAsync = hasMismatchedExtendsAsync;
|
|
36
|
-
async function migrateAsync(projectDir) {
|
|
37
|
-
var _a, _b;
|
|
38
|
-
const reader = new DeprecatedEasJsonReader_1.EasJsonReader(projectDir, 'all');
|
|
39
|
-
try {
|
|
40
|
-
await reader.validateAsync();
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
throw new Error(`Valid eas.json is required to migrate to the new format\n${err.message}`);
|
|
44
|
-
}
|
|
45
|
-
const rawEasJson = (await readEasJsonAsync(projectDir));
|
|
46
|
-
const profiles = new Set();
|
|
47
|
-
Object.keys((_a = rawEasJson.builds.android) !== null && _a !== void 0 ? _a : {}).forEach(profile => profiles.add(profile));
|
|
48
|
-
Object.keys((_b = rawEasJson.builds.ios) !== null && _b !== void 0 ? _b : {}).forEach(profile => profiles.add(profile));
|
|
49
|
-
const result = {
|
|
50
|
-
build: {},
|
|
51
|
-
};
|
|
52
|
-
profiles.forEach(profileName => {
|
|
53
|
-
result.build[profileName] = migrateProfile(rawEasJson, profileName);
|
|
54
|
-
});
|
|
55
|
-
await fs_extra_1.default.writeFile(path_1.default.join(projectDir, 'eas.json'), `${JSON.stringify(result, null, 2)}\n`);
|
|
56
|
-
}
|
|
57
|
-
exports.migrateAsync = migrateAsync;
|
|
58
|
-
async function readEasJsonAsync(projectDir) {
|
|
59
|
-
try {
|
|
60
|
-
const easJsonPath = path_1.default.join(projectDir, 'eas.json');
|
|
61
|
-
return json_file_1.default.read(easJsonPath);
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
if (err.code === 'EJSONPARSE') {
|
|
65
|
-
err.message = `Found invalid JSON in eas.json. ${err.message}`;
|
|
66
|
-
}
|
|
67
|
-
throw err;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function migrateProfile(rawEasJson, profileName) {
|
|
71
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
72
|
-
const androidProfile = ((_c = (_b = (_a = rawEasJson === null || rawEasJson === void 0 ? void 0 : rawEasJson.builds) === null || _a === void 0 ? void 0 : _a.android) === null || _b === void 0 ? void 0 : _b[profileName]) !== null && _c !== void 0 ? _c : {});
|
|
73
|
-
const iosProfile = ((_f = (_e = (_d = rawEasJson === null || rawEasJson === void 0 ? void 0 : rawEasJson.builds) === null || _d === void 0 ? void 0 : _d.ios) === null || _e === void 0 ? void 0 : _e[profileName]) !== null && _f !== void 0 ? _f : {});
|
|
74
|
-
let profile = {
|
|
75
|
-
android: {},
|
|
76
|
-
ios: {},
|
|
77
|
-
};
|
|
78
|
-
const ctx = { androidProfile, iosProfile };
|
|
79
|
-
const androidCtx = { androidProfile };
|
|
80
|
-
const iosCtx = { iosProfile };
|
|
81
|
-
// simple common values
|
|
82
|
-
profile = migrateProperty('credentialsSource', profile, ctx);
|
|
83
|
-
profile = migrateProperty('releaseChannel', profile, ctx);
|
|
84
|
-
profile = migrateProperty('channel', profile, ctx);
|
|
85
|
-
profile = migrateProperty('node', profile, ctx);
|
|
86
|
-
profile = migrateProperty('yarn', profile, ctx);
|
|
87
|
-
profile = migrateProperty('expoCli', profile, ctx);
|
|
88
|
-
if (androidProfile.extends && androidProfile.extends === iosProfile.extends) {
|
|
89
|
-
profile = migrateProperty('extends', profile, ctx);
|
|
90
|
-
}
|
|
91
|
-
// android
|
|
92
|
-
profile = migrateProperty('image', profile, androidCtx);
|
|
93
|
-
profile = migrateProperty('ndk', profile, androidCtx);
|
|
94
|
-
profile = migrateProperty('gradleCommand', profile, androidCtx);
|
|
95
|
-
profile = migrateProperty('artifactPath', profile, androidCtx);
|
|
96
|
-
profile = migrateProperty('env', profile, androidCtx);
|
|
97
|
-
profile = migrateProperty('cache', profile, androidCtx);
|
|
98
|
-
profile = migrateProperty('withoutCredentials', profile, androidCtx);
|
|
99
|
-
// ios
|
|
100
|
-
profile = migrateProperty('enterpriseProvisioning', profile, iosCtx);
|
|
101
|
-
profile = migrateProperty('autoIncrement', profile, iosCtx);
|
|
102
|
-
profile = migrateProperty('image', profile, iosCtx);
|
|
103
|
-
profile = migrateProperty('bundler', profile, iosCtx);
|
|
104
|
-
profile = migrateProperty('fastlane', profile, iosCtx);
|
|
105
|
-
profile = migrateProperty('cocoapods', profile, iosCtx);
|
|
106
|
-
profile = migrateProperty('artifactPath', profile, iosCtx);
|
|
107
|
-
profile = migrateProperty('scheme', profile, iosCtx);
|
|
108
|
-
profile = migrateProperty('env', profile, iosCtx);
|
|
109
|
-
profile = migrateProperty('cache', profile, iosCtx);
|
|
110
|
-
profile = migrateProperty('developmentClient', profile, {
|
|
111
|
-
androidProfile: {
|
|
112
|
-
...androidProfile,
|
|
113
|
-
developmentClient: androidProfile.buildType === eas_build_job_1.Android.BuildType.DEVELOPMENT_CLIENT || undefined,
|
|
114
|
-
},
|
|
115
|
-
iosProfile: {
|
|
116
|
-
...iosProfile,
|
|
117
|
-
developmentClient: iosProfile.buildType === eas_build_job_1.Ios.BuildType.DEVELOPMENT_CLIENT || undefined,
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
if (androidProfile.buildType &&
|
|
121
|
-
androidProfile.buildType !== eas_build_job_1.Android.BuildType.DEVELOPMENT_CLIENT) {
|
|
122
|
-
profile.android.buildType = androidProfile.buildType;
|
|
123
|
-
}
|
|
124
|
-
if (iosProfile.distribution === 'simulator') {
|
|
125
|
-
profile.ios.simulator = true;
|
|
126
|
-
delete iosProfile.distribution;
|
|
127
|
-
}
|
|
128
|
-
profile = migrateProperty('distribution', profile, ctx);
|
|
129
|
-
if (iosProfile.schemeBuildConfiguration) {
|
|
130
|
-
profile.ios.buildConfiguration = iosProfile.schemeBuildConfiguration;
|
|
131
|
-
}
|
|
132
|
-
if (Object.keys((_g = profile.android) !== null && _g !== void 0 ? _g : {}).length === 0) {
|
|
133
|
-
delete profile.android;
|
|
134
|
-
}
|
|
135
|
-
if (Object.keys((_h = profile.ios) !== null && _h !== void 0 ? _h : {}).length === 0) {
|
|
136
|
-
delete profile.ios;
|
|
137
|
-
}
|
|
138
|
-
return profile;
|
|
139
|
-
}
|
|
140
|
-
exports.migrateProfile = migrateProfile;
|
|
141
|
-
function migrateProperty(key, profile, ctx) {
|
|
142
|
-
var _a, _b;
|
|
143
|
-
const androidProperty = (_a = ctx.androidProfile) === null || _a === void 0 ? void 0 : _a[key];
|
|
144
|
-
const iosProperty = (_b = ctx.iosProfile) === null || _b === void 0 ? void 0 : _b[key];
|
|
145
|
-
if (androidProperty && iosProperty && androidProperty === iosProperty) {
|
|
146
|
-
return { ...profile, [key]: androidProperty };
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
return {
|
|
150
|
-
...profile,
|
|
151
|
-
android: {
|
|
152
|
-
...profile.android,
|
|
153
|
-
...(androidProperty ? { [key]: androidProperty } : {}),
|
|
154
|
-
},
|
|
155
|
-
ios: {
|
|
156
|
-
...profile.ios,
|
|
157
|
-
...(iosProperty ? { [key]: iosProperty } : {}),
|
|
158
|
-
},
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
}
|