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

chore: update schema with boundaries #10118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
82 changes: 82 additions & 0 deletions packages/turbo-types/schemas/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
"$ref": "#/definitions/EnvMode",
"description": "Turborepo's Environment Modes allow you to control which environment variables are available to a task at runtime:\n\n- `\"strict\"`: Filter environment variables to only those that are specified in the `env` and `globalEnv` keys in `turbo.json`.\n- `\"loose\"`: Allow all environment variables for the process to be available.\n\nDocumentation: https://turbo.build/repo/docs/reference/configuration#envmode",
"default": "strict"
},
"boundaries": {
"$ref": "#/definitions/RootBoundariesConfig",
"description": "Configuration for `turbo boundaries`. Allows users to restrict a package's dependencies and dependents"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -253,6 +257,60 @@
"loose"
]
},
"RootBoundariesConfig": {
"type": "object",
"properties": {
"implicitDependencies": {
"type": "array",
"items": {
"type": "string"
},
"description": "Declares any implicit dependencies, i.e. any dependency not declared in a package.json. These can include dependencies automatically injected by a framework or a testing library."
},
"tags": {
"$ref": "#/definitions/BoundariesRulesMap",
"description": "The boundaries rules for tags. Restricts which packages can import a tag and which packages a tag can import"
}
},
"additionalProperties": false
},
"BoundariesRulesMap": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"dependencies": {
"$ref": "#/definitions/Permissions",
"description": "Rules for a tag's dependencies. Restricts which packages a tag can import"
},
"dependents": {
"$ref": "#/definitions/Permissions",
"description": "Rules for a tag's dependents. Restricts which packages can import this tag."
}
},
"additionalProperties": false
}
},
"Permissions": {
"type": "object",
"properties": {
"allow": {
"type": "array",
"items": {
"type": "string"
},
"description": "Lists which tags are allowed. Any tag not included will be banned If omitted, all tags are permitted"
},
"deny": {
"type": "array",
"items": {
"type": "string"
},
"description": "Lists which tags are banned."
}
},
"additionalProperties": false
},
"WorkspaceSchema": {
"type": "object",
"properties": {
Expand All @@ -278,6 +336,17 @@
"default": [
"//"
]
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "Used to tag a package for boundaries rules. Boundaries rules can restrict which packages a tag group can import or be imported by."
},
"boundaries": {
"$ref": "#/definitions/BoundariesConfig",
"description": "Configuration for `turbo boundaries` that is specific to this package"
}
},
"required": [
Expand All @@ -286,6 +355,19 @@
],
"additionalProperties": false,
"description": "A `turbo.json` file in a package in the monorepo (not the root)"
},
"BoundariesConfig": {
"type": "object",
"properties": {
"implicitDependencies": {
"type": "array",
"items": {
"type": "string"
},
"description": "Declares any implicit dependencies, i.e. any dependency not declared in a package.json. These can include dependencies automatically injected by a framework or a testing library."
}
},
"additionalProperties": false
}
}
}
82 changes: 82 additions & 0 deletions packages/turbo-types/schemas/schema.v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
"$ref": "#/definitions/EnvMode",
"description": "Turborepo's Environment Modes allow you to control which environment variables are available to a task at runtime:\n\n- `\"strict\"`: Filter environment variables to only those that are specified in the `env` and `globalEnv` keys in `turbo.json`.\n- `\"loose\"`: Allow all environment variables for the process to be available.\n\nDocumentation: https://turbo.build/repo/docs/reference/configuration#envmode",
"default": "strict"
},
"boundaries": {
"$ref": "#/definitions/RootBoundariesConfig",
"description": "Configuration for `turbo boundaries`. Allows users to restrict a package's dependencies and dependents"
}
},
"additionalProperties": false,
Expand Down Expand Up @@ -253,6 +257,60 @@
"loose"
]
},
"RootBoundariesConfig": {
"type": "object",
"properties": {
"implicitDependencies": {
"type": "array",
"items": {
"type": "string"
},
"description": "Declares any implicit dependencies, i.e. any dependency not declared in a package.json. These can include dependencies automatically injected by a framework or a testing library."
},
"tags": {
"$ref": "#/definitions/BoundariesRulesMap",
"description": "The boundaries rules for tags. Restricts which packages can import a tag and which packages a tag can import"
}
},
"additionalProperties": false
},
"BoundariesRulesMap": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"dependencies": {
"$ref": "#/definitions/Permissions",
"description": "Rules for a tag's dependencies. Restricts which packages a tag can import"
},
"dependents": {
"$ref": "#/definitions/Permissions",
"description": "Rules for a tag's dependents. Restricts which packages can import this tag."
}
},
"additionalProperties": false
}
},
"Permissions": {
"type": "object",
"properties": {
"allow": {
"type": "array",
"items": {
"type": "string"
},
"description": "Lists which tags are allowed. Any tag not included will be banned If omitted, all tags are permitted"
},
"deny": {
"type": "array",
"items": {
"type": "string"
},
"description": "Lists which tags are banned."
}
},
"additionalProperties": false
},
"WorkspaceSchema": {
"type": "object",
"properties": {
Expand All @@ -278,6 +336,17 @@
"default": [
"//"
]
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "Used to tag a package for boundaries rules. Boundaries rules can restrict which packages a tag group can import or be imported by."
},
"boundaries": {
"$ref": "#/definitions/BoundariesConfig",
"description": "Configuration for `turbo boundaries` that is specific to this package"
}
},
"required": [
Expand All @@ -286,6 +355,19 @@
],
"additionalProperties": false,
"description": "A `turbo.json` file in a package in the monorepo (not the root)"
},
"BoundariesConfig": {
"type": "object",
"properties": {
"implicitDependencies": {
"type": "array",
"items": {
"type": "string"
},
"description": "Declares any implicit dependencies, i.e. any dependency not declared in a package.json. These can include dependencies automatically injected by a framework or a testing library."
}
},
"additionalProperties": false
}
}
}
55 changes: 55 additions & 0 deletions packages/turbo-types/src/types/config-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ export interface WorkspaceSchema extends BaseSchema {
* @defaultValue `["//"]`
*/
extends: Array<string>;
/**
* Used to tag a package for boundaries rules. Boundaries rules can restrict
* which packages a tag group can import or be imported by.
*/
tags?: Array<string>;
/**
* Configuration for `turbo boundaries` that is specific to this package
*/
boundaries?: BoundariesConfig;
}

