Skip to content

Commit a026293

Browse files
use generated config path env
1 parent 8760df3 commit a026293

File tree

1 file changed

+17
-29
lines changed
  • packages/eas-cli/src/commands/update

1 file changed

+17
-29
lines changed

packages/eas-cli/src/commands/update/index.ts

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import type { ExpoConfig } from '@expo/config';
21
import { Workflow } from '@expo/eas-build-job';
32
import { EasJson, EasJsonAccessor, EasJsonUtils } from '@expo/eas-json';
43
import { Errors, Flags } from '@oclif/core';
54
import chalk from 'chalk';
6-
import fs from 'node:fs';
7-
import path from 'node:path';
5+
import * as os from 'node:os';
6+
import * as path from 'node:path';
87
import nullthrows from 'nullthrows';
98

109
import { getExpoWebsiteBaseUrl } from '../../api';
@@ -255,6 +254,8 @@ export default class UpdatePublish extends EasCommand {
255254
? { ...(await getServerSideEnvironmentVariablesAsync()), EXPO_NO_DOTENV: '1' }
256255
: {};
257256

257+
const generatedConfigPath = getTemporaryPath();
258+
258259
// build bundle and upload assets for a new publish
259260
if (!skipBundler) {
260261
const bundleSpinner = ora().start('Exporting...');
@@ -265,7 +266,10 @@ export default class UpdatePublish extends EasCommand {
265266
exp,
266267
platformFlag: requestedPlatform,
267268
clearCache,
268-
extraEnv: maybeServerEnv,
269+
extraEnv: {
270+
...maybeServerEnv,
271+
__EXPO_GENERATED_CONFIG_PATH: generatedConfigPath,
272+
},
269273
});
270274
bundleSpinner.succeed('Exported bundle(s)');
271275
} catch (e) {
@@ -274,10 +278,6 @@ export default class UpdatePublish extends EasCommand {
274278
}
275279
}
276280

277-
// NOTE(@krystofwoldrich): This adds auto generated server url to the app config extras.
278-
// This is done in-memory only to avoid breaking updates fingerprint.
279-
await readDeployedServerUrlAsync(exp, inputDir);
280-
281281
// After possibly bundling, assert that the input directory can be found.
282282
const distRoot = await resolveInputDirectoryAsync(inputDir, { skipBundler });
283283

@@ -358,7 +358,13 @@ export default class UpdatePublish extends EasCommand {
358358

359359
uploadedAssetCount = uploadResults.uniqueUploadedAssetCount;
360360
assetLimitPerUpdateGroup = uploadResults.assetLimitPerUpdateGroup;
361-
unsortedUpdateInfoGroups = await buildUnsortedUpdateInfoGroupAsync(assets, exp);
361+
362+
const { exp: expAfterBuild } = await getDynamicPublicProjectConfigAsync({
363+
env: {
364+
__EXPO_GENERATED_CONFIG_PATH: generatedConfigPath,
365+
},
366+
});
367+
unsortedUpdateInfoGroups = await buildUnsortedUpdateInfoGroupAsync(assets, expAfterBuild);
362368

363369
// NOTE(cedric): we assume that bundles are always uploaded, and always are part of
364370
// `uploadedAssetCount`, perferably we don't assume. For that, we need to refactor the
@@ -765,25 +771,7 @@ export default class UpdatePublish extends EasCommand {
765771
};
766772
}
767773
}
768-
async function readDeployedServerUrlAsync(exp: ExpoConfig, inputDir: string): Promise<void> {
769-
const deploymentPath = path.join(inputDir, 'server-deployment.json');
770-
try {
771-
const rawContent = await fs.promises.readFile(deploymentPath, 'utf-8');
772-
const { serverUrl } = JSON.parse(rawContent);
773-
if (!serverUrl) {
774-
Log.debug('No auto-deployed server URL found.');
775-
return;
776-
}
777774

778-
exp.extra ??= {};
779-
exp.extra.router ??= {};
780-
exp.extra.router.generatedOrigin = serverUrl;
781-
Log.withInfo(`Set origin to ${serverUrl}`);
782-
} catch (error: any) {
783-
if (error.code === 'ENOENT') {
784-
Log.debug('No auto-deployed server URL file found.');
785-
} else {
786-
Log.error(`Failed to read auto-deployed server URL from ${deploymentPath}.`);
787-
}
788-
}
775+
function getTemporaryPath(): string {
776+
return path.join(os.tmpdir(), Math.random().toString(36).substring(2));
789777
}

0 commit comments

Comments
 (0)