Create App
The `scaffold` command is the fastest way to create new apps, doctypes, and actions in your Zodula project. It provides an interactive CLI that guides you through the setup process.
Quick Start
nailgun scaffoldThis 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
Scaffold App
Create a new application with the following command:
nailgun scaffold appOr simply run nailgun scaffold and select "App" from the menu.
Interactive Setup
The scaffold command will prompt you for:
- App name - Must start with lowercase letter and contain only lowercase letters, numbers, hyphens, and underscores
- App description - Optional description of your application
Generated Structure
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/Example
$ nailgun scaffold app
? App name: my-awesome-app
? App description: A sample application
✓ App my-awesome-app created successfully!
Next steps:
1. cd apps/my-awesome-app
2. Run 'nailgun prepare' to generate types
3. Run 'nailgun dev' to start developmentScaffold Doctype
Create a new document type within an existing app:
nailgun scaffold doctypeInteractive Setup
The scaffold command will prompt you for:
- 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
Generated Doctype
The scaffold creates a basic doctype with a name field:
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"
})Scaffold Action
Create a new API action within an existing app:
nailgun scaffold actionInteractive Setup
The scaffold command will prompt you for:
- 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")
Generated Action
The scaffold creates a basic 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()
})
}
});Next Steps
After scaffolding:
- For Apps: Navigate to your app directory and run
nailgun prepareto generate types - For Doctypes: Add fields to your doctype and run
nailgun generateto create migrations - 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
Zodula