mirror of
https://github.com/twentyhq/twenty.git
synced 2024-11-22 11:43:34 +03:00
Update yarn commands (#4644)
* Simplify commands * Simplify commands * Migrate all dev commands to project.json * Fix tests
This commit is contained in:
parent
1639b2ad0e
commit
e576fe0d67
4
.github/workflows/ci-server.yaml
vendored
4
.github/workflows/ci-server.yaml
vendored
@ -30,7 +30,7 @@ jobs:
|
||||
- name: Server / Run linter
|
||||
run: yarn nx lint twenty-server
|
||||
- name: Server / Run jest tests
|
||||
run: yarn nx test twenty-server
|
||||
run: yarn nx test:unit twenty-server
|
||||
- name: Server / Build
|
||||
run: yarn nx build twenty-server
|
||||
- name: Server / Write .env
|
||||
@ -38,4 +38,4 @@ jobs:
|
||||
cd packages/twenty-server
|
||||
cp .env.example .env
|
||||
- name: Worker / Run
|
||||
run: MESSAGE_QUEUE_TYPE=sync yarn nx queue:work twenty-server
|
||||
run: MESSAGE_QUEUE_TYPE=sync yarn nx worker twenty-server
|
||||
|
2
.vscode/launch.json
vendored
2
.vscode/launch.json
vendored
@ -10,7 +10,7 @@
|
||||
"runtimeArgs": [
|
||||
"nx",
|
||||
"run",
|
||||
"twenty-server:start:dev",
|
||||
"twenty-server:start",
|
||||
],
|
||||
"outputCapture": "std",
|
||||
"internalConsoleOptions": "openOnSessionStart",
|
||||
|
@ -318,7 +318,7 @@
|
||||
},
|
||||
"version": "0.2.1",
|
||||
"scripts": {
|
||||
"start": "cross-env FORCE_COLOR=true concurrently -n \"twenty-server,twenty-front\" -c \"bgBlue.bold,bgGreen.bold\" \"yarn nx start:dev twenty-server\" \"yarn nx start twenty-front\""
|
||||
"start": "cross-env FORCE_COLOR=true concurrently -n \"twenty-server,twenty-front\" -c \"bgBlue.bold,bgGreen.bold\" \"yarn nx start twenty-server\" \"yarn nx start twenty-front\""
|
||||
},
|
||||
"workspaces": {
|
||||
"packages": [
|
||||
|
@ -13,35 +13,31 @@ import DocCardList from '@theme/DocCardList';
|
||||
|
||||
## Useful commands
|
||||
|
||||
These commands should be exectued from packages/twenty-server folder.
|
||||
From any other folder you can run `yarn nx <command>` twenty-server.
|
||||
|
||||
### First time setup
|
||||
|
||||
```
|
||||
yarn prisma:migrate # run migrations
|
||||
yarn prisma:generate # generate prisma and nestjs-graphql schemas
|
||||
yarn prisma:seed # provision database with seeds
|
||||
|
||||
# alternatively, you can run
|
||||
yarn prisma:reset # all-in-one command to reset, migrate, seed and generate schemas
|
||||
yarn nx database:reset # setup the database with dev seeds
|
||||
```
|
||||
|
||||
### Starting the app
|
||||
|
||||
```
|
||||
nx prisma:migrate twenty-server
|
||||
nx prisma:generate twenty-server
|
||||
nx start:dev twenty-server
|
||||
yarn nx start
|
||||
```
|
||||
|
||||
### Lint
|
||||
|
||||
```
|
||||
nx lint twenty-server
|
||||
yarn nx lint
|
||||
```
|
||||
|
||||
### Test
|
||||
|
||||
```
|
||||
nx test twenty-server
|
||||
yarn nx test:unit
|
||||
```
|
||||
|
||||
### Resetting the database
|
||||
@ -49,7 +45,7 @@ nx test twenty-server
|
||||
If you want to reset the database, you can run the following command:
|
||||
|
||||
```bash
|
||||
nx database:reset twenty-server
|
||||
yarn nx database:reset
|
||||
```
|
||||
|
||||
:::warning
|
||||
|
@ -97,7 +97,7 @@ Setup database, run migrations, and seed:
|
||||
```bash
|
||||
make docker-dev-sh
|
||||
yarn
|
||||
yarn nx database:init twenty-server
|
||||
yarn nx database:reset twenty-server
|
||||
```
|
||||
|
||||
## Step 5: Start Twenty
|
||||
@ -106,7 +106,7 @@ Run the project with the following commands from the `root` folder:
|
||||
|
||||
```bash
|
||||
make docker-dev-sh
|
||||
yarn nx start:dev twenty-server
|
||||
yarn nx start twenty-server
|
||||
```
|
||||
|
||||
and in a separate terminal:
|
||||
|
@ -183,12 +183,12 @@ yarn
|
||||
|
||||
Setup your database with the following command:
|
||||
```bash
|
||||
yarn nx database:init twenty-server
|
||||
yarn nx database:reset twenty-server
|
||||
```
|
||||
|
||||
Start the server and the frontend:
|
||||
```bash
|
||||
yarn nx start:dev twenty-server
|
||||
yarn nx start twenty-server
|
||||
yarn nx start twenty-front
|
||||
```
|
||||
|
||||
|
@ -36,7 +36,7 @@ The file shares are used to store uploaded images and files through the UI, and
|
||||
3. Run `terraform plan -out tfplan`
|
||||
4. Run `terraform apply tfplan`
|
||||
5. Connect to server `az containerapp exec --name twenty-server -g twenty-crm-rg`
|
||||
6. Initialize the database from the server `yarn database:init`
|
||||
6. Initialize the database from the server `yarn database:init:prod`
|
||||
7. Go to https://your-twenty-front-fqdn - located in the portal
|
||||
|
||||
#### Production docker containers
|
||||
|
@ -24,7 +24,7 @@ REFRESH_TOKEN_SECRET=replace_me_with_a_random_string_refresh
|
||||
|
||||
### Not able to login
|
||||
|
||||
If you encounter errors, (not able to log into the application after inputting an email) after the inital setup, try running `docker exec -it twenty-backend-1 yarn database:reset` and see if that solves your issue.
|
||||
If you encounter errors, (not able to log into the application after inputting an email) after the inital setup, try running `docker exec -it twenty-backend-1 yarn nx database:reset` and see if that solves your issue.
|
||||
|
||||
### Cannot connect to server, running behind a reverse proxy
|
||||
|
||||
|
@ -757,7 +757,6 @@ import {
|
||||
IconBrandPocket,
|
||||
IconBrandPolymer,
|
||||
IconBrandPowershell,
|
||||
IconBrandPrisma,
|
||||
IconBrandProducthunt,
|
||||
IconBrandPushbullet,
|
||||
IconBrandPushover,
|
||||
@ -4957,7 +4956,6 @@ export default {
|
||||
IconBrandPocket,
|
||||
IconBrandPolymer,
|
||||
IconBrandPowershell,
|
||||
IconBrandPrisma,
|
||||
IconBrandProducthunt,
|
||||
IconBrandPushbullet,
|
||||
IconBrandPushover,
|
||||
|
@ -7,29 +7,10 @@
|
||||
"license": "AGPL-3.0",
|
||||
"scripts": {
|
||||
"nx": "NX_DEFAULT_PROJECT=twenty-server node ../../node_modules/nx/bin/nx.js",
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "npx nx prebuild && nest build --path ./tsconfig.build.json",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "NODE_ENV=development && nest start",
|
||||
"start:dev": "npx nx start --watch",
|
||||
"start:debug": "npx nx start:dev --debug",
|
||||
"start:prod": "node dist/src/main",
|
||||
"lint": "eslint \"src/**/*.ts\" --fix",
|
||||
"test": "jest",
|
||||
"test:watch": "npx nx test --watch",
|
||||
"test:cov": "npx nx test --coverage",
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register ../../node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "./scripts/run-integration.sh",
|
||||
"typeorm": "npx ts-node ../../node_modules/typeorm/cli.js",
|
||||
"database:init": "npx nx database:setup && npx nx database:seed:dev",
|
||||
"database:setup": "npx ts-node ./scripts/setup-db.ts && npx nx database:migrate",
|
||||
"database:truncate": "npx ts-node ./scripts/truncate-db.ts",
|
||||
"database:migrate": "npx nx typeorm -- migration:run -d src/database/typeorm/metadata/metadata.datasource && npx nx typeorm -- migration:run -d src/database/typeorm/core/core.datasource",
|
||||
"database:seed:dev": "npx nx command -- workspace:seed:dev",
|
||||
"database:seed:demo": "npx nx command -- workspace:seed:demo",
|
||||
"database:reset": "npx nx database:truncate && npx nx database:init",
|
||||
"command": "node dist/src/command/command",
|
||||
"queue:work": "node dist/src/queue-worker/queue-worker",
|
||||
"command:prod": "node dist/src/command/command",
|
||||
"worker:prod": "node dist/src/queue-worker/queue-worker",
|
||||
"database:init:prod": "npx ts-node ./scripts/setup-db.ts && yarn database:migrate:prod",
|
||||
"database:migrate:prod": "npx -y typeorm migration:run -d dist/src/database/typeorm/metadata/metadata.datasource && npx -y typeorm migration:run -d dist/src/database/typeorm/core/core.datasource"
|
||||
},
|
||||
"dependencies": {
|
||||
|
@ -1,34 +1,155 @@
|
||||
{
|
||||
"name": "twenty-server",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"projectType": "application",
|
||||
"targets": {
|
||||
"build:packageJson": {
|
||||
"executor": "@nx/js:tsc",
|
||||
"dependsOn": [
|
||||
"prebuild"
|
||||
],
|
||||
"options": {
|
||||
"main": "packages/twenty-server/dist/src/main.js",
|
||||
"tsConfig": "packages/twenty-server/tsconfig.json",
|
||||
"outputPath": "packages/twenty-server/dist",
|
||||
"updateBuildableProjectDepsInPackageJson": true
|
||||
}
|
||||
},
|
||||
"command": {
|
||||
"executor": "nx:run-commands",
|
||||
"dependsOn": [
|
||||
"build"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "node dist/src/command/command.js"
|
||||
}
|
||||
},
|
||||
"test:debug": {
|
||||
"dependsOn": [
|
||||
"^build"
|
||||
]
|
||||
}
|
||||
"name": "twenty-server",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"projectType": "application",
|
||||
"targets": {
|
||||
"build": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"commands": ["rimraf dist", "nest build --path ./tsconfig.build.json"]
|
||||
}
|
||||
},
|
||||
"build:packageJson": {
|
||||
"executor": "@nx/js:tsc",
|
||||
"options": {
|
||||
"main": "packages/twenty-server/dist/src/main.js",
|
||||
"tsConfig": "packages/twenty-server/tsconfig.json",
|
||||
"outputPath": "packages/twenty-server/dist",
|
||||
"updateBuildableProjectDepsInPackageJson": true
|
||||
}
|
||||
},
|
||||
"start": {
|
||||
"executor": "nx:run-commands",
|
||||
"dependsOn": ["build"],
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "NODE_ENV=development && nest start --watch"
|
||||
}
|
||||
},
|
||||
"start:debug": {
|
||||
"executor": "nx:run-commands",
|
||||
"dependsOn": ["build"],
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "nx start --debug"
|
||||
}
|
||||
},
|
||||
"command": {
|
||||
"executor": "nx:run-commands",
|
||||
"dependsOn": ["build"],
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "node dist/src/command/command.js"
|
||||
}
|
||||
},
|
||||
"command-no-deps": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "node dist/src/command/command.js"
|
||||
}
|
||||
},
|
||||
"worker": {
|
||||
"executor": "nx:run-commands",
|
||||
"dependsOn": ["build"],
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "node dist/src/queue-worker/queue-worker.js"
|
||||
}
|
||||
},
|
||||
"typeorm": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "ts-node ../../node_modules/typeorm/cli.js"
|
||||
}
|
||||
},
|
||||
"ts-node": {
|
||||
"executor": "nx:run-commands",
|
||||
"dependsOn": ["build"],
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "ts-node"
|
||||
}
|
||||
},
|
||||
"ts-node-no-deps": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "ts-node"
|
||||
}
|
||||
},
|
||||
"lint": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "eslint \"src/**/*.ts\" --fix"
|
||||
}
|
||||
},
|
||||
"test:unit": {
|
||||
"executor": "nx:run-commands",
|
||||
"dependsOn": ["build"],
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "jest"
|
||||
}
|
||||
},
|
||||
"test:unit:watch": {
|
||||
"executor": "nx:run-commands",
|
||||
"dependsOn": ["build"],
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "jest --watch"
|
||||
}
|
||||
},
|
||||
"test:unit:coverage": {
|
||||
"executor": "nx:run-commands",
|
||||
"dependsOn": ["build"],
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "jest --coverage"
|
||||
}
|
||||
},
|
||||
"test:unit:debug": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register ../../node_modules/.bin/jest --runInBand"
|
||||
}
|
||||
},
|
||||
"test:e2e": {
|
||||
"executor": "nx:run-commands",
|
||||
"dependsOn": ["build"],
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"command": "./scripts/run-integration.sh"
|
||||
}
|
||||
},
|
||||
"database:migrate": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"commands": [
|
||||
"nx typeorm -- migration:run -d src/database/typeorm/metadata/metadata.datasource",
|
||||
"nx typeorm -- migration:run -d src/database/typeorm/core/core.datasource"
|
||||
],
|
||||
"parallel": false
|
||||
}
|
||||
},
|
||||
"database:reset": {
|
||||
"executor": "nx:run-commands",
|
||||
"dependsOn": ["build"],
|
||||
"options": {
|
||||
"cwd": "packages/twenty-server",
|
||||
"commands": [
|
||||
"nx ts-node-no-deps -- ./scripts/truncate-db.ts",
|
||||
"nx ts-node-no-deps -- ./scripts/setup-db.ts",
|
||||
"nx database:migrate",
|
||||
"nx command-no-deps -- workspace:seed:dev"
|
||||
],
|
||||
"parallel": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
export PG_DATABASE_URL=postgres://twenty:twenty@$PG_DATABASE_HOST:$PG_DATABASE_PORT/default
|
||||
yarn database:setup
|
||||
yarn database:init:prod
|
||||
node dist/src/main
|
||||
|
@ -4,5 +4,5 @@
|
||||
DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
source $DIR/set-env-test.sh
|
||||
|
||||
yarn database:init
|
||||
yarn jest --config ./test/jest-e2e.json
|
||||
yarn nx database:reset
|
||||
yarn nx jest --config ./test/jest-e2e.json
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
|
||||
|
||||
const environmentService = new EnvironmentService(new ConfigService());
|
||||
|
Loading…
Reference in New Issue
Block a user