Skip to content

Commit 2002b42

Browse files
orinokaiserhalp
andauthored
fix: framework detection for solidjs and solidstart (#5856)
* fix: framework detection for solidjs and solidstart * feat: add dark logo * feat: ensure vite doesn't match for solid start * fix(build-info): reintroduce support for old SolidStart sites also: - add Solid.js and SolidStart detection tests - make the filename for Solid.js match the framework id like all the others - avoid bug elsewhere with using just `vite` as a dev command (I should really write up that bug... sorry) --------- Co-authored-by: Philippe Serhal <[email protected]>
1 parent 071380e commit 2002b42

File tree

7 files changed

+163
-14
lines changed

7 files changed

+163
-14
lines changed
Lines changed: 1 addition & 0 deletions
Loading

packages/build-info/src/frameworks/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ import { RedwoodJS } from './redwoodjs.js'
3434
import { Remix } from './remix.js'
3535
import { Roots } from './roots.js'
3636
import { Sapper } from './sapper.js'
37+
import { SolidJs } from './solid-js.js'
3738
import { SolidStart } from './solid-start.js'
38-
import { Solid } from './solid.js'
3939
import { Stencil } from './stencil.js'
4040
import { SvelteKit } from './svelte-kit.js'
4141
import { Svelte } from './svelte.js'
@@ -68,7 +68,7 @@ export const frameworks = [
6868
ReactStatic,
6969
RedwoodJS,
7070
Remix,
71-
Solid,
71+
SolidJs,
7272
SolidStart,
7373
Stencil,
7474
TanStackRouter,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { beforeEach, expect, test } from 'vitest'
2+
3+
import { mockFileSystem } from '../../tests/mock-file-system.js'
4+
import { NodeFS } from '../node/file-system.js'
5+
import { Project } from '../project.js'
6+
7+
beforeEach((ctx) => {
8+
ctx.fs = new NodeFS()
9+
})
10+
11+
test('detects a Solid.js site', async ({ fs }) => {
12+
const cwd = mockFileSystem({
13+
'package.json': JSON.stringify({
14+
scripts: {
15+
start: 'vite',
16+
dev: 'vite',
17+
build: 'vite build',
18+
serve: 'vite preview',
19+
},
20+
dependencies: {
21+
'solid-js': '^1.8.11',
22+
},
23+
devDependencies: {
24+
'solid-devtools': '^0.29.2',
25+
vite: '^5.0.11',
26+
'vite-plugin-solid': '^2.8.2',
27+
},
28+
}),
29+
})
30+
const detected = await new Project(fs, cwd).detectFrameworks()
31+
32+
const detectedFrameworks = (detected ?? []).map((framework) => framework.id)
33+
expect(detectedFrameworks).not.toContain('vinxi')
34+
expect(detectedFrameworks).not.toContain('vite')
35+
expect(detectedFrameworks).not.toContain('solid-start')
36+
37+
expect(detected?.[0]?.id).toBe('solid-js')
38+
expect(detected?.[0]?.build?.command).toBe('vite build')
39+
expect(detected?.[0]?.build?.directory).toBe('dist')
40+
expect(detected?.[0]?.dev?.command).toBe('vite dev')
41+
expect(detected?.[0]?.dev?.port).toBe(3000)
42+
})

packages/build-info/src/frameworks/solid.ts renamed to packages/build-info/src/frameworks/solid-js.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import { BaseFramework, Category, Framework } from './framework.js'
22

3-
export class Solid extends BaseFramework implements Framework {
3+
export class SolidJs extends BaseFramework implements Framework {
44
readonly id = 'solid-js'
55
name = 'SolidJS'
66
npmDependencies = ['solid-js']
7-
excludedNpmDependencies = ['solid-start']
7+
excludedNpmDependencies = ['solid-start', '@solidjs/start']
88
category = Category.SSG
99

1010
dev = {
11-
command: 'npm run dev',
11+
command: 'vite dev',
1212
port: 3000,
1313
pollingStrategies: [{ name: 'TCP' }],
1414
}
1515

1616
build = {
17-
command: 'npm run build',
18-
directory: 'netlify',
17+
command: 'vite build',
18+
directory: 'dist',
1919
}
2020

2121
logo = {
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import { beforeEach, expect, test } from 'vitest'
2+
3+
import { mockFileSystem } from '../../tests/mock-file-system.js'
4+
import { NodeFS } from '../node/file-system.js'
5+
import { Project } from '../project.js'
6+
7+
beforeEach((ctx) => {
8+
ctx.fs = new NodeFS()
9+
})
10+
11+
test('detects and configures a SolidStart site that uses the old `solid-start` package', async ({ fs }) => {
12+
const cwd = mockFileSystem({
13+
'package.json': JSON.stringify({
14+
scripts: {
15+
dev: 'solid-start dev',
16+
build: 'solid-start build',
17+
start: 'solid-start start',
18+
},
19+
dependencies: {
20+
'@solidjs/meta': '^0.28.5',
21+
'@solidjs/router': '^0.8.2',
22+
'solid-js': '^1.7.8',
23+
'solid-start': '^0.2.26',
24+
},
25+
devDependencies: {
26+
'solid-start-netlify': '^0.2.26',
27+
'solid-start-node': '^0.2.26',
28+
vite: '3.2.5',
29+
},
30+
}),
31+
})
32+
const detected = await new Project(fs, cwd).detectFrameworks()
33+
34+
const detectedFrameworks = (detected ?? []).map((framework) => framework.id)
35+
expect(detectedFrameworks).not.toContain('vinxi')
36+
expect(detectedFrameworks).not.toContain('vite')
37+
expect(detectedFrameworks).not.toContain('solidjs')
38+
39+
expect(detected?.[0]?.id).toBe('solid-start')
40+
expect(detected?.[0]?.build?.command).toBe('solid-start build')
41+
expect(detected?.[0]?.build?.directory).toBe('netlify')
42+
expect(detected?.[0]?.dev?.command).toBe('solid-start dev')
43+
expect(detected?.[0]?.dev?.port).toBe(3000)
44+
})
45+
46+
test('detects and configures a SolidStart site that uses the new `@solidjs/start` package', async ({ fs }) => {
47+
const cwd = mockFileSystem({
48+
'package.json': JSON.stringify({
49+
scripts: {
50+
dev: 'vinxi dev',
51+
build: 'vinxi build',
52+
start: 'vinxi start',
53+
},
54+
dependencies: {
55+
'@solidjs/router': '^0.14.1',
56+
'@solidjs/start': '^1.0.6',
57+
'solid-js': '^1.8.18',
58+
},
59+
devDependencies: {
60+
vinxi: '^0.4.1',
61+
},
62+
}),
63+
})
64+
const detected = await new Project(fs, cwd).detectFrameworks()
65+
66+
const detectedFrameworks = (detected ?? []).map((framework) => framework.id)
67+
expect(detectedFrameworks).not.toContain('vinxi')
68+
expect(detectedFrameworks).not.toContain('vite')
69+
expect(detectedFrameworks).not.toContain('solidjs')
70+
71+
expect(detected?.[0]?.id).toBe('solid-start')
72+
expect(detected?.[0]?.build?.command).toBe('vinxi build')
73+
expect(detected?.[0]?.build?.directory).toBe('dist')
74+
expect(detected?.[0]?.dev?.command).toBe('vinxi dev')
75+
expect(detected?.[0]?.dev?.port).toBe(3000)
76+
})
Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,52 @@
1-
import { BaseFramework, Category, Framework } from './framework.js'
1+
import { BaseFramework, Category, type DetectedFramework, type Framework } from './framework.js'
2+
3+
const LEGACY_PACKAGE_NAME = 'solid-start'
4+
const LEGACY_DEV = {
5+
command: 'solid-start dev',
6+
port: 3000,
7+
}
8+
const LEGACY_BUILD = {
9+
command: 'solid-start build',
10+
directory: 'netlify',
11+
}
212

313
export class SolidStart extends BaseFramework implements Framework {
414
readonly id = 'solid-start'
515
name = 'Solid Start'
6-
npmDependencies = ['solid-start']
16+
npmDependencies = [
17+
// Used this name up to 0.3.11
18+
'solid-start',
19+
// Renamed starting at 0.4.0
20+
'@solidjs/start',
21+
]
722
category = Category.SSG
823

924
dev = {
10-
command: 'solid-start dev',
25+
command: 'vinxi dev',
1126
port: 3000,
12-
pollingStrategies: [{ name: 'TCP' }],
1327
}
1428

1529
build = {
16-
command: 'solid-start build',
17-
directory: 'netlify',
30+
command: 'vinxi build',
31+
directory: 'dist',
1832
}
1933

2034
logo = {
2135
default: '/logos/solid-start/default.svg',
2236
light: '/logos/solid-start/default.svg',
23-
dark: '/logos/solid-start/default.svg',
37+
dark: '/logos/solid-start/dark.svg',
38+
}
39+
40+
async detect(): Promise<DetectedFramework | undefined> {
41+
await super.detect()
42+
43+
if (this.detected) {
44+
if (this.detected.package?.name === LEGACY_PACKAGE_NAME) {
45+
this.dev = LEGACY_DEV
46+
this.build = LEGACY_BUILD
47+
return this as DetectedFramework
48+
}
49+
return this as DetectedFramework
50+
}
2451
}
2552
}

packages/build-info/src/frameworks/vite.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ export class Vite extends BaseFramework implements Framework {
1010
'@remix-run/server-runtime',
1111
'@shopify/hydrogen',
1212
'@builder.io/qwik',
13+
// Used this name up to 0.3.11
1314
'solid-start',
15+
// Renamed starting at 0.4.0
16+
'@solidjs/start',
1417
'solid-js',
1518
'@tanstack/react-router',
1619
'@tanstack/start',

0 commit comments

Comments
 (0)