Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ninety-hairs-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rnx-kit/align-deps": patch
---

Added profile for react-native 0.72
5 changes: 5 additions & 0 deletions .changeset/purple-tips-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rnx-kit/config": patch
---

Add new capability, `core/metro-config`, for `@react-native/metro-config`
5 changes: 5 additions & 0 deletions .changeset/thick-ducks-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rnx-kit/react-native-auth": patch
---

Declare support for react-native 0.72
97 changes: 49 additions & 48 deletions packages/align-deps/README.md

Large diffs are not rendered by default.

64 changes: 49 additions & 15 deletions packages/align-deps/scripts/update-profile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import { markdownTable } from "markdown-table";
import { existsSync as fileExists } from "node:fs";
import * as fs from "node:fs/promises";
import * as fs from "node:fs";
import * as path from "node:path";
import { fileURLToPath } from "node:url";
import packageJson from "package-json";
Expand Down Expand Up @@ -90,21 +90,18 @@ function getPackageVersion(packageName, dependencies) {
* Returns the path to a profile.
* @param {string} preset
* @param {string} profileVersion
* @returns {string}
* @returns {[string, string]}
*/
function getProfilePath(preset, profileVersion) {
const __dirname = path.dirname(fileURLToPath(import.meta.url));
return path.relative(
const presetDir = path.relative(
process.cwd(),
path.join(
__dirname,
"..",
"src",
"presets",
preset,
`profile-${profileVersion}.ts`
)
path.join(__dirname, "..", "src", "presets", preset)
);
return [
path.join(presetDir, `profile-${profileVersion}.ts`),
presetDir + ".ts",
];
}

/**
Expand Down Expand Up @@ -138,7 +135,7 @@ function generateFromTemplate({
nextVersionCoerced.minor - 1
}`;

const currentProfile = getProfilePath(preset, currentVersion);
const [currentProfile] = getProfilePath(preset, currentVersion);
if (!fileExists(currentProfile)) {
throw new Error(`Could not find '${currentProfile}'`);
}
Expand All @@ -152,7 +149,7 @@ import profile_${currentVersionVarName} from "./profile-${currentVersion}";
const reactNative: Package = {
name: "react-native",
version: "^${targetVersion}.0",
capabilities: ["react"],
capabilities: ["react", "core/metro-config"],
};

const profile: Profile = {
Expand Down Expand Up @@ -186,6 +183,11 @@ const profile: Profile = {
version: "^${targetVersion}.0",
capabilities: ["core"],
},
"core/metro-config": {
name: "@react-native/metro-config",
version: "^${targetVersion}.0",
devOnly: true,
},

"babel-preset-react-native": {
name: "metro-react-native-babel-preset",
Expand Down Expand Up @@ -355,9 +357,41 @@ async function main({
latestProfile
);
if (newProfile) {
const dst = getProfilePath(presetName, targetVersion);
fs.writeFile(dst, newProfile).then(() => {
const [dst, presetFile] = getProfilePath(presetName, targetVersion);
fs.writeFile(dst, newProfile, () => {
console.log(`Wrote to '${dst}'`);

const profiles = fs
.readdirSync(path.dirname(dst))
.filter((file) => file.startsWith("profile-"))
.map((file) => {
const filename = path.basename(file, ".ts");
const version = filename.substring("profile-".length);
const varName = filename.replace(/[^\w]/g, "_");
return [version, varName];
});

const preset = [
`import type { Preset } from "../../types";`,
...profiles.map(
([version, varName]) =>
`import ${varName} from "./react-native/profile-${version}";`
),
"",
"// Also export this by name for scripts to work around a bug where this module",
"// is wrapped twice, i.e. `{ default: { default: preset } }`, when imported as",
"// ESM.",
"export const preset: Readonly<Preset> = {",
...profiles.map(
([version, varName]) => ` "${version}": ${varName},`
),
"};",
"",
"export default preset;",
"",
].join("\n");
fs.writeFileSync(presetFile, preset);
console.log(`Updated '${presetFile}'`);
});
}
} catch (e) {
Expand Down
4 changes: 3 additions & 1 deletion packages/align-deps/scripts/update-readme.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,12 @@ const table = markdownTable([
if ("version" in pkg) {
const { name, version } = pkg;
return `${name}@${version}`;
} else {
} else if (pkg.capabilities.length > 0) {
return `Meta package for installing ${pkg.capabilities
.map((name) => `\`${name}\``)
.join(", ")}`;
} else {
return "-";
}
}),
];
Expand Down
6 changes: 6 additions & 0 deletions packages/align-deps/src/presets/banned.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ const bannedPackages: ExcludedPackage[] = [
reason:
"Types are included in react-native starting with 0.71.0. '@types/react-native' is deprecated from 0.72 onwards.",
},
{
name: "hermes-engine",
version: "~0.11.0",
reason:
"Hermes is included with react-native starting with 0.70. Remove this package when you're on react-native 0.70 or higher.",
},
{
name: "react-native-linear-gradient",
version: "<2.6.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/align-deps/src/presets/microsoft/react-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import profile_0_68 from "./react-native/profile-0.68";
import profile_0_69 from "./react-native/profile-0.69";
import profile_0_70 from "./react-native/profile-0.70";
import profile_0_71 from "./react-native/profile-0.71";
import profile_0_72 from "./react-native/profile-0.72";

// Also export this by name for scripts to work around a bug where this module
// is wrapped twice, i.e. `{ default: { default: preset } }`, when imported as
Expand All @@ -26,6 +27,7 @@ export const preset: Readonly<Preset> = {
"0.69": profile_0_69,
"0.70": profile_0_70,
"0.71": profile_0_71,
"0.72": profile_0_72,
};

export default preset;
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ const profile: Profile = {
version: "^0.61.0",
capabilities: ["core"],
},
"core/metro-config": {
name: "#meta",
capabilities: [],
devOnly: true,
},

"babel-preset-react-native": {
name: "metro-react-native-babel-preset",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ const profile: Profile = {
name: "react-native-gesture-handler",
version: "^2.6.0",
},
hermes: {
// Hermes now comes bundled with `react-native`
name: "#meta",
capabilities: [],
},
netinfo: {
name: "@react-native-community/netinfo",
version: "^9.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ const profile: Profile = {
name: "react-native-reanimated",
version: "^2.14.1",
},
checkbox: {
name: "@react-native-community/checkbox",
version: "^0.5.15",
},
"datetime-picker": {
name: "@react-native-community/datetimepicker",
version: "^6.4.2",
Expand All @@ -108,6 +112,14 @@ const profile: Profile = {
version: "^29.2.1",
devOnly: true,
},
"masked-view": {
name: "@react-native-masked-view/masked-view",
version: "^0.2.9",
},
"safe-area": {
name: "react-native-safe-area-context",
version: "^4.5.1",
},
screens: {
name: "react-native-screens",
version: "^3.19.0",
Expand All @@ -122,13 +134,17 @@ const profile: Profile = {
},
svg: {
name: "react-native-svg",
version: "^13.7.0",
version: "^13.9.0",
},
"test-app": {
name: "react-native-test-app",
version: "^2.2.1",
devOnly: true,
},
webview: {
name: "react-native-webview",
version: "^12.0.2",
},
};

export default profile;
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import type { Package, Profile } from "../../../types";
import profile_0_71 from "./profile-0.71";

const reactNative: Package = {
name: "react-native",
version: "^0.72.0",
capabilities: ["react", "core/metro-config"],
};

const profile: Profile = {
...profile_0_71,
react: {
name: "react",
version: "18.2.0",
},
"react-dom": {
name: "react-dom",
version: "^18.2.0",
capabilities: ["react"],
},
"react-test-renderer": {
name: "react-test-renderer",
version: "18.2.0",
capabilities: ["react"],
devOnly: true,
},

core: reactNative,
"core-android": reactNative,
"core-ios": reactNative,
"core-macos": {
name: "react-native-macos",
version: "^0.72.0",
capabilities: ["react"],
},
"core-windows": {
name: "react-native-windows",
version: "^0.72.0",
capabilities: ["core"],
},
"core/metro-config": {
name: "@react-native/metro-config",
version: "^0.72.0",
devOnly: true,
},

"babel-preset-react-native": {
name: "metro-react-native-babel-preset",
version: "^0.76.5",
devOnly: true,
},
"community/cli": {
name: "@react-native-community/cli",
version: "^11.3.2",
capabilities: ["community/cli-android", "community/cli-ios"],
devOnly: true,
},
"community/cli-android": {
name: "@react-native-community/cli-platform-android",
version: "^11.3.2",
devOnly: true,
},
"community/cli-ios": {
name: "@react-native-community/cli-platform-ios",
version: "^11.3.2",
devOnly: true,
},
metro: {
name: "metro",
version: "^0.76.5",
devOnly: true,
},
"metro-config": {
name: "metro-config",
version: "^0.76.5",
devOnly: true,
},
"metro-core": {
name: "metro-core",
version: "^0.76.5",
devOnly: true,
},
"metro-react-native-babel-transformer": {
name: "metro-react-native-babel-transformer",
version: "^0.76.5",
devOnly: true,
},
"metro-resolver": {
name: "metro-resolver",
version: "^0.76.5",
devOnly: true,
},
"metro-runtime": {
name: "metro-runtime",
version: "^0.76.5",
devOnly: true,
},

animation: {
name: "react-native-reanimated",
version: "^3.3.0",
},
"datetime-picker": {
name: "@react-native-community/datetimepicker",
version: "^7.1.0",
},
gestures: {
name: "react-native-gesture-handler",
version: "^2.12.0",
},
"safe-area": {
name: "react-native-safe-area-context",
version: "^4.5.3",
},
screens: {
name: "react-native-screens",
version: "^3.21.0",
},
storage: {
name: "@react-native-async-storage/async-storage",
version: "^1.18.2",
},
"test-app": {
name: "react-native-test-app",
version: "^2.5.5",
devOnly: true,
},
webview: {
name: "react-native-webview",
version: "^13.2.2",
},
};

export default profile;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ exports[`checkPackageManifest({ kitType: 'app' }) (backwards compatibility) adds
"@react-native-community/netinfo": "^9.0.0",
"@rnx-kit/react-native-lazy-index": "^2.1.7",
"conan": "1.0.0",
"hermes-engine": "~0.11.0",
"quaid": "1.0.0",
"react": "18.1.0",
"react-native": "^0.70.0",
Expand Down
Loading