ZodulaZodula
Cli

Scaffold

Scaffold

scaffold

Scaffold new app, doctype, or action with interactive prompts.

Usage

nailgun scaffold [type]

Arguments

  • [type] - Type of scaffold: app, doctype, or action

If no type is provided, you'll be prompted to choose from the available options.

Options

None

Examples

Interactive Mode

nailgun scaffold

This will prompt you to choose what you'd like to scaffold:

  • App - Create a new application
  • Doctype - Create a new document type
  • Action - Create a new API action

Direct Mode

# Scaffold a new app
nailgun scaffold app

# Scaffold a new doctype
nailgun scaffold doctype

# Scaffold a new action
nailgun scaffold action

What Gets Created

App Scaffolding

When you scaffold an app, the following structure is created:

apps/your-app-name/
├── package.json
├── index.ts
├── src/
│   └── server/
│       └── index.ts
├── doctype/
│   └── core/
├── actions/
├── migrations/
└── fixtures/

Doctype Scaffolding

Creates a new doctype file with a basic structure:

export default $doctype<"app__DoctypeName">({
    name: {
        type: "Text",
        label: "Name",
        required: 1,
        unique: 1,
        in_list_view: 1
    },
    // Add more fields as needed
}, {
    label: "Doctype Name",
    is_submittable: 0,
    search_fields: "name"
})

Action Scaffolding

Creates a new action with request/response schemas:

import { z } from "zodula";

export const action_name = $action(async ctx => {
    // TODO: Implement action_name logic
    return ctx.json({
        message: "action_name action executed"
    });
}, {
    // TODO: Add request/response schemas
    response: {
        200: z.object({
            message: z.string()
        })
    }
});

Interactive Prompts

App Prompts

  • App name: Must start with lowercase letter and contain only lowercase letters, numbers, hyphens, and underscores
  • App description: Optional description of your application

Doctype Prompts

  • Select app: Choose from existing apps
  • Doctype name: Must start with uppercase letter (e.g., Customer, Product)
  • Domain: Folder name (default: "core")
  • Label: Display name (defaults to doctype name)
  • Is submittable: Whether this doctype can be submitted

Action Prompts

  • Select app: Choose from existing apps
  • Action name: Must start with lowercase letter (e.g., create_user, get_products)
  • Module name: Grouping for actions (default: "core")

Next Steps

After scaffolding:

  1. For Apps: Navigate to your app directory and run nailgun prepare to generate types
  2. For Doctypes: Add fields to your doctype and run nailgun generate to create migrations
  3. For Actions: Implement your action logic and test via API

Tips

  • Use descriptive names for your apps, doctypes, and actions
  • Follow the naming conventions (lowercase for apps/actions, PascalCase for doctypes)
  • Start with simple structures and add complexity as needed
  • Use the generated code as a starting point and customize as required