chore(client): refactor & organise config (#40875)

This commit is contained in:
Oliver Eyton-Williams
2021-02-03 10:52:07 +01:00
committed by GitHub
parent c1f9cd93f5
commit fffc0e51ec
32 changed files with 36 additions and 39 deletions

7
.gitignore vendored
View File

@ -154,13 +154,18 @@ jspm_packages/
### Netlify ###
.netlify
### Generated config files ###
config/env.json
config/client/sass-compile.json
config/client/frame-runner.json
config/client/test-evaluator.json
### Additional Files ###
*.csv
*.dat
*.out
*.gz
*.swp
env.json
curriculum/curricula.json
client/static/js/frame-runner.js
client/static/js/frame-runner.js.map

5
client/.gitignore vendored
View File

@ -3,11 +3,6 @@
node_modules
yarn-error.log
config/env.json
config/frame-runner.json
config/sass-compile.json
config/test-evaluator.json
# Build directory
/public
.DS_Store

View File

@ -1 +0,0 @@
# this file is here to add an empty dir to git

View File

@ -4,7 +4,8 @@ const {
clientLocale,
curriculumLocale,
homeLocation
} = require('../config/env');
} = require('../config/env.json');
const {
buildChallenges,
replaceChallengeNode,

View File

@ -1,8 +1,8 @@
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
const { clientLocale } = require('../config/env');
const { i18nextCodes } = require('./allLangs');
import { clientLocale } from '../../config/env.json';
import { i18nextCodes } from './allLangs';
const i18nextCode = i18nextCodes[clientLocale];

View File

@ -4,7 +4,7 @@ const React = require('react');
const gatsby = jest.requireActual('gatsby');
const { clientLocale } = require('../../config/env');
const { clientLocale } = require('../../../config/env.json');
module.exports = {
...gatsby,

View File

@ -5,7 +5,7 @@ import { createSelector } from 'reselect';
import { Grid, Button } from '@freecodecamp/react-bootstrap';
import Helmet from 'react-helmet';
import { apiLocation } from '../../config/env.json';
import { apiLocation } from '../../../config/env.json';
import {
signInLoadingSelector,
userSelector,

View File

@ -1,7 +1,7 @@
/* global jest, expect */
import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow';
import { apiLocation } from '../../config/env.json';
import { apiLocation } from '../../../config/env.json';
import { ShowSettings } from './ShowSettings';

View File

@ -4,7 +4,7 @@ import { Grid, Panel, Button } from '@freecodecamp/react-bootstrap';
import Helmet from 'react-helmet';
import { useTranslation } from 'react-i18next';
import env from '../../config/env.json';
import env from '../../../config/env.json';
import FullWidthRow from '../components/helpers/FullWidthRow';
import { Spacer } from '../components/helpers';

View File

@ -24,10 +24,9 @@ import {
donationUrls,
modalDefaultDonation
} from '../../../../config/donation-settings';
import { stripePublicKey } from '../../../../config/env.json';
import { stripePublicKey, deploymentEnv } from '../../../../config/env.json';
import { stripeScriptLoader } from '../../utils/scriptLoaders';
import DonateFormChildViewForHOC from './DonateFormChildViewForHOC';
import { deploymentEnv } from '../../../config/env.json';
import Spacer from '../helpers/Spacer';
import PaypalButton from './PaypalButton';
import DonateCompletion from './DonateCompletion';

View File

@ -7,7 +7,7 @@ import { createSelector } from 'reselect';
import PayPalButtonScriptLoader from './PayPalButtonScriptLoader';
import { withTranslation } from 'react-i18next';
import { paypalClientId, deploymentEnv } from '../../../config/env.json';
import { paypalClientId, deploymentEnv } from '../../../../config/env.json';
import {
paypalConfigurator,
paypalConfigTypes

View File

@ -6,7 +6,7 @@ import { Button } from '@freecodecamp/react-bootstrap';
import { useTranslation } from 'react-i18next';
import { isSignedInSelector } from '../../../redux';
import { apiLocation, homeLocation } from '../../../../config/env.json';
import { apiLocation, homeLocation } from '../../../../../config/env.json';
import './login.css';

View File

@ -1,6 +1,6 @@
import React from 'react';
import { Link, Spacer } from '../../helpers';
import { forumLocation } from '../../../../config/env.json';
import { forumLocation } from '../../../../../config/env.json';
import { Trans, useTranslation } from 'react-i18next';
import '../intro.css';

View File

@ -1,4 +1,4 @@
import { forumLocation } from '../../config/env.json';
import { forumLocation } from '../../../config/env.json';
const createExternalRedirect = (page, { clientLocale }) => {
const isNotEnglish = clientLocale !== 'english';

View File

@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { apiLocation } from '../../../config/env.json';
import { apiLocation } from '../../../../config/env.json';
const currentChallengeApi = '/challenges/current-challenge';

View File

@ -11,7 +11,7 @@ import HeatMap from './components/HeatMap';
import Certifications from './components/Certifications';
import Portfolio from './components/Portfolio';
import Timeline from './components/TimeLine';
import { apiLocation } from '../../../config/env.json';
import { apiLocation } from '../../../../config/env.json';
const propTypes = {
isSessionUser: PropTypes.bool,

View File

@ -16,7 +16,7 @@ import Link from '../../helpers/Link';
import './camper.css';
import { langCodes } from '../../../../i18n/allLangs';
import { clientLocale } from '../../../../config/env';
import { clientLocale } from '../../../../../config/env.json';
const localeCode = langCodes[clientLocale];

View File

@ -16,7 +16,7 @@ import '@freecodecamp/react-calendar-heatmap/dist/styles.css';
import './heatmap.css';
import { langCodes } from '../../../../i18n/allLangs';
import { clientLocale } from '../../../../config/env';
import { clientLocale } from '../../../../../config/env.json';
const localeCode = langCodes[clientLocale];

View File

@ -25,7 +25,7 @@ import { maybeUrlRE } from '../../../utils';
import CertificationIcon from '../../../assets/icons/CertificationIcon';
import { langCodes } from '../../../../i18n/allLangs';
import { clientLocale } from '../../../../config/env';
import { clientLocale } from '../../../../../config/env.json';
const localeCode = langCodes[clientLocale];

View File

@ -15,7 +15,7 @@ import {
toggleSearchDropdown,
updateSearchQuery
} from './redux';
import { algoliaAppId, algoliaAPIKey } from '../../../config/env.json';
import { algoliaAppId, algoliaAPIKey } from '../../../../config/env.json';
import { createSelector } from 'reselect';

View File

@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import { first } from 'lodash';
import EditorTabs from './EditorTabs';
import ActionRow from './ActionRow';
import { showUpcomingChanges } from '../../../../config/env.json';
import { showUpcomingChanges } from '../../../../../config/env.json';
const propTypes = {
challengeFiles: PropTypes.object,

View File

@ -8,7 +8,7 @@ import { createStructuredSelector } from 'reselect';
import { currentTabSelector, moveToTab } from '../redux';
import { bindActionCreators } from 'redux';
import EditorTabs from './EditorTabs';
import { showUpcomingChanges } from '../../../../config/env.json';
import { showUpcomingChanges } from '../../../../../config/env.json';
const mapStateToProps = createStructuredSelector({
currentTab: currentTabSelector

View File

@ -7,7 +7,7 @@ import { Trans, withTranslation } from 'react-i18next';
import { createQuestion, closeModal, isHelpModalOpenSelector } from '../redux';
import { executeGA } from '../../../redux';
import { forumLocation } from '../../../../config/env.json';
import { forumLocation } from '../../../../../config/env.json';
import './help-modal.css';

View File

@ -17,7 +17,7 @@ import createWorker from '../utils/worker-executor';
// the config files are created during the build, but not before linting
// eslint-disable-next-line import/no-unresolved
import { filename as sassCompile } from '../../../../config/sass-compile';
import { filename as sassCompile } from '../../../../../config/client/sass-compile';
const protectTimeout = 100;
const testProtectTimeout = 1500;

View File

@ -10,9 +10,9 @@ import {
// the config files are created during the build, but not before linting
// eslint-disable-next-line import/no-unresolved
import { filename as runner } from '../../../../config/frame-runner';
import { filename as runner } from '../../../../../config/client/frame-runner';
// eslint-disable-next-line import/no-unresolved
import { filename as testEvaluator } from '../../../../config/test-evaluator';
import { filename as testEvaluator } from '../../../../../config/client/test-evaluator';
const frameRunner = [
{

View File

@ -1,4 +1,4 @@
import { apiLocation } from '../../config/env.json';
import { apiLocation } from '../../../config/env.json';
import axios from 'axios';
import Tokens from 'csrf';
import cookies from 'browser-cookies';

View File

@ -1,4 +1,4 @@
const config = require('../../config/env');
const config = require('../../../config/env.json');
const words = require(`../../i18n/locales/${config.clientLocale}/motivation.json`);

View File

@ -6,7 +6,7 @@ const {
challengesDir,
getChallengesDirForLang
} = require('../../curriculum/getChallenges');
const { curriculumLocale } = require('../config/env.json');
const { curriculumLocale } = require('../../config/env.json');
exports.localeChallengesRootDir = getChallengesDirForLang(curriculumLocale);

View File

@ -5,7 +5,7 @@ const { writeFileSync } = require('fs');
module.exports = (env = {}) => {
const __DEV__ = env.production !== true;
const staticPath = path.join(__dirname, './static/js');
const configPath = path.join(__dirname, './config');
const configPath = path.join(__dirname, '../config/client');
return {
mode: __DEV__ ? 'development' : 'production',
entry: {

0
config/client/.gitkeep Normal file
View File

View File

@ -60,7 +60,7 @@ const TRANSLATABLE_COMMENTS = getTranslatableComments(
path.resolve(__dirname, '..', 'dictionaries')
);
const testEvaluator = require('../../client/config/test-evaluator').filename;
const testEvaluator = require('../../config/client/test-evaluator').filename;
const commentExtractors = {
html: require('./utils/extract-html-comments'),

View File

@ -4,7 +4,6 @@ const path = require('path');
const env = require('../../../config/env');
const { availableLangs } = require('../../../client/i18n/allLangs');
const clientPath = path.resolve(__dirname, '../../../client');
const globalConfigPath = path.resolve(__dirname, '../../../config');
const { FREECODECAMP_NODE_ENV } = process.env;
@ -104,5 +103,4 @@ if (FREECODECAMP_NODE_ENV !== 'development') {
checkCurriculumLocale();
}
fs.writeFileSync(`${clientPath}/config/env.json`, JSON.stringify(env));
fs.writeFileSync(`${globalConfigPath}/env.json`, JSON.stringify(env));