Skip to content

Conversation

@Tobbe
Copy link
Member

@Tobbe Tobbe commented Jan 14, 2026

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.

@netlify
Copy link

netlify bot commented Jan 14, 2026

Deploy Preview for cedarjs failed.

Name Link
🔨 Latest commit 22912b0
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/6968f63931769a0008decc76

@github-actions github-actions bot added this to the next-release milestone Jan 14, 2026
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 14, 2026

Greptile Summary

This PR adds support for cedar.toml configuration files alongside the existing redwood.toml files to better identify Cedar apps for external tools and AI assistants. The implementation correctly prioritizes cedar.toml over redwood.toml when both exist.

Key changes:

  • Enhanced findUp() utility to accept arrays of filenames and check them in priority order
  • Updated getConfigPath() to search for both cedar.toml and redwood.toml with proper prioritization
  • Renamed template config files from redwood.toml to cedar.toml for all project templates (js, ts, esm-js, esm-ts)
  • Updated 60+ files with generic config terminology instead of hardcoded "redwood.toml" references
  • Added comprehensive test coverage for prioritization logic
  • Updated error messages to mention both config file options

The core findUp implementation properly prioritizes files by checking them in array order at each directory level before traversing up. However, two locations (packages/cli/src/index.js:277-279 and packages/cli-helpers/src/lib/project.ts:192-194) use sequential findUp() calls instead of passing an array, causing redundant filesystem traversals when only redwood.toml exists.

Confidence Score: 4/5

  • This PR is safe to merge with minor performance considerations
  • The implementation is well-tested with comprehensive test coverage for the new prioritization logic. The core findUp function correctly implements array-based prioritization. Two locations have minor performance issues with sequential filesystem traversals but won't cause functional problems. All template files properly use cedar.toml, and backward compatibility with redwood.toml is preserved.
  • Pay attention to packages/cli/src/index.js and packages/cli-helpers/src/lib/project.ts for the sequential findUp() calls that could be optimized

Important Files Changed

Filename Overview
packages/project-config/src/configPath.ts Updated to support both cedar.toml and redwood.toml with correct prioritization using array-based lookup
packages/project-config/src/findUp.ts Enhanced to accept array of filenames and iterate through them with proper prioritization
packages/cli/src/index.js Added fallback logic for config file discovery but uses inefficient sequential findUp calls that traverse filesystem twice
packages/cli-helpers/src/lib/project.ts Updated setRedwoodCWD with same inefficient sequential findUp pattern as CLI index

Sequence Diagram

sequenceDiagram
    participant CLI as CLI/Command
    participant Helper as cli-helpers
    participant ConfigPath as configPath.ts
    participant FindUp as findUp.ts
    participant FS as FileSystem

    CLI->>Helper: setRedwoodCWD(cwd?)
    alt cwd specified
        Helper->>FS: Check for cedar.toml or redwood.toml
        FS-->>Helper: exists/not exists
    else cwd not specified
        Helper->>FindUp: findUp('cedar.toml')
        FindUp->>FS: Walk up dirs looking for cedar.toml
        FS-->>FindUp: result or null
        alt cedar.toml not found
            Helper->>FindUp: findUp('redwood.toml')
            FindUp->>FS: Walk up dirs again
            FS-->>FindUp: result or null
        end
    end
    
    Note over CLI,FS: Core config resolution (optimized)
    
    CLI->>ConfigPath: getConfigPath(cwd)
    ConfigPath->>FindUp: findUp(['cedar.toml', 'redwood.toml'], cwd)
    loop Each directory level
        FindUp->>FS: exists(cedar.toml)?
        alt cedar.toml exists
            FS-->>FindUp: path to cedar.toml
            FindUp-->>ConfigPath: return path
        else cedar.toml missing
            FindUp->>FS: exists(redwood.toml)?
            alt redwood.toml exists
                FS-->>FindUp: path to redwood.toml
                FindUp-->>ConfigPath: return path
            else both missing
                Note over FindUp: Move up one directory
            end
        end
    end
    ConfigPath-->>CLI: config file path
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

62 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +192 to +194
const configTomlPath =
findUp('cedar.toml', process.cwd()) ||
findUp('redwood.toml', process.cwd())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: inefficient sequential filesystem traversals - findUp walks the directory tree twice when only redwood.toml exists

Suggested change
const configTomlPath =
findUp('cedar.toml', process.cwd()) ||
findUp('redwood.toml', process.cwd())
const configTomlPath = findUp(['cedar.toml', 'redwood.toml'], process.cwd())
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cli-helpers/src/lib/project.ts
Line: 192:194

Comment:
**style:** inefficient sequential filesystem traversals - `findUp` walks the directory tree twice when only `redwood.toml` exists

```suggestion
    const configTomlPath = findUp(['cedar.toml', 'redwood.toml'], process.cwd())
```

How can I resolve this? If you propose a fix, please make it concise.

@nx-cloud
Copy link

nx-cloud bot commented Jan 14, 2026

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 22912b0

Command Status Duration Result
nx run-many -t test:types ✅ Succeeded 6s View ↗
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded 33s View ↗
nx run-many -t build ✅ Succeeded 2m 3s View ↗

☁️ Nx Cloud last updated this comment at 2026-01-15 14:20:01 UTC

@Tobbe
Copy link
Member Author

Tobbe commented Jan 15, 2026

@greptileai Can you please review this PR again and pay extra attention to any changes that might cause problems on Windows systems?

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this PR, I can identify several potential issues that could cause problems on Windows systems:

1. Path Separator Issues in Docker Templates

In packages/cli/src/commands/setup/docker/templates/Dockerfile, the COPY commands use globbing patterns that may not work consistently across platforms:

