A web-based editor for creating and editing SmartGridready device and functional profile XML declarations. This tool provides a form-based interface with validation, XML preview and import/export capabilities.
For more information about SmartGridready, visit the SGrSpecifications repository and smartgridready.ch.
- Getting Started
- Project Overview
- Project Structure
- Used Libraries
- Commit Rules
- Releasing
- Pipeline and Deployment
-
Clone the repository
git clone https://github.com/SmartGridready/SGrDeclarationTool.git
-
Install dependencies
npm ci
-
Run the development server
npm run dev
-
Open your browser
Navigate to http://localhost:3000.
The src/ folder contains the following top-level directories:
app/- Next.js App Router pages and layouts for the main routes (devices, functional profiles)components/- Reusable React components including editor dialogs, form inputs, navigation, and shadcn UI primitivesconstants/- Constant values for error, info, and success messages used throughout the applicationhooks/- Custom React hooks for file import/export, validation, debouncing, and XSL previewmodels/- TypeScript type definitions for functional profiles and productssections/- Form sections and related logic (builders, mappers, schemas, slices) for device and functional profile editorstest/- Jest test files for library API integration testsutils/- Utility functions for XML building, mapping, validation, and other shared logic
- Next.js - React framework for routing and optimization features
- React - Core React library for building user interfaces
- TypeScript - Typed superset of JavaScript for type safety
- Tailwind CSS - Utility-first CSS framework for styling
- Zustand - Lightweight state management solution
- xml2js - XML parser for SmartGridready declarations
- Shadcn UI - Reusable UI components built with Radix UI and Tailwind CSS
- Zod - TypeScript-first schema validation library
- Sonner - Toast notification library for React
- ESLint & Prettier - Code linting and formatting
- Jest & Testing Library - Testing framework and utilities
- Husky - Git hooks for pre-commit checks
- standard-version - Automated versioning and changelog generation
This project follows the Conventional Commits specification for commit messages.
Each commit message should follow this format:
<type>(<scope>): <subject> (GL-<Issue Number>)
- Type (required): The type of change being made
- Scope (optional): The area of the codebase affected
- Subject (required): A short, imperative description of the change
- Issue Number (optional but preferred): The linked Issue from GitLab
Example:
git commit -m "feat(api): change device endpoint structure (GL-99)"This project uses Husky to run automated checks before commits:
- Pre-commit hook: Runs
npm run lintandnpm run format:check - Commit-msg hook: Validates commit messages follow the Conventional Commits specification
Releases are performed manually using semantic versioning (patch, minor, major). The project uses standard-version.
-
Choose the release type and run the command
Patch (
0.2.0→0.2.1): Bug fixes, patchesnpm run release:patch
Minor (
0.2.0→0.3.0): New features, backwards compatiblenpm run release:minor
Major (
0.2.0→1.0.0): Breaking changesnpm run release:major
This will:
- Bump the version in
package.json - Generate/update
CHANGELOG.mdbased on commit history - Create a git tag with the new version
- Create a commit with the version bump and changelog
- Bump the version in
-
Push the release
git push --follow-tags origin main
docker build --rm -t sgr-declaration-tool:latest .The Docker build process has 2 stages:
- Build using NodeJS image
- Copy to Nginx runtime image
Run container:
docker compose up -dStop:
docker compose downThe Github CI/CD pipeline consists of three stages:
- Lint: Runs
npm run linton all branches and commits - Test: Runs
npm run teston all branches and commits - Build Runs
npm run buildon all branches and commits
The GitLab CI/CD pipeline consists of three stages:
- Lint: Runs
npm run linton all branches and commits - Test: Runs
npm run teston all branches and commits - Build Runs
npm run buildon all branches and commits
