Skip to content

Commit 0be7484

Browse files
authored
feat: refactor and expose remote cache provider (#260)
* refactor: remote cache provider * update * remove console * fixup * rename * cleanup * fixup * simplify finding binaries * changeset * use simulator fallback * inline
1 parent 86522ec commit 0be7484

File tree

16 files changed

+227
-390
lines changed

16 files changed

+227
-390
lines changed

.changeset/famous-tips-lie.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@rnef/platform-apple-helpers': patch
3+
'@rnef/platform-android': patch
4+
'@rnef/config': patch
5+
'@rnef/tools': patch
6+
---
7+
8+
feat: refactor and expose remote cache provider

packages/config/src/lib/schema.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,18 @@ const ConfigTypeSchema = Joi.object({
4040
plugins: Joi.array().items(Joi.function()).optional(),
4141
platforms: Joi.object().pattern(Joi.string(), Joi.function()).optional(),
4242
commands: Joi.array().items(CommandTypeSchema).optional(),
43-
remoteCacheProvider: Joi.string().valid('github-actions', null).optional(),
43+
remoteCacheProvider: Joi.string()
44+
.valid('github-actions', null, Joi.function())
45+
.optional(),
4446
fingerprint: Joi.object({
4547
extraSources: Joi.array().items(Joi.string()).default([]),
4648
ignorePaths: Joi.array().items(Joi.string()).default([]),
47-
}).default({
48-
extraSources: [],
49-
ignorePaths: [],
50-
}).optional(),
49+
})
50+
.default({
51+
extraSources: [],
52+
ignorePaths: [],
53+
})
54+
.optional(),
5155
}).unknown(false);
5256

5357
export { ConfigTypeSchema };

packages/platform-android/src/lib/commands/runAndroid/fetchCachedBuild.ts

Lines changed: 0 additions & 127 deletions
This file was deleted.

packages/platform-android/src/lib/commands/runAndroid/runAndroid.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import type {
66
} from '@react-native-community/cli-types';
77
import type { SupportedRemoteCacheProviders } from '@rnef/tools';
88
import {
9+
fetchCachedBuild,
10+
formatArtifactName,
911
intro,
1012
isInteractive,
1113
logger,
@@ -18,7 +20,6 @@ import { options } from '../buildAndroid/buildAndroid.js';
1820
import { runGradle } from '../runGradle.js';
1921
import { toPascalCase } from '../toPascalCase.js';
2022
import { getDevices } from './adb.js';
21-
import { fetchCachedBuild } from './fetchCachedBuild.js';
2223
import type { DeviceData } from './listAndroidDevices.js';
2324
import { listAndroidDevices } from './listAndroidDevices.js';
2425
import { tryInstallAppOnDevice } from './tryInstallAppOnDevice.js';
@@ -59,12 +60,16 @@ export async function runAndroid(
5960
const tasks = args.tasks ?? [`${mainTaskType}${toPascalCase(args.variant)}`];
6061

6162
if (!args.binaryPath && args.remoteCache) {
62-
const cachedBuild = await fetchCachedBuild({
63-
variant: args.variant,
64-
remoteCacheProvider,
63+
const artifactName = await formatArtifactName({
64+
platform: 'android',
65+
traits: [args.variant],
6566
root: projectRoot,
6667
fingerprintOptions,
6768
});
69+
const cachedBuild = await fetchCachedBuild({
70+
artifactName,
71+
remoteCacheProvider,
72+
});
6873
if (cachedBuild) {
6974
// @todo replace with a more generic way to pass binary path
7075
args.binaryPath = cachedBuild.binaryPath;

packages/platform-apple-helpers/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"adm-zip": "^0.5.16",
2222
"fast-glob": "^3.3.2",
2323
"fast-xml-parser": "^4.5.0",
24-
"tar": "^7.4.3",
2524
"tslib": "^2.3.0"
2625
},
2726
"devDependencies": {

packages/platform-apple-helpers/src/lib/commands/run/createRun.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import path from 'node:path';
33
import type { SupportedRemoteCacheProviders } from '@rnef/tools';
44
import {
55
color,
6+
fetchCachedBuild,
7+
formatArtifactName,
68
isInteractive,
79
logger,
810
promptSelect,
@@ -21,7 +23,6 @@ import {
2123
getSimulatorPlatformSDK,
2224
} from '../../utils/getPlatformInfo.js';
2325
import { listDevicesAndSimulators } from '../../utils/listDevices.js';
24-
import { fetchCachedBuild } from './fetchCachedBuild.js';
2526
import { matchingDevice } from './matchingDevice.js';
2627
import { cacheRecentDevice, sortByRecentDevices } from './recentDevices.js';
2728
import { runOnDevice } from './runOnDevice.js';
@@ -39,13 +40,16 @@ export const createRun = async (
3940
fingerprintOptions: { extraSources: string[]; ignorePaths: string[] }
4041
) => {
4142
if (!args.binaryPath && args.remoteCache) {
42-
const cachedBuild = await fetchCachedBuild({
43-
configuration: args.configuration ?? 'Debug',
44-
distribution: args.destination ?? 'simulator',
45-
remoteCacheProvider,
43+
const artifactName = await formatArtifactName({
44+
platform: 'ios',
45+
traits: [args.destination ?? 'simulator', args.configuration ?? 'Debug'],
4646
root: projectRoot,
4747
fingerprintOptions,
4848
});
49+
const cachedBuild = await fetchCachedBuild({
50+
artifactName,
51+
remoteCacheProvider,
52+
});
4953
if (cachedBuild) {
5054
// @todo replace with a more generic way to pass binary path
5155
args.binaryPath = cachedBuild.binaryPath;

0 commit comments

Comments
 (0)