export interface RootSchema extends BaseSchema {
Expand Down Expand Up @@ -155,6 +164,11 @@ export interface RootSchema extends BaseSchema {
* @defaultValue `"strict"`
*/
envMode?: EnvMode;

/**
* Configuration for `turbo boundaries`. Allows users to restrict a package's dependencies and dependents
*/
boundaries?: RootBoundariesConfig;
}

export interface Pipeline {
Expand Down Expand Up @@ -372,6 +386,47 @@ export interface RemoteCache {
teamSlug?: string;
}

export interface Permissions {
/**
* Lists which tags are allowed. Any tag not included will be banned
* If omitted, all tags are permitted
*/
allow?: Array<string>;
/**
* Lists which tags are banned.
*/
deny?: Array<string>;
}

interface TagRules {
/**
* Rules for a tag's dependencies. Restricts which packages a tag can import
*/
dependencies?: Permissions;
/**
* Rules for a tag's dependents. Restricts which packages can import this tag.
*/
dependents?: Permissions;
}

export type BoundariesRulesMap = Record<string, TagRules>;

export interface BoundariesConfig {
/**
* Declares any implicit dependencies, i.e. any dependency not declared in a package.json.
* These can include dependencies automatically injected by a framework or a testing library.
*/
implicitDependencies?: Array<string>;
}

export interface RootBoundariesConfig extends BoundariesConfig {
/**
* The boundaries rules for tags. Restricts which packages
* can import a tag and which packages a tag can import
*/
tags?: BoundariesRulesMap;
}

export const isRootSchemaV2 = (schema: Schema): schema is RootSchema =>
!("extends" in schema);

Expand Down
Loading