eas-cli 20.5.0 → 21.0.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 (50) hide show
  1. package/README.md +128 -175
  2. package/build/analytics/AnalyticsManager.js +3 -0
  3. package/build/analytics/agent.d.ts +5 -0
  4. package/build/analytics/agent.js +26 -0
  5. package/build/build/context.d.ts +2 -2
  6. package/build/build/createContext.d.ts +2 -2
  7. package/build/build/local.d.ts +2 -2
  8. package/build/commandUtils/workflow/buildProfileUtils.d.ts +11 -29
  9. package/build/commandUtils/workflow/buildProfileUtils.js +47 -126
  10. package/build/commandUtils/workflow/creation.d.ts +11 -3
  11. package/build/commandUtils/workflow/creation.js +151 -261
  12. package/build/commands/integrations/posthog/dashboard.d.ts +1 -0
  13. package/build/commands/integrations/posthog/dashboard.js +30 -6
  14. package/build/commands/observe/metrics.js +1 -1
  15. package/build/commands/project/init.d.ts +0 -7
  16. package/build/commands/project/init.js +4 -274
  17. package/build/commands/simulator/get.js +57 -4
  18. package/build/commands/workflow/create.d.ts +3 -0
  19. package/build/commands/workflow/create.js +118 -87
  20. package/build/credentials/ios/appstore/bundleIdCapabilities.js +9 -3
  21. package/build/fingerprint/utils.d.ts +2 -2
  22. package/build/graphql/generated.d.ts +204 -242
  23. package/build/graphql/generated.js +41 -4
  24. package/build/graphql/mutations/PostHogMutation.d.ts +2 -1
  25. package/build/graphql/mutations/PostHogMutation.js +14 -0
  26. package/build/graphql/queries/DeviceRunSessionQuery.js +15 -0
  27. package/build/graphql/queries/UserQuery.js +0 -10
  28. package/build/graphql/queries/WorkflowRunQuery.js +1 -0
  29. package/build/integrations/asc/utils.js +6 -4
  30. package/build/observe/metricNames.d.ts +1 -1
  31. package/build/observe/metricNames.js +7 -6
  32. package/build/project/android/applicationId.d.ts +2 -1
  33. package/build/project/android/applicationId.js +19 -11
  34. package/build/project/ios/bundleIdentifier.d.ts +2 -1
  35. package/build/project/ios/bundleIdentifier.js +19 -11
  36. package/build/project/ios/entitlements.d.ts +2 -1
  37. package/build/project/ios/target.d.ts +15 -1
  38. package/build/project/ios/target.js +23 -0
  39. package/build/project/projectInitialization.d.ts +9 -0
  40. package/build/project/projectInitialization.js +277 -0
  41. package/build/project/publish.js +73 -40
  42. package/build/submit/context.d.ts +2 -2
  43. package/build/utils/usage/checkForOverages.d.ts +3 -1
  44. package/build/utils/usage/checkForOverages.js +11 -3
  45. package/oclif.manifest.json +2603 -2649
  46. package/package.json +9 -8
  47. package/build/commands/project/onboarding.d.ts +0 -14
  48. package/build/commands/project/onboarding.js +0 -362
  49. package/build/graphql/mutations/UserPreferencesMutation.d.ts +0 -10
  50. package/build/graphql/mutations/UserPreferencesMutation.js +0 -41
@@ -6,24 +6,35 @@ const core_1 = require("@oclif/core");
6
6
  const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
7
  const promises_1 = tslib_1.__importDefault(require("fs/promises"));
8
8
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
9
+ const nullthrows_1 = tslib_1.__importDefault(require("nullthrows"));
9
10
  const path_1 = tslib_1.__importDefault(require("path"));
10
11
  const EasCommand_1 = tslib_1.__importDefault(require("../../commandUtils/EasCommand"));
11
12
  const buildProfileUtils_1 = require("../../commandUtils/workflow/buildProfileUtils");
12
13
  const creation_1 = require("../../commandUtils/workflow/creation");
13
14
  const validation_1 = require("../../commandUtils/workflow/validation");
