Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
100 changes: 100 additions & 0 deletions packages/build-info/src/frameworks/cedar.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import { beforeEach, expect, test } from 'vitest'

import { mockFileSystem } from '../../tests/mock-file-system.js'
import { NodeFS } from '../node/file-system.js'
import { Project } from '../project.js'

beforeEach((ctx) => {
ctx.fs = new NodeFS()
})

const cedarToml = `
# This file contains the configuration settings for your Cedar app.
# This file is also what makes your Cedar app a Cedar app.
# If you remove it and try to run \`yarn cedar dev\`, you'll get an error.
#
# For the full list of options, see the "App Configuration: cedar.toml" doc:
# https://cedarjs.com/docs/app-configuration-cedar-toml

[web]
title = "Cedar App"
port = 8910
apiUrl = "/.redwood/functions"
includeEnvironmentVariables = [
# Add any ENV vars that should be available to the web side to this array
# See https://cedarjs.com/docs/environment-variables#web
]
[api]
port = 8911
[browser]
open = true
[notifications]
versionUpdates = ["latest"]
`

test('should detect cedar', async ({ fs }) => {
const cwd = mockFileSystem({
'cedar.toml': cedarToml,
'package.json': JSON.stringify({
private: true,
workspaces: {
packages: ['api', 'web'],
},
devDependencies: {
'@cedarjs/core': '2.8.0',
},
eslintConfig: {
extends: '@cedarjs/eslint-config',
root: true,
},
engines: {
node: '=24.x',
},
packageManager: 'yarn@4.12.0',
}),
'web/package.json': JSON.stringify({
name: 'web',
version: '0.0.0',
private: true,
browserslist: {
development: ['last 1 version'],
production: ['defaults'],
},
dependencies: {
'@cedarjs/forms': '2.8.0',
'@cedarjs/router': '2.8.0',
'@cedarjs/web': '2.8.0',
react: '18.3.1',
'react-dom': '18.3.1',
},
devDependencies: {
'@cedarjs/vite': '2.8.0',
'@types/react': '^18.2.55',
'@types/react-dom': '^18.2.19',
},
}),
'api/package.json': JSON.stringify({
name: 'api',
version: '0.0.0',
private: true,
dependencies: {
'@cedarjs/api': '2.8.0',
'@cedarjs/graphql-server': '2.8.0',
},
}),
})

const project = new Project(fs, cwd, cwd)

expect(await project.detectWorkspaces()).toBeNull()
const detected = await project.detectFrameworks()

expect(detected).toHaveLength(1)
expect(detected?.[0].id).toBe('cedarjs')
expect(detected?.[0].name).toBe('CedarJS')
expect(detected?.[0].build.command).toBe('cedar deploy netlify')
expect(detected?.[0].build.directory).toBe('web/dist')
expect(detected?.[0].dev?.command).toBe('yarn cedar dev')
expect(detected?.[0].env.NODE_VERSION).toBe('24')
expect(detected?.[0].env.AWS_LAMBDA_JS_RUNTIME).toBe('nodejs24.x')
})
35 changes: 35 additions & 0 deletions packages/build-info/src/frameworks/cedarjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { BaseFramework, Category, Framework } from './framework.js'

export class CedarJS extends BaseFramework implements Framework {
readonly id = 'cedarjs'
name = 'CedarJS'
npmDependencies = ['@cedarjs/core']
configFiles = ['cedar.toml']
category = Category.SSG
staticAssetsDirectory = 'public'

dev = {
// Cedar only works with yarn
// https://cedarjs.com/docs/tutorial/chapter1/prerequisites#nodejs-and-yarn-versions
command: 'yarn cedar dev',
port: 8910,
pollingStrategies: [{ name: 'TCP' }],
}

build = {
// explicitly not invoked with yarn: https://github.com/netlify/framework-info/commit/b3cd21d1e60d91facd397068f35b850b80d1ef13
command: 'cedar deploy netlify',
directory: 'web/dist',
}

env = {
AWS_LAMBDA_JS_RUNTIME: 'nodejs24.x',
NODE_VERSION: '24',
}

logo = {
default: '/logos/cedarjs/default.png',
light: '/logos/cedarjs/default.png',
dark: '/logos/cedarjs/default.png',
}
}
2 changes: 2 additions & 0 deletions packages/build-info/src/frameworks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Astro } from './astro.js'
import { Blitz } from './blitz.js'
import { Brunch } from './brunch.js'
import { Cecil } from './cecil.js'
import { CedarJS } from './cedarjs.js'
import { DocPad } from './docpad.js'
import { Docusaurus } from './docusaurus.js'
import { Eleventy } from './eleventy.js'
Expand Down Expand Up @@ -56,6 +57,7 @@ import { Zola } from './zola.js'
export const frameworks = [
// Static site generators / meta frameworks
Astro,
CedarJS,
Docusaurus,
Eleventy,
Gatsby,
Expand Down
4 changes: 4 additions & 0 deletions packages/build-info/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ export class Project {
return null
}

async isCedarProject(): Promise<boolean> {
return await this.fs.fileExists(this.fs.resolve(this.fs.cwd, 'cedar.toml'))
}

async isRedwoodProject(): Promise<boolean> {
return await this.fs.fileExists(this.fs.resolve(this.fs.cwd, 'redwood.toml'))
}
Expand Down
2 changes: 1 addition & 1 deletion packages/build-info/src/workspaces/detect-workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export async function detectWorkspaces(project: Project): Promise<WorkspaceInfo
return null
}

if (await project.isRedwoodProject()) {
if ((await project.isRedwoodProject()) || (await project.isCedarProject())) {
return null
}

Expand Down