expo-modules-autolinking
Advanced tools
Comparing version 2.0.0-canary-20241008-90b13ad to 2.0.0-canary-20241018-bf4b2f7
@@ -13,1 +13,5 @@ import { findModulesAsync } from './findModules'; | ||
export declare function queryAutolinkingModulesFromProjectAsync(projectRoot: string, options: Pick<SearchOptions, 'platform' | 'exclude' | 'onlyProjectDeps'>): Promise<ModuleDescriptor[]>; | ||
/** | ||
* Get the project root directory from the current working directory. | ||
*/ | ||
export declare function findProjectRootSync(cwd?: string): string; |
@@ -16,4 +16,8 @@ "use strict"; | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.queryAutolinkingModulesFromProjectAsync = exports.verifySearchResults = exports.generatePackageListAsync = exports.generateModulesProviderAsync = exports.resolveSearchPathsAsync = exports.resolveModulesAsync = exports.resolveExtraBuildDependenciesAsync = exports.mergeLinkingOptionsAsync = exports.getProjectPackageJsonPathAsync = exports.findModulesAsync = void 0; | ||
exports.findProjectRootSync = exports.queryAutolinkingModulesFromProjectAsync = exports.verifySearchResults = exports.generatePackageListAsync = exports.generateModulesProviderAsync = exports.resolveSearchPathsAsync = exports.resolveModulesAsync = exports.resolveExtraBuildDependenciesAsync = exports.mergeLinkingOptionsAsync = exports.getProjectPackageJsonPathAsync = exports.findModulesAsync = void 0; | ||
const path_1 = __importDefault(require("path")); | ||
const findModules_1 = require("./findModules"); | ||
@@ -44,2 +48,9 @@ Object.defineProperty(exports, "findModulesAsync", { enumerable: true, get: function () { return findModules_1.findModulesAsync; } }); | ||
exports.queryAutolinkingModulesFromProjectAsync = queryAutolinkingModulesFromProjectAsync; | ||
/** | ||
* Get the project root directory from the current working directory. | ||
*/ | ||
function findProjectRootSync(cwd = process.cwd()) { | ||
return path_1.default.dirname((0, mergeLinkingOptions_1.getProjectPackageJsonPathSync)(cwd)); | ||
} | ||
exports.findProjectRootSync = findProjectRootSync; | ||
//# sourceMappingURL=index.js.map |
@@ -7,2 +7,6 @@ import { SearchOptions } from '../types'; | ||
/** | ||
* Synchronous version of {@link getProjectPackageJsonPathAsync}. | ||
*/ | ||
export declare function getProjectPackageJsonPathSync(projectRoot: string): string; | ||
/** | ||
* Merges autolinking options from different sources (the later the higher priority) | ||
@@ -9,0 +13,0 @@ * - options defined in package.json's `expo.autolinking` field |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveSearchPathsAsync = exports.mergeLinkingOptionsAsync = exports.getProjectPackageJsonPathAsync = void 0; | ||
exports.resolveSearchPathsAsync = exports.mergeLinkingOptionsAsync = exports.getProjectPackageJsonPathSync = exports.getProjectPackageJsonPathAsync = void 0; | ||
const find_up_1 = __importDefault(require("find-up")); | ||
@@ -23,2 +23,13 @@ const fs_extra_1 = __importDefault(require("fs-extra")); | ||
/** | ||
* Synchronous version of {@link getProjectPackageJsonPathAsync}. | ||
*/ | ||
function getProjectPackageJsonPathSync(projectRoot) { | ||
const result = find_up_1.default.sync('package.json', { cwd: projectRoot }); | ||
if (!result) { | ||
throw new Error(`Couldn't find "package.json" up from path "${projectRoot}"`); | ||
} | ||
return result; | ||
} | ||
exports.getProjectPackageJsonPathSync = getProjectPackageJsonPathSync; | ||
/** | ||
* Merges autolinking options from different sources (the later the higher priority) | ||
@@ -25,0 +36,0 @@ * - options defined in package.json's `expo.autolinking` field |
@@ -49,15 +49,24 @@ "use strict"; | ||
.option('-j, --json', 'Output results in the plain JSON format.', () => true, false) | ||
.action(async (paths, options) => { | ||
if (!['android', 'ios'].includes(options.platform)) { | ||
throw new Error(`Unsupported platform: ${options.platform}`); | ||
.action(async (searchPaths, providedOptions) => { | ||
if (!['android', 'ios'].includes(providedOptions.platform)) { | ||
throw new Error(`Unsupported platform: ${providedOptions.platform}`); | ||
} | ||
const projectRoot = path_1.default.dirname(await (0, autolinking_1.getProjectPackageJsonPathAsync)(options.projectRoot)); | ||
const searchPaths = await (0, autolinking_1.resolveSearchPathsAsync)(paths, projectRoot); | ||
const providedOptions = { | ||
platform: options.platform, | ||
const projectRoot = path_1.default.dirname(await (0, autolinking_1.getProjectPackageJsonPathAsync)(providedOptions.projectRoot)); | ||
const linkingOptions = await (0, autolinking_1.mergeLinkingOptionsAsync)(searchPaths.length > 0 | ||
? { | ||
...providedOptions, | ||
projectRoot, | ||
searchPaths, | ||
} | ||
: { | ||
...providedOptions, | ||
projectRoot, | ||
}); | ||
const options = { | ||
platform: linkingOptions.platform, | ||
projectRoot, | ||
searchPaths, | ||
searchPaths: linkingOptions.searchPaths, | ||
}; | ||
const results = await (0, reactNativeConfig_1.createReactNativeConfigAsync)(providedOptions); | ||
if (options.json) { | ||
const results = await (0, reactNativeConfig_1.createReactNativeConfigAsync)(options); | ||
if (providedOptions.json) { | ||
console.log(JSON.stringify(results)); | ||
@@ -64,0 +73,0 @@ } |
@@ -14,2 +14,3 @@ # Changelog | ||
- Added Apple code sign entitlements to generated `ExpoModulesProvider.swift`. ([#31518](https://github.com/expo/expo/pull/31518) by [@kudo](https://github.com/kudo)) | ||
- Added `searchPaths` support to the `react-native-config`. ([#32153](https://github.com/expo/expo/pull/32153) by [@kudo](https://github.com/kudo)) | ||
@@ -27,2 +28,3 @@ ### 🐛 Bug fixes | ||
- 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)) | ||
- Exported a new `findProjectRootSync` API. ([#31966](https://github.com/expo/expo/pull/31966) by [@kudo](https://github.com/kudo)) | ||
@@ -29,0 +31,0 @@ ## 1.11.2 - 2024-08-14 |
{ | ||
"name": "expo-modules-autolinking", | ||
"version": "2.0.0-canary-20241008-90b13ad", | ||
"version": "2.0.0-canary-20241018-bf4b2f7", | ||
"description": "Scripts that autolink Expo modules.", | ||
@@ -38,3 +38,3 @@ "main": "build/index.js", | ||
"@types/fs-extra": "^9.0.11", | ||
"expo-module-scripts": "3.6.0-canary-20241008-90b13ad", | ||
"expo-module-scripts": "3.6.0-canary-20241018-bf4b2f7", | ||
"minimatch": "^3.0.4" | ||
@@ -52,3 +52,3 @@ }, | ||
}, | ||
"gitHead": "90b13ad9d0dd3469556ac776d8b74643375b1d97" | ||
"gitHead": "bf4b2f7ee85a6454ab9f0f97f247bf86d1a47769" | ||
} |
@@ -0,4 +1,7 @@ | ||
import path from 'path'; | ||
import { findModulesAsync } from './findModules'; | ||
import { | ||
getProjectPackageJsonPathAsync, | ||
getProjectPackageJsonPathSync, | ||
mergeLinkingOptionsAsync, | ||
@@ -34,1 +37,8 @@ resolveSearchPathsAsync, | ||
} | ||
/** | ||
* Get the project root directory from the current working directory. | ||
*/ | ||
export function findProjectRootSync(cwd: string = process.cwd()): string { | ||
return path.dirname(getProjectPackageJsonPathSync(cwd)); | ||
} |
@@ -19,2 +19,13 @@ import findUp from 'find-up'; | ||
/** | ||
* Synchronous version of {@link getProjectPackageJsonPathAsync}. | ||
*/ | ||
export function getProjectPackageJsonPathSync(projectRoot: string): string { | ||
const result = findUp.sync('package.json', { cwd: projectRoot }); | ||
if (!result) { | ||
throw new Error(`Couldn't find "package.json" up from path "${projectRoot}"`); | ||
} | ||
return result; | ||
} | ||
/** | ||
* Merges autolinking options from different sources (the later the higher priority) | ||
@@ -21,0 +32,0 @@ * - options defined in package.json's `expo.autolinking` field |
@@ -12,3 +12,2 @@ import commander from 'commander'; | ||
resolveModulesAsync, | ||
resolveSearchPathsAsync, | ||
verifySearchResults, | ||
@@ -104,15 +103,28 @@ } from './autolinking'; | ||
.option<boolean>('-j, --json', 'Output results in the plain JSON format.', () => true, false) | ||
.action(async (paths, options) => { | ||
if (!['android', 'ios'].includes(options.platform)) { | ||
throw new Error(`Unsupported platform: ${options.platform}`); | ||
.action(async (searchPaths, providedOptions) => { | ||
if (!['android', 'ios'].includes(providedOptions.platform)) { | ||
throw new Error(`Unsupported platform: ${providedOptions.platform}`); | ||
} | ||
const projectRoot = path.dirname(await getProjectPackageJsonPathAsync(options.projectRoot)); | ||
const searchPaths = await resolveSearchPathsAsync(paths, projectRoot); | ||
const providedOptions: RNConfigCommandOptions = { | ||
platform: options.platform, | ||
const projectRoot = path.dirname( | ||
await getProjectPackageJsonPathAsync(providedOptions.projectRoot) | ||
); | ||
const linkingOptions = await mergeLinkingOptionsAsync<SearchOptions>( | ||
searchPaths.length > 0 | ||
? { | ||
...providedOptions, | ||
projectRoot, | ||
searchPaths, | ||
} | ||
: { | ||
...providedOptions, | ||
projectRoot, | ||
} | ||
); | ||
const options: RNConfigCommandOptions = { | ||
platform: linkingOptions.platform, | ||
projectRoot, | ||
searchPaths, | ||
searchPaths: linkingOptions.searchPaths, | ||
}; | ||
const results = await createReactNativeConfigAsync(providedOptions); | ||
if (options.json) { | ||
const results = await createReactNativeConfigAsync(options); | ||
if (providedOptions.json) { | ||
console.log(JSON.stringify(results)); | ||
@@ -119,0 +131,0 @@ } else { |
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
379763
4607