@expo/build-tools 20.2.0 → 20.3.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.
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { type bunyan } from '@expo/logger';
|
|
1
2
|
import { BuildFunction } from '@expo/steps';
|
|
2
3
|
import { CustomBuildContext } from '../../customBuildContext';
|
|
3
4
|
export declare function createStartArgentRemoteSessionBuildFunction(ctx: CustomBuildContext): BuildFunction;
|
|
5
|
+
export declare function warnIfArgentPackageVersionCannotBeVerified({ packageVersion, logger, }: {
|
|
6
|
+
packageVersion: string | undefined;
|
|
7
|
+
logger: bunyan;
|
|
8
|
+
}): void;
|
|
@@ -4,19 +4,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.createStartArgentRemoteSessionBuildFunction = createStartArgentRemoteSessionBuildFunction;
|
|
7
|
+
exports.warnIfArgentPackageVersionCannotBeVerified = warnIfArgentPackageVersionCannotBeVerified;
|
|
7
8
|
const eas_build_job_1 = require("@expo/eas-build-job");
|
|
8
9
|
const steps_1 = require("@expo/steps");
|
|
9
10
|
const turtle_spawn_1 = __importDefault(require("@expo/turtle-spawn"));
|
|
10
11
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
12
|
const node_os_1 = __importDefault(require("node:os"));
|
|
12
13
|
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
+
const semver_1 = __importDefault(require("semver"));
|
|
13
15
|
const zod_1 = require("zod");
|
|
14
16
|
const remoteDeviceRunSession_1 = require("../utils/remoteDeviceRunSession");
|
|
15
17
|
const ARGENT_PACKAGE_NAME = '@swmansion/argent';
|
|
18
|
+
const MIN_ARGENT_REMOTE_SESSION_VERSION = '0.11.0';
|
|
16
19
|
const ARGENT_STATE_FILE = node_path_1.default.join(node_os_1.default.homedir(), '.argent', 'tool-server.json');
|
|
17
20
|
const XCODE_DEVELOPER_DIR = '/Applications/Xcode.app/Contents/Developer';
|
|
18
21
|
const STARTUP_TIMEOUT_MS = 60_000;
|
|
19
|
-
const ArgentToolServerStateSchema = zod_1.z.object({
|
|
22
|
+
const ArgentToolServerStateSchema = zod_1.z.object({
|
|
23
|
+
port: zod_1.z.number(),
|
|
24
|
+
token: zod_1.z.string().optional(),
|
|
25
|
+
});
|
|
20
26
|
function createStartArgentRemoteSessionBuildFunction(ctx) {
|
|
21
27
|
return new steps_1.BuildFunction({
|
|
22
28
|
namespace: 'eas',
|
|
@@ -39,6 +45,7 @@ function createStartArgentRemoteSessionBuildFunction(ctx) {
|
|
|
39
45
|
const ngrokTunnelDomain = (0, remoteDeviceRunSession_1.getNgrokTunnelDomainOrThrow)(env);
|
|
40
46
|
const ngrokAuthtoken = (0, remoteDeviceRunSession_1.getNgrokAuthtokenOrThrow)(env);
|
|
41
47
|
const packageVersion = inputs.package_version.value;
|
|
48
|
+
warnIfArgentPackageVersionCannotBeVerified({ packageVersion, logger });
|
|
42
49
|
const versionSpec = packageVersion ?? 'latest';
|
|
43
50
|
const { runtimePlatform } = global;
|
|
44
51
|
logger.info(`Starting argent remote session (version: ${versionSpec}, runtime: ${runtimePlatform}).`);
|
|
@@ -48,32 +55,48 @@ function createStartArgentRemoteSessionBuildFunction(ctx) {
|
|
|
48
55
|
}
|
|
49
56
|
// Stale state from a previous run would mask the new server's port.
|
|
50
57
|
await node_fs_1.default.promises.rm(ARGENT_STATE_FILE, { force: true });
|
|
51
|
-
logger.info(`Launching ${ARGENT_PACKAGE_NAME}@${versionSpec} via bunx.`);
|
|
52
|
-
|
|
53
|
-
// to spawn the tool-server detached + unref'd, so the tool-server
|
|
54
|
-
// outlives this MCP process. ARGENT_IDLE_TIMEOUT_MINUTES=0 disables the
|
|
55
|
-
// 30-min idle shutdown that would otherwise tear the tunnel down.
|
|
56
|
-
(0, remoteDeviceRunSession_1.spawnDetached)({
|
|
58
|
+
logger.info(`Launching ${ARGENT_PACKAGE_NAME}@${versionSpec} tool-server via bunx.`);
|
|
59
|
+
const argentServer = (0, remoteDeviceRunSession_1.spawnDetached)({
|
|
57
60
|
command: 'bunx',
|
|
58
|
-
args: [
|
|
59
|
-
|
|
61
|
+
args: [
|
|
62
|
+
`${ARGENT_PACKAGE_NAME}@${versionSpec}`,
|
|
63
|
+
'server',
|
|
64
|
+
'start',
|
|
65
|
+
'--port',
|
|
66
|
+
'0',
|
|
67
|
+
'--idle-timeout',
|
|
68
|
+
'0',
|
|
69
|
+
'--detach',
|
|
70
|
+
],
|
|
71
|
+
env,
|
|
60
72
|
});
|
|
61
73
|
logger.info(`Waiting for argent tool-server state at ${ARGENT_STATE_FILE}.`);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
let toolServerPort;
|
|
75
|
+
let toolServerToken;
|
|
76
|
+
try {
|
|
77
|
+
const toolServerState = await (0, remoteDeviceRunSession_1.waitForFileAsync)({
|
|
78
|
+
filePath: ARGENT_STATE_FILE,
|
|
79
|
+
timeoutMs: STARTUP_TIMEOUT_MS,
|
|
80
|
+
description: 'argent tool-server state',
|
|
81
|
+
parse: parseArgentToolServerState,
|
|
82
|
+
});
|
|
83
|
+
toolServerPort = toolServerState.port;
|
|
84
|
+
toolServerToken = toolServerState.token;
|
|
85
|
+
}
|
|
86
|
+
catch (err) {
|
|
87
|
+
const output = argentServer.getOutput();
|
|
88
|
+
throw new eas_build_job_1.SystemError(`${err instanceof Error ? err.message : `Timed out waiting for argent tool-server state.`}${output ? `\nArgent tool-server output:\n${output}` : ''}`);
|
|
89
|
+
}
|
|
68
90
|
logger.info(`Argent tool-server is listening on port ${toolServerPort}.`);
|
|
69
|
-
const
|
|
91
|
+
const publicToolsUrl = await (0, remoteDeviceRunSession_1.startNgrokTunnelAsync)({
|
|
70
92
|
port: toolServerPort,
|
|
71
93
|
subdomainPrefix: 'argent',
|
|
72
94
|
baseDomain: ngrokTunnelDomain,
|
|
73
95
|
authtoken: ngrokAuthtoken,
|
|
96
|
+
rewriteHostHeader: true,
|
|
74
97
|
logger,
|
|
75
98
|
});
|
|
76
|
-
logger.info(`Tunnel is ready at ${
|
|
99
|
+
logger.info(`Tunnel is ready at ${publicToolsUrl}.`);
|
|
77
100
|
// serve-sim is iOS-only — Android sessions go without a preview URL.
|
|
78
101
|
let webPreviewUrl;
|
|
79
102
|
if (runtimePlatform === steps_1.BuildRuntimePlatform.DARWIN) {
|
|
@@ -90,7 +113,8 @@ function createStartArgentRemoteSessionBuildFunction(ctx) {
|
|
|
90
113
|
ctx,
|
|
91
114
|
deviceRunSessionId,
|
|
92
115
|
remoteConfig: {
|
|
93
|
-
toolsUrl,
|
|
116
|
+
toolsUrl: publicToolsUrl,
|
|
117
|
+
...(toolServerToken ? { toolsAuthToken: toolServerToken } : {}),
|
|
94
118
|
...(webPreviewUrl ? { webPreviewUrl } : {}),
|
|
95
119
|
},
|
|
96
120
|
logger,
|
|
@@ -102,6 +126,23 @@ function createStartArgentRemoteSessionBuildFunction(ctx) {
|
|
|
102
126
|
},
|
|
103
127
|
});
|
|
104
128
|
}
|
|
129
|
+
function warnIfArgentPackageVersionCannotBeVerified({ packageVersion, logger, }) {
|
|
130
|
+
if (!packageVersion || packageVersion === 'latest') {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
const validVersion = semver_1.default.valid(packageVersion);
|
|
134
|
+
if (!validVersion) {
|
|
135
|
+
logger.warn(`Argent remote simulator sessions require ${ARGENT_PACKAGE_NAME}@${MIN_ARGENT_REMOTE_SESSION_VERSION} or newer, ` +
|
|
136
|
+
`but package_version "${packageVersion}" is not an exact semver version that EAS can verify. ` +
|
|
137
|
+
`Continuing and letting bunx resolve it.`);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (semver_1.default.lt(validVersion, MIN_ARGENT_REMOTE_SESSION_VERSION)) {
|
|
141
|
+
throw new eas_build_job_1.SystemError(`Argent remote simulator sessions require ${ARGENT_PACKAGE_NAME}@${MIN_ARGENT_REMOTE_SESSION_VERSION} or newer. ` +
|
|
142
|
+
`The requested package_version "${packageVersion}" is too old for the EAS remote-session API. ` +
|
|
143
|
+
`Use "latest" or pass an exact version >= ${MIN_ARGENT_REMOTE_SESSION_VERSION}.`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
105
146
|
function parseArgentToolServerState(raw) {
|
|
106
147
|
const result = ArgentToolServerStateSchema.safeParse(JSON.parse(raw));
|
|
107
148
|
if (!result.success) {
|
|
@@ -55,11 +55,12 @@ export declare function startServeSimWithTunnelAsync(ctx: CustomBuildContext, {
|
|
|
55
55
|
previewUrl: string;
|
|
56
56
|
streamUrl: string;
|
|
57
57
|
}>;
|
|
58
|
-
export declare function startNgrokTunnelAsync({ port, subdomainPrefix, baseDomain, authtoken, logger, }: {
|
|
58
|
+
export declare function startNgrokTunnelAsync({ port, subdomainPrefix, baseDomain, authtoken, rewriteHostHeader, logger, }: {
|
|
59
59
|
port: number;
|
|
60
60
|
subdomainPrefix: string;
|
|
61
61
|
baseDomain: string;
|
|
62
62
|
authtoken: string;
|
|
63
|
+
rewriteHostHeader?: boolean;
|
|
63
64
|
logger: bunyan;
|
|
64
65
|
}): Promise<string>;
|
|
65
66
|
export declare function waitForFileAsync<T>({ filePath, timeoutMs, description, parse, }: {
|
|
@@ -231,12 +231,17 @@ function matchLabeledUrl({ output, label, baseDomain, }) {
|
|
|
231
231
|
const match = labelPattern.exec(output);
|
|
232
232
|
return match ? match[1] : null;
|
|
233
233
|
}
|
|
234
|
-
async function startNgrokTunnelAsync({ port, subdomainPrefix, baseDomain, authtoken, logger, }) {
|
|
234
|
+
async function startNgrokTunnelAsync({ port, subdomainPrefix, baseDomain, authtoken, rewriteHostHeader, logger, }) {
|
|
235
235
|
const domain = `${subdomainPrefix}-${(0, node_crypto_1.randomBytes)(8).toString('hex')}.${baseDomain}`;
|
|
236
236
|
logger.info(`Starting ngrok tunnel ${domain} -> http://localhost:${port}.`);
|
|
237
237
|
// Run the ngrok agent in-process via the SDK; it keeps the session alive until
|
|
238
238
|
// the process exits, and the step blocks forever to hold it open.
|
|
239
|
-
const listener = await ngrok.forward({
|
|
239
|
+
const listener = await ngrok.forward({
|
|
240
|
+
addr: port,
|
|
241
|
+
authtoken,
|
|
242
|
+
domain,
|
|
243
|
+
...(rewriteHostHeader ? { request_header_add: [`Host:localhost:${port}`] } : {}),
|
|
244
|
+
});
|
|
240
245
|
const url = listener.url();
|
|
241
246
|
if (!url) {
|
|
242
247
|
throw new eas_build_job_1.SystemError(`ngrok tunnel for ${domain} did not return a public URL.`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/build-tools",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.3.0",
|
|
4
4
|
"bugs": "https://github.com/expo/eas-cli/issues",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Expo <support@expo.io>",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"typescript": "^5.5.4",
|
|
101
101
|
"uuid": "^9.0.1"
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "490457976c996d06447e6442fbd1aec1ace09f1b"
|
|
104
104
|
}
|