-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(build-info): fix detection of Remix sites
- Loading branch information
Showing
9 changed files
with
265 additions
and
8 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
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 Remix Classic Compiler site with origin SSR as remix-classic', async ({ fs }) => { | ||
const cwd = mockFileSystem({ | ||
'remix.config.js': '', | ||
'package.json': JSON.stringify({ | ||
scripts: { | ||
build: 'remix build', | ||
dev: 'remix dev', | ||
start: 'netlify serve', | ||
typecheck: 'tsc', | ||
}, | ||
dependencies: { | ||
'@netlify/functions': '^2.8.1', | ||
'@remix-run/css-bundle': '^2.9.2', | ||
'@remix-run/node': '^2.9.2', | ||
'@remix-run/react': '^2.9.2', | ||
react: '^18.2.0', | ||
'react-dom': '^18.2.0', | ||
}, | ||
devDependencies: { | ||
'@netlify/remix-adapter': '^2.4.0', | ||
'@remix-run/dev': '^2.9.2', | ||
'@remix-run/serve': '^2.9.2', | ||
}, | ||
}), | ||
}) | ||
const detected = await new Project(fs, cwd).detectFrameworks() | ||
|
||
const detectedFrameworks = (detected ?? []).map((framework) => framework.id) | ||
expect(detectedFrameworks).not.toContain('remix') | ||
expect(detectedFrameworks).not.toContain('vite') | ||
|
||
expect(detected?.[0].id).toBe('remix-classic') | ||
expect(detected?.[0].build.command).toBe('remix build') | ||
expect(detected?.[0].build.directory).toBe('public') | ||
expect(detected?.[0].dev?.command).toBe('remix watch') | ||
}) | ||
|
||
test('detects a Remix Classic Compiler site with edge SSR as remix-classic', async ({ fs }) => { | ||
const cwd = mockFileSystem({ | ||
'remix.config.js': '', | ||
'package.json': JSON.stringify({ | ||
scripts: { | ||
build: 'remix build', | ||
dev: 'remix dev', | ||
start: 'netlify serve', | ||
typecheck: 'tsc', | ||
}, | ||
dependencies: { | ||
'@netlify/functions': '^2.8.1', | ||
'@netlify/remix-runtime': '^2.3.0', | ||
'@remix-run/css-bundle': '^2.9.2', | ||
'@remix-run/node': '^2.9.2', | ||
'@remix-run/react': '^2.9.2', | ||
react: '^18.2.0', | ||
'react-dom': '^18.2.0', | ||
}, | ||
devDependencies: { | ||
'@netlify/remix-edge-adapter': '^3.3.0', | ||
'@remix-run/dev': '^2.9.2', | ||
'@remix-run/serve': '^2.9.2', | ||
}, | ||
}), | ||
}) | ||
const detected = await new Project(fs, cwd).detectFrameworks() | ||
|
||
const detectedFrameworks = (detected ?? []).map((framework) => framework.id) | ||
expect(detectedFrameworks).not.toContain('remix') | ||
expect(detectedFrameworks).not.toContain('vite') | ||
|
||
expect(detected?.[0].id).toBe('remix-classic') | ||
expect(detected?.[0].build.command).toBe('remix build') | ||
expect(detected?.[0].build.directory).toBe('public') | ||
expect(detected?.[0].dev?.command).toBe('remix watch') | ||
}) |
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,44 @@ | ||
import { BaseFramework, Category, Framework } from './framework.js' | ||
|
||
export class RemixClassic extends BaseFramework implements Framework { | ||
readonly id = 'remix-classic' | ||
name = 'Remix (Classic Compiler)' | ||
npmDependencies = [ | ||
'@remix-run/react', | ||
'@remix-run/dev', | ||
'@remix-run/server-runtime', | ||
'@netlify/remix-adapter', | ||
'@netlify/remix-edge-adapter', | ||
'@netlify/remix-runtime', | ||
// Deprecated package name (deprecated in 1.6, removed in 2.0) | ||
'remix', | ||
// Deprecated Netlify packages | ||
'@remix-run/netlify', | ||
'@remix-run/netlify-edge', | ||
] | ||
configFiles = ['remix.config.js'] | ||
excludedConfigFiles = [ | ||
'vite.config.js', | ||
'vite.config.mjs', | ||
'vite.config.cjs', | ||
'vite.config.ts', | ||
'vite.config.mts', | ||
'vite.config.cts', | ||
] | ||
category = Category.SSG | ||
|
||
dev = { | ||
command: 'remix watch', | ||
} | ||
|
||
build = { | ||
command: 'remix build', | ||
directory: 'public', | ||
} | ||
|
||
logo = { | ||
default: '/logos/remix/default.svg', | ||
light: '/logos/remix/light.svg', | ||
dark: '/logos/remix/dark.svg', | ||
} | ||
} |
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,84 @@ | ||
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 Remix Vite site with origin SSR as remix', async ({ fs }) => { | ||
const cwd = mockFileSystem({ | ||
'vite.config.js': '', | ||
'package.json': JSON.stringify({ | ||
scripts: { | ||
build: 'remix vite:build', | ||
dev: 'remix vite:dev', | ||
start: 'remix-serve ./build/server/index.js', | ||
}, | ||
dependencies: { | ||
'@remix-run/node': '^2.9.2', | ||
'@remix-run/react': '^2.9.2', | ||
'@remix-run/serve': '^2.9.2', | ||
react: '^18.2.0', | ||
'react-dom': '^18.2.0', | ||
}, | ||
devDependencies: { | ||
'@netlify/remix-adapter': '^2.4.0', | ||
'@remix-run/dev': '^2.9.2', | ||
'@types/react': '^18.2.20', | ||
'@types/react-dom': '^18.2.7', | ||
vite: '^5.0.0', | ||
'vite-tsconfig-paths': '^4.2.1', | ||
}, | ||
}), | ||
}) | ||
const detected = await new Project(fs, cwd).detectFrameworks() | ||
expect(detected?.[0].id).toBe('remix') | ||
expect(detected?.[0].build.command).toBe('remix vite:build') | ||
expect(detected?.[0].build.directory).toBe('dist') | ||
expect(detected?.[0].dev?.command).toBe('remix vite:dev') | ||
|
||
const detectedFrameworks = (detected ?? []).map((framework) => framework.id) | ||
expect(detectedFrameworks).not.toContain('remix-classic') | ||
expect(detectedFrameworks).not.toContain('vite') | ||
}) | ||
|
||
test('detects a Remix Vite site with edge SSR as remix', async ({ fs }) => { | ||
const cwd = mockFileSystem({ | ||
'vite.config.js': '', | ||
'package.json': JSON.stringify({ | ||
scripts: { | ||
build: 'remix vite:build', | ||
dev: 'remix vite:dev', | ||
start: 'remix-serve ./build/server/index.js', | ||
}, | ||
dependencies: { | ||
'@netlify/remix-runtime': '^2.3.0', | ||
'@remix-run/node': '^2.9.2', | ||
'@remix-run/react': '^2.9.2', | ||
'@remix-run/serve': '^2.9.2', | ||
react: '^18.2.0', | ||
'react-dom': '^18.2.0', | ||
}, | ||
devDependencies: { | ||
'@netlify/remix-edge-adapter': '^3.3.0', | ||
'@remix-run/dev': '^2.9.2', | ||
'@types/react': '^18.2.20', | ||
'@types/react-dom': '^18.2.7', | ||
vite: '^5.0.0', | ||
'vite-tsconfig-paths': '^4.2.1', | ||
}, | ||
}), | ||
}) | ||
const detected = await new Project(fs, cwd).detectFrameworks() | ||
expect(detected?.[0].id).toBe('remix') | ||
expect(detected?.[0].build.command).toBe('remix vite:build') | ||
expect(detected?.[0].build.directory).toBe('dist') | ||
expect(detected?.[0].dev?.command).toBe('remix vite:dev') | ||
|
||
const detectedFrameworks = (detected ?? []).map((framework) => framework.id) | ||
expect(detectedFrameworks).not.toContain('remix-classic') | ||
expect(detectedFrameworks).not.toContain('vite') | ||
}) |
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
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