Skip to content

Releases: cedarjs/cedar

v2.6.0

10 Feb 06:42

Choose a tag to compare

Release Notes

This release is all about improvements to Cedar's realtime features. With more to come!
Plus incorporating the patch that was released as v1.1.2 a couple of days ago

Changelog

🚀 Features

feat(realtime): Rename to useCedarRealtime and CedarRealtimeOptions (#1158) by @Tobbe

Moves the implementation from RW to Cedar naming, but keeps the old exports for backwards compatibility until a future major version

This is very unlikely to happen, but I'm noting it here just to surface the risk a tiny bit more (comment from Greptile)

Symbol string changed from useRedwoodRealtime.wasLiveQueryAdded to useCedarRealtime.wasLiveQueryAdded. Since Symbol.for() returns the same symbol for the same string globally, schemas marked with the old symbol won't be recognized by the new code. If users have cached schemas or use both versions simultaneously during migration, the schema might get the live directive added twice.

feat(realtime): Add realtime to GraphQL Handler during setup (#1157) by @Tobbe

Fixes #512

feat(realtime): Remove RW shim file (#1159) by @Tobbe

This should affect noone, but if you for some reason did a deep import of useRedwoodRealtime you'll need to change it to import from just @cedarjs/realtime now, which is how we've always shown it being done

🛠️ Fixes

fix(realtime): Remove filename comment from auctions sdl template (#1156) by @Tobbe

We typically don't include this in templates shipped with the CLI. We do sometimes have it in our docs though (but I prefer using Docusaurus' title="filename.ext" feature for that)

fix(cli): Use CEDAR_CWD env var (#1179) by @Tobbe

Continuing the rebranding effort from RW to Cedar.
The old RWJS_CWD variable still works, to keep this change backwards compatible.

fix(exec): Support importing graphql handler function (#1168) by @Tobbe

Add Vite plugins to support imports like these

import directives from 'src/directives/**/*.{js,ts}'
import sdls from 'src/graphql/**/*.sdl.{js,ts}'
import services from 'src/services/**/*.{js,ts}'

in files imported and used by scripts

fix(cli): Fix passing multiple files to `yarn cedar lint` (#1163) by @Tobbe

yarn cedar lint file1 file2 used to pass "file1 file2" to eslint, which then looked for a single file literally named "file1 file2", i.e. with a space in the file name. This PR makes sure to pass all files as separate args

fix(cli): Support relative paths for CEDAR_CWD (#1178) by @Tobbe

This PR adds better support for relative paths, like CEDAR_CWD=__fixture__ or CEDAR_CWD=../../test-project. It worked before as well, in simple cases. But when the CLI invoked itself (like calling out to generate a new prisma client in a separate process) it could fail. Now it doesn't anymore

📦 Dependencies

Click to see all 15 dependency updates

🧹 Chore

Click to see all chore contributions
  • chore(ci): Strip hash from canary publish GH comment (7b94164) by @Tobbe
  • Version docs to 2.6 (acd183a) by @Tobbe
  • chore(test-project): rebuild-test-project-fixture: Build cca before running it (#1165) by @Tobbe

v1.1.2

08 Feb 11:36

Choose a tag to compare

Release Notes

Patch release for a single issue with scripts importing other files that have glob imports (like import directives from 'src/directives/**/*.{js,ts}').
(scripts, as in those you generate with yarn cedar generate script and then run with yarn cedar exec)

Changelog

🛠️ Fixes

fix(exec): Support importing graphql handler function (#1168) by @Tobbe

Add Vite plugins to support imports like these

import directives from 'src/directives/**/*.{js,ts}'
import sdls from 'src/graphql/**/*.sdl.{js,ts}'
import services from 'src/services/**/*.{js,ts}'

in files imported and used by scripts

v2.5.1

05 Feb 19:30

Choose a tag to compare

Release Notes

A patch release to get a few security fixes in third-party packages released. Plus a PR from @Bigood! Thank you so much 🙏

Changelog

🛠️ Fixes

fix(docs): Fix link to cedar.toml section (3bbdac8) by @Tobbe

Using file paths with .md extensions for links to work with versioned docs

fix(api-server): Do not watch changes inside packages' src (#1148) by @Tobbe

We had a glob syntax path that wasn't working. I simplified that specific piece of code to not rely on globs

fix(paths): Add missing types for 'subscriptions' and 'packages' paths (#1146) by @Tobbe

We provided both api.subscriptions and packages from getPaths() in @cedarjs/project-config, but they were not part of the exported types

chore(deps): update dependency @sentry/* to v10 and @envelop/sentry t… (#1048) by @Bigood I started having some bugs with the current Prisma version (issue on sentry-javascript repo)
TypeError: request.headers.split is not a function
    at setHeadersOnRequest (…/node_modules/@sentry/node/cjs/integrations/undici/index.js:247:39)
    at _onRequestCreate (…/node_modules/@sentry/node/cjs/integrations/undici/index.js:151:9)
    …

I upgraded beyond v7, and it went fluently, in dev and production. Let me know if there's something more to do before merging !

📚 Docs

docs(README): Replace Redwood with Cedar (#1149) by @Tobbe

As we bring more, new, people to Cedar it's confusing if the READMEs say Redwood.

docs(README): Remove package leads (#1147) by @Tobbe

There is only one maintainer for this project, so it's kind of obvious who to reach out to

📦 Dependencies

Click to see all 15 dependency updates

🧹 Chore

Click to see all chore contributions
  • chore(internal): api.ts rw -> cedar (42af5fc) by @Tobbe
  • chore(ci): publish_canary: npm whoami (8549504) by @Tobbe
  • chore(ci): publish_canary: npm validate token expiry (4816e30) by @Tobbe
  • chore(ci): detect-changes changeset bypass fix (#1141) by @Tobbe
  • chore(ci): get-ci-stats max job duration (#1139) by @Tobbe
  • chore(ci): Make publish-rc script MTS, and configure eslint (#1154) by @Tobbe
  • chore(docs): Correct eslint config for ignore_build.mjs (#1131) by @Tobbe

v2.5.0

02 Feb 20:22

Choose a tag to compare

Release Notes

  • Wait for the API server to properly start up before starting to send requests to it. This fixes that annoying initial red error messages you'd see in the terminal when first starting the dev server
  • Automatically rebuild and reload the API server when a shared package is changed
  • Help set up shared packages for api and/or web when invoking yarn cedar generate package
  • Use cedar.toml by default
  • Intellisense for cedar.toml thanks to a proper jsonschema doc for the toml
  • Add clipboard functionality to copy error details from the error overlay page

TL;DR: Rename your redwood.toml file to cedar.toml and put this at the top

#:schema https://raw.githubusercontent.com/cedarjs/cedar/main/packages/project-config/cedar-toml-schema-2.0.json
#:tombi format.disabled = true

Changelog

🚀 Features

feat(error-page): Copy to clipboard (#994) by @razzeee

Add clipboard functionality to copy error details and enhance error reporting

The idea is to make it easier to grab the whole context, to be able to feed it into an AI or report it here.

feat(upgrade-scripts): Default to matching Cedar version for deps (#1011) by @Tobbe

If an upgrade script does import { getPaths } from '@cedarjs/project-config the version of @cedarjs/project-config that gets installed now matches the version the user is upgrading to. So if the user ran yarn cedar upgrade -t canary the canary version of @cedarjs/project-config will get installed (instead of "latest", which was the behaviour before)

feat(cli): Generate valid email addresses in scenario tests (#1059) by @Tobbe

We need this for the shared workspace package code, but this is actually a general improvement for all Cedar apps where it'll now generate a valid email to use as test data for any string field with a name that includes "email"

feat(config): Support cedar.toml (#1000) by @Tobbe

External vendors, and AI tools, use redwood.toml to detect RW apps. As Cedar adds more and more features not available in RW it's important that these tools know they're working with a Cedar app. So this PR adds support for also configuring your app with cedar.toml. For now cedar.toml and redwood.toml both work exactly the same and have the same capabilities, but going forward they might start diverging with new features only being tested with cedar.toml.

feat(cca): cedar.toml (#1010) by @Tobbe

Now that #1000 has landed and we have a Canary build with support for cedar.toml I'm hoping CI can pass for this PR that updates create-cedar-app to ship with a cedar.toml file instead of a redwood.toml one

feat(toml): Include toml schema link in default cedar.toml (#1115) by @Tobbe

New Cedar apps now ship with cedar.toml intellisense

I've also explicitly disabled formatting rules. Eventually I want to turn those on. But to make this less disruptive for folks I'm having them off for now.

See #1006 for more details on how to integrate this in your existing Cedar app

feat(cli): Support prettier.config.mjs when calling prettify (#999) by @Tobbe

Code formatting was silently skipped when using the generators if a project had a .mjs prettier config file. This would lead to code full of red squiggles because of formatting "errors". This PR updates the formatting code to look for both .cjs and .mjs config files.

feat(graphql): Deprecate Redwood root schema (#1023) by @Tobbe

In addition to all the graphql schemas a user app might define, Cedar also adds its own root schema. Redwood did too, and now I'm deprecating the Redwood one, in favor of Cedar's

feat(env): CEDAR_DELAY_API_RESTART (#1130) by @Tobbe

This is really more of a "chore" PR as it's mostly about rebranding from RW to Cedar. The RWJS_DELAY_RESTART env var was never documented. But it was/is possible for apps to have configured it. So I'm keeping the old env var name around, but still undocumented. Instead I document the new variable name, and I will remove the old one in a future release

feat(cli): Ask what workspaces to use shared packages in (#1061) by @Tobbe

It might not be obvious to everyone how to integrate the new workspace package in code on the web and api workspaces, so this PR adds a step that asks the user what workspace(s) will use the package, and properly adds it to that workspace's package.json and tsconfig.json files.

feat(workspace-packages): API watch and reload packages (#1119) by @Tobbe

The script that runs the api server in dev used on only restart the server when any of the files in the api workspace changes. I've now extended this logic to also watch and restart when workspace packages the api side uses changes

feat(cli): workspace packages: Update web and scripts tsconfig if needed (#1064) by @Tobbe

The generate script previously checked, and updated, the api workspace tsconfig file. Now it also checks and updates the tsconfig file inside web/ and scripts/ to make sure it's compatible with workspace packages

feat(dev): Wait for API server to start before sending gql requests (#1015) by @Tobbe

This PR adds a new Vite plugin that adds a middleware to Vite's own dev server that blocks request while it waits for the backend server to be listening on the api port. The middleware will wait up to 1 minute. If the API server still isn't ready the middleware will send an error response to the frontend.

Also reviewed with Devin https://app.devin.ai/review/cedarjs/cedar/pull/1015

feat(toml): Add cedar.toml schema (#1006) by @Tobbe

See https://tombi-toml.github.io/tombi/docs/json-schema for full details on the schema format

Following the advice here https://github.com/SchemaStore/schemastore/blob/979bb17b767d05ebfb26a22f903cba117c7c339a/CONTRIBUTING.md?plain=1#L606 for including the version in the schema filename

There are a few ways you can incorporate this into your own project

  1. Place a tombi.toml config file at the root of your Cedar app with the same content as the one in the root of this repo. This only works if your IDE is using tombi for its toml LSP plugin
  2. Add a #:schema comment to the top of your cedar.toml file that points to the schema in this repo
  3. Copy the schema to your own project and use a relative path to point to it. This way you have 100% control (and ownership) of the schema, and then point to it either using a tombi.toml file or a #:schema comment.

Long-term I want to add the schema to schemastore.org so that the LSP can pick it up automatically, but we're not there yet.

🛠️ Fixes

fix(forms): expose new react-hook-form generic types (#1026) by @mgramigna

React hook form changed the type signature of UseFormReturn and other types to have TTransformedValues default to TFieldValues instead of undefined.

This ensures consumers who modify/use these types can take advantage of all the generics not just TFieldValues.

This change should be backwards compatible since it's introducing no new required types and TTransformedValues defaults to TFieldValues when not provided, so existing onSubmit props should be fine.

fix(cca): Add missing dev dep to Cedar apps (#1035) by @Tobbe

The root eslint config file uses @cedarjs/eslint-config, so it should list it as a dev dependency

For existing Cedar apps: It's recommended that you manually add this dependency yourself

fix(dbAuth): Update generated code to say Cedar (#1052) by @Tobbe

RW -> Cedar

fix(tsconfig): lowercase module (#1108) by @Tobbe

The tsconfig json schema currently doesn't support "module": "Node20", see SchemaStore/schemastore#5326

But even if/when that PR gets merged, the intellisense (hover hints/auto complete) will use "node20". And while not 100% consistent, the tsconfig docs also seems to prefer all-lowercase values, listing "node20" as an allowed value
image
https://www.typescriptlang.org/tsconfig/#module

So this PR switches the "module" value, and a couple of others, to lowercase

fix(cli): workspace packages: Fix skip note for .gitignore (#1062) by @Tobbe

If the .gitignore file is already up-to-date we skip the task that updates it. The skip-message should say ".gitignore", not "tsconfig". This PR fixes that

fix(cli): Use 'cedar' bin instead of deprecated 'rw' bin in more places (#1028) by @Tobbe

Follow-up to #1027 – found a few more keywords to search for

fix(cli): Use 'cedar' bin instead of deprecated 'rw' bin (#...
Read more

v2.4.1

13 Jan 14:32

Choose a tag to compare

Release Notes

Patch release for fixing yarn cedar build crash when you have packages/* in your workspace configuration, but no actual shared packages at that path

Changelog

🛠️ Fixes

fix(cli): Don't crash on building with no packages (#992) by @Tobbe

Gracefully handle a workspace config that includes packages/*, but that doesn't resolve to any actual folders on the filesystem

Without this fix users were seeing errors like these

❯ yarn cedar build
✔ Generating Prisma Client...
✖ [concurrently] no commands provided
◼ Verifying graphql schema...
◼ Building API...
◼ Building Web...
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
AssertionError [ERR_ASSERTION]: [concurrently] no commands provided
    at concurrently (/home/user/dev/project/node_modules/concurrently/dist/src/concurrently.js:36:22)
    at concurrently (/home/user/dev/project/node_modules/concurrently/dist/src/index.js:51:44)
    at buildPackagesTask (file:///home/user/dev/project/node_modules/@cedarjs/cli/dist/commands/build/buildPackagesTask.js:21:22)
    at async _Task.run (file:///home/user/dev/project/node_modules/listr2/dist/index.js:1979:11)

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Need help?
 - Not sure about something or need advice? Reach out on our Discord
 - Think you've found a bug? Open an issue on our GitHub
 - Here's your unique error reference to quote: '3c7eb5ef-4ab3-478a-acd3-1c581f9f5d03'
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

📦 Dependencies

chore(deps): update dependency @types/lodash to v4.17.22 (#991) by @renovate-bot

This PR contains the following updates:

Package Change Age Confidence
@types/lodash (source) 4.17.214.17.22 age confidence

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Enabled.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

chore(deps): update github/codeql-action digest to cdefb33 (#989) by @renovate-bot

This PR contains the following updates:

Package Type Update Change
github/codeql-action (changelog) action digest 5d4e8d1cdefb33

Configuration

📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

🧹 Chore

Click to see all chore contributions
  • chore: Don't version private package @cedarjs/framework-tools (d42070e) by @Tobbe

v2.4.0

12 Jan 13:53

Choose a tag to compare

Release Notes

Highlights

Highlights for this release includes continued improvements to the workspace packages feature that lets you share code between the api and web sidesworkspaces, and the release of Cedar Studio v2.x and the required updates to the framework tooling to support it.

Workspace packages

Workspace packages are still behind a feature flag as I keep working on refining the feature. See the release notes for the previous release for more info on how to try out sharing code between api and web.

Cedar Studio

The Studio hasn't received the love and attention it deserves. It really is a stand-out feature of Cedar. I had to send an email in a recent project, and I just love the ability to preview email templates and to run all the workflows that triggers email seeing all the emails end up in Studio. Not having to worry about accidentally sending emails to real users during development is such a relief.

Here's a screenshot from Cedar Studio

image

Other noteworthy changes

  • yarn rw and yarn redwood have been deprecated in favor of running yarn cedar.

    If you want something shorter to type than yarn cedar you can define your own alias in a couple of ways. One option is to create a shell alias. I had a "cedar" zsh alias for a while. So I could just run cedar dev and zsh would expand that to yarn cedar dev. Another option (which I'd recommend over a shell alias) is to just define a regular "script" in your package.json. Something like this would allow you to run yarn c dev:

    "scripts": {
      "c": "cedar"
    }
  • Cedar's api server internally switched to using yoga's handleNodeRequestAndResponse function, enabling Cedar apps to use the useExecutionCancellation plugin. See #957 for more information. Thank you so much @cstoltze for this! 🙏

  • A couple of more low-impact deprecations. See the full details below. I intend to remove the deprecated exports/function parameters etc in a future major release, so please switch as soon as you can if you're currently using anything that's deprecated.

Changelog

🚀 Features

feat(cli): Update .gitignore when creating a workspace package (#913) by @Tobbe

The workspace packages we generate are composite packages. And for composite packages TypeScript generates tsconfig.tsbuildinfo files to enable faster builds. This file should not be version controlled, so we add it to project's .gitignore files.

Read more here https://www.typescriptlang.org/tsconfig/#tsBuildInfoFile

feat(cli): `cedar dev` for workspace packages (#936) by @Tobbe

Similar to how I previously added support for workspace packages to yarn cedar build in #915 this PR adds it to yarn cedar dev.

There is still room for improvement. Like the fact that you still have to restart the dev process to pick up on new changes on the api side.

feat(cli): `cedar build` now also builds all packages (#915) by @Tobbe

yarn cedar build used to only build the "web" and "api" sidesworkspaces. Now it builds web, api and all packages

Output is a bit rough, but it works!

feat(dbAuth): Use uuid as user id (#977) by @Tobbe

Using integers, especially sequential integers, for user IDs is bad practice for security. It makes it all too easy to guess valid user IDs and to guess how many users there are in a system. Using UUIDs is safer, so that's what we're defaulting to now for dbAuth. It's still possible for Cedar app developers to switch over to auto-incrementing ints if they want to. It's just that UUID strings is the new default for when you first set up dbAuth

feat(studio): Update to Cedar Studio v2 (#953) by @Tobbe

Cedar Studio was updated to work with Prisma v6 and Fastify v5. It now requires Node 24 (same as Cedar), and was released as version 2.0.0

This PR makes the Studio setup command install Cedar v2

🛠️ Fixes

  • fix(mailer): Correct package name in yarn add command (a391192) by @Tobbe
fix(cli): side -> workspace for `cedar dev` (#937) by @Tobbe

Same as #914 but for yarn cedar dev instead of build.

fix(cli): side -> workspace for `cedar build` (#914) by @Tobbe

This is mostly a chore kind of commit preparing for adding support for building workspace packages.
I did some refactoring to make the code easier to read. I also renamed "side" to "workspace" since that's what they really are. And that's why this is a "fix" and not just a "chore" because the help output now says "workspace" instead of "side" making this a user facing change as well.

fix(cli): Update templates to say CedarJS Testing Doc (#945) by @Tobbe

More rebranding work

fix(gql): switch to using `handleNodeRequestAndResponse` (#957) by @cstoltze

Update the graphql yoga handler to allow cedar users to enable the useExecutionCancellation plugin using extraPlugins.

Execution cancellation is useful to stop resolving data on the server when the client is no longer interested in the response. This PR sets up the graphql handler so that this plugin is available if cedar users want it.

See graphql-yoga migration notes for justification of why the handler needs to change in order for this plugin to function correctly. handleNodeRequest() is also deprecated:

(method) ServerAdapterObject<{}>.handleNodeRequest(
  nodeRequest: NodeRequest,
  ...ctx: Partial<ServerAdapterInitialContext>[]
): MaybePromise<Response>
This function takes Node’s request object and returns a WHATWG Fetch spec compliant Response object.
@deprecated — Use handleNodeRequestAndResponse instead.
fix(cli): Update generator paths message in upgrade script (#911) by @Tobbe

Make it clear that it's not the templates themselves that are deprecated – it's just the path they're located at

fix(cli): Update workspace package templates (#931) by @Tobbe
  • Use ESM exports in package.json
  • Remove eol semicolon in README code snippet
  • Exclude test files from TypeScript compilation

For the future I probably want a separate tsconfig for building, so that I can keep including test files for IDE integration

fix(esm): Update lodash imports to work with ESM (#940) by @Tobbe

Follow-up on #939 and following the guidelines here https://lodash.com/per-method-packages they ask you to do const throttle = require('lodash/throttle'). The ESM version of that is import throttle from lodash/throttle.js`. So that's what I'm doing everywhere.

fix(netlify): Fix Netlify deploy to use Node 24 (#946) by @Tobbe

Updating the template for netlify.toml with the most important change being the upgrade to Node 24. Current Cedar versions no longer work with Node 20

fix(ui): Fix import issues in Mantine UI setup (#939) by @Tobbe
  • named import for babel
  • direct file imports for lodash
fix(mailer): Use apiKey for ResendMailHandler (#965) by @Tobbe

Make the implementation match the documentation that LLMs are already trained on

⚠️ The older apiToken constructor parameter is now marked as Deprecated. If you have an existing implementation, please switch over to apiKey. It's just a name change, no functionality has changed, so it should be a quick and easy replace

fix(studio): Remove version check since all versions of Cedar support Studio (#951) by @Tobbe

And also ask to install v1 of Studio, as that's the version Cedar Studio use right now

fix(bin): Deprecate `yarn rw` in favor of `yarn cedar` (#981) by @Tobbe

To help LLMs use the correct command, I'm printing a deprecation message

image

If you for some reason can't switch to yarn cedar you can disable the deprecation message by setting rwBinWarning = false in your redwood.toml file. Please also join our Discord and tell me why you can't switch to yarn cedar so that I know not to entirely remove the redwood bin

fix(docs): Fix comment text color on highlighted lines (#980) by @Tobbe

Before

image

After

image
fix(cli): Fix DEP0190 when building (#916) by @Tobbe

Running yarn cedar build used to print "(node:90324) [DEP0190] DeprecationWarning: Passing args to a child process with shell option true can lead to security vulnerabilities, as the arguments are not escaped, only concatenated." to the terminal. This PR fixes this by not using shell: true.

fix(cli): Update yargs script name...
Read more

v2.3.0

02 Jan 13:24

Choose a tag to compare

Release Notes

We have two new exciting features in this release!

  1. Custom Cedar scripts templates
  2. (Experimental) code sharing between the web and api sides

1. Custom Cedar scripts templates

Many might not be aware of this, but you can customize most of the code that Cedar's generators generate for you. The generated code is all based on templates, and you can bring your own templates for all the generator commands. If you for example don't like the default page that yarn cedar generate page gives you, you can update the template for generated pages.

Up until now there was one thing missing though – being able to customize the template for scripts generated by yarn cedar generate script. But no more! As of this release you can run yarn setup generator script and you will get generatorTemplates/scripts/script/script.ts.template, which is the template that's used for new scripts. Make whatever edits you want, and the next time you generate a script your own custom template will be used!

To make this work I decided to move all generated templates to this new generatorTemplates/ top level directory. So if you have custom templates for any of the generators already, please move them to this new top level directory. web/generators/<generator-name> should be moved to generatorTemplates/web/<generator-name>, and same thing for api side generators. This release also includes a codemod you can run to do this for you. If you want to automatically move your existing templates you can run npx @cedarjs/codemods@latest move-generator-templates. The old location continues to work, so moving your existing templates is optional, but highly recommended. I plan to remove support for the old location in the next major release of Cedar.

Do be aware though that you're basically "ejecting" here. If there are any updates/fixes to the templates Cedar uses you won't get those. Cedar will continue using your templates.

TL;DR:

  • Run npx @cedarjs/codemods@latest move-generator-templates.
  • Generate templates for scripts by running yarn cedar setup generator script.

2. Code Sharing Between the Web and Api Sides

Being able to share code between the web and api sides of a Cedar app has been a long standing feature request. I have now implemented experimental support for this by the way of workspace packages.

It works, but the workflow is still too manual for the feature to be generally available.

Read more in the PR description for #767 and #908 and see the list of things still left to do in #725

To make code sharing work you need to update the tsconfig file for the API side. The new yarn cedar generate package command will do this for you, so no manual update is strictly needed. But it's recommended to also update the tsconfig file in the scripts/ directory, and the package generator command will not do this. New Cedar apps will have updated tsconfig files for both api/ and scripts/, but for existing apps we recommend you manually update. The required change is to upgrade "module" to "node20". See more in #902

And, of course, in alignment with feature highlight #1 above, it's also possible to fully customize the templates used for generating workspace packages. Just run yarn cedar setup generator package and you'll get to customize all the templates you want in generatorTemplates/packages/package.

Because this is an experimental feature you have to manually enable it like this in your redwood.toml file:

[experimental.packagesWorkspace]
  enabled = true

TL;DR: Run yarn cedar generate package and follow the instructions on the screen.

Changelog

🚀 Features

feat(upgrade): Add first upgrade script (#857) by @Tobbe

Adding a script to show a deprecation warning if old workspace syntax is detected

feat(cli): Link to Proxy docs on failed latestVersion call (#889) by @Tobbe

Got this error report on Discord earlier today

yarn cedar upgrade
√ Confirm upgrade
× Could not find the latest version
■ Removing CLI cache
■ Running yarn install
■ Refreshing the Prisma client
■ De-duplicating dependencies
■ One more thing..
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Error: Could not find the latest version
    at setLatestVersionToContext (file:///project_path/node_modules/@cedarjs/cli/dist/commands/upgrade.js:249:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async _Task.run (file:///project_path/node_modules/listr2/dist/index.js:1979:11)

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Need help?
 - Not sure about something or need advice? Reach out on our Forum
 - Think you've found a bug? Open an issue on our GitHub
 - Here's your unique error reference to quote: '8a23ea7e-157a-4555-bbb7-f0f7b846bef3'

After some debugging we discovered this:

e TypeError: fetch failed
    at node:internal/deps/undici/undici:15845:13
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async function_ (file:///D:/dimas/project/re-BISA/node_modules/ky/distribution/core/Ky.js:23:28)
    at async #retry (file:///D:/dimas/project/re-BISA/node_modules/ky/distribution/core/Ky.js:286:20)
    at async result.<computed> [as json] (file:///D:/dimas/project/re-BISA/node_modules/ky/distribution/core/Ky.js:89:34)
    at async packageJson (file:///D:/dimas/project/re-BISA/node_modules/package-json/index.js:43:10)
    at async latestVersion (file:///D:/dimas/project/re-BISA/node_modules/latest-version/index.js:6:20)
    at async setLatestVersionToContext (file:///D:/dimas/project/re-BISA/node_modules/@cedarjs/cli/dist/commands/upgrade.js:239:26)
    at async _Task.run (file:///D:/dimas/project/re-BISA/node_modules/listr2/dist/index.js:1979:11) {
  [cause]: Error: getaddrinfo ENOTFOUND registry.npmjs.org
      at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:122:26) {
    errno: -3008,
    code: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'registry.npmjs.org'
  }
}

And with some more digging we saw this:

node -e "require('dns').lookup('registry.npmjs.org', console.log)"
Error: getaddrinfo ENOTFOUND registry.npmjs.org
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:111:26) {
  errno: -3008,
  code: 'ENOTFOUND',
  syscall: 'getaddrinfo',
  hostname: 'registry.npmjs.org'
}

At which point we realized that the user was behind a Proxy and needed to configure the proxy to be able to access the npm registry. They had already configured yarn and npm to use their proxy, but not Node.

When I found the docs for the recently added proxy support natively in Node they were able to set some env vars and could then successfully run the upgrade command.

I decided I should update the error message that yarn cedar upgrade prints to include the https://nodejs.org/api/http.html#built-in-proxy-support link.
And I also made it print the full error message when you use the --verbose flag.

feat(cli): Experimental flag to enable shared packages (#908) by @Tobbe

Sharing code by putting it in a workspace package and importing it on both the web and api sides now work, but the feature isn't polished enough for general availability yet. But I still want users to be able to experiment with this new feature, so I'm putting it behind an experimental flag.

Just add this to your redwood.toml file to enable the feature

[experimental.packagesWorkspace]
  enabled = true
feat(cli): Custom script templates (#813) by @Tobbe

Not a lot of people know this, but it's possible to fully customize the files being generated by Cedar generators like yarn cedar generate page, yarn cedar generate scaffold etc.

The script generator however (yarn cedar generate script <name>) did not have this possibility. But now it does!

To facilitate this improvement I've also decided to move the templates the generators use. Templates for generators used on the web side, like yarn cedar generate page used to live inside web/generators/. And for api side generators there were a api/generators/ folder (if you had custom generators setup that is).

For scripts I didn't want to have a scripts/generators/ folder though. Because that might interfere with a script you already have, or wanted to create in the future.

So with this PR I move all generator templates out into a new top-level folder called generatorTemplates/. Inside that folder you'll have api/, web/ and scripts/ sub-folders.

If you don't have any custom templates the folder(s) won't be created.

This used to be a breaking change, but thanks to #876 I can now release this in a minor version if I release both PRs together (which I will)

📝 For the release notes: There's also a codemod for this upgrade that will move your current custom templates for you

feat(upgrade-scripts): 3.x upgrade script and updated canary script (66c457c) by @Tobbe

Adding a package.json file to make it easier to test the scripts locally without Node complaining about ESM syntax

feat(cca): Update tsconfig and jsconfig to support require(ESM) (#902) by @Tobbe

Update tsconfig and jsconfig for the api side and for scripts to align with the fact that we now require Node 24. This lets TS know that it's safe to requ...

Read more

v2.2.1

29 Dec 14:39

Choose a tag to compare

Release Notes

This release contains fixes to the pre-upgrade command feature that was introduced in v2.2.0. I hope to make use of that feature in the next minor and major releases, so you need to install this patch release first, to be able to take advantage of the extra help the pre-upgrade script will give you.

Changelog

🛠️ Fixes

fix(cli): Fix mailer setup on Windows (#850) by @Tobbe

Adding this to debug #830
And I'm probably going to keep it, to make sure we're not regressing on this in the future

fix(upgrade): canary pre-upgrade scripts (#858) by @Tobbe

Fix pre-release scripts for tag releases like canary and rc

fix(upgrade): Tweak output from pre-upgrade scripts (#861) by @Tobbe
  • Error emoji that works in more terminals (🚨)
  • Two spaces for indentation
  • Only one empty line between heading and messages
  • Extra details on errors with --verbose
fix(upgrade): Tweak output for package upgrades and pre-upgrade scripts (#872) by @Tobbe

Before:

Updated packages appears at end of output
Pre-upgrade message title icon 📣 is indented 3 spaces

image

After:

Updated packages are grouped with the correct task in the task list
Pre-upgrade message title icon is correctly indented 2 spaces

image
fix(upgrade): Use npm with pre-upgrade scripts (#859) by @Tobbe

Switch from yarn to npm to not have to worry about PnP support, yarn versions, etc. npm is guaranteed to be available on all systems with Node, and we know it's a modern version of npm too.

And to not have to fiddle with updating a package.json file to tell Node to use ESM mode I set the file extension to .mts.

📦 Dependencies

Click to see all 13 dependency updates

🧹 Chore

Click to see all chore contributions
  • chore(renovate): Finer grained control for some packages (node, uuid, kill-port) (#867) by @Tobbe
  • chore(cli): Convert JS files to TS (part I) (#855) by @Tobbe
  • chore(config): migrate Renovate config (#868) by @renovate-bot

v2.2.0

26 Dec 16:37

Choose a tag to compare

Release Notes

The focus of this release has been to get all minor and patch version updates to packages Cedar depend on merged. And I'm happy to say I succeeded! This release has 77 commits with package updates.

On the Features front there are two things I want to call out

  1. I've updated the templates for new Cedar apps to use modern workspace config in the root package.json file. I recommend you do the same for your projects.

    Just change it from this:

      "workspaces": {
        "packages": [
          "api",
          "web"
        ]
      },

    to this:

      "workspaces": [
        "api",
        "web"
      ]

    Read more here: #751

  2. The yarn cedar upgrade cli now comes with a new feature where it can run pre-upgrade scripts and print messages relevant to the new release you're about to upgrade to. There's a bit of a chicken-and-egg problem here though, where you need a version of the cli that already has this support before it can help you with the upgrade to the next version. So I'm shipping this feature with this version without any actual pre-upgrade scripts, so that all users get the new cli feature for when it's needed for future upgrades.

    Future upgrades might for example have a pre-check to make sure you've updated to the new workspace definition syntax shown above before it lets you continue with the upgrade (unless you use --force).

There's also a "fix" worth mentioning: For those of you who work on the framework itself I've renamed the rwfw binary to cfw. Piece by piece I'm chipping away on the Redwood to Cedar rebranding 🙂

Changelog

🚀 Features

feat(cca): Use modern workspace config (#751) by @Tobbe

Cedar apps have always shipped with the following workspace config

  "workspaces": {
    "packages": [
      "api",
      "web"
    ]
  },

If you read yarn's docs on workspaces they say the "workspaces" value should be an array, but here it was an object.
It's very difficult to find any kind of documentation for this object notation. Even going back to the yarn v1.x docs it says it should be an array.
Here are their introduction blog post when they added workspaces support: https://classic.yarnpkg.com/blog/2017/08/02/introducing-workspaces/
That blog post also only mentions the array syntax.

Even more digging lead me to this blog post from 2018 https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
Yarn introduced a nohoist option for workspaces. And this is where they also added support for workspaces being an object with a packages key.

So, from yarn v1.4.2 workspaces could be an object.

With yarn v2 the hoisted option in the workspaces config was replaced by their nmHoistingLimits config as seen in their migration docs. But, and this is only my guess, they decided to keep support for the workspaces.packages syntax to be less disruptive and make it easier for projects to upgrade.

So the reason we use the object notation is that the template in Redwood was set up to use that syntax when Redwood still used yarn v1 >v1.4 and it just hasn't changed since then. This is where Redwood introduced that config: redwoodjs/create-redwood-app@3651cb0

Switching to the array syntax also make the config work with npm and pnpm, making it easier for users to switch to another package manager if they want.

feat(cli): pre-upgrade scripts (#833) by @Tobbe

This PR adds a new feature to the yarn cedar upgrade command where it can download and execute a script before running the actual upgrade.

This is intended to be used to either just print informational messages during upgrade, or to run pre-upgrade checks. If, for example, there is something the user has to change in the project before being able to upgrade, this would be a good place to check if that thing has been completed

feat(cli): Better upgrade and exit output (#839) by @Tobbe

This PR improves cli command output for the upgrade command specifically and the error display for all cli commands in general.

The upgrade command has update information displayed inline instead of at the end of the command output.

Error output has been updated to link to the Cedar Discord instead of the RW forums. And error delimiter lines have been shortened to prevent wrapping when the output is long enough to cause scrollbars to render.

Before

dry-run

image

error

image

After

dry-run

image

error

image

🛠️ Fixes

fix(cedar): Update all docs links to point to https://cedarjs.com/docs (#783) by @Tobbe

Update all old rw doc links to now point to https://cedarjs.com/docs instead

fix(bin): Rename rwfw to cfw (#793) by @Tobbe

Renaming the rwfw that's used for internal framework development and testing to cfw.
This could be considered a breaking change, but since it's only(?) used by maintainers and contributors, not Cedar app developers, I'll release this as part of the next minor version

Also renaming a few internal environment variable names and const names.

📦 Dependencies

Click to see all 77 dependency updates
Read more

v2.1.1

19 Dec 11:42

Choose a tag to compare

Release Notes

This release makes the switch to eslint's flat config introduce fewer eslint rule changes. The goal is that no new errors/warnings should be introduced to your codebase. Please file an issue if you see something new.

Changelog

🛠️ Fixes

fix(eslint): Make new flat config more compatible with the old legacy config (#730) by @Tobbe

A user reported seeing new eslint errors after upgrading to Cedar v2

/home/me/dev/project/web/src/test-helpers.ts
  165:3  error  'mockGraphQLQuery' is not defined  no-undef

/home/me/dev/project/web/src/test/helpers.ts
  30:3  error  'mockCurrentUser' is not defined  no-undef
  68:4   error  'GraphQLMutationHookOptions' is not defined  no-undef
  68:36  error  'GraphQLOperationVariables' is not defined   no-undef

This PR addresses those issues, and a few more I noticed while working on the config

📦 Dependencies

Click to see all 27 dependency updates

🧹 Chore

Click to see all chore contributions
  • chore(ci): Add GitHub stale action. Mark issues and PRs as stale after 30 days (3384169) by @Tobbe
  • chore(ci): Fix permissions and message for Stale action (9652dc7) by @Tobbe
  • chore(jobs): Fix timing issue in flaky forever loop unit test by mocking timers (#739) by @Tobbe