From 6d6cc2a853d8590a2f849bab66bfb71acaf80018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20Kwa=C5=9Bniewski?= Date: Mon, 15 Jan 2024 11:53:57 +0100 Subject: [PATCH] feat: implement visionos cli commands (#64) --- .../react-native/local-cli/localCommands.js | 43 +++++++++++++++++++ packages/react-native/package.json | 1 + packages/react-native/react-native.config.js | 10 ++++- packages/react-native/template/package.json | 1 + yarn.lock | 2 +- 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 packages/react-native/local-cli/localCommands.js diff --git a/packages/react-native/local-cli/localCommands.js b/packages/react-native/local-cli/localCommands.js new file mode 100644 index 00000000000000..e40eeb0e29c986 --- /dev/null +++ b/packages/react-native/local-cli/localCommands.js @@ -0,0 +1,43 @@ +const { + buildOptions, + createBuild, + createLog, + createRun, + logOptions, + runOptions, +} = require('@react-native-community/cli-platform-apple'); + +const run = { + name: 'run-visionos', + description: 'builds your app and starts it on visionOS simulator', + func: createRun({platformName: 'visionos'}), + examples: [ + { + desc: 'Run on a specific simulator', + cmd: 'npx @callstack/react-native-visionos run-visionos --simulator "Apple Vision Pro"', + }, + ], + options: runOptions, +}; + +const log = { + name: 'log-visionos', + description: 'starts visionOS device syslog tail', + func: createLog({platformName: 'visionos'}), + options: logOptions, +}; + +const build = { + name: 'build-visionos', + description: 'builds your app for visionOS platform', + func: createBuild({platformName: 'visionos'}), + examples: [ + { + desc: 'Build the app for all visionOS devices in Release mode', + cmd: 'npx @callstack/react-native-visionos build-visionos --mode "Release"', + }, + ], + options: buildOptions, +}; + +module.exports = [run, log, build]; diff --git a/packages/react-native/package.json b/packages/react-native/package.json index 25ac584a8ac7f7..29aac0ef33a410 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -101,6 +101,7 @@ "@react-native-community/cli": "13.6.1", "@react-native-community/cli-platform-android": "13.6.1", "@react-native-community/cli-platform-ios": "13.6.1", + "@react-native-community/cli-platform-apple": "13.5.1", "@react-native/assets-registry": "0.75.0-main", "@react-native/codegen": "0.75.0-main", "@react-native/community-cli-plugin": "0.75.0-main", diff --git a/packages/react-native/react-native.config.js b/packages/react-native/react-native.config.js index b0f5efca15cb49..e94424bf05d555 100644 --- a/packages/react-native/react-native.config.js +++ b/packages/react-native/react-native.config.js @@ -9,7 +9,12 @@ 'use strict'; +const localCommands = require('./local-cli/localCommands'); const android = require('@react-native-community/cli-platform-android'); +const { + getDependencyConfig, + getProjectConfig, +} = require('@react-native-community/cli-platform-apple'); const ios = require('@react-native-community/cli-platform-ios'); const { bundleCommand, @@ -50,12 +55,13 @@ module.exports = { bundleCommand, startCommand, codegenCommand, + ...localCommands, ], platforms: { visionos: { npmPackageName: '@callstack/react-native-visionos', - projectConfig: ios.projectConfig, - dependencyConfig: ios.dependencyConfig, + projectConfig: getProjectConfig({platformName: 'visionos'}), + dependencyConfig: getDependencyConfig({platformName: 'visionos'}), }, ios: { projectConfig: ios.projectConfig, diff --git a/packages/react-native/template/package.json b/packages/react-native/template/package.json index 97fc4e62e64a7d..2beff04a04d6a3 100644 --- a/packages/react-native/template/package.json +++ b/packages/react-native/template/package.json @@ -5,6 +5,7 @@ "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", + "visionos": "react-native run-visionos", "lint": "eslint .", "start": "react-native start", "test": "jest" diff --git a/yarn.lock b/yarn.lock index f702dabecf3a7e..3e23c7d3aa3780 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7142,7 +7142,7 @@ metro-minify-terser@0.80.3: dependencies: terser "^5.15.0" -metro-resolver@0.80.3, metro-resolver@^0.80.3: +metro-resolver@0.80.3, metro-resolver@^0.80.0, metro-resolver@^0.80.3: version "0.80.3" resolved "https://registry.yarnpkg.com/metro-resolver/-/metro-resolver-0.80.3.tgz#f9676508583d81182c7afaabc908254dc928a345" integrity sha512-zwa0i32rj/TI3NivcvMXHJwTG2gUgo2dXdcnAJlhEKKQvyN+7AfhNdQSlDdDqMQmU7FaLRdeWORnQJbYCrprQQ==