diff --git a/.gitignore b/.gitignore index 899ef2e..8309bc6 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ debian/*-stamp debian/*.substvars debian/tmp .DS_Store +node_modules diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..0442f2e --- /dev/null +++ b/.prettierignore @@ -0,0 +1,10 @@ +node_modules/ +macos/ +debian/ +build/ +package.nw/lib/ol.js +package.nw/lib/moment-with-locales.js +package.nw/lib/moment-timezone-with-data.js +package.nw/lib/datepicker.js +package.nw/lib/third-party.js + diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..1cbe686 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,11 @@ +{ + "printWidth": 80, + "overrides": [ + { + "files": ["*.html"], + "options": { + "printWidth": 120 + } + } + ] +} diff --git a/README.md b/README.md index 6765ff8..2f6a2b5 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,29 @@ # Developing GridTracker -GridTracker runs using [NWJS](https://nwjs.io/), a tools that wraps both Chrome windows and node processes into a native application. +GridTracker runs using [NWJS](https://nwjs.io/), a tools that wraps both Chrome windows and node processes into +a native application. To work on GridTracker you need to clone this git repository and then invoke NWJS with the contents of `package.nw`. -NWJS comes in two flavors, "normal" and "sdk". GridTracker is distributed with the normal flavor, but for development work -we recommend the SDK flavor because it provides access to Chrome's Developer Tools, among other things. +NWJS comes in two flavors, "normal" and "sdk". GridTracker is distributed with the normal flavor, +but for development work we recommend the SDK flavor because it provides access to Chrome's Developer Tools, +among other things. + +### Code Formatting +We use `prettier` to enforce code formatting rules, and we follow +the [JavaScript Standard Style](https://standardjs.com/) + +You can use all kinds of plugins and configurations in your text editor to verify these rules, and even reformat code +automatically, but if you want to run on the command line, you can (after running `npm install`) run the +`npm run prettier-check` command to verify the formatting of all files, or `npm run prettier-write` to reformat +all files to match the standard. + +If you want to know more about why these tools are useful, +[watch this talk](https://www.youtube.com/watch?v=kuHfMw8j4xk) + + +# Developer Environment Setup ## Developing on Windows @@ -19,7 +36,7 @@ To access the Developer Tools, right-click on an unused area of a window, or pre ## Developing on Mac -We suggest using the `macos/run.sh` script to launch GridTracker while developing. It will download the sdk flavor of NWJS if needed, -and use it to run the app. +We suggest using the `macos/run.sh` script to launch GridTracker while developing. It will download the sdk flavor +of NWJS if needed, and use it to run the app. To access the Developer Tools, right-click on an unused area of a window, or press F12. diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..35223c4 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,13 @@ +{ + "name": "gridtracker-development", + "requires": true, + "lockfileVersion": 1, + "dependencies": { + "prettier": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz", + "integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==", + "dev": true + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..1f447aa --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "gridtracker-development", + "devDependencies": { + "prettier": "2.1.2" + }, + "scripts": { + "test": "npm run prettier-check", + "prettier-check": "npx prettier --check package.nw", + "prettier-write": "npx prettier --write package.nw" + } +}