COPY --chown=node:node cedar.toml* redwood.toml* ./

This pattern assumes Unix-style path handling and may not work reliably on Windows Docker contexts.

2. File Path Construction in Configuration Detection

In packages/cli/src/lib/project.ts and packages/project-config/src/configPath.ts, there are multiple places where file paths are constructed and checked:

const configFiles = ['cedar.toml', 'redwood.toml']
if (!configFiles.some((file) => cwd && fs.existsSync(path.join(cwd, file)))) {

While path.join() should handle this correctly, the error messages and path comparisons might not account for Windows path separators.

3. Path Comparison and Caching Issues

In packages/project-config/src/configPath.ts, the caching mechanism uses the cwd as a key:

const getConfigPathCache = new Map<string, string>()

On Windows, path casing and separator differences could cause cache misses or incorrect lookups.

4. Find-up Logic Potential Issues

The find-up logic now checks for two files instead of one:

const configPath = findUp('cedar.toml', cwd) || findUp('redwood.toml', cwd)

This could be inefficient on Windows and may have different behavior depending on the file system case sensitivity.

5. Template Path References

Several template files now reference both config files with wildcards, which might not expand correctly on Windows systems, particularly in the Docker context.

Recommendations

To make this more Windows-compatible, consider:

  1. Normalize paths consistently - ensure all path operations use path.resolve() and path.normalize()
  2. Test Docker globbing - verify the cedar.toml* redwood.toml* pattern works on Windows Docker Desktop
  3. Case-insensitive caching - normalize cache keys for path comparisons on Windows
  4. Error message paths - ensure error messages display paths in the correct format for the platform

The changes look generally solid, but these Windows-specific considerations should be tested thoroughly, especially the Docker template changes and the dual-file detection logic.

@Tobbe
Copy link
Member Author

Tobbe commented Jan 15, 2026

@greptileai We don't need Docker support on Windows, so ignore that.

I'm specifically seeing this error. Can you spot what change might have caused this?

❌ > nx run @cedarjs/internal:build
  
  
    dist\generate\typeDefinitions.js  10.0kb
    dist\generate\graphqlCodeGen.js    9.4kb
    dist\validateSchema.js             5.5kb
    dist\files.js                      4.7kb
    dist\ast.js                        4.6kb
    ...and 20 more output files...
  
  Done in 45ms
  ---- Error building ESM types ----
  file:///D:/a/cedar/cedar/packages/framework-tools/dist/generateTypes.js:28
      throw new Error(e);
            ^
  
  Error: 12:44:11 PM - Projects in this build: 
  
      * tsconfig.build.json
  
  
  
  12:44:11 PM - Project 'tsconfig.build.json' is out of date because output file 'tsconfig.build.tsbuildinfo' does not exist
  
  
  
  12:44:11 PM - Building project 'D:/a/cedar/cedar/packages/internal/tsconfig.build.json'...
  
  
  
  Error: src/routes.ts(11,28): error TS7016: Could not find a declaration file for module '@cedarjs/structure'. 'D:/a/cedar/cedar/packages/structure/dist/index.js' implicitly has an 'any' type.
  
    Try `npm i --save-dev @types/cedarjs__structure` if it exists or add a new declaration (.d.ts) file containing `declare module '@cedarjs/structure';`
  
  Error: src/routes.ts(12,30): error TS7016: Could not find a declaration file for module '@cedarjs/structure'. 'D:/a/cedar/cedar/packages/structure/dist/index.js' implicitly has an 'any' type.
  
    Try `npm i --save-dev @types/cedarjs__structure` if it exists or add a new declaration (.d.ts) file containing `declare module '@cedarjs/structure';`
  
  Error: src/routes.ts(102,3): error TS2578: Unused '@ts-expect-error' directive.
      at generateTypesEsm (file:///D:/a/cedar/cedar/packages/framework-tools/dist/generateTypes.js:28:11)
      at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
      at async <anonymous> (D:\a\cedar\cedar\packages\internal\build.mts:14:1)
  
  Node.js v24.12.0

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the error, the issue appears to be a TypeScript compilation error in the @cedarjs/internal package, specifically in src/routes.ts. The error shows:

  1. Could not find a declaration file for module '@cedarjs/structure'
  2. Unused '@ts-expect-error' directive

However, looking through the diff you provided, I don't see any changes to the @cedarjs/structure package or the @cedarjs/internal package that would directly cause this issue.

The most likely culprit is this change in File 67: packages/structure/src/model/RWProject.ts:

@lazy() get redwoodTOML(): RWTOML {
-  return new RWTOML(join(this.projectRoot, 'redwood.toml'), this)
+  return new RWTOML(getConfigPath(this.projectRoot), this)
}

And the related import addition:

import {
  getPaths,
  processPagesDir,
  getSchemaPath,
+ getConfigPath,
} from '@cedarjs/project-config'

This change modifies the public API of the @cedarjs/structure package by changing how the RWTOML class is instantiated. The getConfigPath() function now looks for either cedar.toml or redwood.toml, which could potentially return a different path or throw an error in cases where it previously worked.

The TypeScript error about missing declaration files suggests that there might be a build order issue or the @cedarjs/structure package needs to be rebuilt before @cedarjs/internal can properly import it.

The "Unused '@ts-expect-error' directive" error in src/routes.ts line 102 suggests that whatever error was being suppressed there is no longer occurring, possibly due to the API change in the structure package.

Recommendation: Try rebuilding the @cedarjs/structure package first, then rebuild @cedarjs/internal. The build system might need the structure package to be built with its new API before other packages can properly reference it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants