Skip to content

Commit

Permalink
Moved to nx monorepo
Browse files Browse the repository at this point in the history
  • Loading branch information
begelundmuller committed Apr 1, 2022
1 parent fd51bc4 commit 3e4add5
Show file tree
Hide file tree
Showing 90 changed files with 8,703 additions and 501 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Editor configuration, see http://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
max_line_length = off
trim_trailing_whitespace = false
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SECRET="secret"

POSTGRES_URL="postgresql://postgres:postgres@localhost:54321/"
POSTGRES_URL="postgresql://postgres:postgres@localhost:5432/"

NEXTAUTH_URL="http://localhost:3000"

Expand Down
18 changes: 0 additions & 18 deletions .eslintrc

This file was deleted.

64 changes: 64 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"extends": ["prettier", "plugin:import/recommended"],
"plugins": ["import"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
],
"import/order": [
"error",
{
"groups": ["builtin", "external", ["internal", "unknown"], "parent", "sibling", "index"],
"newlines-between": "always",
"alphabetize": { "order": "asc", "caseInsensitive": true }
}
]
},
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"typescript": {
"project": ["tsconfig.base.json", "apps/*/tsconfig.json", "libs/*/tsconfig.json"]
},
"node": {
"project": ["tsconfig.base.json", "apps/*/tsconfig.json", "libs/*/tsconfig.json"]
}
}
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"rules": {
"quotes": ["error", "double", { "allowTemplateLiterals": true, "avoidEscape": true }],
"semi": ["error", "always"]
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"rules": {
"quotes": ["error", "double", { "allowTemplateLiterals": true, "avoidEscape": true }],
"semi": ["error", "always"]
}
}
]
}
43 changes: 38 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,39 @@
.DS_Store
.env
# compiled output
/dist
/tmp
/out-tsc
.next
.vercel
node_modules
prisma/dev.db

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
.env
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Add files here to ignore them from prettier formatting

/dist
/coverage
.next
.vercel
8 changes: 8 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"recommendations": [
"nrwl.angular-console",
"esbenp.prettier-vscode",
"firsttris.vscode-jest-runner",
"dbaeumer.vscode-eslint"
]
}
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

