diff --git a/.changeset/little-impalas-look.md b/.changeset/little-impalas-look.md new file mode 100644 index 000000000..a845151cc --- /dev/null +++ b/.changeset/little-impalas-look.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/console/test/index.test.ts b/packages/console/test/index.test.ts index 44f32e79a..e335f3995 100644 --- a/packages/console/test/index.test.ts +++ b/packages/console/test/index.test.ts @@ -5,30 +5,21 @@ import { error, info, warn } from "../src/index"; describe("console", () => { const args = ["string", 0, true]; - it("prints error messages", (t) => { - const errorMock = t.mock.method(console, "error", () => null); - - error(...args); - - equal(errorMock.mock.calls.length, 1); - deepEqual(errorMock.mock.calls[0].arguments, ["error", ...args]); - }); - - it("prints info messages", (t) => { - const infoMock = t.mock.method(console, "log", () => null); - - info(...args); - - equal(infoMock.mock.calls.length, 1); - deepEqual(infoMock.mock.calls[0].arguments, ["info", ...args]); - }); - - it("prints warning messages", (t) => { - const warnMock = t.mock.method(console, "warn", () => null); - - warn(...args); - - equal(warnMock.mock.calls.length, 1); - deepEqual(warnMock.mock.calls[0].arguments, ["warn", ...args]); - }); + const loggers = [ + { log: error, methodName: "error" as const }, + { log: info, logLevel: "info", methodName: "log" as const }, + { log: warn, methodName: "warn" as const }, + ]; + + for (const { log, logLevel, methodName } of loggers) { + const level = logLevel ?? methodName; + it(`prints ${level} messages`, (t) => { + const method = t.mock.method(console, methodName, () => null); + + log(...args); + + equal(method.mock.calls.length, 1); + deepEqual(method.mock.calls[0].arguments, [level, ...args]); + }); + } }); diff --git a/packages/typescript-react-native-compiler/CHANGELOG.md b/packages/typescript-react-native-compiler/CHANGELOG.md deleted file mode 100644 index ba0faaab0..000000000 --- a/packages/typescript-react-native-compiler/CHANGELOG.md +++ /dev/null @@ -1,88 +0,0 @@ -# Change Log - @rnx-kit/typescript-react-native-compiler - -## 0.0.10 - -### Patch Changes - -- f01bdef6: Mark this package as depcrecated. -- Updated dependencies [f01bdef6] - - @rnx-kit/typescript-react-native-resolver@0.3.1 - -## 0.0.9 - -### Patch Changes - -- 94aeb460: BREAKING: remove command-line parameters - 'traceReactNativeModuleResolutionErrors' and 'traceResolutionLog' which were - used for configuring custom trace logging. From this version onward, standard - TypeScript module resolution tracing applies. Set the compiler option - 'traceResolution' to true, and you will see trace messages appear in the - console. Logging to a file is no longer supported. -- Updated dependencies [94aeb460] - - @rnx-kit/typescript-react-native-resolver@0.3.0 - -## 0.0.8 - -### Patch Changes - -- 569a099: Bump @rnx-kit/tools-node to v1.2.7 - -## 0.0.7 - -### Patch Changes - -- Updated dependencies [28f632a] - - @rnx-kit/typescript-react-native-resolver@0.2.0 - -## 0.0.6 - -Tue, 30 Nov 2021 17:24:14 GMT - -### Patches - -- Bump @rnx-kit/tools-language to v1.2.6 -- Bump @rnx-kit/tools-node to v1.2.6 -- Bump @rnx-kit/typescript-react-native-resolver to v0.1.3 -- Bump @rnx-kit/typescript-service to v1.5.3 - -## 0.0.5 - -Fri, 19 Nov 2021 16:08:47 GMT - -### Patches - -- Bump @rnx-kit/typescript-react-native-resolver to v0.1.2 -- Bump @rnx-kit/typescript-service to v1.5.2 - -## 0.0.4 - -Thu, 18 Nov 2021 20:51:05 GMT - -### Patches - -- Bump @rnx-kit/tools-language to v1.2.5 -- Bump @rnx-kit/tools-node to v1.2.5 -- Bump @rnx-kit/typescript-react-native-resolver to v0.1.1 -- Bump @rnx-kit/typescript-service to v1.5.1 - -## 0.0.3 - -Tue, 09 Nov 2021 21:11:31 GMT - -### Patches - -- Update the CLI's Metro/TS integration to use the new, generalized resolver in @rnx-kit/typescript-react-native-resolver. Remove the unneeded "default" resolver. (afoxman@microsoft.com) -- Bump @rnx-kit/typescript-react-native-resolver to v0.1.0 -- Bump @rnx-kit/typescript-service to v1.5.0 - -## 0.0.2 - -Fri, 05 Nov 2021 19:44:16 GMT - -### Patches - -- Create the typescript-react-native-compiler package (afoxman@microsoft.com) -- Bump @rnx-kit/tools-language to v1.2.4 -- Bump @rnx-kit/tools-node to v1.2.4 -- Bump @rnx-kit/typescript-react-native-resolver to v0.0.5 -- Bump @rnx-kit/typescript-service to v1.4.3 diff --git a/packages/typescript-react-native-compiler/README.md b/packages/typescript-react-native-compiler/README.md deleted file mode 100644 index 791c58ad0..000000000 --- a/packages/typescript-react-native-compiler/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# @rnx-kit/typescript-react-native-compiler - -[![Build](https://github.com/microsoft/rnx-kit/actions/workflows/build.yml/badge.svg)](https://github.com/microsoft/rnx-kit/actions/workflows/build.yml) -[![npm version](https://img.shields.io/npm/v/@rnx-kit/typescript-react-native-compiler)](https://www.npmjs.com/package/@rnx-kit/typescript-react-native-compiler) - -`@rnx-kit/typescript-react-native-compiler` is the TypeScript compiler `tsc` -with a custom module resolver for react-native projects. - -## 🛑 Deprecated 🛑 - -This tool has been deprecated in favor of using `tsc` >= 4.7 with the -`moduleSuffixes` -[compiler option](https://www.typescriptlang.org/tsconfig#moduleSuffixes). - -You may continue to use it, but it will be removed in a future release. - -## Synopsis - -This package extends TypeScript, adding the concept of a platform to `tsc`. When -resolving modules, the platform is used to find platform-extension files such as -`foo.ios.ts` and `foo.native.ts`. The platform is also used to map -`react-native` module references to out-of-tree platforms such as -`react-native-windows` and `react-native-macos`. - -This package exports a new command-line tool: `rn-tsc`. It is a drop-in -replacement for `tsc` with a few additional command-line parameters. - -## Example Commands - -```bash -yarn run rn-tsc --platform ios --platformExtensions mobile,native -``` - -```bash -yarn run rn-tsc --platform macos --platformExtensions native --disableReactNativePackageSubstitution -``` - -Run a normal build without using the custom module resolver: - -```bash -yarn run rn-tsc -``` - -Get a full listing of all command-line parameters: - -```bash -yarn run rn-tsc --help -``` diff --git a/scripts/src/index.js b/scripts/src/index.js index facfdf105..335a820b0 100755 --- a/scripts/src/index.js +++ b/scripts/src/index.js @@ -16,8 +16,7 @@ import { updateApiReadme } from "./commands/updateApiReadme.js"; */ function init(commands) { const parser = yargs(process.argv.slice(2)); - Object.keys(commands).forEach((name) => { - const { description, command } = commands[name]; + for (const [name, { description, command }] of Object.entries(commands)) { parser.command(name, description, {}, async (args) => { try { await command(args, process.argv.slice(3)); @@ -28,7 +27,7 @@ function init(commands) { process.exitCode = 1; } }); - }); + } return parser.help().demandCommand().argv; } diff --git a/scripts/src/process.js b/scripts/src/process.js index 45f483ca8..3b2d4290b 100644 --- a/scripts/src/process.js +++ b/scripts/src/process.js @@ -28,7 +28,7 @@ function workspaceRoot() { * @param {SpawnOptions=} options * @returns {Promise} */ -export function spawn(command, args, options) { +function spawn(command, args, options) { return new Promise((resolve, reject) => { /** @type {SpawnOptions} */ const opts = { @@ -70,14 +70,3 @@ export function runScript(command, ...args) { const yarn = os.platform() === "win32" ? "yarn.cmd" : "yarn"; return execute(yarn, command, ...args); } - -/** - * @param {...(() => Promise)} scripts - * @returns {Promise} - */ -export function sequence(...scripts) { - return scripts.reduce( - (result, script) => result.then(() => script()), - Promise.resolve() - ); -} diff --git a/scripts/src/require.js b/scripts/src/require.js deleted file mode 100644 index 139f5af5e..000000000 --- a/scripts/src/require.js +++ /dev/null @@ -1,3 +0,0 @@ -// @ts-check -import { createRequire } from "node:module"; -export const require = createRequire(import.meta.url);