@radhya/mach 2.0.31 → 2.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -85,12 +85,54 @@ const resolveDeepLinks = config => {
85
85
  return { ...deepLinks, baseUrl, domain, scheme }
86
86
  }
87
87
 
88
+ const resolveOta = config => {
89
+ const machConfig = readMachConfig(config)
90
+ const ota = machConfig.ota || machConfig.update || {}
91
+ if (ota.enabled === false) return { enabled: false }
92
+ const projectId = nonEmpty(machConfig.projectId)
93
+ const engine = nonEmpty(ota.engine) || (machConfig.framework === 'expo' ? 'expo-updates' : undefined)
94
+ const url = first(
95
+ ota.url,
96
+ ota.deploymentUrl,
97
+ projectId && engine !== 'mach-react-native' ? `https://mach-api.securejs.in/api/ota/expo/${projectId}` : undefined
98
+ )
99
+ const runtimeVersion = nonEmpty(ota.runtimeVersion)
100
+ const runtimeVersionPolicy = nonEmpty(ota.runtimeVersionPolicy) || 'appVersion'
101
+ const channel = nonEmpty(ota.channel) || 'production'
102
+ return { ...ota, enabled: Boolean(url), projectId, engine, url, runtimeVersion, runtimeVersionPolicy, channel }
103
+ }
104
+
88
105
  module.exports = function withMachDeepLinks(config) {
89
106
  const deepLinks = resolveDeepLinks(config)
107
+ const ota = resolveOta(config)
108
+
109
+ config.extra = { ...(config.extra || {}) }
110
+
111
+ if (ota.enabled && ota.url) {
112
+ config.updates = {
113
+ ...(config.updates || {}),
114
+ url: ota.url,
115
+ }
116
+ if (ota.runtimeVersion) {
117
+ config.runtimeVersion = ota.runtimeVersion
118
+ } else if (!config.runtimeVersion && ota.runtimeVersionPolicy) {
119
+ config.runtimeVersion = { policy: ota.runtimeVersionPolicy }
120
+ }
121
+ config.extra.mach = {
122
+ ...(config.extra.mach || {}),
123
+ projectId: ota.projectId,
124
+ ota: {
125
+ channel: ota.channel,
126
+ url: ota.url,
127
+ runtimeVersionPolicy: ota.runtimeVersionPolicy,
128
+ },
129
+ }
130
+ }
131
+
90
132
  if (!deepLinks.baseUrl || !deepLinks.domain) return config
91
133
 
92
134
  config.scheme = deepLinks.scheme
93
- config.extra = { ...(config.extra || {}), deepLinkBaseUrl: deepLinks.baseUrl }
135
+ config.extra.deepLinkBaseUrl = deepLinks.baseUrl
94
136
 
95
137
  config.ios = config.ios || {}
96
138
  config.ios.associatedDomains = unique([
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@radhya/mach",
3
- "version": "2.0.31",
3
+ "version": "2.0.33",
4
4
  "description": "Mach CLI: Cloud Build Orchestrator for React Native & Expo",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",