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
118 changes: 118 additions & 0 deletions .yarn/plugins/@rnx-kit/yarn-plugin-dynamic-overrides.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
// @ts-check

/**
* @import { Descriptor, Hooks, Ident, Plugin } from "@yarnpkg/core";
*
* @typedef {Ident & { specifier: string; }} ExtendedIdent
*/

const DEFAULT_SPECIFIER = "^";
const DYNAMIC_OVERRIDES_KEY = "dynamicPackageOverrides";

/**
* @param {Descriptor} dependency
* @param {Ident=} locator
* @returns {locator is Ident}
*/
function matches(dependency, locator) {
if (!locator) {
return false;
}

// appium -> @appium/base-plugin
if (locator.name === dependency.scope) {
return false;
}

// @appium/base-plugin -> @appium/base-driver
if (locator.scope && locator.scope === dependency.scope) {
return false;
}

return true;
}

// This module *must* be CommonJS because `actions/setup-node` (and probably
// other GitHub actions) does not support ESM. Yarn itself does.
exports.name = "@rnx-kit/yarn-plugin-dynamic-overrides";

/** @type {(require: NodeJS.Require) => Plugin<Hooks>} */
exports.factory = (require) => {
const { SettingsType, structUtils } = require("@yarnpkg/core");

/**
* @param {Map<string, string>} entry
* @returns {[string, ExtendedIdent]}
*/
function toKeyValuePair(entry) {
const id = entry.get("id");
if (!id) {
throw new Error(`"${DYNAMIC_OVERRIDES_KEY}" expects an id`);
}
const ident = structUtils.parseIdent(id);
return [
ident.identHash,
{
...ident,
specifier: entry.get("specifier") ?? DEFAULT_SPECIFIER,
},
];
}

/** @type {Plugin<Hooks>["configuration"] & Record<string, unknown>} */
const configuration = {};
configuration[DYNAMIC_OVERRIDES_KEY] = {
description: "Packages whose dependencies are overridden",
type: SettingsType.SHAPE,
isArray: true,
properties: {
id: {
type: SettingsType.STRING,
},
specifier: {
type: SettingsType.STRING,
default: DEFAULT_SPECIFIER,
},
},
};

/** @type {Map<string, ExtendedIdent>} */
let overrides;

return {
configuration,
hooks: {
reduceDependency: async (
dependency,
project,
locator,
_initialDependency,
_extra
) => {
if (!overrides) {
const config = project.configuration.get(DYNAMIC_OVERRIDES_KEY);
if (!Array.isArray(config)) {
throw new Error(
`Expected "${DYNAMIC_OVERRIDES_KEY}" to be an array`
);
}
overrides = new Map(config.map(toKeyValuePair));
}

const ident = overrides.get(locator.identHash);
if (matches(dependency, ident)) {
const { protocol, selector } = structUtils.parseRange(
dependency.range
);
if (protocol === "npm:" && /^\d/.test(selector)) {
return structUtils.makeDescriptor(
dependency,
`${protocol}${ident.specifier}${selector}`
);
}
}
return dependency;
},
},
};
};
20 changes: 19 additions & 1 deletion .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@ catalog:
"@babel/core": ^7.25.2
"@babel/preset-env": ^7.25.3
"@react-native-webapis/web-storage": ^0.4.6
"@types/node": ^24.0.0
"@rnx-kit/cli": ^2.0.1
"@rnx-kit/metro-config": ^2.2.4
"@rnx-kit/polyfills": ^0.3.0
"@rnx-kit/tsconfig": ^3.0.1
"@types/node": ^24.0.0
compressionLevel: 0
dynamicPackageOverrides:
- id: "@appium/base-driver"
- id: "@appium/logger"
- id: "@appium/support"
- id: "@microsoft/eslint-plugin-sdl"
- id: "@nx/devkit"
- id: "@nx/js"
- id: "@nx/workspace"
- id: appium
- id: argparse
- id: compression
- id: nx
- id: react-native-windows
- id: simple-plist
specifier: ~
enableGlobalCache: false
enableScripts: false
enableTelemetry: false
Expand Down Expand Up @@ -36,5 +51,8 @@ plugins:
- checksum: 8d8252c376e41a67ca509b2778f3fb92164aa91828459ae8a6aa0e13f1b6f9843586d0983ba9a200f6d813d37efc171474c8dbc85b0dff01df56c0d476c238ce
path: .yarn/plugins/@rnx-kit/yarn-plugin-ignore.cjs
spec: "https://raw.githubusercontent.com/microsoft/rnx-kit/main/incubator/yarn-plugin-ignore/dist/yarn-plugin-ignore.cjs"
- checksum: 3b1a87005ab0306362d5ef0813715cf981544b8cc916079259b71b27bb8ad6bb36b53568e0e474ec1809a7632235597a591d0a3a389e0d3aa41f1d661969c379
path: .yarn/plugins/@rnx-kit/yarn-plugin-dynamic-overrides.cjs
spec: "https://raw.githubusercontent.com/microsoft/rnx-kit/refs/heads/main/incubator/yarn-plugin-dynamic-overrides/index.js"
tsEnableAutoTypes: false
yarnPath: .yarn/releases/yarn-4.13.0.cjs
52 changes: 0 additions & 52 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,68 +51,16 @@
"typescript": "^7.0.2"
},
"resolutions": {
"@appium/base-driver/asyncbox": "^6.3.0",
"@appium/base-driver/axios": "^1.18.0",
"@appium/base-driver/lru-cache": "^11.5.1",
"@appium/base-driver/path-to-regexp": "^8.4.2",
"@appium/docutils": "ignore:",
"@appium/logger/lru-cache": "^11.5.1",
"@appium/support/archiver": "~8.0.0",
"@appium/support/asyncbox": "^6.3.0",
"@appium/support/axios": "^1.18.0",
"@appium/support/form-data": "~4.0.6",
"@appium/support/glob": "^13.0.6",
"@appium/support/semver": "~7.8.4",
"@appium/support/shell-quote": "^1.8.4",
"@appium/support/teen_process": "~4.1.3",
"@appium/support/uuid": "~14.0.0",
"@appium/support/yauzl": "~3.4.0",
"@colors/colors": "^1.6.0",
"@microsoft/eslint-plugin-sdl/eslint-plugin-n": "^17.10.3",
"@microsoft/eslint-plugin-sdl/eslint-plugin-react": "^7.37.3",
"@nx/devkit/minimatch": "^10.2.5",
"@nx/js/picomatch": "^4.0.4",
"@nx/workspace/picomatch": "^4.0.4",
"@react-native-windows/cli/@xmldom/xmldom": "^0.9.0",
"@react-native-windows/telemetry/@xmldom/xmldom": "^0.9.0",
"appium/ajv": "~8.18.0",
"appium/asyncbox": "^6.3.0",
"appium/axios": "^1.18.0",
"appium/lru-cache": "^11.5.1",
"appium/semver": "~7.8.4",
"appium/teen_process": "~4.1.3",
"appium/ws": "~8.21.0",
"appium/yaml": "~2.9.0",
"argparse/sprintf-js": "^1.0.2",
"babel-jest": "ignore:",
"compression/bytes": "^3.1.2",
"node-gyp": "ignore:",
"node-gyp-build": "ignore:",
"nx/axios": "^1.16.0",
"nx/brace-expansion": "~5.0.6",
"nx/form-data": "~4.0.6",
"nx/hasown": "~2.0.4",
"nx/minimatch": "^10.2.5",
"nx/semver": "^7.7.4",
"nx/tmp": "^0.2.7",
"oxc-parser": "^0.138.0",
"oxc-resolver": "^11.23.0",
"react-native-windows/@react-native-community/cli": "^20.0.0",
"react-native-windows/@react-native-community/cli-platform-android": "^20.0.0",
"react-native-windows/@react-native-community/cli-platform-ios": "^20.0.0",
"react-native-windows/@react-native/assets-registry": "^0.83.0",
"react-native-windows/@react-native/codegen": "^0.83.0",
"react-native-windows/@react-native/community-cli-plugin": "^0.83.0",
"react-native-windows/@react-native/debugger-frontend": "^0.83.0",
"react-native-windows/@react-native/debugger-shell": "^0.83.0",
"react-native-windows/@react-native/dev-middleware": "^0.83.0",
"react-native-windows/@react-native/gradle-plugin": "^0.83.0",
"react-native-windows/@react-native/js-polyfills": "^0.83.0",
"react-native-windows/@react-native/normalize-colors": "^0.83.0",
"react-native-windows/@react-native/virtualized-lists": "^0.83.0",
"safe-buffer": "~5.2.1",
"simple-plist/bplist-creator": "~0.1.0",
"simple-plist/bplist-parser": "~0.3.1",
"xcode/uuid": "~14.0.0"
},
"engines": {
Expand Down
Loading
Loading