Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement catalog protocol reads (feature flagged) #8020

Closed
wants to merge 10 commits into from
5 changes: 5 additions & 0 deletions catalogs/types/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @pnpm/catalogs.types

## 0.1.0

Initial release
3 changes: 3 additions & 0 deletions catalogs/types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @pnpm/catalogs.types

> Types related to the pnpm catalogs feature.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating a new @pnpm/catalogs.types package, we could also stuff the small definitions here into the existing @pnpm/types package. I opted for a new package for now since we're doing something similar for hooks: @pnpm/hooks.types.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'll separate the new packages out to a different PR so you don't have to keep looking at these changes when re-reviewing this PR.

38 changes: 38 additions & 0 deletions catalogs/types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@pnpm/catalogs.types",
"version": "0.1.0",
"description": "Types related to the pnpm catalogs feature.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"engines": {
"node": ">=18.12"
},
"files": [
"lib",
"!*.map"
],
"repository": "https://github.com/pnpm/pnpm/blob/main/catalogs/types",
"keywords": [
"pnpm9",
"pnpm",
"types"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/pnpm/pnpm/issues"
},
"homepage": "https://github.com/pnpm/pnpm/blob/main/catalogs/types#readme",
"scripts": {
"lint": "eslint \"src/**/*.ts\"",
"compile": "tsc --build && pnpm run lint --fix",
"prepublishOnly": "pnpm run compile",
"test": "pnpm run compile"
},
"funding": "https://opencollective.com/pnpm",
"exports": {
".": "./lib/index.js"
},
"devDependencies": {
"@pnpm/catalogs.types": "workspace:*"
}
}
29 changes: 29 additions & 0 deletions catalogs/types/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Catalogs parsed from the pnpm-workspace.yaml file.
*
* https://github.com/pnpm/rfcs/pull/1
*/
export interface Catalogs {
/**
* The default catalog.
*
* The default catalog can be defined in 2 ways.
*
* 1. Users can specify a top-level "catalog" field or,
* 2. An explicitly named "default" catalog under the "catalogs" map.
*
* This field contains either definition. Note that it's an error to define
* the default catalog using both options. The parser will fail when reading
* the workspace manifest.
*/
readonly default?: Catalog

/**
* Named catalogs.
*/
readonly [catalogName: string]: Catalog | undefined
}

export interface Catalog {
readonly [dependencyName: string]: string | undefined
}
13 changes: 13 additions & 0 deletions catalogs/types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "@pnpm/tsconfig",
"composite": true,
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": [
"src/**/*.ts",
"../../__typings__/**/*.d.ts"
],
"references": []
}
8 changes: 8 additions & 0 deletions catalogs/types/tsconfig.lint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.json",
"include": [
"src/**/*.ts",
"test/**/*.ts",
"../../__typings__/**/*.d.ts"
]
}
6 changes: 6 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.