Skip to content

Commit

Permalink
fix: honor forced remix and hydrogen framework and allow detecting wh…
Browse files Browse the repository at this point in the history
…en config file is missing
  • Loading branch information
pieh committed Sep 19, 2024
1 parent f53b7a5 commit 1706dca
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 34 deletions.
2 changes: 1 addition & 1 deletion packages/build-info/src/frameworks/hydrogen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class Hydrogen extends BaseFramework implements Framework {
this.dev = VITE_DEV
this.build = VITE_BUILD
return this as DetectedFramework
} else if (CLASSIC_COMPILER_CONFIG_FILES.includes(this.detected.configName)) {
} else {
this.dev = CLASSIC_COMPILER_DEV
this.build = CLASSIC_COMPILER_BUILD
return this as DetectedFramework
Expand Down
54 changes: 22 additions & 32 deletions packages/build-info/src/frameworks/remix.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,28 @@ beforeEach((ctx) => {
}),
},
] as const,
[
'with no config file',
{
'package.json': JSON.stringify({
scripts: {
build: 'remix build',
dev: 'remix dev',
start: 'netlify serve',
typecheck: 'tsc',
},
dependencies: {
'@remix-run/netlify-edge': '1.7.4',
remix: '1.7.4',
react: '18.2.0',
'react-dom': '18.2.0',
},
devDependencies: {
'@netlify/functions': '^1.0.0',
},
}),
},
] as const,
].forEach(([description, files]) =>
test(`detects a Remix Classic Compiler site ${description}`, async ({ fs }) => {
const cwd = mockFileSystem(files)
Expand All @@ -249,35 +271,3 @@ beforeEach((ctx) => {
expect(detected?.[0]?.dev?.port).toBeUndefined()
}),
)

test('does not detect an invalid Remix site with no config file', async ({ fs }) => {
const cwd = mockFileSystem({
'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()

const detectedFrameworks = (detected ?? []).map((framework) => framework.id)
expect(detectedFrameworks).not.toContain('remix')
})
2 changes: 1 addition & 1 deletion packages/build-info/src/frameworks/remix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class Remix extends BaseFramework implements Framework {
this.dev = VITE_DEV
this.build = VITE_BUILD
return this as DetectedFramework
} else if (CLASSIC_COMPILER_CONFIG_FILES.includes(this.detected.configName)) {
} else {
this.dev = CLASSIC_COMPILER_DEV
this.build = CLASSIC_COMPILER_BUILD
return this as DetectedFramework
Expand Down

0 comments on commit 1706dca

Please sign in to comment.