From 5c378bc8ceaf207780ab29014117cb17497d50db Mon Sep 17 00:00:00 2001 From: Matti Nannt Date: Thu, 13 Oct 2022 09:46:43 +0200 Subject: [PATCH] Feature/monorepo #95 (#105) Move repository into a monorepo with turborepo and pnpm. This is a big change in the way the code is organized, used and deployed. --- .devcontainer/Dockerfile | 14 - .devcontainer/devcontainer.json | 31 - .devcontainer/docker-compose.yml | 63 - .env.example | 76 +- .eslintrc.js | 10 + .eslintrc.json | 3 - .github/workflows/checks.yml | 15 +- .gitignore | 26 +- .npmrc | 6 + .prettierrc.js | 1 + Dockerfile | 39 - README.md | 84 +- apps/web/.eslintrc.js | 4 + apps/web/.gitignore | 40 + apps/web/Dockerfile | 38 + .../web/components}/FormList.tsx | 73 +- .../web/components}/Loading.tsx | 4 +- .../web/components}/LoadingModal.tsx | 20 +- .../web/components}/MessagePage.tsx | 6 +- {components => apps/web/components}/Modal.tsx | 23 +- .../web/components}/StandardButton.tsx | 5 +- .../web/components}/builder/Builder.tsx | 34 +- .../web/components}/builder/PageToolbar.tsx | 23 +- .../web/components}/builder/SettingsModal.tsx | 67 +- .../web/components}/builder/ShareModal.tsx | 49 +- .../web/components}/editorjs/Editor.tsx | 14 +- .../editorjs/tools/EmailQuestion.tsx | 48 +- .../editorjs/tools/MultipleChoiceQuestion.tsx | 5 +- .../tools/MultipleChoiceQuestionComponent.tsx | 49 +- .../editorjs/tools/NumberQuestion.tsx | 39 +- .../editorjs/tools/PageTransition.tsx | 28 +- .../editorjs/tools/PhoneQuestion.tsx | 45 +- .../editorjs/tools/TextQuestion.tsx | 39 +- .../editorjs/tools/TextareaQuestion.tsx | 39 +- .../editorjs/tools/WebsiteQuestion.tsx | 48 +- .../web/components}/form/FormCode.tsx | 71 +- .../web/components}/form/NewFormModal.tsx | 74 +- .../web/components}/frontend/App.tsx | 54 +- .../layout/BaseLayoutManagement.tsx | 23 +- .../layout/BaseLayoutUnauthorized.tsx | 0 .../components}/layout/EmptyPageFiller.tsx | 12 +- .../web/components}/layout/FullWidth.tsx | 2 +- .../web/components}/layout/LayoutPreview.tsx | 22 +- .../web/components}/layout/LimitedWidth.tsx | 2 +- .../components}/layout/MenuBreadcrumbs.tsx | 15 +- .../web/components}/layout/MenuProfile.tsx | 24 +- .../web/components}/layout/MenuSteps.tsx | 16 +- .../components}/layout/NewFormNavButton.tsx | 7 +- .../web/components}/layout/SecondNavBar.tsx | 17 +- .../components}/layout/WithAuthentication.tsx | 0 .../pipelines/AddPipelineModal.tsx | 31 +- .../pipelines/UpdatePipelineModal.tsx | 34 +- .../pipelines/webhook/SettingsComponent.tsx | 70 +- .../components}/pipelines/webhook/handler.ts | 15 +- .../components}/pipelines/webhook/index.ts | 3 +- .../web/components}/results/AnalyticsCard.tsx | 38 +- .../components}/results/DownloadResponses.tsx | 32 +- .../components}/results/ResultsInsights.tsx | 28 +- .../components}/results/ResultsResponses.tsx | 152 +- .../components}/results/ResultsSummary.tsx | 22 +- .../web/components}/results/Submission.tsx | 12 +- .../components}/results/SubmissionDisplay.tsx | 11 +- .../results/summary/BaseResults.tsx | 20 +- .../results/summary/ChoiceResults.tsx | 2 +- .../results/summary/TextResults.tsx | 4 +- {lib => apps/web/lib}/api.ts | 2 +- {lib => apps/web/lib}/apiEvents.ts | 19 +- {lib => apps/web/lib}/auth.ts | 4 +- {lib => apps/web/lib}/email.ts | 18 +- {lib => apps/web/lib}/events.ts | 0 {lib => apps/web/lib}/forms.ts | 21 +- apps/web/lib/jwt.ts | 27 + .../navigation/formCodeSecondNavigation.ts | 5 +- .../web/lib}/navigation/formMenuSteps.ts | 0 .../navigation/formResultsSecondNavigation.ts | 6 +- {lib => apps/web/lib}/noCodeForm.ts | 14 +- {lib => apps/web/lib}/pipelines.ts | 10 +- {lib => apps/web/lib}/posthog.ts | 6 +- {lib => apps/web/lib}/submissionSessions.ts | 62 +- {lib => apps/web/lib}/telemetry.ts | 0 {lib => apps/web/lib}/types.ts | 5 +- {lib => apps/web/lib}/users.ts | 2 +- {lib => apps/web/lib}/utils.ts | 8 +- next-env.d.ts => apps/web/next-env.d.ts | 0 next.config.js => apps/web/next.config.js | 4 + apps/web/package.json | 61 + apps/web/pages/404.tsx | 30 + {pages => apps/web/pages}/_app.tsx | 7 +- apps/web/pages/_document.tsx | 20 + .../web/pages}/api/auth/[...nextauth].ts | 15 +- .../web/pages}/api/forms/[id]/event.ts | 9 +- .../web/pages}/api/forms/[id]/index.ts | 15 +- .../pages}/api/forms/[id]/nocodeform/index.ts | 15 +- .../[id]/pipelines/[pipelineId]/index.ts | 11 +- .../pages}/api/forms/[id]/pipelines/index.ts | 15 +- .../[submissionSessionId]/index.ts | 11 +- .../forms/[id]/submissionSessions/index.ts | 14 +- {pages => apps/web/pages}/api/forms/index.ts | 11 +- .../api/public/forms/[id]/nocodeform/index.ts | 7 +- .../api/public/users/forgot-password.tsx | 11 +- .../web/pages}/api/public/users/index.tsx | 11 +- .../api/public/users/reset-password.tsx | 19 +- .../api/public/users/verification-email.tsx | 11 +- .../pages/auth/forgot-password-email-sent.tsx | 34 + .../web/pages}/auth/forgot-password.tsx | 35 +- .../web/pages/auth/reset-password-success.tsx | 31 + .../web/pages}/auth/reset-password.tsx | 30 +- {pages => apps/web/pages}/auth/signin.tsx | 54 +- .../signup-without-verification-success.tsx | 36 + {pages => apps/web/pages}/auth/signup.tsx | 76 +- .../pages}/auth/verification-requested.tsx | 26 +- {pages => apps/web/pages}/auth/verify.tsx | 10 +- {pages => apps/web/pages}/f/[id].tsx | 36 +- .../web/pages}/forms/[id]/form/index.tsx | 15 +- .../web/pages}/forms/[id]/form/react.tsx | 62 +- .../web/pages}/forms/[id]/index.tsx | 6 +- .../web/pages}/forms/[id]/pipelines.tsx | 125 +- .../web/pages}/forms/[id]/preview.tsx | 15 +- .../pages}/forms/[id]/results/insights.tsx | 12 +- .../pages}/forms/[id]/results/responses.tsx | 18 +- .../web/pages}/forms/[id]/results/summary.tsx | 12 +- {pages => apps/web/pages}/forms/index.tsx | 3 +- .../web/postcss.config.js | 0 {public => apps/web/public}/favicon.ico | Bin .../favicons/android-chrome-192x192.png | Bin .../favicons/android-chrome-256x256.png | Bin .../web/public}/favicons/apple-touch-icon.png | Bin .../web/public}/favicons/favicon-16x16.png | Bin .../web/public}/favicons/favicon-32x32.png | Bin .../web/public}/favicons/mstile-150x150.png | Bin .../public}/favicons/safari-pinned-tab.svg | 0 .../web/public}/favicons/site.webmanifest | 0 .../web/public}/fonts/Poppins-Black.woff | Bin .../web/public}/fonts/Poppins-Black.woff2 | Bin .../web/public}/fonts/Poppins-Bold.woff | Bin .../web/public}/fonts/Poppins-Bold.woff2 | Bin .../web/public}/fonts/Poppins-ExtraBold.woff | Bin .../web/public}/fonts/Poppins-ExtraBold.woff2 | Bin .../web/public}/fonts/Poppins-ExtraLight.woff | Bin .../public}/fonts/Poppins-ExtraLight.woff2 | Bin .../web/public}/fonts/Poppins-Light.woff | Bin .../web/public}/fonts/Poppins-Light.woff2 | Bin .../web/public}/fonts/Poppins-Medium.woff | Bin .../web/public}/fonts/Poppins-Medium.woff2 | Bin .../web/public}/fonts/Poppins-Regular.woff | Bin .../web/public}/fonts/Poppins-Regular.woff2 | Bin .../web/public}/fonts/Poppins-SemiBold.woff | Bin .../web/public}/fonts/Poppins-SemiBold.woff2 | Bin .../web/public}/fonts/Poppins-Thin.woff | Bin .../web/public}/fonts/Poppins-Thin.woff2 | Bin .../web/public}/img/a-b-test-v1.svg | 0 .../web/public}/img/avatar-placeholder.png | Bin .../web/public}/img/drop-offs-v1.svg | 0 .../web/public}/img/mascot-face-small.png | Bin .../web/public}/img/snoopforms-logo.svg | 0 {public => apps/web/public}/vercel.svg | 0 {styles => apps/web/styles}/editorjs.css | 0 {styles => apps/web/styles}/globals.css | 0 {styles => apps/web/styles}/toastify.css | 0 .../web/tailwind.config.js | 0 apps/web/tsconfig.json | 5 + docker-compose.dev.yml | 25 + docker-compose.yml | 5 +- lib/jwt.ts | 34 - lib/prisma.ts | 21 - package.json | 76 +- packages/database/.env | 1 + packages/database/.eslintrc.js | 4 + packages/database/package.json | 39 + .../20220624041413_initial/migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../20220713132158_add_signup/migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../migration.sql | 0 .../prisma}/migrations/migration_lock.toml | 0 .../database/prisma}/schema.prisma | 0 packages/database/src/client.ts | 9 + packages/database/src/index.ts | 1 + packages/database/tsconfig.json | 5 + packages/database/tsup.config.ts | 12 + packages/eslint-config-custom/index.js | 7 + packages/eslint-config-custom/package.json | 19 + .../prettier-config/merged-prettier-plugin.js | 12 + packages/prettier-config/package.json | 13 + packages/prettier-config/prettier-preset.js | 11 + packages/tailwind-config/package.json | 9 + packages/tailwind-config/tailwind.config.js | 19 + packages/tsconfig/base.json | 20 + .../tsconfig/nextjs.json | 20 +- packages/tsconfig/node16.json | 14 + packages/tsconfig/package.json | 9 + packages/tsconfig/react-library.json | 11 + packages/ui/package.json | 29 + packages/ui/src/Button.tsx | 44 + packages/ui/src/index.tsx | 1 + packages/ui/src/styles.css | 3 + packages/ui/src/utils.ts | 3 + packages/ui/tailwind.config.js | 3 + packages/ui/tsconfig.json | 5 + pages/404.tsx | 34 - pages/_document.tsx | 38 - pages/auth/forgot-password-email-sent.tsx | 45 - pages/auth/reset-password-success.tsx | 44 - .../signup-without-verification-success.tsx | 47 - pnpm-lock.yaml | 4459 +++++++++++++++++ pnpm-workspace.yaml | 3 + turbo.json | 28 + yarn.lock | 2835 ----------- 210 files changed, 6064 insertions(+), 5021 deletions(-) delete mode 100644 .devcontainer/Dockerfile delete mode 100644 .devcontainer/devcontainer.json delete mode 100644 .devcontainer/docker-compose.yml create mode 100644 .eslintrc.js delete mode 100644 .eslintrc.json create mode 100644 .npmrc create mode 100644 .prettierrc.js delete mode 100644 Dockerfile create mode 100644 apps/web/.eslintrc.js create mode 100644 apps/web/.gitignore create mode 100644 apps/web/Dockerfile rename {components => apps/web/components}/FormList.tsx (63%) rename {components => apps/web/components}/Loading.tsx (74%) rename {components => apps/web/components}/LoadingModal.tsx (67%) rename {components => apps/web/components}/MessagePage.tsx (54%) rename {components => apps/web/components}/Modal.tsx (68%) rename {components => apps/web/components}/StandardButton.tsx (92%) rename {components => apps/web/components}/builder/Builder.tsx (81%) rename {components => apps/web/components}/builder/PageToolbar.tsx (61%) rename {components => apps/web/components}/builder/SettingsModal.tsx (61%) rename {components => apps/web/components}/builder/ShareModal.tsx (64%) rename {components => apps/web/components}/editorjs/Editor.tsx (92%) rename {components => apps/web/components}/editorjs/tools/EmailQuestion.tsx (74%) rename {components => apps/web/components}/editorjs/tools/MultipleChoiceQuestion.tsx (97%) rename {components => apps/web/components}/editorjs/tools/MultipleChoiceQuestionComponent.tsx (65%) rename {components => apps/web/components}/editorjs/tools/NumberQuestion.tsx (78%) rename {components => apps/web/components}/editorjs/tools/PageTransition.tsx (62%) rename {components => apps/web/components}/editorjs/tools/PhoneQuestion.tsx (74%) rename {components => apps/web/components}/editorjs/tools/TextQuestion.tsx (74%) rename {components => apps/web/components}/editorjs/tools/TextareaQuestion.tsx (78%) rename {components => apps/web/components}/editorjs/tools/WebsiteQuestion.tsx (76%) rename {components => apps/web/components}/form/FormCode.tsx (66%) rename {components => apps/web/components}/form/NewFormModal.tsx (67%) rename {components => apps/web/components}/frontend/App.tsx (77%) rename {components => apps/web/components}/layout/BaseLayoutManagement.tsx (66%) rename {components => apps/web/components}/layout/BaseLayoutUnauthorized.tsx (100%) rename {components => apps/web/components}/layout/EmptyPageFiller.tsx (70%) rename {components => apps/web/components}/layout/FullWidth.tsx (69%) rename {components => apps/web/components}/layout/LayoutPreview.tsx (56%) rename {components => apps/web/components}/layout/LimitedWidth.tsx (70%) rename {components => apps/web/components}/layout/MenuBreadcrumbs.tsx (70%) rename {components => apps/web/components}/layout/MenuProfile.tsx (65%) rename {components => apps/web/components}/layout/MenuSteps.tsx (73%) rename {components => apps/web/components}/layout/NewFormNavButton.tsx (65%) rename {components => apps/web/components}/layout/SecondNavBar.tsx (60%) rename {components => apps/web/components}/layout/WithAuthentication.tsx (100%) rename {components => apps/web/components}/pipelines/AddPipelineModal.tsx (67%) rename {components => apps/web/components}/pipelines/UpdatePipelineModal.tsx (55%) rename {components => apps/web/components}/pipelines/webhook/SettingsComponent.tsx (67%) rename {components => apps/web/components}/pipelines/webhook/handler.ts (57%) rename {components => apps/web/components}/pipelines/webhook/index.ts (55%) rename {components => apps/web/components}/results/AnalyticsCard.tsx (52%) rename {components => apps/web/components}/results/DownloadResponses.tsx (80%) rename {components => apps/web/components}/results/ResultsInsights.tsx (70%) rename {components => apps/web/components}/results/ResultsResponses.tsx (50%) rename {components => apps/web/components}/results/ResultsSummary.tsx (79%) rename {components => apps/web/components}/results/Submission.tsx (84%) rename {components => apps/web/components}/results/SubmissionDisplay.tsx (83%) rename {components => apps/web/components}/results/summary/BaseResults.tsx (69%) rename {components => apps/web/components}/results/summary/ChoiceResults.tsx (94%) rename {components => apps/web/components}/results/summary/TextResults.tsx (84%) rename {lib => apps/web/lib}/api.ts (92%) rename {lib => apps/web/lib}/apiEvents.ts (83%) rename {lib => apps/web/lib}/auth.ts (94%) rename {lib => apps/web/lib}/email.ts (87%) rename {lib => apps/web/lib}/events.ts (100%) rename {lib => apps/web/lib}/forms.ts (87%) create mode 100644 apps/web/lib/jwt.ts rename {lib => apps/web/lib}/navigation/formCodeSecondNavigation.ts (90%) rename {lib => apps/web/lib}/navigation/formMenuSteps.ts (100%) rename {lib => apps/web/lib}/navigation/formResultsSecondNavigation.ts (87%) rename {lib => apps/web/lib}/noCodeForm.ts (78%) rename {lib => apps/web/lib}/pipelines.ts (87%) rename {lib => apps/web/lib}/posthog.ts (89%) rename {lib => apps/web/lib}/submissionSessions.ts (70%) rename {lib => apps/web/lib}/telemetry.ts (100%) rename {lib => apps/web/lib}/types.ts (96%) rename {lib => apps/web/lib}/users.ts (98%) rename {lib => apps/web/lib}/utils.ts (93%) rename next-env.d.ts => apps/web/next-env.d.ts (100%) rename next.config.js => apps/web/next.config.js (93%) create mode 100644 apps/web/package.json create mode 100644 apps/web/pages/404.tsx rename {pages => apps/web/pages}/_app.tsx (76%) create mode 100644 apps/web/pages/_document.tsx rename {pages => apps/web/pages}/api/auth/[...nextauth].ts (94%) rename {pages => apps/web/pages}/api/forms/[id]/event.ts (84%) rename {pages => apps/web/pages}/api/forms/[id]/index.ts (80%) rename {pages => apps/web/pages}/api/forms/[id]/nocodeform/index.ts (81%) rename {pages => apps/web/pages}/api/forms/[id]/pipelines/[pipelineId]/index.ts (88%) rename {pages => apps/web/pages}/api/forms/[id]/pipelines/index.ts (80%) rename {pages => apps/web/pages}/api/forms/[id]/submissionSessions/[submissionSessionId]/index.ts (84%) rename {pages => apps/web/pages}/api/forms/[id]/submissionSessions/index.ts (82%) rename {pages => apps/web/pages}/api/forms/index.ts (88%) rename {pages => apps/web/pages}/api/public/forms/[id]/nocodeform/index.ts (79%) rename {pages => apps/web/pages}/api/public/users/forgot-password.tsx (80%) rename {pages => apps/web/pages}/api/public/users/index.tsx (84%) rename {pages => apps/web/pages}/api/public/users/reset-password.tsx (70%) rename {pages => apps/web/pages}/api/public/users/verification-email.tsx (80%) create mode 100644 apps/web/pages/auth/forgot-password-email-sent.tsx rename {pages => apps/web/pages}/auth/forgot-password.tsx (62%) create mode 100644 apps/web/pages/auth/reset-password-success.tsx rename {pages => apps/web/pages}/auth/reset-password.tsx (62%) rename {pages => apps/web/pages}/auth/signin.tsx (59%) create mode 100644 apps/web/pages/auth/signup-without-verification-success.tsx rename {pages => apps/web/pages}/auth/signup.tsx (61%) rename {pages => apps/web/pages}/auth/verification-requested.tsx (62%) rename {pages => apps/web/pages}/auth/verify.tsx (60%) rename {pages => apps/web/pages}/f/[id].tsx (61%) rename {pages => apps/web/pages}/forms/[id]/form/index.tsx (87%) rename {pages => apps/web/pages}/forms/[id]/form/react.tsx (69%) rename {pages => apps/web/pages}/forms/[id]/index.tsx (93%) rename {pages => apps/web/pages}/forms/[id]/pipelines.tsx (70%) rename {pages => apps/web/pages}/forms/[id]/preview.tsx (78%) rename {pages => apps/web/pages}/forms/[id]/results/insights.tsx (85%) rename {pages => apps/web/pages}/forms/[id]/results/responses.tsx (85%) rename {pages => apps/web/pages}/forms/[id]/results/summary.tsx (85%) rename {pages => apps/web/pages}/forms/index.tsx (98%) rename postcss.config.js => apps/web/postcss.config.js (100%) rename {public => apps/web/public}/favicon.ico (100%) rename {public => apps/web/public}/favicons/android-chrome-192x192.png (100%) rename {public => apps/web/public}/favicons/android-chrome-256x256.png (100%) rename {public => apps/web/public}/favicons/apple-touch-icon.png (100%) rename {public => apps/web/public}/favicons/favicon-16x16.png (100%) rename {public => apps/web/public}/favicons/favicon-32x32.png (100%) rename {public => apps/web/public}/favicons/mstile-150x150.png (100%) rename {public => apps/web/public}/favicons/safari-pinned-tab.svg (100%) rename {public => apps/web/public}/favicons/site.webmanifest (100%) rename {public => apps/web/public}/fonts/Poppins-Black.woff (100%) rename {public => apps/web/public}/fonts/Poppins-Black.woff2 (100%) rename {public => apps/web/public}/fonts/Poppins-Bold.woff (100%) rename {public => apps/web/public}/fonts/Poppins-Bold.woff2 (100%) rename {public => apps/web/public}/fonts/Poppins-ExtraBold.woff (100%) rename {public => apps/web/public}/fonts/Poppins-ExtraBold.woff2 (100%) rename {public => apps/web/public}/fonts/Poppins-ExtraLight.woff (100%) rename {public => apps/web/public}/fonts/Poppins-ExtraLight.woff2 (100%) rename {public => apps/web/public}/fonts/Poppins-Light.woff (100%) rename {public => apps/web/public}/fonts/Poppins-Light.woff2 (100%) rename {public => apps/web/public}/fonts/Poppins-Medium.woff (100%) rename {public => apps/web/public}/fonts/Poppins-Medium.woff2 (100%) rename {public => apps/web/public}/fonts/Poppins-Regular.woff (100%) rename {public => apps/web/public}/fonts/Poppins-Regular.woff2 (100%) rename {public => apps/web/public}/fonts/Poppins-SemiBold.woff (100%) rename {public => apps/web/public}/fonts/Poppins-SemiBold.woff2 (100%) rename {public => apps/web/public}/fonts/Poppins-Thin.woff (100%) rename {public => apps/web/public}/fonts/Poppins-Thin.woff2 (100%) rename {public => apps/web/public}/img/a-b-test-v1.svg (100%) rename {public => apps/web/public}/img/avatar-placeholder.png (100%) rename {public => apps/web/public}/img/drop-offs-v1.svg (100%) rename {public => apps/web/public}/img/mascot-face-small.png (100%) rename {public => apps/web/public}/img/snoopforms-logo.svg (100%) rename {public => apps/web/public}/vercel.svg (100%) rename {styles => apps/web/styles}/editorjs.css (100%) rename {styles => apps/web/styles}/globals.css (100%) rename {styles => apps/web/styles}/toastify.css (100%) rename tailwind.config.js => apps/web/tailwind.config.js (100%) create mode 100644 apps/web/tsconfig.json create mode 100644 docker-compose.dev.yml delete mode 100644 lib/jwt.ts delete mode 100644 lib/prisma.ts create mode 120000 packages/database/.env create mode 100644 packages/database/.eslintrc.js create mode 100644 packages/database/package.json rename {prisma => packages/database/prisma}/migrations/20220624041413_initial/migration.sql (100%) rename {prisma => packages/database/prisma}/migrations/20220625055704_add_published_flag_to_nocodeform/migration.sql (100%) rename {prisma => packages/database/prisma}/migrations/20220626023941_new_nocode_editor_approach/migration.sql (100%) rename {prisma => packages/database/prisma}/migrations/20220713132158_add_signup/migration.sql (100%) rename {prisma => packages/database/prisma}/migrations/20220816150326_add_closed_property_to_nocode_form/migration.sql (100%) rename {prisma => packages/database/prisma}/migrations/20220830155214_update_pipelines/migration.sql (100%) rename {prisma => packages/database/prisma}/migrations/20220902135652_remove_session_fingerprint/migration.sql (100%) rename {prisma => packages/database/prisma}/migrations/migration_lock.toml (100%) rename {prisma => packages/database/prisma}/schema.prisma (100%) create mode 100644 packages/database/src/client.ts create mode 100644 packages/database/src/index.ts create mode 100644 packages/database/tsconfig.json create mode 100644 packages/database/tsup.config.ts create mode 100644 packages/eslint-config-custom/index.js create mode 100644 packages/eslint-config-custom/package.json create mode 100644 packages/prettier-config/merged-prettier-plugin.js create mode 100644 packages/prettier-config/package.json create mode 100644 packages/prettier-config/prettier-preset.js create mode 100644 packages/tailwind-config/package.json create mode 100644 packages/tailwind-config/tailwind.config.js create mode 100644 packages/tsconfig/base.json rename tsconfig.json => packages/tsconfig/nextjs.json (54%) create mode 100644 packages/tsconfig/node16.json create mode 100644 packages/tsconfig/package.json create mode 100644 packages/tsconfig/react-library.json create mode 100644 packages/ui/package.json create mode 100644 packages/ui/src/Button.tsx create mode 100644 packages/ui/src/index.tsx create mode 100644 packages/ui/src/styles.css create mode 100644 packages/ui/src/utils.ts create mode 100644 packages/ui/tailwind.config.js create mode 100644 packages/ui/tsconfig.json delete mode 100644 pages/404.tsx delete mode 100644 pages/_document.tsx delete mode 100644 pages/auth/forgot-password-email-sent.tsx delete mode 100644 pages/auth/reset-password-success.tsx delete mode 100644 pages/auth/signup-without-verification-success.tsx create mode 100644 pnpm-lock.yaml create mode 100644 pnpm-workspace.yaml create mode 100644 turbo.json delete mode 100644 yarn.lock diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 2b28681164..0000000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster -ARG VARIANT=16-bullseye -FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT} - -# [Optional] Uncomment this section to install additional OS packages. -# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends - -# [Optional] Uncomment if you want to install an additional version of node using nvm -# ARG EXTRA_NODE_VERSION=10 -# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}" - -# [Optional] Uncomment if you want to install more global node modules -# RUN su node -c "npm install -g " diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index 821fbedd78..0000000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,31 +0,0 @@ -// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: -// https://github.com/microsoft/vscode-dev-containers/tree/v0.245.2/containers/javascript-node-postgres -// Update the VARIANT arg in docker-compose.yml to pick a Node.js version -{ - "name": "Node.js & PostgreSQL", - "dockerComposeFile": "docker-compose.yml", - "service": "app", - "workspaceFolder": "/workspace", - // Configure tool-specific properties. - "customizations": { - // Configure properties specific to VS Code. - "vscode": { - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "dbaeumer.vscode-eslint" - ] - } - }, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // This can be used to network with other containers or with the host. - "forwardPorts": [ - // frontend - 3000, - // postgres - 5432 - ], - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "yarn install && yarn prisma migrate dev", - // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "node" -} \ No newline at end of file diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml deleted file mode 100644 index c8bdfdf212..0000000000 --- a/.devcontainer/docker-compose.yml +++ /dev/null @@ -1,63 +0,0 @@ -version: '3.8' - -services: - app: - build: - context: . - dockerfile: Dockerfile - args: - VARIANT: 16-bullseye - - environment: - DATABASE_URL: postgresql://postgres:postgres@db:5432/snoopformsdev?schema=public - NEXTAUTH_URL: http://localhost:3000 - NEXT_TELEMETRY_DISABLED: 1 - - MAIL_FROM: noreply@example.com - SMTP_HOST: mailhog - SMTP_PORT: 1025 - SMTP_USER: smtpUser - SMTP_PASSWORD: smtpPassword - - TERMS_URL: https://www.example.com/terms - PRIVACY_URL: https://www.example.com/privacy - PUBLIC_IMPRINT_URL: https://www.example.com/imprint - PUBLIC_PRIVACY_URL: https://www.example.com/enduserPrivacy - - volumes: - - ..:/workspace:cached - - # Overrides default command so things don't shut down after the process ends. - command: sleep infinity - - # # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. - # network_mode: service:db - - # Uncomment the next line to use a non-root user for all processes. - # user: node - - # Use "forwardPorts" in **devcontainer.json** to forward an app port locally. - # (Adding the "ports" property to this file will not forward from a Codespace.) - - db: - image: postgres:13-alpine - restart: unless-stopped - volumes: - - postgres-data:/var/lib/postgresql/data - # network_mode: service:app - - environment: - POSTGRES_PASSWORD: postgres - POSTGRES_USER: postgres - POSTGRES_DB: snoopformsdev - - mailhog: - image: mailhog/mailhog - # network_mode: service:app - logging: - driver: 'none' # disable saving logs - ports: - - 8025:8025 # web ui - # - 1025:1025 # smtp server -volumes: - postgres-data: diff --git a/.env.example b/.env.example index 1a74b25ac5..53adcdbbbc 100644 --- a/.env.example +++ b/.env.example @@ -1,32 +1,74 @@ -# ------------ MANDATORY (CHANGE ACCORDING TO YOUR SETUP) ------------ +######################################################################## +# ------------ MANDATORY (CHANGE ACCORDING TO YOUR SETUP) ------------# +######################################################################## + + +############ +# Basics # +############ NEXTAUTH_SECRET=RANDOM_STRING NEXTAUTH_URL=http://localhost:3000 -DATABASE_URL='postgresql://user@localhost:5432/snoopforms?schema=public' -# For Docker Compose Setup use this Database URL: +DATABASE_URL='postgresql://postgres:postgres@postgres:5432/snoopforms?schema=public' +# For Docker Compose Production Setup use this Database URL: # DATABASE_URL='postgresql://postgres:postgres@postgres:5432/snoopforms?schema=public' +################ +# Mail Setup # +################ + +# Necessary if email verification and password reset are enabled. +# See optional configurations below if you want to disable these features. + +MAIL_FROM=noreply@example.com +SMTP_HOST=localhost +SMTP_PORT=1025 +SMTP_SECURE_ENABLED=0 # Enable for TLS (port 465) +SMTP_USER=smtpUser +SMTP_PASSWORD=smtpPassword + + +######################################################################## +# ------------------------------ OPTIONAL -----------------------------# +######################################################################## + +# Uncomment the variables you would like to use and customize the values. + +##################### +# Disable Features # +##################### + # Email Verification. If you enable Email Verification you have to setup SMTP-Settings, too. -EMAIL_VERIFICATION_DISABLED=1 +# EMAIL_VERIFICATION_DISABLED=1 # Password Reset. If you enable Password Reset functionality you have to setup SMTP-Settings, too. -PASSWORD_RESET_DISABLED=1 +# PASSWORD_RESET_DISABLED=1 -NEXT_TELEMETRY_DISABLED=1 - -# ------------ OPTIONAL ------------ - -## MAIL SETUP - -# MAIL_FROM=noreply@example.com -# SMTP_HOST=smtp.example.com -# SMTP_PORT=587 -# SMTP_USER=smtpUser -# SMTP_PASSWORD=smtpPassword +####################### +# Additional Options # +####################### # TERMS_URL=https://www.example.com/terms # PRIVACY_URL=https://www.example.com/privacy # PUBLIC_IMPRINT_URL=https://www.example.com/imprint -# PUBLIC_PRIVACY_URL=https://www.example.com/enduserPrivacy \ No newline at end of file +# PUBLIC_PRIVACY_URL=https://www.example.com/enduserPrivacy + +###################### +# Posthog Tracking # +###################### + +# POSTHOG_API_HOST=https://app.posthog.com +# POSTHOG_API_KEY= + +############### +# Telemetry # +############### + +# We also track anononymous usage telemetry on the server to improve snoopForms. +# That way we can see how many people use snoopForms. +# We can't identify you, or your users and only receive the number of submissions on your instance. +# You help us a lot, if you leave this activated. +# If you still want to opt-out, uncomment the next line. +# TELEMETRY_DISABLED=1 \ No newline at end of file diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000000..5b999efa47 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,10 @@ +module.exports = { + root: true, + // This tells ESLint to load the config from the package `eslint-config-custom` + extends: ["custom"], + settings: { + next: { + rootDir: ["apps/*/"], + }, + }, +}; diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index bffb357a71..0000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "next/core-web-vitals" -} diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 1cb2ce5649..616ca899f9 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -10,6 +10,10 @@ jobs: node: ["16.x"] os: [ubuntu-latest, windows-latest, macOS-latest] + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ secrets.TURBO_TEAM }} + steps: - name: Checkout repo uses: actions/checkout@v2 @@ -19,11 +23,14 @@ jobs: with: node-version: ${{ matrix.node }} - - name: Install deps and build (with cache) - uses: bahmutov/npm-install@v1 + - name: Install pnpm + uses: pnpm/action-setup@v2.2.2 + + - name: Install dependencies + run: pnpm install - name: Lint - run: yarn lint + run: pnpm lint - name: Build - run: yarn build + run: pnpm build diff --git a/.gitignore b/.gitignore index 3820f70b09..1b7a904ba0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,30 +1,30 @@ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. # dependencies -/node_modules -/.pnp +node_modules +.pnp .pnp.js +.pnpm-store/ # testing -/coverage +coverage # next.js -/.next/ -/out/ +.next/ +out/ +build -# production -/build +# node +dist/ # misc .DS_Store *.pem -.idea/ # debug npm-debug.log* yarn-debug.log* yarn-error.log* -.pnpm-debug.log* # local env files .env @@ -32,9 +32,7 @@ yarn-error.log* .env.development.local .env.test.local .env.production.local +!packages/database/.env -# vercel -.vercel - -# typescript -*.tsbuildinfo +# turbo +.turbo diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000000..73061bcd75 --- /dev/null +++ b/.npmrc @@ -0,0 +1,6 @@ +auto-install-peers=true +link-workspace-packages = true +shamefully-hoist = true +shared-workspace-shrinkwrap = true +access = public +enable-pre-post-scripts = true \ No newline at end of file diff --git a/.prettierrc.js b/.prettierrc.js new file mode 100644 index 0000000000..db8e3eee54 --- /dev/null +++ b/.prettierrc.js @@ -0,0 +1 @@ +module.exports = require("./packages/prettier-config/prettier-preset"); diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 6af7c3ffec..0000000000 --- a/Dockerfile +++ /dev/null @@ -1,39 +0,0 @@ -# Install dependencies only when needed -FROM node:16-alpine AS deps -# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. -RUN apk add --no-cache libc6-compat -WORKDIR /app -COPY package.json yarn.lock ./ -RUN yarn install --frozen-lockfile - -# Rebuild the source code only when needed -FROM node:16-alpine AS builder -WORKDIR /app -COPY . . -COPY --from=deps /app/node_modules ./node_modules -RUN yarn prisma generate -RUN yarn build && yarn install --production --ignore-scripts --prefer-offline - -# Production image, copy all the files and run next -FROM node:16-alpine AS runner -WORKDIR /app - -ENV NODE_ENV production - -RUN addgroup -g 1001 -S nodejs -RUN adduser -S nextjs -u 1001 - -COPY --from=builder /app/next.config.js ./ -COPY --from=builder /app/public ./public -COPY --from=builder --chown=nextjs:nodejs /app/.next ./.next -COPY --from=builder /app/node_modules ./node_modules -COPY --from=builder /app/package.json ./package.json -COPY --from=builder /app/prisma ./prisma - -USER nextjs - -EXPOSE 3000 - -ENV NEXT_TELEMETRY_DISABLED 1 - -CMD ["yarn", "start"] \ No newline at end of file diff --git a/README.md b/README.md index e48836ce31..9cc225db3a 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,6 @@
-> :warning: **Note**: This repository is still in an early stage of development. We love the open source community and want to show what we are working on early. We will update this readme with more information once it is safe to use. Until then, feel free to share your thoughts, contact us, and contribute if you'd like. - -
- ## About snoopForms snoopForms-architecture @@ -49,86 +45,78 @@ With snoopForms you can build complex multi-page forms in minutes using either o - [TailwindCSS](https://tailwindcss.com/) - [Prisma](https://prisma.io/) -## Getting started +## Cloud vs. self-hosted -you can develop in a VS Code [dev container](https://code.visualstudio.com/docs/remote/containers) or using any editor/IDE with local tool installation. +We offer you a ready hosted and maintained version of snoopForms on [snoopforms.com](https://snoopforms.com). It is always up to date and offers a generous free plan. If you want to try snoopForms, or save yourself the hassle and stress of self-hosting, this is the place to start. -### Getting started using VS Code dev container +The version of snoopForms you'll find in this repository is the same version that runs in the cloud, and you can easily host it yourself on your servers. See the readme below for the deployment instructions. -You need +(In the future we may develop additional features that aren't in the free Open-Source version) -- Docker, e.g. [Docker Desktop](https://www.docker.com/products/docker-desktop) -- [VS Code](https://code.visualstudio.com/download) with the extension [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) (`ms-vscode-remote.remote-containers`) +## Get started with development -Either use the command `Open Folder in Container...` in the cloned repo, or use `Remote Containers: Clone Repository in Container Volume...`, for example to inspect a PR. +This repository is a monorepository using [Turborepo](https://turborepo.org/) and [pnpm](https://pnpm.io/). It contains the snoopForms [server application](https://github.com/formbricks/snoopforms/tree/main/apps/web), the [react library](https://github.com/formbricks/snoopforms/tree/main/packages/react) and other helper packages like database or UI library. -The dev container comes with - -- Node.JS, yarn etc pre-installed -- a `postgres` container and environment variables preset to reach it, -- a `mailhog` container that acts as a mock SMTP server and shows received mails in a web UI (forwarded to your host's `localhost:8025`) - -upon start, it executes the `yarn install` and `yarn prisma migrate dev` automatically once. - -When your dev container is ready, you can simply hit `F5` to start the application in debug mode. - -### Getting started using local development setup +### How to run locally To get the project running locally on your machine you need to have the following development tools installed: - Node.JS (we recommend v16) -- Yarn -- PostgreSQL +- [pnpm](https://pnpm.io/) +- [Docker](https://www.docker.com/) (to run PostgreSQL / MailHog) 1. Clone the project: ``` -git clone https://github.com/formbricks/snoopforms.git && cd snoopforms +git clone https://github.com/formbricks/snoopforms.git ``` -2. Install Node.JS packages via yarn. Don't have yarn? Use `npm install --global yarn`. +and move into the directory ``` -yarn install +cd snoopforms ``` -3. Make sure you have a running database instance, e.g. by using docker. A quick and dirty instance can be spun up via: +2. Install Node.JS packages via pnpm. Don't have pnpm? Get it [here](https://pnpm.io/installation) ``` -docker run --name snoopformsDB -p 5432:5432 -e POSTGRES_USER=snoopforms -e POSTGRES_PASSWORD=password -e POSTGRES_DB=snoopforms -d postgres +pnpm install ``` -4. Create a `.env` file based on `.env.example` and change it according to your setup. Make sure the `DATABASE_URL` variable is set correctly according to your local database. +3. To make the process of installing a dev dependencies easier, we offer a [`docker-compose.yml`](https://docs.docker.com/compose/) file to deploy a PostgreSQL server locally with a new database named `turborepo` (To change this update the `MYSQL_DATABASE` environment variable in the `docker-compose.yml` file) + +- a `postgres` container and environment variables preset to reach it, +- a `mailhog` container that acts as a mock SMTP server and shows received mails in a web UI (forwarded to your host's `localhost:8025`) + +``` +docker-compose -f docker-compose.dev.yml up -d +``` + +4. Create a `.env` file based on `.env.example` and change it according to your setup. If you are using a cloud based database or another mail server, you will need to update the `DATABASE_URL` and SMTP settings in your `.env` accordingly. ``` cp .env.example .env ``` -For the example above, use the following: +5. Make sure your PostgreSQL Database Server is running. Then let prisma set up the database for you: ``` -DATABASE_URL='postgresql://snoopforms:password@localhost:5432/snoopforms?schema=public' +pnpm dlx prisma migrate dev ``` -5. Use the code editor of your choice to edit the .env file. You need to change all fields according to your setup. - -6. Make sure your PostgreSQL Database Server is running. Then let prisma set up the database for you: +6. Start the development server: ``` -yarn prisma migrate dev -``` - -7. Start the development server: - -``` -yarn dev +pnpm dev ``` **You can now access the app on [https://localhost:3000](https://localhost:3000)**. You will be automatically redirected to the login. To use your local installation of snoopForms, create a new account. -## Deployment +For viewing the confirmation email and other emails the system sends you, you can access mailhog at [https://localhost:8025](https://localhost:8025) -The easiest way to deploy the snoopHub on your own machine is using Docker. This requires Docker and the docker compose plugin on your system to work. +## Deployment for Production Setup + +The easiest way to deploy snoopForms on your own machine is using Docker. This requires Docker and the docker compose plugin on your system to work. Clone the repository: @@ -138,15 +126,17 @@ git clone https://github.com/formbricks/snoopforms.git && cd snoopforms ``` -Create a `.env` file based on `.env.example` and change all fields according to your setup. The SMTP-credentials are essential for verification emails to work during user signup. +Create a `.env` file based on `.env.example` and change all fields according to your setup. You need to uncomment the right line for the `DATABASE_URL` for the database connection to work. Also you need to configure the SMTP settings for the signup process with verification emails to work. If you don't have a mail server for sending email, you need to disable email verification (`EMAIL_VERIFICATION_DISABLED=1`) and password reset (`PASSWORD_RESET_DISABLED=1`). + +Copy the `.env.example` file to `.env` and edit it with an editor of your choice. ``` -cp .env.example .env && nano .env +cp .env.example .env ``` -Start the docker compose process to build and spin up the snoopForms container as well as the postgres database. +Start the docker compose process to build and spin up the snoopForms container as well as the PostgreSQL database. ```bash diff --git a/apps/web/.eslintrc.js b/apps/web/.eslintrc.js new file mode 100644 index 0000000000..c8df607506 --- /dev/null +++ b/apps/web/.eslintrc.js @@ -0,0 +1,4 @@ +module.exports = { + root: true, + extends: ["custom"], +}; diff --git a/apps/web/.gitignore b/apps/web/.gitignore new file mode 100644 index 0000000000..3820f70b09 --- /dev/null +++ b/apps/web/.gitignore @@ -0,0 +1,40 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem +.idea/ + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# local env files +.env +.env.local +.env.development.local +.env.test.local +.env.production.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo diff --git a/apps/web/Dockerfile b/apps/web/Dockerfile new file mode 100644 index 0000000000..9a66ceeab3 --- /dev/null +++ b/apps/web/Dockerfile @@ -0,0 +1,38 @@ +# Add lockfile and package.json's of isolated subworkspace +FROM node:16-alpine AS installer +RUN apk update +RUN apk --no-cache add curl libc6-compat +RUN curl -fsSL "https://github.com/pnpm/pnpm/releases/latest/download/pnpm-linuxstatic-x64" -o /bin/pnpm; chmod +x /bin/pnpm; +WORKDIR /app + +# First install the dependencies (as they change less often) +COPY . . +RUN pnpm install + +# Build the project +RUN pnpm dlx prisma generate +RUN pnpm turbo run build --filter=web... + +FROM node:16-alpine AS runner + +RUN apk --no-cache add curl libc6-compat +RUN curl -fsSL "https://github.com/pnpm/pnpm/releases/latest/download/pnpm-linuxstatic-x64" -o /bin/pnpm; chmod +x /bin/pnpm; + +# Don't run production as root +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs +USER nextjs + +WORKDIR /home/nextjs + +COPY --from=installer /app/apps/web/next.config.js . +COPY --from=installer /app/apps/web/package.json . + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/standalone ./ +COPY --from=installer --chown=nextjs:nodejs /app/apps/web/.next/static ./apps/web/.next/static +COPY --from=installer --chown=nextjs:nodejs /app/apps/web/public ./apps/web/public +COPY --from=installer --chown=nextjs:nodejs /app/packages/database/prisma/schema.prisma ./packages/database/prisma/schema.prisma + +CMD pnpm dlx prisma migrate deploy && node apps/web/server.js \ No newline at end of file diff --git a/components/FormList.tsx b/apps/web/components/FormList.tsx similarity index 63% rename from components/FormList.tsx rename to apps/web/components/FormList.tsx index 79f49bbc07..498c067ec6 100644 --- a/components/FormList.tsx +++ b/apps/web/components/FormList.tsx @@ -1,10 +1,5 @@ import { Menu, Transition } from "@headlessui/react"; -import { - DocumentPlusIcon, - PlusIcon, - CommandLineIcon, - SquaresPlusIcon, -} from "@heroicons/react/24/outline"; +import { DocumentPlusIcon, PlusIcon, CommandLineIcon, SquaresPlusIcon } from "@heroicons/react/24/outline"; import { EllipsisHorizontalIcon, TrashIcon } from "@heroicons/react/24/solid"; import Link from "next/link"; import { Fragment, useState } from "react"; @@ -47,18 +42,17 @@ export default function FormList() { hintText="Start by creating a form." buttonText="create form" borderStyles="border-4 border-dotted border-red" - hasButton={true} - > - + hasButton={true}> + ) : ( -