Skip to content

Commit 7ea0db8

Browse files
committed
chore: add vendored version of @pnpm/find-workspace-dir for use in pnpmfile
Signed-off-by: Logan McAnsh <logan@mcan.sh> (cherry picked from commit b80fe2c) Signed-off-by: Logan McAnsh <logan@mcan.sh>
1 parent 244da77 commit 7ea0db8

File tree

22 files changed

+849
-38
lines changed

22 files changed

+849
-38
lines changed

.pnpmfile.cjs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,39 @@
1-
function readPackage(pkg) {
1+
const path = require("node:path");
2+
const fsp = require("node:fs/promises");
3+
const { findWorkspaceDir } = require("./vendor/@pnpm/find-workspace-dir");
4+
5+
let cache = new Map();
6+
7+
async function getExamples() {
8+
if (cache.size > 0) return cache;
9+
10+
let root = await findWorkspaceDir(process.cwd());
11+
let exampleRoot = path.join(root, "examples");
12+
let exampleContents = await fsp.readdir(exampleRoot, { withFileTypes: true });
13+
let directories = exampleContents
14+
.filter((dirent) => dirent.isDirectory())
15+
.map((dirent) => dirent.name);
16+
17+
for (const file of directories) {
18+
const content = await fsp.readFile(
19+
path.join(exampleRoot, file, "package.json"),
20+
"utf-8",
21+
);
22+
23+
let pkg = JSON.parse(content);
24+
25+
cache.set(pkg.name, pkg);
26+
}
27+
28+
return cache;
29+
}
30+
31+
async function readPackage(pkg) {
32+
// first get the examples from the examples directory and cache them
33+
// this is necessary because we need to use the examples in the package.json
34+
// but we don't want to read the directory every time
35+
let examples = await getExamples();
36+
237
// replace hardcoded version of remix-fastify with workspace:*
338
// this is necessary because we're using pnpm workspaces
439
// and we want to use the local version of remix-fastify

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dev": "pnpm run --filter remix-fastify --filter playground --recursive --parallel dev",
88
"dev:vite": "pnpm run --filter remix-fastify --filter vite-remix --recursive --parallel dev",
99
"build": "pnpm run --recursive build",
10-
"test": "pnpm --filter ./packages/* test",
10+
"test": "pnpm run --recursive test",
1111
"publish": "./scripts/publish.js",
1212
"publint": "publint ./packages/**",
1313
"attw": "attw ./packages/** --pack",
@@ -24,12 +24,15 @@
2424
"@changesets/cli": "^2.27.10",
2525
"@manypkg/get-packages": "^2.2.2",
2626
"@npmcli/package-json": "^6.0.1",
27+
"@pnpm/error": "file:./vendor/@pnpm/error",
28+
"@pnpm/find-workspace-dir": "file:./vendor/@pnpm/find-workspace-dir",
2729
"@remix-run/eslint-config": "2.15.3",
2830
"@total-typescript/tsconfig": "^1.0.4",
2931
"@types/npmcli__package-json": "^4.0.4",
3032
"chalk": "^5.3.0",
3133
"eslint": "^9.15.0",
3234
"eslint-plugin-prefer-let": "^4.0.0",
35+
"find-up": "file:./vendor/find-up",
3336
"glob": "^11.0.0",
3437
"jsonfile": "^6.1.0",
3538
"pkg-pr-new": "^0.0.30",
@@ -44,5 +47,5 @@
4447
"typescript": "^5.7.2",
4548
"vitest": "^3.0.6"
4649
},
47-
"packageManager": "pnpm@10.4.1+sha512.c753b6c3ad7afa13af388fa6d808035a008e30ea9993f58c6663e2bc5ff21679aa834db094987129aa4d488b86df57f7b634981b2f827cdcacc698cc0cfb88af"
50+
"packageManager": "pnpm@10.9.0+sha512.0486e394640d3c1fb3c9d43d49cf92879ff74f8516959c235308f5a8f62e2e19528a65cdc2a3058f587cde71eba3d5b56327c8c33a97e4c4051ca48a10ca2d5f"
4851
}

pnpm-lock.yaml

Lines changed: 51 additions & 33 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
packages:
2-
- "packages/*"
3-
- "examples/*"
2+
- packages/*
3+
- examples/*
4+
5+
onlyBuiltDependencies:
6+
- esbuild
7+
8+
overrides:
9+
find-up: "file:./vendor/find-up"

vendor/@pnpm/error/LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
4+
Copyright (c) 2016-2025 Zoltan Kochan and other contributors
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.

vendor/@pnpm/error/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# @pnpm/error
2+
3+
> An error class for pnpm errors
4+
5+
<!--@shields('npm')-->
6+
[![npm version](https://img.shields.io/npm/v/@pnpm/error.svg)](https://www.npmjs.com/package/@pnpm/error)
7+
<!--/@-->
8+
9+
## Installation
10+
11+
```sh
12+
pnpm add @pnpm/error
13+
```
14+
15+
### Usage
16+
17+
```ts
18+
import { PnpmError } from '@pnpm/error'
19+
20+
try {
21+
throw new PnpmError('THE_ERROR_CODE', 'The error message')
22+
} catch (err: any) { // eslint-disable-line
23+
console.log(err.code)
24+
//> ERR_PNPM_THE_ERROR_CODE
25+
console.log(err.message)
26+
//> The error message
27+
}
28+
```
29+
30+
## License
31+
32+
MIT

vendor/@pnpm/error/lib/index.d.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export declare class PnpmError extends Error {
2+
readonly code: string;
3+
readonly hint?: string;
4+
attempts?: number;
5+
prefix?: string;
6+
pkgsStack?: Array<{
7+
id: string;
8+
name: string;
9+
version: string;
10+
}>;
11+
constructor(code: string, message: string, opts?: {
12+
attempts?: number;
13+
hint?: string;
14+
});
15+
}
16+
export interface FetchErrorResponse {
17+
status: number;
18+
statusText: string;
19+
}
20+
export interface FetchErrorRequest {
21+
url: string;
22+
authHeaderValue?: string;
23+
}
24+
export declare class FetchError extends PnpmError {
25+
readonly response: FetchErrorResponse;
26+
readonly request: FetchErrorRequest;
27+
constructor(request: FetchErrorRequest, response: FetchErrorResponse, hint?: string);
28+
}
29+
export declare class LockfileMissingDependencyError extends PnpmError {
30+
constructor(depPath: string);
31+
}

0 commit comments

Comments
 (0)