@expo/fingerprint
Advanced tools
Comparing version 0.11.0-canary-20240912-1059f85 to 1.0.0-canary-20240927-ab8a962
@@ -34,2 +34,5 @@ #!/usr/bin/env node | ||
debug: !!process.env.DEBUG, | ||
useRNCoreAutolinkingFromExpo: process.env.USE_RNCORE_AUTOLINKING_FROM_EXPO | ||
? ['1', 'true'].includes(process.env.USE_RNCORE_AUTOLINKING_FROM_EXPO) | ||
: undefined, | ||
} | ||
@@ -36,0 +39,0 @@ try { |
@@ -44,2 +44,3 @@ "use strict"; | ||
'enableReactImportsPatcher', | ||
'useRNCoreAutolinkingFromExpo', | ||
'debug', | ||
@@ -46,0 +47,0 @@ ]; |
@@ -27,3 +27,3 @@ "use strict"; | ||
else { | ||
duplicatedItem.reasons.push(...source.reasons); | ||
duplicatedItem.reasons = [...duplicatedItem.reasons, ...source.reasons]; | ||
} | ||
@@ -30,0 +30,0 @@ } |
@@ -86,2 +86,7 @@ /// <reference types="node" /> | ||
/** | ||
* Use the react-native core autolinking sources from expo-modules-autolinking rather than @react-native-community/cli. | ||
* @default true for Expo SDK 52 and higher. | ||
*/ | ||
useRNCoreAutolinkingFromExpo?: boolean; | ||
/** | ||
* Whether running the functions should mute all console output. This is useful when fingerprinting is being done as | ||
@@ -100,3 +105,3 @@ * part of a CLI that outputs a fingerprint and outputting anything else pollutes the results. | ||
*/ | ||
export type Config = Pick<Options, 'concurrentIoLimit' | 'hashAlgorithm' | 'ignorePaths' | 'extraSources' | 'enableReactImportsPatcher' | 'debug'> & { | ||
export type Config = Pick<Options, 'concurrentIoLimit' | 'hashAlgorithm' | 'ignorePaths' | 'extraSources' | 'enableReactImportsPatcher' | 'useRNCoreAutolinkingFromExpo' | 'debug'> & { | ||
sourceSkips?: SourceSkips | SourceSkipsKeys[]; | ||
@@ -103,0 +108,0 @@ }; |
@@ -6,2 +6,4 @@ import type { HashSource, NormalizedOptions } from '../Fingerprint.types'; | ||
export declare function getGitIgnoreSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>; | ||
export declare function getRncliAutolinkingSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>; | ||
export declare function getCoreAutolinkingSourcesFromRncCliAsync(projectRoot: string, options: NormalizedOptions, useRNCoreAutolinkingFromExpo?: boolean): Promise<HashSource[]>; | ||
export declare function getCoreAutolinkingSourcesFromExpoAndroid(projectRoot: string, options: NormalizedOptions, useRNCoreAutolinkingFromExpo?: boolean): Promise<HashSource[]>; | ||
export declare function getCoreAutolinkingSourcesFromExpoIos(projectRoot: string, options: NormalizedOptions, useRNCoreAutolinkingFromExpo?: boolean): Promise<HashSource[]>; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getRncliAutolinkingSourcesAsync = exports.getGitIgnoreSourcesAsync = exports.getPackageJsonScriptSourcesAsync = exports.getBareIosSourcesAsync = exports.getBareAndroidSourcesAsync = void 0; | ||
exports.getCoreAutolinkingSourcesFromExpoIos = exports.getCoreAutolinkingSourcesFromExpoAndroid = exports.getCoreAutolinkingSourcesFromRncCliAsync = exports.getGitIgnoreSourcesAsync = exports.getPackageJsonScriptSourcesAsync = exports.getBareIosSourcesAsync = exports.getBareAndroidSourcesAsync = void 0; | ||
const spawn_async_1 = __importDefault(require("@expo/spawn-async")); | ||
@@ -70,27 +70,13 @@ const assert_1 = __importDefault(require("assert")); | ||
exports.getGitIgnoreSourcesAsync = getGitIgnoreSourcesAsync; | ||
async function getRncliAutolinkingSourcesAsync(projectRoot, options) { | ||
async function getCoreAutolinkingSourcesFromRncCliAsync(projectRoot, options, useRNCoreAutolinkingFromExpo) { | ||
if (useRNCoreAutolinkingFromExpo === true) { | ||
return []; | ||
} | ||
try { | ||
const results = []; | ||
const { stdout } = await (0, spawn_async_1.default)('npx', ['react-native', 'config'], { cwd: projectRoot }); | ||
const config = JSON.parse(stdout); | ||
const { root } = config; | ||
const reasons = ['bareRncliAutolinking']; | ||
const autolinkingConfig = {}; | ||
for (const [depName, depData] of Object.entries(config.dependencies)) { | ||
try { | ||
stripRncliAutolinkingAbsolutePaths(depData, root); | ||
const filePath = depData.root; | ||
debug(`Adding react-native-cli autolinking dir - ${chalk_1.default.dim(filePath)}`); | ||
results.push({ type: 'dir', filePath, reasons }); | ||
autolinkingConfig[depName] = depData; | ||
} | ||
catch (e) { | ||
debug(chalk_1.default.red(`Error adding react-native-cli autolinking dir - ${depName}.\n${e}`)); | ||
} | ||
} | ||
results.push({ | ||
type: 'contents', | ||
id: 'rncliAutolinkingConfig', | ||
contents: JSON.stringify(autolinkingConfig), | ||
reasons, | ||
const results = await parseCoreAutolinkingSourcesAsync({ | ||
config, | ||
contentsId: 'rncoreAutolinkingConfig', | ||
reasons: ['rncoreAutolinking'], | ||
}); | ||
@@ -100,8 +86,77 @@ return results; | ||
catch (e) { | ||
debug(chalk_1.default.red(`Error adding react-native-cli autolinking sources.\n${e}`)); | ||
debug(chalk_1.default.red(`Error adding react-native core autolinking sources.\n${e}`)); | ||
return []; | ||
} | ||
} | ||
exports.getRncliAutolinkingSourcesAsync = getRncliAutolinkingSourcesAsync; | ||
function stripRncliAutolinkingAbsolutePaths(dependency, root) { | ||
exports.getCoreAutolinkingSourcesFromRncCliAsync = getCoreAutolinkingSourcesFromRncCliAsync; | ||
async function getCoreAutolinkingSourcesFromExpoAndroid(projectRoot, options, useRNCoreAutolinkingFromExpo) { | ||
if (useRNCoreAutolinkingFromExpo === false || !options.platforms.includes('android')) { | ||
return []; | ||
} | ||
try { | ||
const { stdout } = await (0, spawn_async_1.default)('npx', ['expo-modules-autolinking', 'react-native-config', '--json', '--platform', 'android'], { cwd: projectRoot }); | ||
const config = JSON.parse(stdout); | ||
const results = await parseCoreAutolinkingSourcesAsync({ | ||
config, | ||
contentsId: 'rncoreAutolinkingConfig:android', | ||
reasons: ['rncoreAutolinkingAndroid'], | ||
platform: 'android', | ||
}); | ||
return results; | ||
} | ||
catch (e) { | ||
debug(chalk_1.default.red(`Error adding react-native core autolinking sources for android.\n${e}`)); | ||
return []; | ||
} | ||
} | ||
exports.getCoreAutolinkingSourcesFromExpoAndroid = getCoreAutolinkingSourcesFromExpoAndroid; | ||
async function getCoreAutolinkingSourcesFromExpoIos(projectRoot, options, useRNCoreAutolinkingFromExpo) { | ||
if (useRNCoreAutolinkingFromExpo === false || !options.platforms.includes('ios')) { | ||
return []; | ||
} | ||
try { | ||
const { stdout } = await (0, spawn_async_1.default)('npx', ['expo-modules-autolinking', 'react-native-config', '--json', '--platform', 'ios'], { cwd: projectRoot }); | ||
const config = JSON.parse(stdout); | ||
const results = await parseCoreAutolinkingSourcesAsync({ | ||
config, | ||
contentsId: 'rncoreAutolinkingConfig:ios', | ||
reasons: ['rncoreAutolinkingIos'], | ||
platform: 'ios', | ||
}); | ||
return results; | ||
} | ||
catch (e) { | ||
debug(chalk_1.default.red(`Error adding react-native core autolinking sources for ios.\n${e}`)); | ||
return []; | ||
} | ||
} | ||
exports.getCoreAutolinkingSourcesFromExpoIos = getCoreAutolinkingSourcesFromExpoIos; | ||
async function parseCoreAutolinkingSourcesAsync({ config, reasons, contentsId, platform, }) { | ||
const logTag = platform | ||
? `react-native core autolinking dir for ${platform}` | ||
: 'react-native core autolinking dir'; | ||
const results = []; | ||
const { root } = config; | ||
const autolinkingConfig = {}; | ||
for (const [depName, depData] of Object.entries(config.dependencies)) { | ||
try { | ||
stripRncoreAutolinkingAbsolutePaths(depData, root); | ||
const filePath = depData.root; | ||
debug(`Adding ${logTag} - ${chalk_1.default.dim(filePath)}`); | ||
results.push({ type: 'dir', filePath, reasons }); | ||
autolinkingConfig[depName] = depData; | ||
} | ||
catch (e) { | ||
debug(chalk_1.default.red(`Error adding ${logTag} - ${depName}.\n${e}`)); | ||
} | ||
} | ||
results.push({ | ||
type: 'contents', | ||
id: contentsId, | ||
contents: JSON.stringify(autolinkingConfig), | ||
reasons, | ||
}); | ||
return results; | ||
} | ||
function stripRncoreAutolinkingAbsolutePaths(dependency, root) { | ||
(0, assert_1.default)(dependency.root); | ||
@@ -108,0 +163,0 @@ const dependencyRoot = dependency.root; |
import type { HashSource, NormalizedOptions } from '../Fingerprint.types'; | ||
export declare function getExpoConfigSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>; | ||
export declare function getEasBuildSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>; | ||
export declare function getExpoAutolinkingAndroidSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>; | ||
export declare function getExpoAutolinkingAndroidSourcesAsync(projectRoot: string, options: NormalizedOptions, expoAutolinkingVersion: string): Promise<HashSource[]>; | ||
/** | ||
@@ -9,3 +9,3 @@ * Gets the patch sources for the `patch-project`. | ||
export declare function getExpoCNGPatchSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>; | ||
export declare function getExpoAutolinkingIosSourcesAsync(projectRoot: string, options: NormalizedOptions): Promise<HashSource[]>; | ||
export declare function getExpoAutolinkingIosSourcesAsync(projectRoot: string, options: NormalizedOptions, expoAutolinkingVersion: string): Promise<HashSource[]>; | ||
/** | ||
@@ -12,0 +12,0 @@ * Sort the expo-modules-autolinking android config to make it stable from hashing. |
@@ -176,3 +176,3 @@ "use strict"; | ||
exports.getEasBuildSourcesAsync = getEasBuildSourcesAsync; | ||
async function getExpoAutolinkingAndroidSourcesAsync(projectRoot, options) { | ||
async function getExpoAutolinkingAndroidSourcesAsync(projectRoot, options, expoAutolinkingVersion) { | ||
if (!options.platforms.includes('android')) { | ||
@@ -227,7 +227,8 @@ return []; | ||
exports.getExpoCNGPatchSourcesAsync = getExpoCNGPatchSourcesAsync; | ||
async function getExpoAutolinkingIosSourcesAsync(projectRoot, options) { | ||
async function getExpoAutolinkingIosSourcesAsync(projectRoot, options, expoAutolinkingVersion) { | ||
if (!options.platforms.includes('ios')) { | ||
return []; | ||
} | ||
const platform = getIosAutolinkingPlatformParam(projectRoot); | ||
// expo-modules-autolinking 1.10.0 added support for apple platform | ||
const platform = semver_1.default.lt(expoAutolinkingVersion, '1.10.0') ? 'ios' : 'apple'; | ||
try { | ||
@@ -270,20 +271,2 @@ const reasons = ['expoAutolinkingIos']; | ||
exports.sortExpoAutolinkingAndroidConfig = sortExpoAutolinkingAndroidConfig; | ||
/** | ||
* Get the platform parameter for expo-modules-autolinking. | ||
* | ||
* Older autolinking uses `ios` and newer autolinking uses `apple`. | ||
*/ | ||
function getIosAutolinkingPlatformParam(projectRoot) { | ||
let platformParam = 'apple'; | ||
const expoPackageRoot = resolve_from_1.default.silent(projectRoot, 'expo/package.json'); | ||
const autolinkingPackageJsonPath = resolve_from_1.default.silent(expoPackageRoot ?? projectRoot, 'expo-modules-autolinking/package.json'); | ||
if (autolinkingPackageJsonPath) { | ||
const autolinkingPackageJson = require(autolinkingPackageJsonPath); | ||
// expo-modules-autolinking 1.10.0 added support for apple platform | ||
if (semver_1.default.lt(autolinkingPackageJson.version, '1.10.0')) { | ||
platformParam = 'ios'; | ||
} | ||
} | ||
return platformParam; | ||
} | ||
//# sourceMappingURL=Expo.js.map |
@@ -8,4 +8,6 @@ "use strict"; | ||
const chalk_1 = __importDefault(require("chalk")); | ||
const semver_1 = __importDefault(require("semver")); | ||
const Bare_1 = require("./Bare"); | ||
const Expo_1 = require("./Expo"); | ||
const ExpoVersions_1 = require("./ExpoVersions"); | ||
const Packages_1 = require("./Packages"); | ||
@@ -16,6 +18,14 @@ const PatchPackage_1 = require("./PatchPackage"); | ||
async function getHashSourcesAsync(projectRoot, options) { | ||
const expoAutolinkingVersion = (0, ExpoVersions_1.resolveExpoAutolinkingVersion)(projectRoot) ?? '0.0.0'; | ||
const useRNCoreAutolinkingFromExpo = | ||
// expo-modules-autolinking supports the `react-native-config` core autolinking from 1.11.2. | ||
// To makes the `useRNCoreAutolinkingFromExpo` default to `true` for Expo SDK 52 and higher. | ||
// We check the expo-modules-autolinking version from 1.12.0. | ||
typeof options.useRNCoreAutolinkingFromExpo === 'boolean' | ||
? options.useRNCoreAutolinkingFromExpo | ||
: semver_1.default.gte(expoAutolinkingVersion, '1.12.0'); | ||
const results = await Promise.all([ | ||
// expo | ||
(0, Profile_1.profile)(options, Expo_1.getExpoAutolinkingAndroidSourcesAsync)(projectRoot, options), | ||
(0, Profile_1.profile)(options, Expo_1.getExpoAutolinkingIosSourcesAsync)(projectRoot, options), | ||
(0, Profile_1.profile)(options, Expo_1.getExpoAutolinkingAndroidSourcesAsync)(projectRoot, options, expoAutolinkingVersion), | ||
(0, Profile_1.profile)(options, Expo_1.getExpoAutolinkingIosSourcesAsync)(projectRoot, options, expoAutolinkingVersion), | ||
(0, Profile_1.profile)(options, Expo_1.getExpoConfigSourcesAsync)(projectRoot, options), | ||
@@ -30,4 +40,6 @@ (0, Profile_1.profile)(options, Expo_1.getEasBuildSourcesAsync)(projectRoot, options), | ||
(0, Profile_1.profile)(options, Bare_1.getBareIosSourcesAsync)(projectRoot, options), | ||
// rn-cli autolinking | ||
(0, Profile_1.profile)(options, Bare_1.getRncliAutolinkingSourcesAsync)(projectRoot, options), | ||
// react-native core autolinking | ||
(0, Profile_1.profile)(options, Bare_1.getCoreAutolinkingSourcesFromExpoAndroid)(projectRoot, options, useRNCoreAutolinkingFromExpo), | ||
(0, Profile_1.profile)(options, Bare_1.getCoreAutolinkingSourcesFromExpoIos)(projectRoot, options, useRNCoreAutolinkingFromExpo), | ||
(0, Profile_1.profile)(options, Bare_1.getCoreAutolinkingSourcesFromRncCliAsync)(projectRoot, options, useRNCoreAutolinkingFromExpo), | ||
// patch-package | ||
@@ -34,0 +46,0 @@ (0, Profile_1.profile)(options, PatchPackage_1.getPatchPackageSourcesAsync)(projectRoot, options), |
{ | ||
"name": "@expo/fingerprint", | ||
"version": "0.11.0-canary-20240912-1059f85", | ||
"version": "1.0.0-canary-20240927-ab8a962", | ||
"description": "A library to generate a fingerprint from a React Native project", | ||
@@ -55,3 +55,3 @@ "main": "build/index.js", | ||
"@types/find-up": "^4.0.0", | ||
"expo-module-scripts": "3.6.0-canary-20240912-1059f85", | ||
"expo-module-scripts": "3.6.0-canary-20240927-ab8a962", | ||
"glob": "^10.4.2", | ||
@@ -61,3 +61,3 @@ "require-from-string": "^2.0.2", | ||
}, | ||
"gitHead": "1059f8556047a3e02fa319e8b2459274571f4e6f" | ||
"gitHead": "ab8a962d2c3dddbda124a6bd88d24475831dae00" | ||
} |
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
155690
67
2288
19