1const path = require('path');
2
3const { initAsync, setupManualTestAppAsync } = require('./project');
4
5const repoRoot = process.env.EXPO_REPO_ROOT;
6const workingDir = path.resolve(repoRoot, '..');
7
8/*
9 * Change this to your own Expo account name
10 */
11const EXPO_ACCOUNT_NAME = process.env.EXPO_ACCOUNT_NAME || 'myusername';
12
13/**
14 * This generates a project at the location TEST_PROJECT_ROOT,
15 * set up to use the latest bits from the current repo source,
16 * and can be used to test different expo-updates and EAS updates workflows.
17 */
18
19function transformAppJson(appJson, projectName, runtimeVersion) {
20  return {
21    expo: {
22      ...appJson.expo,
23      name: projectName,
24      runtimeVersion,
25      updates: {
26        ...appJson.expo.updates,
27        requestHeaders: {
28          'expo-channel-name': 'main',
29        },
30      },
31      android: {
32        ...appJson.expo.android,
33        package: `com.${EXPO_ACCOUNT_NAME}.${projectName}`,
34      },
35      ios: {
36        ...appJson.expo.ios,
37        bundleIdentifier: `com.${EXPO_ACCOUNT_NAME}.${projectName}`,
38      },
39    },
40  };
41}
42
43(async function () {
44  if (!process.env.EXPO_REPO_ROOT) {
45    throw new Error('Missing one or more environment variables; see instructions in e2e/README.md');
46  }
47  const projectRoot = process.env.TEST_PROJECT_ROOT || path.join(workingDir, 'updates-e2e');
48  const localCliBin = path.join(repoRoot, 'packages/@expo/cli/build/bin/cli');
49  const runtimeVersion = '1.0.0';
50  await initAsync(projectRoot, {
51    repoRoot,
52    runtimeVersion,
53    localCliBin,
54    configureE2E: false,
55    transformAppJson,
56  });
57
58  await setupManualTestAppAsync(projectRoot);
59})();
60