@expo/build-tools 1.0.198 → 1.0.199
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.
- package/dist/steps/functions/internalMaestroTest.d.ts +0 -2
- package/dist/steps/functions/internalMaestroTest.js +30 -21
- package/dist/steps/functions/internalMaestroTest.js.map +1 -1
- package/dist/utils/findMaestroPathsFlowsToExecuteAsync.d.ts +9 -0
- package/dist/utils/findMaestroPathsFlowsToExecuteAsync.js +127 -0
- package/dist/utils/findMaestroPathsFlowsToExecuteAsync.js.map +1 -0
- package/package.json +4 -3
|
@@ -3,8 +3,6 @@ import { CustomBuildContext } from '../../customBuildContext';
|
|
|
3
3
|
export declare function createInternalEasMaestroTestFunction(ctx: CustomBuildContext): BuildFunction;
|
|
4
4
|
export declare function getMaestroTestCommand(params: {
|
|
5
5
|
flow_path: string;
|
|
6
|
-
include_tags: string | undefined;
|
|
7
|
-
exclude_tags: string | undefined;
|
|
8
6
|
output_format: string | undefined;
|
|
9
7
|
/** Unused if `output_format` is undefined */
|
|
10
8
|
output_path: string;
|
|
@@ -16,6 +16,7 @@ const eas_build_job_1 = require("@expo/eas-build-job");
|
|
|
16
16
|
const IosSimulatorUtils_1 = require("../../utils/IosSimulatorUtils");
|
|
17
17
|
const AndroidEmulatorUtils_1 = require("../../utils/AndroidEmulatorUtils");
|
|
18
18
|
const strings_1 = require("../../utils/strings");
|
|
19
|
+
const findMaestroPathsFlowsToExecuteAsync_1 = require("../../utils/findMaestroPathsFlowsToExecuteAsync");
|
|
19
20
|
function createInternalEasMaestroTestFunction(ctx) {
|
|
20
21
|
return new steps_1.BuildFunction({
|
|
21
22
|
namespace: 'eas',
|
|
@@ -80,6 +81,23 @@ function createInternalEasMaestroTestFunction(ctx) {
|
|
|
80
81
|
record_screen: zod_1.z.boolean().default(false),
|
|
81
82
|
})
|
|
82
83
|
.parse(Object.fromEntries(Object.entries(_inputs).map(([key, value]) => [key, value.value])));
|
|
84
|
+
const flowPathsToExecute = [];
|
|
85
|
+
for (const flowPath of flow_paths) {
|
|
86
|
+
const flowPaths = await (0, findMaestroPathsFlowsToExecuteAsync_1.findMaestroPathsFlowsToExecuteAsync)({
|
|
87
|
+
workingDirectory: stepCtx.workingDirectory,
|
|
88
|
+
flowPath,
|
|
89
|
+
logger: stepCtx.logger,
|
|
90
|
+
includeTags: include_tags ? include_tags.split(',') : undefined,
|
|
91
|
+
excludeTags: exclude_tags ? exclude_tags.split(',') : undefined,
|
|
92
|
+
});
|
|
93
|
+
if (flowPaths.length === 0) {
|
|
94
|
+
stepCtx.logger.warn(`No flows to execute found in "${flowPath}".`);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
stepCtx.logger.info(`Marking for execution:\n- ${flowPaths.map((flowPath) => node_path_1.default.relative(stepCtx.workingDirectory, flowPath)).join('\n- ')}`);
|
|
98
|
+
stepCtx.logger.info('');
|
|
99
|
+
flowPathsToExecute.push(...flowPaths);
|
|
100
|
+
}
|
|
83
101
|
// TODO: Add support for shards. (Shouldn't be too difficult.)
|
|
84
102
|
if (shards > 1) {
|
|
85
103
|
stepCtx.logger.warn('Sharding support has been temporarily disabled. Running tests on a single shard.');
|
|
@@ -140,7 +158,7 @@ function createInternalEasMaestroTestFunction(ctx) {
|
|
|
140
158
|
const maestroReportsDir = await node_fs_1.default.promises.mkdtemp(node_path_1.default.join(node_os_1.default.tmpdir(), 'maestro-reports-'));
|
|
141
159
|
const deviceLogsDir = await node_fs_1.default.promises.mkdtemp(node_path_1.default.join(node_os_1.default.tmpdir(), 'device-logs-'));
|
|
142
160
|
const failedFlows = [];
|
|
143
|
-
for (const [flowIndex, flowPath] of
|
|
161
|
+
for (const [flowIndex, flowPath] of flowPathsToExecute.entries()) {
|
|
144
162
|
stepCtx.logger.info('');
|
|
145
163
|
// If output_format is empty or noop, we won't use this.
|
|
146
164
|
const outputPath = node_path_1.default.join(maestroReportsDir, [
|
|
@@ -170,8 +188,6 @@ function createInternalEasMaestroTestFunction(ctx) {
|
|
|
170
188
|
stepCtx.logger.info('');
|
|
171
189
|
const [command, ...args] = getMaestroTestCommand({
|
|
172
190
|
flow_path: flowPath,
|
|
173
|
-
include_tags,
|
|
174
|
-
exclude_tags,
|
|
175
191
|
output_format,
|
|
176
192
|
output_path: outputPath,
|
|
177
193
|
});
|
|
@@ -194,7 +210,12 @@ function createInternalEasMaestroTestFunction(ctx) {
|
|
|
194
210
|
if (logsResult === null || logsResult === void 0 ? void 0 : logsResult.ok) {
|
|
195
211
|
try {
|
|
196
212
|
const extension = node_path_1.default.extname(logsResult.value.outputPath);
|
|
197
|
-
|
|
213
|
+
const destinationPath = node_path_1.default.join(deviceLogsDir, `flow-${flowIndex}${extension}`);
|
|
214
|
+
await node_fs_1.default.promises.rm(destinationPath, {
|
|
215
|
+
force: true,
|
|
216
|
+
recursive: true,
|
|
217
|
+
});
|
|
218
|
+
await node_fs_1.default.promises.rename(logsResult.value.outputPath, destinationPath);
|
|
198
219
|
}
|
|
199
220
|
catch (err) {
|
|
200
221
|
stepCtx.logger.warn({ err }, 'Failed to prepare device logs for upload.');
|
|
@@ -277,9 +298,12 @@ function createInternalEasMaestroTestFunction(ctx) {
|
|
|
277
298
|
stepCtx.logger.error({ err }, 'Failed to upload device logs.');
|
|
278
299
|
}
|
|
279
300
|
}
|
|
301
|
+
stepCtx.logger.info('');
|
|
280
302
|
// If any tests failed, we throw an error to mark the step as failed.
|
|
281
303
|
if (failedFlows.length > 0) {
|
|
282
|
-
throw new Error(`Some Maestro tests failed:\n- ${failedFlows
|
|
304
|
+
throw new Error(`Some Maestro tests failed:\n- ${failedFlows
|
|
305
|
+
.map((flowPath) => node_path_1.default.relative(stepCtx.workingDirectory, flowPath))
|
|
306
|
+
.join('\n- ')}`);
|
|
283
307
|
}
|
|
284
308
|
else {
|
|
285
309
|
stepCtx.logger.info('All Maestro tests passed.');
|
|
@@ -289,26 +313,11 @@ function createInternalEasMaestroTestFunction(ctx) {
|
|
|
289
313
|
}
|
|
290
314
|
exports.createInternalEasMaestroTestFunction = createInternalEasMaestroTestFunction;
|
|
291
315
|
function getMaestroTestCommand(params) {
|
|
292
|
-
let includeTagsFlag = [];
|
|
293
|
-
if (typeof params.include_tags === 'string') {
|
|
294
|
-
includeTagsFlag = [`--include-tags`, params.include_tags];
|
|
295
|
-
}
|
|
296
|
-
let excludeTagsFlag = [];
|
|
297
|
-
if (typeof params.exclude_tags === 'string') {
|
|
298
|
-
excludeTagsFlag = [`--exclude-tags`, params.exclude_tags];
|
|
299
|
-
}
|
|
300
316
|
let outputFormatFlags = [];
|
|
301
317
|
if (params.output_format) {
|
|
302
318
|
outputFormatFlags = [`--format`, params.output_format, `--output`, params.output_path];
|
|
303
319
|
}
|
|
304
|
-
return [
|
|
305
|
-
'maestro',
|
|
306
|
-
'test',
|
|
307
|
-
...includeTagsFlag,
|
|
308
|
-
...excludeTagsFlag,
|
|
309
|
-
...outputFormatFlags,
|
|
310
|
-
params.flow_path,
|
|
311
|
-
];
|
|
320
|
+
return ['maestro', 'test', ...outputFormatFlags, params.flow_path];
|
|
312
321
|
}
|
|
313
322
|
exports.getMaestroTestCommand = getMaestroTestCommand;
|
|
314
323
|
const MaestroOutputFormatToExtensionMap = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalMaestroTest.js","sourceRoot":"","sources":["../../../src/steps/functions/internalMaestroTest.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAC7B,sDAAyB;AAEzB,uCAMqB;AACrB,6BAAwB;AACxB,sEAAsE;AACtE,yCAAgD;AAChD,2CAA4D;AAC5D,uDAA0D;AAG1D,qEAAoF;AACpF,2EAI0C;AAC1C,iDAA8D;AAE9D,SAAgB,oCAAoC,CAAC,GAAuB;IAC1E,OAAO,IAAI,qBAAa,CAAC;QACvB,SAAS,EAAE,KAAK;QAChB,EAAE,EAAE,gBAAgB;QACpB,cAAc,EAAE;YACd,sBAAc,CAAC,cAAc,CAAC;gBAC5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AAE,CAAC;IAC7D,CAAC;AACH,CAAC","sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport os from 'node:os';\n\nimport {\n BuildFunction,\n BuildStepEnv,\n BuildStepInput,\n BuildStepInputValueTypeName,\n spawnAsync,\n} from '@expo/steps';\nimport { z } from 'zod';\nimport spawn, { SpawnPromise, SpawnResult } from '@expo/turtle-spawn';\nimport { PipeMode, bunyan } from '@expo/logger';\nimport { Result, asyncResult, result } from '@expo/results';\nimport { GenericArtifactType } from '@expo/eas-build-job';\n\nimport { CustomBuildContext } from '../../customBuildContext';\nimport { IosSimulatorName, IosSimulatorUtils } from '../../utils/IosSimulatorUtils';\nimport {\n AndroidDeviceSerialId,\n AndroidEmulatorUtils,\n AndroidVirtualDeviceName,\n} from '../../utils/AndroidEmulatorUtils';\nimport { PlatformToProperNounMap } from '../../utils/strings';\n\nexport function createInternalEasMaestroTestFunction(ctx: CustomBuildContext): BuildFunction {\n return new BuildFunction({\n namespace: 'eas',\n id: '__maestro_test',\n inputProviders: [\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.STRING,\n id: 'platform',\n required: true,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.JSON,\n id: 'flow_paths',\n required: true,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.NUMBER,\n id: 'retries',\n defaultValue: 1,\n required: false,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.STRING,\n id: 'include_tags',\n required: false,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.STRING,\n id: 'exclude_tags',\n required: false,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.NUMBER,\n id: 'shards',\n defaultValue: 1,\n required: false,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.STRING,\n id: 'output_format',\n required: false,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.BOOLEAN,\n id: 'record_screen',\n defaultValue: false,\n required: false,\n }),\n ],\n fn: async (stepCtx, { inputs: _inputs, env }) => {\n // inputs come in form of { value: unknown }. Here we parse them into a typed and validated object.\n const {\n platform,\n flow_paths,\n retries,\n include_tags,\n exclude_tags,\n shards,\n output_format,\n record_screen,\n } = z\n .object({\n platform: z.enum(['ios', 'android']),\n flow_paths: z.array(z.string()),\n retries: z.number().default(1),\n include_tags: z.string().optional(),\n exclude_tags: z.string().optional(),\n shards: z.number().default(1),\n output_format: z.string().optional(),\n record_screen: z.boolean().default(false),\n })\n .parse(\n Object.fromEntries(Object.entries(_inputs).map(([key, value]) => [key, value.value]))\n );\n\n // TODO: Add support for shards. (Shouldn't be too difficult.)\n if (shards > 1) {\n stepCtx.logger.warn(\n 'Sharding support has been temporarily disabled. Running tests on a single shard.'\n );\n }\n\n // eas/__maestro_test does not start devices, it expects a single device to be already running\n // and configured with the app. Here we find the booted device and stop it.\n\n let sourceDeviceIdentifier: IosSimulatorName | AndroidVirtualDeviceName;\n\n switch (platform) {\n case 'ios': {\n const bootedDevices = await IosSimulatorUtils.getAvailableDevicesAsync({\n env,\n filter: 'booted',\n });\n if (bootedDevices.length === 0) {\n throw new Error('No booted iOS Simulator found.');\n } else if (bootedDevices.length > 1) {\n throw new Error('Multiple booted iOS Simulators found.');\n }\n\n const device = bootedDevices[0];\n stepCtx.logger.info(`Running tests on iOS Simulator: ${device.name}.`);\n\n stepCtx.logger.info(`Preparing Simulator for tests...`);\n await spawnAsync('xcrun', ['simctl', 'shutdown', device.udid], {\n logger: stepCtx.logger,\n stdio: 'pipe',\n });\n\n sourceDeviceIdentifier = device.name;\n break;\n }\n case 'android': {\n const connectedDevices = await AndroidEmulatorUtils.getAttachedDevicesAsync({ env });\n if (connectedDevices.length === 0) {\n throw new Error('No booted Android Emulator found.');\n } else if (connectedDevices.length > 1) {\n throw new Error('Multiple booted Android Emulators found.');\n }\n\n const { serialId } = connectedDevices[0];\n const adbEmuAvdNameResult = await spawn('adb', ['-s', serialId, 'emu', 'avd', 'name'], {\n mode: PipeMode.COMBINED,\n env,\n });\n const avdName = adbEmuAvdNameResult.stdout\n .replace(/\\r\\n/g, '\\n')\n .split('\\n')[0] as AndroidVirtualDeviceName;\n stepCtx.logger.info(`Running tests on Android Emulator: ${avdName}.`);\n\n stepCtx.logger.info(`Preparing Emulator for tests...`);\n await spawnAsync('adb', ['-s', serialId, 'emu', 'kill'], {\n stdio: 'pipe',\n });\n\n sourceDeviceIdentifier = avdName;\n break;\n }\n }\n\n // During tests we generate reports and device logs. We store them in temporary directories\n // and upload them once all tests are done. When a test is retried, new reports overwrite\n // the old ones. The files are named \"flow-${index}\" for easier identification.\n const maestroReportsDir = await fs.promises.mkdtemp(\n path.join(os.tmpdir(), 'maestro-reports-')\n );\n const deviceLogsDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'device-logs-'));\n\n const failedFlows: string[] = [];\n\n for (const [flowIndex, flowPath] of flow_paths.entries()) {\n stepCtx.logger.info('');\n\n // If output_format is empty or noop, we won't use this.\n const outputPath = path.join(\n maestroReportsDir,\n [\n `${output_format + '-' ?? ''}report-flow-${flowIndex + 1}`,\n MaestroOutputFormatToExtensionMap[output_format ?? 'noop'],\n ]\n .filter(Boolean)\n .join('.')\n );\n\n for (let attemptCount = 0; attemptCount < retries; attemptCount++) {\n const localDeviceName = `eas-simulator-${flowIndex}-${attemptCount}` as\n | IosSimulatorName\n | AndroidVirtualDeviceName;\n\n // If the test passes, but the recording fails, we don't want to make the test fail,\n // so we return two separate results.\n const {\n fnResult: { fnResult, recordingResult },\n logsResult,\n } = await withCleanDeviceAsync({\n platform,\n sourceDeviceIdentifier,\n localDeviceName,\n env,\n logger: stepCtx.logger,\n fn: async ({ deviceIdentifier }) => {\n return await maybeWithScreenRecordingAsync({\n shouldRecord: record_screen,\n platform,\n deviceIdentifier,\n env,\n logger: stepCtx.logger,\n fn: async () => {\n stepCtx.logger.info('');\n\n const [command, ...args] = getMaestroTestCommand({\n flow_path: flowPath,\n include_tags,\n exclude_tags,\n output_format,\n output_path: outputPath,\n });\n\n try {\n await spawnAsync(command, args, {\n logger: stepCtx.logger,\n cwd: stepCtx.workingDirectory,\n env,\n stdio: 'pipe',\n });\n } finally {\n stepCtx.logger.info('');\n }\n },\n });\n },\n });\n\n // Move device logs to the device logs directory.\n if (logsResult?.ok) {\n try {\n const extension = path.extname(logsResult.value.outputPath);\n await fs.promises.rename(\n logsResult.value.outputPath,\n path.join(deviceLogsDir, `flow-${flowIndex}${extension}`)\n );\n } catch (err) {\n stepCtx.logger.warn({ err }, 'Failed to prepare device logs for upload.');\n }\n } else if (logsResult?.reason) {\n stepCtx.logger.error({ err: logsResult.reason }, 'Failed to collect device logs.');\n }\n\n const isLastAttempt = fnResult.ok || attemptCount === retries - 1;\n if (isLastAttempt && recordingResult.value) {\n try {\n await ctx.runtimeApi.uploadArtifact({\n logger: stepCtx.logger,\n artifact: {\n // TODO(sjchmiela): Add metadata to artifacts so we don't need to encode flow path and attempt in the name.\n name: `Screen Recording (${flowPath})`,\n paths: [recordingResult.value],\n type: GenericArtifactType.OTHER,\n },\n });\n } catch (err) {\n stepCtx.logger.warn({ err }, 'Failed to upload screen recording.');\n }\n }\n\n if (fnResult.ok) {\n stepCtx.logger.info(`Test passed.`);\n // Break out of the retry loop.\n break;\n }\n\n if (attemptCount < retries - 1) {\n stepCtx.logger.info(`Retrying test...`);\n stepCtx.logger.info('');\n continue;\n }\n\n // fnResult.reason is not super interesting, but it does print out the full command so we can keep it for debugging purposes.\n stepCtx.logger.error({ err: fnResult.reason }, 'Test errored.');\n failedFlows.push(flowPath);\n }\n }\n\n stepCtx.logger.info('');\n\n // When all tests are done, we upload the reports and device logs.\n const generatedMaestroReports = await fs.promises.readdir(maestroReportsDir);\n if (generatedMaestroReports.length === 0) {\n stepCtx.logger.warn('No reports were generated.');\n } else {\n stepCtx.logger.info(`Uploading reports...`);\n try {\n await ctx.runtimeApi.uploadArtifact({\n logger: stepCtx.logger,\n artifact: {\n name: `${PlatformToProperNounMap[platform]} Maestro Test Reports (${output_format})`,\n paths: [maestroReportsDir],\n type: GenericArtifactType.OTHER,\n },\n });\n } catch (err) {\n stepCtx.logger.error({ err }, 'Failed to upload reports.');\n }\n }\n\n const generatedDeviceLogs = await fs.promises.readdir(deviceLogsDir);\n if (generatedDeviceLogs.length === 0) {\n stepCtx.logger.warn('No device logs were successfully collected.');\n } else {\n stepCtx.logger.info(`Uploading device logs...`);\n try {\n await ctx.runtimeApi.uploadArtifact({\n logger: stepCtx.logger,\n artifact: {\n name: `Maestro Test Device Logs`,\n paths: [deviceLogsDir],\n type: GenericArtifactType.OTHER,\n },\n });\n } catch (err) {\n stepCtx.logger.error({ err }, 'Failed to upload device logs.');\n }\n }\n\n // If any tests failed, we throw an error to mark the step as failed.\n if (failedFlows.length > 0) {\n throw new Error(`Some Maestro tests failed:\\n- ${failedFlows.join('\\n- ')}`);\n } else {\n stepCtx.logger.info('All Maestro tests passed.');\n }\n },\n });\n}\n\nexport function getMaestroTestCommand(params: {\n flow_path: string;\n include_tags: string | undefined;\n exclude_tags: string | undefined;\n output_format: string | undefined;\n /** Unused if `output_format` is undefined */\n output_path: string;\n}): [command: string, ...args: string[]] {\n let includeTagsFlag: string[] = [];\n if (typeof params.include_tags === 'string') {\n includeTagsFlag = [`--include-tags`, params.include_tags];\n }\n\n let excludeTagsFlag: string[] = [];\n if (typeof params.exclude_tags === 'string') {\n excludeTagsFlag = [`--exclude-tags`, params.exclude_tags];\n }\n\n let outputFormatFlags: string[] = [];\n if (params.output_format) {\n outputFormatFlags = [`--format`, params.output_format, `--output`, params.output_path];\n }\n\n return [\n 'maestro',\n 'test',\n ...includeTagsFlag,\n ...excludeTagsFlag,\n ...outputFormatFlags,\n params.flow_path,\n ] as [command: string, ...args: string[]];\n}\n\nconst MaestroOutputFormatToExtensionMap: Record<string, string | undefined> = {\n junit: 'xml',\n html: 'html',\n};\n\nasync function withCleanDeviceAsync<TResult>({\n platform,\n sourceDeviceIdentifier,\n localDeviceName,\n env,\n logger,\n fn,\n}: {\n env: BuildStepEnv;\n logger: bunyan;\n platform: 'ios' | 'android';\n sourceDeviceIdentifier: IosSimulatorName | AndroidVirtualDeviceName;\n localDeviceName: IosSimulatorName | AndroidVirtualDeviceName;\n fn: ({\n deviceIdentifier,\n }: {\n deviceIdentifier: IosSimulatorName | AndroidDeviceSerialId;\n }) => Promise<TResult>;\n}): Promise<{ fnResult: TResult; logsResult: Result<{ outputPath: string }> | null }> {\n // Clone and start the device\n\n let localDeviceIdentifier: IosSimulatorName | AndroidDeviceSerialId;\n\n switch (platform) {\n case 'ios': {\n logger.info(`Cloning iOS Simulator ${sourceDeviceIdentifier} to ${localDeviceName}...`);\n await IosSimulatorUtils.cloneAsync({\n sourceDeviceIdentifier: sourceDeviceIdentifier as IosSimulatorName,\n destinationDeviceName: localDeviceName as IosSimulatorName,\n env,\n });\n logger.info(`Starting iOS Simulator ${localDeviceName}...`);\n const { udid } = await IosSimulatorUtils.startAsync({\n deviceIdentifier: localDeviceName as IosSimulatorName,\n env,\n });\n logger.info(`Waiting for iOS Simulator ${localDeviceName} to be ready...`);\n await IosSimulatorUtils.waitForReadyAsync({\n udid,\n env,\n });\n localDeviceIdentifier = localDeviceName as IosSimulatorName;\n break;\n }\n case 'android': {\n logger.info(`Cloning Android Emulator ${sourceDeviceIdentifier} to ${localDeviceName}...`);\n await AndroidEmulatorUtils.cloneAsync({\n sourceDeviceName: sourceDeviceIdentifier as AndroidVirtualDeviceName,\n destinationDeviceName: localDeviceName as AndroidVirtualDeviceName,\n env,\n });\n logger.info(`Starting Android Emulator ${localDeviceName}...`);\n const { serialId } = await AndroidEmulatorUtils.startAsync({\n deviceName: localDeviceName as AndroidVirtualDeviceName,\n env,\n });\n logger.info(`Waiting for Android Emulator ${localDeviceName} to be ready...`);\n await AndroidEmulatorUtils.waitForReadyAsync({\n serialId,\n env,\n });\n localDeviceIdentifier = serialId;\n break;\n }\n }\n\n // Run the function\n\n const fnResult = await asyncResult(fn({ deviceIdentifier: localDeviceIdentifier }));\n\n // Stop the device\n\n let logsResult: Result<{ outputPath: string }> | null = null;\n\n try {\n switch (platform) {\n case 'ios': {\n logger.info(`Collecting logs from ${localDeviceName}...`);\n logsResult = await asyncResult(\n IosSimulatorUtils.collectLogsAsync({\n deviceIdentifier: localDeviceIdentifier as IosSimulatorName,\n env,\n })\n );\n\n logger.info(`Cleaning up ${localDeviceName}...`);\n await IosSimulatorUtils.deleteAsync({\n deviceIdentifier: localDeviceIdentifier as IosSimulatorName,\n env,\n });\n break;\n }\n case 'android': {\n logger.info(`Collecting logs from ${localDeviceName}...`);\n logsResult = await asyncResult(\n AndroidEmulatorUtils.collectLogsAsync({\n serialId: localDeviceIdentifier as AndroidDeviceSerialId,\n env,\n })\n );\n\n logger.info(`Cleaning up ${localDeviceName}...`);\n await AndroidEmulatorUtils.deleteAsync({\n serialId: localDeviceIdentifier as AndroidDeviceSerialId,\n env,\n });\n break;\n }\n }\n } catch (err) {\n logger.error(`Error cleaning up device: ${err}`);\n }\n\n return { fnResult: fnResult.enforceValue(), logsResult };\n}\n\n/** Runs provided `fn` function, optionally wrapping it with starting and stopping screen recording. */\nasync function maybeWithScreenRecordingAsync<TResult>({\n shouldRecord,\n platform,\n deviceIdentifier,\n env,\n logger,\n fn,\n}: {\n // As weird as it is, it's more convenient to have this function like `maybeWith...`\n // than \"withScreenRecordingAsync\" and `withScreenRecordingAsync(fn)` vs `fn` in the caller.\n shouldRecord: boolean;\n platform: 'ios' | 'android';\n deviceIdentifier: IosSimulatorName | AndroidDeviceSerialId;\n env: BuildStepEnv;\n logger: bunyan;\n fn: () => Promise<TResult>;\n}): Promise<{ fnResult: Result<TResult>; recordingResult: Result<string | null> }> {\n if (!shouldRecord) {\n return { fnResult: await asyncResult(fn()), recordingResult: result(null) };\n }\n\n let recordingResult: Result<{\n recordingSpawn: SpawnPromise<SpawnResult>;\n outputPath?: string;\n }>;\n\n // Start screen recording\n\n logger.info(`Starting screen recording on ${deviceIdentifier}...`);\n\n switch (platform) {\n case 'ios': {\n recordingResult = await asyncResult(\n IosSimulatorUtils.startScreenRecordingAsync({\n deviceIdentifier: deviceIdentifier as IosSimulatorName,\n env,\n })\n );\n break;\n }\n case 'android': {\n recordingResult = await asyncResult(\n AndroidEmulatorUtils.startScreenRecordingAsync({\n serialId: deviceIdentifier as AndroidDeviceSerialId,\n env,\n })\n );\n break;\n }\n }\n\n if (!recordingResult.ok) {\n logger.warn('Failed to start screen recording.', recordingResult.reason);\n }\n\n // Run the function\n\n const fnResult = await asyncResult(fn());\n\n // If recording failed there's nothing to stop, so we return the results\n\n if (!recordingResult.ok) {\n return { fnResult, recordingResult: result(recordingResult.reason) };\n }\n\n // If recording started, finish it\n\n try {\n logger.info(`Stopping screen recording on ${deviceIdentifier}...`);\n\n switch (platform) {\n case 'ios': {\n await IosSimulatorUtils.stopScreenRecordingAsync({\n recordingSpawn: recordingResult.value.recordingSpawn,\n });\n return {\n fnResult,\n // We know outputPath is defined, because startIosScreenRecording() should have filled it.\n recordingResult: result(recordingResult.value.outputPath!),\n };\n }\n case 'android': {\n const { outputPath } = await AndroidEmulatorUtils.stopScreenRecordingAsync({\n serialId: deviceIdentifier as AndroidDeviceSerialId,\n recordingSpawn: recordingResult.value.recordingSpawn,\n env,\n });\n return { fnResult, recordingResult: result(outputPath) };\n }\n }\n } catch (err) {\n logger.warn('Failed to stop screen recording.', err);\n\n return { fnResult, recordingResult: result(err as Error) };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"internalMaestroTest.js","sourceRoot":"","sources":["../../../src/steps/functions/internalMaestroTest.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAyB;AACzB,0DAA6B;AAC7B,sDAAyB;AAEzB,uCAMqB;AACrB,6BAAwB;AACxB,sEAAsE;AACtE,yCAAgD;AAChD,2CAA4D;AAC5D,uDAA0D;AAG1D,qEAAoF;AACpF,2EAI0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\n BuildStepInput,\n BuildStepInputValueTypeName,\n spawnAsync,\n} from '@expo/steps';\nimport { z } from 'zod';\nimport spawn, { SpawnPromise, SpawnResult } from '@expo/turtle-spawn';\nimport { PipeMode, bunyan } from '@expo/logger';\nimport { Result, asyncResult, result } from '@expo/results';\nimport { GenericArtifactType } from '@expo/eas-build-job';\n\nimport { CustomBuildContext } from '../../customBuildContext';\nimport { IosSimulatorName, IosSimulatorUtils } from '../../utils/IosSimulatorUtils';\nimport {\n AndroidDeviceSerialId,\n AndroidEmulatorUtils,\n AndroidVirtualDeviceName,\n} from '../../utils/AndroidEmulatorUtils';\nimport { PlatformToProperNounMap } from '../../utils/strings';\nimport { findMaestroPathsFlowsToExecuteAsync } from '../../utils/findMaestroPathsFlowsToExecuteAsync';\n\nexport function createInternalEasMaestroTestFunction(ctx: CustomBuildContext): BuildFunction {\n return new BuildFunction({\n namespace: 'eas',\n id: '__maestro_test',\n inputProviders: [\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.STRING,\n id: 'platform',\n required: true,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.JSON,\n id: 'flow_paths',\n required: true,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.NUMBER,\n id: 'retries',\n defaultValue: 1,\n required: false,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.STRING,\n id: 'include_tags',\n required: false,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.STRING,\n id: 'exclude_tags',\n required: false,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.NUMBER,\n id: 'shards',\n defaultValue: 1,\n required: false,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.STRING,\n id: 'output_format',\n required: false,\n }),\n BuildStepInput.createProvider({\n allowedValueTypeName: BuildStepInputValueTypeName.BOOLEAN,\n id: 'record_screen',\n defaultValue: false,\n required: false,\n }),\n ],\n fn: async (stepCtx, { inputs: _inputs, env }) => {\n // inputs come in form of { value: unknown }. Here we parse them into a typed and validated object.\n const {\n platform,\n flow_paths,\n retries,\n include_tags,\n exclude_tags,\n shards,\n output_format,\n record_screen,\n } = z\n .object({\n platform: z.enum(['ios', 'android']),\n flow_paths: z.array(z.string()),\n retries: z.number().default(1),\n include_tags: z.string().optional(),\n exclude_tags: z.string().optional(),\n shards: z.number().default(1),\n output_format: z.string().optional(),\n record_screen: z.boolean().default(false),\n })\n .parse(\n Object.fromEntries(Object.entries(_inputs).map(([key, value]) => [key, value.value]))\n );\n\n const flowPathsToExecute: string[] = [];\n for (const flowPath of flow_paths) {\n const flowPaths = await findMaestroPathsFlowsToExecuteAsync({\n workingDirectory: stepCtx.workingDirectory,\n flowPath,\n logger: stepCtx.logger,\n includeTags: include_tags ? include_tags.split(',') : undefined,\n excludeTags: exclude_tags ? exclude_tags.split(',') : undefined,\n });\n if (flowPaths.length === 0) {\n stepCtx.logger.warn(`No flows to execute found in \"${flowPath}\".`);\n continue;\n }\n stepCtx.logger.info(\n `Marking for execution:\\n- ${flowPaths.map((flowPath) => path.relative(stepCtx.workingDirectory, flowPath)).join('\\n- ')}`\n );\n stepCtx.logger.info('');\n flowPathsToExecute.push(...flowPaths);\n }\n\n // TODO: Add support for shards. (Shouldn't be too difficult.)\n if (shards > 1) {\n stepCtx.logger.warn(\n 'Sharding support has been temporarily disabled. Running tests on a single shard.'\n );\n }\n\n // eas/__maestro_test does not start devices, it expects a single device to be already running\n // and configured with the app. Here we find the booted device and stop it.\n\n let sourceDeviceIdentifier: IosSimulatorName | AndroidVirtualDeviceName;\n\n switch (platform) {\n case 'ios': {\n const bootedDevices = await IosSimulatorUtils.getAvailableDevicesAsync({\n env,\n filter: 'booted',\n });\n if (bootedDevices.length === 0) {\n throw new Error('No booted iOS Simulator found.');\n } else if (bootedDevices.length > 1) {\n throw new Error('Multiple booted iOS Simulators found.');\n }\n\n const device = bootedDevices[0];\n stepCtx.logger.info(`Running tests on iOS Simulator: ${device.name}.`);\n\n stepCtx.logger.info(`Preparing Simulator for tests...`);\n await spawnAsync('xcrun', ['simctl', 'shutdown', device.udid], {\n logger: stepCtx.logger,\n stdio: 'pipe',\n });\n\n sourceDeviceIdentifier = device.name;\n break;\n }\n case 'android': {\n const connectedDevices = await AndroidEmulatorUtils.getAttachedDevicesAsync({ env });\n if (connectedDevices.length === 0) {\n throw new Error('No booted Android Emulator found.');\n } else if (connectedDevices.length > 1) {\n throw new Error('Multiple booted Android Emulators found.');\n }\n\n const { serialId } = connectedDevices[0];\n const adbEmuAvdNameResult = await spawn('adb', ['-s', serialId, 'emu', 'avd', 'name'], {\n mode: PipeMode.COMBINED,\n env,\n });\n const avdName = adbEmuAvdNameResult.stdout\n .replace(/\\r\\n/g, '\\n')\n .split('\\n')[0] as AndroidVirtualDeviceName;\n stepCtx.logger.info(`Running tests on Android Emulator: ${avdName}.`);\n\n stepCtx.logger.info(`Preparing Emulator for tests...`);\n await spawnAsync('adb', ['-s', serialId, 'emu', 'kill'], {\n stdio: 'pipe',\n });\n\n sourceDeviceIdentifier = avdName;\n break;\n }\n }\n\n // During tests we generate reports and device logs. We store them in temporary directories\n // and upload them once all tests are done. When a test is retried, new reports overwrite\n // the old ones. The files are named \"flow-${index}\" for easier identification.\n const maestroReportsDir = await fs.promises.mkdtemp(\n path.join(os.tmpdir(), 'maestro-reports-')\n );\n const deviceLogsDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), 'device-logs-'));\n\n const failedFlows: string[] = [];\n\n for (const [flowIndex, flowPath] of flowPathsToExecute.entries()) {\n stepCtx.logger.info('');\n\n // If output_format is empty or noop, we won't use this.\n const outputPath = path.join(\n maestroReportsDir,\n [\n `${output_format + '-' ?? ''}report-flow-${flowIndex + 1}`,\n MaestroOutputFormatToExtensionMap[output_format ?? 'noop'],\n ]\n .filter(Boolean)\n .join('.')\n );\n\n for (let attemptCount = 0; attemptCount < retries; attemptCount++) {\n const localDeviceName = `eas-simulator-${flowIndex}-${attemptCount}` as\n | IosSimulatorName\n | AndroidVirtualDeviceName;\n\n // If the test passes, but the recording fails, we don't want to make the test fail,\n // so we return two separate results.\n const {\n fnResult: { fnResult, recordingResult },\n logsResult,\n } = await withCleanDeviceAsync({\n platform,\n sourceDeviceIdentifier,\n localDeviceName,\n env,\n logger: stepCtx.logger,\n fn: async ({ deviceIdentifier }) => {\n return await maybeWithScreenRecordingAsync({\n shouldRecord: record_screen,\n platform,\n deviceIdentifier,\n env,\n logger: stepCtx.logger,\n fn: async () => {\n stepCtx.logger.info('');\n\n const [command, ...args] = getMaestroTestCommand({\n flow_path: flowPath,\n output_format,\n output_path: outputPath,\n });\n\n try {\n await spawnAsync(command, args, {\n logger: stepCtx.logger,\n cwd: stepCtx.workingDirectory,\n env,\n stdio: 'pipe',\n });\n } finally {\n stepCtx.logger.info('');\n }\n },\n });\n },\n });\n\n // Move device logs to the device logs directory.\n if (logsResult?.ok) {\n try {\n const extension = path.extname(logsResult.value.outputPath);\n const destinationPath = path.join(deviceLogsDir, `flow-${flowIndex}${extension}`);\n\n await fs.promises.rm(destinationPath, {\n force: true,\n recursive: true,\n });\n await fs.promises.rename(logsResult.value.outputPath, destinationPath);\n } catch (err) {\n stepCtx.logger.warn({ err }, 'Failed to prepare device logs for upload.');\n }\n } else if (logsResult?.reason) {\n stepCtx.logger.error({ err: logsResult.reason }, 'Failed to collect device logs.');\n }\n\n const isLastAttempt = fnResult.ok || attemptCount === retries - 1;\n if (isLastAttempt && recordingResult.value) {\n try {\n await ctx.runtimeApi.uploadArtifact({\n logger: stepCtx.logger,\n artifact: {\n // TODO(sjchmiela): Add metadata to artifacts so we don't need to encode flow path and attempt in the name.\n name: `Screen Recording (${flowPath})`,\n paths: [recordingResult.value],\n type: GenericArtifactType.OTHER,\n },\n });\n } catch (err) {\n stepCtx.logger.warn({ err }, 'Failed to upload screen recording.');\n }\n }\n\n if (fnResult.ok) {\n stepCtx.logger.info(`Test passed.`);\n // Break out of the retry loop.\n break;\n }\n\n if (attemptCount < retries - 1) {\n stepCtx.logger.info(`Retrying test...`);\n stepCtx.logger.info('');\n continue;\n }\n\n // fnResult.reason is not super interesting, but it does print out the full command so we can keep it for debugging purposes.\n stepCtx.logger.error({ err: fnResult.reason }, 'Test errored.');\n failedFlows.push(flowPath);\n }\n }\n\n stepCtx.logger.info('');\n\n // When all tests are done, we upload the reports and device logs.\n const generatedMaestroReports = await fs.promises.readdir(maestroReportsDir);\n if (generatedMaestroReports.length === 0) {\n stepCtx.logger.warn('No reports were generated.');\n } else {\n stepCtx.logger.info(`Uploading reports...`);\n try {\n await ctx.runtimeApi.uploadArtifact({\n logger: stepCtx.logger,\n artifact: {\n name: `${PlatformToProperNounMap[platform]} Maestro Test Reports (${output_format})`,\n paths: [maestroReportsDir],\n type: GenericArtifactType.OTHER,\n },\n });\n } catch (err) {\n stepCtx.logger.error({ err }, 'Failed to upload reports.');\n }\n }\n\n const generatedDeviceLogs = await fs.promises.readdir(deviceLogsDir);\n if (generatedDeviceLogs.length === 0) {\n stepCtx.logger.warn('No device logs were successfully collected.');\n } else {\n stepCtx.logger.info(`Uploading device logs...`);\n try {\n await ctx.runtimeApi.uploadArtifact({\n logger: stepCtx.logger,\n artifact: {\n name: `Maestro Test Device Logs`,\n paths: [deviceLogsDir],\n type: GenericArtifactType.OTHER,\n },\n });\n } catch (err) {\n stepCtx.logger.error({ err }, 'Failed to upload device logs.');\n }\n }\n\n stepCtx.logger.info('');\n\n // If any tests failed, we throw an error to mark the step as failed.\n if (failedFlows.length > 0) {\n throw new Error(\n `Some Maestro tests failed:\\n- ${failedFlows\n .map((flowPath) => path.relative(stepCtx.workingDirectory, flowPath))\n .join('\\n- ')}`\n );\n } else {\n stepCtx.logger.info('All Maestro tests passed.');\n }\n },\n });\n}\n\nexport function getMaestroTestCommand(params: {\n flow_path: string;\n output_format: string | undefined;\n /** Unused if `output_format` is undefined */\n output_path: string;\n}): [command: string, ...args: string[]] {\n let outputFormatFlags: string[] = [];\n if (params.output_format) {\n outputFormatFlags = [`--format`, params.output_format, `--output`, params.output_path];\n }\n\n return ['maestro', 'test', ...outputFormatFlags, params.flow_path] as [\n command: string,\n ...args: string[],\n ];\n}\n\nconst MaestroOutputFormatToExtensionMap: Record<string, string | undefined> = {\n junit: 'xml',\n html: 'html',\n};\n\nasync function withCleanDeviceAsync<TResult>({\n platform,\n sourceDeviceIdentifier,\n localDeviceName,\n env,\n logger,\n fn,\n}: {\n env: BuildStepEnv;\n logger: bunyan;\n platform: 'ios' | 'android';\n sourceDeviceIdentifier: IosSimulatorName | AndroidVirtualDeviceName;\n localDeviceName: IosSimulatorName | AndroidVirtualDeviceName;\n fn: ({\n deviceIdentifier,\n }: {\n deviceIdentifier: IosSimulatorName | AndroidDeviceSerialId;\n }) => Promise<TResult>;\n}): Promise<{ fnResult: TResult; logsResult: Result<{ outputPath: string }> | null }> {\n // Clone and start the device\n\n let localDeviceIdentifier: IosSimulatorName | AndroidDeviceSerialId;\n\n switch (platform) {\n case 'ios': {\n logger.info(`Cloning iOS Simulator ${sourceDeviceIdentifier} to ${localDeviceName}...`);\n await IosSimulatorUtils.cloneAsync({\n sourceDeviceIdentifier: sourceDeviceIdentifier as IosSimulatorName,\n destinationDeviceName: localDeviceName as IosSimulatorName,\n env,\n });\n logger.info(`Starting iOS Simulator ${localDeviceName}...`);\n const { udid } = await IosSimulatorUtils.startAsync({\n deviceIdentifier: localDeviceName as IosSimulatorName,\n env,\n });\n logger.info(`Waiting for iOS Simulator ${localDeviceName} to be ready...`);\n await IosSimulatorUtils.waitForReadyAsync({\n udid,\n env,\n });\n localDeviceIdentifier = localDeviceName as IosSimulatorName;\n break;\n }\n case 'android': {\n logger.info(`Cloning Android Emulator ${sourceDeviceIdentifier} to ${localDeviceName}...`);\n await AndroidEmulatorUtils.cloneAsync({\n sourceDeviceName: sourceDeviceIdentifier as AndroidVirtualDeviceName,\n destinationDeviceName: localDeviceName as AndroidVirtualDeviceName,\n env,\n });\n logger.info(`Starting Android Emulator ${localDeviceName}...`);\n const { serialId } = await AndroidEmulatorUtils.startAsync({\n deviceName: localDeviceName as AndroidVirtualDeviceName,\n env,\n });\n logger.info(`Waiting for Android Emulator ${localDeviceName} to be ready...`);\n await AndroidEmulatorUtils.waitForReadyAsync({\n serialId,\n env,\n });\n localDeviceIdentifier = serialId;\n break;\n }\n }\n\n // Run the function\n\n const fnResult = await asyncResult(fn({ deviceIdentifier: localDeviceIdentifier }));\n\n // Stop the device\n\n let logsResult: Result<{ outputPath: string }> | null = null;\n\n try {\n switch (platform) {\n case 'ios': {\n logger.info(`Collecting logs from ${localDeviceName}...`);\n logsResult = await asyncResult(\n IosSimulatorUtils.collectLogsAsync({\n deviceIdentifier: localDeviceIdentifier as IosSimulatorName,\n env,\n })\n );\n\n logger.info(`Cleaning up ${localDeviceName}...`);\n await IosSimulatorUtils.deleteAsync({\n deviceIdentifier: localDeviceIdentifier as IosSimulatorName,\n env,\n });\n break;\n }\n case 'android': {\n logger.info(`Collecting logs from ${localDeviceName}...`);\n logsResult = await asyncResult(\n AndroidEmulatorUtils.collectLogsAsync({\n serialId: localDeviceIdentifier as AndroidDeviceSerialId,\n env,\n })\n );\n\n logger.info(`Cleaning up ${localDeviceName}...`);\n await AndroidEmulatorUtils.deleteAsync({\n serialId: localDeviceIdentifier as AndroidDeviceSerialId,\n env,\n });\n break;\n }\n }\n } catch (err) {\n logger.error(`Error cleaning up device: ${err}`);\n }\n\n return { fnResult: fnResult.enforceValue(), logsResult };\n}\n\n/** Runs provided `fn` function, optionally wrapping it with starting and stopping screen recording. */\nasync function maybeWithScreenRecordingAsync<TResult>({\n shouldRecord,\n platform,\n deviceIdentifier,\n env,\n logger,\n fn,\n}: {\n // As weird as it is, it's more convenient to have this function like `maybeWith...`\n // than \"withScreenRecordingAsync\" and `withScreenRecordingAsync(fn)` vs `fn` in the caller.\n shouldRecord: boolean;\n platform: 'ios' | 'android';\n deviceIdentifier: IosSimulatorName | AndroidDeviceSerialId;\n env: BuildStepEnv;\n logger: bunyan;\n fn: () => Promise<TResult>;\n}): Promise<{ fnResult: Result<TResult>; recordingResult: Result<string | null> }> {\n if (!shouldRecord) {\n return { fnResult: await asyncResult(fn()), recordingResult: result(null) };\n }\n\n let recordingResult: Result<{\n recordingSpawn: SpawnPromise<SpawnResult>;\n outputPath?: string;\n }>;\n\n // Start screen recording\n\n logger.info(`Starting screen recording on ${deviceIdentifier}...`);\n\n switch (platform) {\n case 'ios': {\n recordingResult = await asyncResult(\n IosSimulatorUtils.startScreenRecordingAsync({\n deviceIdentifier: deviceIdentifier as IosSimulatorName,\n env,\n })\n );\n break;\n }\n case 'android': {\n recordingResult = await asyncResult(\n AndroidEmulatorUtils.startScreenRecordingAsync({\n serialId: deviceIdentifier as AndroidDeviceSerialId,\n env,\n })\n );\n break;\n }\n }\n\n if (!recordingResult.ok) {\n logger.warn('Failed to start screen recording.', recordingResult.reason);\n }\n\n // Run the function\n\n const fnResult = await asyncResult(fn());\n\n // If recording failed there's nothing to stop, so we return the results\n\n if (!recordingResult.ok) {\n return { fnResult, recordingResult: result(recordingResult.reason) };\n }\n\n // If recording started, finish it\n\n try {\n logger.info(`Stopping screen recording on ${deviceIdentifier}...`);\n\n switch (platform) {\n case 'ios': {\n await IosSimulatorUtils.stopScreenRecordingAsync({\n recordingSpawn: recordingResult.value.recordingSpawn,\n });\n return {\n fnResult,\n // We know outputPath is defined, because startIosScreenRecording() should have filled it.\n recordingResult: result(recordingResult.value.outputPath!),\n };\n }\n case 'android': {\n const { outputPath } = await AndroidEmulatorUtils.stopScreenRecordingAsync({\n serialId: deviceIdentifier as AndroidDeviceSerialId,\n recordingSpawn: recordingResult.value.recordingSpawn,\n env,\n });\n return { fnResult, recordingResult: result(outputPath) };\n }\n }\n } catch (err) {\n logger.warn('Failed to stop screen recording.', err);\n\n return { fnResult, recordingResult: result(err as Error) };\n }\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="bunyan" />
|
|
2
|
+
import { bunyan } from '@expo/logger';
|
|
3
|
+
export declare function findMaestroPathsFlowsToExecuteAsync({ workingDirectory, flowPath, includeTags, excludeTags, logger, }: {
|
|
4
|
+
workingDirectory: string;
|
|
5
|
+
flowPath: string;
|
|
6
|
+
includeTags: string[] | undefined;
|
|
7
|
+
excludeTags: string[] | undefined;
|
|
8
|
+
logger: bunyan;
|
|
9
|
+
}): Promise<string[]>;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.findMaestroPathsFlowsToExecuteAsync = void 0;
|
|
27
|
+
const node_fs_1 = require("node:fs");
|
|
28
|
+
const path = __importStar(require("node:path"));
|
|
29
|
+
const yaml = __importStar(require("yaml"));
|
|
30
|
+
const zod_1 = require("zod");
|
|
31
|
+
const results_1 = require("@expo/results");
|
|
32
|
+
const FlowConfigSchema = zod_1.z.object({
|
|
33
|
+
name: zod_1.z.string().optional(),
|
|
34
|
+
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
35
|
+
});
|
|
36
|
+
async function findMaestroPathsFlowsToExecuteAsync({ workingDirectory, flowPath, includeTags, excludeTags, logger, }) {
|
|
37
|
+
var _a;
|
|
38
|
+
const absoluteFlowPath = path.resolve(workingDirectory, flowPath);
|
|
39
|
+
// If it's a file, just return it (no validation needed)
|
|
40
|
+
const stat = await node_fs_1.promises.stat(absoluteFlowPath);
|
|
41
|
+
if (stat.isFile()) {
|
|
42
|
+
logger.info(`Found a file: ${path.relative(workingDirectory, absoluteFlowPath)}`);
|
|
43
|
+
return [absoluteFlowPath];
|
|
44
|
+
}
|
|
45
|
+
// It's a directory - discover flow files
|
|
46
|
+
logger.info(`Found a directory: ${path.relative(workingDirectory, absoluteFlowPath)}`);
|
|
47
|
+
logger.info(`Searching for flow files...`);
|
|
48
|
+
const { flows } = await findAndParseFlowFilesAsync({
|
|
49
|
+
dirPath: absoluteFlowPath,
|
|
50
|
+
workingDirectory,
|
|
51
|
+
logger,
|
|
52
|
+
});
|
|
53
|
+
if (flows.length === 0) {
|
|
54
|
+
logger.info(`No valid flow files found in: ${path.relative(workingDirectory, absoluteFlowPath)}`);
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
if (!includeTags && !excludeTags) {
|
|
58
|
+
logger.info(`No tags provided, returning all flows.`);
|
|
59
|
+
return flows.map(({ path }) => path);
|
|
60
|
+
}
|
|
61
|
+
logger.info(`Filtering flows by tags. Tags to include: ${JSON.stringify(includeTags)}. Tags to exclude: ${(_a = JSON.stringify(excludeTags)) !== null && _a !== void 0 ? _a : 'none'}.`);
|
|
62
|
+
return flows
|
|
63
|
+
.filter(({ config, path: flowPath }) => {
|
|
64
|
+
var _a;
|
|
65
|
+
const shouldInclude = matchesTags({
|
|
66
|
+
flowTags: (_a = config === null || config === void 0 ? void 0 : config.tags) !== null && _a !== void 0 ? _a : [],
|
|
67
|
+
includeTags: includeTags !== null && includeTags !== void 0 ? includeTags : [],
|
|
68
|
+
excludeTags: excludeTags !== null && excludeTags !== void 0 ? excludeTags : [],
|
|
69
|
+
});
|
|
70
|
+
logger.info(shouldInclude
|
|
71
|
+
? `- ${path.relative(workingDirectory, flowPath)} matches tags, including.`
|
|
72
|
+
: `- ${path.relative(workingDirectory, flowPath)} does not match tags, excluding.`);
|
|
73
|
+
return shouldInclude;
|
|
74
|
+
})
|
|
75
|
+
.map(({ path }) => path);
|
|
76
|
+
}
|
|
77
|
+
exports.findMaestroPathsFlowsToExecuteAsync = findMaestroPathsFlowsToExecuteAsync;
|
|
78
|
+
async function findAndParseFlowFilesAsync({ workingDirectory, dirPath, logger, }) {
|
|
79
|
+
const flows = [];
|
|
80
|
+
const entries = await node_fs_1.promises.readdir(dirPath, { withFileTypes: true });
|
|
81
|
+
for (const entry of entries) {
|
|
82
|
+
const fullPath = path.join(dirPath, entry.name);
|
|
83
|
+
if (entry.isFile()) {
|
|
84
|
+
// Skip non-YAML files
|
|
85
|
+
const ext = path.extname(fullPath);
|
|
86
|
+
if (ext !== '.yaml' && ext !== '.yml') {
|
|
87
|
+
logger.info(`Skipping non-YAML file: ${path.relative(workingDirectory, fullPath)}`);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
// Skip Maestro config files
|
|
91
|
+
const basename = path.basename(fullPath, ext);
|
|
92
|
+
if (basename === 'config') {
|
|
93
|
+
logger.info(`Maestro config files are not supported yet. Skipping Maestro config file: ${path.relative(workingDirectory, fullPath)}`);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
const result = await (0, results_1.asyncResult)(parseFlowFile(fullPath));
|
|
97
|
+
if (result.ok) {
|
|
98
|
+
logger.info(`Found flow file: ${path.relative(workingDirectory, fullPath)}`);
|
|
99
|
+
flows.push({ config: result.value, path: fullPath });
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
logger.info({ err: result.reason }, `Skipping flow file: ${path.relative(workingDirectory, fullPath)}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else if (entry.isDirectory()) {
|
|
106
|
+
logger.info(`Default behavior excludes subdirectories. Skipping subdirectory: ${path.relative(workingDirectory, fullPath)}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return { flows };
|
|
110
|
+
}
|
|
111
|
+
async function parseFlowFile(filePath) {
|
|
112
|
+
const content = await node_fs_1.promises.readFile(filePath, 'utf-8');
|
|
113
|
+
const documents = yaml.parseAllDocuments(content);
|
|
114
|
+
const configDoc = documents[0];
|
|
115
|
+
if (!configDoc) {
|
|
116
|
+
throw new Error(`No config section found in ${filePath}`);
|
|
117
|
+
}
|
|
118
|
+
return FlowConfigSchema.parse(configDoc.toJS());
|
|
119
|
+
}
|
|
120
|
+
function matchesTags({ flowTags, includeTags, excludeTags, }) {
|
|
121
|
+
// Include logic: if includeTags is empty OR flow has any of the include tags
|
|
122
|
+
const includeMatch = includeTags.length === 0 || includeTags.some((tag) => flowTags.includes(tag));
|
|
123
|
+
// Exclude logic: if excludeTags is empty OR flow has none of the exclude tags
|
|
124
|
+
const excludeMatch = excludeTags.length === 0 || !excludeTags.some((tag) => flowTags.includes(tag));
|
|
125
|
+
return includeMatch && excludeMatch;
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=findMaestroPathsFlowsToExecuteAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findMaestroPathsFlowsToExecuteAsync.js","sourceRoot":"","sources":["../../src/utils/findMaestroPathsFlowsToExecuteAsync.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyC;AACzC,gDA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AAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAEjF,OAAO,YAAY,IAAI,YAAY,CAAC;AACtC,CAAC","sourcesContent":["import { promises as fs } from 'node:fs';\nimport * as path from 'node:path';\n\nimport { bunyan } from '@expo/logger';\nimport * as yaml from 'yaml';\nimport { z } from 'zod';\nimport { asyncResult } from '@expo/results';\n\nconst FlowConfigSchema = z.object({\n name: z.string().optional(),\n tags: z.array(z.string()).optional(),\n});\n\ntype FlowConfig = z.infer<typeof FlowConfigSchema>;\n\nexport async function findMaestroPathsFlowsToExecuteAsync({\n workingDirectory,\n flowPath,\n includeTags,\n excludeTags,\n logger,\n}: {\n workingDirectory: string;\n flowPath: string;\n includeTags: string[] | undefined;\n excludeTags: string[] | undefined;\n logger: bunyan;\n}): Promise<string[]> {\n const absoluteFlowPath = path.resolve(workingDirectory, flowPath);\n // If it's a file, just return it (no validation needed)\n const stat = await fs.stat(absoluteFlowPath);\n\n if (stat.isFile()) {\n logger.info(`Found a file: ${path.relative(workingDirectory, absoluteFlowPath)}`);\n return [absoluteFlowPath];\n }\n\n // It's a directory - discover flow files\n logger.info(`Found a directory: ${path.relative(workingDirectory, absoluteFlowPath)}`);\n logger.info(`Searching for flow files...`);\n const { flows } = await findAndParseFlowFilesAsync({\n dirPath: absoluteFlowPath,\n workingDirectory,\n logger,\n });\n\n if (flows.length === 0) {\n logger.info(\n `No valid flow files found in: ${path.relative(workingDirectory, absoluteFlowPath)}`\n );\n return [];\n }\n\n if (!includeTags && !excludeTags) {\n logger.info(`No tags provided, returning all flows.`);\n return flows.map(({ path }) => path);\n }\n\n logger.info(\n `Filtering flows by tags. Tags to include: ${JSON.stringify(includeTags)}. Tags to exclude: ${JSON.stringify(excludeTags) ?? 'none'}.`\n );\n return flows\n .filter(({ config, path: flowPath }) => {\n const shouldInclude = matchesTags({\n flowTags: config?.tags ?? [],\n includeTags: includeTags ?? [],\n excludeTags: excludeTags ?? [],\n });\n\n logger.info(\n shouldInclude\n ? `- ${path.relative(workingDirectory, flowPath)} matches tags, including.`\n : `- ${path.relative(workingDirectory, flowPath)} does not match tags, excluding.`\n );\n\n return shouldInclude;\n })\n .map(({ path }) => path);\n}\n\nasync function findAndParseFlowFilesAsync({\n workingDirectory,\n dirPath,\n logger,\n}: {\n workingDirectory: string;\n dirPath: string;\n logger: bunyan;\n}): Promise<{ flows: { config: FlowConfig; path: string }[] }> {\n const flows: { config: FlowConfig; path: string }[] = [];\n\n const entries = await fs.readdir(dirPath, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(dirPath, entry.name);\n\n if (entry.isFile()) {\n // Skip non-YAML files\n const ext = path.extname(fullPath);\n if (ext !== '.yaml' && ext !== '.yml') {\n logger.info(`Skipping non-YAML file: ${path.relative(workingDirectory, fullPath)}`);\n continue;\n }\n\n // Skip Maestro config files\n const basename = path.basename(fullPath, ext);\n if (basename === 'config') {\n logger.info(\n `Maestro config files are not supported yet. Skipping Maestro config file: ${path.relative(workingDirectory, fullPath)}`\n );\n continue;\n }\n\n const result = await asyncResult(parseFlowFile(fullPath));\n if (result.ok) {\n logger.info(`Found flow file: ${path.relative(workingDirectory, fullPath)}`);\n flows.push({ config: result.value, path: fullPath });\n } else {\n logger.info(\n { err: result.reason },\n `Skipping flow file: ${path.relative(workingDirectory, fullPath)}`\n );\n }\n } else if (entry.isDirectory()) {\n logger.info(\n `Default behavior excludes subdirectories. Skipping subdirectory: ${path.relative(workingDirectory, fullPath)}`\n );\n }\n }\n\n return { flows };\n}\n\nasync function parseFlowFile(filePath: string): Promise<FlowConfig> {\n const content = await fs.readFile(filePath, 'utf-8');\n const documents = yaml.parseAllDocuments(content);\n const configDoc = documents[0];\n if (!configDoc) {\n throw new Error(`No config section found in ${filePath}`);\n }\n return FlowConfigSchema.parse(configDoc.toJS());\n}\n\nfunction matchesTags({\n flowTags,\n includeTags,\n excludeTags,\n}: {\n flowTags: string[];\n includeTags: string[];\n excludeTags: string[];\n}): boolean {\n // Include logic: if includeTags is empty OR flow has any of the include tags\n const includeMatch =\n includeTags.length === 0 || includeTags.some((tag) => flowTags.includes(tag));\n\n // Exclude logic: if excludeTags is empty OR flow has none of the exclude tags\n const excludeMatch =\n excludeTags.length === 0 || !excludeTags.some((tag) => flowTags.includes(tag));\n\n return includeMatch && excludeMatch;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/build-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.199",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -51,7 +51,8 @@
|
|
|
51
51
|
"resolve-from": "^5.0.0",
|
|
52
52
|
"retry": "^0.13.1",
|
|
53
53
|
"semver": "^7.6.2",
|
|
54
|
-
"tar": "^7.4.3"
|
|
54
|
+
"tar": "^7.4.3",
|
|
55
|
+
"yaml": "^2.8.1"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@expo/repack-app": "~0.2.5",
|
|
@@ -78,5 +79,5 @@
|
|
|
78
79
|
"node": "20.14.0",
|
|
79
80
|
"yarn": "1.22.21"
|
|
80
81
|
},
|
|
81
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "ce5b578c8a33028cd68b6f29872ea6dfdbf0a4fe"
|
|
82
83
|
}
|