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

Monorepo plugin #630

Open
wants to merge 12 commits into
base: roots-manuva
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
7 changes: 6 additions & 1 deletion core/cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@
},
{
"path": "../../lib/state"
},
{
"path": "../../lib/base"
}
],
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
},
"include": ["src/**/*"]
"include": [
"src/**/*"
]
}
4 changes: 3 additions & 1 deletion lib/schemas/src/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { SmokeTestSchema } from './tasks/n-test'
import { CypressSchema } from './tasks/cypress'
import { HerokuProductionSchema } from './tasks/heroku-production'
import { ServerlessRunSchema } from './tasks/serverless-run'
import { WorkspaceCommandSchema } from './tasks/workspace-command'
import { z } from 'zod'

export const TaskSchemas = {
Expand All @@ -39,7 +40,8 @@ export const TaskSchemas = {
ServerlessTeardown: z.object({}).describe('Tear down existing serverless functions'),
TypeScript: TypeScriptSchema,
UploadAssetsToS3: UploadAssetsToS3Schema,
Webpack: WebpackSchema
Webpack: WebpackSchema,
WorkspaceCommand: WorkspaceCommandSchema
}

export type TaskOptions = InferSchemaOptions<typeof TaskSchemas>
64 changes: 64 additions & 0 deletions lib/schemas/src/tasks/workspace-command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { z } from 'zod'

export const WorkspaceCommandSchema = z.object({
command: z.string().optional().describe('A specific command to run instead of the command that ran this task.')
}).describe(`Runs a Tool Kit command in all workspace packages that have that command. By default, runs the command that was used to run this task.

For example, imagine a monorepo with these \`.toolkitrc.yml\` files:

<details><summary><code>.toolkitrc.yml</code></summary>

~~~yml
commands:
run:local: WorkspaceCommand
build:local: WorkspaceCommand
~~~

</details>

<details><summary><code>packages/api/.toolkitrc.yml</code></summary>

~~~yml
commands:
run:local: Node
~~~

</details>

<details><summary><code>packages/client/.toolkitrc.yml</code></summary>

~~~yml
commands:
build:local: TypeScript
~~~

</details>

<details><summary><code>packages/components/.toolkitrc.yml</code></summary>

~~~yml
commands:
build:local: Webpack
run:local:
Webpack:
watch: true
~~~

</details>

Running \`dotcom-tool-kit run:local\` at the root level will run the \`Node\` task in \`packages/api\` and the \`Webpack\` task in watch mode in \`packages/components\`; running \`dotcom-tool-kit build:local\` will run \`TypeScript\` in \`packages/client\` and \`Webpack\` in \`packages/components\`.

To run a particular command in the workspace instead of dynamically inferring the command from which was run at root level, set the \`command\` option for the task:

~~~yml
commands:
build:ci:
WorkspaceCommand:
command: build:local
~~~

`)

export type WorkspaceCommandOptions = z.infer<typeof WorkspaceCommandSchema>

export const Schema = WorkspaceCommandSchema
Loading