expo-modules-autolinking 3.0.0 → 3.0.2
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/CHANGELOG.md +16 -0
- package/build/autolinking/findModules.d.ts +11 -5
- package/build/autolinking/findModules.js +8 -16
- package/build/autolinking/findModules.js.map +1 -1
- package/build/autolinking/generatePackageList.d.ts +16 -10
- package/build/autolinking/generatePackageList.js +13 -28
- package/build/autolinking/generatePackageList.js.map +1 -1
- package/build/autolinking/getConfiguration.d.ts +9 -2
- package/build/autolinking/getConfiguration.js +9 -4
- package/build/autolinking/getConfiguration.js.map +1 -1
- package/build/autolinking/index.d.ts +22 -17
- package/build/autolinking/index.js +23 -47
- package/build/autolinking/index.js.map +1 -1
- package/build/autolinking/resolveModules.d.ts +13 -9
- package/build/autolinking/resolveModules.js +21 -18
- package/build/autolinking/resolveModules.js.map +1 -1
- package/build/commands/autolinkingOptions.d.ts +50 -0
- package/build/commands/autolinkingOptions.js +168 -0
- package/build/commands/autolinkingOptions.js.map +1 -0
- package/build/commands/generateModulesProviderCommand.d.ts +3 -0
- package/build/commands/generateModulesProviderCommand.js +35 -0
- package/build/commands/generateModulesProviderCommand.js.map +1 -0
- package/build/commands/generatePackageListCommand.d.ts +6 -0
- package/build/commands/generatePackageListCommand.js +39 -0
- package/build/commands/generatePackageListCommand.js.map +1 -0
- package/build/commands/reactNativeConfigCommand.d.ts +3 -0
- package/build/commands/reactNativeConfigCommand.js +36 -0
- package/build/commands/reactNativeConfigCommand.js.map +1 -0
- package/build/commands/resolveCommand.d.ts +3 -0
- package/build/commands/resolveCommand.js +63 -0
- package/build/commands/resolveCommand.js.map +1 -0
- package/build/commands/searchCommand.d.ts +2 -0
- package/build/commands/searchCommand.js +27 -0
- package/build/commands/searchCommand.js.map +1 -0
- package/build/{autolinking/verifySearchResults.d.ts → commands/verifyCommand.d.ts} +4 -2
- package/build/{autolinking/verifySearchResults.js → commands/verifyCommand.js} +24 -3
- package/build/commands/verifyCommand.js.map +1 -0
- package/build/dependencies/CachedDependenciesLinker.d.ts +2 -1
- package/build/dependencies/CachedDependenciesLinker.js +23 -9
- package/build/dependencies/CachedDependenciesLinker.js.map +1 -1
- package/build/exports.d.ts +17 -1
- package/build/exports.js +48 -1
- package/build/exports.js.map +1 -1
- package/build/index.js +18 -162
- package/build/index.js.map +1 -1
- package/build/platforms/{android.d.ts → android/android.d.ts} +7 -2
- package/build/platforms/{android.js → android/android.js} +1 -5
- package/build/platforms/android/android.js.map +1 -0
- package/build/platforms/android/index.d.ts +1 -0
- package/build/platforms/android/index.js +9 -0
- package/build/platforms/android/index.js.map +1 -0
- package/build/platforms/{apple.d.ts → apple/apple.d.ts} +6 -6
- package/build/platforms/{apple.js → apple/apple.js} +5 -7
- package/build/platforms/apple/apple.js.map +1 -0
- package/build/platforms/apple/index.d.ts +1 -0
- package/build/platforms/apple/index.js +8 -0
- package/build/platforms/apple/index.js.map +1 -0
- package/build/platforms/index.d.ts +15 -0
- package/build/{autolinking/utils.js → platforms/index.js} +6 -1
- package/build/platforms/index.js.map +1 -0
- package/build/reactNativeConfig/reactNativeConfig.d.ts +11 -2
- package/build/reactNativeConfig/reactNativeConfig.js +13 -15
- package/build/reactNativeConfig/reactNativeConfig.js.map +1 -1
- package/build/reactNativeConfig/reactNativeConfig.types.d.ts +4 -33
- package/build/reactNativeConfig/reactNativeConfig.types.js.map +1 -1
- package/build/types.d.ts +1 -58
- package/build/types.js.map +1 -1
- package/package.json +3 -3
- package/src/autolinking/findModules.ts +18 -16
- package/src/autolinking/generatePackageList.ts +30 -31
- package/src/autolinking/getConfiguration.ts +16 -5
- package/src/autolinking/index.ts +48 -41
- package/src/autolinking/resolveModules.ts +47 -34
- package/src/commands/autolinkingOptions.ts +265 -0
- package/src/commands/generateModulesProviderCommand.ts +60 -0
- package/src/commands/generatePackageListCommand.ts +67 -0
- package/src/commands/reactNativeConfigCommand.ts +50 -0
- package/src/commands/resolveCommand.ts +101 -0
- package/src/commands/searchCommand.ts +35 -0
- package/src/{autolinking/verifySearchResults.ts → commands/verifyCommand.ts} +48 -6
- package/src/dependencies/CachedDependenciesLinker.ts +30 -12
- package/src/exports.ts +65 -0
- package/src/index.ts +18 -286
- package/src/platforms/{android.ts → android/android.ts} +10 -12
- package/src/platforms/android/index.ts +6 -0
- package/src/platforms/{apple.ts → apple/apple.ts} +10 -11
- package/src/platforms/apple/index.ts +5 -0
- package/src/platforms/index.ts +49 -0
- package/src/reactNativeConfig/reactNativeConfig.ts +25 -28
- package/src/reactNativeConfig/reactNativeConfig.types.ts +4 -35
- package/src/types.ts +10 -70
- package/build/autolinking/mergeLinkingOptions.d.ts +0 -27
- package/build/autolinking/mergeLinkingOptions.js +0 -112
- package/build/autolinking/mergeLinkingOptions.js.map +0 -1
- package/build/autolinking/utils.d.ts +0 -2
- package/build/autolinking/utils.js.map +0 -1
- package/build/autolinking/verifySearchResults.js.map +0 -1
- package/build/platforms/android.js.map +0 -1
- package/build/platforms/apple.js.map +0 -1
- package/src/autolinking/mergeLinkingOptions.ts +0 -146
- package/src/autolinking/utils.ts +0 -15
package/src/index.ts
CHANGED
|
@@ -1,293 +1,25 @@
|
|
|
1
1
|
import commander from 'commander';
|
|
2
|
-
import path from 'path';
|
|
3
2
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
mergeLinkingOptionsAsync,
|
|
11
|
-
resolveExtraBuildDependenciesAsync,
|
|
12
|
-
resolveModulesAsync,
|
|
13
|
-
verifySearchResults,
|
|
14
|
-
} from './autolinking';
|
|
15
|
-
import {
|
|
16
|
-
makeCachedDependenciesLinker,
|
|
17
|
-
mergeResolutionResults,
|
|
18
|
-
scanDependencyResolutionsForPlatform,
|
|
19
|
-
} from './dependencies';
|
|
20
|
-
import { type RNConfigCommandOptions, createReactNativeConfigAsync } from './reactNativeConfig';
|
|
21
|
-
import type {
|
|
22
|
-
ModuleDescriptor,
|
|
23
|
-
CommonNativeModuleDescriptor,
|
|
24
|
-
GenerateModulesProviderOptions,
|
|
25
|
-
GenerateOptions,
|
|
26
|
-
ResolveOptions,
|
|
27
|
-
SearchOptions,
|
|
28
|
-
SearchResults,
|
|
29
|
-
ModuleDescriptorAndroid,
|
|
30
|
-
ModuleDescriptorIos,
|
|
31
|
-
} from './types';
|
|
3
|
+
import { generateModulesProviderCommand } from './commands/generateModulesProviderCommand';
|
|
4
|
+
import { generatePackageListCommand } from './commands/generatePackageListCommand';
|
|
5
|
+
import { reactNativeConfigCommand } from './commands/reactNativeConfigCommand';
|
|
6
|
+
import { resolveCommand } from './commands/resolveCommand';
|
|
7
|
+
import { searchCommand } from './commands/searchCommand';
|
|
8
|
+
import { verifyCommand } from './commands/verifyCommand';
|
|
32
9
|
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Registers a command that only searches for available expo modules.
|
|
41
|
-
*/
|
|
42
|
-
function registerSearchCommand<OptionsType extends SearchOptions>(
|
|
43
|
-
commandName: string,
|
|
44
|
-
fn: (search: SearchResults, options: OptionsType) => any
|
|
45
|
-
) {
|
|
46
|
-
return commander
|
|
47
|
-
.command(`${commandName} [paths...]`)
|
|
48
|
-
.option<string[] | null>(
|
|
49
|
-
'-i, --ignore-paths <ignorePaths...>',
|
|
50
|
-
'Paths to ignore when looking up for modules.',
|
|
51
|
-
(value, previous) => (previous ?? []).concat(value)
|
|
52
|
-
)
|
|
53
|
-
.option<string[] | null>(
|
|
54
|
-
'-e, --exclude <exclude...>',
|
|
55
|
-
'Package names to exclude when looking up for modules.',
|
|
56
|
-
(value, previous) => (previous ?? []).concat(value)
|
|
57
|
-
)
|
|
58
|
-
.option(
|
|
59
|
-
'-p, --platform [platform]',
|
|
60
|
-
'The platform that the resulting modules must support. Available options: "apple", "android"',
|
|
61
|
-
'apple'
|
|
62
|
-
)
|
|
63
|
-
.option('--silent', 'Silence resolution warnings')
|
|
64
|
-
.addOption(
|
|
65
|
-
new commander.Option(
|
|
66
|
-
'--project-root <projectRoot>',
|
|
67
|
-
'The path to the root of the project'
|
|
68
|
-
).default(process.cwd(), 'process.cwd()')
|
|
69
|
-
)
|
|
70
|
-
.option(
|
|
71
|
-
'--only-project-deps',
|
|
72
|
-
'For a monorepo, include only modules that are the project dependencies.',
|
|
73
|
-
true
|
|
74
|
-
)
|
|
75
|
-
.option('--no-only-project-deps', 'Opposite of --only-project-deps', false)
|
|
76
|
-
.action(async (searchPaths, providedOptions) => {
|
|
77
|
-
const options = await mergeLinkingOptionsAsync<OptionsType>(
|
|
78
|
-
searchPaths.length > 0
|
|
79
|
-
? {
|
|
80
|
-
...providedOptions,
|
|
81
|
-
searchPaths,
|
|
82
|
-
}
|
|
83
|
-
: providedOptions
|
|
84
|
-
);
|
|
85
|
-
const searchResults = await findModulesAsync(options);
|
|
86
|
-
return await fn(searchResults, options);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Registers a command that searches for modules and then resolves them for specific platform.
|
|
92
|
-
*/
|
|
93
|
-
function registerResolveCommand<OptionsType extends ResolveOptions>(
|
|
94
|
-
commandName: string,
|
|
95
|
-
fn: (search: SearchResults, options: OptionsType) => any
|
|
96
|
-
) {
|
|
97
|
-
return registerSearchCommand<OptionsType>(commandName, fn);
|
|
98
|
-
}
|
|
10
|
+
async function main(args: string[]) {
|
|
11
|
+
const cli = commander
|
|
12
|
+
.version(require('expo-modules-autolinking/package.json').version)
|
|
13
|
+
.description('CLI command that searches for native modules to autolink them.');
|
|
99
14
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
.option(
|
|
107
|
-
'-p, --platform [platform]',
|
|
108
|
-
'The platform that the resulting modules must support. Available options: "android", "ios"',
|
|
109
|
-
'ios'
|
|
110
|
-
)
|
|
111
|
-
.addOption(
|
|
112
|
-
new commander.Option(
|
|
113
|
-
'--project-root <projectRoot>',
|
|
114
|
-
'The path to the root of the project'
|
|
115
|
-
).default(process.cwd(), 'process.cwd()')
|
|
116
|
-
)
|
|
117
|
-
.option('--source-dir <sourceDir>', 'The path to the native source directory')
|
|
118
|
-
.option<boolean>('-j, --json', 'Output results in the plain JSON format.', () => true, false)
|
|
119
|
-
.action(async (searchPaths, providedOptions) => {
|
|
120
|
-
if (!['android', 'ios'].includes(providedOptions.platform)) {
|
|
121
|
-
throw new Error(`Unsupported platform: ${providedOptions.platform}`);
|
|
122
|
-
}
|
|
123
|
-
const projectRoot = path.dirname(
|
|
124
|
-
await getProjectPackageJsonPathAsync(providedOptions.projectRoot)
|
|
125
|
-
);
|
|
126
|
-
const options = await mergeLinkingOptionsAsync<RNConfigCommandOptions>(
|
|
127
|
-
searchPaths.length > 0
|
|
128
|
-
? {
|
|
129
|
-
...providedOptions,
|
|
130
|
-
projectRoot,
|
|
131
|
-
searchPaths,
|
|
132
|
-
}
|
|
133
|
-
: {
|
|
134
|
-
...providedOptions,
|
|
135
|
-
projectRoot,
|
|
136
|
-
}
|
|
137
|
-
);
|
|
138
|
-
const results = await createReactNativeConfigAsync(options);
|
|
139
|
-
if (providedOptions.json) {
|
|
140
|
-
console.log(JSON.stringify(results));
|
|
141
|
-
} else {
|
|
142
|
-
console.log(require('util').inspect(results, false, null, true));
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
}
|
|
15
|
+
verifyCommand(cli);
|
|
16
|
+
searchCommand(cli);
|
|
17
|
+
resolveCommand(cli);
|
|
18
|
+
generatePackageListCommand(cli);
|
|
19
|
+
generateModulesProviderCommand(cli);
|
|
20
|
+
reactNativeConfigCommand(cli);
|
|
146
21
|
|
|
147
|
-
|
|
148
|
-
Register the `verify` command.
|
|
149
|
-
*/
|
|
150
|
-
function registerVerifyCommand() {
|
|
151
|
-
return commander
|
|
152
|
-
.command('verify')
|
|
153
|
-
.option(
|
|
154
|
-
'-p, --platform [platform]',
|
|
155
|
-
'The platform to validate native modules for. Available options: "android", "ios", "both"',
|
|
156
|
-
'both'
|
|
157
|
-
)
|
|
158
|
-
.addOption(
|
|
159
|
-
new commander.Option(
|
|
160
|
-
'--project-root <projectRoot>',
|
|
161
|
-
'The path to the root of the project'
|
|
162
|
-
).default(process.cwd(), 'process.cwd()')
|
|
163
|
-
)
|
|
164
|
-
.option<boolean>(
|
|
165
|
-
'-v, --verbose',
|
|
166
|
-
'Output all results instead of just warnings.',
|
|
167
|
-
() => true,
|
|
168
|
-
false
|
|
169
|
-
)
|
|
170
|
-
.option<boolean>('-j, --json', 'Output results in the plain JSON format.', () => true, false)
|
|
171
|
-
.action(async (providedOptions) => {
|
|
172
|
-
const platforms =
|
|
173
|
-
providedOptions.platform === 'both' ? ['android', 'ios'] : [providedOptions.platform];
|
|
174
|
-
const linker = makeCachedDependenciesLinker({ projectRoot: providedOptions.projectRoot });
|
|
175
|
-
const results = mergeResolutionResults(
|
|
176
|
-
await Promise.all(
|
|
177
|
-
platforms.map((platform) => scanDependencyResolutionsForPlatform(linker, platform))
|
|
178
|
-
)
|
|
179
|
-
);
|
|
180
|
-
await verifySearchResults(results, {
|
|
181
|
-
projectRoot: providedOptions.projectRoot,
|
|
182
|
-
verbose: providedOptions.verbose,
|
|
183
|
-
json: providedOptions.json,
|
|
184
|
-
});
|
|
185
|
-
});
|
|
22
|
+
await cli.parseAsync(args, { from: 'user' });
|
|
186
23
|
}
|
|
187
24
|
|
|
188
|
-
module.exports =
|
|
189
|
-
// Searches for available expo modules.
|
|
190
|
-
registerSearchCommand<SearchOptions & { json?: boolean }>('search', async (results, options) => {
|
|
191
|
-
if (options.json) {
|
|
192
|
-
console.log(JSON.stringify(results));
|
|
193
|
-
} else {
|
|
194
|
-
console.log(require('util').inspect(results, false, null, true));
|
|
195
|
-
}
|
|
196
|
-
}).option<boolean>('-j, --json', 'Output results in the plain JSON format.', () => true, false);
|
|
197
|
-
|
|
198
|
-
// Checks whether there are no resolving issues in the current setup.
|
|
199
|
-
registerVerifyCommand();
|
|
200
|
-
|
|
201
|
-
// Searches for available expo modules and resolves the results for given platform.
|
|
202
|
-
registerResolveCommand('resolve', async (results, options) => {
|
|
203
|
-
const modules = await resolveModulesAsync(results, options);
|
|
204
|
-
const extraDependencies = await resolveExtraBuildDependenciesAsync(options);
|
|
205
|
-
const configuration = getConfiguration(options);
|
|
206
|
-
|
|
207
|
-
const coreFeatures = [
|
|
208
|
-
...modules.reduce<Set<string>>((acc, module) => {
|
|
209
|
-
if (hasCoreFeatures(module)) {
|
|
210
|
-
const features = module.coreFeatures ?? [];
|
|
211
|
-
for (const feature of features) {
|
|
212
|
-
acc.add(feature);
|
|
213
|
-
}
|
|
214
|
-
return acc;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return acc;
|
|
218
|
-
}, new Set()),
|
|
219
|
-
];
|
|
220
|
-
if (options.json) {
|
|
221
|
-
console.log(
|
|
222
|
-
JSON.stringify({
|
|
223
|
-
extraDependencies,
|
|
224
|
-
coreFeatures,
|
|
225
|
-
modules,
|
|
226
|
-
...(configuration ? { configuration } : {}),
|
|
227
|
-
})
|
|
228
|
-
);
|
|
229
|
-
} else {
|
|
230
|
-
console.log(
|
|
231
|
-
require('util').inspect(
|
|
232
|
-
{
|
|
233
|
-
extraDependencies,
|
|
234
|
-
coreFeatures,
|
|
235
|
-
modules,
|
|
236
|
-
...(configuration ? { configuration } : {}),
|
|
237
|
-
},
|
|
238
|
-
false,
|
|
239
|
-
null,
|
|
240
|
-
true
|
|
241
|
-
)
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
}).option<boolean>('-j, --json', 'Output results in the plain JSON format.', () => true, false);
|
|
245
|
-
|
|
246
|
-
// Generates a source file listing all packages to link.
|
|
247
|
-
// It's deprecated for apple platforms, use `generate-modules-provider` instead.
|
|
248
|
-
registerResolveCommand<GenerateOptions>('generate-package-list', async (results, options) => {
|
|
249
|
-
const modules = options.empty ? [] : await resolveModulesAsync(results, options);
|
|
250
|
-
generatePackageListAsync(modules, options);
|
|
251
|
-
})
|
|
252
|
-
.option(
|
|
253
|
-
'-t, --target <path>',
|
|
254
|
-
'Path to the target file, where the package list should be written to.'
|
|
255
|
-
)
|
|
256
|
-
.option(
|
|
257
|
-
'-n, --namespace <namespace>',
|
|
258
|
-
'Java package name under which the package list should be placed.'
|
|
259
|
-
)
|
|
260
|
-
.option(
|
|
261
|
-
'--empty',
|
|
262
|
-
'Whether to only generate an empty list. Might be used when the user opts-out of autolinking.',
|
|
263
|
-
false
|
|
264
|
-
);
|
|
265
|
-
|
|
266
|
-
// Generates a source file listing all packages to link in the runtime.
|
|
267
|
-
registerResolveCommand<GenerateModulesProviderOptions>(
|
|
268
|
-
'generate-modules-provider',
|
|
269
|
-
async (results, options) => {
|
|
270
|
-
const packages = options.packages ?? [];
|
|
271
|
-
const modules = await resolveModulesAsync(results, options);
|
|
272
|
-
const filteredModules = modules.filter((module) => packages.includes(module.packageName));
|
|
273
|
-
|
|
274
|
-
generateModulesProviderAsync(filteredModules, options);
|
|
275
|
-
}
|
|
276
|
-
)
|
|
277
|
-
.option(
|
|
278
|
-
'-t, --target <path>',
|
|
279
|
-
'Path to the target file, where the package list should be written to.'
|
|
280
|
-
)
|
|
281
|
-
.option('--entitlement <path>', 'Path to the Apple code signing entitlements file.')
|
|
282
|
-
.option(
|
|
283
|
-
'-p, --packages <packages...>',
|
|
284
|
-
'Names of the packages to include in the generated modules provider.'
|
|
285
|
-
);
|
|
286
|
-
|
|
287
|
-
registerReactNativeConfigCommand();
|
|
288
|
-
|
|
289
|
-
await commander
|
|
290
|
-
.version(require('expo-modules-autolinking/package.json').version)
|
|
291
|
-
.description('CLI command that searches for Expo modules to autolink them.')
|
|
292
|
-
.parseAsync(args, { from: 'user' });
|
|
293
|
-
};
|
|
25
|
+
module.exports = main;
|
|
@@ -2,22 +2,20 @@ import fs from 'fs';
|
|
|
2
2
|
import { glob } from 'glob';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
ModuleDescriptorAndroid,
|
|
8
|
-
PackageRevision,
|
|
9
|
-
ResolveOptions,
|
|
10
|
-
} from '../types';
|
|
5
|
+
import { AutolinkingOptions } from '../../commands/autolinkingOptions';
|
|
6
|
+
import type { ExtraDependencies, ModuleDescriptorAndroid, PackageRevision } from '../../types';
|
|
11
7
|
|
|
12
8
|
const ANDROID_PROPERTIES_FILE = 'gradle.properties';
|
|
13
9
|
const ANDROID_EXTRA_BUILD_DEPS_KEY = 'android.extraMavenRepos';
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
interface AndroidConfigurationOutput {
|
|
12
|
+
buildFromSource: string[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function getConfiguration(
|
|
16
|
+
options: AutolinkingOptions
|
|
17
|
+
): AndroidConfigurationOutput | undefined {
|
|
18
|
+
return options.buildFromSource ? { buildFromSource: options.buildFromSource } : undefined;
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
/**
|
|
@@ -3,15 +3,14 @@ import fs from 'fs';
|
|
|
3
3
|
import { glob } from 'glob';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
|
|
6
|
-
import { fileExistsAsync } from '
|
|
6
|
+
import { fileExistsAsync } from '../../fileUtils';
|
|
7
7
|
import type {
|
|
8
8
|
AppleCodeSignEntitlements,
|
|
9
9
|
ExtraDependencies,
|
|
10
10
|
ModuleDescriptorIos,
|
|
11
11
|
ModuleIosPodspecInfo,
|
|
12
12
|
PackageRevision,
|
|
13
|
-
|
|
14
|
-
} from '../types';
|
|
13
|
+
} from '../../types';
|
|
15
14
|
|
|
16
15
|
const APPLE_PROPERTIES_FILE = 'Podfile.properties.json';
|
|
17
16
|
const APPLE_EXTRA_BUILD_DEPS_KEY = 'apple.extraPods';
|
|
@@ -43,13 +42,11 @@ export function getSwiftModuleNames(
|
|
|
43
42
|
return pods.map((pod) => pod.podName.replace(/[^a-zA-Z0-9]/g, '_'));
|
|
44
43
|
}
|
|
45
44
|
|
|
46
|
-
/**
|
|
47
|
-
* Resolves module search result with additional details required for iOS platform.
|
|
48
|
-
*/
|
|
45
|
+
/** Resolves module search result with additional details required for iOS platform. */
|
|
49
46
|
export async function resolveModuleAsync(
|
|
50
47
|
packageName: string,
|
|
51
48
|
revision: PackageRevision,
|
|
52
|
-
|
|
49
|
+
extraOutput: { flags?: Record<string, any> }
|
|
53
50
|
): Promise<ModuleDescriptorIos | null> {
|
|
54
51
|
const podspecFiles = await findPodspecFiles(revision);
|
|
55
52
|
if (!podspecFiles.length) {
|
|
@@ -68,7 +65,7 @@ export async function resolveModuleAsync(
|
|
|
68
65
|
packageName,
|
|
69
66
|
pods,
|
|
70
67
|
swiftModuleNames,
|
|
71
|
-
flags:
|
|
68
|
+
flags: extraOutput.flags,
|
|
72
69
|
modules: revision.config?.appleModules() ?? [],
|
|
73
70
|
appDelegateSubscribers: revision.config?.appleAppDelegateSubscribers() ?? [],
|
|
74
71
|
reactDelegateHandlers: revision.config?.appleReactDelegateHandlers() ?? [],
|
|
@@ -99,7 +96,7 @@ export async function resolveExtraBuildDependenciesAsync(
|
|
|
99
96
|
export async function generateModulesProviderAsync(
|
|
100
97
|
modules: ModuleDescriptorIos[],
|
|
101
98
|
targetPath: string,
|
|
102
|
-
entitlementPath: string
|
|
99
|
+
entitlementPath: string | null
|
|
103
100
|
): Promise<void> {
|
|
104
101
|
const className = path.basename(targetPath, path.extname(targetPath));
|
|
105
102
|
const entitlements = await parseEntitlementsAsync(entitlementPath);
|
|
@@ -280,8 +277,10 @@ function wrapInDebugConfigurationCheck(
|
|
|
280
277
|
)}${debugBlock}\n${indent.repeat(indentationLevel)}#endif`;
|
|
281
278
|
}
|
|
282
279
|
|
|
283
|
-
async function parseEntitlementsAsync(
|
|
284
|
-
|
|
280
|
+
async function parseEntitlementsAsync(
|
|
281
|
+
entitlementPath: string | null
|
|
282
|
+
): Promise<AppleCodeSignEntitlements> {
|
|
283
|
+
if (!entitlementPath || !(await fileExistsAsync(entitlementPath))) {
|
|
285
284
|
return {};
|
|
286
285
|
}
|
|
287
286
|
const { stdout } = await spawnAsync('plutil', ['-convert', 'json', '-o', '-', entitlementPath]);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { SupportedPlatform } from '../types';
|
|
2
|
+
|
|
3
|
+
interface PlatformImplementations {
|
|
4
|
+
ios: typeof import('./apple/apple');
|
|
5
|
+
macos: typeof import('./apple/apple');
|
|
6
|
+
tvos: typeof import('./apple/apple');
|
|
7
|
+
apple: typeof import('./apple/apple');
|
|
8
|
+
android: typeof import('./android/android');
|
|
9
|
+
devtools: typeof import('./devtools');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getLinkingImplementationForPlatform<Platform extends keyof PlatformImplementations>(
|
|
13
|
+
platform: Platform
|
|
14
|
+
): PlatformImplementations[Platform];
|
|
15
|
+
function getLinkingImplementationForPlatform(
|
|
16
|
+
platform: 'ios' | 'macos' | 'tvos' | 'apple'
|
|
17
|
+
): PlatformImplementations['apple'];
|
|
18
|
+
function getLinkingImplementationForPlatform(
|
|
19
|
+
platform: 'android'
|
|
20
|
+
): PlatformImplementations['android'];
|
|
21
|
+
function getLinkingImplementationForPlatform(
|
|
22
|
+
platform: 'devtools'
|
|
23
|
+
): PlatformImplementations['devtools'];
|
|
24
|
+
function getLinkingImplementationForPlatform(
|
|
25
|
+
platform: SupportedPlatform
|
|
26
|
+
): PlatformImplementations[keyof PlatformImplementations];
|
|
27
|
+
|
|
28
|
+
function getLinkingImplementationForPlatform(
|
|
29
|
+
platform: SupportedPlatform
|
|
30
|
+
): PlatformImplementations[keyof PlatformImplementations] {
|
|
31
|
+
if (!platform) {
|
|
32
|
+
throw new Error(`No platform was specified, but linking commands require a specific platform.`);
|
|
33
|
+
}
|
|
34
|
+
switch (platform) {
|
|
35
|
+
case 'ios':
|
|
36
|
+
case 'macos':
|
|
37
|
+
case 'tvos':
|
|
38
|
+
case 'apple':
|
|
39
|
+
return require('../platforms/apple');
|
|
40
|
+
case 'android':
|
|
41
|
+
return require('../platforms/android');
|
|
42
|
+
case 'devtools':
|
|
43
|
+
return require('../platforms/devtools');
|
|
44
|
+
default:
|
|
45
|
+
throw new Error(`No linking implementation is available for platform "${platform}"`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export { getLinkingImplementationForPlatform };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
1
|
import path from 'path';
|
|
3
2
|
|
|
4
|
-
import type {
|
|
3
|
+
import type { SupportedPlatform } from '../types';
|
|
5
4
|
import {
|
|
6
5
|
findGradleAndManifestAsync,
|
|
7
6
|
parsePackageNameAsync,
|
|
@@ -10,7 +9,6 @@ import {
|
|
|
10
9
|
import { loadConfigAsync } from './config';
|
|
11
10
|
import { resolveDependencyConfigImplIosAsync } from './iosResolver';
|
|
12
11
|
import type {
|
|
13
|
-
RNConfigCommandOptions,
|
|
14
12
|
RNConfigDependency,
|
|
15
13
|
RNConfigDependencyAndroid,
|
|
16
14
|
RNConfigDependencyIos,
|
|
@@ -20,7 +18,7 @@ import type {
|
|
|
20
18
|
RNConfigResult,
|
|
21
19
|
} from './reactNativeConfig.types';
|
|
22
20
|
import { discoverExpoModuleConfigAsync, ExpoModuleConfig } from '../ExpoModuleConfig';
|
|
23
|
-
import {
|
|
21
|
+
import { AutolinkingOptions } from '../commands/autolinkingOptions';
|
|
24
22
|
import {
|
|
25
23
|
DependencyResolution,
|
|
26
24
|
filterMapResolutionResult,
|
|
@@ -96,49 +94,47 @@ export async function resolveReactNativeModule(
|
|
|
96
94
|
);
|
|
97
95
|
}
|
|
98
96
|
|
|
97
|
+
interface CreateRNConfigParams {
|
|
98
|
+
appRoot: string;
|
|
99
|
+
sourceDir: string | undefined;
|
|
100
|
+
autolinkingOptions: AutolinkingOptions & { platform: SupportedPlatform };
|
|
101
|
+
}
|
|
102
|
+
|
|
99
103
|
/**
|
|
100
104
|
* Create config for react-native core autolinking.
|
|
101
105
|
*/
|
|
102
|
-
export async function createReactNativeConfigAsync(
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
);
|
|
108
|
-
const
|
|
109
|
-
const projectConfig = await loadConfigAsync<RNConfigReactNativeProjectConfig>(
|
|
110
|
-
options.projectRoot
|
|
111
|
-
);
|
|
106
|
+
export async function createReactNativeConfigAsync({
|
|
107
|
+
appRoot,
|
|
108
|
+
sourceDir,
|
|
109
|
+
autolinkingOptions,
|
|
110
|
+
}: CreateRNConfigParams): Promise<RNConfigResult> {
|
|
111
|
+
const excludeNames = new Set(autolinkingOptions.exclude);
|
|
112
|
+
const projectConfig = await loadConfigAsync<RNConfigReactNativeProjectConfig>(appRoot);
|
|
112
113
|
|
|
113
114
|
// custom native modules should be resolved first so that they can override other modules
|
|
114
|
-
const searchPaths =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
: (options.searchPaths ?? []);
|
|
115
|
+
const searchPaths = autolinkingOptions.nativeModulesDir
|
|
116
|
+
? [autolinkingOptions.nativeModulesDir, ...autolinkingOptions.searchPaths]
|
|
117
|
+
: autolinkingOptions.searchPaths;
|
|
118
118
|
|
|
119
|
-
const limitDepth =
|
|
119
|
+
const limitDepth = autolinkingOptions.legacy_shallowReactNativeLinking ? 1 : undefined;
|
|
120
120
|
|
|
121
121
|
const resolutions = mergeResolutionResults(
|
|
122
122
|
await Promise.all([
|
|
123
|
-
scanDependenciesFromRNProjectConfig(
|
|
123
|
+
scanDependenciesFromRNProjectConfig(appRoot, projectConfig),
|
|
124
124
|
...searchPaths.map((searchPath) => scanDependenciesInSearchPath(searchPath)),
|
|
125
|
-
scanDependenciesRecursively(
|
|
125
|
+
scanDependenciesRecursively(appRoot, { limitDepth }),
|
|
126
126
|
])
|
|
127
127
|
);
|
|
128
128
|
|
|
129
129
|
const dependencies = await filterMapResolutionResult(resolutions, (resolution) =>
|
|
130
|
-
resolveReactNativeModule(resolution, projectConfig,
|
|
130
|
+
resolveReactNativeModule(resolution, projectConfig, autolinkingOptions.platform, excludeNames)
|
|
131
131
|
);
|
|
132
132
|
|
|
133
133
|
return {
|
|
134
|
-
root:
|
|
134
|
+
root: appRoot,
|
|
135
135
|
reactNativePath: resolutions['react-native']?.path!,
|
|
136
136
|
dependencies,
|
|
137
|
-
project: await resolveAppProjectConfigAsync(
|
|
138
|
-
options.projectRoot,
|
|
139
|
-
options.platform,
|
|
140
|
-
options.sourceDir
|
|
141
|
-
),
|
|
137
|
+
project: await resolveAppProjectConfigAsync(appRoot, autolinkingOptions.platform, sourceDir),
|
|
142
138
|
};
|
|
143
139
|
}
|
|
144
140
|
|
|
@@ -147,6 +143,7 @@ export async function resolveAppProjectConfigAsync(
|
|
|
147
143
|
platform: SupportedPlatform,
|
|
148
144
|
sourceDir?: string
|
|
149
145
|
): Promise<RNConfigReactNativeAppProjectConfig> {
|
|
146
|
+
// TODO(@kitten): use the commandRoot here to find these files in non <projectRoot>/<platform> folders
|
|
150
147
|
if (platform === 'android') {
|
|
151
148
|
const androidDir = path.join(projectRoot, 'android');
|
|
152
149
|
const { gradle, manifest } = await findGradleAndManifestAsync({ androidDir, isLibrary: false });
|
|
@@ -1,31 +1,6 @@
|
|
|
1
1
|
import type { SupportedPlatform } from '../types';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Options for 'react-native-config' command.
|
|
5
|
-
*/
|
|
6
|
-
export interface RNConfigCommandOptions {
|
|
7
|
-
platform: SupportedPlatform;
|
|
8
|
-
projectRoot: string;
|
|
9
|
-
searchPaths?: string[];
|
|
10
|
-
transitiveLinkingDependencies: string[];
|
|
11
|
-
sourceDir?: string;
|
|
12
|
-
// NOTE(@kitten): This was missing before. The options utils are very imprecisely defined. Sometimes some options
|
|
13
|
-
// are defined but not used, and in this case this was missing
|
|
14
|
-
nativeModulesDir?: string | null;
|
|
15
|
-
/** Only scan direct "dependencies" of a project for React Native modules, rather than including transitive dependencies.
|
|
16
|
-
* @remarks
|
|
17
|
-
* Before SDK 54, React Native modules would only be linked if they were listed as dependencies
|
|
18
|
-
* of a project. However, in SDK 54+ transitive React Native modules dependencies are also
|
|
19
|
-
* auto-linked, unless this flag is enabled.
|
|
20
|
-
* @privateRemarks
|
|
21
|
-
* This is not an argument, but can only be specified on `expo.autolinking`
|
|
22
|
-
*/
|
|
23
|
-
legacy_shallowReactNativeLinking?: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Dependency configuration for Android platform.
|
|
28
|
-
*/
|
|
3
|
+
/** Dependency configuration for Android platform. */
|
|
29
4
|
export interface RNConfigDependencyAndroid {
|
|
30
5
|
sourceDir: string;
|
|
31
6
|
packageImportPath: string | null;
|
|
@@ -41,9 +16,7 @@ export interface RNConfigDependencyAndroid {
|
|
|
41
16
|
isPureCxxDependency?: boolean;
|
|
42
17
|
}
|
|
43
18
|
|
|
44
|
-
/**
|
|
45
|
-
* Dependency configuration for iOS platform.
|
|
46
|
-
*/
|
|
19
|
+
/** Dependency configuration for iOS platform. */
|
|
47
20
|
export interface RNConfigDependencyIos {
|
|
48
21
|
podspecPath: string;
|
|
49
22
|
version: string;
|
|
@@ -51,9 +24,7 @@ export interface RNConfigDependencyIos {
|
|
|
51
24
|
scriptPhases: any[];
|
|
52
25
|
}
|
|
53
26
|
|
|
54
|
-
/**
|
|
55
|
-
* Dependency configuration.
|
|
56
|
-
*/
|
|
27
|
+
/** Dependency configuration. */
|
|
57
28
|
export interface RNConfigDependency {
|
|
58
29
|
root: string;
|
|
59
30
|
name: string;
|
|
@@ -63,9 +34,7 @@ export interface RNConfigDependency {
|
|
|
63
34
|
};
|
|
64
35
|
}
|
|
65
36
|
|
|
66
|
-
/**
|
|
67
|
-
* Result of 'react-native-config' command.
|
|
68
|
-
*/
|
|
37
|
+
/** Result of 'react-native-config' command. */
|
|
69
38
|
export interface RNConfigResult {
|
|
70
39
|
root: string;
|
|
71
40
|
reactNativePath: string;
|