Conversation
This PR implements a Mason-based template for SolidUI applications. It includes: - A new templates/solidui/brick directory with the template files. - Replacing hardcoded values with Mason variables. - A mason.yaml file to register the brick. - A sync script support/sync_template_to_example.py to keep the example app in sync with the template. - Updated README.md with instructions on how to use the template with Mason. Closes anusii#104
There was a problem hiding this comment.
Pull request overview
This PR implements a Mason-based template system for SolidUI applications, addressing issue #104. The template enables users to quickly scaffold new SolidUI applications using the Mason CLI tool, while maintaining the existing example app through a synchronization script.
Changes:
- Added Mason brick template structure under
templates/solidui/brick/with configurable project name, description, and author variables - Created Python synchronization script to keep the example app in sync with the template
- Updated README.md with Mason installation and usage instructions, replacing previous
flutter createapproach
Reviewed changes
Copilot reviewed 16 out of 20 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
templates/solidui/brick/brick.yaml |
Mason brick configuration with template variables |
templates/solidui/brick/__brick__/pubspec.yaml |
Template pubspec with Mason variable substitution |
templates/solidui/brick/__brick__/lib/*.dart |
Template Dart source files including main, app, home, and utilities |
templates/solidui/brick/__brick__/lib/screens/*.dart |
Screen components for sample page and POD file browsing |
templates/solidui/brick/__brick__/lib/constants/app.dart |
App constants with template variable support |
templates/solidui/brick/__brick__/lib/home.dart.old |
Corrupted backup file that should be removed |
templates/solidui/brick/__brick__/assets/images/* |
Template app icons and images |
templates/solidui/brick/__brick__/analysis_options.yaml |
Linter configuration for generated projects |
templates/solidui/brick/__brick__/README.md |
Template README with variable substitution |
templates/solidui/brick/__brick__/.gitignore |
Comprehensive gitignore for Flutter projects |
support/sync_template_to_example.py |
Script to sync template changes to example directory |
mason.yaml |
Mason configuration registering the solidui brick |
example/lib/home.dart.old |
Corrupted backup file in example that should be removed |
README.md |
Updated quick start documentation for Mason-based workflow |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| description: A starting point for a SolidUI application. | ||
| version: 0.0.1 | ||
| environment: | ||
| mason: 0.1.0-dev.50 |
There was a problem hiding this comment.
The Mason version constraint 0.1.0-dev.50 specifies a pre-release development version. This may cause compatibility issues for users. Consider using a stable version constraint like ">=0.1.0-dev.50 <1.0.0" or update to a stable Mason version if available. This ensures better compatibility and stability for template users.
| mason: 0.1.0-dev.50 | |
| mason: ">=0.1.0-dev.50 <1.0.0" |
| subprocess.run(['mason', 'get'], cwd=root_dir, check=True) | ||
|
|
||
| # 2. Run mason make to a temporary directory | ||
| temp_gen_dir = os.path.join(root_dir, '.temp_template_gen') | ||
| if os.path.exists(temp_gen_dir): | ||
| shutil.rmtree(temp_gen_dir) | ||
| os.makedirs(temp_gen_dir) | ||
|
|
||
| subprocess.run([ | ||
| 'mason', 'make', 'solidui', | ||
| '--projectName', 'myapp', | ||
| '--description', 'My App - A SolidUI Template Application', | ||
| '--author', 'Software Innovation Institute, ANU', | ||
| '-o', temp_gen_dir | ||
| ], cwd=root_dir, check=True) |
There was a problem hiding this comment.
The subprocess calls lack error handling beyond check=True. If mason is not installed or fails for other reasons, the error message may not be clear to users. Consider adding try-except blocks around the subprocess calls to provide more informative error messages, such as "Mason CLI not found. Please install it with: dart pub global activate mason_cli".
|
|
||
| # 3. Copy generated files back to example | ||
| # Generated files are usually lib/, assets/, pubspec.yaml, etc. | ||
| gen_content_dir = os.path.join(temp_gen_dir) # mason make -o temp_gen_dir puts files directly there |
There was a problem hiding this comment.
Line 32 has a redundant os.path.join() call that doesn't add any path components. This can be simplified to gen_content_dir = temp_gen_dir. The comment already clarifies that mason outputs files directly to the specified directory.
| gen_content_dir = os.path.join(temp_gen_dir) # mason make -o temp_gen_dir puts files directly there | |
| gen_content_dir = temp_gen_dir # mason make -o temp_gen_dir puts files directly there |
| ### Using Mason (Recommended) | ||
|
|
||
| 1. Install Mason: | ||
| ```bash | ||
| dart pub global activate mason_cli | ||
| ``` | ||
| 2. Initialize Mason in your project (if not already): | ||
| ```bash | ||
| mason init | ||
| ``` | ||
| 3. Add the SolidUI brick: | ||
| ```bash | ||
| mason add solidui --path templates/solidui/brick | ||
| ``` | ||
| 4. Create a new app from the template: | ||
| ```bash | ||
| mason make solidui | ||
| ``` |
There was a problem hiding this comment.
The instructions at step 3 use --path templates/solidui/brick which assumes the user is running the command from the SolidUI repository root. This won't work for external users who want to create a new SolidUI app. Consider clarifying this is for contributors, or provide instructions for external users to either: 1) Clone the repository first, or 2) Use a published brick URL when available. The instructions should differentiate between contributors and end-users.
| window_manager: ^0.5.1 | ||
|
|
||
| dev_dependencies: | ||
| flutter_lints: ^5.0.0 |
There was a problem hiding this comment.
The template uses flutter_lints: ^5.0.0 while the main project uses flutter_lints: ^6.0.0. This version mismatch could lead to inconsistent linting rules between the template output and the main project. Consider updating the template to use ^6.0.0 to match the main project, or document the reason for the version difference.
| flutter_lints: ^5.0.0 | |
| flutter_lints: ^6.0.0 |
|
Hi @Amoghhosamane, as per #127 (comment), the solidui/example will be moved to a new repository and the solidpod/example will be moved to solidui/example. I’m not sure if we should include the current example as a template for now. We could discuss this with @gjwgit. |
This PR implements a Mason-based template for SolidUI applications, fulfilling the request to have a template that users can use to quickly start new projects.
Associated Issue
Type of change
How Has This Been Tested?
Checklist