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
1 change: 0 additions & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"access": "public",
"baseBranch": "origin/main",
"ignore": [
"@rnx-kit/ignore",
"@rnx-kit/template",
"@rnx-kit/test-app",
"@rnx-kit/test-app-macos",
Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ plugins:
spec: "@yarnpkg/plugin-compat"
- path: incubator/yarn-plugin-dynamic-extensions/index.js
- path: incubator/yarn-plugin-external-workspaces/dist/external-workspaces.cjs
- path: incubator/yarn-plugin-ignore/dist/yarn-plugin-ignore.cjs
- path: incubator/yarn-plugin-install-to/dist/yarn-plugin-install-to.cjs

tsEnableAutoTypes: false
Expand Down
10 changes: 5 additions & 5 deletions docsite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
"typescript": "catalog:"
},
"resolutions": {
"@algolia/autocomplete-core": "link:../incubator/ignore",
"@docsearch/react": "link:../incubator/ignore",
"@algolia/autocomplete-core": "ignore:",
"@docsearch/react": "ignore:",
"@pnpm/network.ca-file/graceful-fs": "^4.2.10",
"algoliasearch": "link:../incubator/ignore",
"algoliasearch-helper": "link:../incubator/ignore",
"node-gyp": "link:../incubator/ignore"
"algoliasearch": "ignore:",
"algoliasearch-helper": "ignore:",
"node-gyp": "ignore:"
},
"browserslist": {
"production": [
Expand Down
20 changes: 10 additions & 10 deletions docsite/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ __metadata:
version: 8
cacheKey: 10c0

"@algolia/autocomplete-core@link:../incubator/ignore::locator=%40rnx-kit%2Fdocsite%40workspace%3A.":
"@algolia/autocomplete-core@ignore:":
version: 0.0.0-use.local
resolution: "@algolia/autocomplete-core@link:../incubator/ignore::locator=%40rnx-kit%2Fdocsite%40workspace%3A."
resolution: "@algolia/autocomplete-core@ignore:"
languageName: node
linkType: soft

Expand Down Expand Up @@ -1800,9 +1800,9 @@ __metadata:
languageName: node
linkType: hard

"@docsearch/react@link:../incubator/ignore::locator=%40rnx-kit%2Fdocsite%40workspace%3A.":
"@docsearch/react@ignore:":
version: 0.0.0-use.local
resolution: "@docsearch/react@link:../incubator/ignore::locator=%40rnx-kit%2Fdocsite%40workspace%3A."
resolution: "@docsearch/react@ignore:"
languageName: node
linkType: soft

Expand Down Expand Up @@ -4381,15 +4381,15 @@ __metadata:
languageName: node
linkType: hard

"algoliasearch-helper@link:../incubator/ignore::locator=%40rnx-kit%2Fdocsite%40workspace%3A.":
"algoliasearch-helper@ignore:":
version: 0.0.0-use.local
resolution: "algoliasearch-helper@link:../incubator/ignore::locator=%40rnx-kit%2Fdocsite%40workspace%3A."
resolution: "algoliasearch-helper@ignore:"
languageName: node
linkType: soft

"algoliasearch@link:../incubator/ignore::locator=%40rnx-kit%2Fdocsite%40workspace%3A.":
"algoliasearch@ignore:":
version: 0.0.0-use.local
resolution: "algoliasearch@link:../incubator/ignore::locator=%40rnx-kit%2Fdocsite%40workspace%3A."
resolution: "algoliasearch@ignore:"
languageName: node
linkType: soft

Expand Down Expand Up @@ -9344,9 +9344,9 @@ __metadata:
languageName: node
linkType: hard

"node-gyp@link:../incubator/ignore::locator=%40rnx-kit%2Fdocsite%40workspace%3A.":
"node-gyp@ignore:":
version: 0.0.0-use.local
resolution: "node-gyp@link:../incubator/ignore::locator=%40rnx-kit%2Fdocsite%40workspace%3A."
resolution: "node-gyp@ignore:"
languageName: node
linkType: soft

Expand Down
1 change: 0 additions & 1 deletion incubator/ignore/index.js

This file was deleted.

25 changes: 0 additions & 25 deletions incubator/ignore/package.json

This file was deleted.

2 changes: 2 additions & 0 deletions incubator/yarn-plugin-ignore/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
!dist/
dist/*.map
29 changes: 29 additions & 0 deletions incubator/yarn-plugin-ignore/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# @rnx-kit/yarn-plugin-ignore

[![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/yarn-plugin-ignore)](https://www.npmjs.com/package/@rnx-kit/yarn-plugin-ignore)

🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧

### THIS TOOL IS EXPERIMENTAL — USE WITH CAUTION

🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧

A Yarn plugin for excluding packages from being installed.

## Installation

```sh
yarn plugin import https://raw.githubusercontent.com/microsoft/rnx-kit/main/incubator/yarn-plugin-ignore/dist/yarn-plugin-ignore.cjs
```

## Usage

In the root `package.json`, add a `resolutions` section and use the `ignore:`
protocol to exclude packages. For example, to exclude `node-gyp`:

Comment thread
tido64 marked this conversation as resolved.
```diff
+ "resolutions": {
+ "node-gyp": "ignore:"
+ },
```
153 changes: 153 additions & 0 deletions incubator/yarn-plugin-ignore/dist/yarn-plugin-ignore.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@rnx-kit/yarn-plugin-ignore",
factory: function (require) {
"use strict";
var plugin = (() => {
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
}) : x)(function(x) {
if (typeof require !== "undefined") return require.apply(this, arguments);
throw Error('Dynamic require of "' + x + '" is not supported');
});
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/index.ts
var index_exports = {};
__export(index_exports, {
IgnoreFetcher: () => IgnoreFetcher,
IgnoreResolver: () => IgnoreResolver,
default: () => index_default
});

// src/IgnoreFetcher.ts
var import_fslib = __require("@yarnpkg/fslib");
var fs = __toESM(__require("fs"), 1);

// src/constants.ts
var IGNORE_PROTOCOL = "ignore:";
var STUB_MODULE = `module.exports = {};
`;
var STUB_PACKAGE = `{
"name": "@rnx-kit/yarn-plugin-ignore/stub",
"version": "0.0.0",
"description": "Stub package for '@rnx-kit/yarn-plugin-ignore'",
"main": "index.js"
}
`;

// src/IgnoreFetcher.ts
var IgnoreFetcher = class {
supports(locator) {
return locator.reference.startsWith(IGNORE_PROTOCOL);
}
getLocalPath() {
return null;
}
async fetch(_locator, opts) {
const base = opts.project.cwd;
const sourceFs = new import_fslib.CwdFS(base);
const localPath = import_fslib.ppath.resolve(
base,
"node_modules",
".generated",
"@rnx-kit",
"yarn-plugin-ignore-stub"
);
const nativePath = import_fslib.npath.fromPortablePath(localPath);
if (!fs.existsSync(nativePath)) {
fs.mkdirSync(nativePath, { recursive: true, mode: 493 });
fs.writeFileSync(import_fslib.npath.join(nativePath, "package.json"), STUB_PACKAGE);
fs.writeFileSync(import_fslib.npath.join(nativePath, "index.js"), STUB_MODULE);
}
return {
packageFs: new import_fslib.CwdFS(localPath, { baseFs: sourceFs }),
prefixPath: import_fslib.PortablePath.dot,
discardFromLookup: true,
localPath
};
}
};

// src/IgnoreResolver.ts
var import_core = __require("@yarnpkg/core");
var import_node_assert = __require("assert");
var IgnoreResolver = class {
supportsDescriptor(descriptor) {
return descriptor.range.startsWith(IGNORE_PROTOCOL);
}
supportsLocator(locator) {
return locator.reference.startsWith(IGNORE_PROTOCOL);
}
shouldPersistResolution() {
return false;
}
bindDescriptor(descriptor, _fromLocator) {
return descriptor;
}
getResolutionDependencies() {
return {};
}
async getCandidates(descriptor, _dependencies, _opts) {
return [import_core.structUtils.makeLocator(descriptor, IGNORE_PROTOCOL)];
}
async getSatisfying(_descriptor, _dependencies, locators, _opts) {
(0, import_node_assert.equal)(locators.length, 1, "Expected a single locator candidate");
return { locators, sorted: true };
}
async resolve(locator, opts) {
const manifest = new import_core.Manifest();
return {
...locator,
version: "0.0.0",
languageName: opts.project.configuration.get("defaultLanguageName"),
linkType: import_core.LinkType.SOFT,
conditions: null,
dependencies: manifest.dependencies,
peerDependencies: manifest.peerDependencies,
dependenciesMeta: manifest.dependenciesMeta,
peerDependenciesMeta: manifest.peerDependenciesMeta,
bin: manifest.bin
};
}
};

// src/index.ts
var plugin = {
fetchers: [IgnoreFetcher],
resolvers: [IgnoreResolver]
};
var index_default = plugin;
return __toCommonJS(index_exports);
})();
return plugin;
}
};
//# sourceMappingURL=yarn-plugin-ignore.cjs.map
40 changes: 40 additions & 0 deletions incubator/yarn-plugin-ignore/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@rnx-kit/yarn-plugin-ignore",
"version": "0.0.1",
"private": true,
"description": "EXPERIMENTAL - USE WITH CAUTION - yarn-plugin-ignore",
"homepage": "https://github.com/microsoft/rnx-kit/tree/main/incubator/yarn-plugin-ignore#readme",
"license": "MIT",
"author": {
"name": "Microsoft Open Source",
"email": "microsoftopensource@users.noreply.github.com"
},
"repository": {
"type": "git",
"url": "https://github.com/microsoft/rnx-kit",
"directory": "incubator/yarn-plugin-ignore"
},
"files": [
"dist/yarn-plugin-ignore.cjs"
],
"type": "module",
"main": "dist/yarn-plugin-ignore.cjs",
"scripts": {
"build": "rnx-kit-scripts build",
"bundle": "rnx-kit-scripts bundle --platform yarn --sourceMap",
"format": "rnx-kit-scripts format",
"lint": "rnx-kit-scripts lint",
"test": "rnx-kit-scripts test"
},
"devDependencies": {
"@rnx-kit/scripts": "*",
"@rnx-kit/tsconfig": "*",
"@yarnpkg/core": "^4.2.0",
"@yarnpkg/fslib": "^3.1.1"
},
"engines": {
"node": ">=18.12",
"yarn": ">=4.0"
},
"experimental": true
}
45 changes: 45 additions & 0 deletions incubator/yarn-plugin-ignore/src/IgnoreFetcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type {
Fetcher,
FetchOptions,
FetchResult,
Locator,
} from "@yarnpkg/core";
import { CwdFS, npath, PortablePath, ppath } from "@yarnpkg/fslib";
import * as fs from "node:fs";
import { IGNORE_PROTOCOL, STUB_MODULE, STUB_PACKAGE } from "./constants.ts";

export class IgnoreFetcher implements Fetcher {
supports(locator: Locator): boolean {
return locator.reference.startsWith(IGNORE_PROTOCOL);
}

getLocalPath(): PortablePath | null {
return null;
}

async fetch(_locator: Locator, opts: FetchOptions): Promise<FetchResult> {
const base = opts.project.cwd;
const sourceFs = new CwdFS(base);
const localPath = ppath.resolve(
base,
"node_modules",
".generated",
"@rnx-kit",
"yarn-plugin-ignore-stub"
);

const nativePath = npath.fromPortablePath(localPath);
if (!fs.existsSync(nativePath)) {
fs.mkdirSync(nativePath, { recursive: true, mode: 0o755 });
fs.writeFileSync(npath.join(nativePath, "package.json"), STUB_PACKAGE);
fs.writeFileSync(npath.join(nativePath, "index.js"), STUB_MODULE);
}

return {
packageFs: new CwdFS(localPath, { baseFs: sourceFs }),
prefixPath: PortablePath.dot,
discardFromLookup: true,
localPath,
};
}
}
Loading
Loading