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 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" + } + } + } +}