mirror of
https://github.com/expo/eas-cli.git
synced 2026-11-14 10:08:06 -10:00
Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0f2823fa18 | ||
|
|
52e6fd0e81 | ||
|
|
3957f058e9 | ||
|
|
8597524f32 | ||
|
|
7c5190a4ab | ||
|
|
9247f3cf78 | ||
|
|
bde331da63 | ||
|
|
fd055f08b3 | ||
|
|
785d690e65 | ||
|
|
47335f02f0 | ||
|
|
75d9be813f | ||
|
|
cdaa011ce3 |
No files matched your search
+10
-2
@@ -8,12 +8,20 @@ This is the log of notable changes to EAS CLI and related packages.
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
- [eas-cli] `eas integrations:posthog:connect` now supports existing PostHog user connection. ([#3895](https://github.com/expo/eas-cli/pull/3895) by [@gwdp](https://github.com/gwdp))
|
||||
|
||||
### 🐛 Bug fixes
|
||||
|
||||
- [eas-cli] Select correct tvOS build target for non-interactive Apple builds when EXPO_TV env variable is set. ([#3907](https://github.com/expo/eas-cli/pull/3907) by [@douglowder](https://github.com/douglowder))
|
||||
|
||||
### 🧹 Chores
|
||||
|
||||
- [eas-cli] Bump `@expo/apple-utils` to `2.1.22`. ([#3913](https://github.com/expo/eas-cli/pull/3913) by [@sjchmiela](https://github.com/sjchmiela))
|
||||
|
||||
## [20.5.0](https://github.com/expo/eas-cli/releases/tag/v20.5.0) - 2026-06-29
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
- [eas-cli] `eas integrations:posthog:connect` now supports existing PostHog user connection. ([#3895](https://github.com/expo/eas-cli/pull/3895) by [@gwdp](https://github.com/gwdp))
|
||||
|
||||
## [20.4.0](https://github.com/expo/eas-cli/releases/tag/v20.4.0) - 2026-06-25
|
||||
|
||||
### 🎉 New features
|
||||
|
||||
@@ -40,7 +40,7 @@ describe(installDependenciesWithNpmCacheFallbackAsync, () => {
|
||||
env: {
|
||||
EAS_VERBOSE: '1',
|
||||
EAS_USE_NPM_CACHE: '1',
|
||||
NPM_CONFIG_REGISTRY: npmCacheUrl,
|
||||
EAS_BUILD_NPM_CACHE_URL: npmCacheUrl,
|
||||
},
|
||||
logger,
|
||||
cwd: '/tmp/build',
|
||||
@@ -56,6 +56,7 @@ describe(installDependenciesWithNpmCacheFallbackAsync, () => {
|
||||
env: {
|
||||
EAS_VERBOSE: '1',
|
||||
EAS_USE_NPM_CACHE: '1',
|
||||
EAS_BUILD_NPM_CACHE_URL: npmCacheUrl,
|
||||
NPM_CONFIG_REGISTRY: npmCacheUrl,
|
||||
},
|
||||
});
|
||||
@@ -66,6 +67,7 @@ describe(installDependenciesWithNpmCacheFallbackAsync, () => {
|
||||
env: {
|
||||
EAS_VERBOSE: '1',
|
||||
EAS_USE_NPM_CACHE: '1',
|
||||
EAS_BUILD_NPM_CACHE_URL: npmCacheUrl,
|
||||
},
|
||||
});
|
||||
expect(logger.warn).toHaveBeenCalledWith(
|
||||
@@ -110,7 +112,7 @@ describe(installDependenciesWithNpmCacheFallbackAsync, () => {
|
||||
packageManager: PackageManager.NPM,
|
||||
env: {
|
||||
EAS_USE_NPM_CACHE: '1',
|
||||
NPM_CONFIG_REGISTRY: npmCacheUrl,
|
||||
EAS_BUILD_NPM_CACHE_URL: npmCacheUrl,
|
||||
},
|
||||
logger,
|
||||
cwd: '/tmp/build',
|
||||
@@ -158,7 +160,7 @@ describe(installDependenciesWithNpmCacheFallbackAsync, () => {
|
||||
packageManager: PackageManager.NPM,
|
||||
env: {
|
||||
EAS_USE_NPM_CACHE: '1',
|
||||
NPM_CONFIG_REGISTRY: 'http://npm.staging.caches.eas-build.internal',
|
||||
EAS_BUILD_NPM_CACHE_URL: 'http://npm.staging.caches.eas-build.internal',
|
||||
},
|
||||
logger,
|
||||
cwd: '/tmp/build',
|
||||
@@ -170,7 +172,7 @@ describe(installDependenciesWithNpmCacheFallbackAsync, () => {
|
||||
expect(Sentry.capture).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('does not retry when EAS_USE_NPM_CACHE is not enabled', async () => {
|
||||
it('does not retry when the npm cache is not enabled', async () => {
|
||||
const logger = createMockLogger();
|
||||
const npmCacheUrl = 'http://npm.staging.caches.eas-build.internal';
|
||||
const error = Object.assign(
|
||||
@@ -188,9 +190,7 @@ describe(installDependenciesWithNpmCacheFallbackAsync, () => {
|
||||
await expect(
|
||||
installDependenciesWithNpmCacheFallbackAsync({
|
||||
packageManager: PackageManager.NPM,
|
||||
env: {
|
||||
NPM_CONFIG_REGISTRY: npmCacheUrl,
|
||||
},
|
||||
env: {},
|
||||
logger,
|
||||
cwd: '/tmp/build',
|
||||
useFrozenLockfile: false,
|
||||
@@ -200,6 +200,40 @@ describe(installDependenciesWithNpmCacheFallbackAsync, () => {
|
||||
expect(spawn).toHaveBeenCalledTimes(1);
|
||||
expect(Sentry.capture).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('installs through the npm cache registry without retrying when the cache install succeeds', async () => {
|
||||
const logger = createMockLogger();
|
||||
const npmCacheUrl = 'http://npm.staging.caches.eas-build.internal';
|
||||
|
||||
jest
|
||||
.mocked(spawn)
|
||||
.mockReturnValueOnce(createSpawnPromise(Promise.resolve(createSpawnResult())));
|
||||
|
||||
await installDependenciesWithNpmCacheFallbackAsync({
|
||||
packageManager: PackageManager.NPM,
|
||||
env: {
|
||||
EAS_USE_NPM_CACHE: '1',
|
||||
EAS_BUILD_NPM_CACHE_URL: npmCacheUrl,
|
||||
},
|
||||
logger,
|
||||
cwd: '/tmp/build',
|
||||
useFrozenLockfile: false,
|
||||
});
|
||||
|
||||
expect(spawn).toHaveBeenCalledTimes(1);
|
||||
expect(spawn).toHaveBeenCalledWith('npm', ['install', '--include=dev'], {
|
||||
cwd: '/tmp/build',
|
||||
logger,
|
||||
infoCallbackFn: undefined,
|
||||
lineTransformer: expect.any(Function),
|
||||
env: {
|
||||
EAS_USE_NPM_CACHE: '1',
|
||||
EAS_BUILD_NPM_CACHE_URL: npmCacheUrl,
|
||||
NPM_CONFIG_REGISTRY: npmCacheUrl,
|
||||
},
|
||||
});
|
||||
expect(Sentry.capture).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
function createSpawnPromise(result: Promise<SpawnResult>): SpawnPromise<SpawnResult> {
|
||||
|
||||
@@ -93,7 +93,24 @@ export async function installDependenciesWithNpmCacheFallbackAsync({
|
||||
infoCallbackFn?: SpawnOptions['infoCallbackFn'];
|
||||
useFrozenLockfile: boolean;
|
||||
}): Promise<void> {
|
||||
const npmCacheUrl = env.NPM_CONFIG_REGISTRY;
|
||||
const npmCacheUrl = env.EAS_BUILD_NPM_CACHE_URL;
|
||||
|
||||
if (!npmCacheUrl) {
|
||||
await (
|
||||
await installDependenciesAsync({
|
||||
packageManager,
|
||||
env,
|
||||
logger,
|
||||
infoCallbackFn,
|
||||
cwd,
|
||||
useFrozenLockfile,
|
||||
})
|
||||
).spawnPromise;
|
||||
return;
|
||||
}
|
||||
|
||||
logger.info(`Installing dependencies using the npm cache registry (${npmCacheUrl}).`);
|
||||
|
||||
let firstErrorLine: string | undefined;
|
||||
let errorLineCount = 0;
|
||||
|
||||
@@ -101,11 +118,11 @@ export async function installDependenciesWithNpmCacheFallbackAsync({
|
||||
await (
|
||||
await installDependenciesAsync({
|
||||
packageManager,
|
||||
env,
|
||||
env: { ...env, NPM_CONFIG_REGISTRY: npmCacheUrl },
|
||||
logger,
|
||||
infoCallbackFn,
|
||||
lineTransformer: (line: string) => {
|
||||
if (isNpmCacheRegistryErrorLine(line, { env, npmCacheUrl })) {
|
||||
if (isNpmCacheRegistryErrorLine(line, npmCacheUrl)) {
|
||||
firstErrorLine ??= line;
|
||||
errorLineCount += 1;
|
||||
}
|
||||
@@ -124,7 +141,7 @@ export async function installDependenciesWithNpmCacheFallbackAsync({
|
||||
});
|
||||
}
|
||||
} catch (err: unknown) {
|
||||
if (!isNpmCacheInstallFailure(err, { env, npmCacheUrl })) {
|
||||
if (!isNpmCacheInstallFailure(err, npmCacheUrl)) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
@@ -144,11 +161,10 @@ export async function installDependenciesWithNpmCacheFallbackAsync({
|
||||
},
|
||||
});
|
||||
|
||||
const { NPM_CONFIG_REGISTRY: _NPM_CONFIG_REGISTRY, ...fallbackEnv } = env;
|
||||
await (
|
||||
await installDependenciesAsync({
|
||||
packageManager,
|
||||
env: fallbackEnv,
|
||||
env,
|
||||
logger,
|
||||
infoCallbackFn,
|
||||
cwd,
|
||||
@@ -172,35 +188,17 @@ export function resolvePackagerDir(ctx: BuildContext<Job>): string {
|
||||
return packagerRunDir;
|
||||
}
|
||||
|
||||
function isNpmCacheInstallFailure(
|
||||
err: unknown,
|
||||
{ env, npmCacheUrl }: { env: Record<string, string | undefined>; npmCacheUrl: string | undefined }
|
||||
): boolean {
|
||||
if (!isNpmCacheRegistryEnabled(env, npmCacheUrl)) {
|
||||
return false;
|
||||
}
|
||||
const errorOutput = getErrorOutput(err);
|
||||
return errorOutput.includes(npmCacheUrl);
|
||||
function isNpmCacheInstallFailure(err: unknown, npmCacheUrl: string): boolean {
|
||||
return getErrorOutput(err).includes(npmCacheUrl);
|
||||
}
|
||||
|
||||
function isNpmCacheRegistryErrorLine(
|
||||
line: string,
|
||||
{ env, npmCacheUrl }: { env: Record<string, string | undefined>; npmCacheUrl: string | undefined }
|
||||
): boolean {
|
||||
function isNpmCacheRegistryErrorLine(line: string, npmCacheUrl: string): boolean {
|
||||
return (
|
||||
isNpmCacheRegistryEnabled(env, npmCacheUrl) &&
|
||||
line.includes(npmCacheUrl) &&
|
||||
/(?:error|failed|ENOTFOUND|ECONN|ETIMEDOUT|EAI_AGAIN|FetchError)/i.test(line)
|
||||
);
|
||||
}
|
||||
|
||||
function isNpmCacheRegistryEnabled(
|
||||
env: Record<string, string | undefined>,
|
||||
npmCacheUrl: string | undefined
|
||||
): npmCacheUrl is string {
|
||||
return env.EAS_USE_NPM_CACHE === '1' && !!npmCacheUrl;
|
||||
}
|
||||
|
||||
function getErrorOutput(err: unknown): string {
|
||||
if (!(err instanceof Error)) {
|
||||
return '';
|
||||
|
||||
@@ -233,7 +233,7 @@ async function uploadProjectMetadataAsync(
|
||||
}
|
||||
`),
|
||||
{
|
||||
buildId: ctx.env.EAS_BUILD_ID,
|
||||
buildId: nullthrows(ctx.env.EAS_BUILD_ID, 'EAS_BUILD_ID is not set'),
|
||||
projectMetadataFile: {
|
||||
type: 'GCS',
|
||||
bucketKey: uploadSession.bucketKey,
|
||||
|
||||
@@ -63,7 +63,7 @@ export interface BuildContextOptions {
|
||||
reportError?: (
|
||||
msg: string,
|
||||
err?: Error,
|
||||
options?: { tags?: Record<string, string>; extras?: Record<string, string> }
|
||||
options?: { tags?: Record<string, string>; extras?: Record<string, string | undefined> }
|
||||
) => void;
|
||||
skipNativeBuild?: boolean;
|
||||
metadata?: Metadata;
|
||||
@@ -80,7 +80,7 @@ export class BuildContext<TJob extends Job = Job> {
|
||||
public readonly reportError?: (
|
||||
msg: string,
|
||||
err?: Error,
|
||||
options?: { tags?: Record<string, string>; extras?: Record<string, string> }
|
||||
options?: { tags?: Record<string, string>; extras?: Record<string, string | undefined> }
|
||||
) => void;
|
||||
public readonly skipNativeBuild?: boolean;
|
||||
public readonly expoApiV2BaseUrl?: string;
|
||||
|
||||
@@ -93,7 +93,7 @@ export async function runFastlane(
|
||||
cwd,
|
||||
}: {
|
||||
logger?: bunyan;
|
||||
env?: Record<string, string>;
|
||||
env?: Env;
|
||||
cwd?: string;
|
||||
} = {}
|
||||
): Promise<SpawnResult> {
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
import { BuildStepContext, BuildStepEnv } from '@expo/steps';
|
||||
import spawn, { SpawnPromise, SpawnResult } from '@expo/turtle-spawn';
|
||||
|
||||
import { createMockLogger } from '../../../__tests__/utils/logger';
|
||||
import {
|
||||
PackageManager,
|
||||
findPackagerRootDir,
|
||||
resolvePackageManager,
|
||||
shouldUseFrozenLockfile,
|
||||
} from '../../../utils/packageManager';
|
||||
import { readPackageJson } from '../../../utils/project';
|
||||
import { installNodeModules } from '../installNodeModules';
|
||||
|
||||
jest.mock('@expo/turtle-spawn', () => jest.fn());
|
||||
jest.mock('../../../sentry', () => ({
|
||||
Sentry: {
|
||||
capture: jest.fn(),
|
||||
},
|
||||
}));
|
||||
jest.mock('../../../utils/packageManager', () => ({
|
||||
...jest.requireActual('../../../utils/packageManager'),
|
||||
resolvePackageManager: jest.fn(),
|
||||
findPackagerRootDir: jest.fn(),
|
||||
shouldUseFrozenLockfile: jest.fn(),
|
||||
}));
|
||||
jest.mock('../../../utils/project', () => ({
|
||||
...jest.requireActual('../../../utils/project'),
|
||||
readPackageJson: jest.fn(),
|
||||
}));
|
||||
|
||||
describe(installNodeModules, () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
jest.mocked(resolvePackageManager).mockReturnValue(PackageManager.NPM);
|
||||
jest.mocked(findPackagerRootDir).mockReturnValue('/tmp/build');
|
||||
jest.mocked(shouldUseFrozenLockfile).mockReturnValue(false);
|
||||
jest.mocked(readPackageJson).mockReturnValue({});
|
||||
});
|
||||
|
||||
function createStepCtx(logger: ReturnType<typeof createMockLogger>): BuildStepContext {
|
||||
return {
|
||||
logger,
|
||||
workingDirectory: '/tmp/build',
|
||||
global: {
|
||||
projectTargetDirectory: '/tmp/build',
|
||||
staticContext: { metadata: {} },
|
||||
},
|
||||
} as unknown as BuildStepContext;
|
||||
}
|
||||
|
||||
it('retries the install without the npm cache registry when the cache install fails', async () => {
|
||||
const logger = createMockLogger();
|
||||
const npmCacheUrl = 'http://npm.caches.eas-build.internal';
|
||||
const env: BuildStepEnv = {
|
||||
EAS_USE_NPM_CACHE: '1',
|
||||
EAS_BUILD_NPM_CACHE_URL: npmCacheUrl,
|
||||
};
|
||||
const error = Object.assign(new Error('npm install exited with non-zero code: 1'), {
|
||||
status: 1,
|
||||
signal: null,
|
||||
stdout: '',
|
||||
stderr: `npm error request to ${npmCacheUrl}/left-pad failed, reason: getaddrinfo ENOTFOUND`,
|
||||
});
|
||||
|
||||
jest
|
||||
.mocked(spawn)
|
||||
.mockReturnValueOnce(createSpawnPromise(Promise.reject(error)))
|
||||
.mockReturnValueOnce(createSpawnPromise(Promise.resolve(createSpawnResult())));
|
||||
|
||||
await installNodeModules(createStepCtx(logger), env);
|
||||
|
||||
expect(spawn).toHaveBeenCalledTimes(2);
|
||||
expect(spawn).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'npm',
|
||||
['install', '--include=dev'],
|
||||
expect.objectContaining({
|
||||
env: {
|
||||
EAS_USE_NPM_CACHE: '1',
|
||||
EAS_BUILD_NPM_CACHE_URL: npmCacheUrl,
|
||||
NPM_CONFIG_REGISTRY: npmCacheUrl,
|
||||
},
|
||||
})
|
||||
);
|
||||
expect(spawn).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
'npm',
|
||||
['install', '--include=dev'],
|
||||
expect.objectContaining({
|
||||
env: { EAS_USE_NPM_CACHE: '1', EAS_BUILD_NPM_CACHE_URL: npmCacheUrl },
|
||||
})
|
||||
);
|
||||
expect(logger.warn).toHaveBeenCalledWith(
|
||||
`Failed to install dependencies using the npm cache registry (${npmCacheUrl}). Retrying without the npm cache registry.`
|
||||
);
|
||||
});
|
||||
|
||||
it('does not retry when the npm cache is not enabled', async () => {
|
||||
const logger = createMockLogger();
|
||||
const error = Object.assign(new Error('npm install exited with non-zero code: 1'), {
|
||||
status: 1,
|
||||
signal: null,
|
||||
stdout: '',
|
||||
stderr: 'npm error some unrelated failure',
|
||||
});
|
||||
|
||||
jest.mocked(spawn).mockReturnValueOnce(createSpawnPromise(Promise.reject(error)));
|
||||
|
||||
await expect(installNodeModules(createStepCtx(logger), {})).rejects.toThrow(error);
|
||||
|
||||
expect(spawn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
function createSpawnPromise(result: Promise<SpawnResult>): SpawnPromise<SpawnResult> {
|
||||
return Object.assign(result, {
|
||||
child: {
|
||||
pid: 123,
|
||||
},
|
||||
}) as SpawnPromise<SpawnResult>;
|
||||
}
|
||||
|
||||
function createSpawnResult(): SpawnResult {
|
||||
return {
|
||||
pid: 123,
|
||||
output: ['', ''],
|
||||
stdout: '',
|
||||
stderr: '',
|
||||
status: 0,
|
||||
signal: null,
|
||||
};
|
||||
}
|
||||
@@ -27,7 +27,7 @@ describe(createRepackBuildFunction, () => {
|
||||
vol.reset();
|
||||
});
|
||||
|
||||
it('should set the output path for successful repack', async () => {
|
||||
it('should set generated output path for successful repack', async () => {
|
||||
const repack = createRepackBuildFunction();
|
||||
const repackStep = repack.createBuildStepFromFunctionCall(
|
||||
createGlobalContextMock({
|
||||
@@ -38,14 +38,33 @@ describe(createRepackBuildFunction, () => {
|
||||
{
|
||||
callInputs: {
|
||||
platform: 'ios',
|
||||
source_app_path: '/path/to/source_app',
|
||||
output_path: '/path/to/output_app',
|
||||
source_app_path: '/path/to/source_app.ipa',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
await repackStep.executeAsync();
|
||||
expect(repackStep.outputById['output_path'].value).toBe('/path/to/output_app');
|
||||
expect(repackStep.outputById['output_path'].value).toMatch(/repacked-.*\.ipa$/);
|
||||
});
|
||||
|
||||
it('should rename generated aab output path to apk', async () => {
|
||||
const repack = createRepackBuildFunction();
|
||||
const repackStep = repack.createBuildStepFromFunctionCall(
|
||||
createGlobalContextMock({
|
||||
staticContextContent: {
|
||||
job: createTestAndroidJob(),
|
||||
},
|
||||
}),
|
||||
{
|
||||
callInputs: {
|
||||
platform: 'android',
|
||||
source_app_path: '/path/to/source_app.aab',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
await repackStep.executeAsync();
|
||||
expect(repackStep.outputById['output_path'].value).toMatch(/repacked-.*\.apk$/);
|
||||
});
|
||||
|
||||
it('should throw for unsupported platforms', async () => {
|
||||
|
||||
@@ -15,6 +15,7 @@ jest.mock('../../../utils/IosSimulatorUtils', () => ({
|
||||
getAvailableDevicesAsync: jest.fn(),
|
||||
getDeviceAsync: jest.fn(),
|
||||
cloneAsync: jest.fn(),
|
||||
enableAccessibilitySettingsAsync: jest.fn(),
|
||||
startAsync: jest.fn(),
|
||||
waitForReadyAsync: jest.fn(),
|
||||
disableApsdAsync: jest.fn(),
|
||||
@@ -34,15 +35,59 @@ function createStep(callInputs?: Record<string, unknown>) {
|
||||
|
||||
describe(createStartIosSimulatorBuildFunction, () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
mockedSpawn.mockResolvedValue({ stdout: '', stderr: '' } as any);
|
||||
mockedUtils.getAvailableDevicesAsync.mockResolvedValue([]);
|
||||
mockedUtils.getDeviceAsync.mockResolvedValue(null);
|
||||
mockedUtils.cloneAsync.mockResolvedValue(undefined);
|
||||
mockedUtils.enableAccessibilitySettingsAsync.mockResolvedValue(undefined);
|
||||
mockedUtils.startAsync.mockResolvedValue({ udid: 'test-udid' as any });
|
||||
mockedUtils.waitForReadyAsync.mockResolvedValue(undefined);
|
||||
mockedUtils.disableApsdAsync.mockResolvedValue(undefined);
|
||||
});
|
||||
|
||||
it('does not enable accessibility settings by default', async () => {
|
||||
await createStep({ device_identifier: 'iPhone 15' }).executeAsync();
|
||||
|
||||
expect(mockedUtils.enableAccessibilitySettingsAsync).not.toHaveBeenCalled();
|
||||
expect(mockedUtils.startAsync).toHaveBeenCalledWith({
|
||||
deviceIdentifier: 'iPhone 15',
|
||||
env: expect.any(Object),
|
||||
});
|
||||
});
|
||||
|
||||
it('enables accessibility settings before starting the main device and every clone when requested', async () => {
|
||||
mockedUtils.startAsync
|
||||
.mockResolvedValueOnce({ udid: 'base' as any })
|
||||
.mockResolvedValueOnce({ udid: 'clone-1' as any })
|
||||
.mockResolvedValueOnce({ udid: 'clone-2' as any });
|
||||
|
||||
await createStep({
|
||||
device_identifier: 'iPhone 15',
|
||||
count: 2,
|
||||
enable_accessibility_settings: true,
|
||||
}).executeAsync();
|
||||
|
||||
expect(mockedUtils.enableAccessibilitySettingsAsync).toHaveBeenCalledWith({
|
||||
deviceIdentifier: 'iPhone 15',
|
||||
env: expect.any(Object),
|
||||
});
|
||||
expect(mockedUtils.enableAccessibilitySettingsAsync).toHaveBeenCalledWith({
|
||||
deviceIdentifier: 'eas-simulator-1',
|
||||
env: expect.any(Object),
|
||||
});
|
||||
expect(mockedUtils.enableAccessibilitySettingsAsync).toHaveBeenCalledWith({
|
||||
deviceIdentifier: 'eas-simulator-2',
|
||||
env: expect.any(Object),
|
||||
});
|
||||
for (const [callIndex] of mockedUtils.startAsync.mock.calls.entries()) {
|
||||
const enableCallOrder =
|
||||
mockedUtils.enableAccessibilitySettingsAsync.mock.invocationCallOrder[callIndex];
|
||||
const startCallOrder = mockedUtils.startAsync.mock.invocationCallOrder[callIndex];
|
||||
expect(enableCallOrder).toBeLessThan(startCallOrder);
|
||||
}
|
||||
});
|
||||
|
||||
it('disables apsd on the main device and every clone', async () => {
|
||||
mockedUtils.startAsync
|
||||
.mockResolvedValueOnce({ udid: 'base' as any })
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { asyncResult } from '@expo/results';
|
||||
import { BuildFunction, BuildStepInput, BuildStepInputValueTypeName } from '@expo/steps';
|
||||
|
||||
import { Sentry } from '../../sentry';
|
||||
import { retryOnDNSFailure } from '../../utils/retryOnDNSFailure';
|
||||
|
||||
export function createSubmissionEntityFunction(): BuildFunction {
|
||||
@@ -54,18 +55,42 @@ export function createSubmissionEntityFunction(): BuildFunction {
|
||||
const robotAccessToken = stepsCtx.global.staticContext.job.secrets?.robotAccessToken;
|
||||
if (!robotAccessToken) {
|
||||
stepsCtx.logger.error('Failed to create submission entity: no robot access token found');
|
||||
Sentry.capture('Failed to create submission entity: missing robot access token');
|
||||
return;
|
||||
}
|
||||
|
||||
const buildId = inputs.build_id.value;
|
||||
if (!buildId) {
|
||||
stepsCtx.logger.error('Failed to create submission entity: no build ID provided');
|
||||
Sentry.capture('Failed to create submission entity: missing build ID', {
|
||||
extras: {
|
||||
buildId,
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const workflowJobId = stepsCtx.global.env.__WORKFLOW_JOB_ID;
|
||||
if (!workflowJobId) {
|
||||
stepsCtx.logger.error('Failed to create submission entity: no workflow job ID found');
|
||||
Sentry.capture('Failed to create submission entity: missing workflow job ID', {
|
||||
extras: {
|
||||
buildId,
|
||||
workflowJobId,
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const expoApiServerURL = stepsCtx.global.staticContext.expoApiServerURL;
|
||||
if (!expoApiServerURL) {
|
||||
stepsCtx.logger.error('Failed to create submission entity: no Expo API server URL found');
|
||||
Sentry.capture('Failed to create submission entity: missing Expo API server URL', {
|
||||
extras: {
|
||||
buildId,
|
||||
workflowJobId,
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -83,7 +108,7 @@ export function createSubmissionEntityFunction(): BuildFunction {
|
||||
|
||||
try {
|
||||
const response = await retryOnDNSFailure(fetch)(
|
||||
new URL('/v2/app-store-submissions/', stepsCtx.global.staticContext.expoApiServerURL),
|
||||
new URL('/v2/app-store-submissions/', expoApiServerURL),
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UserError } from '@expo/eas-build-job';
|
||||
import { SystemError } from '@expo/eas-build-job';
|
||||
import { bunyan } from '@expo/logger';
|
||||
import { asyncResult } from '@expo/results';
|
||||
import {
|
||||
@@ -56,18 +56,23 @@ export function createDownloadArtifactFunction(): BuildFunction {
|
||||
const interpolationContext = stepsCtx.global.getInterpolationContext();
|
||||
|
||||
if (!('workflow' in interpolationContext)) {
|
||||
throw new UserError(
|
||||
'EAS_DOWNLOAD_ARTIFACT_NO_WORKFLOW',
|
||||
'No workflow found in the interpolation context.'
|
||||
);
|
||||
throw new SystemError('No workflow found in the interpolation context.', {
|
||||
trackingCode: 'EAS_DOWNLOAD_ARTIFACT_NO_WORKFLOW',
|
||||
});
|
||||
}
|
||||
|
||||
const robotAccessToken = stepsCtx.global.staticContext.job.secrets?.robotAccessToken;
|
||||
if (!robotAccessToken) {
|
||||
throw new UserError(
|
||||
'EAS_DOWNLOAD_ARTIFACT_NO_ROBOT_ACCESS_TOKEN',
|
||||
'No robot access token found in the job secrets.'
|
||||
);
|
||||
throw new SystemError('No robot access token found in the job secrets.', {
|
||||
trackingCode: 'EAS_DOWNLOAD_ARTIFACT_NO_ROBOT_ACCESS_TOKEN',
|
||||
});
|
||||
}
|
||||
|
||||
const expoApiServerURL = stepsCtx.global.staticContext.expoApiServerURL;
|
||||
if (!expoApiServerURL) {
|
||||
throw new SystemError('Missing Expo API server URL.', {
|
||||
trackingCode: 'EAS_DOWNLOAD_ARTIFACT_NO_EXPO_API_SERVER_URL',
|
||||
});
|
||||
}
|
||||
|
||||
const workflowRunId = interpolationContext.workflow.id;
|
||||
@@ -82,7 +87,7 @@ export function createDownloadArtifactFunction(): BuildFunction {
|
||||
const { artifactPath } = await downloadArtifactAsync({
|
||||
logger,
|
||||
workflowRunId,
|
||||
expoApiServerURL: stepsCtx.global.staticContext.expoApiServerURL,
|
||||
expoApiServerURL,
|
||||
robotAccessToken,
|
||||
params,
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { BuildFunction, BuildStepContext, BuildStepEnv } from '@expo/steps';
|
||||
import path from 'path';
|
||||
|
||||
import { installDependenciesAsync } from '../../common/installDependencies';
|
||||
import { installDependenciesWithNpmCacheFallbackAsync } from '../../common/installDependencies';
|
||||
import {
|
||||
findPackagerRootDir,
|
||||
getPackageVersionFromPackageJson,
|
||||
@@ -63,7 +63,7 @@ export async function installNodeModules(
|
||||
packageName: 'react-native',
|
||||
});
|
||||
|
||||
const { spawnPromise } = await installDependenciesAsync({
|
||||
await installDependenciesWithNpmCacheFallbackAsync({
|
||||
packageManager,
|
||||
env,
|
||||
logger: stepCtx.logger,
|
||||
@@ -74,5 +74,4 @@ export async function installNodeModules(
|
||||
reactNativeVersion,
|
||||
}),
|
||||
});
|
||||
await spawnPromise;
|
||||
}
|
||||
@@ -42,11 +42,6 @@ export function createRepackBuildFunction(): BuildFunction {
|
||||
required: false,
|
||||
allowedValueTypeName: BuildStepInputValueTypeName.STRING,
|
||||
}),
|
||||
BuildStepInput.createProvider({
|
||||
id: 'output_path',
|
||||
allowedValueTypeName: BuildStepInputValueTypeName.STRING,
|
||||
required: false,
|
||||
}),
|
||||
BuildStepInput.createProvider({
|
||||
id: 'embed_bundle_assets',
|
||||
allowedValueTypeName: BuildStepInputValueTypeName.BOOLEAN,
|
||||
@@ -109,9 +104,10 @@ export function createRepackBuildFunction(): BuildFunction {
|
||||
stepsCtx.logger.info(`Created temporary working directory: ${workingDirectory}`);
|
||||
|
||||
const sourceAppPath = inputs.source_app_path.value as string;
|
||||
const outputPath =
|
||||
(inputs.output_path.value as string) ??
|
||||
path.join(tmpDir, `repacked-${randomUUID()}${path.extname(sourceAppPath)}`);
|
||||
const outputPath = createOutputPath({
|
||||
sourceAppPath,
|
||||
tmpDir,
|
||||
});
|
||||
const exportEmbedOptions = inputs.embed_bundle_assets.value
|
||||
? {
|
||||
sourcemapOutput: undefined,
|
||||
@@ -202,6 +198,21 @@ export function createRepackBuildFunction(): BuildFunction {
|
||||
});
|
||||
}
|
||||
|
||||
function createOutputPath({
|
||||
sourceAppPath,
|
||||
tmpDir,
|
||||
}: {
|
||||
sourceAppPath: string;
|
||||
tmpDir: string;
|
||||
}): string {
|
||||
const outputPath = path.join(tmpDir, `repacked-${randomUUID()}${path.extname(sourceAppPath)}`);
|
||||
const extension = path.extname(outputPath);
|
||||
if (extension.toLowerCase() !== '.aab') {
|
||||
return outputPath;
|
||||
}
|
||||
return `${outputPath.slice(0, -extension.length)}.apk`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install `@expo/repack-app` in a sandbox directory and import it.
|
||||
*/
|
||||
|
||||
@@ -69,6 +69,10 @@ export function createRestoreCacheFunction(): BuildFunction {
|
||||
.filter(key => key !== '');
|
||||
|
||||
const jobId = nullthrows(env.EAS_BUILD_ID, 'EAS_BUILD_ID is not set');
|
||||
const expoApiServerURL = nullthrows(
|
||||
stepsCtx.global.staticContext.expoApiServerURL,
|
||||
'expoApiServerURL is not set'
|
||||
);
|
||||
const robotAccessToken = nullthrows(
|
||||
stepsCtx.global.staticContext.job.secrets?.robotAccessToken,
|
||||
'robotAccessToken is not set'
|
||||
@@ -77,7 +81,7 @@ export function createRestoreCacheFunction(): BuildFunction {
|
||||
const { archivePath, matchedKey } = await downloadCacheAsync({
|
||||
logger,
|
||||
jobId,
|
||||
expoApiServerURL: stepsCtx.global.staticContext.expoApiServerURL,
|
||||
expoApiServerURL,
|
||||
robotAccessToken,
|
||||
paths,
|
||||
key,
|
||||
|
||||
@@ -43,6 +43,10 @@ export function createSaveCacheFunction(): BuildFunction {
|
||||
.filter(path => path.length > 0);
|
||||
const key = z.string().parse(inputs.key.value);
|
||||
const jobId = nullthrows(env.EAS_BUILD_ID, 'EAS_BUILD_ID is not set');
|
||||
const expoApiServerURL = nullthrows(
|
||||
stepsCtx.global.staticContext.expoApiServerURL,
|
||||
'expoApiServerURL is not set'
|
||||
);
|
||||
const robotAccessToken = nullthrows(
|
||||
stepsCtx.global.staticContext.job.secrets?.robotAccessToken,
|
||||
'robotAccessToken is not set'
|
||||
@@ -61,7 +65,7 @@ export function createSaveCacheFunction(): BuildFunction {
|
||||
await uploadPublicCacheAsync({
|
||||
logger,
|
||||
jobId,
|
||||
expoApiServerURL: stepsCtx.global.staticContext.expoApiServerURL,
|
||||
expoApiServerURL,
|
||||
robotAccessToken,
|
||||
archivePath,
|
||||
key,
|
||||
@@ -73,7 +77,7 @@ export function createSaveCacheFunction(): BuildFunction {
|
||||
await uploadCacheAsync({
|
||||
logger,
|
||||
jobId,
|
||||
expoApiServerURL: stepsCtx.global.staticContext.expoApiServerURL,
|
||||
expoApiServerURL,
|
||||
robotAccessToken,
|
||||
archivePath,
|
||||
key,
|
||||
|
||||
@@ -31,6 +31,12 @@ export function createStartIosSimulatorBuildFunction(): BuildFunction {
|
||||
defaultValue: 1,
|
||||
allowedValueTypeName: BuildStepInputValueTypeName.NUMBER,
|
||||
}),
|
||||
BuildStepInput.createProvider({
|
||||
id: 'enable_accessibility_settings',
|
||||
required: false,
|
||||
defaultValue: false,
|
||||
allowedValueTypeName: BuildStepInputValueTypeName.BOOLEAN,
|
||||
}),
|
||||
],
|
||||
fn: async ({ logger }, { inputs, env }) => {
|
||||
try {
|
||||
@@ -55,11 +61,18 @@ export function createStartIosSimulatorBuildFunction(): BuildFunction {
|
||||
| undefined;
|
||||
const originalDeviceIdentifier =
|
||||
deviceIdentifierInput ?? (await findMostGenericIphoneUuidAsync({ env }));
|
||||
const enableAccessibilitySettings = Boolean(inputs.enable_accessibility_settings.value);
|
||||
|
||||
if (!originalDeviceIdentifier) {
|
||||
throw new Error('Could not find an iPhone among available simulator devices.');
|
||||
}
|
||||
|
||||
if (enableAccessibilitySettings) {
|
||||
await IosSimulatorUtils.enableAccessibilitySettingsAsync({
|
||||
deviceIdentifier: originalDeviceIdentifier,
|
||||
env,
|
||||
});
|
||||
}
|
||||
const { udid } = await IosSimulatorUtils.startAsync({
|
||||
deviceIdentifier: originalDeviceIdentifier,
|
||||
env,
|
||||
@@ -97,6 +110,12 @@ export function createStartIosSimulatorBuildFunction(): BuildFunction {
|
||||
env,
|
||||
});
|
||||
|
||||
if (enableAccessibilitySettings) {
|
||||
await IosSimulatorUtils.enableAccessibilitySettingsAsync({
|
||||
deviceIdentifier: cloneDeviceName,
|
||||
env,
|
||||
});
|
||||
}
|
||||
const { udid: cloneUdid } = await IosSimulatorUtils.startAsync({
|
||||
deviceIdentifier: cloneDeviceName,
|
||||
env,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ExpoError, SystemError, UserError } from '@expo/eas-build-job';
|
||||
import spawn, { SpawnPromise, SpawnResult } from '@expo/turtle-spawn';
|
||||
import fs from 'node:fs';
|
||||
import os from 'node:os';
|
||||
@@ -92,6 +93,67 @@ export namespace IosSimulatorUtils {
|
||||
});
|
||||
}
|
||||
|
||||
export async function enableAccessibilitySettingsAsync({
|
||||
deviceIdentifier,
|
||||
env,
|
||||
}: {
|
||||
deviceIdentifier: IosSimulatorUuid | IosSimulatorName;
|
||||
env: NodeJS.ProcessEnv;
|
||||
}): Promise<void> {
|
||||
try {
|
||||
const devices = await getAvailableDevicesAsync({ env, filter: 'available' });
|
||||
const device = devices.find(
|
||||
device =>
|
||||
device.isAvailable &&
|
||||
(device.udid === deviceIdentifier || device.name === deviceIdentifier)
|
||||
);
|
||||
if (!device) {
|
||||
throw new UserError(
|
||||
'EAS_IOS_SIMULATOR_NOT_FOUND',
|
||||
`Failed to find available iOS Simulator "${deviceIdentifier}" to update accessibility settings.`
|
||||
);
|
||||
}
|
||||
if (device.state !== 'Shutdown') {
|
||||
throw new UserError(
|
||||
'EAS_IOS_SIMULATOR_NOT_SHUTDOWN',
|
||||
`Expected iOS Simulator "${deviceIdentifier}" to be shutdown before updating accessibility settings, but it is ${device.state}.`
|
||||
);
|
||||
}
|
||||
|
||||
const plistPath = path.join(
|
||||
device.dataPath,
|
||||
'Library',
|
||||
'Preferences',
|
||||
'com.apple.Accessibility.plist'
|
||||
);
|
||||
await fs.promises.mkdir(path.dirname(plistPath), { recursive: true });
|
||||
|
||||
const plistExists = await fs.promises
|
||||
.access(plistPath)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
if (!plistExists) {
|
||||
await spawn('plutil', ['-create', 'binary1', plistPath], { env });
|
||||
}
|
||||
|
||||
for (const key of [
|
||||
'AutomationEnabled',
|
||||
'IgnoreAXServerEntitlements',
|
||||
'AccessibilityEnabled',
|
||||
'ApplicationAccessibilityEnabled',
|
||||
]) {
|
||||
await spawn('plutil', ['-replace', key, '-bool', 'true', plistPath], { env });
|
||||
}
|
||||
} catch (err) {
|
||||
if (err instanceof ExpoError) {
|
||||
throw err;
|
||||
}
|
||||
throw new SystemError('Failed to update iOS Simulator accessibility settings.', {
|
||||
cause: err,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function startAsync({
|
||||
deviceIdentifier,
|
||||
env,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { SystemError, UserError } from '@expo/eas-build-job';
|
||||
import spawn from '@expo/turtle-spawn';
|
||||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
@@ -18,9 +19,143 @@ const mockedSpawn = jest.mocked(spawn);
|
||||
|
||||
describe('IosSimulatorUtils', () => {
|
||||
beforeEach(() => {
|
||||
mockedSpawn.mockReset();
|
||||
mockedSpawn.mockResolvedValue({ stdout: '', stderr: '' } as any);
|
||||
});
|
||||
|
||||
describe(IosSimulatorUtils.startAsync, () => {
|
||||
it('waits for boot completion without writing accessibility prefs', async () => {
|
||||
mockedSpawn.mockImplementation((async (command: string, args: string[]) => {
|
||||
if (command === 'xcrun' && args.join(' ') === 'simctl bootstatus test-udid -b') {
|
||||
return {
|
||||
stdout: 'Monitoring boot status for iPhone 15 (test-udid).\n',
|
||||
stderr: '',
|
||||
} as any;
|
||||
}
|
||||
return { stdout: '', stderr: '' } as any;
|
||||
}) as any);
|
||||
|
||||
await IosSimulatorUtils.startAsync({
|
||||
deviceIdentifier: 'test-udid' as any,
|
||||
env: process.env,
|
||||
});
|
||||
|
||||
expect(mockedSpawn).not.toHaveBeenCalledWith(
|
||||
'xcrun',
|
||||
['simctl', 'list', 'devices', '--json', '--no-escape-slashes', 'test-udid'],
|
||||
expect.anything()
|
||||
);
|
||||
expect(mockedSpawn).not.toHaveBeenCalledWith('plutil', expect.anything(), expect.anything());
|
||||
});
|
||||
});
|
||||
|
||||
describe(IosSimulatorUtils.enableAccessibilitySettingsAsync, () => {
|
||||
function device(overrides: Record<string, unknown> = {}) {
|
||||
return {
|
||||
dataPath: '/tmp/eas-test-simulator-data',
|
||||
dataPathSize: 1,
|
||||
logPath: '/tmp/eas-test-simulator-logs',
|
||||
udid: 'test-udid',
|
||||
isAvailable: true,
|
||||
deviceTypeIdentifier: 'com.apple.CoreSimulator.SimDeviceType.iPhone-15',
|
||||
state: 'Shutdown',
|
||||
name: 'iPhone 15',
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function mockAvailableDevices(devices: Record<string, unknown>[]) {
|
||||
mockedSpawn.mockImplementation((async (command: string, args: string[]) => {
|
||||
if (
|
||||
command === 'xcrun' &&
|
||||
args.join(' ') === 'simctl list devices --json --no-escape-slashes available'
|
||||
) {
|
||||
return {
|
||||
stdout: JSON.stringify({
|
||||
devices: {
|
||||
'com.apple.CoreSimulator.SimRuntime.iOS-18-0': devices,
|
||||
},
|
||||
}),
|
||||
stderr: '',
|
||||
} as any;
|
||||
}
|
||||
return { stdout: '', stderr: '' } as any;
|
||||
}) as any);
|
||||
}
|
||||
|
||||
it('writes accessibility prefs for an exact shutdown simulator match', async () => {
|
||||
mockAvailableDevices([
|
||||
device({
|
||||
udid: 'test-udid-pro',
|
||||
name: 'iPhone 17 Pro',
|
||||
dataPath: '/tmp/eas-test-simulator-data-pro',
|
||||
}),
|
||||
device({ name: 'iPhone 17' }),
|
||||
]);
|
||||
|
||||
await expect(
|
||||
IosSimulatorUtils.enableAccessibilitySettingsAsync({
|
||||
deviceIdentifier: 'iPhone 17' as any,
|
||||
env: process.env,
|
||||
})
|
||||
).resolves.toBeUndefined();
|
||||
|
||||
for (const key of [
|
||||
'AutomationEnabled',
|
||||
'IgnoreAXServerEntitlements',
|
||||
'AccessibilityEnabled',
|
||||
'ApplicationAccessibilityEnabled',
|
||||
]) {
|
||||
expect(mockedSpawn).toHaveBeenCalledWith(
|
||||
'plutil',
|
||||
[
|
||||
'-replace',
|
||||
key,
|
||||
'-bool',
|
||||
'true',
|
||||
'/tmp/eas-test-simulator-data/Library/Preferences/com.apple.Accessibility.plist',
|
||||
],
|
||||
{ env: process.env }
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it('throws UserError when no available simulator exactly matches the identifier', async () => {
|
||||
mockAvailableDevices([device({ name: 'iPhone 17 Pro' })]);
|
||||
|
||||
await expect(
|
||||
IosSimulatorUtils.enableAccessibilitySettingsAsync({
|
||||
deviceIdentifier: 'iPhone 17' as any,
|
||||
env: process.env,
|
||||
})
|
||||
).rejects.toThrow(UserError);
|
||||
|
||||
expect(mockedSpawn).not.toHaveBeenCalledWith('plutil', expect.anything(), expect.anything());
|
||||
});
|
||||
|
||||
it('throws UserError when the matched simulator is already booted', async () => {
|
||||
mockAvailableDevices([device({ state: 'Booted' })]);
|
||||
|
||||
await expect(
|
||||
IosSimulatorUtils.enableAccessibilitySettingsAsync({
|
||||
deviceIdentifier: 'test-udid' as any,
|
||||
env: process.env,
|
||||
})
|
||||
).rejects.toThrow(UserError);
|
||||
});
|
||||
|
||||
it('throws SystemError when pre-boot accessibility setup fails', async () => {
|
||||
mockedSpawn.mockRejectedValue(new Error('Failed to list simulators'));
|
||||
|
||||
await expect(
|
||||
IosSimulatorUtils.enableAccessibilitySettingsAsync({
|
||||
deviceIdentifier: 'test-udid' as any,
|
||||
env: process.env,
|
||||
})
|
||||
).rejects.toThrow(SystemError);
|
||||
});
|
||||
});
|
||||
|
||||
describe(IosSimulatorUtils.waitForReadyAsync, () => {
|
||||
it('takes the readiness screenshot into a writable temp file, not /dev/null', async () => {
|
||||
await IosSimulatorUtils.waitForReadyAsync({
|
||||
|
||||
@@ -104,4 +104,33 @@ describe(expoUpdates.configureExpoUpdatesIfInstalledAsync, () => {
|
||||
expect(iosSetChannelNativelyAsync).toBeCalledTimes(1);
|
||||
expect(getExpoUpdatesPackageVersionIfInstalledAsync).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it('does not fail on missing EAS_BUILD_ID when logging fingerprint diffs', async () => {
|
||||
jest.mocked(getExpoUpdatesPackageVersionIfInstalledAsync).mockResolvedValue('0.18.0');
|
||||
|
||||
const warn = jest.fn();
|
||||
const managedCtx: BuildContext<BuildJob> = {
|
||||
appConfig: {},
|
||||
env: {},
|
||||
job: {
|
||||
platform: Platform.IOS,
|
||||
},
|
||||
logger: { warn },
|
||||
metadata: {
|
||||
runtimeVersion: 'runtime-version-from-local-machine',
|
||||
},
|
||||
getReactNativeProjectDirectory: () => '/app',
|
||||
} as any;
|
||||
|
||||
await expect(
|
||||
expoUpdates.configureExpoUpdatesIfInstalledAsync(managedCtx, {
|
||||
resolvedRuntimeVersion: 'runtime-version-from-eas-build',
|
||||
resolvedFingerprintSources: [],
|
||||
})
|
||||
).rejects.toThrow(
|
||||
'Runtime version calculated on local machine not equal to runtime version calculated during build.'
|
||||
);
|
||||
|
||||
expect(warn).toHaveBeenCalledWith('Skipping fingerprint diff because EAS_BUILD_ID is not set');
|
||||
});
|
||||
});
|
||||
@@ -243,6 +243,12 @@ async function logDiffFingerprints({
|
||||
ctx: BuildContext<BuildJob>;
|
||||
}): Promise<void> {
|
||||
const { resolvedRuntimeVersion, resolvedFingerprintSources } = resolvedRuntime;
|
||||
const buildId = ctx.env.EAS_BUILD_ID;
|
||||
|
||||
if (!buildId) {
|
||||
ctx.logger.warn('Skipping fingerprint diff because EAS_BUILD_ID is not set');
|
||||
return;
|
||||
}
|
||||
|
||||
const fingerprintInfo = await ctx.graphqlClient
|
||||
.query(
|
||||
@@ -257,7 +263,7 @@ async function logDiffFingerprints({
|
||||
}
|
||||
}
|
||||
`),
|
||||
{ id: ctx.env.EAS_BUILD_ID }
|
||||
{ id: buildId }
|
||||
)
|
||||
.toPromise();
|
||||
|
||||
|
||||
@@ -1,4 +1,18 @@
|
||||
import { StaticWorkflowInterpolationContextZ } from '../common';
|
||||
import { EnvSchema, StaticWorkflowInterpolationContextZ } from '../common';
|
||||
|
||||
describe('EnvSchema', () => {
|
||||
it('accepts explicit undefined values', () => {
|
||||
const env = {
|
||||
DEFINED_ENV: 'value',
|
||||
UNDEFINED_ENV: undefined,
|
||||
};
|
||||
|
||||
const { value, error } = EnvSchema.validate(env);
|
||||
|
||||
expect(error).toBeUndefined();
|
||||
expect(value).toEqual(env);
|
||||
});
|
||||
});
|
||||
|
||||
describe('StaticWorkflowInterpolationContextZ', () => {
|
||||
it('accepts app and account context', () => {
|
||||
|
||||
@@ -115,8 +115,8 @@ export const ArchiveSourceSchemaZ = z.discriminatedUnion('type', [
|
||||
}),
|
||||
]);
|
||||
|
||||
export type Env = Record<string, string>;
|
||||
export const EnvSchema = Joi.object().pattern(Joi.string(), Joi.string());
|
||||
export type Env = Record<string, string | undefined>;
|
||||
export const EnvSchema = Joi.object().pattern(Joi.string(), Joi.string().optional());
|
||||
|
||||
export type EnvironmentSecret = {
|
||||
name: string;
|
||||
|
||||
@@ -11,7 +11,7 @@ type StaticJobOnlyInterpolationContext = {
|
||||
outputs: Record<string, string | undefined>;
|
||||
}
|
||||
>;
|
||||
expoApiServerURL: string;
|
||||
expoApiServerURL: string | undefined;
|
||||
};
|
||||
|
||||
export type StaticJobInterpolationContext =
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
"copy-new-templates": "rimraf build/commandUtils/new/templates && mkdir -p build/commandUtils/new && cp -r src/commandUtils/new/templates build/commandUtils/new"
|
||||
},
|
||||
"dependencies": {
|
||||
"@expo/apple-utils": "2.1.19",
|
||||
"@expo/apple-utils": "2.1.22",
|
||||
"@expo/code-signing-certificates": "0.0.5",
|
||||
"@expo/config": "55.0.10",
|
||||
"@expo/config-plugins": "55.0.7",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ExpoConfig } from '@expo/config';
|
||||
import { Platform, Workflow } from '@expo/eas-build-job';
|
||||
import { Env, Platform, Workflow } from '@expo/eas-build-job';
|
||||
import { BuildProfile, EasJson } from '@expo/eas-json';
|
||||
import { LoggerLevel } from '@expo/logger';
|
||||
import { NodePackageManager } from '@expo/package-manager';
|
||||
@@ -65,5 +65,5 @@ export interface BuildContext<T extends Platform> {
|
||||
loggerLevel?: LoggerLevel;
|
||||
isVerboseLoggingEnabled: boolean;
|
||||
whatToTest?: string;
|
||||
env: Record<string, string>;
|
||||
env: Env;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Platform } from '@expo/eas-build-job';
|
||||
import { Env, Platform } from '@expo/eas-build-job';
|
||||
import { BuildProfile, EasJson, ResourceClass } from '@expo/eas-json';
|
||||
import JsonFile from '@expo/json-file';
|
||||
import { LoggerLevel } from '@expo/logger';
|
||||
@@ -69,7 +69,7 @@ export async function createBuildContextAsync<T extends Platform>({
|
||||
refreshAdHocProvisioningProfile?: boolean;
|
||||
isVerboseLoggingEnabled: boolean;
|
||||
whatToTest?: string;
|
||||
env: Record<string, string>;
|
||||
env: Env;
|
||||
}): Promise<BuildContext<T>> {
|
||||
const { exp, projectId } = await getDynamicPrivateProjectConfigAsync({
|
||||
env,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Job, Metadata, version } from '@expo/eas-build-job';
|
||||
import { Env, Job, Metadata, version } from '@expo/eas-build-job';
|
||||
import spawnAsync from '@expo/spawn-async';
|
||||
import { ChildProcess } from 'child_process';
|
||||
import semver from 'semver';
|
||||
@@ -42,7 +42,7 @@ export async function runLocalBuildAsync(
|
||||
job: Job,
|
||||
metadata: Metadata,
|
||||
options: LocalBuildOptions,
|
||||
env: Record<string, string>
|
||||
env: Env
|
||||
): Promise<void> {
|
||||
const { command, args } = await getCommandAndArgsAsync(job, metadata);
|
||||
let spinner;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Platform, Workflow } from '@expo/eas-build-job';
|
||||
import { Env, Platform, Workflow } from '@expo/eas-build-job';
|
||||
|
||||
import { createFingerprintAsync } from './cli';
|
||||
import { Fingerprint } from './types';
|
||||
@@ -16,7 +16,7 @@ export async function getFingerprintInfoFromLocalProjectForPlatformsAsync(
|
||||
projectId: string,
|
||||
vcsClient: Client,
|
||||
platforms: AppPlatform[],
|
||||
{ env }: { env?: Record<string, string> } = {}
|
||||
{ env }: { env?: Env } = {}
|
||||
): Promise<Fingerprint> {
|
||||
const workflows = await resolveWorkflowPerPlatformAsync(projectDir, vcsClient);
|
||||
const optionsFromWorkflow = getFingerprintOptionsFromWorkflow(platforms, workflows);
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import { testTarget } from '../../../credentials/__tests__/fixtures-ios';
|
||||
import { ApplePlatform } from '../../../credentials/ios/appstore/constants';
|
||||
import { Target } from '../../../credentials/ios/types';
|
||||
import { getApplePlatformFromDeviceFamily, getApplePlatformFromSdkRoot } from '../target';
|
||||
import {
|
||||
getApplePlatformFromDeviceFamily,
|
||||
getApplePlatformFromSdkRoot,
|
||||
getApplePlatformFromTarget,
|
||||
getManagedTvBuildSettings,
|
||||
} from '../target';
|
||||
|
||||
function getApplePlatformWithSdkRoot(sdkRoot: string): ApplePlatform | null {
|
||||
const target = {
|
||||
@@ -56,3 +61,64 @@ describe(getApplePlatformFromDeviceFamily, () => {
|
||||
expect(getApplePlatformWithDeviceFamily('ilovecats')).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe(getManagedTvBuildSettings, () => {
|
||||
const originalExpoTv = process.env.EXPO_TV;
|
||||
afterEach(() => {
|
||||
if (originalExpoTv === undefined) {
|
||||
delete process.env.EXPO_TV;
|
||||
} else {
|
||||
process.env.EXPO_TV = originalExpoTv;
|
||||
}
|
||||
});
|
||||
|
||||
test('returns undefined when EXPO_TV is not set in env or process.env', () => {
|
||||
delete process.env.EXPO_TV;
|
||||
expect(getManagedTvBuildSettings(undefined)).toBeUndefined();
|
||||
expect(getManagedTvBuildSettings({})).toBeUndefined();
|
||||
expect(getManagedTvBuildSettings({ EXPO_TV: '' })).toBeUndefined();
|
||||
expect(getManagedTvBuildSettings({ EXPO_TV: '0' })).toBeUndefined();
|
||||
expect(getManagedTvBuildSettings({ EXPO_TV: 'false' })).toBeUndefined();
|
||||
expect(getManagedTvBuildSettings({ EXPO_TV: 'no' })).toBeUndefined();
|
||||
});
|
||||
|
||||
test('returns TARGETED_DEVICE_FAMILY=3 when EXPO_TV is truthy in the env parameter (eas.json case)', () => {
|
||||
delete process.env.EXPO_TV;
|
||||
for (const value of ['1', 'true', 'yes', 'TRUE', 'Yes']) {
|
||||
expect(getManagedTvBuildSettings({ EXPO_TV: value })).toEqual({
|
||||
TARGETED_DEVICE_FAMILY: '3',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test('falls back to process.env when env is missing EXPO_TV (shell case)', () => {
|
||||
process.env.EXPO_TV = '1';
|
||||
expect(getManagedTvBuildSettings(undefined)).toEqual({ TARGETED_DEVICE_FAMILY: '3' });
|
||||
expect(getManagedTvBuildSettings({})).toEqual({ TARGETED_DEVICE_FAMILY: '3' });
|
||||
});
|
||||
|
||||
test('env-parameter EXPO_TV takes precedence over process.env (eas.json overrides shell)', () => {
|
||||
process.env.EXPO_TV = '0';
|
||||
expect(getManagedTvBuildSettings({ EXPO_TV: '1' })).toEqual({
|
||||
TARGETED_DEVICE_FAMILY: '3',
|
||||
});
|
||||
|
||||
process.env.EXPO_TV = '1';
|
||||
expect(getManagedTvBuildSettings({ EXPO_TV: '0' })).toBeUndefined();
|
||||
});
|
||||
|
||||
test('feeds into getApplePlatformFromTarget so managed tvOS targets resolve to TV_OS', () => {
|
||||
delete process.env.EXPO_TV;
|
||||
const target: Target = {
|
||||
...testTarget,
|
||||
buildSettings: getManagedTvBuildSettings({ EXPO_TV: '1' }),
|
||||
};
|
||||
expect(getApplePlatformFromTarget(target)).toBe(ApplePlatform.TV_OS);
|
||||
|
||||
const iosTarget: Target = {
|
||||
...testTarget,
|
||||
buildSettings: getManagedTvBuildSettings({}),
|
||||
};
|
||||
expect(getApplePlatformFromTarget(iosTarget)).toBe(ApplePlatform.IOS);
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ExportedConfig, IOSConfig, compileModsAsync } from '@expo/config-plugins';
|
||||
import { Env } from '@expo/eas-build-job';
|
||||
import { JSONObject } from '@expo/json-file';
|
||||
import { getPrebuildConfigAsync } from '@expo/prebuild-config';
|
||||
|
||||
@@ -17,7 +18,7 @@ interface Target {
|
||||
|
||||
export async function getManagedApplicationTargetEntitlementsAsync(
|
||||
projectDir: string,
|
||||
env: Record<string, string>,
|
||||
env: Env,
|
||||
vcsClient: Client
|
||||
): Promise<JSONObject> {
|
||||
let expoConfigError: any;
|
||||
@@ -95,7 +96,7 @@ export async function getManagedApplicationTargetEntitlementsAsync(
|
||||
|
||||
async function resolveManagedApplicationTargetEntitlementsWithBundledConfigAsync(
|
||||
projectDir: string,
|
||||
env: Record<string, string>,
|
||||
env: Env,
|
||||
vcsClient: Client
|
||||
): Promise<JSONObject> {
|
||||
const originalProcessEnv = process.env;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ExpoConfig } from '@expo/config';
|
||||
import { IOSConfig, XcodeProject } from '@expo/config-plugins';
|
||||
import { Platform, Workflow } from '@expo/eas-build-job';
|
||||
import { Env, Platform, Workflow } from '@expo/eas-build-job';
|
||||
import { JSONObject } from '@expo/json-file';
|
||||
import Joi from 'joi';
|
||||
import type { XCBuildConfiguration } from 'xcode';
|
||||
@@ -26,7 +26,7 @@ interface UserDefinedTarget {
|
||||
interface ResolveTargetOptions {
|
||||
projectDir: string;
|
||||
exp: ExpoConfig;
|
||||
env?: Record<string, string>;
|
||||
env?: Env;
|
||||
xcodeBuildContext: XcodeBuildContext;
|
||||
vcsClient: Client;
|
||||
}
|
||||
@@ -40,6 +40,28 @@ const AppExtensionsConfigSchema = Joi.array().items(
|
||||
})
|
||||
);
|
||||
|
||||
/**
|
||||
* For managed projects we don't have an Xcode project to read build settings
|
||||
* from, but the @react-native-tvos/config-tv plugin signals a tvOS build via
|
||||
* the EXPO_TV environment variable. That variable can come from the build
|
||||
* profile's `env` in eas.json (the typical case, which flows in via `env`),
|
||||
* or from the shell process when the user runs `EXPO_TV=1 eas build ...`
|
||||
* (which is NOT included in the merged `env` upstream, so we read
|
||||
* `process.env` directly as a fallback). When set, synthesize
|
||||
* TARGETED_DEVICE_FAMILY=3 so getApplePlatformFromTarget (and every
|
||||
* Apple-portal flow downstream) picks TV_OS for these targets instead of
|
||||
* defaulting to IOS.
|
||||
*/
|
||||
export function getManagedTvBuildSettings(
|
||||
env: Env | undefined
|
||||
): Target['buildSettings'] | undefined {
|
||||
const expoTv = (env?.EXPO_TV ?? process.env.EXPO_TV ?? '').toString().toLowerCase();
|
||||
if (expoTv === '1' || expoTv === 'true' || expoTv === 'yes') {
|
||||
return { TARGETED_DEVICE_FAMILY: '3' };
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export async function resolveManagedProjectTargetsAsync({
|
||||
exp,
|
||||
projectDir,
|
||||
@@ -76,12 +98,14 @@ export async function resolveManagedProjectTargetsAsync({
|
||||
);
|
||||
}
|
||||
|
||||
const managedBuildSettings = getManagedTvBuildSettings(env);
|
||||
const extensionsTargets: Target[] = appExtensions.map(extension => ({
|
||||
targetName: extension.targetName,
|
||||
buildConfiguration,
|
||||
bundleIdentifier: extension.bundleIdentifier,
|
||||
parentBundleIdentifier: extension.parentBundleIdentifier ?? applicationTargetBundleIdentifier,
|
||||
entitlements: extension.entitlements ?? {},
|
||||
...(managedBuildSettings && { buildSettings: managedBuildSettings }),
|
||||
}));
|
||||
return [
|
||||
{
|
||||
@@ -89,6 +113,7 @@ export async function resolveManagedProjectTargetsAsync({
|
||||
bundleIdentifier: applicationTargetBundleIdentifier,
|
||||
buildConfiguration,
|
||||
entitlements: applicationTargetEntitlements,
|
||||
...(managedBuildSettings && { buildSettings: managedBuildSettings }),
|
||||
},
|
||||
...extensionsTargets,
|
||||
];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ExpoConfig } from '@expo/config';
|
||||
import { Platform } from '@expo/eas-build-job';
|
||||
import { Env, Platform } from '@expo/eas-build-job';
|
||||
import { SubmitProfile } from '@expo/eas-json';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
@@ -47,7 +47,7 @@ export interface SubmitArchiveFlags {
|
||||
export async function createSubmissionContextAsync<T extends Platform>(params: {
|
||||
archiveFlags: SubmitArchiveFlags;
|
||||
credentialsCtx?: CredentialsContext;
|
||||
env?: Record<string, string>;
|
||||
env?: Env;
|
||||
nonInteractive: boolean;
|
||||
isVerboseFastlaneEnabled: boolean;
|
||||
groups: string[] | undefined;
|
||||
|
||||
@@ -268,8 +268,8 @@ describe(getBuildEnv.name, () => {
|
||||
buildId: 'build-id',
|
||||
});
|
||||
|
||||
expect(env.NPM_CACHE_URL).toBe('https://npm.example');
|
||||
expect(env.NPM_CONFIG_REGISTRY).toBe('https://npm.example');
|
||||
expect(env.NPM_CACHE_URL).toBeUndefined();
|
||||
expect(env.NPM_CONFIG_REGISTRY).toBeUndefined();
|
||||
expect(env.EAS_BUILD_NPM_CACHE_URL).toBe('https://npm.example');
|
||||
expect(env.NVM_NODEJS_ORG_MIRROR).toBe('https://node.example');
|
||||
expect(env.EAS_BUILD_MAVEN_CACHE_URL).toBe('https://maven.example');
|
||||
|
||||
@@ -70,24 +70,30 @@ function printImageDescription(ctx: BuildContext<Job>): void {
|
||||
function printEnvs(ctx: BuildContext<Job>): void {
|
||||
const { logger, job } = ctx;
|
||||
const publicEnv: Record<string, string> = {};
|
||||
const secretEnv: Record<string, string> = {};
|
||||
// We don't expect environment secrets to be missing from ctx.env,
|
||||
// but if they do we want to see it in logs as "=undefined".
|
||||
const secretEnv: Record<string, string | undefined> = {};
|
||||
const instanceEnv: Record<string, string> = {};
|
||||
|
||||
// skip development and testing to avoid leaking local credentials from envs to bucket
|
||||
if (config.env !== Environment.DEVELOPMENT && config.env !== Environment.TEST) {
|
||||
Object.entries(ctx.env).forEach(([key, value]) => {
|
||||
instanceEnv[key] = value;
|
||||
if (value !== undefined) {
|
||||
instanceEnv[key] = value;
|
||||
}
|
||||
});
|
||||
}
|
||||
Object.entries(job.builderEnvironment?.env ?? ({} as Record<string, string>)).forEach(
|
||||
([key, value]) => {
|
||||
Object.entries(job.builderEnvironment?.env ?? {}).forEach(([key, value]) => {
|
||||
if (value !== undefined) {
|
||||
publicEnv[key] = value;
|
||||
delete instanceEnv[key];
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
job.secrets?.environmentSecrets?.forEach(({ name, type }) => {
|
||||
if (type === EnvironmentSecretType.FILE) {
|
||||
// ctx.env[name] for a FILE-typed environment secret
|
||||
// should be a path to the file.
|
||||
secretEnv[name] = ctx.env[name];
|
||||
} else {
|
||||
secretEnv[name] = '********';
|
||||
|
||||
@@ -36,14 +36,11 @@ export function getBuildEnv({
|
||||
setEnv(env, 'EAS_BUILD_RUNNER', 'eas-build');
|
||||
setEnv(env, 'EAS_BUILD_PLATFORM', job.platform);
|
||||
setEnv(env, 'EAS_CLI_SENTRY_DSN', config.sentry.dsn);
|
||||
// NPM_CACHE_URL is deprecated
|
||||
const npmCacheUrl = RuntimeSettings.getNpmCacheUrl();
|
||||
const nodeJsCacheUrl = RuntimeSettings.getNodeJsCacheUrl();
|
||||
const mavenCacheUrl = RuntimeSettings.getMavenCacheUrl();
|
||||
const cocoapodsCacheUrl = RuntimeSettings.getCocoapodsCacheUrl();
|
||||
|
||||
setEnv(env, 'NPM_CACHE_URL', npmCacheUrl);
|
||||
setEnv(env, 'NPM_CONFIG_REGISTRY', npmCacheUrl);
|
||||
setEnv(env, 'NVM_NODEJS_ORG_MIRROR', nodeJsCacheUrl);
|
||||
setEnv(env, 'EAS_BUILD_NPM_CACHE_URL', npmCacheUrl);
|
||||
setEnv(env, 'EAS_BUILD_PROFILE', metadata.buildProfile);
|
||||
|
||||
@@ -2847,12 +2847,12 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@expo/apple-utils@npm:2.1.19":
|
||||
version: 2.1.19
|
||||
resolution: "@expo/apple-utils@npm:2.1.19"
|
||||
"@expo/apple-utils@npm:2.1.22":
|
||||
version: 2.1.22
|
||||
resolution: "@expo/apple-utils@npm:2.1.22"
|
||||
bin:
|
||||
apple-utils: bin.js
|
||||
checksum: 10c0/42eb1038bd0906d53b37d830499c7a8ee7ec9f9b9ef4078ff898ca84cb5af1e6ac39d3a392818825151aa2ea237a44698f539b973936733350f314efff020858
|
||||
checksum: 10c0/19a5d21f80cde11e7502d7380b17bb4634568dcd243eb72ce741277dd71aab2b20168e44060143b10bfa01f0b03a6b8a2628b3cf3e5d697b12cf7f78a16d469a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -11154,7 +11154,7 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "eas-cli@workspace:packages/eas-cli"
|
||||
dependencies:
|
||||
"@expo/apple-utils": "npm:2.1.19"
|
||||
"@expo/apple-utils": "npm:2.1.22"
|
||||
"@expo/code-signing-certificates": "npm:0.0.5"
|
||||
"@expo/config": "npm:55.0.10"
|
||||
"@expo/config-plugins": "npm:55.0.7"
|
||||
|
||||
Reference in new issue
Block a user