diff --git a/config/env.js b/config/env.js index 1144545613..a11ed84645 100644 --- a/config/env.js +++ b/config/env.js @@ -14,8 +14,6 @@ const { API_LOCATION: api, FORUM_LOCATION: forum, NEWS_LOCATION: news, - FORUM_PROXY: forumProxy, - NEWS_PROXY: newsProxy, LOCALE: locale, STRIPE_PUBLIC_KEY: stripePublicKey, SERVICEBOT_ID: servicebotId, @@ -29,9 +27,7 @@ const locations = { homeLocation: home, apiLocation: api, forumLocation: forum, - newsLocation: news, - forumProxy: forumProxy, - newsProxy: newsProxy + newsLocation: news }; module.exports = Object.assign(locations, { diff --git a/sample.env b/sample.env index bc88d48fe4..89747ffcfb 100644 --- a/sample.env +++ b/sample.env @@ -1,57 +1,73 @@ -COMPOSE_PROJECT_NAME=freecodecamp +# --------------------- +# API +# --------------------- +# Database MONGOHQ_URL='mongodb://localhost:27017/freecodecamp' -ALGOLIA_ADMIN_KEY=123abc -ALGOLIA_APP_ID=X5V7KWJ4RB -ALGOLIA_API_KEY=a45d2b80c97479bbda5cf5c55914230f +# Logging +SENTRY_DSN=dsn_from_sentry_dashboard +SENTRY_ENVIRONMENT='staging' -AUTH0_CLIENT_ID=stuff -AUTH0_CLIENT_SECRET=stuff -AUTH0_DOMAIN=stuff +# Auth0 - OAuth 2.0 Credentials +AUTH0_CLIENT_ID=client_id_from_auth0_dashboard +AUTH0_CLIENT_SECRET=client_secret_from_auth0_dashboard +AUTH0_DOMAIN=example.auth0.com -SESSION_SECRET=secretstuff -COOKIE_SECRET='this is a secret' -JWT_SECRET='a very long secret' +# Session, Cookie and JWT encryption strings +SESSION_SECRET=a_session_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_PUBLIC_KEY=pk_from_stripe_dashboard STRIPE_SECRET_KEY=sk_from_stripe_dashboard SERVICEBOT_ID=servicebot_id_from_servicebot_dashboard SERVICEBOT_HMAC_SECRET_KEY=secret_key_from_servicebot_dashboard - +# PayPal PAYPAL_SUPPORTERS=1703 - PAYPAL_CLIENT_ID=id_from_paypal_dashboard PAYPAL_SECRET=secret_from_paypal_dashboard 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_WEBHOOK_ID=webhook_id_from_paypal_dashboard + +# --------------------- +# Build variants +# --------------------- DEPLOYMENT_ENV='staging' - -PEER=stuff -DEBUG=true -LOCAL_MOCK_AUTH=true - -IMAGE_BASE_URL='https://s3.amazonaws.com/freecodecamp/images/' - +FREECODECAMP_NODE_ENV='development' +# Language to build +LOCALE=english +# Show or hide WIP in progress challenges +SHOW_HIDDEN=true +# Application paths HOME_LOCATION='http://localhost:8000' API_LOCATION='http://localhost:3000' FORUM_LOCATION='https://localhost/forum' 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='' - -LOCALE=english - +# Docker Setup DOCKER_HOST_LOCATION=localhost - -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 +COMPOSE_PROJECT_NAME=freecodecamp diff --git a/tools/scripts/build/__snapshots__/create-redirects.test.js.snap b/tools/scripts/build/__snapshots__/create-redirects.test.js.snap deleted file mode 100644 index 655686ee61..0000000000 --- a/tools/scripts/build/__snapshots__/create-redirects.test.js.snap +++ /dev/null @@ -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 - -" -`; diff --git a/tools/scripts/build/create-redirects.js b/tools/scripts/build/create-redirects.js deleted file mode 100644 index a74f64f0ab..0000000000 --- a/tools/scripts/build/create-redirects.js +++ /dev/null @@ -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 */ diff --git a/tools/scripts/build/create-redirects.test.js b/tools/scripts/build/create-redirects.test.js deleted file mode 100644 index 8a486233af..0000000000 --- a/tools/scripts/build/create-redirects.test.js +++ /dev/null @@ -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()); -}); diff --git a/tools/scripts/build/ensure-env.js b/tools/scripts/build/ensure-env.js index c5f1e9d487..26d2aac5ca 100644 --- a/tools/scripts/build/ensure-env.js +++ b/tools/scripts/build/ensure-env.js @@ -2,36 +2,18 @@ const fs = require('fs'); const path = require('path'); 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 { 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 clientPath = path.resolve(__dirname, '../../../client'); -const clientStaticPath = path.resolve(clientPath, 'static'); const globalConfigPath = path.resolve(__dirname, '../../../config'); -if (FREECODECAMP_NODE_ENV === 'production') { - const redirects = createRedirects({ api, newsProxy, forumProxy }); - 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 { FREECODECAMP_NODE_ENV } = process.env; +const { locale } = env; const migrationMapPath = `${apiPath}/server/resources/pathMigration.json`; fs.access(migrationMapPath, err => {