chore: move client to website folder

feature/blog
Näser 3 years ago
parent 233ce6fea4
commit 2266345b56

@ -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"
}
}
]
}

@ -1,6 +0,0 @@
import { defineConfig } from 'cypress';
import { nxE2EPreset } from '@nrwl/cypress/plugins/cypress-preset';
export default defineConfig({
e2e: nxE2EPreset(__dirname),
});

@ -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"]
}

@ -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');
});
});

@ -1,4 +0,0 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io"
}

@ -1 +0,0 @@
export const getGreeting = () => cy.get('h1');

@ -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<Subject> {
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) => { ... })

@ -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';

@ -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"]
}

@ -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
}
}

@ -1,7 +0,0 @@
export const environment = {
production: true,
strapi: {
apiUrl: 'http://localhost:1337/api',
url: 'http://localhost:1337'
}
};

@ -1,7 +0,0 @@
export const environment = {
production: false,
strapi: {
apiUrl: 'http://localhost:1337/api',
url: 'http://localhost:1337'
}
};

@ -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: {},
},
};

@ -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: [],
};

@ -0,0 +1,4 @@
STRAPI_URL_API=http://127.0.0.1:1337/api
STRAPI_URL=http://127.0.0.1:1337/
NEXTAUTH_SECRET=<SECRET>
NEXTAUTH_URL=http://localhost:4200

@ -0,0 +1,4 @@
STRAPI_URL_API=http://127.0.0.1:1337/api
STRAPI_URL=http://127.0.0.1:1337/
NEXTAUTH_SECRET=<SECRET>
NEXTAUTH_URL=http://localhost:4200

@ -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
}
}

@ -1,11 +1,11 @@
/* eslint-disable */ /* eslint-disable */
export default { export default {
displayName: 'client', displayName: 'website',
preset: '../../jest.preset.js', preset: '../../jest.preset.js',
transform: { transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest', '^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nrwl/react/plugins/jest',
'^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/next/babel'] }], '^.+\\.[tj]sx?$': ['babel-jest', { presets: ['@nrwl/next/babel'] }],
}, },
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/apps/client', coverageDirectory: '../../coverage/apps/website',
}; };

@ -1,8 +1,6 @@
import axios from "axios"; import axios from "axios";
import * as _ from 'lodash'; import * as _ from 'lodash';
import {environment} from "../environments/environments";
export type Inputs = { export type Inputs = {
email: string, email: string,
username: string, username: string,
@ -17,12 +15,12 @@ export const hasAvatar = (user) => {
} }
export const getBackendImg = (imageUrl: string) => { export const getBackendImg = (imageUrl: string) => {
return `${environment.strapi.url}${imageUrl}`; return `${process.env.STRAPI_URL}${imageUrl}`;
} }
export const signUpRequest = async (inputs: Inputs) => { export const signUpRequest = async (inputs: Inputs) => {
try { 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, email: inputs.email,
password: inputs.password, password: inputs.password,
username: inputs.username, username: inputs.username,

@ -1,7 +1,7 @@
//@ts-check //@ts-check
// eslint-disable-next-line @typescript-eslint/no-var-requires // 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} * @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}

@ -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"
}
}

@ -1,7 +1,7 @@
{ {
"name": "client", "name": "website",
"$schema": "../../node_modules/nx/schemas/project-schema.json", "$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/client", "sourceRoot": "apps/website",
"projectType": "application", "projectType": "application",
"targets": { "targets": {
"build": { "build": {
@ -9,19 +9,14 @@
"outputs": ["{options.outputPath}"], "outputs": ["{options.outputPath}"],
"defaultConfiguration": "production", "defaultConfiguration": "production",
"options": { "options": {
"root": "apps/client", "root": "apps/website",
"outputPath": "dist/apps/client" "outputPath": "dist/apps/website"
}, },
"configurations": { "configurations": {
"development": { "development": {
"fileReplacements": [ "outputPath": "apps/website"
{
"replace": "apps/client/environments/environment.ts",
"with": "apps/client/environments/environment.prod.ts"
}
],
"outputPath": "apps/client"
}, },
"staging": {},
"production": {} "production": {}
} }
}, },
@ -29,16 +24,20 @@
"executor": "@nrwl/next:server", "executor": "@nrwl/next:server",
"defaultConfiguration": "development", "defaultConfiguration": "development",
"options": { "options": {
"buildTarget": "client:build", "buildTarget": "website:build",
"dev": true "dev": true
}, },
"configurations": { "configurations": {
"development": { "development": {
"buildTarget": "client:build:development", "buildTarget": "website:build:development",
"dev": true "dev": true
}, },
"staging": {
"buildTarget": "website:build:staging",
"dev": false
},
"production": { "production": {
"buildTarget": "client:build:production", "buildTarget": "website:build:production",
"dev": false "dev": false
} }
} }
@ -46,14 +45,14 @@
"export": { "export": {
"executor": "@nrwl/next:export", "executor": "@nrwl/next:export",
"options": { "options": {
"buildTarget": "client:build:production" "buildTarget": "website:build:production"
} }
}, },
"test": { "test": {
"executor": "@nrwl/jest:jest", "executor": "@nrwl/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"], "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": { "options": {
"jestConfig": "apps/client/jest.config.ts", "jestConfig": "apps/website/jest.config.ts",
"passWithNoTests": true "passWithNoTests": true
} }
}, },
@ -61,7 +60,7 @@
"executor": "@nrwl/linter:eslint", "executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"], "outputs": ["{options.outputFile}"],
"options": { "options": {
"lintFilePatterns": ["apps/client/**/*.{ts,tsx,js,jsx}"] "lintFilePatterns": ["apps/website/**/*.{ts,tsx,js,jsx}"]
} }
} }
}, },

@ -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 <img src> 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
Loading…
Cancel
Save