-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ci/pin-os-and-node-images
- Loading branch information
Showing
11 changed files
with
221 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
packages/build-info/src/frameworks/react-router.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
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() | ||
}) | ||
test('detects a site using React Router v7 as a framework', async ({ fs }) => { | ||
const cwd = mockFileSystem({ | ||
'react-router.config.ts': '', | ||
'vite.config.ts': '', | ||
'package.json': JSON.stringify({ | ||
scripts: { | ||
build: 'react-router build', | ||
dev: 'react-router dev', | ||
start: 'react-router-serve ./build/server/index.js', | ||
typecheck: 'react-router typegen && tsc', | ||
}, | ||
dependencies: { | ||
'@react-router/node': '^7.0.2', | ||
'@react-router/serve': '^7.0.2', | ||
react: '^18.3.1', | ||
'react-dom': '^18.3.1', | ||
'react-router': '^7.0.2', | ||
}, | ||
devDependencies: { | ||
'@netlify/vite-plugin-react-router': '^1.0.0', | ||
'@react-router/dev': '^7.0.2', | ||
typescript: '^5.6.3', | ||
vite: '^5.4.11', | ||
'vite-tsconfig-paths': '^5.1.2', | ||
}, | ||
}), | ||
}) | ||
const detected = await new Project(fs, cwd).detectFrameworks() | ||
|
||
const detectedFrameworks = (detected ?? []).map((framework) => framework.id) | ||
expect(detectedFrameworks).not.toContain('remix') | ||
|
||
expect(detected?.[0]?.id).toBe('react-router') | ||
expect(detected?.[0]?.build?.command).toBe('react-router build') | ||
expect(detected?.[0]?.build?.directory).toBe('build/client') | ||
expect(detected?.[0]?.dev?.command).toBe('react-router dev') | ||
expect(detected?.[0]?.dev?.port).toBe(5173) | ||
}) | ||
|
||
test('does NOT detect a site using React Router v7 as a library', async ({ fs }) => { | ||
const cwd = mockFileSystem({ | ||
'rollup.config.ts': '', | ||
'package.json': JSON.stringify({ | ||
scripts: { | ||
build: 'rollup build', | ||
dev: 'rollup dev', | ||
typecheck: 'react-router typegen && tsc', | ||
}, | ||
dependencies: { | ||
react: '^18.3.1', | ||
'react-dom': '^18.3.1', | ||
'react-router': '^7.0.2', | ||
}, | ||
devDependencies: { | ||
rollup: '^4.28.1', | ||
typescript: '^5.6.3', | ||
}, | ||
}), | ||
}) | ||
const detected = await new Project(fs, cwd).detectFrameworks() | ||
|
||
const detectedFrameworks = (detected ?? []).map((framework) => framework.id) | ||
expect(detectedFrameworks).not.toContain('react-router') | ||
}) | ||
|
||
test('does NOT detect a React Router <v7 site', async ({ fs }) => { | ||
const cwd = mockFileSystem({ | ||
'vite.config.ts': '', | ||
'package.json': JSON.stringify({ | ||
scripts: { | ||
build: 'vite build', | ||
dev: 'vite dev', | ||
}, | ||
dependencies: { | ||
react: '^18.2.0', | ||
'react-dom': '^18.2.0', | ||
'react-router-dom': '^6.15.0', | ||
}, | ||
devDependencies: { | ||
'@vitejs/plugin-react': '^3.0.1', | ||
typescript: '^4.9.5', | ||
vite: '^4.0.4', | ||
}, | ||
}), | ||
}) | ||
const detected = await new Project(fs, cwd).detectFrameworks() | ||
|
||
const detectedFrameworks = (detected ?? []).map((framework) => framework.id) | ||
expect(detectedFrameworks).not.toContain('react-router') | ||
|
||
expect(detected?.[0]?.id).toBe('vite') | ||
}) |
Oops, something went wrong.