eas-cli 16.21.0 → 16.23.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.
Files changed (56) hide show
  1. package/README.md +210 -209
  2. package/build/build/android/graphql.js +1 -2
  3. package/build/build/evaluateConfigWithEnvVarsAsync.js +5 -11
  4. package/build/build/ios/graphql.js +1 -2
  5. package/build/build/utils/environment.d.ts +1 -4
  6. package/build/build/utils/environment.js +7 -24
  7. package/build/commandUtils/EasCommand.d.ts +1 -2
  8. package/build/commandUtils/context/ContextField.d.ts +1 -2
  9. package/build/commandUtils/context/contextUtils/loadServerSideEnvironmentVariablesAsync.d.ts +1 -2
  10. package/build/commandUtils/context/contextUtils/loadServerSideEnvironmentVariablesAsync.js +3 -8
  11. package/build/commandUtils/flags.d.ts +3 -5
  12. package/build/commandUtils/flags.js +8 -22
  13. package/build/commandUtils/workflow/buildProfileUtils.d.ts +36 -0
  14. package/build/commandUtils/workflow/buildProfileUtils.js +210 -0
  15. package/build/commandUtils/workflow/creation.d.ts +20 -0
  16. package/build/commandUtils/workflow/creation.js +462 -0
  17. package/build/commandUtils/workflow/validation.d.ts +4 -0
  18. package/build/commandUtils/workflow/validation.js +8 -4
  19. package/build/commands/build/resign.d.ts +2 -3
  20. package/build/commands/deploy/index.d.ts +1 -2
  21. package/build/commands/env/create.d.ts +1 -2
  22. package/build/commands/env/create.js +12 -14
  23. package/build/commands/env/delete.d.ts +1 -2
  24. package/build/commands/env/delete.js +2 -6
  25. package/build/commands/env/exec.js +6 -7
  26. package/build/commands/env/get.d.ts +1 -2
  27. package/build/commands/env/get.js +4 -6
  28. package/build/commands/env/list.d.ts +1 -2
  29. package/build/commands/env/list.js +8 -6
  30. package/build/commands/env/pull.d.ts +1 -1
  31. package/build/commands/env/pull.js +8 -8
  32. package/build/commands/env/push.d.ts +6 -4
  33. package/build/commands/env/push.js +42 -30
  34. package/build/commands/env/update.d.ts +2 -3
  35. package/build/commands/env/update.js +7 -8
  36. package/build/commands/fingerprint/compare.d.ts +1 -2
  37. package/build/commands/fingerprint/compare.js +1 -1
  38. package/build/commands/fingerprint/generate.d.ts +1 -2
  39. package/build/commands/fingerprint/generate.js +1 -1
  40. package/build/commands/update/configure.d.ts +1 -1
  41. package/build/commands/update/configure.js +1 -1
  42. package/build/commands/update/index.d.ts +1 -2
  43. package/build/commands/update/index.js +1 -1
  44. package/build/commands/workflow/create.d.ts +4 -3
  45. package/build/commands/workflow/create.js +130 -56
  46. package/build/graphql/generated.d.ts +44 -0
  47. package/build/graphql/queries/EnvironmentVariablesQuery.d.ts +6 -6
  48. package/build/graphql/queries/EnvironmentVariablesQuery.js +15 -0
  49. package/build/graphql/types/Workflow.js +11 -0
  50. package/build/utils/prompts.d.ts +8 -5
  51. package/build/utils/prompts.js +69 -10
  52. package/build/utils/variableUtils.d.ts +1 -3
  53. package/build/utils/variableUtils.js +1 -6
  54. package/build/worker/assets.d.ts +1 -2
  55. package/oclif.manifest.json +43 -114
  56. package/package.json +4 -4
@@ -4,7 +4,6 @@ exports.transformJob = void 0;
4
4
  const eas_build_job_1 = require("@expo/eas-build-job");
5
5
  const generated_1 = require("../../graphql/generated");
6
6
  const graphql_1 = require("../graphql");
