How microsoft/powerbi-visuals-tools works
Main Components
• CLI Interface Layer:
– Represented by the executable script in the “bin” directory (bin/pbiviz.js).
– This is the main entry point that accepts user commands and orchestrates further actions.
• Core Engine/Modules (src Directory):
– Modules like CommandManager, VisualManager, FeatureManager, Package, and TemplateFetcher form the core of the tool’s functionality.
– Their responsibilities include processing CLI commands, managing visual project generation, handling TypeScript and Less compilation, certificate handling, and packaging.
• Feature Modules (src/features):
– A series of modules are dedicated to individual features (e.g., AdvancedEditMode, DrillDown, Bookmarks, etc.).
– These are plug-ins or extensions that provide specific functionality for PowerBI visuals.
• Template Management (templates Directory):
– This directory supplies various templates (default, rhtml, rvisual, slicer, table) that are used to scaffold new visual projects.
– Show how the TemplateFetcher pulls in the relevant templates for generating project code.
• Build and Configuration:
– Files like webpack.config.ts, tsconfig.json, and config.json indicate that the project uses a TypeScript/webpack based build process.
– This layer also includes ESLint configuration files (e.g., .eslintrc.json, eslint.config.mjs) which affect code quality.
• Testing and Continuous Integration:
– The “spec” directory contains both end-to-end (e2e) and unit tests, along with helper utilities.
– The .github folder (and the workflows within it) represents CI/CD pipelines for build, code analysis, and releases.
• Assets & Documentation:
– Assets (logos etc.) and documentation files (README, CONTRIBUTING, Changelog, etc.) support project maintenance and user adoption.
Determining Relationships and Interactions
• The CLI layer (pbiviz.js) parses user commands and passes instructions to the CommandManager module.
• The CommandManager interacts with other core modules (VisualManager, FeatureManager, Package, WebPackWrap) to perform tasks such as generating project files using templates or kicking off a build process.
• The TemplateFetcher pulls templates as needed from the “templates” directory, and these templates feed into how visuals are structured.
• During development, tests in the “spec” directory validate functionality, and CI workflows automatically trigger these tests.
• Build tools like webpack (configured by webpack.config.ts) and compiler settings (tsconfig.json) ensure proper code bundling and type-checking.
• External tools such as NodeJS (as a dependency) and NPM (for package management) set the runtime environment.
Architectural Patterns and Design Principles
• Modularity – The separation of concerns is visible through distinct modules for commands, visuals, and features.
• Plugin/Extension Model – The “src/features” directory suggests that the system is extensible, with each feature encapsulated in its own module.
• Template Driven – The “templates” directory drives project generation which is central to the tool’s functionality.
• Test Driven/Continuous Integration – The presence of dedicated test folders and CI/CD workflows indicates a robust development lifecycle is intended.