dhis2_init_webapp
Set up a new DHIS2 web application project with structured scaffolding by specifying app name, title, template, and optional features like TypeScript or PWA support.
Instructions
Initialize a new DHIS2 web application project with proper scaffolding
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appDescription | No | Description of the application | |
| appName | Yes | Name of the application (e.g., "my-health-app") | |
| appTitle | Yes | Human-readable title of the application | |
| appType | No | Type of DHIS2 application | |
| namespace | No | App namespace (defaults to appName if not provided) | |
| outputPath | No | Directory path where to create the app (default: current directory) | |
| pwa | No | Enable Progressive Web App features | |
| template | No | App template to use | |
| typescript | No | Use TypeScript (default: true) |
Implementation Reference
- src/index.ts:961-972 (handler)Handler for dhis2_init_webapp tool: destructures input parameters and calls generateWebAppInitInstructions to produce a markdown guide for initializing a DHIS2 web application.case 'dhis2_init_webapp': const { appName, appTitle, appDescription, namespace, appType, template, typescript, pwa, outputPath } = args as any; const initInstructions = generateWebAppInitInstructions(appName, appTitle, appDescription, { namespace, appType, template, typescript, pwa, outputPath }); return { content: [ { type: 'text', text: initInstructions, }, ], };
- src/webapp-generators.ts:6-71 (helper)Core generator function that creates comprehensive markdown instructions for initializing a new DHIS2 web app, including commands, structure, and configuration.export function generateWebAppInitInstructions( appName: string, appTitle: string, appDescription: string, options: any = {} ): string { const { namespace, appType = 'app', template = 'basic', typescript = true, pwa = false, outputPath = './' } = options; return `# DHIS2 Web App Initialization Guide ## App Configuration - **App Name**: ${appName} - **App Title**: ${appTitle} - **Description**: ${appDescription || 'A DHIS2 web application'} - **Namespace**: ${namespace || appName} - **App Type**: ${appType} - **Template**: ${template} - **TypeScript**: ${typescript ? 'Yes' : 'No'} - **PWA Enabled**: ${pwa ? 'Yes' : 'No'} - **Output Path**: ${outputPath} ## Quick Start Commands \`\`\`bash # Initialize new DHIS2 app using App Platform npx @dhis2/cli-app-scripts init ${appName} # Navigate to project directory cd ${appName} # Install dependencies yarn install # Start development server yarn start \`\`\` ## Project Structure \`\`\` ${appName}/ ├── src/ │ ├── App.js${typescript ? 'x' : ''} │ ├── components/ │ └── index.js${typescript ? 'x' : ''} ├── public/ │ └── manifest.webapp ├── d2.config.js ├── package.json ${typescript ? '├── tsconfig.json' : ''} ${pwa ? '├── workbox.config.js' : ''} └── README.md \`\`\` ## Next Steps 1. Configure your DHIS2 instance connection 2. Set up proxy for development 3. Add CORS allowlist configuration 4. Implement your app components 5. Test with different DHIS2 versions ## Template-Specific Features ${generateTemplateFeatures(template)} ${pwa ? generatePWAConfiguration() : ''} `; }
- src/permission-system.ts:132-143 (registration)Registers dhis2_init_webapp in TOOL_PERMISSIONS map, associating it with 'canConfigureApps' permission for access control.// Web App Platform Tools ['dhis2_init_webapp', 'canConfigureApps'], ['dhis2_configure_app_manifest', 'canConfigureApps'], ['dhis2_configure_build_system', 'canConfigureApps'], ['dhis2_setup_dev_environment', 'canConfigureApps'], ['dhis2_generate_app_runtime_config', 'canConfigureApps'], ['dhis2_create_datastore_namespace', 'canConfigureApps'], ['dhis2_manage_datastore_key', 'canConfigureApps'], ['dhis2_setup_authentication_patterns', 'canConfigureApps'], ['dhis2_create_ui_components', 'canUseUITools'], ['dhis2_generate_test_setup', 'canConfigureApps'],
- References dhis2_init_webapp as a trigger in development-pipeline workflow for multi-server composition.triggers: ['dhis2_init_webapp']