@@ -13,9 +13,14 @@ import {
1313 ANDROID_APP_BUNDLE_SIGNING_ERROR_MESSAGE ,
1414 ANDROID_RELEASE_BUILD_ERROR_MESSAGE ,
1515} from "../constants" ;
16- import { IOptions , IPlatformValidationService } from "../declarations" ;
16+ import {
17+ IOpener ,
18+ IOptions ,
19+ IPlatformValidationService ,
20+ } from "../declarations" ;
1721import { IMigrateController } from "../definitions/migrate" ;
1822import { IProjectData , IProjectDataService } from "../definitions/project" ;
23+ import { IBuildController , IBuildDataService } from "../definitions/build" ;
1924
2025export class RunCommandBase implements ICommand {
2126 private liveSyncCommandHelperAdditionalOptions : ILiveSyncCommandHelperAdditionalOptions =
@@ -223,3 +228,65 @@ export class RunVisionOSCommand extends RunIosCommand {
223228
224229injector . registerCommand ( "run|vision" , RunVisionOSCommand ) ;
225230injector . registerCommand ( "run|visionos" , RunVisionOSCommand ) ;
231+
232+ export class RunMacOSCommand implements ICommand {
233+ public allowedParameters : ICommandParameter [ ] = [ ] ;
234+
235+ public get platform ( ) : string {
236+ return this . $devicePlatformsConstants . macOS || "macOS" ;
237+ }
238+
239+ constructor (
240+ private $buildController : IBuildController ,
241+ private $buildDataService : IBuildDataService ,
242+ private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
243+ private $errors : IErrors ,
244+ private $migrateController : IMigrateController ,
245+ private $opener : IOpener ,
246+ private $options : IOptions ,
247+ private $platformValidationService : IPlatformValidationService ,
248+ private $projectDataService : IProjectDataService ,
249+ ) { }
250+
251+ public async execute ( args : string [ ] ) : Promise < void > {
252+ const projectData = this . $projectDataService . getProjectData ( ) ;
253+ const buildData = this . $buildDataService . getBuildData (
254+ projectData . projectDir ,
255+ this . platform . toLowerCase ( ) ,
256+ this . $options ,
257+ ) ;
258+ const outputPath = await this . $buildController . prepareAndBuild ( buildData ) ;
259+ await this . $opener . open ( outputPath , projectData . projectName ) ;
260+ }
261+
262+ public async canExecute ( args : string [ ] ) : Promise < boolean > {
263+ const projectData = this . $projectDataService . getProjectData ( ) ;
264+
265+ if (
266+ ! this . $platformValidationService . isPlatformSupportedForOS (
267+ this . platform ,
268+ projectData ,
269+ )
270+ ) {
271+ this . $errors . fail (
272+ `Applications for platform ${ this . platform } can not be built on this OS` ,
273+ ) ;
274+ }
275+
276+ if ( ! this . $options . force ) {
277+ await this . $migrateController . validate ( {
278+ projectDir : projectData . projectDir ,
279+ platforms : [ this . platform ] ,
280+ } ) ;
281+ }
282+
283+ return this . $platformValidationService . validateOptions (
284+ this . $options . provision ,
285+ this . $options . teamId ,
286+ projectData ,
287+ this . platform . toLowerCase ( ) ,
288+ ) ;
289+ }
290+ }
291+
292+ injector . registerCommand ( "run|macos" , RunMacOSCommand ) ;
0 commit comments