|
| 1 | +import type { PluginOutput, PluginApi } from '@callstack/rnef-config'; |
| 2 | +import { |
| 3 | + createBuild, |
| 4 | + createRun, |
| 5 | + getRunOptions, |
| 6 | + getBuildOptions, |
| 7 | + RunFlags, |
| 8 | + BuildFlags, |
| 9 | +} from '@callstack/rnef-plugin-platform-apple'; |
| 10 | +import { getProjectConfig } from '@react-native-community/cli-config-apple'; |
| 11 | + |
| 12 | +const projectConfig = getProjectConfig({ platformName: 'visionos' }); |
| 13 | +const buildOptions = getBuildOptions({ platformName: 'visionos' }); |
| 14 | +const runOptions = getRunOptions({ platformName: 'visionos' }); |
| 15 | + |
| 16 | +export const pluginPlatformVisionOS = |
| 17 | + () => |
| 18 | + (api: PluginApi): PluginOutput => { |
| 19 | + api.registerCommand({ |
| 20 | + name: 'build:visionos', |
| 21 | + description: 'Build visionOS app.', |
| 22 | + action: async (args) => { |
| 23 | + const projectRoot = api.getProjectRoot(); |
| 24 | + const config = projectConfig(projectRoot, {}); |
| 25 | + |
| 26 | + if (config) { |
| 27 | + await createBuild('visionos', config, args as BuildFlags); |
| 28 | + } else { |
| 29 | + throw new Error('visionOS project not found.'); |
| 30 | + } |
| 31 | + }, |
| 32 | + options: buildOptions, |
| 33 | + }); |
| 34 | + |
| 35 | + api.registerCommand({ |
| 36 | + name: 'run:visionos', |
| 37 | + description: 'Run visionOS app.', |
| 38 | + action: async (args) => { |
| 39 | + const projectRoot = api.getProjectRoot(); |
| 40 | + const config = projectConfig(projectRoot, {}); |
| 41 | + |
| 42 | + if (config) { |
| 43 | + await createRun('visionos', config, args as RunFlags, projectRoot); |
| 44 | + } else { |
| 45 | + throw new Error('visionOS project not found.'); |
| 46 | + } |
| 47 | + }, |
| 48 | + // @ts-expect-error: fix `simulator` is not defined in `RunFlags` |
| 49 | + options: runOptions, |
| 50 | + }); |
| 51 | + |
| 52 | + return { |
| 53 | + name: 'plugin-platform-visionos', |
| 54 | + description: 'RNEF plugin for everything visionOS.', |
| 55 | + }; |
| 56 | + }; |
| 57 | + |
| 58 | +export default pluginPlatformVisionOS; |
0 commit comments