From 39d33b4c4a108dbf5d9111697cfed1b8083f0c06 Mon Sep 17 00:00:00 2001 From: Daniel Bayley Date: Mon, 9 Dec 2024 21:59:32 +0000 Subject: [PATCH 1/2] feat: add workspace schema --- static/schema/pnpm-workspace.json | 64 +++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 static/schema/pnpm-workspace.json diff --git a/static/schema/pnpm-workspace.json b/static/schema/pnpm-workspace.json new file mode 100644 index 000000000000..741bdc5e7c0a --- /dev/null +++ b/static/schema/pnpm-workspace.json @@ -0,0 +1,64 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://pnpm.io/schema/pnpm-workspace.json", + "title": "pnpm Workspace Specification", + "description": "JSON schema for pnpm-workspace.yaml files.", + "$comment": "https://pnpm.io/pnpm-workspace_yaml", + "$defs": { + "dependency": { + "$comment": "https://json.schemastore.org/package.json", + "description": "Dependencies are specified with a simple hash of package name to version range.\nThe version range is a string which has one or more space-separated descriptors.\nDependencies can also be identified with a tarball or git URL.\n", + "type": "object", + "minProperties": 1, + "propertyNames": { + "type": "string", + "minLength": 1, + "maxLength": 214, + "pattern": "^(@[a-z0-9-~][a-z0-9-._~]*\\/)?[a-z0-9-~][a-z0-9-._~]*$" + }, + "additionalProperties": { + "type": "string", + "minLength": 1, + "maxLength": 256, + "pattern": "^(\\*|latest|next|(^v?|\\sv?|[~^]|[<>]=?))?(0|[1-9xX*]\\d*)(\\.(0|[1-9xX*]\\d*)(\\.(0|[1-9xX*]\\d*)(-((0|[1-9xX*]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(\\.(0|[1-9xX*]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\\+([0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*))?)?)?$" + } + }, + "catalog": { + "description": "Define dependency version ranges as reusable constants,\nfor later reference in package.json files.\nThis (singular) field creates a catalog named default.\n", + "type": "object", + "minProperties": 1, + "$ref": "#/$defs/dependency" + } + }, + "type": "object", + "additionalProperties": false, + "required": [ + "packages" + ], + "properties": { + "packages": { + "description": "Workspace package paths. Glob patterns are supported.", + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string" + } + }, + "catalog": { + "$comment": "https://pnpm.io/catalogs", + "description": "Define dependency version ranges as reusable constants,\nfor later reference in package.json files.\nThis (singular) field creates a catalog named default.\n", + "type": "object", + "minProperties": 1, + "$ref": "#/$defs/dependency" + }, + "catalogs": { + "description": "Define arbitrarily named catalogs.", + "type": "object", + "minProperties": 1, + "additionalProperties": { + "$ref": "#/$defs/catalog" + } + } + } +} From f2aaf9cb711eab8da7ed80e14735840d3b9a73da Mon Sep 17 00:00:00 2001 From: Daniel Bayley Date: Mon, 9 Dec 2024 22:00:54 +0000 Subject: [PATCH 2/2] docs: add workspace schema --- docs/pnpm-workspace_yaml.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/pnpm-workspace_yaml.md b/docs/pnpm-workspace_yaml.md index 3165cb6aa8aa..6b8b927c8f90 100644 --- a/docs/pnpm-workspace_yaml.md +++ b/docs/pnpm-workspace_yaml.md @@ -42,4 +42,10 @@ catalogs: react-dom: ^17.10.0 ``` +A [_schema_](https://json-schema.org/understanding-json-schema/about) is available for this file: + +```yaml title="$schema" +$schema: https://pnpm.io/schema/pnpm-workspace.json +``` + [workspace]: workspaces.md