@amabeth/repeating-wheel-picker 1.1.0 → 1.2.0
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/LICENSE +20 -20
- package/README.md +57 -57
- package/example/index.ts +8 -0
- package/example/node_modules/@expo/cli/static/template/+html.tsx +28 -0
- package/example/node_modules/@expo/cli/static/template/+native-intent.ts +9 -0
- package/example/node_modules/@expo/cli/static/template/[...rsc]+api.ts +16 -0
- package/example/node_modules/ansi-styles/index.d.ts +345 -0
- package/example/node_modules/chalk/index.d.ts +415 -0
- package/example/node_modules/commander/typings/index.d.ts +627 -0
- package/example/node_modules/expo/Expo.podspec +108 -0
- package/example/node_modules/expo/build/Expo.d.ts +8 -0
- package/example/node_modules/expo/build/Expo.fx.d.ts +4 -0
- package/example/node_modules/expo/build/Expo.fx.web.d.ts +3 -0
- package/example/node_modules/expo/build/devtools/DevToolsPluginClient.d.ts +72 -0
- package/example/node_modules/expo/build/devtools/DevToolsPluginClientFactory.d.ts +16 -0
- package/example/node_modules/expo/build/devtools/DevToolsPluginClientImplApp.d.ts +15 -0
- package/example/node_modules/expo/build/devtools/DevToolsPluginClientImplBrowser.d.ts +14 -0
- package/example/node_modules/expo/build/devtools/MessageFramePacker.d.ts +50 -0
- package/example/node_modules/expo/build/devtools/ProtocolVersion.d.ts +7 -0
- package/example/node_modules/expo/build/devtools/WebSocketBackingStore.d.ts +10 -0
- package/example/node_modules/expo/build/devtools/WebSocketWithReconnect.d.ts +81 -0
- package/example/node_modules/expo/build/devtools/devtools.types.d.ts +42 -0
- package/example/node_modules/expo/build/devtools/getConnectionInfo.d.ts +6 -0
- package/example/node_modules/expo/build/devtools/getConnectionInfo.native.d.ts +6 -0
- package/example/node_modules/expo/build/devtools/index.d.ts +12 -0
- package/example/node_modules/expo/build/devtools/logger.d.ts +6 -0
- package/example/node_modules/expo/build/dom/base.d.ts +5 -0
- package/example/node_modules/expo/build/dom/dom-entry.d.ts +3 -0
- package/example/node_modules/expo/build/dom/dom-hooks.d.ts +8 -0
- package/example/node_modules/expo/build/dom/dom.d.ts +5 -0
- package/example/node_modules/expo/build/dom/dom.types.d.ts +34 -0
- package/example/node_modules/expo/build/dom/dom.web.d.ts +3 -0
- package/example/node_modules/expo/build/dom/global-events.d.ts +4 -0
- package/example/node_modules/expo/build/dom/injection.d.ts +9 -0
- package/example/node_modules/expo/build/dom/internal.d.ts +3 -0
- package/example/node_modules/expo/build/dom/internal.web.d.ts +2 -0
- package/example/node_modules/expo/build/dom/marshal.d.ts +4 -0
- package/example/node_modules/expo/build/dom/webview/ExpoDOMWebView.d.ts +6 -0
- package/example/node_modules/expo/build/dom/webview/RNWebView.d.ts +7 -0
- package/example/node_modules/expo/build/dom/webview/useDebugZeroHeight.d.ts +12 -0
- package/example/node_modules/expo/build/dom/webview-wrapper.d.ts +16 -0
- package/example/node_modules/expo/build/environment/DevLoadingView.d.ts +3 -0
- package/example/node_modules/expo/build/environment/DevLoadingView.web.d.ts +3 -0
- package/example/node_modules/expo/build/environment/DevLoadingViewNativeModule.d.ts +9 -0
- package/example/node_modules/expo/build/environment/DevLoadingViewNativeModule.native.d.ts +3 -0
- package/example/node_modules/expo/build/environment/ExpoGo.d.ts +31 -0
- package/example/node_modules/expo/build/environment/ExpoGo.web.d.ts +3 -0
- package/example/node_modules/expo/build/environment/getInitialSafeArea.d.ts +7 -0
- package/example/node_modules/expo/build/environment/getInitialSafeArea.native.d.ts +11 -0
- package/example/node_modules/expo/build/errors/AppEntryNotFound.d.ts +2 -0
- package/example/node_modules/expo/build/errors/ExpoErrorManager.d.ts +8 -0
- package/example/node_modules/expo/build/errors/ExpoErrorManager.native.d.ts +4 -0
- package/example/node_modules/expo/build/hooks/useEvent.d.ts +59 -0
- package/example/node_modules/expo/build/launch/registerRootComponent.d.ts +30 -0
- package/example/node_modules/expo/build/launch/withDevTools.d.ts +3 -0
- package/example/node_modules/expo/build/launch/withDevTools.ios.d.ts +7 -0
- package/example/node_modules/expo/build/launch/withDevTools.web.d.ts +3 -0
- package/example/node_modules/expo/build/timer/polyfillNextTick.d.ts +6 -0
- package/example/node_modules/expo/build/utils/blobUtils.d.ts +9 -0
- package/example/node_modules/expo/build/utils/getBundleUrl.d.ts +2 -0
- package/example/node_modules/expo/build/utils/getBundleUrl.native.d.ts +2 -0
- package/example/node_modules/expo/build/utils/getBundleUrl.web.d.ts +2 -0
- package/example/node_modules/expo/build/winter/FormData.d.ts +49 -0
- package/example/node_modules/expo/build/winter/ImportMetaRegistry.d.ts +9 -0
- package/example/node_modules/expo/build/winter/TextDecoder.d.ts +20 -0
- package/example/node_modules/expo/build/winter/fetch/ExpoFetchModule.d.ts +2 -0
- package/example/node_modules/expo/build/winter/fetch/ExpoFetchModule.web.d.ts +10 -0
- package/example/node_modules/expo/build/winter/fetch/FetchErrors.d.ts +8 -0
- package/example/node_modules/expo/build/winter/fetch/FetchResponse.d.ts +31 -0
- package/example/node_modules/expo/build/winter/fetch/NativeRequest.d.ts +30 -0
- package/example/node_modules/expo/build/winter/fetch/RequestUtils.d.ts +21 -0
- package/example/node_modules/expo/build/winter/fetch/convertFormData.d.ts +19 -0
- package/example/node_modules/expo/build/winter/fetch/fetch.d.ts +4 -0
- package/example/node_modules/expo/build/winter/fetch/fetch.types.d.ts +16 -0
- package/example/node_modules/expo/build/winter/fetch/fetch.web.d.ts +2 -0
- package/example/node_modules/expo/build/winter/fetch/index.d.ts +3 -0
- package/example/node_modules/expo/build/winter/index.d.ts +2 -0
- package/example/node_modules/expo/build/winter/runtime.d.ts +2 -0
- package/example/node_modules/expo/build/winter/runtime.native.d.ts +2 -0
- package/example/node_modules/expo/build/winter/url.d.ts +23 -0
- package/example/node_modules/expo/config-plugins.d.ts +1 -0
- package/example/node_modules/expo/config.d.ts +1 -0
- package/example/node_modules/expo/devtools.d.ts +1 -0
- package/example/node_modules/expo/dom/global.d.ts +1 -0
- package/example/node_modules/expo/dom/index.d.ts +1 -0
- package/example/node_modules/expo/dom/internal.d.ts +1 -0
- package/example/node_modules/expo/fetch.d.ts +1 -0
- package/example/node_modules/expo/fingerprint.d.ts +1 -0
- package/example/node_modules/expo/metro-config.d.ts +1 -0
- package/example/node_modules/expo/react-native.config.js +50 -0
- package/example/node_modules/expo/src/Expo.fx.tsx +53 -0
- package/example/node_modules/expo/src/Expo.fx.web.tsx +21 -0
- package/example/node_modules/expo/src/Expo.ts +30 -0
- package/example/node_modules/expo/src/devtools/DevToolsPluginClient.ts +240 -0
- package/example/node_modules/expo/src/devtools/DevToolsPluginClientFactory.ts +73 -0
- package/example/node_modules/expo/src/devtools/DevToolsPluginClientImplApp.ts +56 -0
- package/example/node_modules/expo/src/devtools/DevToolsPluginClientImplBrowser.ts +38 -0
- package/example/node_modules/expo/src/devtools/MessageFramePacker.ts +235 -0
- package/example/node_modules/expo/src/devtools/ProtocolVersion.ts +6 -0
- package/example/node_modules/expo/src/devtools/WebSocketBackingStore.ts +10 -0
- package/example/node_modules/expo/src/devtools/WebSocketWithReconnect.ts +318 -0
- package/example/node_modules/expo/src/devtools/devtools.types.ts +50 -0
- package/example/node_modules/expo/src/devtools/getConnectionInfo.native.ts +18 -0
- package/example/node_modules/expo/src/devtools/getConnectionInfo.ts +16 -0
- package/example/node_modules/expo/src/devtools/index.ts +53 -0
- package/example/node_modules/expo/src/devtools/logger.ts +29 -0
- package/example/node_modules/expo/src/dom/base.ts +62 -0
- package/example/node_modules/expo/src/dom/dom-entry.tsx +128 -0
- package/example/node_modules/expo/src/dom/dom-hooks.ts +46 -0
- package/example/node_modules/expo/src/dom/dom.ts +8 -0
- package/example/node_modules/expo/src/dom/dom.types.ts +39 -0
- package/example/node_modules/expo/src/dom/dom.web.ts +6 -0
- package/example/node_modules/expo/src/dom/global-events.ts +16 -0
- package/example/node_modules/expo/src/dom/injection.ts +42 -0
- package/example/node_modules/expo/src/dom/internal.ts +5 -0
- package/example/node_modules/expo/src/dom/internal.web.ts +1 -0
- package/example/node_modules/expo/src/dom/marshal.tsx +116 -0
- package/example/node_modules/expo/src/dom/webview/ExpoDOMWebView.ts +10 -0
- package/example/node_modules/expo/src/dom/webview/RNWebView.ts +12 -0
- package/example/node_modules/expo/src/dom/webview/useDebugZeroHeight.ts +62 -0
- package/example/node_modules/expo/src/dom/webview-wrapper.tsx +253 -0
- package/example/node_modules/expo/src/environment/DevLoadingView.tsx +123 -0
- package/example/node_modules/expo/src/environment/DevLoadingView.web.tsx +135 -0
- package/example/node_modules/expo/src/environment/DevLoadingViewNativeModule.native.ts +3 -0
- package/example/node_modules/expo/src/environment/DevLoadingViewNativeModule.ts +7 -0
- package/example/node_modules/expo/src/environment/ExpoGo.ts +53 -0
- package/example/node_modules/expo/src/environment/ExpoGo.web.ts +7 -0
- package/example/node_modules/expo/src/environment/getInitialSafeArea.native.ts +16 -0
- package/example/node_modules/expo/src/environment/getInitialSafeArea.ts +8 -0
- package/example/node_modules/expo/src/errors/AppEntryNotFound.tsx +35 -0
- package/example/node_modules/expo/src/errors/ExpoErrorManager.native.ts +51 -0
- package/example/node_modules/expo/src/errors/ExpoErrorManager.ts +11 -0
- package/example/node_modules/expo/src/hooks/useEvent.ts +112 -0
- package/example/node_modules/expo/src/launch/registerRootComponent.tsx +64 -0
- package/example/node_modules/expo/src/launch/withDevTools.ios.tsx +47 -0
- package/example/node_modules/expo/src/launch/withDevTools.tsx +30 -0
- package/example/node_modules/expo/src/launch/withDevTools.web.tsx +23 -0
- package/example/node_modules/expo/src/timer/polyfillNextTick.ts +10 -0
- package/example/node_modules/expo/src/ts-declarations/console.d.ts +47 -0
- package/example/node_modules/expo/src/ts-declarations/global.d.ts +12 -0
- package/example/node_modules/expo/src/ts-declarations/react-native.d.ts +34 -0
- package/example/node_modules/expo/src/ts-declarations/whatwg-url-without-unicode.d.ts +186 -0
- package/example/node_modules/expo/src/utils/blobUtils.ts +23 -0
- package/example/node_modules/expo/src/utils/getBundleUrl.native.ts +17 -0
- package/example/node_modules/expo/src/utils/getBundleUrl.ts +5 -0
- package/example/node_modules/expo/src/utils/getBundleUrl.web.ts +21 -0
- package/example/node_modules/expo/src/winter/FormData.ts +222 -0
- package/example/node_modules/expo/src/winter/ImportMetaRegistry.ts +14 -0
- package/example/node_modules/expo/src/winter/TextDecoder.ts +429 -0
- package/example/node_modules/expo/src/winter/fetch/ExpoFetchModule.ts +3 -0
- package/example/node_modules/expo/src/winter/fetch/ExpoFetchModule.web.ts +7 -0
- package/example/node_modules/expo/src/winter/fetch/FetchErrors.ts +11 -0
- package/example/node_modules/expo/src/winter/fetch/FetchResponse.ts +146 -0
- package/example/node_modules/expo/src/winter/fetch/NativeRequest.ts +38 -0
- package/example/node_modules/expo/src/winter/fetch/RequestUtils.ts +124 -0
- package/example/node_modules/expo/src/winter/fetch/convertFormData.ts +92 -0
- package/example/node_modules/expo/src/winter/fetch/fetch.ts +59 -0
- package/example/node_modules/expo/src/winter/fetch/fetch.types.ts +17 -0
- package/example/node_modules/expo/src/winter/fetch/fetch.web.ts +1 -0
- package/example/node_modules/expo/src/winter/fetch/index.ts +2 -0
- package/example/node_modules/expo/src/winter/index.ts +1 -0
- package/example/node_modules/expo/src/winter/runtime.native.ts +41 -0
- package/example/node_modules/expo/src/winter/runtime.ts +5 -0
- package/example/node_modules/expo/src/winter/url.ts +116 -0
- package/example/node_modules/expo/types/global.d.ts +38 -0
- package/example/node_modules/expo/types/index.d.ts +3 -0
- package/example/node_modules/expo/types/metro-require.d.ts +52 -0
- package/example/node_modules/expo/types/react-native-web.d.ts +291 -0
- package/example/node_modules/expo-modules-autolinking/build/ExpoModuleConfig.d.ts +85 -0
- package/example/node_modules/expo-modules-autolinking/build/autolinking/findModules.d.ts +5 -0
- package/example/node_modules/expo-modules-autolinking/build/autolinking/generatePackageList.d.ts +11 -0
- package/example/node_modules/expo-modules-autolinking/build/autolinking/getConfiguration.d.ts +2 -0
- package/example/node_modules/expo-modules-autolinking/build/autolinking/index.d.ts +17 -0
- package/example/node_modules/expo-modules-autolinking/build/autolinking/mergeLinkingOptions.d.ts +21 -0
- package/example/node_modules/expo-modules-autolinking/build/autolinking/resolveModules.d.ts +9 -0
- package/example/node_modules/expo-modules-autolinking/build/autolinking/utils.d.ts +6 -0
- package/example/node_modules/expo-modules-autolinking/build/autolinking/verifySearchResults.d.ts +5 -0
- package/example/node_modules/expo-modules-autolinking/build/fileUtils.d.ts +18 -0
- package/example/node_modules/expo-modules-autolinking/build/index.d.ts +1 -0
- package/example/node_modules/expo-modules-autolinking/build/platforms/android.d.ts +38 -0
- package/example/node_modules/expo-modules-autolinking/build/platforms/apple.d.ts +15 -0
- package/example/node_modules/expo-modules-autolinking/build/platforms/devtools.d.ts +3 -0
- package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/androidResolver.d.ts +20 -0
- package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/config.d.ts +5 -0
- package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/index.d.ts +2 -0
- package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/iosResolver.d.ts +2 -0
- package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/reactNativeConfig.d.ts +13 -0
- package/example/node_modules/expo-modules-autolinking/build/reactNativeConfig/reactNativeConfig.types.d.ts +95 -0
- package/example/node_modules/expo-modules-autolinking/build/types.d.ts +319 -0
- package/example/node_modules/expo-modules-autolinking/e2e/TestUtils.ts +53 -0
- package/example/node_modules/expo-modules-autolinking/exports.d.ts +1 -0
- package/example/node_modules/expo-modules-autolinking/src/ExpoModuleConfig.ts +181 -0
- package/example/node_modules/expo-modules-autolinking/src/autolinking/findModules.ts +259 -0
- package/example/node_modules/expo-modules-autolinking/src/autolinking/generatePackageList.ts +46 -0
- package/example/node_modules/expo-modules-autolinking/src/autolinking/getConfiguration.ts +7 -0
- package/example/node_modules/expo-modules-autolinking/src/autolinking/index.ts +45 -0
- package/example/node_modules/expo-modules-autolinking/src/autolinking/mergeLinkingOptions.ts +127 -0
- package/example/node_modules/expo-modules-autolinking/src/autolinking/resolveModules.ts +46 -0
- package/example/node_modules/expo-modules-autolinking/src/autolinking/utils.ts +37 -0
- package/example/node_modules/expo-modules-autolinking/src/autolinking/verifySearchResults.ts +33 -0
- package/example/node_modules/expo-modules-autolinking/src/fileUtils.ts +64 -0
- package/example/node_modules/expo-modules-autolinking/src/index.ts +262 -0
- package/example/node_modules/expo-modules-autolinking/src/platforms/android.ts +303 -0
- package/example/node_modules/expo-modules-autolinking/src/platforms/apple.ts +292 -0
- package/example/node_modules/expo-modules-autolinking/src/platforms/devtools.ts +25 -0
- package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/androidResolver.ts +264 -0
- package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/config.ts +67 -0
- package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/index.ts +2 -0
- package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/iosResolver.ts +37 -0
- package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/reactNativeConfig.ts +245 -0
- package/example/node_modules/expo-modules-autolinking/src/reactNativeConfig/reactNativeConfig.types.ts +107 -0
- package/example/node_modules/expo-modules-autolinking/src/types.ts +384 -0
- package/example/node_modules/find-up/index.d.ts +138 -0
- package/example/node_modules/glob/dist/commonjs/glob.d.ts +388 -0
- package/example/node_modules/glob/dist/commonjs/has-magic.d.ts +14 -0
- package/example/node_modules/glob/dist/commonjs/ignore.d.ts +24 -0
- package/example/node_modules/glob/dist/commonjs/index.d.ts +97 -0
- package/example/node_modules/glob/dist/commonjs/pattern.d.ts +76 -0
- package/example/node_modules/glob/dist/commonjs/processor.d.ts +59 -0
- package/example/node_modules/glob/dist/commonjs/walker.d.ts +97 -0
- package/example/node_modules/glob/dist/esm/glob.d.ts +388 -0
- package/example/node_modules/glob/dist/esm/has-magic.d.ts +14 -0
- package/example/node_modules/glob/dist/esm/ignore.d.ts +24 -0
- package/example/node_modules/glob/dist/esm/index.d.ts +97 -0
- package/example/node_modules/glob/dist/esm/pattern.d.ts +76 -0
- package/example/node_modules/glob/dist/esm/processor.d.ts +59 -0
- package/example/node_modules/glob/dist/esm/walker.d.ts +97 -0
- package/example/node_modules/locate-path/index.d.ts +83 -0
- package/example/node_modules/log-symbols/node_modules/chalk/types/index.d.ts +97 -0
- package/example/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +2 -0
- package/example/node_modules/minimatch/dist/commonjs/ast.d.ts +20 -0
- package/example/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +8 -0
- package/example/node_modules/minimatch/dist/commonjs/escape.d.ts +12 -0
- package/example/node_modules/minimatch/dist/commonjs/index.d.ts +94 -0
- package/example/node_modules/minimatch/dist/commonjs/unescape.d.ts +17 -0
- package/example/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +2 -0
- package/example/node_modules/minimatch/dist/esm/ast.d.ts +20 -0
- package/example/node_modules/minimatch/dist/esm/brace-expressions.d.ts +8 -0
- package/example/node_modules/minimatch/dist/esm/escape.d.ts +12 -0
- package/example/node_modules/minimatch/dist/esm/index.d.ts +94 -0
- package/example/node_modules/minimatch/dist/esm/unescape.d.ts +17 -0
- package/example/node_modules/ora/index.d.ts +257 -0
- package/example/node_modules/ora/node_modules/chalk/types/index.d.ts +97 -0
- package/example/node_modules/ora/node_modules/strip-ansi/index.d.ts +15 -0
- package/example/node_modules/p-locate/index.d.ts +53 -0
- package/example/node_modules/path-exists/index.d.ts +28 -0
- package/example/package.json +29 -0
- package/example/src/constants/styles.ts +43 -0
- package/example/src/hooks/useComponentHeight.ts +13 -0
- package/example/src/scenes/app.tsx +33 -0
- package/example/src/scenes/booleanPicker.tsx +60 -0
- package/example/src/scenes/customTypePicker.tsx +83 -0
- package/example/src/scenes/numberPicker.tsx +75 -0
- package/example/src/scenes/stringPicker.tsx +64 -0
- package/lib/module/index.js +6 -6
- package/lib/module/index.js.map +1 -1
- package/package.json +168 -183
- package/src/index.tsx +0 -507
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { glob } from 'glob';
|
|
4
|
+
import { createRequire } from 'module';
|
|
5
|
+
import path from 'path';
|
|
6
|
+
|
|
7
|
+
import { getProjectPackageJsonPathAsync, mergeLinkingOptionsAsync } from './mergeLinkingOptions';
|
|
8
|
+
import { getIsolatedModulesPath } from './utils';
|
|
9
|
+
import { requireAndResolveExpoModuleConfig } from '../ExpoModuleConfig';
|
|
10
|
+
import { PackageRevision, SearchOptions, SearchResults } from '../types';
|
|
11
|
+
|
|
12
|
+
// Names of the config files. From lowest to highest priority.
|
|
13
|
+
const EXPO_MODULE_CONFIG_FILENAMES = ['unimodule.json', 'expo-module.config.json'];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Searches for modules to link based on given config.
|
|
17
|
+
*/
|
|
18
|
+
export async function findModulesAsync(providedOptions: SearchOptions): Promise<SearchResults> {
|
|
19
|
+
const options = await mergeLinkingOptionsAsync(providedOptions);
|
|
20
|
+
const results: Map<string, PackageRevision> = new Map();
|
|
21
|
+
|
|
22
|
+
const nativeModuleNames = new Set<string>();
|
|
23
|
+
|
|
24
|
+
// custom native modules should be resolved first so that they can override other modules
|
|
25
|
+
const searchPaths = new Set(
|
|
26
|
+
options.nativeModulesDir && fs.existsSync(options.nativeModulesDir)
|
|
27
|
+
? [options.nativeModulesDir, ...options.searchPaths]
|
|
28
|
+
: options.searchPaths
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
// `searchPaths` can be mutated to discover all "isolated modules groups", when using isolated modules
|
|
32
|
+
for (const searchPath of searchPaths) {
|
|
33
|
+
const isNativeModulesDir = searchPath === options.nativeModulesDir;
|
|
34
|
+
|
|
35
|
+
const packageConfigPaths = await findPackagesConfigPathsAsync(searchPath);
|
|
36
|
+
|
|
37
|
+
for (const packageConfigPath of packageConfigPaths) {
|
|
38
|
+
const packagePath = await fs.promises.realpath(
|
|
39
|
+
path.join(searchPath, path.dirname(packageConfigPath))
|
|
40
|
+
);
|
|
41
|
+
const expoModuleConfig = requireAndResolveExpoModuleConfig(
|
|
42
|
+
path.join(packagePath, path.basename(packageConfigPath))
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const { name, version } = resolvePackageNameAndVersion(packagePath, {
|
|
46
|
+
fallbackToDirName: isNativeModulesDir,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const maybeIsolatedModulesPath = getIsolatedModulesPath(packagePath, name);
|
|
50
|
+
if (maybeIsolatedModulesPath) {
|
|
51
|
+
searchPaths.add(maybeIsolatedModulesPath);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (options.exclude?.includes(name) || !expoModuleConfig.supportsPlatform(options.platform)) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// add the current revision to the results
|
|
59
|
+
const currentRevision: PackageRevision = {
|
|
60
|
+
path: packagePath,
|
|
61
|
+
version,
|
|
62
|
+
config: expoModuleConfig,
|
|
63
|
+
};
|
|
64
|
+
addRevisionToResults(results, name, currentRevision);
|
|
65
|
+
|
|
66
|
+
// if the module is a native module, we need to add it to the nativeModuleNames set
|
|
67
|
+
if (isNativeModulesDir && !nativeModuleNames.has(name)) {
|
|
68
|
+
nativeModuleNames.add(name);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const searchResults: SearchResults = Object.fromEntries(results.entries());
|
|
74
|
+
|
|
75
|
+
// It doesn't make much sense to strip modules if there is only one search path.
|
|
76
|
+
// (excluding custom native modules path)
|
|
77
|
+
// Workspace root usually doesn't specify all its dependencies (see Expo Go),
|
|
78
|
+
// so in this case we should link everything.
|
|
79
|
+
if (options.searchPaths.length <= 1 || options.onlyProjectDeps === false) {
|
|
80
|
+
return searchResults;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return await filterToProjectDependenciesAsync(searchResults, {
|
|
84
|
+
...providedOptions,
|
|
85
|
+
// Custom native modules are not filtered out
|
|
86
|
+
// when they're not specified in package.json dependencies.
|
|
87
|
+
alwaysIncludedPackagesNames: nativeModuleNames,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Returns the priority of the config at given path. Higher number means higher priority.
|
|
93
|
+
*/
|
|
94
|
+
function configPriority(fullpath: string): number {
|
|
95
|
+
return EXPO_MODULE_CONFIG_FILENAMES.indexOf(path.basename(fullpath));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Adds {@link revision} to the {@link results} map
|
|
100
|
+
* or to package duplicates if it already exists.
|
|
101
|
+
* @param results [mutable] yet resolved packages map
|
|
102
|
+
* @param name resolved package name
|
|
103
|
+
* @param revision resolved package revision
|
|
104
|
+
*/
|
|
105
|
+
function addRevisionToResults(
|
|
106
|
+
results: Map<string, PackageRevision>,
|
|
107
|
+
name: string,
|
|
108
|
+
revision: PackageRevision
|
|
109
|
+
): void {
|
|
110
|
+
if (!results.has(name)) {
|
|
111
|
+
// The revision that was found first will be the main one.
|
|
112
|
+
// An array of duplicates and the config are needed only here.
|
|
113
|
+
results.set(name, {
|
|
114
|
+
...revision,
|
|
115
|
+
duplicates: [],
|
|
116
|
+
});
|
|
117
|
+
} else if (
|
|
118
|
+
results.get(name)?.path !== revision.path &&
|
|
119
|
+
results.get(name)?.duplicates?.every(({ path }) => path !== revision.path)
|
|
120
|
+
) {
|
|
121
|
+
const { config, duplicates, ...duplicateEntry } = revision;
|
|
122
|
+
results.get(name)?.duplicates?.push(duplicateEntry);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Returns paths to the highest priority config files, relative to the {@link searchPath}.
|
|
128
|
+
* @example
|
|
129
|
+
* ```
|
|
130
|
+
* // Given the following file exists: /foo/myapp/modules/mymodule/expo-module.config.json
|
|
131
|
+
* await findPackagesConfigPathsAsync('/foo/myapp/modules');
|
|
132
|
+
* // returns ['mymodule/expo-module.config.json']
|
|
133
|
+
*
|
|
134
|
+
* await findPackagesConfigPathsAsync('/foo/myapp/modules/mymodule');
|
|
135
|
+
* // returns ['expo-module.config.json']
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
async function findPackagesConfigPathsAsync(searchPath: string): Promise<string[]> {
|
|
139
|
+
const bracedFilenames = '{' + EXPO_MODULE_CONFIG_FILENAMES.join(',') + '}';
|
|
140
|
+
const paths = await glob(
|
|
141
|
+
[`*/${bracedFilenames}`, `@*/*/${bracedFilenames}`, `./${bracedFilenames}`],
|
|
142
|
+
{
|
|
143
|
+
cwd: searchPath,
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
// If the package has multiple configs (e.g. `unimodule.json` and `expo-module.config.json` during the transition time)
|
|
148
|
+
// then we want to give `expo-module.config.json` the priority.
|
|
149
|
+
return Object.values(
|
|
150
|
+
paths.reduce<Record<string, string>>((acc, configPath) => {
|
|
151
|
+
const dirname = path.dirname(configPath);
|
|
152
|
+
|
|
153
|
+
if (!acc[dirname] || configPriority(configPath) > configPriority(acc[dirname])) {
|
|
154
|
+
acc[dirname] = configPath;
|
|
155
|
+
}
|
|
156
|
+
return acc;
|
|
157
|
+
}, {})
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Resolves package name and version for the given {@link packagePath} from its `package.json`.
|
|
163
|
+
* if {@link fallbackToDirName} is true, it returns the dir name when `package.json` doesn't exist.
|
|
164
|
+
* @returns object with `name` and `version` properties. `version` falls back to `UNVERSIONED` if cannot be resolved.
|
|
165
|
+
*/
|
|
166
|
+
function resolvePackageNameAndVersion(
|
|
167
|
+
packagePath: string,
|
|
168
|
+
{ fallbackToDirName }: { fallbackToDirName?: boolean } = {}
|
|
169
|
+
): { name: string; version: string } {
|
|
170
|
+
try {
|
|
171
|
+
const { name, version } = require(path.join(packagePath, 'package.json'));
|
|
172
|
+
return { name, version: version || 'UNVERSIONED' };
|
|
173
|
+
} catch (e) {
|
|
174
|
+
if (fallbackToDirName) {
|
|
175
|
+
// we don't have the package.json name, so we'll use the directory name
|
|
176
|
+
return {
|
|
177
|
+
name: path.basename(packagePath),
|
|
178
|
+
version: 'UNVERSIONED',
|
|
179
|
+
};
|
|
180
|
+
} else {
|
|
181
|
+
throw e;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Filters out packages that are not the dependencies of the project.
|
|
188
|
+
*/
|
|
189
|
+
async function filterToProjectDependenciesAsync(
|
|
190
|
+
results: SearchResults,
|
|
191
|
+
options: Pick<SearchOptions, 'projectRoot' | 'silent'> & {
|
|
192
|
+
alwaysIncludedPackagesNames?: Set<string>;
|
|
193
|
+
}
|
|
194
|
+
): Promise<SearchResults> {
|
|
195
|
+
const filteredResults: SearchResults = {};
|
|
196
|
+
const visitedPackages = new Set<string>();
|
|
197
|
+
|
|
198
|
+
// iterate through always included package names and add them to the visited packages
|
|
199
|
+
// if the results contains them
|
|
200
|
+
for (const name of options.alwaysIncludedPackagesNames ?? []) {
|
|
201
|
+
if (results[name] && !visitedPackages.has(name)) {
|
|
202
|
+
filteredResults[name] = results[name];
|
|
203
|
+
visitedPackages.add(name);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Helper for traversing the dependency hierarchy.
|
|
208
|
+
function visitPackage(packageJsonPath: string) {
|
|
209
|
+
const packageJson = require(packageJsonPath);
|
|
210
|
+
|
|
211
|
+
// Prevent getting into the recursive loop.
|
|
212
|
+
if (visitedPackages.has(packageJson.name)) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
visitedPackages.add(packageJson.name);
|
|
216
|
+
|
|
217
|
+
// Iterate over the dependencies to find transitive modules.
|
|
218
|
+
for (const dependencyName in packageJson.dependencies) {
|
|
219
|
+
const dependencyResult = results[dependencyName];
|
|
220
|
+
|
|
221
|
+
if (!filteredResults[dependencyName]) {
|
|
222
|
+
let dependencyPackageJsonPath: string;
|
|
223
|
+
|
|
224
|
+
if (dependencyResult) {
|
|
225
|
+
filteredResults[dependencyName] = dependencyResult;
|
|
226
|
+
dependencyPackageJsonPath = path.join(dependencyResult.path, 'package.json');
|
|
227
|
+
} else {
|
|
228
|
+
try {
|
|
229
|
+
/**
|
|
230
|
+
* Custom `require` that resolves from the current working dir instead of this script path.
|
|
231
|
+
* **Requires Node v12.2.0**
|
|
232
|
+
*/
|
|
233
|
+
const projectRequire = createRequire(packageJsonPath);
|
|
234
|
+
dependencyPackageJsonPath = projectRequire.resolve(`${dependencyName}/package.json`);
|
|
235
|
+
} catch (error: any) {
|
|
236
|
+
// Some packages don't include package.json in its `exports` field,
|
|
237
|
+
// but none of our packages do that, so it seems fine to just ignore that type of error.
|
|
238
|
+
// Related issue: https://github.com/react-native-community/cli/issues/1168
|
|
239
|
+
if (!options.silent && error.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
|
|
240
|
+
console.warn(
|
|
241
|
+
chalk.yellow(`⚠️ Cannot resolve the path to "${dependencyName}" package.`)
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Visit the dependency package.
|
|
249
|
+
visitPackage(dependencyPackageJsonPath);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Visit project's package.
|
|
255
|
+
const projectPackageJsonPath = await getProjectPackageJsonPathAsync(options.projectRoot);
|
|
256
|
+
visitPackage(projectPackageJsonPath);
|
|
257
|
+
|
|
258
|
+
return filteredResults;
|
|
259
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
3
|
+
import { getLinkingImplementationForPlatform } from './utils';
|
|
4
|
+
import { GenerateModulesProviderOptions, GenerateOptions, ModuleDescriptor } from '../types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generates a source file listing all packages to link.
|
|
8
|
+
* Right know it works only for Android platform.
|
|
9
|
+
*/
|
|
10
|
+
export async function generatePackageListAsync(
|
|
11
|
+
modules: ModuleDescriptor[],
|
|
12
|
+
options: GenerateOptions
|
|
13
|
+
) {
|
|
14
|
+
try {
|
|
15
|
+
const platformLinking = getLinkingImplementationForPlatform(options.platform);
|
|
16
|
+
await platformLinking.generatePackageListAsync(modules, options.target, options.namespace);
|
|
17
|
+
} catch (e) {
|
|
18
|
+
console.error(
|
|
19
|
+
chalk.red(`Generating package list is not available for platform: ${options.platform}`)
|
|
20
|
+
);
|
|
21
|
+
throw e;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Generates ExpoModulesProvider file listing all packages to link.
|
|
27
|
+
* Right know it works only for Apple platforms.
|
|
28
|
+
*/
|
|
29
|
+
export async function generateModulesProviderAsync(
|
|
30
|
+
modules: ModuleDescriptor[],
|
|
31
|
+
options: GenerateModulesProviderOptions
|
|
32
|
+
) {
|
|
33
|
+
try {
|
|
34
|
+
const platformLinking = getLinkingImplementationForPlatform(options.platform);
|
|
35
|
+
await platformLinking.generateModulesProviderAsync(
|
|
36
|
+
modules,
|
|
37
|
+
options.target,
|
|
38
|
+
options.entitlement
|
|
39
|
+
);
|
|
40
|
+
} catch (e) {
|
|
41
|
+
console.error(
|
|
42
|
+
chalk.red(`Generating modules provider is not available for platform: ${options.platform}`)
|
|
43
|
+
);
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ResolveOptions } from '../types';
|
|
2
|
+
import { getLinkingImplementationForPlatform } from './utils';
|
|
3
|
+
|
|
4
|
+
export function getConfiguration(options: ResolveOptions) {
|
|
5
|
+
const platformLinking = getLinkingImplementationForPlatform(options.platform);
|
|
6
|
+
return platformLinking.getConfiguration?.(options);
|
|
7
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
|
|
3
|
+
import { findModulesAsync } from './findModules';
|
|
4
|
+
import {
|
|
5
|
+
getProjectPackageJsonPathAsync,
|
|
6
|
+
getProjectPackageJsonPathSync,
|
|
7
|
+
mergeLinkingOptionsAsync,
|
|
8
|
+
resolveSearchPathsAsync,
|
|
9
|
+
} from './mergeLinkingOptions';
|
|
10
|
+
import { resolveExtraBuildDependenciesAsync, resolveModulesAsync } from './resolveModules';
|
|
11
|
+
import type { ModuleDescriptor, SearchOptions } from '../types';
|
|
12
|
+
import { getConfiguration } from './getConfiguration';
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
findModulesAsync,
|
|
16
|
+
getProjectPackageJsonPathAsync,
|
|
17
|
+
mergeLinkingOptionsAsync,
|
|
18
|
+
resolveExtraBuildDependenciesAsync,
|
|
19
|
+
resolveModulesAsync,
|
|
20
|
+
resolveSearchPathsAsync,
|
|
21
|
+
getConfiguration,
|
|
22
|
+
};
|
|
23
|
+
export { generateModulesProviderAsync, generatePackageListAsync } from './generatePackageList';
|
|
24
|
+
export { verifySearchResults } from './verifySearchResults';
|
|
25
|
+
export * from '../types';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Programmatic API to query autolinked modules for a project.
|
|
29
|
+
*/
|
|
30
|
+
export async function queryAutolinkingModulesFromProjectAsync(
|
|
31
|
+
projectRoot: string,
|
|
32
|
+
options: Pick<SearchOptions, 'platform' | 'exclude' | 'onlyProjectDeps'>
|
|
33
|
+
): Promise<ModuleDescriptor[]> {
|
|
34
|
+
const searchPaths = await resolveSearchPathsAsync(null, projectRoot);
|
|
35
|
+
const linkOptions = await mergeLinkingOptionsAsync({ ...options, projectRoot, searchPaths });
|
|
36
|
+
const searchResults = await findModulesAsync(linkOptions);
|
|
37
|
+
return await resolveModulesAsync(searchResults, linkOptions);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get the project root directory from the current working directory.
|
|
42
|
+
*/
|
|
43
|
+
export function findProjectRootSync(cwd: string = process.cwd()): string {
|
|
44
|
+
return path.dirname(getProjectPackageJsonPathSync(cwd));
|
|
45
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import findUp from 'find-up';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
import type { PlatformAutolinkingOptions, SearchOptions, SupportedPlatform } from '../types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Find the path to the `package.json` of the closest project in the given project root.
|
|
9
|
+
*/
|
|
10
|
+
export async function getProjectPackageJsonPathAsync(projectRoot: string): Promise<string> {
|
|
11
|
+
const result = await findUp('package.json', { cwd: projectRoot });
|
|
12
|
+
if (!result) {
|
|
13
|
+
throw new Error(`Couldn't find "package.json" up from path "${projectRoot}"`);
|
|
14
|
+
}
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Synchronous version of {@link getProjectPackageJsonPathAsync}.
|
|
20
|
+
*/
|
|
21
|
+
export function getProjectPackageJsonPathSync(projectRoot: string): string {
|
|
22
|
+
const result = findUp.sync('package.json', { cwd: projectRoot });
|
|
23
|
+
if (!result) {
|
|
24
|
+
throw new Error(`Couldn't find "package.json" up from path "${projectRoot}"`);
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Merges autolinking options from different sources (the later the higher priority)
|
|
31
|
+
* - options defined in package.json's `expo.autolinking` field
|
|
32
|
+
* - platform-specific options from the above (e.g. `expo.autolinking.apple`)
|
|
33
|
+
* - options provided to the CLI command
|
|
34
|
+
*/
|
|
35
|
+
export async function mergeLinkingOptionsAsync<OptionsType extends SearchOptions>(
|
|
36
|
+
providedOptions: OptionsType
|
|
37
|
+
): Promise<OptionsType> {
|
|
38
|
+
const packageJson = require(await getProjectPackageJsonPathAsync(providedOptions.projectRoot));
|
|
39
|
+
const baseOptions = packageJson.expo?.autolinking as PlatformAutolinkingOptions;
|
|
40
|
+
const platformOptions = getPlatformOptions(providedOptions.platform, baseOptions);
|
|
41
|
+
const finalOptions = Object.assign(
|
|
42
|
+
{},
|
|
43
|
+
baseOptions,
|
|
44
|
+
platformOptions,
|
|
45
|
+
providedOptions
|
|
46
|
+
) as OptionsType;
|
|
47
|
+
|
|
48
|
+
// Makes provided paths absolute or falls back to default paths if none was provided.
|
|
49
|
+
finalOptions.searchPaths = await resolveSearchPathsAsync(
|
|
50
|
+
finalOptions.searchPaths,
|
|
51
|
+
providedOptions.projectRoot
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
finalOptions.nativeModulesDir = await resolveNativeModulesDirAsync(
|
|
55
|
+
finalOptions.nativeModulesDir,
|
|
56
|
+
providedOptions.projectRoot
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
return finalOptions;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Resolves autolinking search paths. If none is provided, it accumulates all node_modules when
|
|
64
|
+
* going up through the path components. This makes workspaces work out-of-the-box without any configs.
|
|
65
|
+
*/
|
|
66
|
+
export async function resolveSearchPathsAsync(
|
|
67
|
+
searchPaths: string[] | null,
|
|
68
|
+
cwd: string
|
|
69
|
+
): Promise<string[]> {
|
|
70
|
+
return searchPaths && searchPaths.length > 0
|
|
71
|
+
? searchPaths.map((searchPath) => path.resolve(cwd, searchPath))
|
|
72
|
+
: await findDefaultPathsAsync(cwd);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Looks up for workspace's `node_modules` paths.
|
|
77
|
+
*/
|
|
78
|
+
async function findDefaultPathsAsync(cwd: string): Promise<string[]> {
|
|
79
|
+
const paths = [];
|
|
80
|
+
let dir = cwd;
|
|
81
|
+
let pkgJsonPath: string | undefined;
|
|
82
|
+
|
|
83
|
+
while ((pkgJsonPath = await findUp('package.json', { cwd: dir }))) {
|
|
84
|
+
dir = path.dirname(path.dirname(pkgJsonPath));
|
|
85
|
+
paths.push(path.join(pkgJsonPath, '..', 'node_modules'));
|
|
86
|
+
|
|
87
|
+
// This stops the infinite loop when the package.json is placed at the root dir.
|
|
88
|
+
if (path.dirname(dir) === dir) {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return paths;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Finds the real path to custom native modules directory.
|
|
97
|
+
* - When {@link cwd} is inside the project directory, the path is searched relatively
|
|
98
|
+
* to the project root (directory with the `package.json` file).
|
|
99
|
+
* - When {@link cwd} is outside project directory (no `package.json` found), it is relative to
|
|
100
|
+
* the current working directory (the {@link cwd} param).
|
|
101
|
+
*
|
|
102
|
+
* @param nativeModulesDir path to custom native modules directory. Defaults to `"./modules"` if null.
|
|
103
|
+
* @param cwd current working directory
|
|
104
|
+
* @returns resolved native modules directory or `null` if it is not found or doesn't exist.
|
|
105
|
+
*/
|
|
106
|
+
async function resolveNativeModulesDirAsync(
|
|
107
|
+
nativeModulesDir: string | null | undefined,
|
|
108
|
+
cwd: string
|
|
109
|
+
): Promise<string | null> {
|
|
110
|
+
const packageJsonPath = await findUp('package.json', { cwd });
|
|
111
|
+
const projectRoot = packageJsonPath != null ? path.join(packageJsonPath, '..') : cwd;
|
|
112
|
+
const resolvedPath = path.resolve(projectRoot, nativeModulesDir || 'modules');
|
|
113
|
+
return fs.existsSync(resolvedPath) ? resolvedPath : null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Gets the platform-specific autolinking options from the base options.
|
|
118
|
+
*/
|
|
119
|
+
function getPlatformOptions(
|
|
120
|
+
platform: SupportedPlatform,
|
|
121
|
+
options?: PlatformAutolinkingOptions
|
|
122
|
+
): PlatformAutolinkingOptions {
|
|
123
|
+
if (platform === 'apple') {
|
|
124
|
+
return options?.apple ?? options?.ios ?? {};
|
|
125
|
+
}
|
|
126
|
+
return options?.[platform] ?? {};
|
|
127
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getLinkingImplementationForPlatform } from './utils';
|
|
2
|
+
import type { ExtraDependencies, ModuleDescriptor, ResolveOptions, SearchResults } from '../types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resolves search results to a list of platform-specific configuration.
|
|
6
|
+
*/
|
|
7
|
+
export async function resolveModulesAsync(
|
|
8
|
+
searchResults: SearchResults,
|
|
9
|
+
options: ResolveOptions
|
|
10
|
+
): Promise<ModuleDescriptor[]> {
|
|
11
|
+
const platformLinking = getLinkingImplementationForPlatform(options.platform);
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
await Promise.all(
|
|
15
|
+
Object.entries(searchResults).map(async ([packageName, revision]) => {
|
|
16
|
+
const resolvedModule = await platformLinking.resolveModuleAsync(
|
|
17
|
+
packageName,
|
|
18
|
+
revision,
|
|
19
|
+
options
|
|
20
|
+
);
|
|
21
|
+
return resolvedModule
|
|
22
|
+
? {
|
|
23
|
+
packageName,
|
|
24
|
+
packageVersion: revision.version,
|
|
25
|
+
...resolvedModule,
|
|
26
|
+
}
|
|
27
|
+
: null;
|
|
28
|
+
})
|
|
29
|
+
)
|
|
30
|
+
)
|
|
31
|
+
.filter(Boolean)
|
|
32
|
+
.sort((a, b) => a.packageName.localeCompare(b.packageName));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Resolves the extra build dependencies for the project, such as additional Maven repositories or CocoaPods pods.
|
|
37
|
+
*/
|
|
38
|
+
export async function resolveExtraBuildDependenciesAsync(
|
|
39
|
+
options: ResolveOptions
|
|
40
|
+
): Promise<ExtraDependencies> {
|
|
41
|
+
const platformLinking = getLinkingImplementationForPlatform(options.platform);
|
|
42
|
+
const extraDependencies = await platformLinking.resolveExtraBuildDependenciesAsync(
|
|
43
|
+
options.projectRoot
|
|
44
|
+
);
|
|
45
|
+
return extraDependencies ?? [];
|
|
46
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
|
|
3
|
+
import { SupportedPlatform } from '../types';
|
|
4
|
+
|
|
5
|
+
export function getLinkingImplementationForPlatform(platform: SupportedPlatform) {
|
|
6
|
+
switch (platform) {
|
|
7
|
+
case 'ios':
|
|
8
|
+
case 'macos':
|
|
9
|
+
case 'tvos':
|
|
10
|
+
case 'apple':
|
|
11
|
+
return require('../platforms/apple');
|
|
12
|
+
case 'android':
|
|
13
|
+
return require('../platforms/android');
|
|
14
|
+
case 'devtools':
|
|
15
|
+
return require('../platforms/devtools');
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get the possible path to the pnpm isolated modules folder.
|
|
21
|
+
*/
|
|
22
|
+
export function getIsolatedModulesPath(packagePath: string, packageName: string): string | null {
|
|
23
|
+
// Check if the project is using isolated modules, by checking
|
|
24
|
+
// if the parent dir of `packagePath` is a `node_modules` folder.
|
|
25
|
+
// Isolated modules installs dependencies in small groups such as:
|
|
26
|
+
// - /.pnpm/expo@50.x.x(...)/node_modules/@expo/cli
|
|
27
|
+
// - /.pnpm/expo@50.x.x(...)/node_modules/expo
|
|
28
|
+
// - /.pnpm/expo@50.x.x(...)/node_modules/expo-application
|
|
29
|
+
// When isolated modules are detected, expand the `searchPaths`
|
|
30
|
+
// to include possible nested dependencies.
|
|
31
|
+
const maybeIsolatedModulesPath = path.join(
|
|
32
|
+
packagePath,
|
|
33
|
+
packageName.startsWith('@') && packageName.includes('/') ? '../..' : '..' // scoped packages are nested deeper
|
|
34
|
+
);
|
|
35
|
+
const isIsolatedModulesPath = path.basename(maybeIsolatedModulesPath) === 'node_modules';
|
|
36
|
+
return isIsolatedModulesPath ? maybeIsolatedModulesPath : null;
|
|
37
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import { PackageRevision, SearchOptions, SearchResults } from '../types';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Verifies the search results by checking whether there are no duplicates.
|
|
8
|
+
*/
|
|
9
|
+
export function verifySearchResults(searchResults: SearchResults, options: SearchOptions): number {
|
|
10
|
+
const relativePath: (pkg: PackageRevision) => string = (pkg) =>
|
|
11
|
+
path.relative(options.projectRoot, pkg.path);
|
|
12
|
+
let counter = 0;
|
|
13
|
+
|
|
14
|
+
for (const moduleName in searchResults) {
|
|
15
|
+
const revision = searchResults[moduleName];
|
|
16
|
+
|
|
17
|
+
if (revision.duplicates?.length) {
|
|
18
|
+
console.warn(`⚠️ Found multiple versions of ${chalk.green(moduleName)}`);
|
|
19
|
+
console.log(` - ${chalk.magenta(relativePath(revision))} (${chalk.cyan(revision.version)})`);
|
|
20
|
+
|
|
21
|
+
for (const duplicate of revision.duplicates) {
|
|
22
|
+
console.log(` - ${chalk.gray(relativePath(duplicate))} (${chalk.gray(duplicate.version)})`);
|
|
23
|
+
}
|
|
24
|
+
counter++;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (counter > 0) {
|
|
28
|
+
console.warn(
|
|
29
|
+
'⚠️ Multiple versions of the same module may introduce some side effects or compatibility issues. Remove the duplicate versions.'
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
return counter;
|
|
33
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import fs from 'fs/promises';
|
|
2
|
+
import { glob, GlobOptions } from 'glob';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A matching function that takes a file path and its contents and returns a string if it matches, or null otherwise.
|
|
7
|
+
*/
|
|
8
|
+
type MatchFunctor = (filePath: string, contents: Buffer) => string | null;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Check if the file exists.
|
|
12
|
+
*/
|
|
13
|
+
export async function fileExistsAsync(file: string): Promise<boolean> {
|
|
14
|
+
return (await fs.stat(file).catch(() => null))?.isFile() ?? false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Search files that match the glob pattern and return all matches from the matchFunctor.
|
|
19
|
+
*/
|
|
20
|
+
export async function globMatchFunctorAllAsync(
|
|
21
|
+
globPattern: string,
|
|
22
|
+
matchFunctor: MatchFunctor,
|
|
23
|
+
options?: GlobOptions
|
|
24
|
+
): Promise<string[]> {
|
|
25
|
+
const globStream = glob.stream(globPattern, { ...options, withFileTypes: false });
|
|
26
|
+
const cwd = options?.cwd !== undefined ? `${options.cwd}` : process.cwd();
|
|
27
|
+
const results: string[] = [];
|
|
28
|
+
for await (const file of globStream) {
|
|
29
|
+
let filePath = file.toString();
|
|
30
|
+
if (!path.isAbsolute(filePath)) {
|
|
31
|
+
filePath = path.resolve(cwd, filePath);
|
|
32
|
+
}
|
|
33
|
+
const contents = await fs.readFile(filePath);
|
|
34
|
+
const matched = matchFunctor(filePath, contents);
|
|
35
|
+
if (matched != null) {
|
|
36
|
+
results.push(matched);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return results;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Search files that match the glob pattern and return the first match from the matchFunctor.
|
|
44
|
+
*/
|
|
45
|
+
export async function globMatchFunctorFirstAsync(
|
|
46
|
+
globPattern: string,
|
|
47
|
+
matchFunctor: MatchFunctor,
|
|
48
|
+
options?: GlobOptions
|
|
49
|
+
): Promise<string | null> {
|
|
50
|
+
const globStream = glob.stream(globPattern, { ...options, withFileTypes: false });
|
|
51
|
+
const cwd = options?.cwd !== undefined ? `${options.cwd}` : process.cwd();
|
|
52
|
+
for await (const file of globStream) {
|
|
53
|
+
let filePath = file.toString();
|
|
54
|
+
if (!path.isAbsolute(filePath)) {
|
|
55
|
+
filePath = path.resolve(cwd, filePath);
|
|
56
|
+
}
|
|
57
|
+
const contents = await fs.readFile(filePath);
|
|
58
|
+
const matched = matchFunctor(filePath, contents);
|
|
59
|
+
if (matched != null) {
|
|
60
|
+
return matched;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
}
|