From da4019ba50f909d7639d31c72f51aad05879fbad Mon Sep 17 00:00:00 2001 From: Tommy Nguyen <4123478+tido64@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:42:58 +0200 Subject: [PATCH] make `yarn update-readme` independent of build state --- packages/align-deps/scripts/update-readme.mjs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/align-deps/scripts/update-readme.mjs b/packages/align-deps/scripts/update-readme.mjs index aa48423575..7f1c1b050a 100755 --- a/packages/align-deps/scripts/update-readme.mjs +++ b/packages/align-deps/scripts/update-readme.mjs @@ -1,9 +1,9 @@ #!/usr/bin/env node // @ts-check +import bundle from "@rnx-kit/scripts/src/commands/bundle.mjs"; 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 = ""; @@ -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} @@ -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)