1import process from 'process'; 2 3import * as EASCLI from './EASCLI'; 4import * as ExpoCLI from './ExpoCLI'; 5import * as Log from './Log'; 6 7type Options = { 8 accessToken?: string; 9 userpass?: { 10 username: string; 11 password: string; 12 }; 13 message: string; 14}; 15 16/** 17 * Uses the installed version of `eas-cli` to publish a project. 18 */ 19export async function publishProjectWithEasCliAsync( 20 projectRoot: string, 21 options: Options 22): Promise<{ createdUpdateGroupId: string }> { 23 process.env.EXPO_NO_DOCTOR = '1'; 24 25 if (options.accessToken) { 26 Log.collapsed('Using access token...'); 27 process.env.EXPO_TOKEN = options.accessToken; 28 } else { 29 const username = options.userpass?.username || process.env.EXPO_CI_ACCOUNT_USERNAME; 30 const password = options.userpass?.password || process.env.EXPO_CI_ACCOUNT_PASSWORD; 31 32 if (username && password) { 33 Log.collapsed('Logging in...'); 34 await ExpoCLI.runExpoCliAsync('login', ['-u', username, '-p', password]); 35 } else { 36 Log.collapsed('Expo username and password not specified. Using currently logged-in account.'); 37 } 38 } 39 40 Log.collapsed('Publishing...'); 41 const publishedUpdatesJSONString = await EASCLI.runEASCliAsync( 42 'update', 43 ['--non-interactive', '--json', '--branch', 'development', '--message', options.message], 44 { 45 cwd: projectRoot, 46 } 47 ); 48 49 const publishedUpdates = JSON.parse(publishedUpdatesJSONString); 50 return { createdUpdateGroupId: publishedUpdates[0].group }; 51} 52