Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rnx-kit/tools-react-native

Package Overview
Dependencies
Maintainers
0
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rnx-kit/tools-react-native - npm Package Compare versions

Comparing version 1.4.0 to 1.4.1

90

lib/platform.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -8,2 +31,5 @@ exports.getAvailablePlatforms = void 0;

exports.parsePlatform = parsePlatform;
const package_1 = require("@rnx-kit/tools-node/package");
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const context_1 = require("./context");

@@ -27,2 +53,56 @@ /**

/**
* Returns a map of available React Native platforms.
*
* Note: This is used only when `@react-native-community/cli-config` is not
* available. This function will be dropped when 0.68 is no longer supported.
*
* @param startDir The directory to look for react-native platforms from
* @param platformMap A platform-to-npm-package map of known packages
* @returns A platform-to-npm-package map, excluding "core" platforms.
*/
function getAvailablePlatformsCompat(startDir = process.cwd(), platformMap = { android: "", ios: "" }) {
const packageJson = path.join(startDir, "package.json");
if (!fs.existsSync(packageJson)) {
const parent = path.dirname(startDir);
return parent === startDir
? platformMap
: getAvailablePlatformsUncached(path.dirname(startDir), platformMap);
}
const options = { startDir };
const { dependencies, peerDependencies, devDependencies } = JSON.parse(fs.readFileSync(packageJson, { encoding: "utf-8" }));
const packages = new Set(dependencies ? Object.keys(dependencies) : []);
if (peerDependencies) {
Object.keys(peerDependencies).forEach((pkg) => packages.add(pkg));
}
if (devDependencies) {
Object.keys(devDependencies).forEach((pkg) => packages.add(pkg));
}
packages.forEach((pkgName) => {
const pkgPath = (0, package_1.findPackageDependencyDir)(pkgName, options);
if (!pkgPath) {
return;
}
const configPath = path.join(pkgPath, "react-native.config.js");
if (fs.existsSync(configPath)) {
try {
const { platforms } = require(configPath);
if (platforms) {
Object.keys(platforms).forEach((platform) => {
if (typeof platformMap[platform] === "undefined") {
const { npmPackageName } = platforms[platform];
if (npmPackageName) {
platformMap[platform] = npmPackageName;
}
}
});
}
}
catch (_) {
// ignore
}
}
});
return platformMap;
}
/**
* Returns a map of available React Native platforms. The result is cached.

@@ -36,3 +116,11 @@ * @param startDir The directory to look for react-native platforms from

if (!platformMap) {
platformMap = getAvailablePlatformsUncached(startDir);
try {
platformMap = getAvailablePlatformsUncached(startDir);
}
catch (_) {
// This only happens when `@react-native-community/cli-config` is not
// available. This path may be dropped when 0.68 is no longer
// supported.
platformMap = getAvailablePlatformsCompat(startDir);
}
}

@@ -39,0 +127,0 @@ return platformMap;

14

package.json
{
"name": "@rnx-kit/tools-react-native",
"version": "1.4.0",
"version": "1.4.1",
"description": "A collection of supplemental react-native functions and types",

@@ -70,4 +70,4 @@ "homepage": "https://github.com/microsoft/rnx-kit/tree/main/packages/tools-react-native#readme",

"devDependencies": {
"@react-native-community/cli": "^12.1.1",
"@react-native-community/cli-types": "^12.3.0",
"@react-native-community/cli": "^13.6.4",
"@react-native-community/cli-types": "^13.6.4",
"@rnx-kit/eslint-config": "*",

@@ -79,6 +79,6 @@ "@rnx-kit/scripts": "*",

"eslint": "^8.56.0",
"metro": "^0.80.0",
"metro-config": "^0.80.0",
"metro-core": "^0.80.0",
"metro-resolver": "^0.80.0",
"metro": "^0.80.3",
"metro-config": "^0.80.3",
"metro-core": "^0.80.3",
"metro-resolver": "^0.80.3",
"metro-source-map": "^0.80.0",

@@ -85,0 +85,0 @@ "prettier": "^3.0.0",

@@ -66,2 +66,3 @@ import type { Config } from "@react-native-community/cli-types";

const { loadConfig } = require(rncli);
const config: Config =

@@ -68,0 +69,0 @@ loadConfig.length === 1

@@ -0,1 +1,4 @@

import { findPackageDependencyDir } from "@rnx-kit/tools-node/package";
import * as fs from "fs";
import * as path from "path";
import { loadContext } from "./context";

@@ -31,2 +34,68 @@

/**
* Returns a map of available React Native platforms.
*
* Note: This is used only when `@react-native-community/cli-config` is not
* available. This function will be dropped when 0.68 is no longer supported.
*
* @param startDir The directory to look for react-native platforms from
* @param platformMap A platform-to-npm-package map of known packages
* @returns A platform-to-npm-package map, excluding "core" platforms.
*/
function getAvailablePlatformsCompat(
startDir = process.cwd(),
platformMap: Record<string, string> = { android: "", ios: "" }
) {
const packageJson = path.join(startDir, "package.json");
if (!fs.existsSync(packageJson)) {
const parent = path.dirname(startDir);
return parent === startDir
? platformMap
: getAvailablePlatformsUncached(path.dirname(startDir), platformMap);
}
const options = { startDir };
const { dependencies, peerDependencies, devDependencies } = JSON.parse(
fs.readFileSync(packageJson, { encoding: "utf-8" })
);
const packages = new Set<string>(
dependencies ? Object.keys(dependencies) : []
);
if (peerDependencies) {
Object.keys(peerDependencies).forEach((pkg) => packages.add(pkg));
}
if (devDependencies) {
Object.keys(devDependencies).forEach((pkg) => packages.add(pkg));
}
packages.forEach((pkgName) => {
const pkgPath = findPackageDependencyDir(pkgName, options);
if (!pkgPath) {
return;
}
const configPath = path.join(pkgPath, "react-native.config.js");
if (fs.existsSync(configPath)) {
try {
const { platforms } = require(configPath);
if (platforms) {
Object.keys(platforms).forEach((platform) => {
if (typeof platformMap[platform] === "undefined") {
const { npmPackageName } = platforms[platform];
if (npmPackageName) {
platformMap[platform] = npmPackageName;
}
}
});
}
} catch (_) {
// ignore
}
}
});
return platformMap;
}
/**
* Returns a map of available React Native platforms. The result is cached.

@@ -40,3 +109,10 @@ * @param startDir The directory to look for react-native platforms from

if (!platformMap) {
platformMap = getAvailablePlatformsUncached(startDir);
try {
platformMap = getAvailablePlatformsUncached(startDir);
} catch (_) {
// This only happens when `@react-native-community/cli-config` is not
// available. This path may be dropped when 0.68 is no longer
// supported.
platformMap = getAvailablePlatformsCompat(startDir);
}
}

@@ -43,0 +119,0 @@ return platformMap;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc