From 2266345b567453e4e86ae1c4abcb4256c3b8d794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?N=C3=A4ser?= Date: Wed, 25 Jan 2023 10:32:43 +0100 Subject: [PATCH] chore: move client to website folder --- apps/client-e2e/.eslintrc.json | 17 -- apps/client-e2e/cypress.config.ts | 6 - apps/client-e2e/project.json | 30 --- apps/client-e2e/src/e2e/app.cy.ts | 13 -- apps/client-e2e/src/fixtures/example.json | 4 - apps/client-e2e/src/support/app.po.ts | 1 - apps/client-e2e/src/support/commands.ts | 33 ---- apps/client-e2e/src/support/e2e.ts | 17 -- apps/client-e2e/tsconfig.json | 10 - apps/client/.eslintrc.json | 49 ----- apps/client/environments/environments.prod.ts | 7 - apps/client/environments/environments.ts | 7 - apps/client/postcss.config.js | 15 -- apps/client/tailwind.config.js | 17 -- .../{client/.env => website/.env.development} | 0 apps/website/.env.production | 4 + apps/website/.env.staging | 4 + apps/website/.eslintrc.json | 31 +++ .../components/carousel/carousel.module.scss | 0 .../components/carousel/carousel.spec.tsx | 0 .../components/carousel/carousel.tsx | 0 .../components/footer/footer.module.scss | 0 .../components/footer/footer.spec.tsx | 0 .../components/footer/footer.tsx | 0 .../header-auth/header-auth.module.scss | 0 .../header-auth/header-auth.spec.tsx | 0 .../components/header-auth/header-auth.tsx | 0 .../components/header/header.module.scss | 0 .../components/header/header.spec.tsx | 0 .../components/header/header.tsx | 0 .../components/layout/layout.module.scss | 0 .../components/layout/layout.spec.tsx | 0 .../components/layout/layout.tsx | 0 .../seo-config/seo-config.module.scss | 0 .../components/seo-config/seo-config.spec.tsx | 0 .../components/seo-config/seo-config.tsx | 0 apps/{client => website}/config.ts | 0 apps/{client => website}/index.d.ts | 0 apps/{client => website}/jest.config.ts | 4 +- apps/{client => website}/libs/api.ts | 6 +- apps/{client => website}/libs/auth.ts | 0 apps/{client => website}/next-env.d.ts | 0 apps/{client => website}/next.config.js | 2 +- apps/website/package.json | 14 ++ apps/{client => website}/pages/_app.tsx | 0 .../pages/api/auth/[...nextauth].ts | 0 .../pages/home/index.module.scss | 0 apps/{client => website}/pages/home/index.tsx | 0 .../pages/index.module.scss | 0 apps/{client => website}/pages/index.tsx | 0 .../pages/lost-password/index.module.scss | 0 .../pages/lost-password/index.tsx | 0 .../pages/sign-in/index.module.scss | 0 .../pages/sign-in/index.tsx | 0 .../pages/sign-up/index.module.scss | 0 .../pages/sign-up/index.tsx | 0 .../signup-confirmation/index.module.scss | 0 .../pages/signup-confirmation/index.tsx | 0 apps/{client => website}/pages/styles.css | 0 apps/{client => website}/project.json | 33 ++-- apps/website/public/.gitkeep | 0 apps/{client => website}/specs/index.spec.tsx | 0 apps/{client => website}/tsconfig.json | 0 apps/{client => website}/tsconfig.spec.json | 0 apps/website/with-nx.js | 176 ++++++++++++++++++ 65 files changed, 250 insertions(+), 250 deletions(-) delete mode 100644 apps/client-e2e/.eslintrc.json delete mode 100644 apps/client-e2e/cypress.config.ts delete mode 100644 apps/client-e2e/project.json delete mode 100644 apps/client-e2e/src/e2e/app.cy.ts delete mode 100644 apps/client-e2e/src/fixtures/example.json delete mode 100644 apps/client-e2e/src/support/app.po.ts delete mode 100644 apps/client-e2e/src/support/commands.ts delete mode 100644 apps/client-e2e/src/support/e2e.ts delete mode 100644 apps/client-e2e/tsconfig.json delete mode 100644 apps/client/.eslintrc.json delete mode 100644 apps/client/environments/environments.prod.ts delete mode 100644 apps/client/environments/environments.ts delete mode 100644 apps/client/postcss.config.js delete mode 100644 apps/client/tailwind.config.js rename apps/{client/.env => website/.env.development} (100%) create mode 100644 apps/website/.env.production create mode 100644 apps/website/.env.staging create mode 100644 apps/website/.eslintrc.json rename apps/{client => website}/components/carousel/carousel.module.scss (100%) rename apps/{client => website}/components/carousel/carousel.spec.tsx (100%) rename apps/{client => website}/components/carousel/carousel.tsx (100%) rename apps/{client => website}/components/footer/footer.module.scss (100%) rename apps/{client => website}/components/footer/footer.spec.tsx (100%) rename apps/{client => website}/components/footer/footer.tsx (100%) rename apps/{client => website}/components/header-auth/header-auth.module.scss (100%) rename apps/{client => website}/components/header-auth/header-auth.spec.tsx (100%) rename apps/{client => website}/components/header-auth/header-auth.tsx (100%) rename apps/{client => website}/components/header/header.module.scss (100%) rename apps/{client => website}/components/header/header.spec.tsx (100%) rename apps/{client => website}/components/header/header.tsx (100%) rename apps/{client => website}/components/layout/layout.module.scss (100%) rename apps/{client => website}/components/layout/layout.spec.tsx (100%) rename apps/{client => website}/components/layout/layout.tsx (100%) rename apps/{client => website}/components/seo-config/seo-config.module.scss (100%) rename apps/{client => website}/components/seo-config/seo-config.spec.tsx (100%) rename apps/{client => website}/components/seo-config/seo-config.tsx (100%) rename apps/{client => website}/config.ts (100%) rename apps/{client => website}/index.d.ts (100%) rename apps/{client => website}/jest.config.ts (78%) rename apps/{client => website}/libs/api.ts (75%) rename apps/{client => website}/libs/auth.ts (100%) rename apps/{client => website}/next-env.d.ts (100%) rename apps/{client => website}/next.config.js (85%) create mode 100644 apps/website/package.json rename apps/{client => website}/pages/_app.tsx (100%) rename apps/{client => website}/pages/api/auth/[...nextauth].ts (100%) rename apps/{client => website}/pages/home/index.module.scss (100%) rename apps/{client => website}/pages/home/index.tsx (100%) rename apps/{client => website}/pages/index.module.scss (100%) rename apps/{client => website}/pages/index.tsx (100%) rename apps/{client => website}/pages/lost-password/index.module.scss (100%) rename apps/{client => website}/pages/lost-password/index.tsx (100%) rename apps/{client => website}/pages/sign-in/index.module.scss (100%) rename apps/{client => website}/pages/sign-in/index.tsx (100%) rename apps/{client => website}/pages/sign-up/index.module.scss (100%) rename apps/{client => website}/pages/sign-up/index.tsx (100%) rename apps/{client => website}/pages/signup-confirmation/index.module.scss (100%) rename apps/{client => website}/pages/signup-confirmation/index.tsx (100%) rename apps/{client => website}/pages/styles.css (100%) rename apps/{client => website}/project.json (61%) create mode 100644 apps/website/public/.gitkeep rename apps/{client => website}/specs/index.spec.tsx (100%) rename apps/{client => website}/tsconfig.json (100%) rename apps/{client => website}/tsconfig.spec.json (100%) create mode 100644 apps/website/with-nx.js diff --git a/apps/client-e2e/.eslintrc.json b/apps/client-e2e/.eslintrc.json deleted file mode 100644 index 4c5989b..0000000 --- a/apps/client-e2e/.eslintrc.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "extends": ["plugin:cypress/recommended", "../../.eslintrc.json"], - "ignorePatterns": ["!**/*"], - "overrides": [ - { - "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} - }, - { - "files": ["src/plugins/index.js"], - "rules": { - "@typescript-eslint/no-var-requires": "off", - "no-undef": "off" - } - } - ] -} diff --git a/apps/client-e2e/cypress.config.ts b/apps/client-e2e/cypress.config.ts deleted file mode 100644 index 22f7c84..0000000 --- a/apps/client-e2e/cypress.config.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { defineConfig } from 'cypress'; -import { nxE2EPreset } from '@nrwl/cypress/plugins/cypress-preset'; - -export default defineConfig({ - e2e: nxE2EPreset(__dirname), -}); diff --git a/apps/client-e2e/project.json b/apps/client-e2e/project.json deleted file mode 100644 index 41236d8..0000000 --- a/apps/client-e2e/project.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "client-e2e", - "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "apps/client-e2e/src", - "projectType": "application", - "targets": { - "e2e": { - "executor": "@nrwl/cypress:cypress", - "options": { - "cypressConfig": "apps/client-e2e/cypress.config.ts", - "devServerTarget": "client:serve:development", - "testingType": "e2e" - }, - "configurations": { - "production": { - "devServerTarget": "client:serve:production" - } - } - }, - "lint": { - "executor": "@nrwl/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["apps/client-e2e/**/*.{js,ts}"] - } - } - }, - "tags": [], - "implicitDependencies": ["client"] -} diff --git a/apps/client-e2e/src/e2e/app.cy.ts b/apps/client-e2e/src/e2e/app.cy.ts deleted file mode 100644 index dee0e0b..0000000 --- a/apps/client-e2e/src/e2e/app.cy.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { getGreeting } from '../support/app.po'; - -describe('client', () => { - beforeEach(() => cy.visit('/')); - - it('should display welcome message', () => { - // Custom command example, see `../support/commands.ts` file - cy.login('my-email@something.com', 'myPassword'); - - // Function helper example, see `../support/app.po.ts` file - getGreeting().contains('Welcome client'); - }); -}); diff --git a/apps/client-e2e/src/fixtures/example.json b/apps/client-e2e/src/fixtures/example.json deleted file mode 100644 index 294cbed..0000000 --- a/apps/client-e2e/src/fixtures/example.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "Using fixtures to represent data", - "email": "hello@cypress.io" -} diff --git a/apps/client-e2e/src/support/app.po.ts b/apps/client-e2e/src/support/app.po.ts deleted file mode 100644 index 3293424..0000000 --- a/apps/client-e2e/src/support/app.po.ts +++ /dev/null @@ -1 +0,0 @@ -export const getGreeting = () => cy.get('h1'); diff --git a/apps/client-e2e/src/support/commands.ts b/apps/client-e2e/src/support/commands.ts deleted file mode 100644 index 310f1fa..0000000 --- a/apps/client-e2e/src/support/commands.ts +++ /dev/null @@ -1,33 +0,0 @@ -// *********************************************** -// This example commands.js shows you how to -// create various custom commands and overwrite -// existing commands. -// -// For more comprehensive examples of custom -// commands please read more here: -// https://on.cypress.io/custom-commands -// *********************************************** - -// eslint-disable-next-line @typescript-eslint/no-namespace -declare namespace Cypress { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - interface Chainable { - login(email: string, password: string): void; - } -} -// -// -- This is a parent command -- -Cypress.Commands.add('login', (email, password) => { - console.log('Custom command example: Login', email, password); -}); -// -// -- This is a child command -- -// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) -// -// -// -- This is a dual command -- -// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) -// -// -// -- This will overwrite an existing command -- -// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) diff --git a/apps/client-e2e/src/support/e2e.ts b/apps/client-e2e/src/support/e2e.ts deleted file mode 100644 index 3d469a6..0000000 --- a/apps/client-e2e/src/support/e2e.ts +++ /dev/null @@ -1,17 +0,0 @@ -// *********************************************************** -// This example support/index.js is processed and -// loaded automatically before your test files. -// -// This is a great place to put global configuration and -// behavior that modifies Cypress. -// -// You can change the location of this file or turn off -// automatically serving support files with the -// 'supportFile' configuration option. -// -// You can read more here: -// https://on.cypress.io/configuration -// *********************************************************** - -// Import commands.js using ES2015 syntax: -import './commands'; diff --git a/apps/client-e2e/tsconfig.json b/apps/client-e2e/tsconfig.json deleted file mode 100644 index cc509a7..0000000 --- a/apps/client-e2e/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "sourceMap": false, - "outDir": "../../dist/out-tsc", - "allowJs": true, - "types": ["cypress", "node"] - }, - "include": ["src/**/*.ts", "src/**/*.js", "cypress.config.ts"] -} diff --git a/apps/client/.eslintrc.json b/apps/client/.eslintrc.json deleted file mode 100644 index 445a04e..0000000 --- a/apps/client/.eslintrc.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "extends": [ - "plugin:@nrwl/nx/react-typescript", - "next", - "next/core-web-vitals", - "../../.eslintrc.json" - ], - "ignorePatterns": [ - "!**/*", - ".next/**/*" - ], - "overrides": [ - { - "files": [ - "*.ts", - "*.tsx", - "*.js", - "*.jsx" - ], - "rules": { - "@next/next/no-html-link-for-pages": [ - "error", - "apps/client/pages" - ] - } - }, - { - "files": [ - "*.ts", - "*.tsx" - ], - "rules": {} - }, - { - "files": [ - "*.js", - "*.jsx" - ], - "rules": {} - } - ], - "rules": { - "@next/next/no-html-link-for-pages": "off", - "@typescript-eslint/ban-ts-comment": "off" - }, - "env": { - "jest": true - } -} diff --git a/apps/client/environments/environments.prod.ts b/apps/client/environments/environments.prod.ts deleted file mode 100644 index 78cee80..0000000 --- a/apps/client/environments/environments.prod.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const environment = { - production: true, - strapi: { - apiUrl: 'http://localhost:1337/api', - url: 'http://localhost:1337' - } -}; diff --git a/apps/client/environments/environments.ts b/apps/client/environments/environments.ts deleted file mode 100644 index 657bb18..0000000 --- a/apps/client/environments/environments.ts +++ /dev/null @@ -1,7 +0,0 @@ -export const environment = { - production: false, - strapi: { - apiUrl: 'http://localhost:1337/api', - url: 'http://localhost:1337' - } -}; diff --git a/apps/client/postcss.config.js b/apps/client/postcss.config.js deleted file mode 100644 index c72626d..0000000 --- a/apps/client/postcss.config.js +++ /dev/null @@ -1,15 +0,0 @@ -const { join } = require('path'); - -// Note: If you use library-specific PostCSS/Tailwind configuration then you should remove the `postcssConfig` build -// option from your application's configuration (i.e. project.json). -// -// See: https://nx.dev/guides/using-tailwind-css-in-react#step-4:-applying-configuration-to-libraries - -module.exports = { - plugins: { - tailwindcss: { - config: join(__dirname, 'tailwind.config.js'), - }, - autoprefixer: {}, - }, -}; diff --git a/apps/client/tailwind.config.js b/apps/client/tailwind.config.js deleted file mode 100644 index 05ff71f..0000000 --- a/apps/client/tailwind.config.js +++ /dev/null @@ -1,17 +0,0 @@ -const {createGlobPatternsForDependencies} = require('@nrwl/react/tailwind'); -const {join} = require('path'); - -/** @type {import('tailwindcss').Config} */ -module.exports = { - content: [ - join( - __dirname, - '{src,pages,components}/**/*!(*.stories|*.spec).{ts,tsx,html}' - ), - ...createGlobPatternsForDependencies(__dirname), - ], - theme: { - extend: {}, - }, - plugins: [], -}; diff --git a/apps/client/.env b/apps/website/.env.development similarity index 100% rename from apps/client/.env rename to apps/website/.env.development diff --git a/apps/website/.env.production b/apps/website/.env.production new file mode 100644 index 0000000..d2ea0ef --- /dev/null +++ b/apps/website/.env.production @@ -0,0 +1,4 @@ +STRAPI_URL_API=http://127.0.0.1:1337/api +STRAPI_URL=http://127.0.0.1:1337/ +NEXTAUTH_SECRET= +NEXTAUTH_URL=http://localhost:4200 diff --git a/apps/website/.env.staging b/apps/website/.env.staging new file mode 100644 index 0000000..d2ea0ef --- /dev/null +++ b/apps/website/.env.staging @@ -0,0 +1,4 @@ +STRAPI_URL_API=http://127.0.0.1:1337/api +STRAPI_URL=http://127.0.0.1:1337/ +NEXTAUTH_SECRET= +NEXTAUTH_URL=http://localhost:4200 diff --git a/apps/website/.eslintrc.json b/apps/website/.eslintrc.json new file mode 100644 index 0000000..8d6d104 --- /dev/null +++ b/apps/website/.eslintrc.json @@ -0,0 +1,31 @@ +{ + "extends": [ + "plugin:@nrwl/nx/react-typescript", + "next", + "next/core-web-vitals", + "../../.eslintrc.json" + ], + "ignorePatterns": ["!**/*", ".next/**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": { + "@next/next/no-html-link-for-pages": ["error", "apps/website/pages"] + } + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ], + "rules": { + "@next/next/no-html-link-for-pages": "off" + }, + "env": { + "jest": true + } +} diff --git a/apps/client/components/carousel/carousel.module.scss b/apps/website/components/carousel/carousel.module.scss similarity index 100% rename from apps/client/components/carousel/carousel.module.scss rename to apps/website/components/carousel/carousel.module.scss diff --git a/apps/client/components/carousel/carousel.spec.tsx b/apps/website/components/carousel/carousel.spec.tsx similarity index 100% rename from apps/client/components/carousel/carousel.spec.tsx rename to apps/website/components/carousel/carousel.spec.tsx diff --git a/apps/client/components/carousel/carousel.tsx b/apps/website/components/carousel/carousel.tsx similarity index 100% rename from apps/client/components/carousel/carousel.tsx rename to apps/website/components/carousel/carousel.tsx diff --git a/apps/client/components/footer/footer.module.scss b/apps/website/components/footer/footer.module.scss similarity index 100% rename from apps/client/components/footer/footer.module.scss rename to apps/website/components/footer/footer.module.scss diff --git a/apps/client/components/footer/footer.spec.tsx b/apps/website/components/footer/footer.spec.tsx similarity index 100% rename from apps/client/components/footer/footer.spec.tsx rename to apps/website/components/footer/footer.spec.tsx diff --git a/apps/client/components/footer/footer.tsx b/apps/website/components/footer/footer.tsx similarity index 100% rename from apps/client/components/footer/footer.tsx rename to apps/website/components/footer/footer.tsx diff --git a/apps/client/components/header-auth/header-auth.module.scss b/apps/website/components/header-auth/header-auth.module.scss similarity index 100% rename from apps/client/components/header-auth/header-auth.module.scss rename to apps/website/components/header-auth/header-auth.module.scss diff --git a/apps/client/components/header-auth/header-auth.spec.tsx b/apps/website/components/header-auth/header-auth.spec.tsx similarity index 100% rename from apps/client/components/header-auth/header-auth.spec.tsx rename to apps/website/components/header-auth/header-auth.spec.tsx diff --git a/apps/client/components/header-auth/header-auth.tsx b/apps/website/components/header-auth/header-auth.tsx similarity index 100% rename from apps/client/components/header-auth/header-auth.tsx rename to apps/website/components/header-auth/header-auth.tsx diff --git a/apps/client/components/header/header.module.scss b/apps/website/components/header/header.module.scss similarity index 100% rename from apps/client/components/header/header.module.scss rename to apps/website/components/header/header.module.scss diff --git a/apps/client/components/header/header.spec.tsx b/apps/website/components/header/header.spec.tsx similarity index 100% rename from apps/client/components/header/header.spec.tsx rename to apps/website/components/header/header.spec.tsx diff --git a/apps/client/components/header/header.tsx b/apps/website/components/header/header.tsx similarity index 100% rename from apps/client/components/header/header.tsx rename to apps/website/components/header/header.tsx diff --git a/apps/client/components/layout/layout.module.scss b/apps/website/components/layout/layout.module.scss similarity index 100% rename from apps/client/components/layout/layout.module.scss rename to apps/website/components/layout/layout.module.scss diff --git a/apps/client/components/layout/layout.spec.tsx b/apps/website/components/layout/layout.spec.tsx similarity index 100% rename from apps/client/components/layout/layout.spec.tsx rename to apps/website/components/layout/layout.spec.tsx diff --git a/apps/client/components/layout/layout.tsx b/apps/website/components/layout/layout.tsx similarity index 100% rename from apps/client/components/layout/layout.tsx rename to apps/website/components/layout/layout.tsx diff --git a/apps/client/components/seo-config/seo-config.module.scss b/apps/website/components/seo-config/seo-config.module.scss similarity index 100% rename from apps/client/components/seo-config/seo-config.module.scss rename to apps/website/components/seo-config/seo-config.module.scss diff --git a/apps/client/components/seo-config/seo-config.spec.tsx b/apps/website/components/seo-config/seo-config.spec.tsx similarity index 100% rename from apps/client/components/seo-config/seo-config.spec.tsx rename to apps/website/components/seo-config/seo-config.spec.tsx diff --git a/apps/client/components/seo-config/seo-config.tsx b/apps/website/components/seo-config/seo-config.tsx similarity index 100% rename from apps/client/components/seo-config/seo-config.tsx rename to apps/website/components/seo-config/seo-config.tsx diff --git a/apps/client/config.ts b/apps/website/config.ts similarity index 100% rename from apps/client/config.ts rename to apps/website/config.ts diff --git a/apps/client/index.d.ts b/apps/website/index.d.ts similarity index 100% rename from apps/client/index.d.ts rename to apps/website/index.d.ts diff --git a/apps/client/jest.config.ts b/apps/website/jest.config.ts similarity index 78% rename from apps/client/jest.config.ts rename to apps/website/jest.config.ts index 9b46e82..b71b9c6 100644 --- a/apps/client/jest.config.ts +++ b/apps/website/jest.config.ts @@ -1,11 +1,11 @@ /* eslint-disable */ export default { - displayName: 'client', + displayName: 'website', preset: '../../jest.preset.js', transform: { '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest', '^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/next/babel'] }], }, moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], - coverageDirectory: '../../coverage/apps/client', + coverageDirectory: '../../coverage/apps/website', }; diff --git a/apps/client/libs/api.ts b/apps/website/libs/api.ts similarity index 75% rename from apps/client/libs/api.ts rename to apps/website/libs/api.ts index 9103767..5ee05fc 100644 --- a/apps/client/libs/api.ts +++ b/apps/website/libs/api.ts @@ -1,8 +1,6 @@ import axios from "axios"; import * as _ from 'lodash'; -import {environment} from "../environments/environments"; - export type Inputs = { email: string, username: string, @@ -17,12 +15,12 @@ export const hasAvatar = (user) => { } export const getBackendImg = (imageUrl: string) => { - return `${environment.strapi.url}${imageUrl}`; + return `${process.env.STRAPI_URL}${imageUrl}`; } export const signUpRequest = async (inputs: Inputs) => { try { - const registerResponse = await axios.post(`${environment.strapi.apiUrl}/auth/local/register`, { + const registerResponse = await axios.post(`${process.env.STRAPI_URL_API}/auth/local/register`, { email: inputs.email, password: inputs.password, username: inputs.username, diff --git a/apps/client/libs/auth.ts b/apps/website/libs/auth.ts similarity index 100% rename from apps/client/libs/auth.ts rename to apps/website/libs/auth.ts diff --git a/apps/client/next-env.d.ts b/apps/website/next-env.d.ts similarity index 100% rename from apps/client/next-env.d.ts rename to apps/website/next-env.d.ts diff --git a/apps/client/next.config.js b/apps/website/next.config.js similarity index 85% rename from apps/client/next.config.js rename to apps/website/next.config.js index 84124f6..81bf708 100644 --- a/apps/client/next.config.js +++ b/apps/website/next.config.js @@ -1,7 +1,7 @@ //@ts-check // eslint-disable-next-line @typescript-eslint/no-var-requires -const { withNx } = require('@nrwl/next/plugins/with-nx'); +const { withNx } = require('./with-nx.js'); /** * @type {import('@nrwl/next/plugins/with-nx').WithNxOptions} diff --git a/apps/website/package.json b/apps/website/package.json new file mode 100644 index 0000000..03ddcb2 --- /dev/null +++ b/apps/website/package.json @@ -0,0 +1,14 @@ +{ + "name": "website", + "version": "0.0.1", + "dependencies": { + "@nrwl/next": "15.5.1", + "next": "13.1.1", + "react": "18.2.0", + "react-dom": "18.2.0", + "typescript": "4.8.4" + }, + "scripts": { + "start": "next start" + } +} diff --git a/apps/client/pages/_app.tsx b/apps/website/pages/_app.tsx similarity index 100% rename from apps/client/pages/_app.tsx rename to apps/website/pages/_app.tsx diff --git a/apps/client/pages/api/auth/[...nextauth].ts b/apps/website/pages/api/auth/[...nextauth].ts similarity index 100% rename from apps/client/pages/api/auth/[...nextauth].ts rename to apps/website/pages/api/auth/[...nextauth].ts diff --git a/apps/client/pages/home/index.module.scss b/apps/website/pages/home/index.module.scss similarity index 100% rename from apps/client/pages/home/index.module.scss rename to apps/website/pages/home/index.module.scss diff --git a/apps/client/pages/home/index.tsx b/apps/website/pages/home/index.tsx similarity index 100% rename from apps/client/pages/home/index.tsx rename to apps/website/pages/home/index.tsx diff --git a/apps/client/pages/index.module.scss b/apps/website/pages/index.module.scss similarity index 100% rename from apps/client/pages/index.module.scss rename to apps/website/pages/index.module.scss diff --git a/apps/client/pages/index.tsx b/apps/website/pages/index.tsx similarity index 100% rename from apps/client/pages/index.tsx rename to apps/website/pages/index.tsx diff --git a/apps/client/pages/lost-password/index.module.scss b/apps/website/pages/lost-password/index.module.scss similarity index 100% rename from apps/client/pages/lost-password/index.module.scss rename to apps/website/pages/lost-password/index.module.scss diff --git a/apps/client/pages/lost-password/index.tsx b/apps/website/pages/lost-password/index.tsx similarity index 100% rename from apps/client/pages/lost-password/index.tsx rename to apps/website/pages/lost-password/index.tsx diff --git a/apps/client/pages/sign-in/index.module.scss b/apps/website/pages/sign-in/index.module.scss similarity index 100% rename from apps/client/pages/sign-in/index.module.scss rename to apps/website/pages/sign-in/index.module.scss diff --git a/apps/client/pages/sign-in/index.tsx b/apps/website/pages/sign-in/index.tsx similarity index 100% rename from apps/client/pages/sign-in/index.tsx rename to apps/website/pages/sign-in/index.tsx diff --git a/apps/client/pages/sign-up/index.module.scss b/apps/website/pages/sign-up/index.module.scss similarity index 100% rename from apps/client/pages/sign-up/index.module.scss rename to apps/website/pages/sign-up/index.module.scss diff --git a/apps/client/pages/sign-up/index.tsx b/apps/website/pages/sign-up/index.tsx similarity index 100% rename from apps/client/pages/sign-up/index.tsx rename to apps/website/pages/sign-up/index.tsx diff --git a/apps/client/pages/signup-confirmation/index.module.scss b/apps/website/pages/signup-confirmation/index.module.scss similarity index 100% rename from apps/client/pages/signup-confirmation/index.module.scss rename to apps/website/pages/signup-confirmation/index.module.scss diff --git a/apps/client/pages/signup-confirmation/index.tsx b/apps/website/pages/signup-confirmation/index.tsx similarity index 100% rename from apps/client/pages/signup-confirmation/index.tsx rename to apps/website/pages/signup-confirmation/index.tsx diff --git a/apps/client/pages/styles.css b/apps/website/pages/styles.css similarity index 100% rename from apps/client/pages/styles.css rename to apps/website/pages/styles.css diff --git a/apps/client/project.json b/apps/website/project.json similarity index 61% rename from apps/client/project.json rename to apps/website/project.json index 4ad51f0..254632d 100644 --- a/apps/client/project.json +++ b/apps/website/project.json @@ -1,7 +1,7 @@ { - "name": "client", + "name": "website", "$schema": "../../node_modules/nx/schemas/project-schema.json", - "sourceRoot": "apps/client", + "sourceRoot": "apps/website", "projectType": "application", "targets": { "build": { @@ -9,19 +9,14 @@ "outputs": ["{options.outputPath}"], "defaultConfiguration": "production", "options": { - "root": "apps/client", - "outputPath": "dist/apps/client" + "root": "apps/website", + "outputPath": "dist/apps/website" }, "configurations": { "development": { - "fileReplacements": [ - { - "replace": "apps/client/environments/environment.ts", - "with": "apps/client/environments/environment.prod.ts" - } - ], - "outputPath": "apps/client" + "outputPath": "apps/website" }, + "staging": {}, "production": {} } }, @@ -29,16 +24,20 @@ "executor": "@nrwl/next:server", "defaultConfiguration": "development", "options": { - "buildTarget": "client:build", + "buildTarget": "website:build", "dev": true }, "configurations": { "development": { - "buildTarget": "client:build:development", + "buildTarget": "website:build:development", "dev": true }, + "staging": { + "buildTarget": "website:build:staging", + "dev": false + }, "production": { - "buildTarget": "client:build:production", + "buildTarget": "website:build:production", "dev": false } } @@ -46,14 +45,14 @@ "export": { "executor": "@nrwl/next:export", "options": { - "buildTarget": "client:build:production" + "buildTarget": "website:build:production" } }, "test": { "executor": "@nrwl/jest:jest", "outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "options": { - "jestConfig": "apps/client/jest.config.ts", + "jestConfig": "apps/website/jest.config.ts", "passWithNoTests": true } }, @@ -61,7 +60,7 @@ "executor": "@nrwl/linter:eslint", "outputs": ["{options.outputFile}"], "options": { - "lintFilePatterns": ["apps/client/**/*.{ts,tsx,js,jsx}"] + "lintFilePatterns": ["apps/website/**/*.{ts,tsx,js,jsx}"] } } }, diff --git a/apps/website/public/.gitkeep b/apps/website/public/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/apps/client/specs/index.spec.tsx b/apps/website/specs/index.spec.tsx similarity index 100% rename from apps/client/specs/index.spec.tsx rename to apps/website/specs/index.spec.tsx diff --git a/apps/client/tsconfig.json b/apps/website/tsconfig.json similarity index 100% rename from apps/client/tsconfig.json rename to apps/website/tsconfig.json diff --git a/apps/client/tsconfig.spec.json b/apps/website/tsconfig.spec.json similarity index 100% rename from apps/client/tsconfig.spec.json rename to apps/website/tsconfig.spec.json diff --git a/apps/website/with-nx.js b/apps/website/with-nx.js new file mode 100644 index 0000000..2c0ed08 --- /dev/null +++ b/apps/website/with-nx.js @@ -0,0 +1,176 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.withNx = void 0; +const tslib_1 = require("tslib"); +function regexEqual(x, y) { + return (x instanceof RegExp && + y instanceof RegExp && + x.source === y.source && + x.global === y.global && + x.ignoreCase === y.ignoreCase && + x.multiline === y.multiline); +} +/** + * Do not remove or rename this function. Production builds inline `with-nx.js` file with a replacement + * To this function that hard-codes the libsDir. + */ +function getWithNxContext() { +return { +workspaceRoot: '/Users/snaser/Projets/nx-guitar-school', +libsDir: 'libs' +} +} +function withNx(nextConfig = {}, context = getWithNxContext()) { + var _a; + // If `next-compose-plugins` is used, the context argument is invalid. + if (!context.libsDir || !context.workspaceRoot) { + context = getWithNxContext(); + } + const userWebpack = nextConfig.webpack || ((x) => x); + const { nx } = nextConfig, validNextConfig = tslib_1.__rest(nextConfig, ["nx"]); + return Object.assign(Object.assign({ eslint: Object.assign({ ignoreDuringBuilds: true }, ((_a = validNextConfig.eslint) !== null && _a !== void 0 ? _a : {})) }, validNextConfig), { webpack: (config, options) => { + /* + * Update babel to support our monorepo setup. + * The 'upward' mode allows the root babel.config.json and per-project .babelrc files to be picked up. + */ + options.defaultLoaders.babel.options.babelrc = true; + options.defaultLoaders.babel.options.rootMode = 'upward'; + /* + * Modify the Next.js webpack config to allow workspace libs to use css modules. + * Note: This would be easier if Next.js exposes css-loader and sass-loader on `defaultLoaders`. + */ + // Include workspace libs in css/sass loaders + const includes = [ + require('path').join(context.workspaceRoot, context.libsDir), + ]; + const nextCssLoaders = config.module.rules.find((rule) => typeof rule.oneOf === 'object'); + // webpack config is not as expected + if (!nextCssLoaders) + return config; + /* + * 1. Modify css loader to enable module support for workspace libs + */ + const nextCssLoader = nextCssLoaders.oneOf.find((rule) => rule.sideEffects === false && regexEqual(rule.test, /\.module\.css$/)); + // Might not be found if Next.js webpack config changes in the future + if (nextCssLoader && nextCssLoader.issuer) { + nextCssLoader.issuer.or = nextCssLoader.issuer.and + ? nextCssLoader.issuer.and.concat(includes) + : includes; + delete nextCssLoader.issuer.and; + } + /* + * 2. Modify sass loader to enable module support for workspace libs + */ + const nextSassLoader = nextCssLoaders.oneOf.find((rule) => rule.sideEffects === false && + regexEqual(rule.test, /\.module\.(scss|sass)$/)); + // Might not be found if Next.js webpack config changes in the future + if (nextSassLoader && nextSassLoader.issuer) { + nextSassLoader.issuer.or = nextSassLoader.issuer.and + ? nextSassLoader.issuer.and.concat(includes) + : includes; + delete nextSassLoader.issuer.and; + } + /* + * 3. Modify error loader to ignore css modules used by workspace libs + */ + const nextErrorCssModuleLoader = nextCssLoaders.oneOf.find((rule) => rule.use && + rule.use.loader === 'error-loader' && + rule.use.options && + (rule.use.options.reason === + 'CSS Modules \u001b[1mcannot\u001b[22m be imported from within \u001b[1mnode_modules\u001b[22m.\n' + + 'Read more: https://err.sh/next.js/css-modules-npm' || + rule.use.options.reason === + 'CSS Modules cannot be imported from within node_modules.\nRead more: https://err.sh/next.js/css-modules-npm')); + // Might not be found if Next.js webpack config changes in the future + if (nextErrorCssModuleLoader) { + nextErrorCssModuleLoader.exclude = includes; + } + /** + * 4. Modify css loader to allow global css from node_modules to be imported from workspace libs + */ + const nextGlobalCssLoader = nextCssLoaders.oneOf.find((rule) => { + var _a, _b; + return (_b = (_a = rule.include) === null || _a === void 0 ? void 0 : _a.and) === null || _b === void 0 ? void 0 : _b.find((include) => regexEqual(include, /node_modules/)); + }); + // Might not be found if Next.js webpack config changes in the future + if (nextGlobalCssLoader && nextGlobalCssLoader.issuer) { + nextGlobalCssLoader.issuer.or = nextGlobalCssLoader.issuer.and + ? nextGlobalCssLoader.issuer.and.concat(includes) + : includes; + delete nextGlobalCssLoader.issuer.and; + } + /** + * 5. Add env variables prefixed with NX_ + */ + addNxEnvVariables(config); + /** + * 6. Add SVGR support if option is on. + */ + // Default SVGR support to be on for projects. + if ((nx === null || nx === void 0 ? void 0 : nx.svgr) !== false) { + config.module.rules.push({ + test: /\.svg$/, + oneOf: [ + // If coming from JS/TS file, then transform into React component using SVGR. + { + issuer: /\.[jt]sx?$/, + use: [ + { + loader: require.resolve('@svgr/webpack'), + options: { + svgo: false, + titleProp: true, + ref: true, + }, + }, + { + loader: require.resolve('url-loader'), + options: { + limit: 10000, + name: '[name].[hash:7].[ext]', + }, + }, + ], + }, + // Fallback to plain URL loader if someone just imports the SVG and references it on the tag + { + loader: require.resolve('url-loader'), + options: { + limit: 10000, + name: '[name].[hash:7].[ext]', + }, + }, + ], + }); + } + return userWebpack(config, options); + } }); +} +exports.withNx = withNx; +function getNxEnvironmentVariables() { + return Object.keys(process.env) + .filter((env) => /^NX_/i.test(env)) + .reduce((env, key) => { + env[key] = process.env[key]; + return env; + }, {}); +} +function addNxEnvVariables(config) { + var _a; + const maybeDefinePlugin = (_a = config.plugins) === null || _a === void 0 ? void 0 : _a.find((plugin) => { + var _a; + return (_a = plugin.definitions) === null || _a === void 0 ? void 0 : _a['process.env.NODE_ENV']; + }); + if (maybeDefinePlugin) { + const env = getNxEnvironmentVariables(); + Object.entries(env) + .map(([name, value]) => [`process.env.${name}`, `"${value}"`]) + .filter(([name]) => !maybeDefinePlugin.definitions[name]) + .forEach(([name, value]) => (maybeDefinePlugin.definitions[name] = value)); + } +} +// Support for older generated code: `const withNx = require('@nrwl/next/plugins/with-nx');` +module.exports = withNx; +// Support for newer generated code: `const { withNx } = require(...);` +module.exports.withNx = withNx; +//# sourceMappingURL=with-nx.js.map \ No newline at end of file