Developing
This article outlines how to get Dashy running in a development environment, and outlines the basics of the architecture. If you're adding new features, you may want to check out the Development Guides docs, for tutorials covering basic tasks.
- Setting up the Development Environment
- Git Strategy
- Resources for Beginners
- App Info
- Code Style Guide
- Application Structure
- Development Tools
- Misc / Notes
Setting up the Dev Environmentโ
Prerequisitesโ
You will need either the latest or LTS version of Node.js to build and serve the application and Git to easily fetch the code, and push any changes. If you plan on running or deploying the container, you'll also need Docker. To avoid any unexpected issues, ensure you've got at least NPM V 7.5 or Yarn 1.22 (you may find NVM helpful for switching/ managing versions).
Running the Projectโ
- Get Code:
git clone https://github.com/Lissy93/dashy.git - Navigate into the directory:
cd dashy - Install dependencies:
yarn - Start dev server:
yarn dev
Dashy should now be being served on http://localhost:8080/. Hot reload is enabled, so making changes to any of the files will trigger them to be rebuilt and the page refreshed.
Project Commandsโ
Basicsโ
yarn build- In the interest of speed, the application is pre-compiled, this means that the config file is read during build-time, and therefore the app needs to rebuilt for any new changes to take effect. Luckily this is very straight forward. Just runyarn buildordocker exec -it [container-id] yarn buildyarn start- Starts a web server, and serves up the production site from./dist(must run build command first)
Developmentโ
yarn dev- Starts the development server with hot reloadingyarn lint- Lints code to ensure it follows a consistent, neat styleyarn test- Runs tests, and outputs results
Utils and Checksโ
yarn validate-config- If you have quite a long configuration file, you may wish to check that it's all good to go, before deploying the app. This can be done withyarn validate-configordocker exec -it [container-id] yarn validate-config. Your config file needs to be in/user-data/conf.yml(or within your Docker container at/app/user-data/conf.yml). This will first check that your YAML is valid, and then validates it against Dashy's schema.yarn health-check- Checks that the application is up and running on it's specified port, and outputs current status and response times. Useful for integrating into your monitoring service, if you need to maintain high system availability
Alternate Start Commandsโ
yarn build-and-start- Builds the app, runs checks and starts the production server. Commands are run in parallel, and so is faster than running them in independently. Uses theyarn buildandyarn startcommandsyarn build-watch- If you find yourself making frequent changes to your configuration, and do not want to have to keep manually rebuilding, then this option is for you. It will watch for changes to any files within the projects root, and then trigger a rebuild. Note that if you are developing new features, thenyarn devwould be more appropriate, as it's significantly faster at recompiling (under 1 second), and has hot reloading, linting and testing integratedyarn pm2-start- Starts the Node server using PM2, a process manager for Node.js applications, that helps them stay alive. PM2 has some built-in basic monitoring features, and an optional management solution. If you are running the app on bare metal, it is recommended to use this start command