Merge pull request #522 from typerqeo/use-gulp

Adding a build process to MT development
This commit is contained in:
Jack 2020-11-04 00:36:28 +00:00 committed by GitHub
commit cada6842bc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 5377 additions and 379 deletions

7
.gitignore vendored
View file

@ -68,9 +68,7 @@ node_modules/
.vscode
*.code-workspace
#css
public/css/style.css
public/css/style.css.map
#firebase
functions/serviceAccountKey.json
functions/serviceAccountKey_live.json
functions/serviceAccountKey_copy.json
@ -80,4 +78,5 @@ functions/serviceAccountKey_live_copy.json
functions/serviceAccountKey_copy.json
functions/serviceAccountKey_live_copy.json
public/css/style.min.css
#generated files
dist/

View file

@ -5,19 +5,17 @@
- NodeJS v10
- Firebase
## Project Setup
## Prerequisite - Firebase Setup
1. [Create a new Firebase project.](https://console.firebase.google.com/u/0/)
- The project name doesn't really matter, but just name it `monkeytype`.
- Google Analytics is not necessary.
2. [Install the Firebase CLI](https://firebase.google.com/docs/cli)
3. Run `firebase login` on your terminal to log in to the same google account as you just used to create the project.
4. Git clone this project.
5. Run `npm install`
6. Compile `public/css/style.scss` to `public/css/style.min.css` as [described below](https://github.com/Miodec/monkeytype/blob/master/CONTRIBUTING.md#standards--conventions)
7. Rename `.firebaserc_example` to `.firebaserc` and change the project name of default to the firebase project id you just created.
1. [Install the Firebase CLI](https://firebase.google.com/docs/cli)
1. Run `firebase login` on your terminal to log in to the same google account as you just used to create the project.
1. Git clone this project.
1. Rename `.firebaserc_example` to `.firebaserc` and change the project name of default to the firebase project id you just created.
- If `.firebaserc_example` does not exist after cloning, create your own with:
@ -31,37 +29,21 @@
- Run `firebase projects:list` to find your firebase project id.
8. Generate a Firebase Admin private key
1. Generate a Firebase Admin private key
- In your Firebase console, go to Project Settings > Service Accounts
- Click "Generate New Private Key"
- Save as `serviceAccountKey.json` in the `functions/` directory
9. Run `npm start` to start a local server on port 5000. Use ctrl+c to stop it.
## Building and Running
1. Run `npm install` in the project root directory to install dependencies.
1. Run `npm run start:dev` to start a local dev server on port 5000. It will watch for changes and rebuild when you edit files in `src/` or `public/`. Use ctrl+c to stop it.
- Run `firebase use default` if you run into any errors for this.
## Standards & Conventions
## Standards and Conventions
1. Use a SCSS compiler, and make sure that a `style.min.css` file is generated in the same directory as the `style.scss`. For VSCode I recommend `Easy Sass` extension by Wojciech Sura. After installing it, to configure it:
- Navigate to the VSCode settings, `Extensions` section and find `Easy Sass configuration`
- Under the `Formats` group click `edit in settings.json`
- Make sure this the code looks like this:
```json
"easysass.formats": [
{
"format": "compressed",
"extension": ".min.css"
}
],
```
_This will make sure that only a minified file is generated._
-Finally, using the command palete (`ctrl/cmd + shift + p`), use the `Compile all SCSS/SASS files in the project` option. You only need to do this once. After this the files will be compiled on save.
2. Install [Prettier](https://prettier.io/docs/en/install.html). Its a code formatter, and it will make sure that we avoid any whitespace or formatting issues when merging code.
1. Code style is enforced by [Prettier](https://prettier.io/docs/en/install.html), which is automatically run every time you `git commit` (if you've followed the above instructions properly).
## Questions

View file

@ -1,6 +1,6 @@
{
"hosting": {
"public": "public",
"public": "dist",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{

46
gulpfile.js Normal file
View file

@ -0,0 +1,46 @@
const { task, src, dest, series, watch } = require("gulp");
const concat = require("gulp-concat");
const del = require("del");
const vinylPaths = require("vinyl-paths");
var sass = require("gulp-sass");
sass.compiler = require("dart-sass");
//the order of files is important
const gulpSrc = [
"./src/js/misc.js",
"./src/js/words.js",
"./src/js/layouts.js",
"./src/js/db.js",
"./src/js/userconfig.js",
"./src/js/commandline.js",
"./src/js/leaderboards.js",
"./src/js/settings.js",
"./src/js/account.js",
"./src/js/script.js",
];
task("cat", function () {
return src(gulpSrc).pipe(concat("monkeytype.js")).pipe(dest("./dist/js"));
});
task("sass", function () {
return src("./src/sass/*.scss")
.pipe(sass({ outputStyle: "compressed" }).on("error", sass.logError))
.pipe(dest("dist/css"));
});
task("static", function () {
return src("./public/**/*").pipe(dest("./dist/"));
});
task("clean", function () {
return src("./dist/", { allowEmpty: true }).pipe(vinylPaths(del));
});
task("compile", series("static", "sass", "cat"));
task("watch", function () {
watch(["./public/**/*", "./src/**/*"], series("compile"));
});
task("build", series("clean", "compile"));

5204
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -2,17 +2,27 @@
"name": "monkeytype",
"version": "1.5.3",
"license": "GPL-3.0",
"private": true,
"scripts": {
"start": "firebase serve",
"build": "npx gulp build",
"start": "npm run build && firebase serve",
"start:dev": "npm run build && concurrently --kill-others \"npx gulp watch\" \"firebase serve\"",
"postinstall": "cd functions && npm install"
},
"engines": {
"node": "10"
},
"devDependencies": {
"concurrently": "^5.3.0",
"dart-sass": "^1.25.0",
"del": "^6.0.0",
"gulp": "^4.0.2",
"gulp-concat": "^2.6.1",
"gulp-sass": "^4.1.0",
"husky": "^4.3.0",
"prettier": "2.1.2",
"pretty-quick": "^3.1.0"
"pretty-quick": "^3.1.0",
"vinyl-paths": "^3.0.1"
},
"husky": {
"hooks": {

View file

@ -6,7 +6,7 @@
<title>Monkeytype</title>
<!-- <link rel="stylesheet" href="css/fa.css" /> -->
<link rel="stylesheet" href="css/balloon.css" />
<link rel="stylesheet" href="css/style.min.css?v=58" />
<link rel="stylesheet" href="css/style.css?v=58" />
<link rel="stylesheet" href="themes/serika_dark.css" id="currentTheme" />
<link rel="stylesheet" href="" id="funBoxTheme" />
<link id="favicon" rel="shortcut icon" href="fav.png" />
@ -2873,12 +2873,12 @@
</form>
<div
data-balloon-pos="up"
aria-label="The new domain seems to be triggering the Chrome's built in phishing detection.
aria-label="The new domain seems to be triggering the Chrome's built in phishing detection.
Basically, since you used monkey-type a lot, when chrome sees that you've entered the same credentials to a veeeery similar domain, Chrome thinks that monkeytype.com is trying to steal your information for... monkey-type.com, and labels the website as Dangerous. (even though its pointing to the same server..)
I've tested with family members and friends who don't visit the site as often or at all, and the dangerous popup was not there. Also, Google's Safe Browsing scanner classifies monkeytype.com as safe, so this leads me to believe the 'dangerous' classification is happening locally.
I've contacted Google to get this sorted out - don't worry, the site is safe."
data-balloon-length="xlarge"
style="text-align: center; margin-top: 1rem; grid-column: 1/3"
@ -3363,14 +3363,5 @@
<script src="js/chartjs-plugin-trendline.js"></script>
<script src="js/chartjs-plugin-annotation.js"></script>
<script src="js/html2canvas.min.js"></script>
<script src="js/misc.js"></script>
<script src="js/words.js"></script>
<script src="js/layouts.js"></script>
<script src="js/db.js"></script>
<script src="js/userconfig.js"></script>
<script src="js/commandline.js"></script>
<script src="js/leaderboards.js"></script>
<script src="js/settings.js"></script>
<script src="js/account.js"></script>
<script src="js/script.js"></script>
<script src="js/monkeytype.js"></script>
</html>

View file

@ -1,212 +1,212 @@
{
"name": "finnish",
"leftToRight": true,
"words": [
"mies",
"nainen",
"poika",
"tyttö",
"hallitus",
"mökki",
"Suomi",
"maailma",
"Eurooppa",
"hali",
"rakkaus",
"teko",
"murha",
"koe",
"raha",
"tappelu",
"siili",
"tuuletin",
"ihminen",
"allas",
"baari",
"ravintola",
"kuolema",
"pako",
"vankila",
"tulevaisuus",
"mahdollisuus",
"suklaa",
"karkki",
"pilkku",
"piste",
"silmä",
"lasi",
"tunneli",
"kotka",
"lisko",
"veri",
"lohi",
"peruna",
"sauna",
"peruna",
"sana",
"vene",
"järvi",
"mokkapala",
"muffinssi",
"salasana",
"testi",
"kaakao",
"palapeli",
"peli",
"suola",
"sokeri",
"armeija",
"kala",
"meri",
"joki",
"kuohu",
"matelija",
"kilpikonna",
"saari",
"maa",
"sänky",
"sarvi",
"taulu",
"matto",
"nuoli",
"ase",
"teoria",
"koomikko",
"raamattu",
"tietokone",
"mato",
"insinööri",
"ohjelmoija",
"fyysikko",
"matemaatikko",
"laatikko",
"maksalaatikko",
"seteli",
"näyttö",
"kaula",
"vampyyri",
"viikate",
"viikatemies",
"sankari",
"timantti",
"louhos",
"kulta",
"hopea",
"kauha",
"lettu",
"hillo",
"sitruuna",
"nuudeli",
"pasta",
"rauha",
"totta",
"valhe",
"veteraani",
"ruoka",
"marmeladi",
"ruotsalainen",
"suomalainen",
"pelto",
"kaupunki",
"maaseutu",
"lukio",
"yliopisto",
"tehdas",
"päästöt",
"vakava",
"rasva",
"nahka",
"salmi",
"pilvi",
"aurinko",
"yritys",
"konkurssi",
"pörssi",
"he",
"nauraa",
"tuote",
"jäte",
"hiukset",
"lapsi",
"rituaali",
"symboli",
"risti",
"patonki",
"markka",
"sota",
"ukkonen",
"lokki",
"juhla",
"uhri",
"liekki",
"rautatie",
"maito",
"rauta",
"sinkki",
"hana",
"vesi",
"makkara",
"ketsuppi",
"lauta",
"tatti",
"kamera",
"yksityiskohta",
"pensas",
"tie",
"kauppa",
"hylly",
"olut",
"lepakko",
"nunna",
"erakko",
"tuore",
"sielu",
"parta",
"tähti",
"video",
"matka",
"rahka",
"tilata",
"klassikko",
"kappale",
"linkki",
"kuulokkeet",
"ajatus",
"nurkka",
"ahdistus",
"lastenvahti",
"isä",
"perhe",
"vanhemmat",
"hevonen",
"leipä",
"luola",
"teatteri",
"sohva",
"nilkka",
"mekko",
"juoma",
"limonadi",
"uhkaava",
"nuori",
"korva",
"nenä",
"asunto",
"lukko",
"posti",
"aula",
"puhelin",
"lattia",
"selkä",
"pää",
"rinta",
"sairaala",
"sydän",
"kyyti",
"aita",
"aika",
"tulevaisuus",
"peikko",
"pelko"
]
"name": "finnish",
"leftToRight": true,
"words": [
"mies",
"nainen",
"poika",
"tyttö",
"hallitus",
"mökki",
"Suomi",
"maailma",
"Eurooppa",
"hali",
"rakkaus",
"teko",
"murha",
"koe",
"raha",
"tappelu",
"siili",
"tuuletin",
"ihminen",
"allas",
"baari",
"ravintola",
"kuolema",
"pako",
"vankila",
"tulevaisuus",
"mahdollisuus",
"suklaa",
"karkki",
"pilkku",
"piste",
"silmä",
"lasi",
"tunneli",
"kotka",
"lisko",
"veri",
"lohi",
"peruna",
"sauna",
"peruna",
"sana",
"vene",
"järvi",
"mokkapala",
"muffinssi",
"salasana",
"testi",
"kaakao",
"palapeli",
"peli",
"suola",
"sokeri",
"armeija",
"kala",
"meri",
"joki",
"kuohu",
"matelija",
"kilpikonna",
"saari",
"maa",
"sänky",
"sarvi",
"taulu",
"matto",
"nuoli",
"ase",
"teoria",
"koomikko",
"raamattu",
"tietokone",
"mato",
"insinööri",
"ohjelmoija",
"fyysikko",
"matemaatikko",
"laatikko",
"maksalaatikko",
"seteli",
"näyttö",
"kaula",
"vampyyri",
"viikate",
"viikatemies",
"sankari",
"timantti",
"louhos",
"kulta",
"hopea",
"kauha",
"lettu",
"hillo",
"sitruuna",
"nuudeli",
"pasta",
"rauha",
"totta",
"valhe",
"veteraani",
"ruoka",
"marmeladi",
"ruotsalainen",
"suomalainen",
"pelto",
"kaupunki",
"maaseutu",
"lukio",
"yliopisto",
"tehdas",
"päästöt",
"vakava",
"rasva",
"nahka",
"salmi",
"pilvi",
"aurinko",
"yritys",
"konkurssi",
"pörssi",
"he",
"nauraa",
"tuote",
"jäte",
"hiukset",
"lapsi",
"rituaali",
"symboli",
"risti",
"patonki",
"markka",
"sota",
"ukkonen",
"lokki",
"juhla",
"uhri",
"liekki",
"rautatie",
"maito",
"rauta",
"sinkki",
"hana",
"vesi",
"makkara",
"ketsuppi",
"lauta",
"tatti",
"kamera",
"yksityiskohta",
"pensas",
"tie",
"kauppa",
"hylly",
"olut",
"lepakko",
"nunna",
"erakko",
"tuore",
"sielu",
"parta",
"tähti",
"video",
"matka",
"rahka",
"tilata",
"klassikko",
"kappale",
"linkki",
"kuulokkeet",
"ajatus",
"nurkka",
"ahdistus",
"lastenvahti",
"isä",
"perhe",
"vanhemmat",
"hevonen",
"leipä",
"luola",
"teatteri",
"sohva",
"nilkka",
"mekko",
"juoma",
"limonadi",
"uhkaava",
"nuori",
"korva",
"nenä",
"asunto",
"lukko",
"posti",
"aula",
"puhelin",
"lattia",
"selkä",
"pää",
"rinta",
"sairaala",
"sydän",
"kyyti",
"aita",
"aika",
"tulevaisuus",
"peikko",
"pelko"
]
}

View file

@ -1,5 +1,5 @@
const db = firebase.firestore();
db.settings({experimentalForceLongPolling: true});
db.settings({ experimentalForceLongPolling: true });
let dbSnapshot = null;