这是indexloc提供的服务,不要输入任何密码
Skip to content

Add schema.json to have a better IDE intellisense #634

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

Merged
merged 15 commits into from
Feb 9, 2022
Merged
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
4 changes: 3 additions & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dev": "next",
"start": "next start",
"build": "next build",
"lint": "next lint"
"lint": "next lint",
"schema": "ts-json-schema-generator -p ./schema.d.ts -o ./public/schema.json -t Schema"
},
"author": "Jared Palmer",
"license": "MPL-2.0",
Expand Down Expand Up @@ -65,6 +66,7 @@
"eslint-config-prettier": "^8.3.0",
"postcss": "^8.3.5",
"tailwindcss": "^3.0.15",
"ts-json-schema-generator": "^0.97.0",
"typescript": "^4.5.5",
"webpack": "^5.65.0"
},
Expand Down
3 changes: 3 additions & 0 deletions docs/pages/docs/features/caching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ To override the default cache output behavior, pass an array of globs to a [`pip

```jsonc
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
"outputs": ["dist/**", ".next/**"],
Expand Down Expand Up @@ -63,6 +64,7 @@ You can also always disable caching on a specific task by setting `cache` to `fa

```json
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"dev": {
"cache": false
Expand All @@ -84,6 +86,7 @@ Luckily, you can control `turbo`'s cache fingerprinting (a.k.a. hashing) behavio

```jsonc
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
"dependsOn": {
Expand Down
44 changes: 23 additions & 21 deletions docs/pages/docs/features/pipelines.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ An example Pipeline configuration in `turbo.json`:

```json
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
"dependsOn": ["^build"]
Expand Down Expand Up @@ -66,6 +67,7 @@ What you are declaring here in the `pipeline` object of the `turbo` configuratio

```json
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
// A package's `build` task depends on that package's
Expand Down Expand Up @@ -100,6 +102,7 @@ A common pattern in many TypeScript monorepos is to declare that a package's `bu

```json
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
// "A package's `build` command depends on its dependencies'
Expand All @@ -117,13 +120,13 @@ An empty dependency list (`dependsOn` is either undefined or `[]`) means that a

```json
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
// ... omitted for brevity

// A package's `lint` command has no dependencies and can be run at
// whenever.
"lint": {}
}
// ... omitted for brevity

// A package's `lint` command has no dependencies and can be run at
// whenever.
"lint": {}
}
}
```
Expand All @@ -145,22 +148,21 @@ For these cases, you can express these relationships in your `pipeline` configur

```json
{

"pipeline": {
"build": {
"dependsOn": ["^build"]
},
"test": {
"dependsOn": ["build"]
},
"deploy": {
"dependsOn": ["test"]
},
"frontend#deploy": {
"dependsOn": ["ui#test", "backend#deploy", "backend#health-check"]
}
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
"dependsOn": ["^build"]
},
"test": {
"dependsOn": ["build"]
},
"deploy": {
"dependsOn": ["test"]
},
"frontend#deploy": {
"dependsOn": ["ui#test", "backend#deploy", "backend#health-check"]
}

}
}
```

Expand Down
2 changes: 2 additions & 0 deletions docs/pages/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ If your git repo's base branch is NOT `origin/master` then you need to specify a

```json
{
"$schema": "https://turborepo.org/schema.json",
"baseBranch": "origin/main"
}
```
Expand All @@ -76,6 +77,7 @@ Your pipeline both defines the way in which your NPM `package.json` scripts rela

```json
{
"$schema": "https://turborepo.org/schema.json",
"baseBranch": "origin/main",
"pipeline": {
"build": {
Expand Down
1 change: 1 addition & 0 deletions docs/pages/docs/guides/migrate-from-lerna.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Create a `turbo.json` file in the root of your project.

```json
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
"dependsOn": ["^build"],
Expand Down
1 change: 1 addition & 0 deletions docs/pages/docs/reference/codemods.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ For example:

// After, turbo.json
{
"$schema": "https://turborepo.org/schema.json",
"baseBranch": "origin/main",
"pipeline": {
...
Expand Down
1 change: 1 addition & 0 deletions docs/pages/docs/reference/command-line-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Given this pipeline in `turbo.json`:

```json
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
"dependsOn": [
Expand Down
6 changes: 6 additions & 0 deletions docs/pages/docs/reference/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ This is useful for busting the cache based on `.env` files (not in Git), environ

```json
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
// ... omitted for brevity
},
Expand All @@ -49,6 +50,7 @@ Each key in the `pipeline` object is the name of a task that can be executed by

```json
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
"dependsOn": ["^build"]
Expand Down Expand Up @@ -80,6 +82,7 @@ Prefixing an item in `dependsOn` with a `$` tells `turbo` that this pipeline tas

```json
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
// "A package's `build` command depends on its dependencies'
Expand All @@ -106,6 +109,7 @@ Prefixing an item in `dependsOn` with a `$` tells `turbo` that this pipeline tas

```json
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
"dependsOn": {
Expand Down Expand Up @@ -143,6 +147,7 @@ Passing an empty array can be used to tell `turbo` that a task is a side-effect

```json
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
// "Cache all files emitted to package's dist/** or .next
Expand Down Expand Up @@ -180,6 +185,7 @@ Defaults to `true`. Whether or not to cache the task [`outputs`](#outputs-1). Se

```json
{
"$schema": "https://turborepo.org/schema.json",
"pipeline": {
"build": {
"dependsOn": ["^build"]
Expand Down
71 changes: 71 additions & 0 deletions docs/public/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"$ref": "#/definitions/Schema",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"Pipeline": {
"additionalProperties": false,
"properties": {
"cache": {
"default": true,
"description": "Whether or not to cache the task outputs. Setting cache to false is useful for daemon or long-running \"watch\" or development mode tasks that you don't want to cache.",
"type": "boolean"
},
"dependsOn": {
"default": [],
"description": "The list of tasks and environment variables that this task depends on.\n\nPrefixing an item in dependsOn with a ^ tells turbo that this pipeline task depends on the package's topological dependencies completing the task with the ^ prefix first (e.g. \"a package's build tasks should only run once all of its dependencies and devDependencies have completed their own build commands\").\n\nItems in dependsOn without ^ prefix, express the relationships between tasks at the package level (e.g. \"a package's test and lint commands depend on build being completed first\").\n\nPrefixing an item in dependsOn with a $ tells turbo that this pipeline task depends the value of that environment variable.",
"items": {
"type": "string"
},
"type": "array"
},
"outputs": {
"default": [
"dist/**",
"build/**"
],
"description": "The set of glob patterns of a task's cacheable filesystem outputs.\n\nNote: turbo automatically logs stderr/stdout to .turbo/run-<task>.log. This file is always treated as a cacheable artifact and never needs to be specified.\n\nPassing an empty array can be used to tell turbo that a task is a side-effect and thus doesn't emit any filesystem artifacts (e.g. like a linter), but you still want to cache its logs (and treat them like an artifact).",
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"Schema": {
"additionalProperties": false,
"properties": {
"$schema": {
"default": "https://turborepo.org/schema.json",
"type": "string"
},
"baseBranch": {
"default": "origin/master",
"description": "The base branch or your git repository. Git is used by turbo in its hashing algorithm and --since CLI flag.",
"type": "string"
},
"globalDependencies": {
"default": [],
"description": "A list of globs and environment variables for implicit global hash dependencies. Environment variables should be prefixed with $ (e.g. $GITHUB_TOKEN).\n\nAny other entry without this prefix, will be considered filesystem glob. The contents of these files will be included in the global hashing algorithm and affect the hashes of all tasks.\n\nThis is useful for busting the cache based on .env files (not in Git), environment variables, or any root level file that impacts package tasks (but are not represented in the traditional dependency graph\n\n(e.g. a root tsconfig.json, jest.config.js, .eslintrc, etc.)).",
"items": {
"type": "string"
},
"type": "array"
},
"pipeline": {
"additionalProperties": {
"$ref": "#/definitions/Pipeline",
"description": "The name of a task that can be executed by turbo run. If turbo finds a workspace package with a package.json scripts object with a matching key, it will apply the pipeline task configuration to that NPM script during execution. This allows you to use pipeline to set conventions across your entire Turborepo."
},
"default": {},
"description": "An object representing the task dependency graph of your project. turbo interprets these conventions to properly schedule, execute, and cache the outputs of tasks in your project.",
"type": "object"
}
},
"required": [
"pipeline"
],
"type": "object"
}
}
}
92 changes: 92 additions & 0 deletions docs/schema.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* This file generates the `schema.json` file. */

export interface Schema {
/** @default https://turborepo.org/schema.json */
$schema?: string;

/**
* The base branch or your git repository. Git is used by turbo in its hashing algorithm
* and --since CLI flag.
*
* @default origin/master
*/
baseBranch?: string;

/**
* A list of globs and environment variables for implicit global hash dependencies.
* Environment variables should be prefixed with $ (e.g. $GITHUB_TOKEN).
*
* Any other entry without this prefix, will be considered filesystem glob. The
* contents of these files will be included in the global hashing algorithm and affect
* the hashes of all tasks.
*
* This is useful for busting the cache based on .env files (not in Git), environment
* variables, or any root level file that impacts package tasks (but are not represented
* in the traditional dependency graph
*
* (e.g. a root tsconfig.json, jest.config.js, .eslintrc, etc.)).
*
* @default []
*/
globalDependencies?: string[];

/**
* An object representing the task dependency graph of your project. turbo interprets
* these conventions to properly schedule, execute, and cache the outputs of tasks in
* your project.
*
* @default {}
*/
pipeline: {
/**
* The name of a task that can be executed by turbo run. If turbo finds a workspace
* package with a package.json scripts object with a matching key, it will apply the
* pipeline task configuration to that NPM script during execution. This allows you to
* use pipeline to set conventions across your entire Turborepo.
*/
[script: string]: Pipeline;
};
}

export interface Pipeline {
/**
* The list of tasks and environment variables that this task depends on.
*
* Prefixing an item in dependsOn with a ^ tells turbo that this pipeline task depends
* on the package's topological dependencies completing the task with the ^ prefix first
* (e.g. "a package's build tasks should only run once all of its dependencies and
* devDependencies have completed their own build commands").
*
* Items in dependsOn without ^ prefix, express the relationships between tasks at the
* package level (e.g. "a package's test and lint commands depend on build being
* completed first").
*
* Prefixing an item in dependsOn with a $ tells turbo that this pipeline task depends
* the value of that environment variable.
*
* @default []
*/
dependsOn?: string[];

/**
* The set of glob patterns of a task's cacheable filesystem outputs.
*
* Note: turbo automatically logs stderr/stdout to .turbo/run-<task>.log. This file is
* always treated as a cacheable artifact and never needs to be specified.
*
* Passing an empty array can be used to tell turbo that a task is a side-effect and
* thus doesn't emit any filesystem artifacts (e.g. like a linter), but you still want
* to cache its logs (and treat them like an artifact).
*
* @default ["dist/**", "build/**"]
*/
outputs?: string[];

/**
* Whether or not to cache the task outputs. Setting cache to false is useful for daemon
* or long-running "watch" or development mode tasks that you don't want to cache.
*
* @default true
*/
cache?: boolean;
}
1 change: 1 addition & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "./docs/public/schema.json",
"baseBranch": "origin/main",
"env": [
"CONVERTKIT_API_KEY",
Expand Down
Loading