Skip to content

Commit

Permalink
Merge pull request #379 from FuelRats/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleClapton authored Oct 17, 2021
2 parents 42036cc + fef004f commit 728fcfc
Show file tree
Hide file tree
Showing 319 changed files with 9,791 additions and 10,431 deletions.
11 changes: 4 additions & 7 deletions .babelrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@ module.exports = {
{
'preset-env': {
bugfixes: true,
targets: 'defaults, not IE 11, not IE_mob 11, node 13',
},
'class-properties': {
loose: true,
targets: 'defaults, not IE 11, not IE_mob 11, node 16',
},
},
],
],
assumptions: {
setPublicClassFields: true,
},
plugins: [
[require.resolve('@fuelrats/babel-plugin-classnames'), { transformObjects: true, packageName: 'clsx' }],
[require.resolve('@babel/plugin-proposal-decorators'), { legacy: true }],
require.resolve('@babel/plugin-proposal-export-default-from'),
require.resolve('@babel/plugin-proposal-export-namespace-from'),
require.resolve('@babel/plugin-proposal-optional-catch-binding'),
],
}
17 changes: 17 additions & 0 deletions .config/ciEnv.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const COMMIT_HASH_LENGTH = 10

const ciEnv = Object.freeze({
isCi: process.env.CI,
ciId: process.env.GITHUB_RUN_ID,
server: process.env.GITHUB_SERVER_URL ?? 'https://github.com',
repository: process.env.GITHUB_REPOSITORY ?? 'fuelrats/fuelrats.com',
branch: process.env.GITHUB_REF?.replace(/^refs\/heads\//u, '')?.replace(/\//gu, '-') ?? 'develop',
commit: process.env.GITHUB_SHA?.toLowerCase(),
commitShort: process.env.GITHUB_SHA?.slice(0, COMMIT_HASH_LENGTH)?.toLowerCase(),
})





module.exports = ciEnv
40 changes: 40 additions & 0 deletions .config/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const DEFAULT_PORT = 3000

const env = Object.freeze({
appUrl: process.env.APP_URL,
proxied: process.env.APP_PROXIED,
isDev: process.env.NODE_ENV !== 'production',
port: process.env.PORT ?? DEFAULT_PORT,
fallbackUrl: process.env.FR_FALLBACK_URL ?? 'https://fallback.fuelrats.com/',
frapi: {
url: process.env.FR_API_URL ?? 'https://dev.api.fuelrats.com',
proxy: `${process.env.APP_URL}/api/fr`,
socket: process.env.FR_SOCKET_URL ?? 'wss://dev.api.fuelrats.com',
clientId: process.env.FR_API_KEY,
clientSecret: process.env.FR_API_SECRET,
},
edsm: {
url: process.env.FR_EDSM_API_URL ?? 'https://www.edsm.net',
proxy: `${process.env.APP_URL}/api/edsm`,
},
wordpress: {
url: process.env.FR_WORDPRESS_URL ?? 'https://wordpress.fuelrats.com',
proxy: `${process.env.APP_URL}/api/wp`,
},
stripe: {
url: `${process.env.APP_URL}/api/stripe`,
public: process.env.FR_STRIPE_API_PK,
secret: process.env.FR_STRIPE_API_SK,
bansFile: process.env.FR_STRIPE_BANS_FILE,
},
qms: {
url: process.env.QMS_API_URL ?? 'https://api.qms.fuelrats.dev',
token: process.env.QMS_API_TOKEN,
},
irc: {
client: process.env.FR_CLIENT_IRC_URL ?? 'https://qms.fuelrats.dev',
rat: process.env.FR_RAT_IRC_URL ?? 'https://kiwi.fuelrats.com',
},
})

module.exports = env
34 changes: 34 additions & 0 deletions .config/headers.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const nextSafe = require('next-safe')


module.exports = ({ isDev, frapi, appUrl }) => {
// Some headers are set by our reverse proxy in prod, so they should be disabled ouside of dev environments.
const defaultIfDev = isDev ? undefined : false
return () => {
return [
{
source: '/:path*',
headers: nextSafe({
isDev,
contentSecurityPolicy: {
'default-src': ["'self'", '*.fuelrats.com'],
'script-src': ["'self'", '*.stripe.com'],
'connect-src': ["'self'", 'wss://*.fuelrats.com', frapi.url, appUrl],
'object-src': ["'self'", 'data:'],
'font-src': ["'self'", 'fonts.gstatic.com'],
'style-src': ["'self'", "'unsafe-inline'", 'fonts.googleapis.com'],
'img-src': ["'self'", '*.wp.com', 'blob:', 'data:'],
'frame-src': ['https://js.stripe.com'],
'child-src': false,
'prefetch-src': false,
'worker-src': false,
},
frameOptions: defaultIfDev,
contentTypeOptions: defaultIfDev,
referrerPolicy: defaultIfDev,
xssProtection: defaultIfDev,
}),
},
]
}
}
26 changes: 26 additions & 0 deletions .config/publicRuntime.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// This information is PUBLIC. all env values are explicitly defined to prevent secret leakage.
// DO NOT BLINDLY DEFINE OBJECTS! I.E. `frapi: env.frapi,`
module.exports = (env) => {
return {
appUrl: env.appUrl,
frapi: {
url: env.frapi.proxy,
server: env.frapi.url,
socket: env.frapi.socket,
},
edsm: {
url: env.edsm.proxy,
},
wordpress: {
url: env.wordpress.proxy,
},
stripe: {
url: env.stripe.url,
public: env.stripe.public,
},
irc: {
client: env.irc.client,
rat: env.irc.rat,
},
}
}
71 changes: 71 additions & 0 deletions .config/redirects.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
module.exports = (env) => {
return () => {
return ([
{
// All IE traffic should go to fallbackUrl.
source: '/:path*',
destination: env.fallbackUrl,
permanent: false,
basePath: false,
has: [
{
type: 'header',
key: 'User-Agent',
value: '(.*Trident.*)',
},
],
},
{
// Temporary workaround so canceled donations return to donate screen
source: '/donate/cancel',
destination: '/donate',
permanent: false,
},
{
// Profile page requires a tab name in the path
source: '/profile',
destination: '/profile/overview',
permanent: true,
},
{
// Old blog used to exist at /blogs
source: '/blogs',
destination: '/blog',
permanent: true,
},
{
// get-help was used at launch of the website, but has since been changed back.
source: '/get-help',
destination: '/i-need-fuel',
permanent: true,
},
{
// Common endpoint for privacy policies
source: '/privacy',
destination: '/privacy-policy',
permanent: true,
},
{
// Lexicon is no longer local
source: '/fuel-rats-lexicon',
destination: 'https://confluence.fuelrats.com/pages/viewpage.action?pageId=3637257',
permanent: true,
basePath: false,
},
{
// statistics are no longer local
source: '/statistics',
destination: 'https://grafana.fuelrats.com',
permanent: true,
basePath: false,
},
{
// People often type this one manually into their URL bar to get to the helpdesk
source: '/help',
destination: 'https://t.fuelr.at/help',
permanent: true,
basePath: false,
},
])
}
}
25 changes: 25 additions & 0 deletions .config/rewrites.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = (env) => {
return () => {
return {
beforeFiles: [
{
// Apple demands this be on the site root, but all api routes must be in /api. oof.
source: '/apple-app-site-association',
destination: '/api/apple-app-site-association',
},
{
// Blog content dir.
source: '/wp-content/:path*',
destination: `${env.wordpress.url}/wp-content/:path*`,
},
],
fallback: [
{
// Old blog links. yikes.
source: '/:year/:month/:day/:slug',
destination: '/blog/:slug',
},
],
}
}
}
38 changes: 38 additions & 0 deletions .config/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/* eslint-disable import/no-extraneous-dependencies -- required dev dependencies are only loaded in development context */
/* eslint-disable no-param-reassign -- reassign is intended for changing configs */
const { DefinePlugin } = require('webpack')

const ciEnv = require('./ciEnv')





module.exports = () => {
return (config, opt) => {
/* Define Plugin */
config.plugins.push(new DefinePlugin({
'$$BUILD.isDev': JSON.stringify(opt.dev),
'$$BUILD.isProduction': JSON.stringify(!opt.dev && ciEnv.branch === 'release'),
'$$BUILD.branch': JSON.stringify(ciEnv.branch ?? null),
'$$BUILD.commit': JSON.stringify(ciEnv.commit ?? null),
'$$BUILD.commitShort': JSON.stringify(ciEnv.commitShort ?? ciEnv.branch),
'$$BUILD.date': JSON.stringify((new Date()).toISOString()),
'$$BUILD.url': JSON.stringify(`${ciEnv.server}/${ciEnv.repository}${ciEnv.ciId ? `/actions/runs/${ciEnv.ciId}` : ''}`),
'$$BUILD.id': JSON.stringify(opt.buildId),
'$$BUILD.nodeVersion': JSON.stringify(process.version),
}))

// Workaround to fix dev warning: https://github.com/vercel/next.js/issues/19865
config.output.hotUpdateMainFilename = 'static/webpack/[fullhash].[runtime].hot-update.json'

/* SVGR */
config.module.rules.push({
exclude: /node_modules/u,
test: /\.svg$/u,
loader: require.resolve('@svgr/webpack'),
})

return config
}
}
2 changes: 1 addition & 1 deletion .env.local.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# REQUIRED | Port to listen on.
# Port to listen on.
PORT=3000

# REQUIRED | Publicly or locally accessible URL. Leave untouched if in development.
Expand Down
57 changes: 36 additions & 21 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
const importRules = require('@fuelrats/eslint-config/core/plugin-import')
const importExtensions = require('@fuelrats/eslint-config/util/importExtensions')
const util = require('@fuelrats/eslint-config-react/util')
const { withAliasResolver } = require('@fuelrats/eslint-config/util/import')

module.exports = {
env: {
Expand All @@ -9,40 +8,56 @@ module.exports = {
},
extends: [
'@fuelrats/eslint-config',
'@fuelrats/eslint-config/plugins/fuelrats',
'@fuelrats/eslint-config-react',
'plugin:@next/next/recommended',
],
globals: {
$$BUILD: 'readonly',
fetch: 'readonly',
},
rules: {
'jsx-a11y/no-noninteractive-element-interactions': ['off'], // We intend to enable this once we refactor certain key components.
'jsdoc/require-jsdoc': ['off'], // we'll get to it someday...
'react/jsx-uses-react': ['off'],
'react/react-in-jsx-scope': ['off'],
'import/order': ['error', {
...importRules.rules['import/order'][1],
'import/order': util.extendRule('import/order', {
'newlines-between': 'always',
}],
}),
...util.disable(
'jsx-a11y/no-noninteractive-element-interactions', // We intend to enable this once we refactor certain key components.
'jsdoc/require-jsdoc', // we'll get to it someday...
'@next/next/link-passhref', // This rule is broken so just ignore it for now.
),
},
settings: {
'import/ignore': [
'.worker.js$',
],
'import/resolver': {
node: {
extensions: importExtensions,
},
alias: {
map: [['~', './src']],
extensions: importExtensions,
},
},
'import/resolver': withAliasResolver([
['~', './src'],
]),
},
overrides: [
{
files: ['src/pages/api/**/*.js'],
files: [
'.config/**/*.js',
'src/pages/api/**/*.js',
'src/util/server/**/*.js',
],
env: {
browser: false,
node: true,
},
},
{
files: ['*.worker.js'],
env: {
browser: false,
commonjs: false,
worker: true,
},
},
{
files: ['src/pages/**/*.js'],
rules: {
'@fuelrats/default-export-matches-module-name': ['off'], // Disabled in pages dir as it becomes difficult to stick to module names
},
},
],
}
Loading

0 comments on commit 728fcfc

Please sign in to comment.