Skip to main content

Usage

import { Scaffold } from '@panda/scaffold'

new Scaffold({
// required: name
name: 'create-foo',
// used as the command called when it's a subcommand
command: 'foo:create',
// used in help menu
description: 'Create a new Foo',
// application or command version
version: '1.4.7',
// argument handler
// if object, 'name' data key contains a single or multiple values
// if array, data keys are applied as positional arguments
arguments: {
name: 'name'
},
// list of options to parse
options: [],
// list of flags to parse
flags: [],
// list of subcommands
// if array, use the `command` property as the subcommand
// if object, use the key as the subcommand
subcommands: [],
// list of prompts to ask user
prompts: [],
// list of custom prompt types available to `prompts`
promptTypes: {},
// directory where scaffolds are stored
scaffoldDir: 'scaffolds',
// current working directory
cwd: process.cwd(),
// title of the scaffold
title: 'Create a Foo',
// flag to automatically generate and display help menu on --help
autoHelp: true,
// flag to automatically output version on --version
autoVersion: true,
// flag to suppress logging output
silent: false,
// method to transform data before reaching action
transform: async (data) => {
data.type = 'based'
return data
},
action: async (data, details) => {
// perform your actions
},
actions: [
// list of actions to perform
],
actionTypes: {
// list of custom action types available to `actions`
}
})

Properties

To learn more about scaffold properties, see the Properties documentation.

Actions

Scaffolds differ from commands in that, instead of a single action method, they usually contain a list of actions to perform. Actions defined in the actions property of the scaffold are performed in the order they should be executed.

note

By default, the action method already exists and is used to process the actions. You can choose to override this method with your own implementation, but you must call the runActions method (or super.action) to execute the actions.

To learn more about actions available to scaffolds, see the Actions documentation.

To learn more about creating new actions, see the Action documentation.