@expo/build-tools 18.13.1 → 19.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.
@@ -24,7 +24,7 @@ async function runGradleCommand(ctx, { logger, gradleCommand, androidDir, extraE
24
24
  logger.info(`Running 'gradlew ${gradleCommand}' in ${androidDir}`);
25
25
  await fs_extra_1.default.chmod(path_1.default.join(androidDir, 'gradlew'), 0o755);
26
26
  const verboseFlag = ctx.env['EAS_VERBOSE'] === '1' ? '--info' : '';
27
- const spawnPromise = (0, turtle_spawn_1.default)('bash', ['-c', `./gradlew ${gradleCommand} ${verboseFlag}`], {
27
+ const spawnPromise = (0, turtle_spawn_1.default)('bash', ['-c', `./gradlew ${gradleCommand} --profile ${verboseFlag}`], {
28
28
  cwd: androidDir,
29
29
  logger,
30
30
  lineTransformer: (line) => {
@@ -35,7 +35,12 @@ async function runGradleCommand(ctx, { logger, gradleCommand, androidDir, extraE
35
35
  return line;
36
36
  }
37
37
  },
38
- env: { ...ctx.env, ...extraEnv, ...resolveVersionOverridesEnvs(ctx), LC_ALL: 'C.UTF-8' },
38
+ env: {
39
+ ...ctx.env,
40
+ ...extraEnv,
41
+ ...resolveVersionOverridesEnvs(ctx),
42
+ LC_ALL: 'C.UTF-8',
43
+ },
39
44
  });
40
45
  if (ctx.env.EAS_BUILD_RUNNER === 'eas-build' && process.platform === 'linux') {
41
46
  adjustOOMScore(spawnPromise, logger);
@@ -0,0 +1,7 @@
1
+ export interface GradleProfileTask {
2
+ path: string;
3
+ durationMs: number;
4
+ result: string;
5
+ }
6
+ export declare function parseGradleProfile(androidDir: string): Promise<GradleProfileTask[]>;
7
+ export declare function formatGradleProfileReport(tasks: GradleProfileTask[]): string;
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.parseGradleProfile = parseGradleProfile;
7
+ exports.formatGradleProfileReport = formatGradleProfileReport;
8
+ const fast_xml_parser_1 = require("fast-xml-parser");
9
+ const fs_extra_1 = __importDefault(require("fs-extra"));
10
+ const path_1 = __importDefault(require("path"));
11
+ async function parseGradleProfile(androidDir) {
12
+ const profileDir = path_1.default.join(androidDir, 'build', 'reports', 'profile');
13
+ if (!(await fs_extra_1.default.pathExists(profileDir))) {
14
+ throw new Error(`Gradle profile directory not found at ${profileDir}`);
15
+ }
16
+ const files = await fs_extra_1.default.readdir(profileDir);
17
+ const htmlFile = files
18
+ .filter(f => f.startsWith('profile-') && f.endsWith('.html'))
19
+ .sort()
20
+ .pop();
21
+ if (!htmlFile) {
22
+ throw new Error(`No Gradle profile HTML found in ${profileDir}`);
23
+ }
24
+ const html = await fs_extra_1.default.readFile(path_1.default.join(profileDir, htmlFile), 'utf8');
25
+ // Locate the <h2>Task Execution</h2> heading and extract its <table>
26
+ const headingMatch = html.match(/<h2[^>]*>\s*Task Execution\s*<\/h2>/i);
27
+ if (!headingMatch || headingMatch.index === undefined) {
28
+ throw new Error('Could not find Task Execution section in Gradle profile');
29
+ }
30
+ const sectionStart = headingMatch.index;
31
+ const tableStart = html.indexOf('<table', sectionStart);
32
+ const tableEnd = html.indexOf('</table>', tableStart);
33
+ if (tableStart === -1 || tableEnd === -1) {
34
+ throw new Error('Could not find task execution table in Gradle profile');
35
+ }
36
+ const tableHtml = html.slice(tableStart, tableEnd + '</table>'.length);
37
+ const parser = new fast_xml_parser_1.XMLParser({
38
+ ignoreAttributes: true,
39
+ isArray: name => name === 'tr' || name === 'td',
40
+ trimValues: true,
41
+ });
42
+ const parsed = parser.parse(tableHtml);
43
+ const rows = parsed?.table?.tbody?.tr ?? parsed?.table?.tr ?? [];
44
+ const tasks = [];
45
+ for (const row of rows) {
46
+ const cells = row?.td;
47
+ if (!cells || cells.length < 2) {
48
+ continue;
49
+ }
50
+ const taskPath = String(cells[0] ?? '').trim();
51
+ const durationStr = String(cells[1] ?? '').trim();
52
+ const result = String(cells[2] ?? '').trim() || 'executed';
53
+ if (!taskPath || !durationStr) {
54
+ continue;
55
+ }
56
+ const durationMs = parseDurationToMs(durationStr);
57
+ tasks.push({ path: taskPath, durationMs, result: result.toLowerCase() });
58
+ }
59
+ return tasks;
60
+ }
61
+ function parseDurationToMs(duration) {
62
+ // Gradle profile durations can be like "1.234s", "0.045s", "12.5s"
63
+ const secondsMatch = duration.match(/^([\d.]+)s$/);
64
+ if (secondsMatch) {
65
+ return Math.round(parseFloat(secondsMatch[1]) * 1000);
66
+ }
67
+ return 0;
68
+ }
69
+ function formatSeconds(ms) {
70
+ const s = ms / 1000;
71
+ if (s < 0.1) {
72
+ return `${ms}ms`;
73
+ }
74
+ return `${s.toFixed(1)}s`;
75
+ }
76
+ function formatGradleProfileReport(tasks) {
77
+ // Filter out tasks under 1 second
78
+ const significantTasks = tasks.filter(t => t.durationMs >= 1000);
79
+ // Separate module totals from individual tasks
80
+ const moduleTotals = significantTasks.filter(t => t.result === '(total)');
81
+ const individualTasks = significantTasks.filter(t => t.result !== '(total)');
82
+ // Group individual tasks by their module prefix
83
+ const moduleChildren = new Map();
84
+ const orphanTasks = [];
85
+ for (const task of individualTasks) {
86
+ const parent = moduleTotals.find(m => task.path.startsWith(m.path + ':'));
87
+ if (parent) {
88
+ const children = moduleChildren.get(parent.path) ?? [];
89
+ children.push(task);
90
+ moduleChildren.set(parent.path, children);
91
+ }
92
+ else {
93
+ orphanTasks.push(task);
94
+ }
95
+ }
96
+ // Sort module totals by duration, sort children within each module
97
+ const sortedModules = [...moduleTotals].sort((a, b) => b.durationMs - a.durationMs);
98
+ for (const children of moduleChildren.values()) {
99
+ children.sort((a, b) => b.durationMs - a.durationMs);
100
+ }
101
+ orphanTasks.sort((a, b) => b.durationMs - a.durationMs);
102
+ // Build display rows: [displayName, task]
103
+ const rows = [];
104
+ for (const mod of sortedModules) {
105
+ rows.push({ displayName: mod.path, task: mod });
106
+ const children = moduleChildren.get(mod.path) ?? [];
107
+ for (let i = 0; i < children.length; i++) {
108
+ const isLast = i === children.length - 1;
109
+ const prefix = isLast ? ' └─ ' : ' ├─ ';
110
+ const shortName = children[i].path.slice(mod.path.length + 1);
111
+ rows.push({ displayName: prefix + shortName, task: children[i] });
112
+ }
113
+ }
114
+ for (const task of orphanTasks) {
115
+ rows.push({ displayName: task.path, task });
116
+ }
117
+ // Compute totals from individual tasks only (avoid double-counting)
118
+ const totalMs = individualTasks.reduce((sum, t) => sum + t.durationMs, 0);
119
+ const maxMs = totalMs || 1;
120
+ const nameWidth = Math.max(4, ...rows.map(r => r.displayName.length)) + 2;
121
+ const barMaxWidth = 20;
122
+ const header = '┌─' +
123
+ '─'.repeat(nameWidth) +
124
+ '─┬────────────┬──────────┬────────────┬─' +
125
+ '─'.repeat(barMaxWidth) +
126
+ '─┐';
127
+ const divider = '├─' +
128
+ '─'.repeat(nameWidth) +
129
+ '─┼────────────┼──────────┼────────────┼─' +
130
+ '─'.repeat(barMaxWidth) +
131
+ '─┤';
132
+ const footer = '└─' +
133
+ '─'.repeat(nameWidth) +
134
+ '─┴────────────┴──────────┴────────────┴─' +
135
+ '─'.repeat(barMaxWidth) +
136
+ '─┘';
137
+ const taskCount = individualTasks.length;
138
+ const cachedCount = individualTasks.filter(t => t.result !== 'executed').length;
139
+ const lines = [];
140
+ lines.push('Gradle Build — Task Execution Profile');
141
+ const cachedSuffix = cachedCount > 0 ? ` (${cachedCount} cached/up-to-date)` : '';
142
+ lines.push(`${taskCount} tasks${cachedSuffix}, total task time: ${formatSeconds(totalMs)}`);
143
+ lines.push('% Time = share of total task execution time');
144
+ lines.push('');
145
+ lines.push(header);
146
+ lines.push('│ ' +
147
+ 'Task'.padEnd(nameWidth) +
148
+ ' │ ' +
149
+ 'Duration'.padStart(10) +
150
+ ' │ ' +
151
+ '% Time'.padStart(8) +
152
+ ' │ ' +
153
+ 'Result'.padEnd(10) +
154
+ ' │ ' +
155
+ ' '.repeat(barMaxWidth) +
156
+ ' │');
157
+ lines.push(divider);
158
+ for (const row of rows) {
159
+ const pct = totalMs === 0 ? 0 : (row.task.durationMs / totalMs) * 100;
160
+ const barLength = Math.round((row.task.durationMs / maxMs) * barMaxWidth);
161
+ const bar = '█'.repeat(barLength) + '░'.repeat(barMaxWidth - barLength);
162
+ const result = row.task.result === '(total)' ? 'total' : row.task.result;
163
+ lines.push('│ ' +
164
+ row.displayName.padEnd(nameWidth) +
165
+ ' │ ' +
166
+ formatSeconds(row.task.durationMs).padStart(10) +
167
+ ' │ ' +
168
+ `${pct.toFixed(1)}%`.padStart(8) +
169
+ ' │ ' +
170
+ result.padEnd(10) +
171
+ ' │ ' +
172
+ bar +
173
+ ' │');
174
+ }
175
+ lines.push(divider);
176
+ lines.push('│ ' +
177
+ 'TOTAL'.padEnd(nameWidth) +
178
+ ' │ ' +
179
+ formatSeconds(totalMs).padStart(10) +
180
+ ' │ ' +
181
+ '100.0%'.padStart(8) +
182
+ ' │ ' +
183
+ ' '.repeat(10) +
184
+ ' │ ' +
185
+ ' '.repeat(barMaxWidth) +
186
+ ' │');
187
+ lines.push(footer);
188
+ lines.push('');
189
+ return lines.join('\n');
190
+ }
package/dist/context.js CHANGED
@@ -10,6 +10,7 @@ const core_1 = require("@urql/core");
10
10
  const fs_extra_1 = __importDefault(require("fs-extra"));
11
11
  const path_1 = __importDefault(require("path"));
12
12
  const detectError_1 = require("./buildErrors/detectError");
13
+ const datadog_1 = require("./datadog");
13
14
  const appConfig_1 = require("./utils/appConfig");
14
15
  const environmentSecrets_1 = require("./utils/environmentSecrets");
15
16
  const packageManager_1 = require("./utils/packageManager");
@@ -235,6 +236,13 @@ class BuildContext {
235
236
  }
236
237
  await this.collectAndUpdateEnvVariablesAsync();
237
238
  this.reportBuildPhaseStats?.({ buildPhase: this.buildPhase, result, durationMs });
239
+ if (this.job.platform) {
240
+ datadog_1.Datadog.distribution('eas.build.phase_duration', durationMs, {
241
+ build_phase: this.buildPhase.toLowerCase(),
242
+ platform: this.job.platform,
243
+ result,
244
+ });
245
+ }
238
246
  if (!doNotMarkEnd) {
239
247
  this.logger.info({ marker: eas_build_job_1.LogMarker.END_PHASE, result, durationMs }, `End phase: ${this.buildPhase}`);
240
248
  }
@@ -0,0 +1,11 @@
1
+ type DatadogSetupOptions = {
2
+ expoApiV2BaseUrl: string;
3
+ turtleBuildId: string;
4
+ robotAccessToken: string;
5
+ };
6
+ export declare const Datadog: {
7
+ setup(opts: DatadogSetupOptions | null): void;
8
+ distribution(name: string, value: number, tags?: Record<string, string>): void;
9
+ flushAsync(): Promise<void>;
10
+ };
11
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Datadog = void 0;
4
+ const sentry_1 = require("./sentry");
5
+ const turtleFetch_1 = require("./utils/turtleFetch");
6
+ let setupOptions = null;
7
+ let pendingMetricUploads = [];
8
+ exports.Datadog = {
9
+ setup(opts) {
10
+ setupOptions = opts;
11
+ },
12
+ distribution(name, value, tags = {}) {
13
+ if (!setupOptions) {
14
+ return;
15
+ }
16
+ const { expoApiV2BaseUrl, turtleBuildId, robotAccessToken } = setupOptions;
17
+ const metrics = [
18
+ {
19
+ name,
20
+ type: 'distribution',
21
+ value,
22
+ tags,
23
+ },
24
+ ];
25
+ const uploadPromise = (0, turtleFetch_1.turtleFetch)(new URL(`turtle-builds/${turtleBuildId}/metrics`, expoApiV2BaseUrl).toString(), 'POST', {
26
+ json: { metrics },
27
+ headers: {
28
+ Authorization: `Bearer ${robotAccessToken}`,
29
+ },
30
+ retries: 2,
31
+ }).catch(err => {
32
+ sentry_1.Sentry.capture('Failed to report turtle build metric', err, {
33
+ extras: { metrics },
34
+ });
35
+ });
36
+ pendingMetricUploads.push(uploadPromise);
37
+ },
38
+ async flushAsync() {
39
+ await Promise.allSettled(pendingMetricUploads);
40
+ },
41
+ };
package/dist/index.d.ts CHANGED
@@ -6,5 +6,8 @@ export { ArtifactToUpload, Artifacts, BuildContext, BuildContextOptions, CacheMa
6
6
  export { PackageManager } from './utils/packageManager';
7
7
  export { findAndUploadXcodeBuildLogsAsync } from './ios/xcodeBuildLogs';
8
8
  export { Hook, runHookIfPresent } from './utils/hooks';
9
+ export { parseGradleProfile, formatGradleProfileReport } from './android/gradleProfile';
10
+ export type { GradleProfileTask } from './android/gradleProfile';
9
11
  export * from './generic';
12
+ export { Datadog } from './datadog';
10
13
  export { Sentry } from './sentry';
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.Sentry = exports.runHookIfPresent = exports.Hook = exports.findAndUploadXcodeBuildLogsAsync = exports.PackageManager = exports.SkipNativeBuildError = exports.BuildContext = exports.GCSLoggerStream = exports.GCS = exports.Builders = void 0;
42
+ exports.Sentry = exports.Datadog = exports.formatGradleProfileReport = exports.parseGradleProfile = exports.runHookIfPresent = exports.Hook = exports.findAndUploadXcodeBuildLogsAsync = exports.PackageManager = exports.SkipNativeBuildError = exports.BuildContext = exports.GCSLoggerStream = exports.GCS = exports.Builders = void 0;
43
43
  const Builders = __importStar(require("./builders"));
44
44
  exports.Builders = Builders;
45
45
  const LoggerStream_1 = __importDefault(require("./gcs/LoggerStream"));
@@ -56,6 +56,11 @@ Object.defineProperty(exports, "findAndUploadXcodeBuildLogsAsync", { enumerable:
56
56
  var hooks_1 = require("./utils/hooks");
57
57
  Object.defineProperty(exports, "Hook", { enumerable: true, get: function () { return hooks_1.Hook; } });
58
58
  Object.defineProperty(exports, "runHookIfPresent", { enumerable: true, get: function () { return hooks_1.runHookIfPresent; } });
59
+ var gradleProfile_1 = require("./android/gradleProfile");
60
+ Object.defineProperty(exports, "parseGradleProfile", { enumerable: true, get: function () { return gradleProfile_1.parseGradleProfile; } });
61
+ Object.defineProperty(exports, "formatGradleProfileReport", { enumerable: true, get: function () { return gradleProfile_1.formatGradleProfileReport; } });
59
62
  __exportStar(require("./generic"), exports);
63
+ var datadog_1 = require("./datadog");
64
+ Object.defineProperty(exports, "Datadog", { enumerable: true, get: function () { return datadog_1.Datadog; } });
60
65
  var sentry_1 = require("./sentry");
61
66
  Object.defineProperty(exports, "Sentry", { enumerable: true, get: function () { return sentry_1.Sentry; } });
@@ -14,7 +14,7 @@ async function runGradleCommand({ logger, gradleCommand, androidDir, env, extraE
14
14
  const verboseFlag = env['EAS_VERBOSE'] === '1' ? '--info' : '';
15
15
  logger.info(`Running 'gradlew ${gradleCommand} ${verboseFlag}' in ${androidDir}`);
16
16
  await fs_extra_1.default.chmod(path_1.default.join(androidDir, 'gradlew'), 0o755);
17
- const spawnPromise = (0, turtle_spawn_1.default)('bash', ['-c', `./gradlew ${gradleCommand} ${verboseFlag}`], {
17
+ const spawnPromise = (0, turtle_spawn_1.default)('bash', ['-c', `./gradlew ${gradleCommand} --profile ${verboseFlag}`], {
18
18
  cwd: androidDir,
19
19
  logger,
20
20
  lineTransformer: (line) => {
@@ -25,7 +25,11 @@ async function runGradleCommand({ logger, gradleCommand, androidDir, env, extraE
25
25
  return line;
26
26
  }
27
27
  },
28
- env: { ...env, ...extraEnv, LC_ALL: 'C.UTF-8' },
28
+ env: {
29
+ ...env,
30
+ ...extraEnv,
31
+ LC_ALL: 'C.UTF-8',
32
+ },
29
33
  });
30
34
  if (env.EAS_BUILD_RUNNER === 'eas-build' && process.platform === 'linux') {
31
35
  adjustOOMScore(spawnPromise, logger);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/build-tools",
3
- "version": "18.13.1",
3
+ "version": "19.0.0",
4
4
  "bugs": "https://github.com/expo/eas-cli/issues",
5
5
  "license": "BUSL-1.1",
6
6
  "author": "Expo <support@expo.io>",
@@ -37,17 +37,17 @@
37
37
  "dependencies": {
38
38
  "@expo/config": "55.0.10",
39
39
  "@expo/config-plugins": "55.0.7",
40
- "@expo/downloader": "18.5.0",
41
- "@expo/eas-build-job": "18.13.1",
40
+ "@expo/downloader": "19.0.0",
41
+ "@expo/eas-build-job": "19.0.0",
42
42
  "@expo/env": "^0.4.0",
43
- "@expo/logger": "18.5.0",
43
+ "@expo/logger": "19.0.0",
44
44
  "@expo/package-manager": "1.9.10",
45
45
  "@expo/plist": "^0.2.0",
46
46
  "@expo/results": "^1.0.0",
47
47
  "@expo/spawn-async": "1.7.2",
48
- "@expo/steps": "18.13.1",
49
- "@expo/template-file": "18.5.0",
50
- "@expo/turtle-spawn": "18.5.0",
48
+ "@expo/steps": "19.0.0",
49
+ "@expo/template-file": "19.0.0",
50
+ "@expo/turtle-spawn": "19.0.0",
51
51
  "@expo/xcpretty": "^4.3.1",
52
52
  "@google-cloud/storage": "^7.11.2",
53
53
  "@sentry/node": "7.77.0",
@@ -99,5 +99,5 @@
99
99
  "typescript": "^5.5.4",
100
100
  "uuid": "^9.0.1"
101
101
  },
102
- "gitHead": "dbf597957dc93133d15e99298c55c0ad31b994c1"
102
+ "gitHead": "fc7c2950e773245d987c756b2bd2e8ba2ac6ee22"
103
103
  }