From 65e886b108ebaf036a1b505144a5f0079c6248c4 Mon Sep 17 00:00:00 2001 From: Jared Henderson Date: Wed, 17 Jan 2024 14:32:02 -0500 Subject: [PATCH] monorepo: a few tweaks from reviewing for open-sourcing --- .github/workflows/ci.yml | 7 +---- .vscode/settings.json | 12 -------- docs/signup-flow.md | 61 ---------------------------------------- readme.md | 28 +++++------------- 4 files changed, 8 insertions(+), 100 deletions(-) delete mode 100644 .vscode/settings.json delete mode 100644 docs/signup-flow.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5571745b..342d6f28 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,9 +43,6 @@ jobs: runs-on: ubuntu-latest env: ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }} - RUN_ARGOS: - ${{ contains(github.event.pull_request.labels.*.name, 'run-argos') || - github.event_name == 'push' }} steps: - name: checkout uses: actions/checkout@v3 @@ -71,19 +68,17 @@ jobs: - name: build storybook run: STORYBOOK_SCREENSHOT_TESTING=true just build-storybook - name: serve storybook - if: env.RUN_ARGOS == 'true' run: | mv -f storybook/storybook-static/{iframe,index}.html pnpm dlx serve@14.2.1 -l 4777 storybook/storybook-static & - name: screenshots - if: env.RUN_ARGOS == 'true' run: | just visual-test pnpm dlx @argos-ci/cli upload storybook/visual-tests/screenshots/argos || true - name: create screenshots pr id: pr uses: peter-evans/create-pull-request@v4 - if: env.RUN_ARGOS == 'true' && github.event_name == 'pull_request' + if: github.event_name == 'pull_request' with: base: ${{ github.head_ref }} commit-message: '[automated] update screenshots from CI' diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 92dc2361..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "files.exclude": { - "**/.next/": true, - "**/pnpm-lock.json": true, - "**/node_modules/": true, - "**/*.tsbuildinfo": true, - "**/build/": true, - "**/out/": true, - "storybook/storybook-static/": true - }, - "typescript.tsdk": "node_modules/typescript/lib" -} diff --git a/docs/signup-flow.md b/docs/signup-flow.md deleted file mode 100644 index 83ec2e9e..00000000 --- a/docs/signup-flow.md +++ /dev/null @@ -1,61 +0,0 @@ -# Signup flow - -## initiate signup - -- starts on _dashboard_ `/signup` route, sends an `initiateSignup` mutation with email and - password -- _api_ responds to `initiateSignup` mutation by: - - creating an `Admin` in the database with `.subscriptionStatus` set to - `.pendingEmailVerification` - - stores an ephemeral verification token - - generates an email containing link to: - `parents.gertrude.app/verify-signup-email/` - -## verify email - -- When admin clicks link in email above, _dashboard_ sends a `verifyEmailMutation` - containing just the token -- _api_ responds to `verifyEmailMutation` by: - - resolving the token into an `Admin.Id` from ephemeral storage - - setting `.subscriptionStatus` to `.emailVerified` - - creating an `AdminVerifiedNotificationMethod` for their signup email - - replies with the `Admin` resource (which the dashboard uses only the `id`) - -## prepare and redirecto to stripe checkout - -- when the _dashboard_ recieves the `Admin.Id` value back from email verification, it - sends a `createSignupPaymentUrl` mutation, sending along the admin id -- the _api_ responds to this `createSignupPaymentUrl` mutation by creating a temporary - checkout session with stripe, by calling the stripe API, and returning the session URL. - It embeds the admin id into the stripe checkout session metadata, which is used later -- when the _dashboard_ gets the checkout URL, it redirects to it - -## return from stripe checkout (happy path) - -- when the user finishes the stripe checkout process successfully, they are redirected - back to the dashboard at `/checkout-success` with a _checkout session id_ embedded in - the query param -- from this _dashboard_ route, a `handleSignupPaymentSuccess` mutation is sent to the api, - containing _only_ the checkout session id -- the _api_ responds to `handleSignupPaymentSuccess` by: - - pulling the stripe session from the stripe API in order to get a `subscription` - object, AND resolve the admin id stored as metadata (see above) - - once it finds the admin id, and has the subscription, it queries the stripe API again, - to get the current **status** of the subscription, and _updates the model in the - database_ accordingly - - finally, it returns an `AdminToken` as the mutation response (which the _dashboard_ - uses for auth and localStorage things) -- when the _dashboard_ gets a successful response from payment success, it: - - the storage middleware listening for the action stores the admin id and token - - the auth redux slice stores the admin credentials - - the signup redux slice stores the successful checkout request state - - and the user is redirected to the dashboard: `/` - -## return from stripe checkout (sad, cancel path) - -- similar to the success state, the _session id_ is used to send a cancel mutation to the - API -- the _api_ resolves the admin from the subscription via the session (using same 2 stripe - api calls as happy path) -- after finding the admin who canceled, it updates their status in the database, and - returns a generic success diff --git a/readme.md b/readme.md index 6d864de9..bd947a4b 100644 --- a/readme.md +++ b/readme.md @@ -23,39 +23,25 @@ ## Environment -- `node` 16 -- `pnpm` 7 +- `node` 18 +- `pnpm` 8 +- `just` 1.9 ## Usage -Run `make` for an overview of the most commonly used dev commands. Check out the -`Makefile` for even more. - -For watching typescript errors, the following monstrosity of a bash command filters out -some of the duplicates/noise: - -```sh -script -q /dev/null make ts-watch | grep -P " [^\.][^\.][^ ]+: (- )?error TS\d+|(?<=0 errors)" -``` +Run `just` for an overview of the most commonly used dev commands. Check out the +`justfile` for even more. ## Tips on adding a new package - `pnpm` requires that the lib be explicitly listed as a dependency, so in other apps/libs that need it, you'll need to run `pnpm --filter @some/pkg install @new/pkg` - if the lib has react components using tailwind, be sure to updated the `content` section - of the `tailwind.comfig.js` for the app consuming it, so that JIT works correctly. -- if a next app is consuming it, edit the `next.config.js` file to transpile the module - (because we don't _build_ anything for consumption, we just deal with straight - typescript), and possibly add the path to the `package.json` `start` script (if using - `next-remote-watch`) -- add the new package to the `Makefile` typechecking commands: `ts-check` and `ts-watch` + of the `tailwind.config.js` for the app consuming it, so that JIT works correctly. +- add the new package to the `justfile` typechecking commands: `ts-check` and `ts-watch` ## Monorepo hacks/issues -- to get `next dev` to HMR when something in a workspace dependency changes, i had to pull - in `next-remote-watch` to replace the standard `next-dev` -- for next.js apps to directly consume un-transpiled typescript, we use - `with-transpiled-modules` in our `next.config.js` - netlify's pnpm+monorepo support isn't quite there yet, had to add `NETLIFY_USE_PNPM=true` ([see here](https://github.com/netlify/build/issues/4648#issuecomment-1288804297))