@expo/build-tools 18.8.0 → 18.9.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.
|
@@ -36,6 +36,7 @@ const runGradle_1 = require("./functions/runGradle");
|
|
|
36
36
|
const saveBuildCache_1 = require("./functions/saveBuildCache");
|
|
37
37
|
const saveCache_1 = require("./functions/saveCache");
|
|
38
38
|
const sendSlackMessage_1 = require("./functions/sendSlackMessage");
|
|
39
|
+
const startAgentDeviceRemoteSession_1 = require("./functions/startAgentDeviceRemoteSession");
|
|
39
40
|
const startAndroidEmulator_1 = require("./functions/startAndroidEmulator");
|
|
40
41
|
const startCuttlefishDevice_1 = require("./functions/startCuttlefishDevice");
|
|
41
42
|
const startIosSimulator_1 = require("./functions/startIosSimulator");
|
|
@@ -73,6 +74,7 @@ function getEasFunctions(ctx) {
|
|
|
73
74
|
(0, generateGymfileFromTemplate_1.generateGymfileFromTemplateFunction)(),
|
|
74
75
|
(0, runFastlane_1.runFastlaneFunction)(),
|
|
75
76
|
(0, parseXcactivitylog_1.parseXcactivitylogFunction)(),
|
|
77
|
+
(0, startAgentDeviceRemoteSession_1.createStartAgentDeviceRemoteSessionBuildFunction)(),
|
|
76
78
|
(0, startAndroidEmulator_1.createStartAndroidEmulatorBuildFunction)(),
|
|
77
79
|
(0, startCuttlefishDevice_1.createStartCuttlefishDeviceBuildFunction)(),
|
|
78
80
|
(0, startIosSimulator_1.createStartIosSimulatorBuildFunction)(),
|
|
@@ -0,0 +1,181 @@
|
|
|
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.createStartAgentDeviceRemoteSessionBuildFunction = createStartAgentDeviceRemoteSessionBuildFunction;
|
|
7
|
+
const steps_1 = require("@expo/steps");
|
|
8
|
+
const turtle_spawn_1 = __importDefault(require("@expo/turtle-spawn"));
|
|
9
|
+
const node_child_process_1 = __importDefault(require("node:child_process"));
|
|
10
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
const retry_1 = require("../../utils/retry");
|
|
14
|
+
const AGENT_DEVICE_REPO_URL = 'https://github.com/callstackincubator/agent-device.git';
|
|
15
|
+
const SRC_DIR = '/tmp/agent-device-src';
|
|
16
|
+
const RUN_DIR = '/tmp/agent-device';
|
|
17
|
+
const DAEMON_LOG = node_path_1.default.join(RUN_DIR, 'daemon.log');
|
|
18
|
+
const TUNNEL_LOG = node_path_1.default.join(RUN_DIR, 'cloudflared.log');
|
|
19
|
+
const DAEMON_JSON_PATH = node_path_1.default.join(node_os_1.default.homedir(), '.agent-device', 'daemon.json');
|
|
20
|
+
const XCODE_DEVELOPER_DIR = '/Applications/Xcode.app/Contents/Developer';
|
|
21
|
+
const STARTUP_TIMEOUT_MS = 60_000;
|
|
22
|
+
function createStartAgentDeviceRemoteSessionBuildFunction() {
|
|
23
|
+
return new steps_1.BuildFunction({
|
|
24
|
+
namespace: 'eas',
|
|
25
|
+
id: 'start_agent_device_remote_session',
|
|
26
|
+
name: 'Start agent device remote session',
|
|
27
|
+
__metricsId: 'eas/start_agent_device_remote_session',
|
|
28
|
+
inputProviders: [
|
|
29
|
+
steps_1.BuildStepInput.createProvider({
|
|
30
|
+
id: 'package_version',
|
|
31
|
+
required: false,
|
|
32
|
+
allowedValueTypeName: steps_1.BuildStepInputValueTypeName.STRING,
|
|
33
|
+
}),
|
|
34
|
+
],
|
|
35
|
+
fn: async ({ logger }, { inputs, env }) => {
|
|
36
|
+
const packageVersion = inputs.package_version.value;
|
|
37
|
+
logger.info(`Starting agent-device remote session (version: ${packageVersion ?? 'latest'}).`);
|
|
38
|
+
logger.info(`Preparing runtime directory at ${RUN_DIR}.`);
|
|
39
|
+
await node_fs_1.default.promises.mkdir(RUN_DIR, { recursive: true });
|
|
40
|
+
logger.info(`Selecting Xcode developer directory: ${XCODE_DEVELOPER_DIR}.`);
|
|
41
|
+
await (0, turtle_spawn_1.default)('sudo', ['xcode-select', '-s', XCODE_DEVELOPER_DIR], { env, logger });
|
|
42
|
+
logger.info('Ensuring cloudflared is installed.');
|
|
43
|
+
await ensureCloudflaredInstalledAsync({ env, logger });
|
|
44
|
+
logger.info('Ensuring bun is installed.');
|
|
45
|
+
await ensureBunInstalledAsync({ env, logger });
|
|
46
|
+
logger.info(packageVersion
|
|
47
|
+
? `Cloning agent-device @ v${packageVersion} into ${SRC_DIR}.`
|
|
48
|
+
: `Cloning agent-device (latest) into ${SRC_DIR}.`);
|
|
49
|
+
await cloneAgentDeviceAsync({ packageVersion, env, logger });
|
|
50
|
+
logger.info('Installing agent-device dependencies.');
|
|
51
|
+
await (0, turtle_spawn_1.default)('bun', ['install', '--production'], {
|
|
52
|
+
cwd: SRC_DIR,
|
|
53
|
+
env,
|
|
54
|
+
logger,
|
|
55
|
+
});
|
|
56
|
+
logger.info(`Launching agent-device daemon (log file: ${DAEMON_LOG}).`);
|
|
57
|
+
await spawnDetachedAsync({
|
|
58
|
+
command: 'bun run src/daemon.ts',
|
|
59
|
+
cwd: SRC_DIR,
|
|
60
|
+
logFile: DAEMON_LOG,
|
|
61
|
+
env: { ...env, AGENT_DEVICE_DAEMON_SERVER_MODE: 'http' },
|
|
62
|
+
logger,
|
|
63
|
+
});
|
|
64
|
+
logger.info(`Waiting for daemon credentials at ${DAEMON_JSON_PATH}.`);
|
|
65
|
+
await waitForFileAsync({
|
|
66
|
+
filePath: DAEMON_JSON_PATH,
|
|
67
|
+
timeoutMs: STARTUP_TIMEOUT_MS,
|
|
68
|
+
description: 'agent-device daemon',
|
|
69
|
+
});
|
|
70
|
+
const { port: daemonPort, token: daemonToken } = readDaemonInfo(DAEMON_JSON_PATH);
|
|
71
|
+
logger.info(`Daemon is listening on port ${daemonPort}; loaded auth token.`);
|
|
72
|
+
logger.info(`Starting cloudflared tunnel to http://localhost:${daemonPort} (log file: ${TUNNEL_LOG}).`);
|
|
73
|
+
await spawnDetachedAsync({
|
|
74
|
+
command: `cloudflared tunnel --url "http://localhost:${daemonPort}"`,
|
|
75
|
+
logFile: TUNNEL_LOG,
|
|
76
|
+
env,
|
|
77
|
+
logger,
|
|
78
|
+
});
|
|
79
|
+
logger.info('Waiting for a public tunnel URL.');
|
|
80
|
+
const tunnelUrl = await waitForMatchInLogAsync({
|
|
81
|
+
logFile: TUNNEL_LOG,
|
|
82
|
+
pattern: /https:\/\/[a-z0-9-]+\.trycloudflare\.com/,
|
|
83
|
+
timeoutMs: STARTUP_TIMEOUT_MS,
|
|
84
|
+
description: 'cloudflared tunnel',
|
|
85
|
+
});
|
|
86
|
+
logger.info(`Tunnel is ready at ${tunnelUrl}.`);
|
|
87
|
+
logger.info('Emitting agent-device credentials for the CLI to pick up:');
|
|
88
|
+
logger.info(`export AGENT_DEVICE_DAEMON_BASE_URL="${tunnelUrl}"`);
|
|
89
|
+
logger.info(`export AGENT_DEVICE_DAEMON_AUTH_TOKEN="${daemonToken}"`);
|
|
90
|
+
logger.info('Remote session is live. Keeping the job alive until the session is stopped.');
|
|
91
|
+
// Keep the turtle job alive so the daemon and tunnel stay reachable
|
|
92
|
+
// until stopDeviceRunSession cancels the run.
|
|
93
|
+
await new Promise(() => { });
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async function ensureCloudflaredInstalledAsync({ env, logger, }) {
|
|
98
|
+
await ensureBrewPackageInstalledAsync({ name: 'cloudflared', env, logger });
|
|
99
|
+
}
|
|
100
|
+
async function ensureBunInstalledAsync({ env, logger, }) {
|
|
101
|
+
await ensureBrewPackageInstalledAsync({ name: 'bun', env, logger });
|
|
102
|
+
}
|
|
103
|
+
async function ensureBrewPackageInstalledAsync({ name, env, logger, }) {
|
|
104
|
+
await (0, turtle_spawn_1.default)('bash', ['-c', `command -v ${name} >/dev/null 2>&1 || HOMEBREW_NO_AUTO_UPDATE=1 brew install ${name}`], { env, logger });
|
|
105
|
+
}
|
|
106
|
+
async function cloneAgentDeviceAsync({ packageVersion, env, logger, }) {
|
|
107
|
+
const branchArgs = packageVersion ? ['--branch', `v${packageVersion}`] : [];
|
|
108
|
+
await (0, turtle_spawn_1.default)('git', ['clone', '--depth', '1', ...branchArgs, AGENT_DEVICE_REPO_URL, SRC_DIR], {
|
|
109
|
+
env,
|
|
110
|
+
logger,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
async function spawnDetachedAsync({ command, cwd, logFile, env, logger, }) {
|
|
114
|
+
// Launch the process fully detached so this function returns immediately and
|
|
115
|
+
// the grandchild survives the step. Stdio goes to a log file so the daemon
|
|
116
|
+
// output can be polled, and we unref so Node doesn't wait on it.
|
|
117
|
+
const fd = node_fs_1.default.openSync(logFile, 'a');
|
|
118
|
+
try {
|
|
119
|
+
const child = node_child_process_1.default.spawn('bash', ['-c', command], {
|
|
120
|
+
cwd,
|
|
121
|
+
env,
|
|
122
|
+
detached: true,
|
|
123
|
+
stdio: ['ignore', fd, fd],
|
|
124
|
+
});
|
|
125
|
+
if (!child.pid) {
|
|
126
|
+
throw new Error(`Failed to spawn detached process: ${command}`);
|
|
127
|
+
}
|
|
128
|
+
child.unref();
|
|
129
|
+
logger.info(`Started detached process (pid ${child.pid}).`);
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
node_fs_1.default.closeSync(fd);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async function waitForMatchInLogAsync({ logFile, pattern, timeoutMs, description, }) {
|
|
136
|
+
const deadline = Date.now() + timeoutMs;
|
|
137
|
+
while (Date.now() < deadline) {
|
|
138
|
+
const content = await readFileOrEmptyAsync(logFile);
|
|
139
|
+
const match = pattern.exec(content);
|
|
140
|
+
if (match) {
|
|
141
|
+
return match[1] ?? match[0];
|
|
142
|
+
}
|
|
143
|
+
await (0, retry_1.sleepAsync)(1_000);
|
|
144
|
+
}
|
|
145
|
+
const tail = await readFileOrEmptyAsync(logFile);
|
|
146
|
+
throw new Error(`Timed out waiting for ${description} to start. Last log contents:\n${tail || '<empty>'}`);
|
|
147
|
+
}
|
|
148
|
+
async function waitForFileAsync({ filePath, timeoutMs, description, }) {
|
|
149
|
+
const deadline = Date.now() + timeoutMs;
|
|
150
|
+
while (Date.now() < deadline) {
|
|
151
|
+
try {
|
|
152
|
+
await node_fs_1.default.promises.access(filePath);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
// not yet; keep polling
|
|
157
|
+
}
|
|
158
|
+
await (0, retry_1.sleepAsync)(1_000);
|
|
159
|
+
}
|
|
160
|
+
throw new Error(`Timed out waiting for ${description} to write ${filePath}.`);
|
|
161
|
+
}
|
|
162
|
+
async function readFileOrEmptyAsync(filePath) {
|
|
163
|
+
try {
|
|
164
|
+
return await node_fs_1.default.promises.readFile(filePath, 'utf8');
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
return '';
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function readDaemonInfo(filePath) {
|
|
171
|
+
const raw = node_fs_1.default.readFileSync(filePath, 'utf8');
|
|
172
|
+
const parsed = JSON.parse(raw);
|
|
173
|
+
if (!parsed ||
|
|
174
|
+
typeof parsed !== 'object' ||
|
|
175
|
+
typeof parsed.httpPort !== 'number' ||
|
|
176
|
+
typeof parsed.token !== 'string') {
|
|
177
|
+
throw new Error(`Expected ${filePath} to contain { "httpPort": <number>, "token": "..." }.`);
|
|
178
|
+
}
|
|
179
|
+
const { httpPort, token } = parsed;
|
|
180
|
+
return { port: httpPort, token };
|
|
181
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/build-tools",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.9.0",
|
|
4
4
|
"bugs": "https://github.com/expo/eas-cli/issues",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Expo <support@expo.io>",
|
|
@@ -45,7 +45,7 @@
|
|
|
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.
|
|
48
|
+
"@expo/steps": "18.9.0",
|
|
49
49
|
"@expo/template-file": "18.5.0",
|
|
50
50
|
"@expo/turtle-spawn": "18.5.0",
|
|
51
51
|
"@expo/xcpretty": "^4.3.1",
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"typescript": "^5.5.4",
|
|
99
99
|
"uuid": "^9.0.1"
|
|
100
100
|
},
|
|
101
|
-
"gitHead": "
|
|
101
|
+
"gitHead": "8fdf47aa7d5d8241d8afa04924a1d0f6d00fdc5a"
|
|
102
102
|
}
|