dashy/assets/js/68d50eef.c8d78b20.js
2021-08-29 19:39:19 +01:00

1 line
No EOL
36 KiB
JavaScript

(self.webpackChunkdashy=self.webpackChunkdashy||[]).push([[783],{3905:function(e,t,n){"use strict";n.d(t,{Zo:function(){return p},kt:function(){return m}});var i=n(7294);function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){a(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(e,t){if(null==e)return{};var n,i,a=function(e,t){if(null==e)return{};var n,i,a={},o=Object.keys(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)n=o[i],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}var s=i.createContext({}),u=function(e){var t=i.useContext(s),n=t;return e&&(n="function"==typeof e?e(t):r(r({},t),e)),n},p=function(e){var t=u(e.components);return i.createElement(s.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return i.createElement(i.Fragment,{},t)}},c=i.forwardRef((function(e,t){var n=e.components,a=e.mdxType,o=e.originalType,s=e.parentName,p=l(e,["components","mdxType","originalType","parentName"]),c=u(n),m=a,h=c["".concat(s,".").concat(m)]||c[m]||d[m]||o;return n?i.createElement(h,r(r({ref:t},p),{},{components:n})):i.createElement(h,r({ref:t},p))}));function m(e,t){var n=arguments,a=t&&t.mdxType;if("string"==typeof e||a){var o=n.length,r=new Array(o);r[0]=c;var l={};for(var s in t)hasOwnProperty.call(t,s)&&(l[s]=t[s]);l.originalType=e,l.mdxType="string"==typeof e?e:a,r[1]=l;for(var u=2;u<o;u++)r[u]=n[u];return i.createElement.apply(null,r)}return i.createElement.apply(null,n)}c.displayName="MDXCreateElement"},5747:function(e,t,n){"use strict";n.r(t),n.d(t,{frontMatter:function(){return l},contentTitle:function(){return s},metadata:function(){return u},toc:function(){return p},default:function(){return c}});var i=n(2122),a=n(9756),o=(n(7294),n(3905)),r=["components"],l={},s="Developing",u={unversionedId:"developing",id:"developing",isDocsHomePage:!1,title:"Developing",description:"This article outlines how to get Dashy running in a development environment, and outlines the basics of the architecture.",source:"@site/docs/developing.md",sourceDirName:".",slug:"/developing",permalink:"/docs/developing",editUrl:"https://github.com/Lissy93/dashy/edit/gh-pages/docs/docs/developing.md",version:"current",frontMatter:{},sidebar:"dashySidebar",previous:{title:"Contributing",permalink:"/docs/contributing"},next:{title:"Development Guides",permalink:"/docs/development-guides"}},p=[{value:"Setting up the Dev Environment",id:"setting-up-the-dev-environment",children:[{value:"Prerequisites",id:"prerequisites",children:[]},{value:"Running the Project",id:"running-the-project",children:[]},{value:"Project Commands",id:"project-commands",children:[]},{value:"Environmental Variables",id:"environmental-variables",children:[]},{value:"Environment Modes",id:"environment-modes",children:[]}]},{value:"Git Strategy",id:"git-strategy",children:[{value:"Git Flow",id:"git-flow",children:[]},{value:"Git Branch Naming",id:"git-branch-naming",children:[]},{value:"Commit Emojis",id:"commit-emojis",children:[]},{value:"PR Guidelines",id:"pr-guidelines",children:[]}]},{value:"Resources for Beginners",id:"resources-for-beginners",children:[]},{value:"Style Guide",id:"style-guide",children:[]},{value:"Application Structure",id:"application-structure",children:[{value:"Directory Structure",id:"directory-structure",children:[]},{value:"Frontend Components",id:"frontend-components",children:[]}]},{value:"Development Tools",id:"development-tools",children:[{value:"Performance - Lighthouse",id:"performance---lighthouse",children:[]},{value:"Dependencies - BundlePhobia",id:"dependencies---bundlephobia",children:[]}]},{value:"Notes",id:"notes",children:[{value:"Known Warnings",id:"known-warnings",children:[]}]}],d={toc:p};function c(e){var t=e.components,n=(0,a.Z)(e,r);return(0,o.kt)("wrapper",(0,i.Z)({},d,n,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h1",{id:"developing"},"Developing"),(0,o.kt)("p",null,"This article outlines how to get Dashy running in a development environment, and outlines the basics of the architecture.\nIf you're adding new features, you may want to check out the ",(0,o.kt)("a",{parentName:"p",href:"/docs/development-guides"},"Development Guides")," docs, for tutorials covering basic tasks."),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"#setting-up-the-dev-environment"},"Setting up the Development Environment")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"#resources-for-beginners"},"Resources for Beginners")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"#style-guide"},"Style Guide")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"#frontend-components"},"Frontend Components")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"#directory-structure"},"Project Structure")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"#dependencies-and-packages"},"Dependencies and Packages"))),(0,o.kt)("h2",{id:"setting-up-the-dev-environment"},"Setting up the Dev Environment"),(0,o.kt)("h3",{id:"prerequisites"},"Prerequisites"),(0,o.kt)("p",null,"You will need either the latest or LTS version of ",(0,o.kt)("strong",{parentName:"p"},(0,o.kt)("a",{parentName:"strong",href:"https://nodejs.org/"},"Node.js"))," to build and serve the application and ",(0,o.kt)("strong",{parentName:"p"},(0,o.kt)("a",{parentName:"strong",href:"https://git-scm.com/downloads"},"Git"))," to easily fetch the code, and push any changes. If you plan on running or deploying the container, you'll also need ",(0,o.kt)("strong",{parentName:"p"},(0,o.kt)("a",{parentName:"strong",href:"https://docs.docker.com/get-docker/"},"Docker")),". To avoid any unexpected issues, ensure you've got at least ",(0,o.kt)("strong",{parentName:"p"},(0,o.kt)("a",{parentName:"strong",href:"https://www.npmjs.com/get-npm"},"NPM"))," V 7.5 or ",(0,o.kt)("strong",{parentName:"p"},(0,o.kt)("a",{parentName:"strong",href:"https://classic.yarnpkg.com/en/docs/install/#windows-stable"},"Yarn"))," 1.22 (you may find ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/nvm-sh/nvm"},"NVM")," helpful for switching/ managing versions)."),(0,o.kt)("h3",{id:"running-the-project"},"Running the Project"),(0,o.kt)("ol",null,(0,o.kt)("li",{parentName:"ol"},"Get Code: ",(0,o.kt)("inlineCode",{parentName:"li"},"git clone https://github.com/Lissy93/dashy.git")),(0,o.kt)("li",{parentName:"ol"},"Navigate into the directory: ",(0,o.kt)("inlineCode",{parentName:"li"},"cd dashy")),(0,o.kt)("li",{parentName:"ol"},"Install dependencies: ",(0,o.kt)("inlineCode",{parentName:"li"},"yarn")),(0,o.kt)("li",{parentName:"ol"},"Start dev server: ",(0,o.kt)("inlineCode",{parentName:"li"},"yarn dev"))),(0,o.kt)("p",null,"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."),(0,o.kt)("h3",{id:"project-commands"},"Project Commands"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"yarn dev")," - Starts the development server with hot reloading"),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"yarn build")," - Builds the project for production, and outputs it into ",(0,o.kt)("inlineCode",{parentName:"li"},"./dist")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"yarn start")," - Starts a web server, and serves up the production site from ",(0,o.kt)("inlineCode",{parentName:"li"},"./dist")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"yarn validate-config")," - Parses and validates your ",(0,o.kt)("inlineCode",{parentName:"li"},"conf.yml")," against Dashy's schema"),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"yarn lint")," - Lints code to ensure it follows a consistent, neat style"),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"yarn test")," - Runs tests, and outputs results")),(0,o.kt)("p",null,"There is also:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"yarn build-and-start")," will run ",(0,o.kt)("inlineCode",{parentName:"li"},"yarn build")," and ",(0,o.kt)("inlineCode",{parentName:"li"},"yarn start")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"yarn build-watch")," will output contents to ",(0,o.kt)("inlineCode",{parentName:"li"},"./dist")," and recompile when anything in ",(0,o.kt)("inlineCode",{parentName:"li"},"./src")," is modified, you can then use either ",(0,o.kt)("inlineCode",{parentName:"li"},"yarn start")," or your own server, to have a production environment that watches for changes.")),(0,o.kt)("p",null,"Using the Vue CLI:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"The app is build with Vue, and uses the ",(0,o.kt)("a",{parentName:"li",href:"https://cli.vuejs.org/guide/cli-service.html"},"Vue-CLI Service")," for basic commands."),(0,o.kt)("li",{parentName:"ul"},"If you have ",(0,o.kt)("a",{parentName:"li",href:"https://github.com/npm/npx"},"NPX")," installed, then you can invoke the Vue CLI binary using ",(0,o.kt)("inlineCode",{parentName:"li"},"npx vue-cli-service [command]")),(0,o.kt)("li",{parentName:"ul"},"Vue also has a GUI environment that can be used for basic project management, and may be useful for beginners, this can be started by running ",(0,o.kt)("inlineCode",{parentName:"li"},"vue ui"),", and opening up ",(0,o.kt)("inlineCode",{parentName:"li"},"http://localhost:8000"))),(0,o.kt)("p",null,"Note:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"If you are using NPM, replace ",(0,o.kt)("inlineCode",{parentName:"li"},"yarn")," with ",(0,o.kt)("inlineCode",{parentName:"li"},"npm run")),(0,o.kt)("li",{parentName:"ul"},"If you are using Docker, precede each command with ",(0,o.kt)("inlineCode",{parentName:"li"},"docker exec -it [container-id]"),". Container ID can be found by running ",(0,o.kt)("inlineCode",{parentName:"li"},"docker ps"))),(0,o.kt)("h3",{id:"environmental-variables"},"Environmental Variables"),(0,o.kt)("p",null,"All environmental variables are optional. Currently there are not many environmental variables used, as most of the user preferences are stored under ",(0,o.kt)("inlineCode",{parentName:"p"},"appConfig")," in the ",(0,o.kt)("inlineCode",{parentName:"p"},"conf.yml")," file."),(0,o.kt)("p",null,"You can set variables within your local development environment using a ",(0,o.kt)("inlineCode",{parentName:"p"},".env")," file."),(0,o.kt)("p",null,"Any environmental variables used by the frontend are preceded with ",(0,o.kt)("inlineCode",{parentName:"p"},"VUE_APP_"),". Vue will merge the contents of your ",(0,o.kt)("inlineCode",{parentName:"p"},".env")," file into the app in a similar way to the ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/motdotla/dotenv"},"'dotenv'")," package, where any variables that you set on your system will always take preference over the contents of any ",(0,o.kt)("inlineCode",{parentName:"p"},".env")," file."),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"PORT")," - The port in which the application will run (defaults to ",(0,o.kt)("inlineCode",{parentName:"li"},"4000")," for the Node.js server, and ",(0,o.kt)("inlineCode",{parentName:"li"},"80")," within the Docker container)"),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"NODE_ENV")," - Which environment to use, either ",(0,o.kt)("inlineCode",{parentName:"li"},"production"),", ",(0,o.kt)("inlineCode",{parentName:"li"},"development")," or ",(0,o.kt)("inlineCode",{parentName:"li"},"test")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"VUE_APP_DOMAIN")," - The URL where Dashy is going to be accessible from. This should include the protocol, hostname and (if not 80 or 443), then the port too, e.g. ",(0,o.kt)("inlineCode",{parentName:"li"},"https://localhost:3000"),", ",(0,o.kt)("inlineCode",{parentName:"li"},"http://192.168.1.2:4002")," or ",(0,o.kt)("inlineCode",{parentName:"li"},"https://dashy.mydomain.com"))),(0,o.kt)("p",null,"If you do add new variables, ensure that there is always a fallback (define it in ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/Lissy93/dashy/blob/master/src/utils/defaults.js"},(0,o.kt)("inlineCode",{parentName:"a"},"defaults.js")),"), so as to not cause breaking changes. Don't commit your ",(0,o.kt)("inlineCode",{parentName:"p"},".env")," file to git, but instead take a few moments to document what you've added under the appropriate section. Try and follow the concepts outlined in the ",(0,o.kt)("a",{parentName:"p",href:"https://12factor.net/config"},"12 factor app"),"."),(0,o.kt)("h3",{id:"environment-modes"},"Environment Modes"),(0,o.kt)("p",null,"You can set the environment using the ",(0,o.kt)("inlineCode",{parentName:"p"},"NODE_ENV")," variable.\nThe correct environment will be selected based on the script you run by default\nThe following environments are supported."),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"production")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"development")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("inlineCode",{parentName:"li"},"test"))),(0,o.kt)("p",null,"For more info, see ",(0,o.kt)("a",{parentName:"p",href:"https://cli.vuejs.org/guide/mode-and-env.html#modes"},"Vue CLI Environment Modes"),"."),(0,o.kt)("hr",null),(0,o.kt)("h2",{id:"git-strategy"},"Git Strategy"),(0,o.kt)("h3",{id:"git-flow"},"Git Flow"),(0,o.kt)("p",null,"Like most Git repos, we are following the ",(0,o.kt)("a",{parentName:"p",href:"https://guides.github.com/introduction/flow"},"Github Flow")," standard."),(0,o.kt)("ol",null,(0,o.kt)("li",{parentName:"ol"},"Create a branch (or fork if you don'd have write acces)"),(0,o.kt)("li",{parentName:"ol"},"Code some awesome stuff, then add and commit your changes"),(0,o.kt)("li",{parentName:"ol"},"Create a Pull Request, complete the checklist and ensure the build succeeds"),(0,o.kt)("li",{parentName:"ol"},"Follow up with any reviews on your code"),(0,o.kt)("li",{parentName:"ol"},"Merge \ud83c\udf89")),(0,o.kt)("h3",{id:"git-branch-naming"},"Git Branch Naming"),(0,o.kt)("p",null,"The format of your branch name should be something similar to: ",(0,o.kt)("inlineCode",{parentName:"p"},"[TYPE]/[TICKET]_[TITLE]"),"\nFor example, ",(0,o.kt)("inlineCode",{parentName:"p"},"FEATURE/420_Awesome-feature")," or ",(0,o.kt)("inlineCode",{parentName:"p"},"FIX/690_login-server-error")),(0,o.kt)("h3",{id:"commit-emojis"},"Commit Emojis"),(0,o.kt)("p",null,"Using a single emoji at the start of each commit message, to indicate the type task, makes the commit ledger easier to understand, plus it looks cool."),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"\ud83c\udfa8 ",(0,o.kt)("inlineCode",{parentName:"li"},":art:")," - Improve structure / format of the code."),(0,o.kt)("li",{parentName:"ul"},"\u26a1\ufe0f ",(0,o.kt)("inlineCode",{parentName:"li"},":zap:")," - Improve performance."),(0,o.kt)("li",{parentName:"ul"},"\ud83d\udd25 ",(0,o.kt)("inlineCode",{parentName:"li"},":fire:")," - Remove code or files."),(0,o.kt)("li",{parentName:"ul"},"\ud83d\udc1b ",(0,o.kt)("inlineCode",{parentName:"li"},":bug:")," - Fix a bug."),(0,o.kt)("li",{parentName:"ul"},"\ud83d\ude91\ufe0f ",(0,o.kt)("inlineCode",{parentName:"li"},":ambulance:")," - Critical hotfix"),(0,o.kt)("li",{parentName:"ul"},"\u2728 ",(0,o.kt)("inlineCode",{parentName:"li"},":sparkles:")," - Introduce new features."),(0,o.kt)("li",{parentName:"ul"},"\ud83d\udcdd ",(0,o.kt)("inlineCode",{parentName:"li"},":memo:")," - Add or update documentation."),(0,o.kt)("li",{parentName:"ul"},"\ud83d\ude80 ",(0,o.kt)("inlineCode",{parentName:"li"},":rocket:")," - Deploy stuff."),(0,o.kt)("li",{parentName:"ul"},"\ud83d\udc84 ",(0,o.kt)("inlineCode",{parentName:"li"},":lipstick:")," - Add or update the UI and style files."),(0,o.kt)("li",{parentName:"ul"},"\ud83c\udf89 ",(0,o.kt)("inlineCode",{parentName:"li"},":tada:")," - Begin a project."),(0,o.kt)("li",{parentName:"ul"},"\u2705 ",(0,o.kt)("inlineCode",{parentName:"li"},":white_check_mark:")," - Add, update, or pass tests."),(0,o.kt)("li",{parentName:"ul"},"\ud83d\udd12\ufe0f ",(0,o.kt)("inlineCode",{parentName:"li"},":lock:")," - Fix security issues."),(0,o.kt)("li",{parentName:"ul"},"\ud83d\udd16 ",(0,o.kt)("inlineCode",{parentName:"li"},":bookmark:")," - Make a Release or Version tag."),(0,o.kt)("li",{parentName:"ul"},"\ud83d\udea8 ",(0,o.kt)("inlineCode",{parentName:"li"},":rotating_light:")," - Fix compiler / linter warnings."),(0,o.kt)("li",{parentName:"ul"},"\ud83d\udea7 ",(0,o.kt)("inlineCode",{parentName:"li"},":construction:")," - Work in progress."),(0,o.kt)("li",{parentName:"ul"},"\u2b06\ufe0f ",(0,o.kt)("inlineCode",{parentName:"li"},":arrow_up:")," - Upgrade dependencies."),(0,o.kt)("li",{parentName:"ul"},"\ud83d\udc77 ",(0,o.kt)("inlineCode",{parentName:"li"},":construction_worker:")," - Add or update CI build system."),(0,o.kt)("li",{parentName:"ul"},"\u267b\ufe0f ",(0,o.kt)("inlineCode",{parentName:"li"},":recycle:")," - Refactor code."),(0,o.kt)("li",{parentName:"ul"},"\ud83e\ude79 ",(0,o.kt)("inlineCode",{parentName:"li"},":adhesive_bandage:")," - Simple fix for a non-critical issue."),(0,o.kt)("li",{parentName:"ul"},"\ud83d\udd27 ",(0,o.kt)("inlineCode",{parentName:"li"},":wrench:")," - Add or update configuration files."),(0,o.kt)("li",{parentName:"ul"},"\ud83c\udf71 ",(0,o.kt)("inlineCode",{parentName:"li"},":bento:")," - Add or update assets."),(0,o.kt)("li",{parentName:"ul"},"\ud83d\uddc3\ufe0f ",(0,o.kt)("inlineCode",{parentName:"li"},":card_file_box:")," - Perform database schema related changes."),(0,o.kt)("li",{parentName:"ul"},"\u270f\ufe0f ",(0,o.kt)("inlineCode",{parentName:"li"},":pencil2:")," - Fix typos."),(0,o.kt)("li",{parentName:"ul"},"\ud83c\udf10 ",(0,o.kt)("inlineCode",{parentName:"li"},":globe_with_meridians:")," - Internationalization and translations.")),(0,o.kt)("p",null,"For a full list of options, see ",(0,o.kt)("a",{parentName:"p",href:"https://gitmoji.dev/"},"gitmoji.dev")),(0,o.kt)("h3",{id:"pr-guidelines"},"PR Guidelines"),(0,o.kt)("p",null,"Once you've made your changes, and pushed them to your fork or branch, you're ready to open a pull request!"),(0,o.kt)("p",null,"For a pull request to be merged, it must:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Must be backwards compatible"),(0,o.kt)("li",{parentName:"ul"},"The build, lint and tests (run by GH actions) must pass"),(0,o.kt)("li",{parentName:"ul"},"There must not be any merge conflicts")),(0,o.kt)("p",null,"When you submit your PR, include the required info, by filling out the PR template. Including:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"A brief description of your changes"),(0,o.kt)("li",{parentName:"ul"},"The issue, ticket or discussion number (if applicable)"),(0,o.kt)("li",{parentName:"ul"},"For UI relate updates include a screenshot"),(0,o.kt)("li",{parentName:"ul"},"If any dependencies were added, explain why it was needed, state the cost associated, and confirm it does not introduce any security issues"),(0,o.kt)("li",{parentName:"ul"},"Finally, check the checkboxes, to confirm that the standards are met, and hit submit!")),(0,o.kt)("hr",null),(0,o.kt)("h2",{id:"resources-for-beginners"},"Resources for Beginners"),(0,o.kt)("p",null,"New to Web Development? Glad you're here! Dashy is a pretty simple app, so it should make a good candidate for your first PR. Presuming that you already have a basic knowledge of JavaScript, the following articles should point you in the right direction for getting up to speed with the technologies used in this project:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://v3.vuejs.org/guide/introduction.html"},"Introduction to Vue.js")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://www.taniarascia.com/getting-started-with-vue/"},"Vue.js Walkthrough")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://blog.logrocket.com/the-definitive-guide-to-scss/"},"Definitive guide to SCSS")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://docker-curriculum.com/"},"Complete beginners guide to Docker")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://training.play-with-docker.com/"},"Docker Classroom - Interactive Tutorials")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://www.freecodecamp.org/news/learn-typescript-in-5-minutes-13eda868daeb/"},"Quick start TypeScript guide")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://www.typescripttutorial.net/"},"Complete TypeScript tutorial series")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://blog.logrocket.com/vue-typescript-tutorial-examples/"},"Using TypeScript with Vue.js")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"http://git-cheatsheet.com/"},"Git cheat sheet")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("a",{parentName:"li",href:"https://www.freecodecamp.org/news/what-is-npm-a-node-package-manager-tutorial-for-beginners/"},"Basics of using NPM"))),(0,o.kt)("p",null,"As well as Node, Git and Docker- you'll also need an IDE (e.g. ",(0,o.kt)("a",{parentName:"p",href:"https://code.visualstudio.com/"},"VS Code")," or ",(0,o.kt)("a",{parentName:"p",href:"https://www.vim.org/"},"Vim"),") and a terminal (Windows users may find ",(0,o.kt)("a",{parentName:"p",href:"https://docs.microsoft.com/en-us/windows/wsl/"},"WSL")," more convenient). "),(0,o.kt)("hr",null),(0,o.kt)("h2",{id:"style-guide"},"Style Guide"),(0,o.kt)("p",null,"Linting is done using ",(0,o.kt)("a",{parentName:"p",href:"https://eslint.org/"},"ESLint"),", and using the ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/vuejs/eslint-config-standard"},"Vue.js Styleguide"),", which is very similar to the ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/airbnb/javascript"},"AirBnB Stylguide"),". You can run ",(0,o.kt)("inlineCode",{parentName:"p"},"yarn lint")," to report and fix issues. While the dev server is running, issues will be reported to the console automatically, and any lint errors will trigger the build to fail. Note that all lint checks must pass before any PR can be merged. Linting is also run as a git pre-commit hook"),(0,o.kt)("p",null,"The most significant things to note are:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Indentation should be done with two spaces"),(0,o.kt)("li",{parentName:"ul"},"Strings should use single quotes"),(0,o.kt)("li",{parentName:"ul"},"All statements must end in a semi-colon"),(0,o.kt)("li",{parentName:"ul"},"The final element in all objects must be preceded with a comma"),(0,o.kt)("li",{parentName:"ul"},"Maximum line length is 100"),(0,o.kt)("li",{parentName:"ul"},"There must be exactly one blank line between sections, before function names, and at the end of the file"),(0,o.kt)("li",{parentName:"ul"},"With conditionals, put else on the same line as your if block\u2019s closing brace"),(0,o.kt)("li",{parentName:"ul"},"All multiline blocks must use braces"),(0,o.kt)("li",{parentName:"ul"},"Avoid console statements in the frontend")),(0,o.kt)("p",null,"Styleguides:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},"Vue: ",(0,o.kt)("a",{parentName:"li",href:"https://vuejs.org/v2/style-guide/"},"Vue styleguide")),(0,o.kt)("li",{parentName:"ul"},"JavaScript: ",(0,o.kt)("a",{parentName:"li",href:"https://github.com/airbnb/javascript"},"github.com/airbnb/javascript")," ")),(0,o.kt)("hr",null),(0,o.kt)("h2",{id:"application-structure"},"Application Structure"),(0,o.kt)("h3",{id:"directory-structure"},"Directory Structure"),(0,o.kt)("h4",{id:"files-in-the-root-"},"Files in the Root: ",(0,o.kt)("inlineCode",{parentName:"h4"},"./")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre"},"\u256e\n\u251c\u2500\u2500 package.json # Project meta-data, dependencies and paths to scripts\n\u251c\u2500\u2500 src/ # Project front-end source code\n\u251c\u2500\u2500 server.js # A Node.js server to serve up the /dist directory\n\u251c\u2500\u2500 vue.config.js # Vue.js configuration\n\u251c\u2500\u2500 Dockerfile # The blueprint for building the Docker container\n\u251c\u2500\u2500 docker-compose.yml # A Docker run command\n\u251c\u2500\u2500 .env # Location for any environmental variables\n\u251c\u2500\u2500 yarn.lock # Auto-generated list of current packages and version numbers\n\u251c\u2500\u2500 docs/ # Markdown documentation\n\u251c\u2500\u2500 README.md # Readme, basic info for getting started\n\u251c\u2500\u2500 LICENSE.md # License for use\n\u256f\n")),(0,o.kt)("h4",{id:"frontend-source-src"},"Frontend Source: ",(0,o.kt)("inlineCode",{parentName:"h4"},"./src/")),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre"},"./src\n\u251c\u2500\u2500 App.vue # Vue.js starting file\n\u251c\u2500\u2500 assets # Static non-compiled assets\n\u2502 \u251c\u2500\u2500 fonts # .ttf font files\n\u2502 \u251c\u2500\u2500 locales # All app text, each language in a separate JSON file\n\u2502 \u2570\u2500\u2500 interface-icons # SVG icons used in the app \n\u251c\u2500\u2500 components # All front-end Vue web components\n\u2502 \u251c\u2500\u2500 Configuration # Components relating to the user config pop-up\n\u2502 \u2502 \u251c\u2500\u2500 AppInfoModal.vue # A modal showing core app info, like version, language, etc\n\u2502 \u2502 \u251c\u2500\u2500 CloudBackupRestore.vue # Form where the user manages cloud sync options\n\u2502 \u2502 \u251c\u2500\u2500 ConfigContainer.vue # Main container, wrapping all other config components\n\u2502 \u2502 \u251c\u2500\u2500 CustomCss.vue # Form where the user can input custom CSS\n\u2502 \u2502 \u251c\u2500\u2500 EditSiteMeta.vue # Form where the user can edit site meta data\n\u2502 \u2502 \u251c\u2500\u2500 JsonEditor.vue # JSON editor, where the user can modify the main config file\n\u2502 \u2502 \u2570\u2500\u2500 RebuildApp.vue # A component allowing user to trigger a rebuild through the UI\n\u2502 \u251c\u2500\u2500 FormElements # Basic form elements used throughout the app\n\u2502 \u2502 \u251c\u2500\u2500 Button.vue # Standard button component\n\u2502 \u2502 \u2570\u2500\u2500 Input.vue # Standard text field input component\n\u2502 \u251c\u2500\u2500 LinkItems # Components for Sections and Link Items\n\u2502 \u2502 \u251c\u2500\u2500 Collapsable.vue # The collapsible functionality of sections\n\u2502 \u2502 \u251c\u2500\u2500 ContextMenu.vue # The right-click menu, for showing Item opening methods and info\n\u2502 \u2502 \u251c\u2500\u2500 IframeModal.vue # Pop-up iframe modal, for viewing websites within the app\n\u2502 \u2502 \u251c\u2500\u2500 Item.vue # Main link item, which is displayed within an item group\n\u2502 \u2502 \u251c\u2500\u2500 ItemGroup.vue # Item group is a section containing icons\n\u2502 \u2502 \u251c\u2500\u2500 ItemIcon.vue # The icon used by both items and sections\n\u2502 \u2502 \u251c\u2500\u2500 ItemOpenMethodIcon.vue # A small icon, visible on hover, indicating opening method \n\u2502 \u2502 \u2570\u2500\u2500 StatusIndicator.vue # Traffic light dot, showing if app is online or down\n\u2502 \u251c\u2500\u2500 PageStrcture # Components relating the main structure of the page\n\u2502 \u2502 \u251c\u2500\u2500 Footer.vue # Footer, visible at the bottom of all pages\n\u2502 \u2502 \u251c\u2500\u2500 Header.vue # Header, visible at the top of pages, and includes title and nav\n\u2502 \u2502 \u251c\u2500\u2500 LoadingScreen.vue # Splash screen shown on first load\n\u2502 \u2502 \u251c\u2500\u2500 Nav.vue # Navigation bar, includes a list of links\n\u2502 \u2502 \u2570\u2500\u2500 PageTitle.vue # Page title and sub-title, visible within the Header\n\u2502 \u2570\u2500\u2500 Settings # Components relating to the quick-settings, in the top-right\n\u2502 \u251c\u2500\u2500 AuthButtons.vue # Logout button and other app info\n\u2502 \u251c\u2500\u2500 ConfigLauncher.vue # Icon that when clicked will launch the Configuration component\n\u2502 \u251c\u2500\u2500 CustomThemeMaker.vue # Color pickers for letting user build their own theme\n\u2502 \u251c\u2500\u2500 ItemSizeSelector.vue # Set of buttons used to set and save item size\n\u2502 \u251c\u2500\u2500 KeyboardShortcutInfo.vue# Small pop-up displaying the available keyboard shortcuts\n\u2502 \u251c\u2500\u2500 LanguageSwitcher.vue # Dropdown in a modal for changing app language\n\u2502 \u251c\u2500\u2500 LayoutSelector.vue # Set of buttons, letting the user select their desired layout\n\u2502 \u251c\u2500\u2500 SearchBar.vue # The input field in the header, used for searching the app\n\u2502 \u251c\u2500\u2500 SettingsContainer.vue # Container that wraps all the quick-settings components\n\u2502 \u2570\u2500\u2500 ThemeSelector.vue # Drop-down menu enabling the user to select and change themes\n\u251c\u2500\u2500 main.js # Main front-end entry point\n\u251c\u2500\u2500 registerServiceWorker.js # Registers and manages service workers, for PWA apps\n\u251c\u2500\u2500 router.js # Defines all available application routes\n\u251c\u2500\u2500 styles # Directory of all globally used common SCSS styles\n\u251c\u2500\u2500 utils # Directory of re-used helper functions\n\u2502 \u251c\u2500\u2500 ArrowKeyNavigation.js # Functionality for arrow-key navigation\n\u2502 \u251c\u2500\u2500 Auth.js # Handles all authentication related actions\n\u2502 \u251c\u2500\u2500 ClickOutside.js # A directive for detecting click, used to hide dropdown, modal or context menu\n\u2502 \u251c\u2500\u2500 ConfigAccumulator.js # Central place for managing and combining config\n\u2502 \u251c\u2500\u2500 ConfigHelpers.js # Helper functions for managing configuration\n\u2502 \u251c\u2500\u2500 CloudBackup.js # Functionality for encrypting, processing and network calls\n\u2502 \u251c\u2500\u2500 ConfigSchema.json # The schema, used to validate the users conf.yml file\n\u2502 \u251c\u2500\u2500 ConfigValidator.js # A helper script that validates the config file against schema\n\u2502 \u251c\u2500\u2500 defaults.js # Global constants and their default values\n\u2502 \u251c\u2500\u2500 ErrorHandler.js # Helper function called when an error is returned\n\u2502 \u251c\u2500\u2500 JsonToYaml.js # Function that parses and converts raw JSON into valid YAML\n\u2502 \u251c\u2500\u2500 languages.js # Handles fetching, switching and validating languages\n\u2502 \u2570\u2500\u2500 ThemeHelper.js # Function that handles the fetching and setting of user themes\n\u2570\u2500\u2500 views # Directory of available pages, corresponding to available routes\n \u251c\u2500\u2500 Home.vue # The home page container\n \u251c\u2500\u2500 About.vue # About page\n \u251c\u2500\u2500 Login.vue # TAuthentication page\n \u251c\u2500\u2500 Minimal.vue # The minimal view\n \u2570\u2500\u2500 Workspace.vue # The workspace view with apps in sidebar\n")),(0,o.kt)("h3",{id:"frontend-components"},"Frontend Components"),(0,o.kt)("p",null,"All frontend code is located in the ",(0,o.kt)("inlineCode",{parentName:"p"},"./src")," directory, which is split into 5 sub-folders:"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("strong",{parentName:"li"},"Components")," - All frontend web components are located here. Each component should have a distinct, well defined and simple task, and ideally should not be too long. The components directory is organised into a series of sub-directories, representing a specific area of the application",(0,o.kt)("ul",{parentName:"li"},(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("strong",{parentName:"li"},"PageStrcture")," - Components relating to overall page structure (nav, footer, etc)"),(0,o.kt)("li",{parentName:"ul"},"FormElements - Reusable form elements (button, input field, etc)"),(0,o.kt)("li",{parentName:"ul"},"LinkItems - Components relating to Dashy's sections and items (item group, item, item icon, etc)"),(0,o.kt)("li",{parentName:"ul"},"Configuration - Components relating to Dashy's configuration forms (cloud backup, JSON editor, etc)"))),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("strong",{parentName:"li"},"Views")," - Each view directly corresponds to a route (defined in the router), and in effectively a page. They should have minimal logic, and just contain a few components"),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("strong",{parentName:"li"},"Utils")," - These are helper functions, or logic that is used within the app does not include an UI elements"),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("strong",{parentName:"li"},"Styles")," - Any SCSS that is used globally throughout that app, and is not specific to a single component goes here. This includes variables, color themes, typography settings, CSS reset and media queries"),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("strong",{parentName:"li"},"Assets")," - Static assets that need to be bundled into the application, but do not require any manipulation go here. This includes interface icons and fonts")),(0,o.kt)("p",null,"The structure of the components directory is similar to that of the frontend application layout"),(0,o.kt)("p",{align:"center"},(0,o.kt)("img",{src:"https://i.ibb.co/wJCt0Lq/dashy-page-structure.png",width:"600"})),(0,o.kt)("hr",null),(0,o.kt)("h2",{id:"development-tools"},"Development Tools"),(0,o.kt)("h3",{id:"performance---lighthouse"},"Performance - Lighthouse"),(0,o.kt)("p",null,"The easiest method of checking performance is to use Chromium's build in auditing tool, Lighthouse. To run the test, open Developer Tools (usually F12) --\x3e Lighthouse and click on the 'Generate Report' button at the bottom."),(0,o.kt)("h3",{id:"dependencies---bundlephobia"},"Dependencies - BundlePhobia"),(0,o.kt)("p",null,(0,o.kt)("a",{parentName:"p",href:"https://bundlephobia.com/"},"BundlePhobia")," is a really useful app that lets you analyze the cost of adding any particular dependency to an application"),(0,o.kt)("hr",null),(0,o.kt)("h2",{id:"notes"},"Notes"),(0,o.kt)("h3",{id:"known-warnings"},"Known Warnings"),(0,o.kt)("p",null,"When running the build command, several warnings appear. These are not errors, and do not affect the security or performance of the application. They will be addressed in a future update"),(0,o.kt)("p",null,(0,o.kt)("inlineCode",{parentName:"p"},"WARN A new version of sass-loader is available. Please upgrade for best experience.")," - Currently we're using an older version of SASS loader, since the more recent releases do not seem to be compatible with the Vue CLI's webpack configuration."),(0,o.kt)("p",null,(0,o.kt)("inlineCode",{parentName:"p"},"WARN asset size limit: The following asset(s) exceed the recommended size limit (244 KiB).")," - For the PWA to support Windows 10, a splash screen asset is required, and is quite large. This throws a warning, however PWA assets are not loaded until needed, so shouldn't have any impact on application performance. A similar warning is thrown for the Raleway font, and that is looking to be addressed."),(0,o.kt)("p",null,(0,o.kt)("inlineCode",{parentName:"p"},"glob-parent Security Alert")," - This will be fixed soon. The version of glob-parent that is used by the latest version of Vue-CLI has a security issue associated with it. I am waiting on Vue to update their dependencies."))}c.isMDXComponent=!0}}]);