-
Notifications
You must be signed in to change notification settings - Fork 113
/
run-ios.ts
105 lines (99 loc) · 2.46 KB
/
run-ios.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import { epilog, tryCatchWrap } from '../lib'
import {
deviceConfig,
log,
AppVersionDescriptor,
PackagePath,
getLocalIp,
} from 'ern-core'
import { runMiniApp } from 'ern-orchestrator'
import { Argv } from 'yargs'
export const command = 'run-ios'
export const desc = 'Run one or more MiniApps in the iOS Runner application'
export const builder = (argv: Argv) => {
return argv
.option('baseComposite', {
describe: 'Base Composite',
type: 'string',
})
.coerce('baseComposite', d => PackagePath.fromString(d))
.option('descriptor', {
alias: 'd',
describe: 'Full native application descriptor',
type: 'string',
})
.coerce('descriptor', d => AppVersionDescriptor.fromString(d))
.option('dev', {
default: true,
describe: 'Enable or disable React Native dev support',
type: 'boolean',
})
.option('host', {
describe: 'Host/IP to use for the local packager',
type: 'string',
})
.option('mainMiniAppName', {
describe:
'Name of the MiniApp to launch when starting the Runner application',
type: 'string',
})
.option('miniapps', {
alias: 'm',
describe: 'One or more MiniApps to combine in the Runner Container',
type: 'array',
})
.coerce('miniapps', d => d.map(PackagePath.fromString))
.option('port', {
default: '8081',
describe: 'Port to use for the local package',
type: 'string',
})
.option('usePreviousDevice', {
alias: 'u',
describe: 'Use the previously selected device to avoid prompt',
type: 'boolean',
})
.epilog(epilog(exports))
}
export const commandHandler = async ({
baseComposite,
descriptor,
dev,
host,
mainMiniAppName,
miniapps,
port,
usePreviousDevice,
}: {
baseComposite?: PackagePath
descriptor?: AppVersionDescriptor
dev?: boolean
host?: string
mainMiniAppName?: string
miniapps?: PackagePath[]
port?: string
usePreviousDevice?: boolean
}) => {
if (process.platform !== 'darwin') {
return log.error('This command can only be used on Mac OS X')
}
deviceConfig.updateDeviceConfig('ios', usePreviousDevice)
if (!host && dev) {
try {
host = getLocalIp()
} catch (e) {
// Swallow
log.debug(e)
}
}
await runMiniApp('ios', {
baseComposite,
descriptor,
dev,
host: host || 'localhost',
mainMiniAppName,
miniapps,
port,
})
}
export const handler = tryCatchWrap(commandHandler)