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
2 changes: 1 addition & 1 deletion .github/actions/setup-toolchain/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ runs:
- name: Set up Node.js
uses: actions/setup-node@v4.1.0
with:
node-version: "20"
node-version: "22"
cache: ${{ inputs.cache-npm-dependencies }}
- name: Set up Xcode
if: ${{ inputs.xcode-developer-dir != '' }}
Expand Down
24 changes: 16 additions & 8 deletions android/autolink.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @ts-check
import { getCurrentState } from "@rnx-kit/tools-react-native/cache";
import { loadContext } from "@rnx-kit/tools-react-native/context";
import { loadContextAsync } from "@rnx-kit/tools-react-native";
import * as fs from "node:fs";
import * as path from "node:path";
import {
Expand Down Expand Up @@ -83,16 +83,16 @@ export function pruneDependencies(config) {
/**
* @param {string} json
* @param {string} projectRoot
* @returns {Config}
* @returns {Promise<Config>}
*/
function loadConfig(json, projectRoot) {
async function loadConfig(json, projectRoot) {
const state = getCurrentState(projectRoot);
const stateFile = json.substring(0, json.length - "json".length) + "sha256";
if (fs.existsSync(stateFile) && readTextFile(stateFile) === state) {
return readJSONFile(json);
}

const config = loadContext(projectRoot);
const config = await loadContextAsync(projectRoot);
const prunedConfig = pruneDependencies(config);

ensureDirForFile(json);
Expand All @@ -101,10 +101,13 @@ function loadConfig(json, projectRoot) {
return prunedConfig;
}

if (isMain(import.meta.url)) {
const [, , projectRoot = process.cwd(), output] = process.argv;

const config = loadConfig(
/**
* @param {string} projectRoot
* @param {string} output
* @returns {Promise<void>}
*/
async function main(projectRoot, output) {
const config = await loadConfig(
output.replace(
/[/\\]app[/\\]build[/\\]generated[/\\]rnta[/\\]/,
"/build/generated/autolinking/"
Expand All @@ -121,3 +124,8 @@ if (isMain(import.meta.url)) {
writeTextFile(output, json + "\n");
}
}

if (isMain(import.meta.url)) {
const [, , projectRoot = process.cwd(), output = ""] = process.argv;
await main(projectRoot, output);
}
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@
"postpack": "node scripts/internal/pack.mjs post",
"release-notes": "node scripts/internal/release-notes.mjs",
"set-react-version": "node scripts/internal/set-react-version.mjs",
"show-affected": "node --import tsx scripts/build/affected.ts",
"show-affected": "node --experimental-transform-types --no-warnings scripts/build/affected.ts",
"test": "node scripts/internal/test.mjs",
"test:js": "node --import tsx --test $(git ls-files '*.test.ts')",
"test:js": "node --experimental-transform-types --no-warnings --test $(git ls-files '*.test.ts')",
"test:matrix": "node scripts/testing/test-matrix.mjs",
"test:rb": "bundle exec ruby -Ilib:test -e \"Dir.glob('./test/test_*.rb').each { |file| require(file) }\""
},
"dependencies": {
"@rnx-kit/react-native-host": "^0.5.0",
"@rnx-kit/tools-react-native": "^2.0.0",
"@rnx-kit/tools-react-native": "^2.0.1",
"ajv": "^8.0.0",
"cliui": "^8.0.0",
"fast-xml-parser": "^4.0.0",
Expand Down Expand Up @@ -146,7 +146,6 @@
"react-native-windows": "^0.75.0",
"semantic-release": "^24.0.0",
"suggestion-bot": "^3.0.0",
"tsx": "^4.16.2",
"typescript": "^5.0.0"
},
"engines": {
Expand Down
4 changes: 2 additions & 2 deletions scripts/internal/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ switch (getTarget(input)) {
break;
case "typescript":
testWith(process.argv0, [
"--import",
"tsx",
"--experimental-transform-types",
"--no-warnings",
"--test",
"--experimental-test-coverage",
...input,
Expand Down
4 changes: 2 additions & 2 deletions test/android/gradle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import * as path from "node:path";
import { URL, fileURLToPath } from "node:url";
import { gatherConfig, writeAllFiles } from "../../scripts/configure.mjs";
import { findNearest, readJSONFile } from "../../scripts/helpers.js";
import type { ConfigureParams } from "../../scripts/types.js";
import { templatePath } from "../template.js";
import type { ConfigureParams } from "../../scripts/types.ts";
import { templatePath } from "../template.ts";

const GRADLE_TEST_TASK = "nodeTest";
const MKDIR_OPTIONS = { recursive: true, mode: 0o755 };
Expand Down
2 changes: 1 addition & 1 deletion test/android/test-app-util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
reactNativeVersion,
removeProject,
runGradleWithProject,
} from "./gradle.js";
} from "./gradle.ts";

describe("test-app-util.gradle", () => {
const defaultTestProject = "TestAppUtilTest";
Expand Down
6 changes: 3 additions & 3 deletions test/configure/gatherConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { describe, it } from "node:test";
import { gatherConfig as gatherConfigActual } from "../../scripts/configure.mjs";
import { readTextFile } from "../../scripts/helpers.js";
import { join } from "../../scripts/template.mjs";
import type { Configuration, ConfigureParams } from "../../scripts/types.js";
import { templatePath } from "../template.js";
import { mockParams } from "./mockParams.js";
import type { Configuration, ConfigureParams } from "../../scripts/types.ts";
import { templatePath } from "../template.ts";
import { mockParams } from "./mockParams.ts";

describe("gatherConfig()", () => {
const templateDir = templatePath.substring(
Expand Down
2 changes: 1 addition & 1 deletion test/configure/getAppName.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { equal } from "node:assert/strict";
import { afterEach, describe, it } from "node:test";
import { getAppName as getAppNameActual } from "../../scripts/configure.mjs";
import { fs, setMockFiles } from "../fs.mock.js";
import { fs, setMockFiles } from "../fs.mock.ts";

describe("getAppName()", () => {
const getAppName: typeof getAppNameActual = (p) => getAppNameActual(p, fs);
Expand Down
6 changes: 3 additions & 3 deletions test/configure/getConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
getConfig as getConfigActual,
getPlatformPackage,
} from "../../scripts/configure.mjs";
import type { ConfigureParams, Platform } from "../../scripts/types.js";
import { templatePath } from "../template.js";
import { mockParams } from "./mockParams.js";
import type { ConfigureParams, Platform } from "../../scripts/types.ts";
import { templatePath } from "../template.ts";
import { mockParams } from "./mockParams.ts";

describe("getConfig()", () => {
const getConfig: typeof getConfigActual = (params, platform) =>
Expand Down
2 changes: 1 addition & 1 deletion test/configure/isDestructive.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { equal, ok } from "node:assert/strict";
import { afterEach, describe, it } from "node:test";
import { isDestructive as isDestructiveActual } from "../../scripts/configure.mjs";
import { fs, setMockFiles } from "../fs.mock.js";
import { fs, setMockFiles } from "../fs.mock.ts";

describe("isDestructive()", () => {
/**
Expand Down
2 changes: 1 addition & 1 deletion test/configure/mockParams.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* node:coverage disable */
import type { ConfigureParams } from "../../scripts/types.js";
import type { ConfigureParams } from "../../scripts/types.ts";

/**
* Returns mock parameters.
Expand Down
4 changes: 2 additions & 2 deletions test/configure/reactNativeConfig.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { equal, ok } from "node:assert/strict";
import { describe, it } from "node:test";
import { reactNativeConfig as reactNativeConfigActual } from "../../scripts/configure.mjs";
import type { ConfigureParams } from "../../scripts/types.js";
import { mockParams } from "./mockParams.js";
import type { ConfigureParams } from "../../scripts/types.ts";
import { mockParams } from "./mockParams.ts";

describe("reactNativeConfig()", () => {
const reactNativeConfig = (params: ConfigureParams): string => {
Expand Down
2 changes: 1 addition & 1 deletion test/configure/removeAllFiles.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ok } from "node:assert/strict";
import { after, beforeEach, describe, it } from "node:test";
import { removeAllFiles as removeAllFilesActual } from "../../scripts/configure.mjs";
import { fs, setMockFiles } from "../fs.mock.js";
import { fs, setMockFiles } from "../fs.mock.ts";

describe("removeAllFiles()", () => {
const removeAllFiles: typeof removeAllFilesActual = (files, destination) =>
Expand Down
4 changes: 2 additions & 2 deletions test/configure/updatePackageManifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { afterEach, describe, it } from "node:test";
import { URL } from "node:url";
import { updatePackageManifest as updatePackageManifestActual } from "../../scripts/configure.mjs";
import { readJSONFile } from "../../scripts/helpers.js";
import type { Manifest } from "../../scripts/types.js";
import { fs, setMockFiles } from "../fs.mock.js";
import type { Manifest } from "../../scripts/types.ts";
import { fs, setMockFiles } from "../fs.mock.ts";

function getExampleManifest() {
const p = new URL("../../example/package.json", import.meta.url);
Expand Down
2 changes: 1 addition & 1 deletion test/configure/writeAllFiles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as path from "node:path";
import { afterEach, describe, it } from "node:test";
import { writeAllFiles as writeAllFilesActual } from "../../scripts/configure.mjs";
import { readTextFile as readTextFileActual } from "../../scripts/helpers.js";
import { fs, setMockFiles } from "../fs.mock.js";
import { fs, setMockFiles } from "../fs.mock.ts";

describe("writeAllFiles()", () => {
const readTextFile: typeof readTextFileActual = (p) =>
Expand Down
2 changes: 1 addition & 1 deletion test/embed-manifest/cpp.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { equal } from "node:assert/strict";
import { describe, it } from "node:test";
import { generate as generateActual } from "../../scripts/embed-manifest/cpp.mjs";
import * as fixtures from "./fixtures.js";
import * as fixtures from "./fixtures.ts";

describe("embed manifest (C++)", () => {
const generate = (json: Record<string, unknown>) => generateActual(json, "0");
Expand Down
2 changes: 1 addition & 1 deletion test/embed-manifest/kotlin.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { equal } from "node:assert/strict";
import { describe, it } from "node:test";
import { generate as generateActual } from "../../scripts/embed-manifest/kotlin.mjs";
import * as fixtures from "./fixtures.js";
import * as fixtures from "./fixtures.ts";

describe("embed manifest (Kotlin)", () => {
const generate = (json: Record<string, unknown>) => generateActual(json, "0");
Expand Down
2 changes: 1 addition & 1 deletion test/embed-manifest/swift.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { equal } from "node:assert/strict";
import { describe, it } from "node:test";
import { generate as generateActual } from "../../scripts/embed-manifest/swift.mjs";
import * as fixtures from "./fixtures.js";
import * as fixtures from "./fixtures.ts";

describe("embed manifest (Swift)", () => {
const generate = (json: Record<string, unknown>) => generateActual(json, "0");
Expand Down
2 changes: 1 addition & 1 deletion test/embed-manifest/validate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { deepEqual, equal, match, notEqual } from "node:assert/strict";
import { afterEach, describe, it } from "node:test";
import { validate as validateActual } from "../../scripts/embed-manifest/validate.mjs";
import { findFile as findFileActual } from "../../scripts/helpers.js";
import { fs, setMockFiles } from "../fs.mock.js";
import { fs, setMockFiles } from "../fs.mock.ts";

describe("validate()", () => {
const findFile: typeof findFileActual = (file, startDir = undefined) =>
Expand Down
2 changes: 1 addition & 1 deletion test/windows/copyAndReplace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { equal, fail, match, rejects } from "node:assert/strict";
import { afterEach, describe, it } from "node:test";
import { readTextFile as readTextFileActual } from "../../scripts/helpers.js";
import { copyAndReplace as copyAndReplaceActual } from "../../windows/test-app.mjs";
import { fs, setMockFiles } from "../fs.mock.js";
import { fs, setMockFiles } from "../fs.mock.ts";

describe("copyAndReplace()", () => {
const copyAndReplace: typeof copyAndReplaceActual = (src, dst, r) =>
Expand Down
2 changes: 1 addition & 1 deletion test/windows/generateSolution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { equal } from "node:assert/strict";
import * as path from "node:path";
import { afterEach, beforeEach, describe, it } from "node:test";
import { generateSolution as generateSolutionActual } from "../../windows/test-app.mjs";
import { fs, setMockFiles } from "../fs.mock.js";
import { fs, setMockFiles } from "../fs.mock.ts";

describe("generateSolution()", () => {
const generateSolution: typeof generateSolutionActual = (d, cfg) =>
Expand Down
2 changes: 1 addition & 1 deletion test/windows/getBundleResources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { deepEqual, equal, match } from "node:assert/strict";
import * as path from "node:path";
import { afterEach, describe, it } from "node:test";
import { getBundleResources as getBundleResourcesActual } from "../../windows/project.mjs";
import { fs, setMockFiles } from "../fs.mock.js";
import { fs, setMockFiles } from "../fs.mock.ts";

describe("getBundleResources()", () => {
const getBundleResources: typeof getBundleResourcesActual = (p) =>
Expand Down
2 changes: 1 addition & 1 deletion test/windows/parseResources.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { deepEqual, equal, match } from "node:assert/strict";
import { afterEach, describe, it } from "node:test";
import { parseResources as parseResourcesActual } from "../../windows/project.mjs";
import { fs, setMockFiles } from "../fs.mock.js";
import { fs, setMockFiles } from "../fs.mock.ts";

describe("parseResources()", () => {
const parseResources: typeof parseResourcesActual = (r, p) =>
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"allowImportingTsExtensions": true,
"moduleResolution": "Node",
"noEmit": true,
"lib": ["ES2022", "DOM"]
Expand Down
Loading