Skip to content

Commit

Permalink
make yarn update-readme independent of build state
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 committed Oct 31, 2023
1 parent 902f4a0 commit da4019b
Showing 1 changed file with 14 additions and 1 deletion.
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.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 = "<!-- @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

0 comments on commit da4019b

Please sign in to comment.