Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/clan-scrape
Browse files Browse the repository at this point in the history
  • Loading branch information
fcaps committed Nov 27, 2023
2 parents c267cda + 9d5de76 commit 7b88d17
Show file tree
Hide file tree
Showing 49 changed files with 1,893 additions and 717 deletions.
7 changes: 7 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"root": true,
"extends": ["standard"],
"rules": {
"indent": ["error", 4]
}
}
6 changes: 4 additions & 2 deletions .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ jobs:
node-version: '20'
cache: 'yarn'
- run: yarn install
# --force should be removed if all the issues are fixed
- run: ./node_modules/.bin/grunt jshint --force
- run: npx webpack
- run: yarn run lint
continue-on-error: true # should be removed if all the issues are fixed
- run: yarn run test
- uses: codecov/codecov-action@v3
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ public/js/*.js

#Sessions
sessions

dist
66 changes: 0 additions & 66 deletions .jshintrc

This file was deleted.

3 changes: 0 additions & 3 deletions .npmcheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@ depcheck:
"grunt-postcss",
"grunt-nodemon",
"grunt-contrib-watch",
"grunt-contrib-uglify-es",
"grunt-contrib-jshint",
"grunt-contrib-concat",
"grunt-concurrent"
]
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ COPY . /code
WORKDIR /code

RUN yarn install --production=false --frozen-lockfile
RUN npx webpack
RUN ./node_modules/.bin/grunt prod
RUN yarn install --production=true --ignore-optional --frozen-lockfile

Expand Down
2 changes: 0 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ module.exports = function(grunt) {

grunt.registerTask('prod', [
'sass:dist',
'concat:js',
'uglify:dist',
'copy'
]);
};
6 changes: 6 additions & 0 deletions fafApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ module.exports.setup = (app) => {
maxAge: 4 * 60 * 60 * 1000 // 4 hours
}))

app.use('/dist', express.static('dist', {
immutable: true,
maxAge: 4 * 60 * 60 * 1000 // 4 hours, could be longer since we got cache-busting
}))

app.use(express.json())
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: false}))
Expand All @@ -138,5 +143,6 @@ module.exports.setup = (app) => {

app.use(flash())
app.use(middleware.populatePugGlobals)
app.use(middleware.webpackAsset)
app.use(copyFlashHandler)
}
17 changes: 0 additions & 17 deletions grunt/concat.js

This file was deleted.

2 changes: 1 addition & 1 deletion grunt/concurrent.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
dev: {
tasks: ['nodemon', 'concat', 'watch', 'copy', 'sass:dev'],
tasks: [['run:webpack','copy', 'sass:dev','nodemon'], 'watch'],
options: {
logConcurrentOutput: true
}
Expand Down
26 changes: 0 additions & 26 deletions grunt/jshint.js

This file was deleted.

1 change: 1 addition & 0 deletions grunt/nodemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
options: {
delay: 500,
ignore: [
'dist/js/*.js',
'sessions/**',
'node_modules/**',
'grunt/**',
Expand Down
5 changes: 5 additions & 0 deletions grunt/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
webpack: {
args: ['node_modules/.bin/webpack'],
}
};
11 changes: 0 additions & 11 deletions grunt/uglify.js

This file was deleted.

21 changes: 4 additions & 17 deletions grunt/watch.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
module.exports = {
js: {
files: [
'public/js/app/*.js'
],
tasks: ['concat:js'],
},
express: {
files: [
'routes/**/*.js',
'express.js',
]
},
webpack: {
files: ['src/frontend/**/*.js'],
tasks: ['run:webpack']
},
sass: {
files: ['public/styles/**/*.{scss,sass}'],
tasks: ['sass:dev']
},
livereload: {
files: [
'public/styles/**/*.css'
],
}
};
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const config = {
collectCoverage: true,
coverageReporters: ['text', 'cobertura'],
setupFilesAfterEnv: ['./tests/setup.js'],
};

