Skip to content

Commit

Permalink
fix(align-deps): add profile for 0.73 (#2724)
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 authored Nov 30, 2023
1 parent 7654fac commit 92445e6
Show file tree
Hide file tree
Showing 11 changed files with 225 additions and 55 deletions.
5 changes: 5 additions & 0 deletions .changeset/eleven-parents-walk.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.73
98 changes: 49 additions & 49 deletions packages/align-deps/README.md

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions packages/align-deps/scripts/update-profile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ function generateFromTemplate({
const currentVersionVarName = `${nextVersionCoerced.major}_${
nextVersionCoerced.minor - 1
}`;

const useOldBabelPresetName = semverCompare(nextVersionCoerced, "0.73.0") < 0;
const babelPresetName = useOldBabelPresetName
? "metro-react-native-babel-preset"
: "@react-native/babel-preset";
const babelPresetVersion = useOldBabelPresetName
? metroVersion
: targetVersion + ".0";

return `import type { Package, Profile } from "../../../types";
import { profile as profile_${currentVersionVarName} } from "./profile-${currentVersion}";
Expand Down Expand Up @@ -208,8 +217,8 @@ export const profile: Profile = {
},
"babel-preset-react-native": {
name: "metro-react-native-babel-preset",
version: "^${metroVersion}",
name: "${babelPresetName}",
version: "^${babelPresetVersion}",
devOnly: true,
},
"community/cli": {
Expand Down
15 changes: 14 additions & 1 deletion packages/align-deps/scripts/update-readme.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env node
// @ts-check

import { bundle } from "@rnx-kit/scripts/src/commands/bundle.js";
import { markdownTable } from "markdown-table";
import * as fs from "node:fs";
import { preset } from "../lib/presets/microsoft/react-native.js";

const README = "README.md";
const TOKEN_START = "<!-- @rnx-kit/align-deps/capabilities start -->";
Expand All @@ -18,6 +18,18 @@ function isCoreCapability(capability) {
return capability === "core" || capability.startsWith("core-");
}

/**
* Loads the `microsoft/react-native` preset.
*/
async function loadPreset() {
// Ensure we always have an updated preset
await bundle({});

/** @type {typeof import("../src/index.ts")} */
const { presets } = await import("../lib/index.js");
return presets["microsoft/react-native"];
}

/**
* Compare function that places core capabilities first.
* @param lhs {string}
Expand All @@ -40,6 +52,7 @@ function sortCoreFirst(lhs, rhs) {
return lhs < rhs ? -1 : 1;
}

const preset = await loadPreset();
const allVersions = /** @type {string[]} */ (Object.keys(preset).reverse());
const allCapabilities = /** @type {import("@rnx-kit/config").Capability[]} */ (
Object.keys(preset[allVersions[0]]).sort(sortCoreFirst)
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 @@ -31,6 +31,12 @@ export const bannedPackages: ExcludedPackage[] = [
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: "metro-react-native-babel-preset",
version: "*",
reason:
"This package was renamed to '@react-native/babel-preset' in react-native 0.73. Replace this package when you're on react-native 0.73 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 @@ -11,6 +11,7 @@ import { profile as profile_0_69 } from "./react-native/profile-0.69";
import { profile as profile_0_70 } from "./react-native/profile-0.70";
import { profile as profile_0_71 } from "./react-native/profile-0.71";
import { profile as profile_0_72 } from "./react-native/profile-0.72";
import { profile as profile_0_73 } from "./react-native/profile-0.73";

// 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 @@ -28,4 +29,5 @@ export const preset: Readonly<Preset> = {
"0.70": profile_0_70,
"0.71": profile_0_71,
"0.72": profile_0_72,
"0.73": profile_0_73,
};
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const profile: Profile = {
},
"datetime-picker": {
name: "@react-native-community/datetimepicker",
version: "^7.1.0",
version: "^7.6.2",
},
gestures: {
name: "react-native-gesture-handler",
Expand Down
132 changes: 132 additions & 0 deletions packages/align-deps/src/presets/microsoft/react-native/profile-0.73.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import type { Package, Profile } from "../../../types";
import { profile as profile_0_72 } from "./profile-0.72";

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

export const profile: Profile = {
...profile_0_72,
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.73.0",
capabilities: ["react"],
},
"core-windows": {
name: "react-native-windows",
version: "^0.73.0",
capabilities: ["core"],
},
"core/metro-config": {
name: "@react-native/metro-config",
version: "^0.73.0",
devOnly: true,
},

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

animation: {
name: "react-native-reanimated",
version: "^3.6.0",
},
gestures: {
name: "react-native-gesture-handler",
version: "^2.14.0",
},
"masked-view": {
name: "@react-native-masked-view/masked-view",
version: "^0.3.0",
},
netinfo: {
name: "@react-native-community/netinfo",
version: "^11.0.1",
},
storage: {
name: "@react-native-async-storage/async-storage",
version: "^1.21.0",
},
svg: {
name: "react-native-svg",
version: "^14.0.0",
},
"test-app": {
name: "react-native-test-app",
version: "^2.5.34",
devOnly: true,
},
webview: {
name: "react-native-webview",
version: "^13.6.1",
},
};
3 changes: 3 additions & 0 deletions packages/align-deps/test/preset.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { profile as profile_0_69 } from "../src/presets/microsoft/react-native/p
import { profile as profile_0_70 } from "../src/presets/microsoft/react-native/profile-0.70";
import { profile as profile_0_71 } from "../src/presets/microsoft/react-native/profile-0.71";
import { profile as profile_0_72 } from "../src/presets/microsoft/react-native/profile-0.72";
import { profile as profile_0_73 } from "../src/presets/microsoft/react-native/profile-0.73";

describe("filterPreset()", () => {
test("returns no profiles if requirements cannot be satisfied", () => {
Expand Down Expand Up @@ -33,6 +34,7 @@ describe("filterPreset()", () => {
"0.70": profile_0_70,
"0.71": profile_0_71,
"0.72": profile_0_72,
"0.73": profile_0_73,
});
});

Expand All @@ -43,6 +45,7 @@ describe("filterPreset()", () => {
"0.70": profile_0_70,
"0.71": profile_0_71,
"0.72": profile_0_72,
"0.73": profile_0_73,
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"peerDependencies": {
"react": "16.11.0 || 16.13.1 || 17.0.1 || 17.0.2 || 18.0.0 || 18.1.0 || 18.2.0",
"react-native": "^0.62.3 || ^0.63.2 || ^0.64.2 || ^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.69.0 || ^0.70.0 || ^0.71.0 || ^0.72.0"
"react-native": "^0.62.3 || ^0.63.2 || ^0.64.2 || ^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.69.0 || ^0.70.0 || ^0.71.0 || ^0.72.0 || ^0.73.0"
},
"devDependencies": {
"@babel/core": "^7.20.0",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4103,7 +4103,7 @@ __metadata:
typescript: ^5.0.0
peerDependencies:
react: 16.11.0 || 16.13.1 || 17.0.1 || 17.0.2 || 18.0.0 || 18.1.0 || 18.2.0
react-native: ^0.62.3 || ^0.63.2 || ^0.64.2 || ^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.69.0 || ^0.70.0 || ^0.71.0 || ^0.72.0
react-native: ^0.62.3 || ^0.63.2 || ^0.64.2 || ^0.65.0 || ^0.66.0 || ^0.67.0 || ^0.68.0 || ^0.69.0 || ^0.70.0 || ^0.71.0 || ^0.72.0 || ^0.73.0
languageName: unknown
linkType: soft

Expand Down

0 comments on commit 92445e6

Please sign in to comment.