@expo/eas-json 0.33.0 → 0.36.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.
@@ -1,297 +0,0 @@
1
- import { EasJson as DeprecatedEasJson } from '../DeprecatedEasJsonReader';
2
- import { migrateProfile } from '../migrate';
3
-
4
- test('migration for default manged eas.json', async () => {
5
- const easJson = {
6
- builds: {
7
- android: {
8
- release: {
9
- buildType: 'app-bundle',
10
- },
11
- development: {
12
- buildType: 'development-client',
13
- distribution: 'internal',
14
- },
15
- },
16
- ios: {
17
- release: {
18
- buildType: 'release',
19
- },
20
- development: {
21
- buildType: 'development-client',
22
- distribution: 'internal',
23
- },
24
- },
25
- },
26
- } as DeprecatedEasJson;
27
- expect(migrateProfile(easJson, 'release')).toEqual({
28
- android: {
29
- buildType: 'app-bundle',
30
- },
31
- });
32
- expect(migrateProfile(easJson, 'development')).toEqual({
33
- developmentClient: true,
34
- distribution: 'internal',
35
- });
36
- });
37
-
38
- test('migration for default bare workflow eas.json', async () => {
39
- const easJson = {
40
- builds: {
41
- android: {
42
- release: {
43
- gradleCommand: ':app:bundleRelease',
44
- },
45
- development: {
46
- gradleCommand: ':app:assembleDebug',
47
- distribution: 'internal',
48
- },
49
- },
50
- ios: {
51
- release: {
52
- schemeBuildConfiguration: 'Release',
53
- },
54
- development: {
55
- schemeBuildConfiguration: 'Debug',
56
- distribution: 'internal',
57
- },
58
- },
59
- },
60
- } as DeprecatedEasJson;
61
- expect(migrateProfile(easJson, 'release')).toEqual({
62
- android: {
63
- gradleCommand: ':app:bundleRelease',
64
- },
65
- ios: {
66
- buildConfiguration: 'Release',
67
- },
68
- });
69
- expect(migrateProfile(easJson, 'development')).toEqual({
70
- distribution: 'internal',
71
- android: {
72
- gradleCommand: ':app:assembleDebug',
73
- },
74
- ios: {
75
- buildConfiguration: 'Debug',
76
- },
77
- });
78
- });
79
-
80
- test('migration for example manged eas.json', async () => {
81
- const easJson = {
82
- builds: {
83
- android: {
84
- base: {
85
- image: 'default',
86
- env: {
87
- EXAMPLE_ENV: 'example value',
88
- },
89
- },
90
- release: {
91
- extends: 'base',
92
- env: {
93
- ENVIRONMENT: 'production',
94
- },
95
- buildType: 'app-bundle',
96
- },
97
- staging: {
98
- extends: 'base',
99
- env: {
100
- ENVIRONMENT: 'staging',
101
- },
102
- distribution: 'internal',
103
- buildType: 'apk',
104
- },
105
- debug: {
106
- extends: 'base',
107
- withoutCredentials: true,
108
- env: {
109
- ENVIRONMENT: 'staging',
110
- },
111
- distribution: 'internal',
112
- buildType: 'development-client',
113
- },
114
- },
115
- ios: {
116
- base: {
117
- image: 'latest',
118
- node: '12.13.0',
119
- yarn: '1.22.5',
120
- },
121
- release: {
122
- extends: 'base',
123
- buildType: 'release',
124
- env: {
125
- ENVIRONMENT: 'production',
126
- },
127
- },
128
- inhouse: {
129
- extends: 'base',
130
- distribution: 'internal',
131
- enterpriseProvisioning: 'universal',
132
- env: {
133
- ENVIRONMENT: 'staging',
134
- },
135
- },
136
- adhoc: {
137
- extends: 'base',
138
- distribution: 'internal',
139
- env: {
140
- ENVIRONMENT: 'staging',
141
- },
142
- },
143
- client: {
144
- extends: 'adhoc',
145
- buildType: 'development-client',
146
- },
147
- },
148
- },
149
- } as DeprecatedEasJson;
150
- expect(migrateProfile(easJson, 'base')).toEqual({
151
- android: {
152
- env: {
153
- EXAMPLE_ENV: 'example value',
154
- },
155
- image: 'default',
156
- },
157
- ios: {
158
- image: 'latest',
159
- node: '12.13.0',
160
- yarn: '1.22.5',
161
- },
162
- });
163
- expect(migrateProfile(easJson, 'release')).toEqual({
164
- extends: 'base',
165
- android: {
166
- buildType: 'app-bundle',
167
- env: {
168
- ENVIRONMENT: 'production',
169
- },
170
- },
171
- ios: {
172
- env: {
173
- ENVIRONMENT: 'production',
174
- },
175
- },
176
- });
177
- expect(migrateProfile(easJson, 'staging')).toEqual({
178
- android: {
179
- buildType: 'apk',
180
- distribution: 'internal',
181
- env: {
182
- ENVIRONMENT: 'staging',
183
- },
184
- },
185
- });
186
- expect(migrateProfile(easJson, 'inhouse')).toEqual({
187
- ios: {
188
- distribution: 'internal',
189
- enterpriseProvisioning: 'universal',
190
- env: {
191
- ENVIRONMENT: 'staging',
192
- },
193
- },
194
- });
195
- });
196
-
197
- test('migration for example bare workflow eas.json', async () => {
198
- const easJson = {
199
- builds: {
200
- android: {
201
- base: {
202
- image: 'ubuntu-18.04-android-30-ndk-r19c',
203
- ndk: '21.4.7075529',
204
- env: {
205
- EXAMPLE_ENV: 'example value',
206
- },
207
- },
208
- release: {
209
- extends: 'base',
210
- env: {
211
- ENVIRONMENT: 'production',
212
- },
213
- gradleCommand: ':app:bundleRelease',
214
- },
215
- staging: {
216
- extends: 'base',
217
- env: {
218
- ENVIRONMENT: 'staging',
219
- },
220
- distribution: 'internal',
221
- gradleCommand: ':app:assembleRelease',
222
- },
223
- debug: {
224
- extends: 'base',
225
- withoutCredentials: true,
226
- env: {
227
- ENVIRONMENT: 'staging',
228
- },
229
- distribution: 'internal',
230
- gradleCommand: ':app:assembleDebug',
231
- },
232
- },
233
- ios: {
234
- base: {
235
- image: 'latest',
236
- node: '12.13.0',
237
- yarn: '1.22.5',
238
- },
239
- release: {
240
- extends: 'base',
241
- schemeBuildConfiguration: 'Release',
242
- scheme: 'testapp',
243
- env: {
244
- ENVIRONMENT: 'production',
245
- },
246
- },
247
- inhouse: {
248
- extends: 'base',
249
- distribution: 'internal',
250
- enterpriseProvisioning: 'universal',
251
- scheme: 'testapp-enterprise',
252
- env: {
253
- ENVIRONMENT: 'staging',
254
- },
255
- },
256
- adhoc: {
257
- extends: 'base',
258
- distribution: 'internal',
259
- scheme: 'testapp',
260
- env: {
261
- ENVIRONMENT: 'staging',
262
- },
263
- },
264
- },
265
- },
266
- } as DeprecatedEasJson;
267
- expect(migrateProfile(easJson, 'base')).toEqual({
268
- android: {
269
- env: {
270
- EXAMPLE_ENV: 'example value',
271
- },
272
- image: 'ubuntu-18.04-android-30-ndk-r19c',
273
- ndk: '21.4.7075529',
274
- },
275
- ios: {
276
- image: 'latest',
277
- node: '12.13.0',
278
- yarn: '1.22.5',
279
- },
280
- });
281
- expect(migrateProfile(easJson, 'release')).toEqual({
282
- extends: 'base',
283
- android: {
284
- env: {
285
- ENVIRONMENT: 'production',
286
- },
287
- gradleCommand: ':app:bundleRelease',
288
- },
289
- ios: {
290
- buildConfiguration: 'Release',
291
- env: {
292
- ENVIRONMENT: 'production',
293
- },
294
- scheme: 'testapp',
295
- },
296
- });
297
- });
package/src/migrate.ts DELETED
@@ -1,182 +0,0 @@
1
- import { Android, Ios } from '@expo/eas-build-job';
2
- import JsonFile, { JSONObject } from '@expo/json-file';
3
- import fs from 'fs-extra';
4
- import path from 'path';
5
-
6
- import { AndroidBuildProfile, IosBuildProfile } from './DeprecatedConfig.types';
7
- import { EasJson as DeprecatedEasJson, EasJsonReader } from './DeprecatedEasJsonReader';
8
- import { EasJson, RawBuildProfile } from './EasJson.types';
9
-
10
- export async function isUsingDeprecatedFormatAsync(projectDir: string): Promise<boolean> {
11
- const easJsonPath = path.join(projectDir, 'eas.json');
12
- if (!(await fs.pathExists(easJsonPath))) {
13
- return false;
14
- }
15
- const json = await readEasJsonAsync(projectDir);
16
- return !!json?.builds;
17
- }
18
-
19
- export async function hasMismatchedExtendsAsync(projectDir: string): Promise<boolean> {
20
- const rawEasJson = (await readEasJsonAsync(projectDir)) as unknown as DeprecatedEasJson;
21
- const profiles = new Set<string>();
22
- Object.keys(rawEasJson.builds.android ?? {}).forEach(profile => profiles.add(profile));
23
- Object.keys(rawEasJson.builds.ios ?? {}).forEach(profile => profiles.add(profile));
24
-
25
- let hasMismatchedExtendsKeys = false;
26
- profiles.forEach(profileName => {
27
- if (
28
- rawEasJson?.builds?.ios?.[profileName]?.extends !==
29
- rawEasJson?.builds?.android?.[profileName]?.extends
30
- ) {
31
- hasMismatchedExtendsKeys = true;
32
- }
33
- });
34
- return hasMismatchedExtendsKeys;
35
- }
36
-
37
- export async function migrateAsync(projectDir: string): Promise<void> {
38
- const reader = new EasJsonReader(projectDir, 'all');
39
- try {
40
- await reader.validateAsync();
41
- } catch (err: any) {
42
- throw new Error(`Valid eas.json is required to migrate to the new format\n${err.message}`);
43
- }
44
- const rawEasJson = (await readEasJsonAsync(projectDir)) as unknown as DeprecatedEasJson;
45
- const profiles = new Set<string>();
46
- Object.keys(rawEasJson.builds.android ?? {}).forEach(profile => profiles.add(profile));
47
- Object.keys(rawEasJson.builds.ios ?? {}).forEach(profile => profiles.add(profile));
48
-
49
- const result: EasJson = {
50
- build: {},
51
- };
52
- profiles.forEach(profileName => {
53
- result.build[profileName] = migrateProfile(rawEasJson, profileName);
54
- });
55
- await fs.writeFile(path.join(projectDir, 'eas.json'), `${JSON.stringify(result, null, 2)}\n`);
56
- }
57
-
58
- async function readEasJsonAsync(projectDir: string): Promise<JSONObject> {
59
- try {
60
- const easJsonPath = path.join(projectDir, 'eas.json');
61
- return JsonFile.read(easJsonPath);
62
- } catch (err: any) {
63
- if (err.code === 'EJSONPARSE') {
64
- err.message = `Found invalid JSON in eas.json. ${err.message}`;
65
- }
66
- throw err;
67
- }
68
- }
69
-
70
- interface MigrateContext {
71
- androidProfile?: Partial<AndroidBuildProfile>;
72
- iosProfile?: Partial<IosBuildProfile>;
73
- }
74
-
75
- export function migrateProfile(
76
- rawEasJson: DeprecatedEasJson,
77
- profileName: string
78
- ): RawBuildProfile {
79
- const androidProfile = (rawEasJson?.builds?.android?.[profileName] ??
80
- {}) as AndroidBuildProfile & { extends?: string };
81
- const iosProfile = (rawEasJson?.builds?.ios?.[profileName] ?? {}) as IosBuildProfile & {
82
- extends?: string;
83
- };
84
- let profile: RawBuildProfile = {
85
- android: {},
86
- ios: {},
87
- };
88
- const ctx = { androidProfile, iosProfile };
89
- const androidCtx = { androidProfile };
90
- const iosCtx = { iosProfile };
91
-
92
- // simple common values
93
- profile = migrateProperty('credentialsSource', profile, ctx);
94
- profile = migrateProperty('releaseChannel', profile, ctx);
95
- profile = migrateProperty('channel', profile, ctx);
96
- profile = migrateProperty('node', profile, ctx);
97
- profile = migrateProperty('yarn', profile, ctx);
98
- profile = migrateProperty('expoCli', profile, ctx);
99
- if (androidProfile.extends && androidProfile.extends === iosProfile.extends) {
100
- profile = migrateProperty('extends', profile, ctx);
101
- }
102
-
103
- // android
104
- profile = migrateProperty('image', profile, androidCtx);
105
- profile = migrateProperty('ndk', profile, androidCtx);
106
- profile = migrateProperty('gradleCommand', profile, androidCtx);
107
- profile = migrateProperty('artifactPath', profile, androidCtx);
108
- profile = migrateProperty('env', profile, androidCtx);
109
- profile = migrateProperty('cache', profile, androidCtx);
110
- profile = migrateProperty('withoutCredentials', profile, androidCtx);
111
-
112
- // ios
113
- profile = migrateProperty('enterpriseProvisioning', profile, iosCtx);
114
- profile = migrateProperty('autoIncrement', profile, iosCtx);
115
- profile = migrateProperty('image', profile, iosCtx);
116
- profile = migrateProperty('bundler', profile, iosCtx);
117
- profile = migrateProperty('fastlane', profile, iosCtx);
118
- profile = migrateProperty('cocoapods', profile, iosCtx);
119
- profile = migrateProperty('artifactPath', profile, iosCtx);
120
- profile = migrateProperty('scheme', profile, iosCtx);
121
- profile = migrateProperty('env', profile, iosCtx);
122
- profile = migrateProperty('cache', profile, iosCtx);
123
-
124
- profile = migrateProperty('developmentClient', profile, {
125
- androidProfile: {
126
- ...androidProfile,
127
- developmentClient:
128
- androidProfile.buildType === Android.BuildType.DEVELOPMENT_CLIENT || undefined,
129
- } as any,
130
- iosProfile: {
131
- ...iosProfile,
132
- developmentClient: iosProfile.buildType === Ios.BuildType.DEVELOPMENT_CLIENT || undefined,
133
- } as any,
134
- });
135
- if (
136
- androidProfile.buildType &&
137
- androidProfile.buildType !== Android.BuildType.DEVELOPMENT_CLIENT
138
- ) {
139
- profile.android!.buildType = androidProfile.buildType;
140
- }
141
- if (iosProfile.distribution === 'simulator') {
142
- profile.ios!.simulator = true;
143
- delete (iosProfile as any).distribution;
144
- }
145
- profile = migrateProperty('distribution', profile, ctx);
146
-
147
- if (iosProfile.schemeBuildConfiguration) {
148
- profile.ios!.buildConfiguration = iosProfile.schemeBuildConfiguration;
149
- }
150
- if (Object.keys(profile.android ?? {}).length === 0) {
151
- delete profile.android;
152
- }
153
- if (Object.keys(profile.ios ?? {}).length === 0) {
154
- delete profile.ios;
155
- }
156
- return profile;
157
- }
158
-
159
- function migrateProperty(
160
- key: string,
161
- profile: RawBuildProfile,
162
- ctx: MigrateContext
163
- ): RawBuildProfile {
164
- const androidProperty = (ctx.androidProfile as any)?.[key];
165
- const iosProperty = (ctx.iosProfile as any)?.[key];
166
-
167
- if (androidProperty && iosProperty && androidProperty === iosProperty) {
168
- return { ...profile, [key]: androidProperty };
169
- } else {
170
- return {
171
- ...profile,
172
- android: {
173
- ...profile.android,
174
- ...(androidProperty ? { [key]: androidProperty } : {}),
175
- },
176
- ios: {
177
- ...profile.ios,
178
- ...(iosProperty ? { [key]: iosProperty } : {}),
179
- },
180
- };
181
- }
182
- }