UNPKG

@burgan-tech/vnext-template

Version:

vNext template package with domain-based workflow components and schema validation

270 lines (206 loc) • 6.09 kB
# {domainName} A structured template package for vNext workflow components with domain-based architecture. ## šŸ“¦ Installation Create a new project with your domain name: ```bash npx @burgan-tech/vnext-template <domain-name> ``` ### Example ```bash npx @burgan-tech/vnext-template user-management ``` This will create a new directory with your domain name, copy all template files, replace `{domainName}` instances, and install dependencies automatically. ### Install specific version ```bash npx @burgan-tech/vnext-template@<version> <domain-name> ``` Example: ```bash npx @burgan-tech/vnext-template@1.0.0 user-management ``` ### Alternative: Install as dependency ```bash npm install @burgan-tech/vnext-template npm run setup <domain-name> ``` Or install specific version: ```bash npm install @burgan-tech/vnext-template@<version> npm run setup <domain-name> ``` Or use environment variable: ```bash DOMAIN_NAME=user-management npm install @burgan-tech/vnext-template@<version> ``` ## šŸš€ Usage After installation, your project structure will be: ``` <domain-name>/ ā”œā”€ā”€ Extensions/ ā”œā”€ā”€ Functions/ ā”œā”€ā”€ Schemas/ ā”œā”€ā”€ Tasks/ ā”œā”€ā”€ Views/ └── Workflows/ ``` ### Access components in code ```javascript const vnextTemplate = require('@burgan-tech/vnext-template'); // Get domain configuration const config = vnextTemplate.getDomainConfig(); // Get paths configuration const paths = vnextTemplate.getPathsConfig(); // Get all schemas const schemas = vnextTemplate.getSchemas(); // Get all workflows const workflows = vnextTemplate.getWorkflows(); // Get all tasks const tasks = vnextTemplate.getTasks(); // Get component path for a specific type const schemasPath = vnextTemplate.getComponentPath('schemas'); ``` ### Available methods | Method | Description | |--------|-------------| | `getDomainConfig()` | Get domain configuration from vnext.config.json | | `getPathsConfig()` | Get paths configuration with defaults | | `getSchemas()` | Get all schemas | | `getWorkflows()` | Get all workflows | | `getTasks()` | Get all tasks | | `getViews()` | Get all views | | `getFunctions()` | Get all functions | | `getExtensions()` | Get all extensions | | `getDomainName()` | Get domain directory name | | `getAvailableTypes()` | Get list of available component types | | `getComponentPath(type)` | Get full path for a component type | ## āš™ļø Configuration The `vnext.config.json` file allows you to customize paths and exports: ```json { "domain": "my-domain", "paths": { "componentsRoot": "my-domain", "schemas": "Schemas", "workflows": "Workflows", "tasks": "Tasks", "views": "Views", "functions": "Functions", "extensions": "Extensions" }, "exports": { "schemas": ["schema1.json", "schema2.json"], "workflows": ["workflow1.json"], "tasks": [], "views": [], "functions": [], "extensions": [] } } ``` ### Path Configuration You can customize component directory names: ```json { "paths": { "componentsRoot": "src", "workflows": "Flows", "schemas": "Models" } } ``` ## āœ… Validation Validate your project structure and schemas: ```bash npm run validate ``` This will check: - Package.json structure and content - Main entry point functionality - vnext.config.json validation - Domain directory structure - JSON file syntax validation - Schema validation using @burgan-tech/vnext-schema - Module functionality - Semantic versioning compliance ### Validation Output The validation provides detailed output with: - āœ… Passed validations - āŒ Failed validations with file paths and line numbers - šŸ“Š Summary statistics - šŸ“‹ Failed files summary for easy navigation ## šŸ—ļø Build Build your domain package for deployment or cross-domain usage: ```bash # Runtime build (default) - Complete domain structure npm run build # Reference build - Only exported components npm run build:reference # Runtime build explicitly npm run build:runtime ``` ### Build Options ```bash npm run build -- [options] Options: -o, --output <dir> Output directory (default: dist) -t, --type <type> Build type: reference or runtime (default: runtime) --skip-validation Skip validation during build -h, --help Show help message ``` ### Build Types | Type | Description | Use Case | |------|-------------|----------| | `runtime` | Complete domain structure with all files | Engine deployment | | `reference` | Only exported components from vnext.config.json | Cross-domain usage | ### Examples ```bash # Build to custom directory npm run build -- -o my-build # Reference build to custom directory npm run build -- -t reference -o packages/ref # Skip validation for faster builds npm run build -- --skip-validation ``` ### Build Output Structure **Runtime Build:** ``` dist/ ā”œā”€ā”€ <domain>/ │ ā”œā”€ā”€ Extensions/ │ ā”œā”€ā”€ Functions/ │ ā”œā”€ā”€ Schemas/ │ ā”œā”€ā”€ Tasks/ │ ā”œā”€ā”€ Views/ │ └── Workflows/ ā”œā”€ā”€ vnext.config.json ā”œā”€ā”€ package.json ā”œā”€ā”€ README.md └── LICENSE ``` **Reference Build:** ``` dist/ ā”œā”€ā”€ <domain>/ │ ā”œā”€ā”€ Extensions/ # Only exported files │ ā”œā”€ā”€ Functions/ # Only exported files │ ā”œā”€ā”€ Schemas/ # Only exported files │ ā”œā”€ā”€ Tasks/ # Only exported files │ ā”œā”€ā”€ Views/ # Only exported files │ └── Workflows/ # Only exported files ā”œā”€ā”€ vnext.config.json ā”œā”€ā”€ package.json ā”œā”€ā”€ README.md └── LICENSE ``` ## šŸ“œ Available Scripts | Script | Description | |--------|-------------| | `npm run validate` | Validate project structure and schemas | | `npm run build` | Build runtime package to dist/ | | `npm run build:runtime` | Build runtime package explicitly | | `npm run build:reference` | Build reference package with exports only | | `npm run setup <name>` | Setup domain with given name | | `npm run sync-schema` | Sync schema version from dependencies | | `npm test` | Run tests | ## šŸ“„ License MIT