Skip to content

Commit

Permalink
Upload the ipa files for the iOS platform
Browse files Browse the repository at this point in the history
Signed-off-by: Serhii Manko <mankoffserg@gmail.com>
  • Loading branch information
mankoffs authored and koral-- committed Sep 20, 2022
1 parent 878171e commit 8eac36a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 22 deletions.
3 changes: 3 additions & 0 deletions res/app/components/stf/app-state/app-state-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module.exports = function AppStateProvider() {
},
user: {
settings: {}
},
device: {
platform: ''
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,15 @@ module.exports = function EnhanceDeviceServiceFactory($filter, AppState) {
return url
}

function enhanceDeviceAppState(device) {
AppState.device.platform = device.platform
}

service.enhance = function(device) {
setState(device)
enhanceDevice(device)
enhanceDeviceDetails(device)
enhanceDeviceAppState(device)
}

return service
Expand Down
58 changes: 36 additions & 22 deletions res/app/components/stf/install/install-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = function InstallService(
, $http
, $filter
, StorageService
, AppState
) {
var installService = Object.create(null)

Expand Down Expand Up @@ -71,9 +72,9 @@ module.exports = function InstallService(
installation.update(uploadResult.progress / 2, uploadResult.lastData)
installation.manifest = uploadResult.body
return control.install({
href: installation.href
, manifest: installation.manifest
, launch: installation.launch
href: installation.href,
manifest: installation.manifest,
launch: installation.launch
})
.progressed(function(result) {
installation.update(50 + result.progress / 2, result.lastData)
Expand All @@ -89,12 +90,13 @@ module.exports = function InstallService(

installService.installFile = function(control, $files) {
var installation = new Installation('uploading')
let isIOSPlatform = AppState.device.platform === 'iOS'
$rootScope.$broadcast('installation', installation)
return StorageService.storeFile('apk', $files, {
filter: function(file) {
return /\.(apk|aab)$/i.test(file.name)
return isIOSPlatform ? /\.(ipa)$/i.test(file.name) : /\.(apk|aab)$/i.test(file.name)
}
})
})
.progressed(function(e) {
if (e.lengthComputable) {
installation.update(e.loaded / e.total * 100 / 2, 'uploading')
Expand All @@ -103,31 +105,43 @@ module.exports = function InstallService(
.then(function(res) {
installation.update(100 / 2, 'processing')
installation.href = res.data.resources.file.href
return $http.get(installation.href + '/manifest')
.then(function(res) {
if (res.data.success) {
installation.manifest = res.data.manifest
return control.install({
href: installation.href
, manifest: installation.manifest
, launch: installation.launch
})
.progressed(function(result) {
installation.update(50 + result.progress / 2, result.lastData)
})
}
else {
throw new Error('Unable to retrieve manifest')
}
if(isIOSPlatform) {
installation.manifest = {'application': {'activities': {}}}
return control.install({
href: installation.href,
manifest: installation.manifest,
launch: installation.launch
})
.progressed(function(result) {
installation.update(50 + result.progress / 2, result.lastData)
})
} else {
return $http.get(installation.href + '/manifest')
.then(function(res) {
if (res.data.success) {
installation.manifest = res.data.manifest
return control.install({
href: installation.href,
manifest: installation.manifest,
launch: installation.launch
})
.progressed(function(result) {
installation.update(50 + result.progress / 2, result.lastData)
})
}
else {
throw new Error('Unable to retrieve manifest')
}
})
}
})
.then(function() {
installation.okay('installed')
})
.catch(function(err) {
installation.fail(err.code || err.message)
})
}
}

return installService
}

0 comments on commit 8eac36a

Please sign in to comment.