expo-modules-autolinking
Advanced tools
Comparing version 1.12.0-canary-20240912-1059f85 to 2.0.0-canary-20240927-ab8a962
@@ -1,2 +0,2 @@ | ||
import { GenerateOptions, ModuleDescriptor } from '../types'; | ||
import { GenerateModulesProviderOptions, GenerateOptions, ModuleDescriptor } from '../types'; | ||
/** | ||
@@ -7,1 +7,6 @@ * Generates a source file listing all packages to link. | ||
export declare function generatePackageListAsync(modules: ModuleDescriptor[], options: GenerateOptions): Promise<void>; | ||
/** | ||
* Generates ExpoModulesProvider file listing all packages to link. | ||
* Right know it works only for Apple platforms. | ||
*/ | ||
export declare function generateModulesProviderAsync(modules: ModuleDescriptor[], options: GenerateModulesProviderOptions): Promise<void>; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generatePackageListAsync = void 0; | ||
exports.generateModulesProviderAsync = exports.generatePackageListAsync = void 0; | ||
const chalk_1 = __importDefault(require("chalk")); | ||
@@ -25,2 +25,17 @@ const utils_1 = require("./utils"); | ||
exports.generatePackageListAsync = generatePackageListAsync; | ||
/** | ||
* Generates ExpoModulesProvider file listing all packages to link. | ||
* Right know it works only for Apple platforms. | ||
*/ | ||
async function generateModulesProviderAsync(modules, options) { | ||
try { | ||
const platformLinking = (0, utils_1.getLinkingImplementationForPlatform)(options.platform); | ||
await platformLinking.generateModulesProviderAsync(modules, options.target, options.entitlement); | ||
} | ||
catch (e) { | ||
console.error(chalk_1.default.red(`Generating modules provider is not available for platform: ${options.platform}`)); | ||
throw e; | ||
} | ||
} | ||
exports.generateModulesProviderAsync = generateModulesProviderAsync; | ||
//# sourceMappingURL=generatePackageList.js.map |
@@ -6,3 +6,3 @@ import { findModulesAsync } from './findModules'; | ||
export { findModulesAsync, getProjectPackageJsonPathAsync, mergeLinkingOptionsAsync, resolveExtraBuildDependenciesAsync, resolveModulesAsync, resolveSearchPathsAsync, }; | ||
export { generatePackageListAsync } from './generatePackageList'; | ||
export { generateModulesProviderAsync, generatePackageListAsync } from './generatePackageList'; | ||
export { verifySearchResults } from './verifySearchResults'; | ||
@@ -9,0 +9,0 @@ export * from '../types'; |
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.queryAutolinkingModulesFromProjectAsync = exports.verifySearchResults = exports.generatePackageListAsync = exports.resolveSearchPathsAsync = exports.resolveModulesAsync = exports.resolveExtraBuildDependenciesAsync = exports.mergeLinkingOptionsAsync = exports.getProjectPackageJsonPathAsync = exports.findModulesAsync = void 0; | ||
exports.queryAutolinkingModulesFromProjectAsync = exports.verifySearchResults = exports.generatePackageListAsync = exports.generateModulesProviderAsync = exports.resolveSearchPathsAsync = exports.resolveModulesAsync = exports.resolveExtraBuildDependenciesAsync = exports.mergeLinkingOptionsAsync = exports.getProjectPackageJsonPathAsync = exports.findModulesAsync = void 0; | ||
const findModules_1 = require("./findModules"); | ||
@@ -29,2 +29,3 @@ Object.defineProperty(exports, "findModulesAsync", { enumerable: true, get: function () { return findModules_1.findModulesAsync; } }); | ||
var generatePackageList_1 = require("./generatePackageList"); | ||
Object.defineProperty(exports, "generateModulesProviderAsync", { enumerable: true, get: function () { return generatePackageList_1.generateModulesProviderAsync; } }); | ||
Object.defineProperty(exports, "generatePackageListAsync", { enumerable: true, get: function () { return generatePackageList_1.generatePackageListAsync; } }); | ||
@@ -31,0 +32,0 @@ var verifySearchResults_1 = require("./verifySearchResults"); |
@@ -8,3 +8,2 @@ "use strict"; | ||
const path_1 = __importDefault(require("path")); | ||
const ReactImportsPatcher_1 = require("./ReactImportsPatcher"); | ||
const autolinking_1 = require("./autolinking"); | ||
@@ -42,10 +41,2 @@ const reactNativeConfig_1 = require("./reactNativeConfig"); | ||
} | ||
// Register for `patch-react-imports` command | ||
function registerPatchReactImportsCommand() { | ||
return commander_1.default | ||
.command('patch-react-imports [paths...]') | ||
.requiredOption('--pods-root <podsRoot>', 'The path to `Pods` directory') | ||
.option('--dry-run', 'Only list files without writing changes to the file system') | ||
.action(ReactImportsPatcher_1.patchReactImportsAsync); | ||
} | ||
/** | ||
@@ -109,3 +100,3 @@ * Registry the `react-native-config` command. | ||
// Generates a source file listing all packages to link. | ||
// It's deprecated, use `generate-modules-provider` instead. | ||
// It's deprecated for apple platforms, use `generate-modules-provider` instead. | ||
registerResolveCommand('generate-package-list', async (results, options) => { | ||
@@ -123,7 +114,7 @@ const modules = options.empty ? [] : await (0, autolinking_1.resolveModulesAsync)(results, options); | ||
const filteredModules = modules.filter((module) => packages.includes(module.packageName)); | ||
(0, autolinking_1.generatePackageListAsync)(filteredModules, options); | ||
(0, autolinking_1.generateModulesProviderAsync)(filteredModules, options); | ||
}) | ||
.option('-t, --target <path>', 'Path to the target file, where the package list should be written to.') | ||
.option('--entitlement <path>', 'Path to the Apple code signing entitlements file.') | ||
.option('-p, --packages <packages...>', 'Names of the packages to include in the generated modules provider.'); | ||
registerPatchReactImportsCommand(); | ||
registerReactNativeConfigCommand(); | ||
@@ -130,0 +121,0 @@ await commander_1.default |
@@ -11,3 +11,3 @@ import type { ExtraDependencies, ModuleDescriptorIos, ModuleIosPodspecInfo, PackageRevision, SearchOptions } from '../types'; | ||
*/ | ||
export declare function generatePackageListAsync(modules: ModuleDescriptorIos[], targetPath: string): Promise<void>; | ||
export declare function generateModulesProviderAsync(modules: ModuleDescriptorIos[], targetPath: string, entitlementPath: string): Promise<void>; | ||
/** | ||
@@ -14,0 +14,0 @@ * Formats an array of modules to Swift's array containing ReactDelegateHandlers |
@@ -6,6 +6,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.formatArrayOfReactDelegateHandler = exports.generatePackageListAsync = exports.resolveExtraBuildDependenciesAsync = exports.resolveModuleAsync = exports.getSwiftModuleNames = void 0; | ||
exports.formatArrayOfReactDelegateHandler = exports.generateModulesProviderAsync = exports.resolveExtraBuildDependenciesAsync = exports.resolveModuleAsync = exports.getSwiftModuleNames = void 0; | ||
const spawn_async_1 = __importDefault(require("@expo/spawn-async")); | ||
const fast_glob_1 = __importDefault(require("fast-glob")); | ||
const fs_extra_1 = __importDefault(require("fs-extra")); | ||
const path_1 = __importDefault(require("path")); | ||
const fileUtils_1 = require("../fileUtils"); | ||
const APPLE_PROPERTIES_FILE = 'Podfile.properties.json'; | ||
@@ -76,12 +78,13 @@ const APPLE_EXTRA_BUILD_DEPS_KEY = 'apple.extraPods'; | ||
*/ | ||
async function generatePackageListAsync(modules, targetPath) { | ||
async function generateModulesProviderAsync(modules, targetPath, entitlementPath) { | ||
const className = path_1.default.basename(targetPath, path_1.default.extname(targetPath)); | ||
const generatedFileContent = await generatePackageListFileContentAsync(modules, className); | ||
const entitlements = await parseEntitlementsAsync(entitlementPath); | ||
const generatedFileContent = await generatePackageListFileContentAsync(modules, className, entitlements); | ||
await fs_extra_1.default.outputFile(targetPath, generatedFileContent); | ||
} | ||
exports.generatePackageListAsync = generatePackageListAsync; | ||
exports.generateModulesProviderAsync = generateModulesProviderAsync; | ||
/** | ||
* Generates the string to put into the generated package list. | ||
*/ | ||
async function generatePackageListFileContentAsync(modules, className) { | ||
async function generatePackageListFileContentAsync(modules, className, entitlements) { | ||
const iosModules = modules.filter((module) => module.modules.length || | ||
@@ -131,2 +134,6 @@ module.appDelegateSubscribers.length || | ||
} | ||
public override func getAppCodeSignEntitlements() -> AppCodeSignEntitlements { | ||
return AppCodeSignEntitlements.from(json: #"${JSON.stringify(entitlements)}"#) | ||
} | ||
} | ||
@@ -189,2 +196,12 @@ `; | ||
} | ||
async function parseEntitlementsAsync(entitlementPath) { | ||
if (!(await (0, fileUtils_1.fileExistsAsync)(entitlementPath))) { | ||
return {}; | ||
} | ||
const { stdout } = await (0, spawn_async_1.default)('plutil', ['-convert', 'json', '-o', '-', entitlementPath]); | ||
const entitlementsJson = JSON.parse(stdout); | ||
return { | ||
appGroups: entitlementsJson['com.apple.security.application-groups'] || undefined, | ||
}; | ||
} | ||
//# sourceMappingURL=apple.js.map |
@@ -17,4 +17,4 @@ import type { RNConfigDependencyAndroid, RNConfigReactNativePlatformsConfigAndroid } from './reactNativeConfig.types'; | ||
}): Promise<{ | ||
gradle: string; | ||
manifest: string; | ||
gradle: string | null; | ||
manifest: string | null; | ||
}>; |
@@ -10,3 +10,3 @@ "use strict"; | ||
const path_1 = __importDefault(require("path")); | ||
const utils_1 = require("./utils"); | ||
const fileUtils_1 = require("../fileUtils"); | ||
async function resolveDependencyConfigImplAndroidAsync(packageRoot, reactNativeConfig) { | ||
@@ -19,3 +19,3 @@ if (reactNativeConfig === null) { | ||
const { gradle, manifest } = await findGradleAndManifestAsync({ androidDir, isLibrary: true }); | ||
if (!manifest && !gradle) { | ||
if (!manifest || !gradle) { | ||
return null; | ||
@@ -98,3 +98,3 @@ } | ||
async function parseNativePackageClassNameAsync(packageRoot, androidDir) { | ||
const matched = await (0, utils_1.globMatchFunctorFirstAsync)('**/*Package.{java,kt}', matchNativePackageClassName, { cwd: androidDir }); | ||
const matched = await (0, fileUtils_1.globMatchFunctorFirstAsync)('**/*Package.{java,kt}', matchNativePackageClassName, { cwd: androidDir }); | ||
if (matched) { | ||
@@ -104,6 +104,6 @@ return matched; | ||
// Early return if the module is an Expo module | ||
if (await (0, utils_1.fileExistsAsync)(path_1.default.join(packageRoot, 'expo-module.config.json'))) { | ||
if (await (0, fileUtils_1.fileExistsAsync)(path_1.default.join(packageRoot, 'expo-module.config.json'))) { | ||
return null; | ||
} | ||
return await (0, utils_1.globMatchFunctorFirstAsync)('**/*.{java,kt}', matchNativePackageClassName, { | ||
return await (0, fileUtils_1.globMatchFunctorFirstAsync)('**/*.{java,kt}', matchNativePackageClassName, { | ||
cwd: androidDir, | ||
@@ -145,3 +145,3 @@ }); | ||
// [1] `libraryName` from build.gradle | ||
if (await (0, utils_1.fileExistsAsync)(gradlePath)) { | ||
if (await (0, fileUtils_1.fileExistsAsync)(gradlePath)) { | ||
const buildGradleContents = await promises_1.default.readFile(gradlePath, 'utf8'); | ||
@@ -155,3 +155,3 @@ const match = buildGradleContents.match(libraryNameRegExp); | ||
const gradleKtsPath = path_1.default.join(androidDir, 'build.gradle.kts'); | ||
if (await (0, utils_1.fileExistsAsync)(gradleKtsPath)) { | ||
if (await (0, fileUtils_1.fileExistsAsync)(gradleKtsPath)) { | ||
const buildGradleContents = await promises_1.default.readFile(gradleKtsPath, 'utf8'); | ||
@@ -170,3 +170,3 @@ const match = buildGradleContents.match(libraryNameRegExp); | ||
: packageRoot; | ||
const results = await (0, utils_1.globMatchFunctorAllAsync)('**/*.{js,jsx,ts,tsx}', matchComponentDescriptors, { | ||
const results = await (0, fileUtils_1.globMatchFunctorAllAsync)('**/*.{js,jsx,ts,tsx}', matchComponentDescriptors, { | ||
cwd: jsRoot, | ||
@@ -212,5 +212,5 @@ ignore: ['**/node_modules/**'], | ||
const gradle = gradles[0]; | ||
return { gradle, manifest }; | ||
return { gradle: gradle || null, manifest: manifest || null }; | ||
} | ||
exports.findGradleAndManifestAsync = findGradleAndManifestAsync; | ||
//# sourceMappingURL=androidResolver.js.map |
@@ -11,3 +11,3 @@ "use strict"; | ||
const resolve_from_1 = __importDefault(require("resolve-from")); | ||
const utils_1 = require("./utils"); | ||
const fileUtils_1 = require("../fileUtils"); | ||
let tsMain = undefined; | ||
@@ -19,3 +19,3 @@ /** | ||
const configJsPath = path_1.default.join(packageRoot, 'react-native.config.js'); | ||
if (await (0, utils_1.fileExistsAsync)(configJsPath)) { | ||
if (await (0, fileUtils_1.fileExistsAsync)(configJsPath)) { | ||
try { | ||
@@ -29,3 +29,3 @@ return require(configJsPath); | ||
const configTsPath = path_1.default.join(packageRoot, 'react-native.config.ts'); | ||
if (await (0, utils_1.fileExistsAsync)(configTsPath)) { | ||
if (await (0, fileUtils_1.fileExistsAsync)(configTsPath)) { | ||
if (tsMain === undefined) { | ||
@@ -32,0 +32,0 @@ const tsPath = resolve_from_1.default.silent(packageRoot, 'typescript'); |
@@ -12,4 +12,4 @@ "use strict"; | ||
const iosResolver_1 = require("./iosResolver"); | ||
const utils_1 = require("./utils"); | ||
const utils_2 = require("../autolinking/utils"); | ||
const utils_1 = require("../autolinking/utils"); | ||
const fileUtils_1 = require("../fileUtils"); | ||
/** | ||
@@ -51,6 +51,6 @@ * Create config for react-native core autolinking. | ||
const packageConfigPath = path_1.default.resolve(searchPath, name, 'package.json'); | ||
if (await (0, utils_1.fileExistsAsync)(packageConfigPath)) { | ||
if (await (0, fileUtils_1.fileExistsAsync)(packageConfigPath)) { | ||
const packageRoot = path_1.default.dirname(packageConfigPath); | ||
results[name] = packageRoot; | ||
const maybeIsolatedModulesPath = (0, utils_2.getIsolatedModulesPath)(packageRoot, name); | ||
const maybeIsolatedModulesPath = (0, utils_1.getIsolatedModulesPath)(packageRoot, name); | ||
if (maybeIsolatedModulesPath) { | ||
@@ -75,5 +75,10 @@ searchPathSet.add(maybeIsolatedModulesPath); | ||
// The rnc-cli will skip this package. | ||
// For example, the `react-native` package. | ||
return null; | ||
} | ||
if (name === 'react-native') { | ||
// Starting from version 0.76, the `react-native` package only defines platforms | ||
// when @react-native-community/cli-platform-android/ios is installed. | ||
// Therefore, we need to manually filter it out. | ||
return null; | ||
} | ||
let platformData = null; | ||
@@ -102,2 +107,5 @@ if (platform === 'android') { | ||
const { gradle, manifest } = await (0, androidResolver_1.findGradleAndManifestAsync)({ androidDir, isLibrary: false }); | ||
if (gradle == null || manifest == null) { | ||
return {}; | ||
} | ||
const packageName = await (0, androidResolver_1.parsePackageNameAsync)(path_1.default.join(androidDir, manifest), path_1.default.join(androidDir, gradle)); | ||
@@ -104,0 +112,0 @@ return { |
@@ -40,8 +40,5 @@ import { ExpoModuleConfig } from './ExpoModuleConfig'; | ||
target: string; | ||
entitlement?: string; | ||
packages: string[]; | ||
} | ||
export interface PatchReactImportsOptions { | ||
podsRoot: string; | ||
dryRun: boolean; | ||
} | ||
export type PackageRevision = { | ||
@@ -256,2 +253,11 @@ path: string; | ||
export type ExtraDependencies = AndroidMavenRepository[] | ApplePod[]; | ||
/** | ||
* Represents code signing entitlements passed to the `ExpoModulesProvider` for Apple platforms. | ||
*/ | ||
export interface AppleCodeSignEntitlements { | ||
/** | ||
* @see https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_application-groups | ||
*/ | ||
appGroups?: string[]; | ||
} | ||
export {}; |
@@ -7,6 +7,9 @@ # Changelog | ||
- Removed the deprecated `generate-package-list` command for Apple platforms. ([#31518](https://github.com/expo/expo/pull/31518) by [@kudo](https://github.com/kudo)) | ||
### 🎉 New features | ||
- Added `react-native-config` command to support core autolinking for react-native. ([#29818](https://github.com/expo/expo/pull/29818) by [@kudo](https://github.com/kudo)) | ||
- Added AAR files autolinking as Gradle projects. ([#30706](https://github.com/expo/expo/pull/30706) by [@kudo](https://github.com/kudo)) | ||
- Add support for react-native 0.76 ([#31593](https://github.com/expo/expo/pull/31593) by [@gabrieldonadel](https://github.com/gabrieldonadel)) | ||
- Added Apple code sign entitlements to generated `ExpoModulesProvider.swift`. ([#31518](https://github.com/expo/expo/pull/31518) by [@kudo](https://github.com/kudo)) | ||
@@ -17,8 +20,20 @@ ### 🐛 Bug fixes | ||
- [Android] Fixed autolinking when using Gradle Kotlin script. ([#30448](https://github.com/expo/expo/pull/30448) by [@amrfarid140](https://github.com/amrfarid140)) | ||
- Added missing `project.android.packageName` in react-native-config for Android core autolinking. ([#30913](https://github.com/expo/expo/pull/30913) by [@kudo](https://github.com/kudo)) | ||
- Fixed core autolinking for react-native-maps. ([#31190](https://github.com/expo/expo/pull/31190) by [@kudo](https://github.com/kudo)) | ||
- Fixed broken `searchPaths` from package.json. ([#31196](https://github.com/expo/expo/pull/31196) by [@kudo](https://github.com/kudo)) | ||
- Fixed `react-native-config` error when running on CNG projects without Android native files. ([#31637](https://github.com/expo/expo/pull/31637) by [@kudo](https://github.com/kudo)) | ||
### 💡 Others | ||
- Removed `expo_patch_react_imports!` and align more stardard react-native project layout. ([#31699](https://github.com/expo/expo/pull/31699) by [@kudo](https://github.com/kudo)) | ||
## 1.11.2 - 2024-08-14 | ||
### 🎉 New features | ||
- Added `react-native-config` command to support core autolinking for react-native. ([#29818](https://github.com/expo/expo/pull/29818) by [@kudo](https://github.com/kudo)) | ||
### 🐛 Bug fixes | ||
- Added missing `project.android.packageName` in react-native-config for Android core autolinking. ([#30913](https://github.com/expo/expo/pull/30913) by [@kudo](https://github.com/kudo)) | ||
## 1.11.1 — 2024-04-23 | ||
@@ -25,0 +40,0 @@ |
{ | ||
"name": "expo-modules-autolinking", | ||
"version": "1.12.0-canary-20240912-1059f85", | ||
"version": "2.0.0-canary-20240927-ab8a962", | ||
"description": "Scripts that autolink Expo modules.", | ||
@@ -37,8 +37,8 @@ "main": "build/index.js", | ||
"devDependencies": { | ||
"@expo/spawn-async": "^1.7.2", | ||
"@types/fs-extra": "^9.0.11", | ||
"expo-module-scripts": "3.6.0-canary-20240912-1059f85", | ||
"expo-module-scripts": "3.6.0-canary-20240927-ab8a962", | ||
"minimatch": "^3.0.4" | ||
}, | ||
"dependencies": { | ||
"@expo/spawn-async": "^1.7.2", | ||
"chalk": "^4.1.0", | ||
@@ -52,3 +52,3 @@ "commander": "^7.2.0", | ||
}, | ||
"gitHead": "1059f8556047a3e02fa319e8b2459274571f4e6f" | ||
"gitHead": "ab8a962d2c3dddbda124a6bd88d24475831dae00" | ||
} |
import chalk from 'chalk'; | ||
import { getLinkingImplementationForPlatform } from './utils'; | ||
import { GenerateOptions, ModuleDescriptor } from '../types'; | ||
import { GenerateModulesProviderOptions, GenerateOptions, ModuleDescriptor } from '../types'; | ||
@@ -24,1 +24,24 @@ /** | ||
} | ||
/** | ||
* Generates ExpoModulesProvider file listing all packages to link. | ||
* Right know it works only for Apple platforms. | ||
*/ | ||
export async function generateModulesProviderAsync( | ||
modules: ModuleDescriptor[], | ||
options: GenerateModulesProviderOptions | ||
) { | ||
try { | ||
const platformLinking = getLinkingImplementationForPlatform(options.platform); | ||
await platformLinking.generateModulesProviderAsync( | ||
modules, | ||
options.target, | ||
options.entitlement | ||
); | ||
} catch (e) { | ||
console.error( | ||
chalk.red(`Generating modules provider is not available for platform: ${options.platform}`) | ||
); | ||
throw e; | ||
} | ||
} |
@@ -18,3 +18,3 @@ import { findModulesAsync } from './findModules'; | ||
}; | ||
export { generatePackageListAsync } from './generatePackageList'; | ||
export { generateModulesProviderAsync, generatePackageListAsync } from './generatePackageList'; | ||
export { verifySearchResults } from './verifySearchResults'; | ||
@@ -21,0 +21,0 @@ export * from '../types'; |
import commander from 'commander'; | ||
import path from 'path'; | ||
import { patchReactImportsAsync } from './ReactImportsPatcher'; | ||
import { | ||
findModulesAsync, | ||
generateModulesProviderAsync, | ||
generatePackageListAsync, | ||
@@ -85,11 +85,2 @@ getProjectPackageJsonPathAsync, | ||
// Register for `patch-react-imports` command | ||
function registerPatchReactImportsCommand() { | ||
return commander | ||
.command('patch-react-imports [paths...]') | ||
.requiredOption('--pods-root <podsRoot>', 'The path to `Pods` directory') | ||
.option('--dry-run', 'Only list files without writing changes to the file system') | ||
.action(patchReactImportsAsync); | ||
} | ||
/** | ||
@@ -164,3 +155,3 @@ * Registry the `react-native-config` command. | ||
// Generates a source file listing all packages to link. | ||
// It's deprecated, use `generate-modules-provider` instead. | ||
// It's deprecated for apple platforms, use `generate-modules-provider` instead. | ||
registerResolveCommand<GenerateOptions>('generate-package-list', async (results, options) => { | ||
@@ -192,3 +183,3 @@ const modules = options.empty ? [] : await resolveModulesAsync(results, options); | ||
generatePackageListAsync(filteredModules, options); | ||
generateModulesProviderAsync(filteredModules, options); | ||
} | ||
@@ -200,2 +191,3 @@ ) | ||
) | ||
.option('--entitlement <path>', 'Path to the Apple code signing entitlements file.') | ||
.option( | ||
@@ -206,3 +198,2 @@ '-p, --packages <packages...>', | ||
registerPatchReactImportsCommand(); | ||
registerReactNativeConfigCommand(); | ||
@@ -209,0 +200,0 @@ |
@@ -0,1 +1,2 @@ | ||
import spawnAsync from '@expo/spawn-async'; | ||
import glob from 'fast-glob'; | ||
@@ -5,3 +6,5 @@ import fs from 'fs-extra'; | ||
import { fileExistsAsync } from '../fileUtils'; | ||
import type { | ||
AppleCodeSignEntitlements, | ||
ExtraDependencies, | ||
@@ -95,8 +98,14 @@ ModuleDescriptorIos, | ||
*/ | ||
export async function generatePackageListAsync( | ||
export async function generateModulesProviderAsync( | ||
modules: ModuleDescriptorIos[], | ||
targetPath: string | ||
targetPath: string, | ||
entitlementPath: string | ||
): Promise<void> { | ||
const className = path.basename(targetPath, path.extname(targetPath)); | ||
const generatedFileContent = await generatePackageListFileContentAsync(modules, className); | ||
const entitlements = await parseEntitlementsAsync(entitlementPath); | ||
const generatedFileContent = await generatePackageListFileContentAsync( | ||
modules, | ||
className, | ||
entitlements | ||
); | ||
@@ -111,3 +120,4 @@ await fs.outputFile(targetPath, generatedFileContent); | ||
modules: ModuleDescriptorIos[], | ||
className: string | ||
className: string, | ||
entitlements: AppleCodeSignEntitlements | ||
): Promise<string> { | ||
@@ -179,2 +189,6 @@ const iosModules = modules.filter( | ||
} | ||
public override func getAppCodeSignEntitlements() -> AppCodeSignEntitlements { | ||
return AppCodeSignEntitlements.from(json: #"${JSON.stringify(entitlements)}"#) | ||
} | ||
} | ||
@@ -269,1 +283,12 @@ `; | ||
} | ||
async function parseEntitlementsAsync(entitlementPath: string): Promise<AppleCodeSignEntitlements> { | ||
if (!(await fileExistsAsync(entitlementPath))) { | ||
return {}; | ||
} | ||
const { stdout } = await spawnAsync('plutil', ['-convert', 'json', '-o', '-', entitlementPath]); | ||
const entitlementsJson = JSON.parse(stdout); | ||
return { | ||
appGroups: entitlementsJson['com.apple.security.application-groups'] || undefined, | ||
}; | ||
} |
@@ -9,3 +9,7 @@ import glob from 'fast-glob'; | ||
} from './reactNativeConfig.types'; | ||
import { fileExistsAsync, globMatchFunctorAllAsync, globMatchFunctorFirstAsync } from './utils'; | ||
import { | ||
fileExistsAsync, | ||
globMatchFunctorAllAsync, | ||
globMatchFunctorFirstAsync, | ||
} from '../fileUtils'; | ||
@@ -22,3 +26,3 @@ export async function resolveDependencyConfigImplAndroidAsync( | ||
const { gradle, manifest } = await findGradleAndManifestAsync({ androidDir, isLibrary: true }); | ||
if (!manifest && !gradle) { | ||
if (!manifest || !gradle) { | ||
return null; | ||
@@ -237,3 +241,3 @@ } | ||
isLibrary: boolean; | ||
}): Promise<{ gradle: string; manifest: string }> { | ||
}): Promise<{ gradle: string | null; manifest: string | null }> { | ||
const globExcludes = [ | ||
@@ -257,3 +261,3 @@ 'node_modules/**', | ||
const gradle = gradles[0]; | ||
return { gradle, manifest }; | ||
return { gradle: gradle || null, manifest: manifest || null }; | ||
} |
@@ -7,3 +7,3 @@ import fs from 'fs/promises'; | ||
import type { RNConfigReactNativeConfig } from './reactNativeConfig.types'; | ||
import { fileExistsAsync } from './utils'; | ||
import { fileExistsAsync } from '../fileUtils'; | ||
@@ -10,0 +10,0 @@ let tsMain: typeof import('typescript') | null | undefined = undefined; |
@@ -19,4 +19,4 @@ import fs from 'fs/promises'; | ||
} from './reactNativeConfig.types'; | ||
import { fileExistsAsync } from './utils'; | ||
import { getIsolatedModulesPath } from '../autolinking/utils'; | ||
import { fileExistsAsync } from '../fileUtils'; | ||
import type { SupportedPlatform } from '../types'; | ||
@@ -107,5 +107,10 @@ | ||
// The rnc-cli will skip this package. | ||
// For example, the `react-native` package. | ||
return null; | ||
} | ||
if (name === 'react-native') { | ||
// Starting from version 0.76, the `react-native` package only defines platforms | ||
// when @react-native-community/cli-platform-android/ios is installed. | ||
// Therefore, we need to manually filter it out. | ||
return null; | ||
} | ||
@@ -143,2 +148,5 @@ let platformData = null; | ||
const { gradle, manifest } = await findGradleAndManifestAsync({ androidDir, isLibrary: false }); | ||
if (gradle == null || manifest == null) { | ||
return {}; | ||
} | ||
const packageName = await parsePackageNameAsync( | ||
@@ -145,0 +153,0 @@ path.join(androidDir, manifest), |
@@ -49,10 +49,6 @@ import { ExpoModuleConfig } from './ExpoModuleConfig'; | ||
target: string; | ||
entitlement?: string; | ||
packages: string[]; | ||
} | ||
export interface PatchReactImportsOptions { | ||
podsRoot: string; | ||
dryRun: boolean; | ||
} | ||
export type PackageRevision = { | ||
@@ -309,1 +305,11 @@ path: string; | ||
export type ExtraDependencies = AndroidMavenRepository[] | ApplePod[]; | ||
/** | ||
* Represents code signing entitlements passed to the `ExpoModulesProvider` for Apple platforms. | ||
*/ | ||
export interface AppleCodeSignEntitlements { | ||
/** | ||
* @see https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_application-groups | ||
*/ | ||
appGroups?: string[]; | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
3
18
375511
8
99
4538
+ Added@expo/spawn-async@^1.7.2
+ Added@expo/spawn-async@1.7.2(transitive)
+ Addedcross-spawn@7.0.6(transitive)
+ Addedisexe@2.0.0(transitive)
+ Addedpath-key@3.1.1(transitive)
+ Addedshebang-command@2.0.0(transitive)
+ Addedshebang-regex@3.0.0(transitive)
+ Addedwhich@2.0.2(transitive)