Expand Down
21 changes: 14 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,25 @@
"devDependencies": {
"awesomplete": "^1.1.5",
"dart-sass": "^1.25.0",
"eslint": "^8.54.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-n": "^16.3.1",
"eslint-plugin-promise": "^6.1.1",
"grunt": "1.6.1",
"grunt-concurrent": "3.0.0",
"grunt-contrib-concat": "^2.1.0",
"grunt-contrib-jshint": "^3.2.0",
"grunt-contrib-uglify-es": "3.3.0",
"grunt-contrib-watch": "^1.1.0",
"grunt-nodemon": "^0.4.2",
"grunt-postcss": "0.9.0",
"grunt-run": "^0.8.1",
"grunt-sass": "3.1.0",
"jest": "^29.7.0",
"jshint-stylish": "2.2.1",
"load-grunt-config": "4.0.1",
"load-grunt-tasks": "5.1.0",
"octokit": "^3.1.2",
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4",
"webpack-manifest-plugin": "^5.0.0"
"nock": "^13.3.8",
"supertest": "^6.3.3"
},
Expand All @@ -52,7 +58,8 @@
},
"scripts": {
"start": "node express.js",
"test": "jest"
},
"main": "express.js"
"test": "jest",
"lint": "eslint --ignore-path .gitignore src tests",
"lint:fix": "eslint --fix --ignore-path .gitignore src tests"
}
}
14 changes: 14 additions & 0 deletions routes/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const ClanRepository = require("../lib/clan/ClanRepository")
const UserService = require("../lib/UserService");
const UserRepository = require("../lib/UserRepository");
const wordpressService = WordpressServiceFactory(appConfig.wordpressUrl)
const fs = require('fs');
const webpackManifestJS = JSON.parse(fs.readFileSync('dist/js/manifest.json', 'utf8'));

exports.initLocals = function(req, res, next) {
let locals = res.locals;
Expand All @@ -17,6 +19,18 @@ exports.initLocals = function(req, res, next) {
next();
};

exports.webpackAsset = (req, res, next) => {
res.locals.webpackAssetJS = (asset) => {
if (asset in webpackManifestJS) {
return webpackManifestJS[asset]
}

throw new Error('[error] middleware::webpackAsset Failed to find asset "' + asset + '"')
}

next()
}

exports.populatePugGlobals = function(req, res, next) {
res.locals.loggedInUser = req.user || null

Expand Down
6 changes: 6 additions & 0 deletions src/backend/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"env": {
"node": true,
"es2020": true
}
}
6 changes: 6 additions & 0 deletions src/frontend/js/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"env": {
"browser": true,
"es2020": true
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Octokit} from "https://esm.sh/@octokit/core";
import {Octokit} from "octokit";

const githubOrg = 'faforever'
const githubRepository = 'downlords-faf-client'
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion templates/layouts/default.pug
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ html(lang='en')
li
a(href='https://forum.faforever.com/') FORUMS

script(src="../../js/app/navigation.js")
script(src=webpackAssetJS('navigation'))

//- Include template-specific javascript files by extending the js block
block js
Expand Down
4 changes: 0 additions & 4 deletions templates/views/account/activate.pug
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,3 @@ block content
br
br
br


block js
script(src='/js/account.min.js')
3 changes: 0 additions & 3 deletions templates/views/account/changeEmail.pug
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@ block content
+currentPassword
.form-actions
button(type='submit').btn.btn-default.btn-lg.btn-outro.btn-danger Change Email

block js
script(src='/js/account.min.js')
2 changes: 0 additions & 2 deletions templates/views/account/changeUsername.pug
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ block content
+username
.form-actions
button(type='submit').btn.btn-default.btn-lg.btn-outro.btn-danger Change
block js
script(src='/js/account.min.js')
3 changes: 0 additions & 3 deletions templates/views/account/confirmPasswordReset.pug
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,3 @@ block content
+confirm-password
.form-actions
button(type='submit').btn.btn-default.btn-lg.btn-outro.btn-danger Reset

block js
script(src='/js/account.min.js')
4 changes: 0 additions & 4 deletions templates/views/account/linkGog.pug
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,3 @@ block content
h2 Why do I need to link my Steam/GOG account to FAF?
p FAF as an organization doesn't own the copyright or trademark to SC:FA (Square Enix does). <br> Therefore, we need to verify you own a copy of SC:FA to prevent piracy.
p Linking your GOG account to FAF doesn't provide us with any information or powers over your account. <br> Only the fact that you own Supreme Commander: Forged Alliance. <br> Which is why we need you to set your Game Details to public when linking your account.


block js
script(src='/js/account.min.js')
6 changes: 0 additions & 6 deletions templates/views/account/linkSteam.pug
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,3 @@ block content
h2 Why do I need to link my Steam/GOG account to FAF?
p FAF as an organization doesn't own the copyright or trademark to SC:FA (Square Enix does). <br> Therefore, we need to verify you own a copy of SC:FA to prevent piracy.
p Linking your steam account to FAF doesn't provide us with any information or powers over your account. <br> Only the fact that you own Supreme Commander: Forged Alliance. <br> Which is why we need you to set your Game Details to public when linking your account.




block js
script(src='/js/account.min.js')
Loading

0 comments on commit 7b88d17

Please sign in to comment.