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

Add --tasks flag to wpdev CLI bundle command #104

Merged
merged 4 commits into from
Feb 19, 2024
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
5 changes: 5 additions & 0 deletions .changeset/thirty-bananas-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wpsocio/wpdev": patch
---

Added `--tasks` flag to wpdev CLI bundle command
1 change: 0 additions & 1 deletion tools/wpdev/src/base-commands/WithConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export abstract class WithConfig extends Command {
'project-types': Flags.option({
description:
'Project types managed in the monorepo. Only used in wp-monorepo mode.',
char: 't',
options: ['plugins', 'themes'] as const,
multiple: true,
})(),
Expand Down
16 changes: 15 additions & 1 deletion tools/wpdev/src/commands/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export default class Bundle extends WithProjects<typeof Bundle> {
description: 'Version to update to.',
exclusive: ['release-type'],
}),
tasks: Flags.string({
description: 'Run only the specified tasks. Comma-separated list.',
}),
'release-type': Flags.string({
char: 't',
description: 'Release type to update to.',
Expand Down Expand Up @@ -161,8 +164,19 @@ export default class Bundle extends WithProjects<typeof Bundle> {

const projectDir = project.dir;

const tasksToRun = this.flags.tasks?.split(',') || [];

const taskList = tasksToRun.length
? bundle.tasks.filter((tsk) => tasksToRun.includes(tsk.type))
: bundle.tasks;

if (!taskList.length) {
task.skip('No tasks to run. Skipping.');
return;
}

return task.newListr(
bundle.tasks.map(({ type: taskType, data: taskData }) => {
taskList.map(({ type: taskType, data: taskData }) => {
switch (taskType) {
case 'run-scripts':
return {
Expand Down
Loading