-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
90 lines (75 loc) · 3.53 KB
/
index.js
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
var exec = require('child_process').exec
module.exports = produce
function produce (options, cb) {
if (typeof options === 'function') {
cb = options
options = {}
}
options = options || {}
cb = cb || function () {}
options.timeout = options.timeout !== undefined ? options.timeout : 0
var cmd = 'produce'
if (options.create) cmd += ' create'
if (options.skipItc) cmd += ' -i'
if (options.skipDevCenter) cmd += ' -d'
if (options.user) cmd += ` -u ${options.user}`
if (options.identifier) cmd += ` -a ${options.identifier}`
if (options.suffix) cmd += ` -e ${options.suffix}`
if (options.name) cmd += ` -q ${options.name}`
if (options.version) cmd += ` -z ${options.version}`
if (options.sku) cmd += ` -y ${options.sku}`
if (options.language) cmd += ` -m ${options.language}`
if (options.company) cmd += ` -c ${options.company}`
if (options.teamId) cmd += ` -b ${options.teamId}`
if (options.teamName) cmd += ` -l ${options.teamName}`
if (options.createAppGroup && options.createAppGroup.name) {
cmd += ` group -g ${options.createAppGroup.name}`
if (options.createAppGroup.description) cmd += ` -n '${options.createAppGroup.description}'`
}
if (options.associateGroup && options.associateGroup.app && options.associateGroup.group) {
cmd += ` associate_group -a ${options.associateGroup.app} '${options.associateGroup.group}'`
}
var services = [ 'app-group', 'associated-domains', 'data-protection', 'healthkit',
'homekit', 'wireless-conf', 'icloud', 'inter-app-audio', 'passbook', 'push-notification', 'vpn-conf' ]
if (options.enableServices) {
var enableServices = options.enableServices.map((option) => {
if (typeof option === 'string' && ~services.indexOf(option)) {
return { service: option }
}
else if (typeof option === 'object' && option.value !== false && ~services.indexOf(option.service)) {
return option
}
}).filter((option) => {
return option !== undefined
})
cmd += ' enable_services'
enableServices.forEach((option) => {
switch (option.service) {
case 'data-protection':
cmd += ` --data-protection ${option.value || 'complete'}`
break
case 'icloud':
cmd += ` --icloud ${option.value || 'cloudkit'}`
break
default:
cmd += ` --${option.service}`
break
}
})
}
if (options.disableServices) {
cmd += ' disable_services'
options.disableServices.forEach((option) => {
console.log(option, typeof option, option.value !== false, ~services.indexOf(option.service))
if (typeof option === 'string' && ~services.indexOf(option)) cmd += ` --${option}`
else if (typeof option === 'object' && option.value !== false && ~services.indexOf(option.service)) cmd += ` --${option.service}`
})
}
var runtimeOptions = { env: Object.assign({}, process.env) }
if (options.timeout) runtimeOptions.timeout = options.timeout
if (options.password) runtimeOptions.env.FASTLANE_PASSWORD = options.password
if (options.path) runtimeOptions.cwd = options.path
exec(cmd, runtimeOptions, (err, stdout, stderr) => {
cb(err, { stdout, stderr })
})
}