diff --git a/.gitignore b/.gitignore index 04e07405572..ac1000ee959 100644 --- a/.gitignore +++ b/.gitignore @@ -17,5 +17,4 @@ !.yarn/sdks !.yarn/versions coverage -.vercel -**/yarn.lock \ No newline at end of file +.vercel \ No newline at end of file diff --git a/nx.json b/nx.json index 1347363db7f..e83387b0883 100644 --- a/nx.json +++ b/nx.json @@ -2,20 +2,38 @@ "targetDefaults": { "build": { "cache": true, - "dependsOn": ["^build"] + "dependsOn": [ + "^build" + ] + }, + "start": { + "cache": true, + "dependsOn": [ + "^build" + ] }, "lint": { "cache": true }, "test": { - "cache": true + "cache": true, + "dependsOn": [ + "^build" + ] }, - "e2e": { - "cache": true + "test:e2e": { + "cache": true, + "dependsOn": [ + "^build" + ] }, "@nx/jest:jest": { "cache": true, - "inputs": ["default", "^default", "{workspaceRoot}/jest.preset.js"], + "inputs": [ + "default", + "^default", + "{workspaceRoot}/jest.preset.js" + ], "options": { "passWithNoTests": true }, @@ -25,6 +43,13 @@ "codeCoverage": true } } + }, + "@nx/vite:test": { + "cache": true, + "inputs": [ + "default", + "^default" + ] } }, "installation": { @@ -32,5 +57,15 @@ }, "affected": { "defaultBase": "main" + }, + "generators": { + "@nx/react": { + "application": { + "babel": true + }, + "library": { + "unitTestRunner": "none" + } + } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 775af78ed7e..e5dc52ef816 100644 --- a/package.json +++ b/package.json @@ -155,6 +155,8 @@ "zod": "^3.22.2" }, "devDependencies": { + "@babel/core": "^7.14.5", + "@babel/preset-react": "^7.14.5", "@docusaurus/module-type-aliases": "^3.0.0", "@docusaurus/tsconfig": "3.0.0", "@graphql-codegen/cli": "^3.3.1", @@ -168,7 +170,9 @@ "@nx/eslint": "17.2.7", "@nx/eslint-plugin": "17.2.7", "@nx/jest": "17.2.7", - "@nx/js": "17.2.7", + "@nx/js": "17.2.8", + "@nx/react": "^17.2.8", + "@nx/vite": "17.2.8", "@storybook/addon-actions": "^7.6.3", "@storybook/addon-coverage": "^1.0.0", "@storybook/addon-essentials": "^7.6.7", @@ -185,7 +189,7 @@ "@swc-node/register": "~1.6.7", "@swc/core": "~1.3.100", "@testing-library/jest-dom": "^6.1.5", - "@testing-library/react": "^13.4.0", + "@testing-library/react": "14.0.0", "@types/apollo-upload-client": "^17.0.2", "@types/bcrypt": "^5.0.0", "@types/better-sqlite3": "^7.6.8", @@ -241,6 +245,7 @@ "jest": "29.7.0", "jest-environment-jsdom": "29.7.0", "jest-fetch-mock": "^3.0.3", + "jsdom": "~22.1.0", "msw": "^2.0.11", "msw-storybook-addon": "2.0.0--canary.122.b3ed3b1.0", "nx": "^17.2.8", @@ -259,6 +264,7 @@ "typescript": "^5.3.3", "vite": "^5.0.0", "vite-plugin-checker": "^0.6.2", + "vite-plugin-dts": "~2.3.0", "vite-plugin-svgr": "^4.2.0" }, "engines": { diff --git a/packages/twenty-docker/prod/twenty-server/Dockerfile b/packages/twenty-docker/prod/twenty-server/Dockerfile index 26ec019287d..52896d0d92a 100644 --- a/packages/twenty-docker/prod/twenty-server/Dockerfile +++ b/packages/twenty-docker/prod/twenty-server/Dockerfile @@ -5,20 +5,15 @@ WORKDIR /app COPY ./package.json . COPY ./yarn.lock . COPY ./.yarnrc.yml . +COPY ./tsconfig.base.json . +COPY ./nx.json . COPY ./.yarn/releases /app/.yarn/releases -COPY ./tools/eslint-rules /app/tools/eslint-rules -COPY ./packages/twenty-server/package.json /app/packages/twenty-server/package.json -COPY ./packages/twenty-server/patches /app/packages/twenty-server/patches COPY ./packages/twenty-emails /app/packages/twenty-emails - -WORKDIR /app/packages/twenty-emails -RUN yarn workspaces focus -RUN yarn build +COPY ./packages/twenty-server /app/packages/twenty-server +RUN yarn workspaces focus twenty-emails twenty-server +RUN npx nx run twenty-server:build WORKDIR /app/packages/twenty-server -COPY ./packages/twenty-server /app/packages/twenty-server -RUN yarn workspaces focus -RUN yarn build LABEL org.opencontainers.image.source=https://github.com/twentyhq/twenty LABEL org.opencontainers.image.description="This image provides a consistent and reproducible environment for the backend, ensuring it deploys faster and runs the same way regardless of the deployment environment." diff --git a/packages/twenty-emails/.babelrc b/packages/twenty-emails/.babelrc new file mode 100644 index 00000000000..1ea870ead41 --- /dev/null +++ b/packages/twenty-emails/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nx/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/packages/twenty-emails/.eslintrc.json b/packages/twenty-emails/.eslintrc.json new file mode 100644 index 00000000000..d3e61a2ea85 --- /dev/null +++ b/packages/twenty-emails/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["../../.eslintrc.js"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/packages/twenty-emails/package.json b/packages/twenty-emails/package.json index 44fc1ca1ebb..7aaac25a767 100644 --- a/packages/twenty-emails/package.json +++ b/packages/twenty-emails/package.json @@ -8,18 +8,32 @@ "main": "./dist/index.js", "scripts": { "nx": "NX_DEFAULT_PROJECT=twenty-emails node ../../node_modules/nx/bin/nx.js", - "build": "tsup" + "build": "vite build", + "lint": "eslint" + }, + "exports": { + ".": { + "import": "./dist/index.mjs", + "require": "./dist/index.js" + } }, "devDependencies": { + "@nx/vite": "17.2.8", + "@vitejs/plugin-react-swc": "^3.5.0", + "vite": "^5.0.0", + "vite-plugin-dts": "~2.3.0", + "vite-tsconfig-paths": "^4.2.1" + }, + "dependencies": { "@react-email/components": "0.0.12", - "@types/react": "^18.2.39", - "date-fns": "^2.30.0", - "tsup": "^8.0.1", - "typescript": "^5.3.3" + "date-fns": "^2.30.0" }, "engines": { "node": "^18.17.1", "npm": "please-use-yarn", "yarn": "^4.0.2" + }, + "nx": { + "projectType": "library" } -} +} \ No newline at end of file diff --git a/packages/twenty-emails/src/components/BaseEmail.tsx b/packages/twenty-emails/src/components/BaseEmail.tsx index 4ab7741fcd3..0e42470d6f5 100644 --- a/packages/twenty-emails/src/components/BaseEmail.tsx +++ b/packages/twenty-emails/src/components/BaseEmail.tsx @@ -1,13 +1,17 @@ -import * as React from 'react'; +import { PropsWithChildren } from 'react'; import { Container, Html } from '@react-email/components'; import { BaseHead } from 'src/components/BaseHead'; import { Logo } from 'src/components/Logo'; -export const BaseEmail = ({ children, width = 290 }) => { +type BaseEmailProps = PropsWithChildren<{ + width?: number; +}>; + +export const BaseEmail = ({ children, width }: BaseEmailProps) => { return ( - + {children} diff --git a/packages/twenty-emails/src/components/BaseHead.tsx b/packages/twenty-emails/src/components/BaseHead.tsx index def13457474..449d22abab6 100644 --- a/packages/twenty-emails/src/components/BaseHead.tsx +++ b/packages/twenty-emails/src/components/BaseHead.tsx @@ -1,4 +1,3 @@ -import * as React from 'react'; import { Font, Head } from '@react-email/components'; import { emailTheme } from 'src/common-style'; diff --git a/packages/twenty-emails/src/components/CallToAction.tsx b/packages/twenty-emails/src/components/CallToAction.tsx index 54448280136..cb49569b49d 100644 --- a/packages/twenty-emails/src/components/CallToAction.tsx +++ b/packages/twenty-emails/src/components/CallToAction.tsx @@ -1,6 +1,7 @@ -import * as React from 'react'; +import { ReactNode } from 'react'; import { Button } from '@react-email/button'; import { emailTheme } from 'src/common-style'; + const callToActionStyle = { display: 'flex', padding: '8px 32px', @@ -13,7 +14,12 @@ const callToActionStyle = { fontWeight: emailTheme.font.weight.bold, }; -export const CallToAction = ({ value, href }) => { +type CallToActionProps = { + href: string; + value: ReactNode; +}; + +export const CallToAction = ({ value, href }: CallToActionProps) => { return (