fix: remove all extraneous env vars (#39443)
This commit is contained in:
committed by
GitHub
parent
cdc1a63ca8
commit
33de8a03b5
@ -14,8 +14,6 @@ const {
|
|||||||
API_LOCATION: api,
|
API_LOCATION: api,
|
||||||
FORUM_LOCATION: forum,
|
FORUM_LOCATION: forum,
|
||||||
NEWS_LOCATION: news,
|
NEWS_LOCATION: news,
|
||||||
FORUM_PROXY: forumProxy,
|
|
||||||
NEWS_PROXY: newsProxy,
|
|
||||||
LOCALE: locale,
|
LOCALE: locale,
|
||||||
STRIPE_PUBLIC_KEY: stripePublicKey,
|
STRIPE_PUBLIC_KEY: stripePublicKey,
|
||||||
SERVICEBOT_ID: servicebotId,
|
SERVICEBOT_ID: servicebotId,
|
||||||
@ -29,9 +27,7 @@ const locations = {
|
|||||||
homeLocation: home,
|
homeLocation: home,
|
||||||
apiLocation: api,
|
apiLocation: api,
|
||||||
forumLocation: forum,
|
forumLocation: forum,
|
||||||
newsLocation: news,
|
newsLocation: news
|
||||||
forumProxy: forumProxy,
|
|
||||||
newsProxy: newsProxy
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = Object.assign(locations, {
|
module.exports = Object.assign(locations, {
|
||||||
|
82
sample.env
82
sample.env
@ -1,57 +1,73 @@
|
|||||||
COMPOSE_PROJECT_NAME=freecodecamp
|
# ---------------------
|
||||||
|
# API
|
||||||
|
# ---------------------
|
||||||
|
# Database
|
||||||
MONGOHQ_URL='mongodb://localhost:27017/freecodecamp'
|
MONGOHQ_URL='mongodb://localhost:27017/freecodecamp'
|
||||||
|
|
||||||
ALGOLIA_ADMIN_KEY=123abc
|
# Logging
|
||||||
ALGOLIA_APP_ID=X5V7KWJ4RB
|
SENTRY_DSN=dsn_from_sentry_dashboard
|
||||||
ALGOLIA_API_KEY=a45d2b80c97479bbda5cf5c55914230f
|
SENTRY_ENVIRONMENT='staging'
|
||||||
|
|
||||||
AUTH0_CLIENT_ID=stuff
|
# Auth0 - OAuth 2.0 Credentials
|
||||||
AUTH0_CLIENT_SECRET=stuff
|
AUTH0_CLIENT_ID=client_id_from_auth0_dashboard
|
||||||
AUTH0_DOMAIN=stuff
|
AUTH0_CLIENT_SECRET=client_secret_from_auth0_dashboard
|
||||||
|
AUTH0_DOMAIN=example.auth0.com
|
||||||
|
|
||||||
SESSION_SECRET=secretstuff
|
# Session, Cookie and JWT encryption strings
|
||||||
COOKIE_SECRET='this is a secret'
|
SESSION_SECRET=a_session_secret
|
||||||
JWT_SECRET='a very long secret'
|
COOKIE_SECRET=a_cookie_secret
|
||||||
|
JWT_SECRET=a_jwt_secret
|
||||||
|
|
||||||
|
# ---------------------
|
||||||
|
# Search
|
||||||
|
# ---------------------
|
||||||
|
# Indexing
|
||||||
|
ALGOLIA_ADMIN_KEY=admin_key_from_algolia_dashboard
|
||||||
|
GHOST_CLIENT_KEY=client_key_from_ghost_dashboard
|
||||||
|
# Client Search Bar
|
||||||
|
ALGOLIA_APP_ID=app_id_from_algolia_dashboard
|
||||||
|
ALGOLIA_API_KEY=api_key_from_algolia_dashboard
|
||||||
|
|
||||||
|
# ---------------------
|
||||||
|
# Donations
|
||||||
|
# ---------------------
|
||||||
|
# Stripe
|
||||||
STRIPE_CREATE_PLANS=true
|
STRIPE_CREATE_PLANS=true
|
||||||
STRIPE_PUBLIC_KEY=pk_from_stripe_dashboard
|
STRIPE_PUBLIC_KEY=pk_from_stripe_dashboard
|
||||||
STRIPE_SECRET_KEY=sk_from_stripe_dashboard
|
STRIPE_SECRET_KEY=sk_from_stripe_dashboard
|
||||||
SERVICEBOT_ID=servicebot_id_from_servicebot_dashboard
|
SERVICEBOT_ID=servicebot_id_from_servicebot_dashboard
|
||||||
SERVICEBOT_HMAC_SECRET_KEY=secret_key_from_servicebot_dashboard
|
SERVICEBOT_HMAC_SECRET_KEY=secret_key_from_servicebot_dashboard
|
||||||
|
# PayPal
|
||||||
PAYPAL_SUPPORTERS=1703
|
PAYPAL_SUPPORTERS=1703
|
||||||
|
|
||||||
PAYPAL_CLIENT_ID=id_from_paypal_dashboard
|
PAYPAL_CLIENT_ID=id_from_paypal_dashboard
|
||||||
PAYPAL_SECRET=secret_from_paypal_dashboard
|
PAYPAL_SECRET=secret_from_paypal_dashboard
|
||||||
PAYPAL_VERIFY_WEBHOOK_URL='https://api.sandbox.paypal.com/v1/notifications/verify-webhook-signature'
|
PAYPAL_VERIFY_WEBHOOK_URL='https://api.sandbox.paypal.com/v1/notifications/verify-webhook-signature'
|
||||||
PAYPAL_API_TOKEN_URL='https://api.sandbox.paypal.com/v1/oauth2/token'
|
PAYPAL_API_TOKEN_URL='https://api.sandbox.paypal.com/v1/oauth2/token'
|
||||||
PAYPAL_WEBHOOK_ID=webhook_id_from_paypal_dashboard
|
PAYPAL_WEBHOOK_ID=webhook_id_from_paypal_dashboard
|
||||||
|
|
||||||
|
# ---------------------
|
||||||
|
# Build variants
|
||||||
|
# ---------------------
|
||||||
DEPLOYMENT_ENV='staging'
|
DEPLOYMENT_ENV='staging'
|
||||||
|
FREECODECAMP_NODE_ENV='development'
|
||||||
PEER=stuff
|
# Language to build
|
||||||
DEBUG=true
|
LOCALE=english
|
||||||
LOCAL_MOCK_AUTH=true
|
# Show or hide WIP in progress challenges
|
||||||
|
SHOW_HIDDEN=true
|
||||||
IMAGE_BASE_URL='https://s3.amazonaws.com/freecodecamp/images/'
|
# Application paths
|
||||||
|
|
||||||
HOME_LOCATION='http://localhost:8000'
|
HOME_LOCATION='http://localhost:8000'
|
||||||
API_LOCATION='http://localhost:3000'
|
API_LOCATION='http://localhost:3000'
|
||||||
FORUM_LOCATION='https://localhost/forum'
|
FORUM_LOCATION='https://localhost/forum'
|
||||||
NEWS_LOCATION='https://localhost/news'
|
NEWS_LOCATION='https://localhost/news'
|
||||||
FORUM_PROXY='https://forum.localhost'
|
|
||||||
NEWS_PROXY='https://news.localhost'
|
|
||||||
|
|
||||||
# You can get a webhook proxy url from smee.io
|
# ---------------------
|
||||||
|
# Debugging Mode Keys
|
||||||
|
# ---------------------
|
||||||
|
PEER=stuff
|
||||||
|
DEBUG=true
|
||||||
|
LOCAL_MOCK_AUTH=true
|
||||||
|
# Webhook proxy url from smee.io for PayPal
|
||||||
WEBHOOK_PROXY_URL=''
|
WEBHOOK_PROXY_URL=''
|
||||||
|
# Docker Setup
|
||||||
LOCALE=english
|
|
||||||
|
|
||||||
DOCKER_HOST_LOCATION=localhost
|
DOCKER_HOST_LOCATION=localhost
|
||||||
|
COMPOSE_PROJECT_NAME=freecodecamp
|
||||||
GHOST_CLIENT_KEY=123abc
|
|
||||||
|
|
||||||
SENTRY_DSN=dsn_from_sentry_dashboard
|
|
||||||
SENTRY_ENVIRONMENT='staging'
|
|
||||||
|
|
||||||
# Set this to false to see what the production site will contain
|
|
||||||
SHOW_HIDDEN=true
|
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
||||||
|
|
||||||
exports[`createRedirects matches the snapshot 1`] = `
|
|
||||||
"
|
|
||||||
#
|
|
||||||
# WARNING: The order of this list is very important.
|
|
||||||
#
|
|
||||||
|
|
||||||
# domain mappings
|
|
||||||
https://freecodecamp-dev.netlify.com/* https://www.freecodecamp.dev/:splat 301!
|
|
||||||
https://freecodecamp-org.netlify.com/* https://www.freecodecamp.org/:splat 301!
|
|
||||||
|
|
||||||
# pages
|
|
||||||
/about https://news.example.com/about 200
|
|
||||||
/academic-honesty https://news.example.com/academic-honesty 200
|
|
||||||
/code-of-conduct https://news.example.com/code-of-conduct 200
|
|
||||||
/copyright https://news.example.com/copyright-policy 200
|
|
||||||
/copyright-policy https://news.example.com/copyright-policy 200
|
|
||||||
/privacy https://news.example.com/privacy-policy 200
|
|
||||||
/privacy-policy https://news.example.com/privacy-policy 200
|
|
||||||
/shop https://news.example.com/shop 200
|
|
||||||
/software-resources-for-nonprofits https://news.example.com/software-resources-for-nonprofits 200
|
|
||||||
/sponsors https://news.example.com/sponsors 200
|
|
||||||
/support https://news.example.com/support 200
|
|
||||||
/terms https://news.example.com/terms-of-service 200
|
|
||||||
/terms-of-service https://news.example.com/terms-of-service 200
|
|
||||||
|
|
||||||
# applications
|
|
||||||
/forum/* https://forum.example.com/:splat 200
|
|
||||||
/news https://news.example.com/ 200
|
|
||||||
/news/* https://news.example.com/:splat 200
|
|
||||||
|
|
||||||
# auth redirects
|
|
||||||
/deprecated-signin https://api.example.com/signin 200!
|
|
||||||
/email-signin https://api.example.com/signin 200!
|
|
||||||
/login https://api.example.com/signin 200!
|
|
||||||
/logout https://api.example.com/signout 200!
|
|
||||||
/passwordless-change https://api.example.com/confirm-email 200!
|
|
||||||
/signin https://api.example.com/signin 200!
|
|
||||||
/signup https://api.example.com/signin 200!
|
|
||||||
|
|
||||||
# certification redirects
|
|
||||||
/:username/front-end-certification /certification/:username/legacy-front-end 301
|
|
||||||
/:username/data-visualization-certification /certification/:username/legacy-data-visualization 301
|
|
||||||
/:username/back-end-certification /certification/:username/legacy-back-end 301
|
|
||||||
/:username/full-stack-certification /certification/:username/full-stack 301
|
|
||||||
|
|
||||||
# unsubscribe redirects
|
|
||||||
/u/* https://api.example.com/u/:splat 200!
|
|
||||||
/ue/* https://api.example.com/ue/:splat 200!
|
|
||||||
/unsubscribe/* https://api.example.com/unsubscribe/:splat 200!
|
|
||||||
|
|
||||||
# misc redirects
|
|
||||||
/agile / 301
|
|
||||||
/all-stories / 301
|
|
||||||
/chat https://gitter.im/FreeCodeCamp/FreeCodeCamp 301
|
|
||||||
/donation/settings /donate 302
|
|
||||||
/field-guide/* / 301
|
|
||||||
/how-nonprofit-projects-work / 301
|
|
||||||
/learn-to-code /learn 301
|
|
||||||
/map /learn 200
|
|
||||||
/nonprofit-project-instructions / 301
|
|
||||||
/Nonprofits / 301
|
|
||||||
/nonprofits / 301
|
|
||||||
/nonprofits-form / 301
|
|
||||||
/pmi-acp-agile-project-managers / 301
|
|
||||||
/pmi-acp-agile-project-managers-form / 301
|
|
||||||
/stories / 301
|
|
||||||
/twitch https://twitch.tv/freecodecamp 301
|
|
||||||
/welcome / 200
|
|
||||||
|
|
||||||
"
|
|
||||||
`;
|
|
@ -1,94 +0,0 @@
|
|||||||
const apiPlaceholderRE = /#\{\{API\}\}/g;
|
|
||||||
const newsPlaceholderRE = /#\{\{NEWS\}\}/g;
|
|
||||||
const forumPlaceholderRE = /#\{\{FORUM\}\}/g;
|
|
||||||
|
|
||||||
exports.createRedirects = function createRedirects(locations) {
|
|
||||||
const { api, newsProxy, forumProxy } = locations;
|
|
||||||
|
|
||||||
if (!(api && newsProxy && forumProxy)) {
|
|
||||||
throw new Error(`One or more locations are missing, all are required.
|
|
||||||
|
|
||||||
api: ${api}
|
|
||||||
newsProxy: ${newsProxy}
|
|
||||||
forumProxy: ${forumProxy}
|
|
||||||
|
|
||||||
`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return template
|
|
||||||
.replace(apiPlaceholderRE, api)
|
|
||||||
.replace(newsPlaceholderRE, newsProxy)
|
|
||||||
.replace(forumPlaceholderRE, forumProxy);
|
|
||||||
};
|
|
||||||
|
|
||||||
/* eslint-disable max-len */
|
|
||||||
const template = `
|
|
||||||
#
|
|
||||||
# WARNING: The order of this list is very important.
|
|
||||||
#
|
|
||||||
|
|
||||||
# domain mappings
|
|
||||||
https://freecodecamp-dev.netlify.com/* https://www.freecodecamp.dev/:splat 301!
|
|
||||||
https://freecodecamp-org.netlify.com/* https://www.freecodecamp.org/:splat 301!
|
|
||||||
|
|
||||||
# pages
|
|
||||||
/about #{{NEWS}}/about 200
|
|
||||||
/academic-honesty #{{NEWS}}/academic-honesty 200
|
|
||||||
/code-of-conduct #{{NEWS}}/code-of-conduct 200
|
|
||||||
/copyright #{{NEWS}}/copyright-policy 200
|
|
||||||
/copyright-policy #{{NEWS}}/copyright-policy 200
|
|
||||||
/privacy #{{NEWS}}/privacy-policy 200
|
|
||||||
/privacy-policy #{{NEWS}}/privacy-policy 200
|
|
||||||
/shop #{{NEWS}}/shop 200
|
|
||||||
/software-resources-for-nonprofits #{{NEWS}}/software-resources-for-nonprofits 200
|
|
||||||
/sponsors #{{NEWS}}/sponsors 200
|
|
||||||
/support #{{NEWS}}/support 200
|
|
||||||
/terms #{{NEWS}}/terms-of-service 200
|
|
||||||
/terms-of-service #{{NEWS}}/terms-of-service 200
|
|
||||||
|
|
||||||
# applications
|
|
||||||
/forum/* #{{FORUM}}/:splat 200
|
|
||||||
/news #{{NEWS}}/ 200
|
|
||||||
/news/* #{{NEWS}}/:splat 200
|
|
||||||
|
|
||||||
# auth redirects
|
|
||||||
/deprecated-signin #{{API}}/signin 200!
|
|
||||||
/email-signin #{{API}}/signin 200!
|
|
||||||
/login #{{API}}/signin 200!
|
|
||||||
/logout #{{API}}/signout 200!
|
|
||||||
/passwordless-change #{{API}}/confirm-email 200!
|
|
||||||
/signin #{{API}}/signin 200!
|
|
||||||
/signup #{{API}}/signin 200!
|
|
||||||
|
|
||||||
# certification redirects
|
|
||||||
/:username/front-end-certification /certification/:username/legacy-front-end 301
|
|
||||||
/:username/data-visualization-certification /certification/:username/legacy-data-visualization 301
|
|
||||||
/:username/back-end-certification /certification/:username/legacy-back-end 301
|
|
||||||
/:username/full-stack-certification /certification/:username/full-stack 301
|
|
||||||
|
|
||||||
# unsubscribe redirects
|
|
||||||
/u/* #{{API}}/u/:splat 200!
|
|
||||||
/ue/* #{{API}}/ue/:splat 200!
|
|
||||||
/unsubscribe/* #{{API}}/unsubscribe/:splat 200!
|
|
||||||
|
|
||||||
# misc redirects
|
|
||||||
/agile / 301
|
|
||||||
/all-stories / 301
|
|
||||||
/chat https://gitter.im/FreeCodeCamp/FreeCodeCamp 301
|
|
||||||
/donation/settings /donate 302
|
|
||||||
/field-guide/* / 301
|
|
||||||
/how-nonprofit-projects-work / 301
|
|
||||||
/learn-to-code /learn 301
|
|
||||||
/map /learn 200
|
|
||||||
/nonprofit-project-instructions / 301
|
|
||||||
/Nonprofits / 301
|
|
||||||
/nonprofits / 301
|
|
||||||
/nonprofits-form / 301
|
|
||||||
/pmi-acp-agile-project-managers / 301
|
|
||||||
/pmi-acp-agile-project-managers-form / 301
|
|
||||||
/stories / 301
|
|
||||||
/twitch https://twitch.tv/freecodecamp 301
|
|
||||||
/welcome / 200
|
|
||||||
|
|
||||||
`;
|
|
||||||
/* eslint-enable max-len */
|
|
@ -1,58 +0,0 @@
|
|||||||
/* global describe expect it */
|
|
||||||
|
|
||||||
const { createRedirects } = require('./create-redirects');
|
|
||||||
|
|
||||||
const testLocations = {
|
|
||||||
api: 'https://api.example.com',
|
|
||||||
newsProxy: 'https://news.example.com',
|
|
||||||
forumProxy: 'https://forum.example.com'
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('createRedirects', () => {
|
|
||||||
it('is a function', () => {
|
|
||||||
expect(typeof createRedirects).toEqual('function');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns a string', () => {
|
|
||||||
expect(typeof createRedirects(testLocations)).toEqual('string');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('replaces instances of `#{{...}}` with the locations provided', () => {
|
|
||||||
expect.assertions(4);
|
|
||||||
|
|
||||||
const apiPlaceholderRE = /#\{\{API\}\}/;
|
|
||||||
const newsPlaceholderRE = /#\{\{NEWS\}\}/;
|
|
||||||
const forumPlaceholderRE = /#\{\{FORUM\}\}/;
|
|
||||||
const redirects = createRedirects(testLocations);
|
|
||||||
|
|
||||||
const hasApiPlaceholder = apiPlaceholderRE.test(redirects);
|
|
||||||
const hasNewsPlaceholder = newsPlaceholderRE.test(redirects);
|
|
||||||
const hasForumPlaceholder = forumPlaceholderRE.test(redirects);
|
|
||||||
|
|
||||||
expect(hasApiPlaceholder).toBe(false);
|
|
||||||
expect(hasNewsPlaceholder).toBe(false);
|
|
||||||
expect(hasForumPlaceholder).toBe(false);
|
|
||||||
|
|
||||||
const { forumProxy } = testLocations;
|
|
||||||
expect(redirects.includes(`${forumProxy}`)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('throws when any location is missing', () => {
|
|
||||||
expect.assertions(3);
|
|
||||||
|
|
||||||
const api = 'api';
|
|
||||||
const newsProxy = 'newsProxy';
|
|
||||||
const forumProxy = 'forumProxy';
|
|
||||||
|
|
||||||
const noApi = { forumProxy, newsProxy };
|
|
||||||
const noNews = { api, forumProxy };
|
|
||||||
const noForum = { api, newsProxy };
|
|
||||||
|
|
||||||
expect(() => createRedirects(noApi)).toThrow();
|
|
||||||
expect(() => createRedirects(noNews)).toThrow();
|
|
||||||
expect(() => createRedirects(noForum)).toThrow();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('matches the snapshot', () =>
|
|
||||||
expect(createRedirects(testLocations)).toMatchSnapshot());
|
|
||||||
});
|
|
@ -2,36 +2,18 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const debug = require('debug');
|
const debug = require('debug');
|
||||||
|
|
||||||
const env = require('../../../config/env');
|
const log = debug('fcc:tools:ensure-env');
|
||||||
|
|
||||||
|
const env = require('../../../config/env');
|
||||||
const { getChallengesForLang } = require('../../../curriculum/getChallenges');
|
const { getChallengesForLang } = require('../../../curriculum/getChallenges');
|
||||||
const { createPathMigrationMap } = require('../seed/createPathMigrationMap');
|
const { createPathMigrationMap } = require('../seed/createPathMigrationMap');
|
||||||
|
|
||||||
const { createRedirects } = require('./create-redirects');
|
|
||||||
|
|
||||||
const log = debug('fcc:tools:ensure-env');
|
|
||||||
|
|
||||||
const { FREECODECAMP_NODE_ENV } = process.env;
|
|
||||||
|
|
||||||
const { apiLocation: api, locale, forumProxy, newsProxy } = env;
|
|
||||||
|
|
||||||
const apiPath = path.resolve(__dirname, '../../../api-server');
|
const apiPath = path.resolve(__dirname, '../../../api-server');
|
||||||
const clientPath = path.resolve(__dirname, '../../../client');
|
const clientPath = path.resolve(__dirname, '../../../client');
|
||||||
const clientStaticPath = path.resolve(clientPath, 'static');
|
|
||||||
const globalConfigPath = path.resolve(__dirname, '../../../config');
|
const globalConfigPath = path.resolve(__dirname, '../../../config');
|
||||||
|
|
||||||
if (FREECODECAMP_NODE_ENV === 'production') {
|
const { FREECODECAMP_NODE_ENV } = process.env;
|
||||||
const redirects = createRedirects({ api, newsProxy, forumProxy });
|
const { locale } = env;
|
||||||
fs.writeFile(`${clientStaticPath}/_redirects`, redirects, function(err) {
|
|
||||||
if (err) {
|
|
||||||
log('Error');
|
|
||||||
console.error(err);
|
|
||||||
}
|
|
||||||
log('_redirects written');
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
log(`ignoring creation of redirect file in ${FREECODECAMP_NODE_ENV}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const migrationMapPath = `${apiPath}/server/resources/pathMigration.json`;
|
const migrationMapPath = `${apiPath}/server/resources/pathMigration.json`;
|
||||||
fs.access(migrationMapPath, err => {
|
fs.access(migrationMapPath, err => {
|
||||||
|
Reference in New Issue
Block a user