7
- const environment_1 = require("../utils/environment");
8
7
  function transformJob(job) {
9
8
  return {
10
9
  type: (0, graphql_1.transformWorkflow)(job.type),
@@ -25,7 +24,7 @@ function transformJob(job) {
25
24
  experimental: job.experimental,
26
25
  mode: (0, graphql_1.transformBuildMode)(job.mode),
27
26
  customBuildConfig: job.customBuildConfig,
28
- environment: (0, environment_1.buildProfileEnvironmentToEnvironment)(job.environment),
27
+ environment: job.environment,
29
28
  loggerLevel: job.loggerLevel
30
29
  ? graphql_1.loggerLevelToGraphQLWorkerLoggerLevel[job.loggerLevel]
31
30
  : undefined,
@@ -23,14 +23,8 @@ async function evaluateConfigWithEnvVarsAsync({ buildProfile, buildProfileName,
23
23
  }
24
24
  exports.evaluateConfigWithEnvVarsAsync = evaluateConfigWithEnvVarsAsync;
25
25
  async function resolveEnvVarsAsync({ buildProfile, buildProfileName, graphqlClient, projectId, }) {
26
- const environment = buildProfile.environment?.toUpperCase() ??
26
+ const environment = buildProfile.environment ??
27
27
  resolveSuggestedEnvironmentForBuildProfileConfiguration(buildProfile);
28
- if (!(0, environment_1.isEnvironment)(environment)) {
29
- log_1.default.log(`Loaded "env" configuration for the "${buildProfileName}" profile: ${buildProfile.env && Object.keys(buildProfile.env).length > 0
30
- ? Object.keys(buildProfile.env).join(', ')
31
- : 'no environment variables specified'}. ${(0, log_1.learnMore)('https://docs.expo.dev/build-reference/variables/')}`);
32
- return { ...buildProfile.env };
33
- }
34
28
  try {
35
29
  const environmentVariables = await EnvironmentVariablesQuery_1.EnvironmentVariablesQuery.byAppIdWithSensitiveAsync(graphqlClient, {
36
30
  appId: projectId,
@@ -68,10 +62,10 @@ async function resolveEnvVarsAsync({ buildProfile, buildProfileName, graphqlClie
68
62
  }
69
63
  function resolveSuggestedEnvironmentForBuildProfileConfiguration(buildProfile) {
70
64
  const environment = buildProfile.distribution === 'store'
71
- ? environment_1.EnvironmentVariableEnvironment.Production
65
+ ? environment_1.DefaultEnvironment.Production
72
66
  : buildProfile.developmentClient
73
- ? environment_1.EnvironmentVariableEnvironment.Development
74
- : environment_1.EnvironmentVariableEnvironment.Preview;
75
- log_1.default.log(`Resolved "${environment.toLowerCase()}" environment for the build. ${(0, log_1.learnMore)('https://docs.expo.dev/eas/environment-variables/#setting-the-environment-for-your-builds')}`);
67
+ ? environment_1.DefaultEnvironment.Development
68
+ : environment_1.DefaultEnvironment.Preview;
69
+ log_1.default.log(`Resolved "${environment}" environment for the build. ${(0, log_1.learnMore)('https://docs.expo.dev/eas/environment-variables/#setting-the-environment-for-your-builds')}`);
76
70
  return environment;
77
71
  }
@@ -4,7 +4,6 @@ exports.transformIosSecrets = exports.transformJob = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const nullthrows_1 = tslib_1.__importDefault(require("nullthrows"));
6
6
  const graphql_1 = require("../graphql");
7
- const environment_1 = require("../utils/environment");
8
7
  function transformJob(job) {
9
8
  return {
10
9
  type: (0, graphql_1.transformWorkflow)(job.type),
@@ -26,7 +25,7 @@ function transformJob(job) {
26
25
  experimental: job.experimental,
27
26
  mode: (0, graphql_1.transformBuildMode)(job.mode),
28
27
  customBuildConfig: job.customBuildConfig,
29
- environment: (0, environment_1.buildProfileEnvironmentToEnvironment)(job.environment),
28
+ environment: job.environment,
30
29
  loggerLevel: job.loggerLevel
31
30
  ? graphql_1.loggerLevelToGraphQLWorkerLoggerLevel[job.loggerLevel]
32
31
  : undefined,
@@ -1,8 +1,5 @@
1
- import { BuildProfile } from '@expo/eas-json';
2
- export declare enum EnvironmentVariableEnvironment {
1
+ export declare enum DefaultEnvironment {
3
2
  Development = "development",
4
3
  Preview = "preview",
5
4
  Production = "production"
6
5
  }
7
- export declare function isEnvironment(env: string): env is EnvironmentVariableEnvironment;
8
- export declare function buildProfileEnvironmentToEnvironment(environment: BuildProfile['environment']): EnvironmentVariableEnvironment | null;
@@ -1,26 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildProfileEnvironmentToEnvironment = exports.isEnvironment = exports.EnvironmentVariableEnvironment = void 0;
4
- // Default environments
5
- var EnvironmentVariableEnvironment;
6
- (function (EnvironmentVariableEnvironment) {
7
- EnvironmentVariableEnvironment["Development"] = "development";
8
- EnvironmentVariableEnvironment["Preview"] = "preview";
9
- EnvironmentVariableEnvironment["Production"] = "production";
10
- })(EnvironmentVariableEnvironment || (exports.EnvironmentVariableEnvironment = EnvironmentVariableEnvironment = {}));
11
- const BuildProfileEnvironmentToEnvironment = {
12
- production: EnvironmentVariableEnvironment.Production,
13
- preview: EnvironmentVariableEnvironment.Preview,
14
- development: EnvironmentVariableEnvironment.Development,
15
- };
16
- function isEnvironment(env) {
17
- return Object.values(EnvironmentVariableEnvironment).includes(env.toLowerCase());
18
- }
19
- exports.isEnvironment = isEnvironment;
20
- function buildProfileEnvironmentToEnvironment(environment) {
21
- if (!environment) {
22
- return null;
23
- }
24
- return BuildProfileEnvironmentToEnvironment[environment];
25
- }
26
- exports.buildProfileEnvironmentToEnvironment = buildProfileEnvironmentToEnvironment;
3
+ exports.DefaultEnvironment = void 0;
4
+ var DefaultEnvironment;
5
+ (function (DefaultEnvironment) {
6
+ DefaultEnvironment["Development"] = "development";
7
+ DefaultEnvironment["Preview"] = "preview";
8
+ DefaultEnvironment["Production"] = "production";
9
+ })(DefaultEnvironment || (exports.DefaultEnvironment = DefaultEnvironment = {}));
@@ -12,7 +12,6 @@ import { ProjectIdContextField } from './context/ProjectIdContextField';
12
12
  import { ServerSideEnvironmentVariablesContextField } from './context/ServerSideEnvironmentVariablesContextField';
13
13
  import SessionManagementContextField from './context/SessionManagementContextField';
14
14
  import VcsClientContextField from './context/VcsClientContextField';
15
- import { EnvironmentVariableEnvironment } from '../build/utils/environment';
16
15
  import { Client } from '../vcs/vcs';
17
16
  export type ContextInput<T extends {
18
17
  [name: string]: any;
@@ -32,7 +31,7 @@ interface BaseGetContextAsyncArgs {
32
31
  vcsClientOverride?: Client;
33
32
  }
34
33
  interface GetContextAsyncArgsWithRequiredServerSideEnvironmentArgument extends BaseGetContextAsyncArgs {
35
- withServerSideEnvironment: EnvironmentVariableEnvironment | null;
34
+ withServerSideEnvironment: string | null;
36
35
  }
37
36
  interface GetContextAsyncArgsWithoutServerSideEnvironmentArgument extends BaseGetContextAsyncArgs {
38
37
  withServerSideEnvironment?: never;
@@ -1,5 +1,4 @@
1
1
  import { Analytics } from '../../analytics/AnalyticsManager';
2
- import { EnvironmentVariableEnvironment } from '../../build/utils/environment';
3
2
  import SessionManager from '../../user/SessionManager';
4
3
  import { Client } from '../../vcs/vcs';
5
4
  export interface ContextOptions {
@@ -10,7 +9,7 @@ export interface ContextOptions {
10
9
  /**
11
10
  * If specified, env variables from the selected environment will be fetched from the server and used to evaluate the dynamic config.
12
11
  */
13
- withServerSideEnvironment?: EnvironmentVariableEnvironment | null;
12
+ withServerSideEnvironment?: string | null;
14
13
  }
15
14
  export default abstract class ContextField<T> {
16
15
  abstract getValueAsync(options: ContextOptions): Promise<T>;
@@ -1,7 +1,6 @@
1
1
  import { ExpoGraphqlClient } from './createGraphqlClient';
2
- import { EnvironmentVariableEnvironment } from '../../../build/utils/environment';
3
2
  export declare function loadServerSideEnvironmentVariablesAsync({ environment, projectId, graphqlClient, }: {
4
- environment: EnvironmentVariableEnvironment;
3
+ environment: string;
5
4
  projectId: string;
6
5
  graphqlClient: ExpoGraphqlClient;
7
6
  }): Promise<Record<string, string>>;
@@ -2,14 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadServerSideEnvironmentVariablesAsync = void 0;
4
4
  const tslib_1 = require("tslib");
5
- const environment_1 = require("../../../build/utils/environment");
6
5
  const EnvironmentVariablesQuery_1 = require("../../../graphql/queries/EnvironmentVariablesQuery");
7
6
  const log_1 = tslib_1.__importDefault(require("../../../log"));
8
- const cachedServerSideEnvironmentVariables = {
9
- [environment_1.EnvironmentVariableEnvironment.Development]: null,
10
- [environment_1.EnvironmentVariableEnvironment.Preview]: null,
11
- [environment_1.EnvironmentVariableEnvironment.Production]: null,
12
- };
7
+ const cachedServerSideEnvironmentVariables = {};
13
8
  async function loadServerSideEnvironmentVariablesAsync({ environment, projectId, graphqlClient, }) {
14
9
  // don't load environment variables if they were already loaded while executing a command
15
10
  const cachedEnvVarsForEnvironment = cachedServerSideEnvironmentVariables[environment];
@@ -24,10 +19,10 @@ async function loadServerSideEnvironmentVariablesAsync({ environment, projectId,
24
19
  .filter(({ name, value }) => name && value)
25
20
  .map(({ name, value }) => [name, value]));
26
21
  if (Object.keys(serverEnvVars).length > 0) {
27
- log_1.default.log(`Environment variables with visibility "Plain text" and "Sensitive" loaded from the "${environment.toLowerCase()}" environment on EAS: ${Object.keys(serverEnvVars).join(', ')}.`);
22
+ log_1.default.log(`Environment variables with visibility "Plain text" and "Sensitive" loaded from the "${environment}" environment on EAS: ${Object.keys(serverEnvVars).join(', ')}.`);
28
23
  }
29
24
  else {
30
- log_1.default.log(`No environment variables with visibility "Plain text" and "Sensitive" found for the "${environment.toLowerCase()}" environment on EAS.`);
25
+ log_1.default.log(`No environment variables with visibility "Plain text" and "Sensitive" found for the "${environment}" environment on EAS.`);
31
26
  }
32
27
  log_1.default.newLine();
33
28
  cachedServerSideEnvironmentVariables[environment] = serverEnvVars;
@@ -1,17 +1,15 @@
1
- import { EnvironmentVariableEnvironment } from '../build/utils/environment';
2
1
  export declare const EasNonInteractiveAndJsonFlags: {
3
2
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
4
3
  'non-interactive': import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
5
4
  };
6
5
  export declare const EasEnvironmentFlagParameters: {
7
6
  description: string;
8
- options: EnvironmentVariableEnvironment[];
9
7
  };
10
8
  export declare const EASEnvironmentFlag: {
11
- environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | undefined>;
9
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
12
10
  };
13
11
  export declare const EASMultiEnvironmentFlag: {
14
- environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment[] | undefined>;
12
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<string[] | undefined>;
15
13
  };
16
14
  export declare const EASVariableFormatFlag: {
17
15
  format: import("@oclif/core/lib/interfaces").OptionFlag<string>;
@@ -30,5 +28,5 @@ export declare const EasJsonOnlyFlag: {
30
28
  json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
31
29
  };
32
30
  export declare const EasUpdateEnvironmentFlag: {
33
- environment: import("@oclif/core/lib/interfaces").OptionFlag<EnvironmentVariableEnvironment | null>;
31
+ environment: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
34
32
  };
@@ -2,15 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EasUpdateEnvironmentFlag = exports.EasJsonOnlyFlag = exports.EASNonInteractiveFlag = exports.EASEnvironmentVariableScopeFlag = exports.EASVariableVisibilityFlag = exports.EASVariableFormatFlag = exports.EASMultiEnvironmentFlag = exports.EASEnvironmentFlag = exports.EasEnvironmentFlagParameters = exports.EasNonInteractiveAndJsonFlags = void 0;
4
4
  const core_1 = require("@oclif/core");
5
- const environment_1 = require("../build/utils/environment");
6
- // NOTE: not exactly true, but, provided mapToLowercase and upperCaseAsync
7
- // are used in tandem, it saves on unnecessary typying in commands
8
- async function upperCaseAsync(input) {
9
- return input.toUpperCase();
10
- }
11
- function mapToLowercase(options) {
12
- return options.map(option => option.toLowerCase());
13
- }
14
5
  exports.EasNonInteractiveAndJsonFlags = {
15
6
  json: core_1.Flags.boolean({
16
7
  description: 'Enable JSON output, non-JSON messages will be printed to stderr.',
@@ -21,18 +12,15 @@ exports.EasNonInteractiveAndJsonFlags = {
21
12
  }),
22
13
  };
23
14
  exports.EasEnvironmentFlagParameters = {
24
- description: "Environment variable's environment",
25
- options: mapToLowercase([
26
- environment_1.EnvironmentVariableEnvironment.Development,
27
- environment_1.EnvironmentVariableEnvironment.Preview,
28
- environment_1.EnvironmentVariableEnvironment.Production,
29
- ]),
15
+ description: "Environment variable's environment, e.g. 'production', 'preview', 'development'",
30
16
  };
31
17
  exports.EASEnvironmentFlag = {
32
- environment: core_1.Flags.enum(exports.EasEnvironmentFlagParameters),
18
+ environment: core_1.Flags.string({
19
+ description: "Environment variable's environment, e.g. 'production', 'preview', 'development'",
20
+ }),
33
21
  };
34
22
  exports.EASMultiEnvironmentFlag = {
35
- environment: core_1.Flags.enum({
23
+ environment: core_1.Flags.string({
36
24
  ...exports.EasEnvironmentFlagParameters,
37
25
  multiple: true,
38
26
  }),
@@ -68,11 +56,9 @@ exports.EasJsonOnlyFlag = {
68
56
  }),
69
57
  };
70
58
  exports.EasUpdateEnvironmentFlag = {
71
- environment: core_1.Flags.enum({
72
- description: 'Environment to use for the server-side defined EAS environment variables during command execution.',
73
- options: mapToLowercase(Object.values(environment_1.EnvironmentVariableEnvironment)),
74
- parse: upperCaseAsync,
59
+ environment: core_1.Flags.string({
60
+ description: 'Environment to use for the server-side defined EAS environment variables during command execution, e.g. "production", "preview", "development"',
75
61
  required: false,
76
- default: null,
62
+ default: undefined,
77
63
  }),
78
64
  };
@@ -0,0 +1,36 @@
1
+ import { ExpoConfig } from '@expo/config';
2
+ import { BuildProfile, Platform } from '@expo/eas-json';
3
+ import { AndroidBuildProfile, IosBuildProfile } from '@expo/eas-json/build/build/types';
4
+ export declare function buildProfileNamesFromProjectAsync(projectDir: string): Promise<Set<string>>;
5
+ export declare function getBuildProfileAsync(projectDir: string, platform: Platform, profileName: string): Promise<BuildProfile<Platform>>;
6
+ export declare function buildProfilesFromProjectAsync(projectDir: string): Promise<Map<string, {
7
+ android: AndroidBuildProfile;
8
+ ios: IosBuildProfile;
9
+ }>>;
10
+ export declare function isBuildProfileForDevelopment(buildProfile: BuildProfile<Platform>, platform: Platform): boolean;
11
+ export declare function isIosBuildProfileForSimulator(buildProfile: BuildProfile<Platform.IOS>): boolean;
12
+ export declare function addAndroidDevelopmentBuildProfileToEasJsonAsync(projectDir: string, buildProfileName: string): Promise<void>;
13
+ export declare function addIosDevelopmentBuildProfileToEasJsonAsync(projectDir: string, buildProfileName: string, simulator: boolean): Promise<void>;
14
+ export declare function addProductionBuildProfileToEasJsonIfNeededAsync(projectDir: string): Promise<boolean>;
15
+ export declare function hasBuildConfigureBeenRunAsync({ projectDir, expoConfig, }: {
16
+ projectDir: string;
17
+ expoConfig: ExpoConfig;
18
+ }): Promise<boolean>;
19
+ export declare function hasUpdateConfigureBeenRunAsync({ projectDir, expoConfig, }: {
20
+ projectDir: string;
21
+ expoConfig: ExpoConfig;
22
+ }): Promise<boolean>;
23
+ /**
24
+ * Runs update:configure if needed. Returns a boolean (proceed with workflow creation, or not)
25
+ */
26
+ export declare function runUpdateConfigureIfNeededAsync({ projectDir, expoConfig, }: {
27
+ projectDir: string;
28
+ expoConfig: ExpoConfig;
29
+ }): Promise<boolean>;
30
+ /**
31
+ * Runs build:configure if needed. Returns a boolean (proceed with workflow creation, or not)
32
+ */
33
+ export declare function runBuildConfigureIfNeededAsync({ projectDir, expoConfig, }: {
34
+ projectDir: string;
35
+ expoConfig: ExpoConfig;
36
+ }): Promise<boolean>;
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runBuildConfigureIfNeededAsync = exports.runUpdateConfigureIfNeededAsync = exports.hasUpdateConfigureBeenRunAsync = exports.hasBuildConfigureBeenRunAsync = exports.addProductionBuildProfileToEasJsonIfNeededAsync = exports.addIosDevelopmentBuildProfileToEasJsonAsync = exports.addAndroidDevelopmentBuildProfileToEasJsonAsync = exports.isIosBuildProfileForSimulator = exports.isBuildProfileForDevelopment = exports.buildProfilesFromProjectAsync = exports.getBuildProfileAsync = exports.buildProfileNamesFromProjectAsync = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const eas_json_1 = require("@expo/eas-json");
6
+ const configure_1 = tslib_1.__importDefault(require("../../commands/build/configure"));
7
+ const configure_2 = tslib_1.__importDefault(require("../../commands/update/configure"));
8
+ const log_1 = tslib_1.__importDefault(require("../../log"));
9
+ const prompts_1 = require("../../prompts");
10
+ async function buildProfileNamesFromProjectAsync(projectDir) {
11
+ const easJsonAccessor = eas_json_1.EasJsonAccessor.fromProjectPath(projectDir);
12
+ const buildProfileNames = new Set(easJsonAccessor && (await eas_json_1.EasJsonUtils.getBuildProfileNamesAsync(easJsonAccessor)));
13
+ return buildProfileNames;
14
+ }
15
+ exports.buildProfileNamesFromProjectAsync = buildProfileNamesFromProjectAsync;
16
+ async function getBuildProfileAsync(projectDir, platform, profileName) {
17
+ const easJsonAccessor = eas_json_1.EasJsonAccessor.fromProjectPath(projectDir);
18
+ const buildProfile = await eas_json_1.EasJsonUtils.getBuildProfileAsync(easJsonAccessor, platform, profileName);
19
+ return buildProfile;
20
+ }
21
+ exports.getBuildProfileAsync = getBuildProfileAsync;
22
+ async function buildProfilesFromProjectAsync(projectDir) {
23
+ const buildProfileNames = await buildProfileNamesFromProjectAsync(projectDir);
24
+ const buildProfiles = new Map();
25
+ for (const profileName of buildProfileNames) {
26
+ const iosBuildProfile = (await getBuildProfileAsync(projectDir, eas_json_1.Platform.IOS, profileName));
27
+ const androidBuildProfile = (await getBuildProfileAsync(projectDir, eas_json_1.Platform.ANDROID, profileName));
28
+ buildProfiles.set(profileName, { android: androidBuildProfile, ios: iosBuildProfile });
29
+ }
30
+ return buildProfiles;
31
+ }
32
+ exports.buildProfilesFromProjectAsync = buildProfilesFromProjectAsync;
33
+ function isBuildProfileForDevelopment(buildProfile, platform) {
34
+ if (buildProfile.developmentClient) {
35
+ return true;
36
+ }
37
+ if (platform === eas_json_1.Platform.ANDROID) {
38
+ return buildProfile.gradleCommand === ':app:assembleDebug';
39
+ }
40
+ if (platform === eas_json_1.Platform.IOS) {
41
+ return buildProfile.buildConfiguration === 'Debug';
42
+ }
43
+ return false;
44
+ }
45
+ exports.isBuildProfileForDevelopment = isBuildProfileForDevelopment;
46
+ function isIosBuildProfileForSimulator(buildProfile) {
47
+ return buildProfile.simulator ?? false;
48
+ }
49
+ exports.isIosBuildProfileForSimulator = isIosBuildProfileForSimulator;
50
+ async function addAndroidDevelopmentBuildProfileToEasJsonAsync(projectDir, buildProfileName) {
51
+ const easJsonAccessor = eas_json_1.EasJsonAccessor.fromProjectPath(projectDir);
52
+ await easJsonAccessor.readRawJsonAsync();
53
+ easJsonAccessor.patch(easJsonRawObject => {
54
+ easJsonRawObject.build = {
55
+ ...easJsonRawObject.build,
56
+ [buildProfileName]: {
57
+ developmentClient: true,
58
+ distribution: 'internal',
59
+ android: {
60
+ gradleCommand: ':app:assembleDebug',
61
+ },
62
+ },
63
+ };
64
+ return easJsonRawObject;
65
+ });
66
+ await easJsonAccessor.writeAsync();
67
+ }
68
+ exports.addAndroidDevelopmentBuildProfileToEasJsonAsync = addAndroidDevelopmentBuildProfileToEasJsonAsync;
69
+ async function addIosDevelopmentBuildProfileToEasJsonAsync(projectDir, buildProfileName, simulator) {
70
+ const easJsonAccessor = eas_json_1.EasJsonAccessor.fromProjectPath(projectDir);
71
+ await easJsonAccessor.readRawJsonAsync();
72
+ easJsonAccessor.patch(easJsonRawObject => {
73
+ easJsonRawObject.build = {
74
+ ...easJsonRawObject.build,
75
+ [buildProfileName]: {
76
+ developmentClient: true,
77
+ distribution: 'internal',
78
+ ios: {
79
+ buildConfiguration: 'Debug',
80
+ simulator,
81
+ },
82
+ },
83
+ };
84
+ return easJsonRawObject;
85
+ });
86
+ await easJsonAccessor.writeAsync();
87
+ }
88
+ exports.addIosDevelopmentBuildProfileToEasJsonAsync = addIosDevelopmentBuildProfileToEasJsonAsync;
89
+ async function addProductionBuildProfileToEasJsonIfNeededAsync(projectDir) {
90
+ const easJsonAccessor = eas_json_1.EasJsonAccessor.fromProjectPath(projectDir);
91
+ await easJsonAccessor.readRawJsonAsync();
92
+ let profileAdded = false;
93
+ easJsonAccessor.patch(easJsonRawObject => {
94
+ if (!easJsonRawObject.build?.production) {
95
+ profileAdded = true;
96
+ easJsonRawObject.build = {
97
+ ...(easJsonRawObject.build ?? {}),
98
+ production: {},
99
+ };
100
+ // Also add the profile to submit
101
+ easJsonRawObject.submit = {
102
+ ...(easJsonRawObject.submit ?? {}),
103
+ production: {},
104
+ };
105
+ }
106
+ return easJsonRawObject;
107
+ });
108
+ if (profileAdded) {
109
+ log_1.default.log('Added missing production build profile to eas.json');
110
+ }
111
+ await easJsonAccessor.writeAsync();
112
+ return profileAdded;
113
+ }
114
+ exports.addProductionBuildProfileToEasJsonIfNeededAsync = addProductionBuildProfileToEasJsonIfNeededAsync;
115
+ async function hasBuildConfigureBeenRunAsync({ projectDir, expoConfig, }) {
116
+ // Is there a project ID in the Expo config?
117
+ if (!expoConfig.extra?.eas?.projectId) {
118
+ return false;
119
+ }
120
+ // Is there an eas.json?
121
+ const easJsonAccessor = eas_json_1.EasJsonAccessor.fromProjectPath(projectDir);
122
+ try {
123
+ await easJsonAccessor.readAsync();
124
+ }
125
+ catch {
126
+ return false;
127
+ }
128
+ return true;
129
+ }
130
+ exports.hasBuildConfigureBeenRunAsync = hasBuildConfigureBeenRunAsync;
131
+ async function hasUpdateConfigureBeenRunAsync({ projectDir, expoConfig, }) {
132
+ // Does the Expo config have an updates URL?
133
+ if (!expoConfig.updates?.url) {
134
+ return false;
135
+ }
136
+ // Does at least one build profile have a channel?
137
+ const easJsonAccessor = eas_json_1.EasJsonAccessor.fromProjectPath(projectDir);
138
+ try {
139
+ const easJson = await easJsonAccessor.readAsync();
140
+ return Object.values(easJson.build ?? {}).some(buildProfile => !!buildProfile.channel);
141
+ }
142
+ catch {
143
+ return false;
144
+ }
145
+ }
146
+ exports.hasUpdateConfigureBeenRunAsync = hasUpdateConfigureBeenRunAsync;
147
+ /**
148
+ * Runs update:configure if needed. Returns a boolean (proceed with workflow creation, or not)
149
+ */
150
+ async function runUpdateConfigureIfNeededAsync({ projectDir, expoConfig, }) {
151
+ if (await hasUpdateConfigureBeenRunAsync({
152
+ projectDir,
153
+ expoConfig,
154
+ })) {
155
+ return true;
156
+ }
157
+ const nextStep = (await (0, prompts_1.promptAsync)({
158
+ type: 'select',
159
+ name: 'nextStep',
160
+ message: 'You have chosen to create a workflow that requires EAS Update configuration. What would you like to do?',
161
+ choices: [
162
+ { title: 'Configure EAS Update and then proceed', value: 'configure' },
163
+ { title: 'EAS Update is already configured, proceed', value: 'proceed' },
164
+ { title: 'Choose a different workflow template', value: 'repeat' },
165
+ ],
166
+ })).nextStep;
167
+ switch (nextStep) {
168
+ case 'configure':
169
+ log_1.default.newLine();
170
+ await configure_2.default.run([]);
171
+ return true;
172
+ case 'proceed':
173
+ return true;
174
+ default:
175
+ return false;
176
+ }
177
+ }
178
+ exports.runUpdateConfigureIfNeededAsync = runUpdateConfigureIfNeededAsync;
179
+ /**
180
+ * Runs build:configure if needed. Returns a boolean (proceed with workflow creation, or not)
181
+ */
182
+ async function runBuildConfigureIfNeededAsync({ projectDir, expoConfig, }) {
183
+ if (await hasBuildConfigureBeenRunAsync({
184
+ projectDir,
185
+ expoConfig,
186
+ })) {
187
+ return true;
188
+ }
189
+ const nextStep = (await (0, prompts_1.promptAsync)({
190
+ type: 'select',
191
+ name: 'nextStep',
192
+ message: 'You have chosen to create a workflow that requires EAS Build configuration. What would you like to do?',
193
+ choices: [
194
+ { title: 'Configure EAS Build and then proceed', value: 'configure' },
195
+ { title: 'EAS Build is already configured, proceed', value: 'proceed' },
196
+ { title: 'Choose a different workflow template', value: 'repeat' },
197
+ ],
198
+ })).nextStep;
199
+ switch (nextStep) {
200
+ case 'configure':
201
+ log_1.default.newLine();
202
+ await configure_1.default.run(['-p', 'all']);
203
+ return true;
204
+ case 'proceed':
205
+ return true;
206
+ default:
207
+ return false;
208
+ }
209
+ }
210
+ exports.runBuildConfigureIfNeededAsync = runBuildConfigureIfNeededAsync;
@@ -0,0 +1,20 @@
1
+ import { ExpoConfig } from '@expo/config';
2
+ export declare enum WorkflowStarterName {
3
+ BUILD = "build",
4
+ UPDATE = "update",
5
+ CUSTOM = "custom",
6
+ DEPLOY = "deploy"
7
+ }
8
+ export type WorkflowStarter = {
9
+ name: WorkflowStarterName;
10
+ displayName: string;
11
+ defaultFileName: string;
12
+ template: any;
13
+ header: string;
14
+ nextSteps?: string[];
15
+ };
16
+ export declare function howToRunWorkflow(workflowFileName: string, workflowStarter: WorkflowStarter): string;
17
+ export declare const workflowStarters: WorkflowStarter[];
18
+ export declare function addBuildJobsToDevelopmentBuildTemplateAsync(projectDir: string, workflowStarter: WorkflowStarter): Promise<WorkflowStarter>;
19
+ export declare function ensureProductionBuildProfileExistsAsync(projectDir: string, workflowStarter: WorkflowStarter): Promise<WorkflowStarter>;
20
+ export declare function customizeTemplateIfNeededAsync(workflowStarter: WorkflowStarter, projectDir: string, expoConfig: ExpoConfig): Promise<any>;