Skip to content

Commit 3e76d8f

Browse files
NicholasLYangchris-olszewski
authored andcommitted
Update schema with boundaries
1 parent db57c84 commit 3e76d8f

File tree

3 files changed

+219
-0
lines changed

3 files changed

+219
-0
lines changed

packages/turbo-types/schemas/schema.json

+82
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
"$ref": "#/definitions/EnvMode",
8989
"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",
9090
"default": "strict"
91+
},
92+
"boundaries": {
93+
"$ref": "#/definitions/RootBoundariesConfig",
94+
"description": "Configuration for `turbo boundaries`. Allows users to restrict a package's dependencies and dependents"
9195
}
9296
},
9397
"additionalProperties": false,
@@ -253,6 +257,60 @@
253257
"loose"
254258
]
255259
},
260+
"RootBoundariesConfig": {
261+
"type": "object",
262+
"properties": {
263+
"implicitDependencies": {
264+
"type": "array",
265+
"items": {
266+
"type": "string"
267+
},
268+
"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."
269+
},
270+
"tags": {
271+
"$ref": "#/definitions/BoundariesRulesMap",
272+
"description": "The boundaries rules for tags. Restricts which packages can import a tag and which packages a tag can import"
273+
}
274+
},
275+
"additionalProperties": false
276+
},
277+
"BoundariesRulesMap": {
278+
"type": "object",
279+
"additionalProperties": {
280+
"type": "object",
281+
"properties": {
282+
"dependencies": {
283+
"$ref": "#/definitions/Permissions",
284+
"description": "Rules for a tag's dependencies. Restricts which packages a tag can import"
285+
},
286+
"dependents": {
287+
"$ref": "#/definitions/Permissions",
288+
"description": "Rules for a tag's dependents. Restricts which packages can import this tag."
289+
}
290+
},
291+
"additionalProperties": false
292+
}
293+
},
294+
"Permissions": {
295+
"type": "object",
296+
"properties": {
297+
"allow": {
298+
"type": "array",
299+
"items": {
300+
"type": "string"
301+
},
302+
"description": "Lists which tags are allowed. Any tag not included will be banned If omitted, all tags are permitted"
303+
},
304+
"deny": {
305+
"type": "array",
306+
"items": {
307+
"type": "string"
308+
},
309+
"description": "Lists which tags are banned."
310+
}
311+
},
312+
"additionalProperties": false
313+
},
256314
"WorkspaceSchema": {
257315
"type": "object",
258316
"properties": {
@@ -278,6 +336,17 @@
278336
"default": [
279337
"//"
280338
]
339+
},
340+
"tags": {
341+
"type": "array",
342+
"items": {
343+
"type": "string"
344+
},
345+
"description": "Used to tag a package for boundaries rules. Boundaries rules can restrict which packages a tag group can import or be imported by."
346+
},
347+
"boundaries": {
348+
"$ref": "#/definitions/BoundariesConfig",
349+
"description": "Configuration for `turbo boundaries` that is specific to this package"
281350
}
282351
},
283352
"required": [
@@ -286,6 +355,19 @@
286355
],
287356
"additionalProperties": false,
288357
"description": "A `turbo.json` file in a package in the monorepo (not the root)"
358+
},
359+
"BoundariesConfig": {
360+
"type": "object",
361+
"properties": {
362+
"implicitDependencies": {
363+
"type": "array",
364+
"items": {
365+
"type": "string"
366+
},
367+
"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."
368+
}
369+
},
370+
"additionalProperties": false
289371
}
290372
}
291373
}

packages/turbo-types/schemas/schema.v2.json

