Skip to content

Commit

Permalink
refactor: create shared workspace (freeCodeCamp#51454)
Browse files Browse the repository at this point in the history
  • Loading branch information
ojeytonwilliams authored Sep 7, 2023
1 parent 3c0c14b commit 391fc2e
Show file tree
Hide file tree
Showing 168 changed files with 278 additions and 263 deletions.
9 changes: 4 additions & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ client/.cache/**
client/public/**
api-server/src/public/**
api-server/lib/**
config/i18n.js
config/misc.js
config/certification-settings.js
config/donation-settings.js
config/superblocks.js
shared/config/i18n.js
shared/config/certification-settings.js
shared/config/donation-settings.js
shared/config/superblocks.js
web/**
docs/**/*.md
tools/ui-components/dist/**
Expand Down
3 changes: 1 addition & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@
"./client/tsconfig.json",
"./tsconfig.json",
"./api/tsconfig.json",
"./config/tsconfig.json",
"./shared/tsconfig.json",
"./tools/ui-components/tsconfig.json",
"./tools/client-plugins/browser-scripts/tsconfig.json",
"./utils/tsconfig.json",
"./web/tsconfig.json",
"./curriculum-server/tsconfig.json",
"./cypress/tsconfig.json",
Expand Down
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
- docs/i18n/**/*
- client/i18n/**/*
- config/crowdin/**/*
- config/i18n/**/*
- shared/config/i18n/**/*
2 changes: 1 addition & 1 deletion .github/workflows/crowdin-download.curriculum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ jobs:
run: |
echo pnpm version $(pnpm -v)
pnpm install
pnpm run create:config
pnpm run create:shared
pnpm run build:curriculum
pnpm run build:server
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-mobile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Install and Build
run: |
pnpm install
pnpm run create:config
pnpm run create:shared
pnpm run build:curriculum
- name: Generate mobile test files
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ jobs:
- name: Install and Build
run: |
pnpm install
pnpm run create:config
pnpm run create:shared
pnpm run build:curriculum
pnpm run build:server
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ jobs:
- name: Install and Build
run: |
pnpm install
pnpm run create:config
pnpm run create:shared
pnpm run build:curriculum
pnpm run build:server
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/node.js-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
run: |
echo pnpm version $(pnpm -v)
pnpm install
pnpm run create:config
pnpm run create:shared
npm i --prefix=curriculum-server
npm i --prefix=web
pnpm run build:curriculum
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
run: |
echo pnpm version $(pnpm -v)
pnpm install
pnpm run create:config
pnpm run create:shared
pnpm run build:curriculum
- name: Run Tests
Expand Down Expand Up @@ -192,7 +192,7 @@ jobs:
run: |
echo pnpm version $(pnpm -v)
pnpm install
pnpm run create:config
pnpm run create:shared
pnpm run build:curriculum
- name: Run Tests
Expand Down Expand Up @@ -241,7 +241,7 @@ jobs:
run: |
echo pnpm version $(pnpm -v)
pnpm install
pnpm run create:config
pnpm run create:shared
pnpm run build:curriculum
- name: Run Tests
Expand Down Expand Up @@ -292,7 +292,7 @@ jobs:
run: |
echo pnpm version $(pnpm -v)
pnpm install
pnpm run create:config
pnpm run create:shared
# DONT REMOVE THIS STEP.
# TODO: Refactor and use re-usable workflow and shared artifacts
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/temporary-container-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ jobs:
- name: Install and Build
run: |
pnpm install
pnpm run create:config
pnpm run create:shared
pnpm run build:curriculum
pnpm run build:server
Expand Down
23 changes: 7 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,24 +157,15 @@ jspm_packages/
.netlify

### Generated config files ###
config/env.json
config/curriculum.json
config/i18n.js
config/misc.js
config/certification-settings.js
config/donation-settings.js
config/superblocks.js
config/superblocks.test.js
config/challenge-types.js
config/constants.js
shared/config/curriculum.json
shared/config/*.js

### Generated utils files ###
utils/index.js
utils/get-lines.js
utils/get-lines.test.js
utils/validate.js
utils/validate.test.js
utils/is-audited.js
shared/utils/get-lines.js
shared/utils/get-lines.test.js
shared/utils/validate.js
shared/utils/validate.test.js
shared/utils/is-audited.js

### Old Generated files ###
# These files are no longer generated by the client, but can
Expand Down
16 changes: 8 additions & 8 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ client/config/browser-scripts/*.json
**/*fixtures*
curriculum/challenges/_meta/*/*
curriculum/challenges/**/*
config/**/*.json
config/*.js
utils/index.js
utils/get-lines.js
utils/get-lines.test.js
utils/validate.js
utils/validate.test.js
utils/is-audited.js
client/config/*.json
shared/config/*.js
shared/config/curriculum.json
shared/utils/get-lines.js
shared/utils/get-lines.test.js
shared/utils/validate.js
shared/utils/validate.test.js
shared/utils/is-audited.js
pnpm-lock.yaml
web/.next
curriculum-server/data/curriculum.json
Expand Down
2 changes: 1 addition & 1 deletion api-server/src/common/models/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import uuid from 'uuid/v4';
import { isEmail } from 'validator';

import { isProfane } from 'no-profanity';
import { blocklistedUsernames } from '../../../../config/constants';
import { blocklistedUsernames } from '../../../../shared/config/constants';

import { wrapHandledError } from '../../server/utils/create-handled-error.js';
import {
Expand Down
2 changes: 1 addition & 1 deletion api-server/src/server/boot/certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
oldDataVizId,
currentCertifications,
upcomingCertifications
} from '../../../../config/certification-settings';
} from '../../../../shared/config/certification-settings';
import { reportError } from '../middlewares/sentry-error-handler.js';

import { deprecatedEndpoint } from '../utils/disabled-endpoints';
Expand Down
2 changes: 1 addition & 1 deletion api-server/src/server/boot/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import fetch from 'node-fetch';
import jwt from 'jsonwebtoken';

import { jwtSecret } from '../../../config/secrets';
import { challengeTypes } from '../../../../config/challenge-types';
import { challengeTypes } from '../../../../shared/config/challenge-types';

import {
fixPartiallyCompletedChallengeItem,
Expand Down
2 changes: 1 addition & 1 deletion api-server/src/server/boot/donate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import debug from 'debug';
import Stripe from 'stripe';

import { donationSubscriptionConfig } from '../../../../config/donation-settings';
import { donationSubscriptionConfig } from '../../../../shared/config/donation-settings';
import keys from '../../../config/secrets';
import {
getAsyncPaypalToken,
Expand Down
2 changes: 1 addition & 1 deletion api-server/src/server/boot/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { check } from 'express-validator';
import _ from 'lodash';
import isURL from 'validator/lib/isURL';

import { isValidUsername } from '../../../../utils/validate';
import { isValidUsername } from '../../../../shared/utils/validate';
import { alertTypes } from '../../common/utils/flash.js';
import {
deprecatedEndpoint,
Expand Down
2 changes: 1 addition & 1 deletion api-server/src/server/component-passport.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PassportConfigurator } from '@freecodecamp/loopback-component-passport'
import dedent from 'dedent';
import passport from 'passport';

import { availableLangs } from '../../../config/i18n';
import { availableLangs } from '../../../shared/config/i18n';
import { jwtSecret } from '../../config/secrets';
import passportProviders from './passport-providers';
import { setAccessTokenToResponse } from './utils/getSetAccessToken';
Expand Down
2 changes: 1 addition & 1 deletion api-server/src/server/utils/donation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import axios from 'axios';
import debug from 'debug';
import isEmail from 'validator/lib/isEmail';
import { donationSubscriptionConfig } from '../../../../config/donation-settings';
import { donationSubscriptionConfig } from '../../../../shared/config/donation-settings';
import keys from '../../../config/secrets';

const log = debug('fcc:boot:donate');
Expand Down
2 changes: 1 addition & 1 deletion api-server/src/server/utils/get-curriculum.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { flatten } from 'lodash';
// collected.

// eslint-disable-next-line import/no-unresolved
import curriculum from '../../../../config/curriculum.json';
import curriculum from '../../../../shared/config/curriculum.json';

export function getChallenges() {
return Object.keys(curriculum)
Expand Down
2 changes: 1 addition & 1 deletion api-server/src/server/utils/redirection.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const jwt = require('jsonwebtoken');
const { allowedOrigins } = require('../../../config/cors-settings');
// process.env.HOME_LOCATION is being used as a fallback here. If the one
// provided by the client is invalid we default to this.
const { availableLangs } = require('../../../../config/i18n');
const { availableLangs } = require('../../../../shared/config/i18n');

function getReturnTo(
encryptedParams,
Expand Down
2 changes: 1 addition & 1 deletion api-server/src/server/utils/stripeHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
durationKeysConfig,
donationOneTimeConfig,
donationSubscriptionConfig
} from '../../../../config/donation-settings';
} from '../../../../shared/config/donation-settings';

export function validStripeForm(amount, duration, email) {
return isEmail('' + email) &&
Expand Down
2 changes: 1 addition & 1 deletion api/src/routes/challenge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { omit } from 'lodash';
import { challengeTypes } from '../../../config/challenge-types';
import { challengeTypes } from '../../../shared/config/challenge-types';
import { devLogin, setupServer, superRequest } from '../../jest.utils';

const isValidChallengeCompletionErrorMsg = {
Expand Down
2 changes: 1 addition & 1 deletion api/src/routes/challenge.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox';
import jwt from 'jsonwebtoken';
import { uniqBy } from 'lodash';
import { challengeTypes } from '../../../config/challenge-types';
import { challengeTypes } from '../../../shared/config/challenge-types';
import { schemas } from '../schemas';
import {
jsCertProjectIds,
Expand Down
4 changes: 2 additions & 2 deletions api/src/routes/settings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type FastifyPluginCallbackTypebox } from '@fastify/type-provider-typebox';
import { isProfane } from 'no-profanity';
import { isValidUsername } from '../../../utils/validate';
import { blocklistedUsernames } from '../../../config/constants';
import { isValidUsername } from '../../../shared/utils/validate';
import { blocklistedUsernames } from '../../../shared/config/constants';
import { schemas } from '../schemas';

/**
Expand Down
2 changes: 1 addition & 1 deletion api/src/utils/common-challenge-functions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { user } from '@prisma/client';
import { FastifyInstance } from 'fastify';
import { omit, pick } from 'lodash';
import { challengeTypes } from '../../../config/challenge-types';
import { challengeTypes } from '../../../shared/config/challenge-types';
import { getChallenges } from './get-challenges';

export const jsCertProjectIds = [
Expand Down
4 changes: 2 additions & 2 deletions api/src/utils/get-challenges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
// redirectToCurrentChallenge and, instead, only report the current challenge id
// via the user object, then we should *not* store this so it can be garbage
// collected.
import curriculum from '../../../config/curriculum.json';
import { SuperBlocks } from '../../../config/superblocks';
import curriculum from '../../../shared/config/curriculum.json';
import { SuperBlocks } from '../../../shared/config/superblocks';

type Curriculum = { [keyValue in SuperBlocks]?: CurriculumProps };

Expand Down
4 changes: 4 additions & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ i18n/locales/**/trending.json
# TODO: Remove once you've figured out why it's generated.
# JS that probably should not be generated
src/components/Donation/types.js

# Config

config/env.json
2 changes: 1 addition & 1 deletion client/config/cert-and-project-map.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
currentCertifications,
upcomingCertifications,
legacyCertifications
} from '../../config/certification-settings';
} from '../../shared/config/certification-settings';
import {
currentCertTitles,
upcomingCertTitles,
Expand Down
4 changes: 2 additions & 2 deletions client/config/cert-and-project-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
legacyCertifications,
upcomingCertifications,
currentCertifications
} from '../../config/certification-settings';
import config from '../../config/env.json';
} from '../../shared/config/certification-settings';
import config from '../config/env.json';

const { showUpcomingChanges } = config;

Expand Down
2 changes: 1 addition & 1 deletion client/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const path = require('path');
const envData = require('../config/env.json');
const envData = require('./config/env.json');
const {
buildChallenges,
replaceChallengeNode,
Expand Down
2 changes: 1 addition & 1 deletion client/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { createFilePath } = require('gatsby-source-filesystem');
const uniq = require('lodash/uniq');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const webpack = require('webpack');
const env = require('../config/env.json');
const env = require('./config/env.json');

const {
createChallengePages,
Expand Down
Loading

0 comments on commit 391fc2e

Please sign in to comment.