14
- const log_1 = tslib_1.__importDefault(require("../../log"));
15
+ const log_1 = tslib_1.__importStar(require("../../log"));
16
+ const expoConfig_1 = require("../../project/expoConfig");
17
+ const projectInitialization_1 = require("../../project/projectInitialization");
15
18
  const prompts_1 = require("../../prompts");
16
19
  const formatFields_1 = tslib_1.__importDefault(require("../../utils/formatFields"));
17
- const workflowFile_1 = require("../../utils/workflowFile");
18
20
  class WorkflowCreate extends EasCommand_1.default {
19
21
  static description = 'create a new workflow configuration YAML file';
20
22
  static args = {
21
23
  name: core_1.Args.string({
22
- description: 'Name of the workflow file (must end with .yml or .yaml)',
24
+ description: 'Name of the workflow file. When provided without --template, a placeholder workflow is created.',
23
25
  required: false,
24
26
  }),
25
27
  };
26
28
  static flags = {
29
+ template: core_1.Flags.option({
30
+ description: 'Template to use for the workflow file',
31
+ options: [
32
+ creation_1.WorkflowStarterName.BUILD,
33
+ creation_1.WorkflowStarterName.UPDATE,
34
+ creation_1.WorkflowStarterName.DEPLOY,
35
+ creation_1.WorkflowStarterName.CUSTOM,
36
+ ],
37
+ })(),
27
38
  'skip-validation': core_1.Flags.boolean({
28
39
  description: 'If set, the workflow file will not be validated before being created',
29
40
  default: false,
@@ -33,58 +44,60 @@ class WorkflowCreate extends EasCommand_1.default {
33
44
  ...this.ContextOptions.DynamicProjectConfig,
34
45
  ...this.ContextOptions.ProjectDir,
35
46
  ...this.ContextOptions.LoggedIn,
47
+ ...this.ContextOptions.Vcs,
36
48
  };
37
49
  async runAsync() {
38
50
  const { args: { name: argFileName }, flags, } = await this.parse(WorkflowCreate);
39
51
  try {
40
- const { getDynamicPrivateProjectConfigAsync, loggedIn: { graphqlClient }, projectDir, } = await this.getContextAsync(WorkflowCreate, {
52
+ const { getDynamicPrivateProjectConfigAsync, loggedIn: { actor, graphqlClient }, projectDir, vcsClient, } = await this.getContextAsync(WorkflowCreate, {
41
53
  nonInteractive: false,
42
54
  withServerSideEnvironment: null,
43
55
  });
56
+ if (argFileName && !flags.template) {
57
+ await createPlaceholderWorkflowFileAsync({ argFileName, projectDir });
58
+ return;
59
+ }
60
+ const privateExpoConfig = await (0, expoConfig_1.getPrivateExpoConfigAsync)(projectDir);
61
+ if (!privateExpoConfig.extra?.eas?.projectId) {
62
+ // Unlike `eas init`, we intentionally do not call `ensureOwnerSlugConsistencyAsync` here.
63
+ // The workflow scaffolder should only link/create a project ID, not rewrite the app
64
+ // config's `owner`/`slug` fields. If those are inconsistent, we leave them for `eas init`
65
+ // to reconcile.
66
+ await (0, projectInitialization_1.initializeWithoutExplicitIDAsync)(graphqlClient, actor, projectDir, {
67
+ force: false,
68
+ nonInteractive: false,
69
+ });
70
+ }
44
71
  const { exp: originalExpoConfig, projectId } = await getDynamicPrivateProjectConfigAsync();
72
+ let workflowStarter = flags.template
73
+ ? (0, nullthrows_1.default)(creation_1.workflowStarters.find(s => s.name === flags.template))
74
+ : await chooseTemplateAsync();
45
75
  let expoConfig = originalExpoConfig;
46
- let workflowStarter;
47
- while (!workflowStarter) {
48
- workflowStarter = await chooseTemplateAsync();
49
- switch (workflowStarter.name) {
50
- case creation_1.WorkflowStarterName.BUILD:
51
- case creation_1.WorkflowStarterName.DEPLOY:
52
- case creation_1.WorkflowStarterName.UPDATE: {
53
- const shouldProceed = await (0, buildProfileUtils_1.runBuildConfigureIfNeededAsync)({
54
- projectDir,
55
- expoConfig,
56
- });
57
- if (!shouldProceed) {
58
- workflowStarter = undefined;
59
- continue;
60
- }
61
- break;
62
- }
63
- default:
64
- break;
65
- }
66
- switch (workflowStarter.name) {
67
- case creation_1.WorkflowStarterName.DEPLOY:
68
- case creation_1.WorkflowStarterName.UPDATE: {
69
- const shouldProceed = await (0, buildProfileUtils_1.runUpdateConfigureIfNeededAsync)({
70
- projectDir,
71
- expoConfig,
72
- });
73
- if (!shouldProceed) {
74
- workflowStarter = undefined;
75
- continue;
76
- }
77
- // Need to refetch the Expo config because it may have changed
78
- expoConfig = (await getDynamicPrivateProjectConfigAsync()).exp;
79
- break;
80
- }
81
- default:
82
- break;
83
- }
76
+ if (workflowStarter.name === creation_1.WorkflowStarterName.BUILD ||
77
+ workflowStarter.name === creation_1.WorkflowStarterName.UPDATE ||
78
+ workflowStarter.name === creation_1.WorkflowStarterName.DEPLOY) {
79
+ expoConfig = await configureProjectForStarterAsync({
80
+ workflowStarter,
81
+ projectDir,
82
+ expoConfig: originalExpoConfig,
83
+ projectId,
84
+ vcsClient,
85
+ getDynamicPrivateProjectConfigAsync,
86
+ });
84
87
  }
85
- const { fileName, filePath } = await chooseFileNameAsync(argFileName, projectDir, workflowStarter);
86
- // Customize the template if needed
87
- workflowStarter = await (0, creation_1.customizeTemplateIfNeededAsync)(workflowStarter, projectDir, expoConfig);
88
+ const { fileName, filePath } = await resolveTemplateFileNameAsync({
89
+ argFileName,
90
+ projectDir,
91
+ workflowStarter,
92
+ });
93
+ workflowStarter = await (0, creation_1.customizeTemplateIfNeededAsync)({
94
+ workflowStarter,
95
+ projectDir,
96
+ expoConfig,
97
+ graphqlClient,
98
+ projectId,
99
+ vcsClient,
100
+ });
88
101
  log_1.default.debug(`Creating workflow file ${fileName} from template ${workflowStarter.name}`);
89
102
  const yamlString = [
90
103
  workflowStarter.header,
@@ -94,28 +107,53 @@ class WorkflowCreate extends EasCommand_1.default {
94
107
  await (0, validation_1.validateWorkflowFileAsync)({ yamlConfig: yamlString, filePath: fileName }, projectDir, graphqlClient, projectId);
95
108
  }
96
109
  await ensureWorkflowsDirectoryExistsAsync({ projectDir });
97
- filePath && (await promises_1.default.writeFile(filePath, yamlString));
110
+ await promises_1.default.writeFile(filePath, yamlString);
98
111
  log_1.default.withTick(`Created ${chalk_1.default.bold(filePath)}`);
99
- log_1.default.addNewLineIfNone();
100
- log_1.default.log((0, creation_1.howToRunWorkflow)(fileName, workflowStarter));
101
- // Next steps
102
- if (workflowStarter.nextSteps && workflowStarter.nextSteps.length > 0) {
103
- log_1.default.addNewLineIfNone();
104
- log_1.default.log('Next steps:');
105
- log_1.default.addNewLineIfNone();
106
- log_1.default.log((0, formatFields_1.default)(workflowStarter.nextSteps.map((step, index) => ({
107
- label: `${index + 1}.`,
108
- value: step,
109
- }))));
110
- }
112
+ logNextSteps([
113
+ ...(workflowStarter.nextSteps ?? []).map(step => `${chalk_1.default.yellow('[Action required]')} ${step}`),
114
+ (0, creation_1.howToRunWorkflow)(fileName, workflowStarter),
115
+ ]);
111
116
  }
112
117
  catch (error) {
113
118
  (0, validation_1.logWorkflowValidationErrors)(error);
114
119
  log_1.default.error('Failed to create workflow file.');
120
+ process.exitCode = 1;
115
121
  }
116
122
  }
117
123
  }
118
124
  exports.WorkflowCreate = WorkflowCreate;
125
+ async function configureProjectForStarterAsync({ workflowStarter, projectDir, expoConfig, projectId, vcsClient, getDynamicPrivateProjectConfigAsync, }) {
126
+ await (0, buildProfileUtils_1.configureEasBuildIfNeededAsync)({ projectDir, expoConfig, vcsClient });
127
+ if (workflowStarter.name === creation_1.WorkflowStarterName.UPDATE ||
128
+ workflowStarter.name === creation_1.WorkflowStarterName.DEPLOY) {
129
+ await (0, buildProfileUtils_1.configureEasUpdateIfNeededAsync)({ projectDir, expoConfig, projectId, vcsClient });
130
+ }
131
+ return (await getDynamicPrivateProjectConfigAsync()).exp;
132
+ }
133
+ function logNextSteps(steps) {
134
+ log_1.default.addNewLineIfNone();
135
+ log_1.default.log('➡️ Next steps:');
136
+ log_1.default.addNewLineIfNone();
137
+ log_1.default.log((0, formatFields_1.default)(steps.map((step, index) => ({
138
+ label: `${index + 1}.`,
139
+ value: step,
140
+ }))));
141
+ }
142
+ async function createPlaceholderWorkflowFileAsync({ argFileName, projectDir, }) {
143
+ const fileName = ensureYamlExtension(argFileName);
144
+ const filePath = path_1.default.join(projectDir, '.eas', 'workflows', fileName);
145
+ if (await fs_extra_1.default.pathExists(filePath)) {
146
+ log_1.default.error(`Workflow file already exists: ${chalk_1.default.bold(filePath)}`);
147
+ return;
148
+ }
149
+ await ensureWorkflowsDirectoryExistsAsync({ projectDir });
150
+ await promises_1.default.writeFile(filePath, creation_1.PLACEHOLDER_WORKFLOW_CONTENTS);
151
+ log_1.default.withTick(`Created ${chalk_1.default.bold(filePath)}`);
152
+ logNextSteps([
153
+ `Fill in the "name", "on", and "jobs" fields. Learn more: ${(0, log_1.link)('https://docs.expo.dev/eas/workflows/syntax/')}`,
154
+ `Run this workflow with ${chalk_1.default.bold(`eas workflow:run ${fileName}`)}`,
155
+ ]);
156
+ }
119
157
  async function ensureWorkflowsDirectoryExistsAsync({ projectDir, }) {
120
158
  try {
121
159
  await promises_1.default.access(path_1.default.join(projectDir, '.eas', 'workflows'));
@@ -137,35 +175,28 @@ async function chooseTemplateAsync() {
137
175
  })).starter;
138
176
  return workflowStarter;
139
177
  }
140
- async function chooseFileNameAsync(initialValue, projectDir, workflowStarter) {
141
- let fileName = initialValue;
142
- let filePath = '';
143
- while ((fileName?.length ?? 0) === 0) {
144
- fileName = (await (0, prompts_1.promptAsync)({
145
- type: 'text',
146
- name: 'fileName',
147
- message: 'What would you like to name your workflow file?',
148
- initial: workflowStarter.defaultFileName,
149
- })).fileName;
150
- if (!fileName) {
151
- fileName = undefined;
152
- continue;
153
- }
154
- try {
155
- workflowFile_1.WorkflowFile.validateYamlExtension(fileName);
156
- }
157
- catch (error) {
158
- log_1.default.error(error instanceof Error ? error.message : 'Invalid YAML file name extension');
159
- fileName = undefined;
160
- continue;
161
- }
178
+ async function resolveTemplateFileNameAsync({ argFileName, projectDir, workflowStarter, }) {
179
+ const baseName = argFileName ? ensureYamlExtension(argFileName) : workflowStarter.defaultFileName;
180
+ const ext = path_1.default.extname(baseName);
181
+ const stem = baseName.slice(0, baseName.length - ext.length);
182
+ let fileName = baseName;
183
+ let filePath = path_1.default.join(projectDir, '.eas', 'workflows', fileName);
184
+ let counter = 1;
185
+ while (await fs_extra_1.default.pathExists(filePath)) {
186
+ fileName = `${stem}-${counter}${ext}`;
162
187
  filePath = path_1.default.join(projectDir, '.eas', 'workflows', fileName);
163
- if (await fs_extra_1.default.pathExists(filePath)) {
164
- log_1.default.error(`Workflow file already exists: ${filePath}`);
165
- log_1.default.error('Please choose a different file name.');
166
- log_1.default.newLine();
167
- fileName = undefined;
168
- }
188
+ counter++;
189
+ }
190
+ return { fileName, filePath };
191
+ }
192
+ function ensureYamlExtension(name) {
193
+ const ext = path_1.default.extname(name);
194
+ if (!ext) {
195
+ return `${name}.yml`;
196
+ }
197
+ const lowerExt = ext.toLowerCase();
198
+ if (lowerExt === '.yml' || lowerExt === '.yaml') {
199
+ return name;
169
200
  }
170
- return { fileName: fileName ?? '', filePath };
201
+ throw new Error(`Workflow file name must end with .yml or .yaml, but got "${name}".`);
171
202
  }
@@ -43,10 +43,16 @@ async function syncCapabilitiesForEntitlementsAsync(bundleId, entitlements = {},
43
43
  await bundleId.updateBundleIdCapabilityAsync(modifiedRequest);
44
44
  }
45
45
  catch (error) {
46
- if (error.message.match(/bundle '[\w\d]+' cannot be deleted. Delete all the Apps/)) {
47
- log_1.default.error('Failed to patch capabilities:', (0, util_1.inspect)(modifiedRequest, { depth: null, colors: true }));
48
- throw new Error(`Unexpected error occurred while attempting to update capabilities for app "${bundleId.attributes.identifier}".\nCapabilities can be modified manually in the Apple developer console at https://developer-mdn.apple.com/account/resources/identifiers/bundleId/edit/${bundleId.id}.\nAuto capability syncing can be disabled with the environment variable \`EXPO_NO_CAPABILITY_SYNC=1\`.\n${error.message}`);
46
+ log_1.default.error('Failed to patch capabilities:', (0, util_1.inspect)(modifiedRequest, { depth: null, colors: true }));
47
+ const context = `Failed to update Apple capabilities for app "${bundleId.attributes.identifier}".\nYou can enable or disable capabilities manually in the Apple developer console at https://developer.apple.com/account/resources/identifiers/bundleId/edit/${bundleId.id}, then re-run this command.\nAuto capability syncing can be disabled with the environment variable \`EXPO_NO_CAPABILITY_SYNC=1\`.`;
48
+ if (error.message?.match?.(/bundle '[\w\d]+' cannot be deleted. Delete all the Apps/)) {
49
+ throw new Error(`${context}\n${error.message}`);
49
50
  }
51
+ // Preserve the underlying Apple error and stack, but attach the same
52
+ // actionable context so the user knows how to unblock their build.
53
+ const wrapped = new Error(`${context}\n\nApple API error: ${error.message}`);
54
+ wrapped.cause = error;
55
+ throw wrapped;
50
56
  }
51
57
  }
52
58
  return { enabled: enabledCapabilityNames, disabled: disabledCapabilityNames };
@@ -1,10 +1,10 @@
1
- import { Platform } from '@expo/eas-build-job';
1
+ import { Env, Platform } from '@expo/eas-build-job';
2
2
  import { Fingerprint } from './types';
3
3
  import { ExpoGraphqlClient } from '../commandUtils/context/contextUtils/createGraphqlClient';
4
4
  import { AppPlatform } from '../graphql/generated';
5
5
  import { Client } from '../vcs/vcs';
6
6
  export declare function getFingerprintInfoFromLocalProjectForPlatformsAsync(graphqlClient: ExpoGraphqlClient, projectDir: string, projectId: string, vcsClient: Client, platforms: AppPlatform[], { env }?: {
7
- env?: Record<string, string>;
7
+ env?: Env;
8
8
  }): Promise<Fingerprint>;
9
9
  export declare function appPlatformToPlatform(platform: AppPlatform): Platform;
10
10
  export declare function appPlatformToString(platform: AppPlatform): string;