- [x] Setup web stack consisting of [Next.js](https://nextjs.org), [Tailwind CSS](https://tailwindcss.com), and [Prisma](https://www.prisma.io)
- [x] Add authentication using [Next Auth](https://next-auth.js.org)
- [ ] Add support for user and workspace deletion
- [ ] Add monorepo setup with NX
- [x] Add support for user and workspace deletion
- [x] Add monorepo setup with NX
- [x] Add good testing facilities, incl. end to end testing
- [ ] Add docs with Docusaurus or Nextra exposed on `/docs`
- [ ] Add highly configurable authorization management
- [ ] Add workspace and groups administration
- [ ] Add good testing facilities, incl. end to end testing
- [ ] Add SSO and SAML support using [Work OS](https://workos.com) or [BoxyHQ](https://boxyhq.com)
- [ ] Add billing, subscription and tax management with support for usage-based pricing using [Stripe](https://stripe.com/) or [Paddle](https://paddle.com)
- [ ] Add docs with Docusaurus or Nextra exposed on `/docs`
- [ ] Add Docker dev containers and Docker Compose for local development with all dependencies set up
- [ ] Add Docker image builds using Github CI/CD
- [ ] Add deployment documentation for Postgres and [CockroachDB])(https://www.cockroachlabs.com)
Expand All @@ -41,11 +41,22 @@
- [ ] Add status page with Atlassian Statuspage
- [ ] Add search with https://typesense.org


## Set up a development environment

Complete the following steps to set up a development environment

1. Copy `.env.example` into `.env` (ignored by Git) and populate the settings. For development purposes, it is sufficient to specify one authentication provider. You can use [Ethereal](ethereal.email) to quickly configure email authentication.
2. Spin up the development dependencies using `docker-compose up`
3. Run migrations and seed the database using `npx prisma migrate dev` followed by `npx prisma db seed`
4. Run `yarn dev` to start the site
2. Install Docker if you don't already have it installed
2. Spin up a development container in VS Code by running the "Remote-Containers: Reopen in Container" command
3. Install dependencies by running `yarn install`
4. Run migrations with `yarn migrate`
5. Run `yarn start` to start the site and open i

## Using `nx`

This project uses `nx` for monorepo management:

- Run `nx g @nrwl/TYPE:lib my-lib` to generate a library (replace `TYPE` with e.g. `next` or `workspace`)
- Run `nx e2e frontend` or `nx affected:e2e frontend` to run end-to-end tests
- Run `nx graph` to see a diagram of the project dependencies
17 changes: 17 additions & 0 deletions apps/frontend-e2e/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"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"
}
}
]
}
12 changes: 12 additions & 0 deletions apps/frontend-e2e/cypress.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"fileServerFolder": ".",
"fixturesFolder": "./src/fixtures",
"integrationFolder": "./src/integration",
"modifyObstructiveCode": false,
"supportFile": "./src/support/index.ts",
"pluginsFile": false,
"video": true,
"videosFolder": "../../dist/cypress/apps/frontend-e2e/videos",
"screenshotsFolder": "../../dist/cypress/apps/frontend-e2e/screenshots",
"chromeWebSecurity": false
}
28 changes: 28 additions & 0 deletions apps/frontend-e2e/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"root": "apps/frontend-e2e",
"sourceRoot": "apps/frontend-e2e/src",
"projectType": "application",
"targets": {
"e2e": {
"executor": "@nrwl/cypress:cypress",
"options": {
"cypressConfig": "apps/frontend-e2e/cypress.json",
"devServerTarget": "frontend:serve"
},
"configurations": {
"production": {
"devServerTarget": "frontend:serve:production"
}
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/frontend-e2e/**/*.{js,ts}"]
}
}
},
"tags": [],
"implicitDependencies": ["frontend"]
}
4 changes: 4 additions & 0 deletions apps/frontend-e2e/src/fixtures/example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "Using fixtures to represent data",
"email": "[email protected]"
}
14 changes: 14 additions & 0 deletions apps/frontend-e2e/src/integration/app.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
describe("frontend", () => {
beforeEach(() => cy.visit("/"));

it("should redirect to the sign in page", () => {
cy.get("h2").contains("Sign in");
});

// it("should redirect to create a workspace on sign in", () => {
// cy.get("h2").contains("Sign in");
// });

// Custom command example, see `../support/commands.ts` file
// cy.login("[email protected]", "myPassword");
});
1 change: 1 addition & 0 deletions apps/frontend-e2e/src/support/app.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const getGreeting = () => cy.get("h1");
33 changes: 33 additions & 0 deletions apps/frontend-e2e/src/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// ***********************************************
// 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) => { ... })
17 changes: 17 additions & 0 deletions apps/frontend-e2e/src/support/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// ***********************************************************
// 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";
10 changes: 10 additions & 0 deletions apps/frontend-e2e/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"allowJs": true,
"types": ["cypress", "node"]
},
"include": ["src/**/*.ts", "src/**/*.js"]
}
30 changes: 30 additions & 0 deletions apps/frontend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"extends": [
"plugin:@nrwl/nx/react-typescript",
"../../.eslintrc.json",
"next",
"next/core-web-vitals"
],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@next/next/no-html-link-for-pages": ["error", "apps/frontend/pages"],
"react/prop-types": 0,
"react/no-unescaped-entities": 0
}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
],
"env": {
"jest": true
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const Avatar: React.FC<Props> = ({ name, image }) => {

let hash = 0;
for (let i = 0; i < initials.length; i++) {
let char = initials.charCodeAt(i);
const char = initials.charCodeAt(i);
hash = (hash << 5) - hash + char;
hash = hash & hash;
}
Expand Down
Loading

0 comments on commit 3e4add5

Please sign in to comment.