Skip to main content

tasks

Type: array
Required: No

A list of tasks to perform when the scaffold is run. Each task represents an action and is run in the order they are defined in the list.

The type property defines which action to run. There are two types of actions: built-in actions and custom actions.

Usage

{
tasks: [
{
type: 'custom',
handler: async (data) => {
console.log('Running custom logic')
}
}
]
}

Properties

Each action has their own set of properties, but there are a few properties that are common to all actions.

For a list of actions and their properties, see Scaffold Actions.

NameDescriptionDefaultRequired
typeThe type of action to runYes
titleThe title of the taskNo
descriptionA description of the taskNo
successMessageA message to display when the task is successfulNo
failureMessageA message to display when the task failsNo
silentWhether to suppress output from the taskfalseNo
sourceThe relative source pathNo
targetThe relative target pathNo
sourceBaseThe base source path (overrides scaffold's scaffoldDir)No
targetBaseThe base target path (overrides scaffold's cwd)No

type

Type: string

The type of action to run. This can be a built-in action or a custom action.

title

Type: string

The title of the task. This is used in the output to describe the task.

description

Type: string

A description of the task. This is currently not used, but may be used in the future.

successMessage

Type: string

A message to display when the task is successful. This is used in the output to indicate that the task was successful.

failureMessage

Type: string

A message to display when the task fails. This is used in the output to indicate that the task failed.

silent

Type: boolean Default: false

Whether to suppress output from the task. If true, the task will not output anything to the console unless it fails.

source

Type: string

The relative source path. This is used in actions that reference a source file or directory.

target

Type: string

The relative target path. This is used in actions that reference a target file or directory.

sourceBase

Type: string

The base source path. This overrides the scaffold's scaffoldDir property and is used in actions that reference a source file or directory.

targetBase

Type: string

The base target path. This overrides the scaffold's cwd property and is used in actions that reference a target file or directory.

Task Groups

Tasks can also be run in groups. This is useful when you want to group related tasks together.

{
tasks: [
{
title: 'Group 1',
tasks: [
{
type: 'custom',
handler: async (data) => {
console.log('Running task 1')
}
},
{
type: 'custom',
handler: async (data) => {
console.log('Running task 2')
}
}
]
}
]
}

Task Group Properties

NameDescriptionDefaultRequired
titleThe title of the task groupNo
tasksThe list of tasks to runYes
concurrentWhether to run the task concurrentlyfalseNo
silentWhether to suppress output from all subtasksfalseNo
collapseSubtasksWhether to collapse subtasks in the output after completionfalseNo
title

Type: string

The title of the task group. This is used in the output to describe the task group.

tasks

Type: array

The list of tasks to run. Each task is an object with its own set of properties.

concurrent

Type: boolean Default: false

Whether to run the task concurrently. If true, the tasks will run concurrently.

silent

Type: boolean Default: false

Whether to suppress output from all subtasks. If true, the subtasks will not output anything to the console unless they fail.

collapseSubtasks

Type: boolean Default: false

Whether to collapse subtasks in the output after completion. If true, the subtasks will be hidden in the output after they complete.

Built-in Actions

Built-in actions are actions that are provided by Panda. They are defined in the @pandajs/scaffold package and are available to all scaffolds.

For a list of built-in actions, see Scaffold Actions.

Custom Actions

Custom actions are actions that are defined by the scaffold author. They are defined in the actionTypes property of the scaffold.

Examples

Basic Task

import { Scaffold } from '@panda/scaffold'

new Scaffold({
tasks: [
{
type: 'custom',
handler: async (data) => {
console.log('Running custom logic')
}
}
]
})

Task with Source and Target

import { Scaffold } from '@panda/scaffold'

new Scaffold({
tasks: [
{
type: 'file:copy',
source: 'path/to/source',
target: 'path/to/target'
}
]
})

Task Group

import { Scaffold } from '@panda/scaffold'

new Scaffold({
tasks: [
{
title: 'Group 1',
tasks: [
{
type: 'custom',
handler: async (data) => {
console.log('Running task 1')
}
},
{
type: 'custom',
handler: async (data) => {
console.log('Running task 2')
}
}
]
}
]
})

Concurrency

import { Scaffold } from '@panda/scaffold'

new Scaffold({
concurrent: true,
tasks: [
{
type: 'custom',
handler: async (data) => {
// Custom logic
}
},
{
type: 'custom',
handler: async (data) => {
// Custom logic
}
}
]
})

Task Group Concurrency

import { Scaffold } from '@panda/scaffold'

new Scaffold({
tasks: [
{
title: 'Group 1',
concurrent: true,
tasks: [
{
type: 'custom',
handler: async (data) => {
console.log('Running task 1')
}
},
{
type: 'custom',
handler: async (data) => {
console.log('Running task 2')
}
}
]
}
]
})

Silent Task

import { Scaffold } from '@panda/scaffold'

new Scaffold({
tasks: [
{
type: 'custom',
handler: async (data) => {
console.log('Running custom logic')
},
silent: true
}
]
})