The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 13:30 UTC
fix(server): find the EAS project of variant app configs (#29466)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Julius Marminge <julius0216@outlook.com>
Krystof Woldrich committed
Nov 14, 2026 at 23:40 UTC
35308053127bbd7158277ff6fd3aec5b69c7dbfc
2 files changed
+121
-7
apps/server/src/device/easProjectId.test.ts
+97
@@ -165,6 +165,103 @@ it.effect.each([
165
},
166
expected: Option.some(ID_A),
167
},
168
+ {
169
+ case: "reads app.json's id through a typed variant config that spreads parts of config",
170
+ files: {
171
+ "app.config.js": `/** @param {import('expo/config').ConfigContext} context */
172
+ module.exports = ({ config }) => ({
173
+ ...config,
174
+ ios: { ...config.ios, infoPlist: { ...config?.ios.infoPlist, CFBundleDisplayName: "Dev" } },
175
+ plugins: [...config.plugins, "expo-dev-client"],
176
+ });`,
177
+ "app.json": JSON.stringify({ expo: { extra: { eas: { projectId: ID_A } } } }),
178
+ },
179
+ expected: Option.some(ID_A),
180
+ },
181
+ {
182
+ case: "reads app.json's id through a config typed in a multi-line JSDoc or line comment",
183
+ files: {
184
+ "app.config.js": `// Types: import('expo/config').ExpoConfig
185
+ /**
186
+ * The dev variant of the app.
187
+ * @param {import('expo/config').ConfigContext} context
188
+ */
189
+ module.exports = ({ config }) => ({ ...config, name: "Dev" });`,
190
+ "app.json": JSON.stringify({ expo: { extra: { eas: { projectId: ID_A } } } }),
191
+ },
192
+ expected: Option.some(ID_A),
193
+ },
194
+ {
195
+ case: "gives no answer when a config spreads a part of config over the top, which may bring its own extra",
196
+ files: {
197
+ "app.config.js": `module.exports = ({ config }) => ({ ...config, ...config.preview });`,
198
+ "app.json": JSON.stringify({
199
+ expo: {
200
+ extra: { eas: { projectId: ID_A } },
201
+ preview: { extra: { eas: { projectId: ID_B } } },
202
+ },
203
+ }),
204
+ },
205
+ expected: Option.none(),
206
+ },
207
+ {
208
+ case: "gives no answer when a config wraps a part of config under another key, as Expo reads expo",
209
+ files: {
210
+ "app.config.js": `module.exports = ({ config }) =>
211
+ process.env.APP_VARIANT === "preview" ? { expo: { ...config.preview } } : { ...config };`,
212
+ "app.json": JSON.stringify({
213
+ expo: {
214
+ extra: { eas: { projectId: ID_A } },
215
+ preview: { extra: { eas: { projectId: ID_B } } },
216
+ },
217
+ }),
218
+ },
219
+ expected: Option.none(),
220
+ },
221
+ {
222
+ case: "gives no answer when a config spreads a part into an expo entry, which Expo reads as the config",
223
+ files: {
224
+ "app.config.js": `module.exports = ({ config }) => ({ ...config, expo: { ...config.preview.expo } });`,
225
+ "app.json": JSON.stringify({
226
+ expo: {
227
+ extra: { eas: { projectId: ID_A } },
228
+ preview: { expo: { extra: { eas: { projectId: ID_B } } } },
229
+ },
230
+ }),
231
+ },
232
+ expected: Option.none(),
233
+ },
234
+ {
235
+ case: "gives no answer when a config spreads a part into a computed key",
236
+ files: {
237
+ "app.config.js": `module.exports = ({ config }) => ({ ...config, [[...config.keys]]: config.preview });`,
238
+ "app.json": JSON.stringify({
239
+ expo: {
240
+ keys: ["extra"],
241
+ extra: { eas: { projectId: ID_A } },
242
+ preview: { eas: { projectId: ID_B } },
243
+ },
244
+ }),
245
+ },
246
+ expected: Option.none(),
247
+ },
248
+ {
249
+ case: "gives no answer when a template line that only looks like a comment replaces extra",
250
+ files: {
251
+ "app.config.js": `module.exports = ({ config }) => {
252
+ const banner = \`
253
+/* \${(config.extra = config.preview.extra)} */\`;
254
+ return { ...config, name: banner };
255
+ };`,
256
+ "app.json": JSON.stringify({
257
+ expo: {
258
+ extra: { eas: { projectId: ID_A } },
259
+ preview: { extra: { eas: { projectId: ID_B } } },
260
+ },
261
+ }),
262
+ },
263
+ expected: Option.none(),
264
+ },
265
{
266
case: "reads a project id that follows spreads",
267
files: {
apps/server/src/device/easProjectId.ts
+24
-7
@@ -48,10 +48,21 @@ const HOLDER_AT = {
48
// `config` and no more of it: not an identifier continuing (`$`, Unicode
49
// letters and a `\u` escape do, where `\b` would not), nor a property.
50
const CONFIG_AT = new RegExp("config" + HOLDER_END, "uy");
51
+// A part of `config` other than `extra`, such as `config.ios`; the last name is
52
+// captured. Spread at the top it could bring its own `extra` (`...config.preview`).
53
+const CONFIG_PART_AT = new RegExp(
54
+ String.raw`config(?:\s*\??\.\s*(?!extra(?![\p{ID_Continue}$]))([\p{ID_Start}$_][\p{ID_Continue}$\u200c\u200d]*))+` +
55
+ HOLDER_END,
56
+ "uy",
57
+);
58
+// So a part keeps the id only as the first item of the object or array entry it
59
+// names (`ios: { ...config.ios`, `plugins: [...config.plugins`); the key is captured.
60
+const PART_OPENER =
61
+ /(?<=[{,]\s*["']?([\p{ID_Start}$_][\p{ID_Continue}$\u200c\u200d]*)["']?\s*:\s*[[{]\s*)/uy;
62
63
/**
53
- * Only Expo's `config` and its own `extra`/`extra.eas` spreads can preserve app.json's id.
54
- * Other spreads may replace it; no spreads leaves inheritance unclear.
64
+ * Only Expo's `config`, its own `extra`/`extra.eas`, and parts kept in their own entry can
65
+ * preserve app.json's id. Other spreads may replace it; no spreads leaves inheritance unclear.
66
* Skip comments whole after spreads to keep scanning linear.
67
*/
68
const staticConfigUse = (source: string): "spreads" | "replaces" | "unclear" => {
@@ -72,18 +83,24 @@ const staticConfigUse = (source: string): "spreads" | "replaces" | "unclear" =>
83
spreads++;
84
continue;
85
}
86
+ CONFIG_PART_AT.lastIndex = at;
87
+ const part = CONFIG_PART_AT.exec(source);
88
+ PART_OPENER.lastIndex = next;
89
+ const opener = part && PART_OPENER.exec(source);
90
+ // Expo reads a returned `expo` entry as the whole config.
91
+ if (opener && opener[1] === part[1] && opener[1] !== "expo") continue;
92
HOLDER_AT.extra.lastIndex = at;
93
HOLDER_AT.eas.lastIndex = at;
94
if (!HOLDER_AT.extra.test(source) && !HOLDER_AT.eas.test(source)) return "replaces";
95
}
96
};
97
const ASSIGNS_OVER = /\bObject\s*\.\s*assign\b|\bassign\s*\(/;
81
-// A config may replace the object holding the entry, or the whole config,
82
-// from somewhere this scan cannot read: an assignment to `.extra` or `.eas`,
83
-// (as a property or in brackets), a `delete` of anything, or another file it
84
-// requires or imports.
98
+// A config may replace its entry or itself from where this scan cannot read:
99
+// assigning `.extra` or `.eas` (dotted or bracketed), a `delete`, or a file it
100
+// requires or imports. Typing it as `import('expo/config').ConfigContext`, in a
101
+// comment or not, loads only Expo's own module.
102
const REPLACES_HOLDER =
86
- /(?:\.\s*(?:extra|eas)|\[\s*["'`](?:extra|eas)["'`]\s*\])\s*=(?!=)|\bdelete\b|\brequire\s*\(|\bimport\s*\(/;
103
+ /(?:\.\s*(?:extra|eas)|\[\s*["'`](?:extra|eas)["'`]\s*\])\s*=(?!=)|\bdelete\b|\brequire\s*\(|\bimport\s*\((?!\s*(["'])expo\/config\1\s*\)\s*\.\s*[A-Z])/;
104
// An `extra`/`eas` object must start by spreading the matching `config` entry to keep app.json's id.
105
// Spreading the whole config there puts the id elsewhere; shorthand entries replace it too.
106
// Stop reading once entries exceed MAX_MENTIONS.