@radhya/mach 2.6.6 → 2.6.8
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.
- package/README.md +1 -1
- package/dist/index.js +160 -153
- package/docs/deep-links.md +21 -0
- package/expo-plugin/index.js +20 -13
- package/package.json +1 -1
package/docs/deep-links.md
CHANGED
|
@@ -179,6 +179,27 @@ export default {
|
|
|
179
179
|
}
|
|
180
180
|
```
|
|
181
181
|
|
|
182
|
+
### Multi-app Expo workspaces
|
|
183
|
+
|
|
184
|
+
When several separately shipped apps share one Expo `app.config.ts`, keep a **single workspace wrapper** and let it select the Mach config for the active build. Do not add one fixed plugin entry per product: every config plugin runs for every build, so a fixed Pocket entry could otherwise add Pocket links to another app.
|
|
185
|
+
|
|
186
|
+
`mach deeplink setup` still writes each product’s association files and configuration when run from that product directory. It intentionally does not inject a fixed plugin into the shared Expo root. The wrapper chooses the config using the same environment variable that chooses the product:
|
|
187
|
+
|
|
188
|
+
```js
|
|
189
|
+
const withMach = require('@radhya/mach/expo-plugin')
|
|
190
|
+
|
|
191
|
+
module.exports = (config) => {
|
|
192
|
+
const appKey = process.env.EXPO_PUBLIC_APP_KEY || 'main'
|
|
193
|
+
return withMach(config, {
|
|
194
|
+
machConfigPath: appKey === 'main'
|
|
195
|
+
? 'mach.config.json'
|
|
196
|
+
: `apps/${appKey}/mach.config.json`,
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Put that wrapper once in the root `plugins` array. Each product’s build profile must set its own selector environment value. Mach resolves the parent Expo root and that profile environment during `mach deeplink verify`, so verification checks the same app configuration that the focused build uses.
|
|
202
|
+
|
|
182
203
|
## Flutter Projects
|
|
183
204
|
|
|
184
205
|
For Flutter applications, setup makes conservative, idempotent native changes:
|
package/expo-plugin/index.js
CHANGED
|
@@ -4,6 +4,10 @@ const path = require('path')
|
|
|
4
4
|
const unique = values => Array.from(new Set(values.filter(Boolean)))
|
|
5
5
|
const nonEmpty = value => typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined
|
|
6
6
|
const first = (...values) => values.map(nonEmpty).find(Boolean)
|
|
7
|
+
const mergeScheme = (current, machScheme) => {
|
|
8
|
+
const values = unique([machScheme, ...(Array.isArray(current) ? current : [current])])
|
|
9
|
+
return values.length === 1 ? values[0] : values
|
|
10
|
+
}
|
|
7
11
|
|
|
8
12
|
const withoutRuntimeVersion = platformConfig => {
|
|
9
13
|
if (!platformConfig || typeof platformConfig !== 'object' || !Object.prototype.hasOwnProperty.call(platformConfig, 'runtimeVersion')) {
|
|
@@ -40,11 +44,14 @@ const domainFromBaseUrl = value => {
|
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
const readMachConfig = config => {
|
|
47
|
+
const readMachConfig = (config, options = {}) => {
|
|
44
48
|
const projectRoot = config && config._internal && config._internal.projectRoot
|
|
45
49
|
? config._internal.projectRoot
|
|
46
50
|
: process.cwd()
|
|
47
|
-
const
|
|
51
|
+
const configuredPath = nonEmpty(options && options.machConfigPath)
|
|
52
|
+
const configPath = configuredPath
|
|
53
|
+
? path.resolve(projectRoot, configuredPath)
|
|
54
|
+
: path.join(projectRoot, 'mach.config.json')
|
|
48
55
|
if (!fs.existsSync(configPath)) return {}
|
|
49
56
|
return JSON.parse(fs.readFileSync(configPath, 'utf-8'))
|
|
50
57
|
}
|
|
@@ -98,8 +105,8 @@ const hasDomainFilter = (filter, domain) => {
|
|
|
98
105
|
return data.some(item => item && item.scheme === 'https' && item.host === domain)
|
|
99
106
|
}
|
|
100
107
|
|
|
101
|
-
const resolveDeepLinks = config => {
|
|
102
|
-
const machConfig = readMachConfig(config)
|
|
108
|
+
const resolveDeepLinks = (config, options) => {
|
|
109
|
+
const machConfig = readMachConfig(config, options)
|
|
103
110
|
const deepLinks = machConfig.deepLinks || {}
|
|
104
111
|
const profileName = deepLinks.profile || process.env.MACH_PROFILE || process.env.EAS_BUILD_PROFILE || 'production'
|
|
105
112
|
const profile = resolveBuildProfile(machConfig, profileName)
|
|
@@ -120,8 +127,8 @@ const resolveDeepLinks = config => {
|
|
|
120
127
|
return { ...deepLinks, baseUrl, domain, scheme }
|
|
121
128
|
}
|
|
122
129
|
|
|
123
|
-
const resolveOta = config => {
|
|
124
|
-
const machConfig = readMachConfig(config)
|
|
130
|
+
const resolveOta = (config, options) => {
|
|
131
|
+
const machConfig = readMachConfig(config, options)
|
|
125
132
|
const ota = machConfig.ota || machConfig.update || {}
|
|
126
133
|
if (ota.enabled === false) return { enabled: false }
|
|
127
134
|
const projectId = nonEmpty(machConfig.projectId)
|
|
@@ -138,8 +145,8 @@ const resolveOta = config => {
|
|
|
138
145
|
return { ...ota, enabled: Boolean(url), projectId, engine, url, runtimeVersion, runtimeVersionPolicy, channel }
|
|
139
146
|
}
|
|
140
147
|
|
|
141
|
-
const resolvePush = config => {
|
|
142
|
-
const machConfig = readMachConfig(config)
|
|
148
|
+
const resolvePush = (config, options) => {
|
|
149
|
+
const machConfig = readMachConfig(config, options)
|
|
143
150
|
const push = machConfig.push || {}
|
|
144
151
|
const projectRoot = projectRootForConfig(config)
|
|
145
152
|
return {
|
|
@@ -154,10 +161,10 @@ const resolvePush = config => {
|
|
|
154
161
|
}
|
|
155
162
|
}
|
|
156
163
|
|
|
157
|
-
module.exports = function withMachDeepLinks(config) {
|
|
158
|
-
const deepLinks = resolveDeepLinks(config)
|
|
159
|
-
const ota = resolveOta(config)
|
|
160
|
-
const push = resolvePush(config)
|
|
164
|
+
module.exports = function withMachDeepLinks(config, options) {
|
|
165
|
+
const deepLinks = resolveDeepLinks(config, options)
|
|
166
|
+
const ota = resolveOta(config, options)
|
|
167
|
+
const push = resolvePush(config, options)
|
|
161
168
|
|
|
162
169
|
config.extra = { ...(config.extra || {}) }
|
|
163
170
|
|
|
@@ -213,7 +220,7 @@ module.exports = function withMachDeepLinks(config) {
|
|
|
213
220
|
|
|
214
221
|
if (!deepLinks.baseUrl || !deepLinks.domain) return config
|
|
215
222
|
|
|
216
|
-
config.scheme = deepLinks.scheme
|
|
223
|
+
config.scheme = mergeScheme(config.scheme, deepLinks.scheme)
|
|
217
224
|
config.extra.deepLinkBaseUrl = deepLinks.baseUrl
|
|
218
225
|
|
|
219
226
|
config.ios = config.ios || {}
|