* feat: initial button setup client * feat: rename walletsButton to .tsx * chore: typescriptize wallet component * chore: re-add keys to config, env, etc + check in gatsby-node * feat: refactor donate form and wallet component * feat(client): set labels correctly * chore: add stripe package back to server * chore: add stripe back to allowed paths * chore: copy donate.js code from PR #41924 * feat: attempt to make back end work * feat: make redux work * feat: clean up * feat: hokify * feat: add error handling * fix: back-end should be working * fix: type errors * fix: clean up back-end * feat:addd styles * feat: connect the client to the api * feat: display wallets button everywhere * test: add stripe key for cypress action * test: fix for cypress tests * test: cypress tests again * test: maybe? * test: more * test: more * test: more * test * askdfjasklfj * fix: tests finally? * revert: remove space from cypress yaml action * remove logs Co-authored-by: moT01 <20648924+moT01@users.noreply.github.com> Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
		
			
				
	
	
		
			107 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			107 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
const fs = require('fs');
 | 
						|
const path = require('path');
 | 
						|
 | 
						|
const { availableLangs } = require('../../../config/i18n/all-langs');
 | 
						|
const env = require('../../../config/read-env');
 | 
						|
 | 
						|
const globalConfigPath = path.resolve(__dirname, '../../../config');
 | 
						|
 | 
						|
const { FREECODECAMP_NODE_ENV } = process.env;
 | 
						|
 | 
						|
function checkClientLocale() {
 | 
						|
  if (!availableLangs.client.includes(process.env.CLIENT_LOCALE)) {
 | 
						|
    throw Error(`
 | 
						|
 | 
						|
      CLIENT_LOCALE, ${process.env.CLIENT_LOCALE}, is not an available language in config/i18n/all-langs.js
 | 
						|
 | 
						|
      `);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
function checkCurriculumLocale() {
 | 
						|
  if (!availableLangs.curriculum.includes(process.env.CURRICULUM_LOCALE)) {
 | 
						|
    throw Error(`
 | 
						|
 | 
						|
      CURRICULUM_LOCALE, ${process.env.CURRICULUM_LOCALE}, is not an available language in config/i18n/all-langs.js
 | 
						|
 | 
						|
      `);
 | 
						|
  }
 | 
						|
}
 | 
						|
 | 
						|
if (FREECODECAMP_NODE_ENV !== 'development') {
 | 
						|
  const locationKeys = [
 | 
						|
    'homeLocation',
 | 
						|
    'apiLocation',
 | 
						|
    'forumLocation',
 | 
						|
    'newsLocation',
 | 
						|
    'radioLocation'
 | 
						|
  ];
 | 
						|
  const deploymentKeys = [
 | 
						|
    'clientLocale',
 | 
						|
    'curriculumLocale',
 | 
						|
    'showLocaleDropdownMenu',
 | 
						|
    'deploymentEnv',
 | 
						|
    'environment',
 | 
						|
    'showUpcomingChanges'
 | 
						|
  ];
 | 
						|
  const searchKeys = ['algoliaAppId', 'algoliaAPIKey'];
 | 
						|
  const donationKeys = ['stripePublicKey', 'paypalClientId'];
 | 
						|
 | 
						|
  const expectedVariables = locationKeys.concat(
 | 
						|
    deploymentKeys,
 | 
						|
    searchKeys,
 | 
						|
    donationKeys
 | 
						|
  );
 | 
						|
  const receivedvariables = Object.keys(env);
 | 
						|
  expectedVariables.sort();
 | 
						|
  receivedvariables.sort();
 | 
						|
  if (expectedVariables.length !== receivedvariables.length) {
 | 
						|
    throw Error(`
 | 
						|
 | 
						|
    Env. variable validation failed. Make sure these keys are used and configured.
 | 
						|
 | 
						|
    Mismatch:
 | 
						|
    ${expectedVariables
 | 
						|
      .filter(expected => !receivedvariables.includes(expected))
 | 
						|
      .concat(
 | 
						|
        receivedvariables.filter(
 | 
						|
          received => !expectedVariables.includes(received)
 | 
						|
        )
 | 
						|
      )}
 | 
						|
 | 
						|
    `);
 | 
						|
  }
 | 
						|
 | 
						|
  for (const key of expectedVariables) {
 | 
						|
    if (typeof env[key] === 'undefined' || env[key] === null) {
 | 
						|
      throw Error(`
 | 
						|
 | 
						|
      Env. variable ${key} is missing, build cannot continue
 | 
						|
 | 
						|
      `);
 | 
						|
    }
 | 
						|
  }
 | 
						|
 | 
						|
  if (env['environment'] !== 'production')
 | 
						|
    throw Error(`
 | 
						|
 | 
						|
    Production environment should be 'production'
 | 
						|
 | 
						|
    `);
 | 
						|
 | 
						|
  if (env['showUpcomingChanges'])
 | 
						|
    throw Error(`
 | 
						|
 | 
						|
    SHOW_UPCOMING_CHANGES should never be 'true' in production
 | 
						|
 | 
						|
    `);
 | 
						|
 | 
						|
  checkClientLocale();
 | 
						|
  checkCurriculumLocale();
 | 
						|
} else {
 | 
						|
  checkClientLocale();
 | 
						|
  checkCurriculumLocale();
 | 
						|
}
 | 
						|
 | 
						|
fs.writeFileSync(`${globalConfigPath}/env.json`, JSON.stringify(env));
 |