+82
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
"$ref": "#/definitions/EnvMode",
8989
"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",
9090
"default": "strict"
91+
},
92+
"boundaries": {
93+
"$ref": "#/definitions/RootBoundariesConfig",
94+
"description": "Configuration for `turbo boundaries`. Allows users to restrict a package's dependencies and dependents"
9195
}
9296
},
9397
"additionalProperties": false,
@@ -253,6 +257,60 @@
253257
"loose"
254258
]
255259
},
260+
"RootBoundariesConfig": {
261+
"type": "object",
262+
"properties": {
263+
"implicitDependencies": {
264+
"type": "array",
265+
"items": {
266+
"type": "string"
267+
},
268+
"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."
269+
},
270+
"tags": {
271+
"$ref": "#/definitions/BoundariesRulesMap",
272+
"description": "The boundaries rules for tags. Restricts which packages can import a tag and which packages a tag can import"
273+
}
274+
},
275+
"additionalProperties": false
276+
},
277+
"BoundariesRulesMap": {
278+
"type": "object",
279+
"additionalProperties": {
280+
"type": "object",
281+
"properties": {
282+
"dependencies": {
283+
"$ref": "#/definitions/Permissions",
284+
"description": "Rules for a tag's dependencies. Restricts which packages a tag can import"
285+
},
286+
"dependents": {
287+
"$ref": "#/definitions/Permissions",
288+
"description": "Rules for a tag's dependents. Restricts which packages can import this tag."
289+
}
290+
},
291+
"additionalProperties": false
292+
}
293+
},
294+
"Permissions": {
295+
"type": "object",
296+
"properties": {
297+
"allow": {
298+
"type": "array",
299+
"items": {
300+
"type": "string"
301+
},
302+
"description": "Lists which tags are allowed. Any tag not included will be banned If omitted, all tags are permitted"
303+
},
304+
"deny": {
305+
"type": "array",
306+
"items": {
307+
"type": "string"
308+
},
309+
"description": "Lists which tags are banned."
310+
}
311+
},
312+
"additionalProperties": false
313+
},
256314
"WorkspaceSchema": {
257315
"type": "object",
258316
"properties": {
@@ -278,6 +336,17 @@
278336
"default": [
279337
"//"
280338
]
339+
},
340+
"tags": {
341+
"type": "array",
342+
"items": {
343+
"type": "string"
344+
},
345+
"description": "Used to tag a package for boundaries rules. Boundaries rules can restrict which packages a tag group can import or be imported by."
346+
},
347+
"boundaries": {
348+
"$ref": "#/definitions/BoundariesConfig",
349+
"description": "Configuration for `turbo boundaries` that is specific to this package"
281350
}
282351
},
283352
"required": [
@@ -286,6 +355,19 @@
286355
],
287356
"additionalProperties": false,
288357
"description": "A `turbo.json` file in a package in the monorepo (not the root)"
358+
},
359+
"BoundariesConfig": {
360+
"type": "object",
361+
"properties": {
362+
"implicitDependencies": {
363+
"type": "array",
364+
"items": {
365+
"type": "string"
366+
},
367+
"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."
368+
}
369+
},
370+
"additionalProperties": false
289371
}
290372
}
291373
}

packages/turbo-types/src/types/config-v2.ts

+55
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ export interface WorkspaceSchema extends BaseSchema {
5252
* @defaultValue `["//"]`
5353
*/
5454
extends: Array<string>;
55+
/**
56+
* Used to tag a package for boundaries rules. Boundaries rules can restrict
57+
* which packages a tag group can import or be imported by.
58+
*/
59+
tags?: Array<string>;
60+
/**
61+
* Configuration for `turbo boundaries` that is specific to this package
62+
*/
63+
boundaries?: BoundariesConfig;
5564
}
5665

5766
export interface RootSchema extends BaseSchema {
@@ -155,6 +164,11 @@ export interface RootSchema extends BaseSchema {
155164
* @defaultValue `"strict"`
156165
*/
157166
envMode?: EnvMode;
167+
168+
/**
169+
* Configuration for `turbo boundaries`. Allows users to restrict a package's dependencies and dependents
170+
*/
171+
boundaries?: RootBoundariesConfig;
158172
}
159173

160174
export interface Pipeline {
@@ -372,6 +386,47 @@ export interface RemoteCache {
372386
teamSlug?: string;
373387
}
374388

389+
export interface Permissions {
390+
/**
391+
* Lists which tags are allowed. Any tag not included will be banned
392+
* If omitted, all tags are permitted
393+
*/
394+
allow?: Array<string>;
395+
/**
396+
* Lists which tags are banned.
397+
*/
398+
deny?: Array<string>;
399+
}
400+
401+
interface TagRules {
402+
/**
403+
* Rules for a tag's dependencies. Restricts which packages a tag can import
404+
*/
405+
dependencies?: Permissions;
406+
/**
407+
* Rules for a tag's dependents. Restricts which packages can import this tag.
408+
*/
409+
dependents?: Permissions;
410+
}
411+
412+
export type BoundariesRulesMap = Record<string, TagRules>;
413+
414+
export interface BoundariesConfig {
415+
/**
416+
* Declares any implicit dependencies, i.e. any dependency not declared in a package.json.
417+
* These can include dependencies automatically injected by a framework or a testing library.
418+
*/
419+
implicitDependencies?: Array<string>;
420+
}
421+
422+
export interface RootBoundariesConfig extends BoundariesConfig {
423+
/**
424+
* The boundaries rules for tags. Restricts which packages
425+
* can import a tag and which packages a tag can import
426+
*/
427+
tags?: BoundariesRulesMap;
428+
}
429+
375430
export const isRootSchemaV2 = (schema: Schema): schema is RootSchema =>
376431
!("extends" in schema);
377432

0 commit comments

Comments
 (0)