@radhya/mach 2.6.6 → 2.6.7
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 +155 -152
- package/docs/deep-links.md +21 -0
- package/expo-plugin/index.js +15 -12
- 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
|
@@ -40,11 +40,14 @@ const domainFromBaseUrl = value => {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const readMachConfig = config => {
|
|
43
|
+
const readMachConfig = (config, options = {}) => {
|
|
44
44
|
const projectRoot = config && config._internal && config._internal.projectRoot
|
|
45
45
|
? config._internal.projectRoot
|
|
46
46
|
: process.cwd()
|
|
47
|
-
const
|
|
47
|
+
const configuredPath = nonEmpty(options && options.machConfigPath)
|
|
48
|
+
const configPath = configuredPath
|
|
49
|
+
? path.resolve(projectRoot, configuredPath)
|
|
50
|
+
: path.join(projectRoot, 'mach.config.json')
|
|
48
51
|
if (!fs.existsSync(configPath)) return {}
|
|
49
52
|
return JSON.parse(fs.readFileSync(configPath, 'utf-8'))
|
|
50
53
|
}
|
|
@@ -98,8 +101,8 @@ const hasDomainFilter = (filter, domain) => {
|
|
|
98
101
|
return data.some(item => item && item.scheme === 'https' && item.host === domain)
|
|
99
102
|
}
|
|
100
103
|
|
|
101
|
-
const resolveDeepLinks = config => {
|
|
102
|
-
const machConfig = readMachConfig(config)
|
|
104
|
+
const resolveDeepLinks = (config, options) => {
|
|
105
|
+
const machConfig = readMachConfig(config, options)
|
|
103
106
|
const deepLinks = machConfig.deepLinks || {}
|
|
104
107
|
const profileName = deepLinks.profile || process.env.MACH_PROFILE || process.env.EAS_BUILD_PROFILE || 'production'
|
|
105
108
|
const profile = resolveBuildProfile(machConfig, profileName)
|
|
@@ -120,8 +123,8 @@ const resolveDeepLinks = config => {
|
|
|
120
123
|
return { ...deepLinks, baseUrl, domain, scheme }
|
|
121
124
|
}
|
|
122
125
|
|
|
123
|
-
const resolveOta = config => {
|
|
124
|
-
const machConfig = readMachConfig(config)
|
|
126
|
+
const resolveOta = (config, options) => {
|
|
127
|
+
const machConfig = readMachConfig(config, options)
|
|
125
128
|
const ota = machConfig.ota || machConfig.update || {}
|
|
126
129
|
if (ota.enabled === false) return { enabled: false }
|
|
127
130
|
const projectId = nonEmpty(machConfig.projectId)
|
|
@@ -138,8 +141,8 @@ const resolveOta = config => {
|
|
|
138
141
|
return { ...ota, enabled: Boolean(url), projectId, engine, url, runtimeVersion, runtimeVersionPolicy, channel }
|
|
139
142
|
}
|
|
140
143
|
|
|
141
|
-
const resolvePush = config => {
|
|
142
|
-
const machConfig = readMachConfig(config)
|
|
144
|
+
const resolvePush = (config, options) => {
|
|
145
|
+
const machConfig = readMachConfig(config, options)
|
|
143
146
|
const push = machConfig.push || {}
|
|
144
147
|
const projectRoot = projectRootForConfig(config)
|
|
145
148
|
return {
|
|
@@ -154,10 +157,10 @@ const resolvePush = config => {
|
|
|
154
157
|
}
|
|
155
158
|
}
|
|
156
159
|
|
|
157
|
-
module.exports = function withMachDeepLinks(config) {
|
|
158
|
-
const deepLinks = resolveDeepLinks(config)
|
|
159
|
-
const ota = resolveOta(config)
|
|
160
|
-
const push = resolvePush(config)
|
|
160
|
+
module.exports = function withMachDeepLinks(config, options) {
|
|
161
|
+
const deepLinks = resolveDeepLinks(config, options)
|
|
162
|
+
const ota = resolveOta(config, options)
|
|
163
|
+
const push = resolvePush(config, options)
|
|
161
164
|
|
|
162
165
|
config.extra = { ...(config.extra || {}) }
|
|
163
166
|
|