Skip to content

Commit 7100451

Browse files
committed
Fix npm build
1 parent 6a05971 commit 7100451

File tree

2 files changed

+48
-20
lines changed

2 files changed

+48
-20
lines changed

MyApp.Client/src/pages/weather.tsx

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import LayoutPage from "@/components/LayoutPage"
33
import SrcPage from "@/components/SrcPage"
44
import { useClient } from "@/gateway"
55
import { GetWeatherForecast, Forecast } from "@/dtos"
6-
import { columnDefs, DataTable, getCoreRowModel } from "@/components/DataTable.tsx"
6+
import { columnDefs, DataTable, getCoreRowModel } from "@/components/DataTable"
7+
import { CellContext } from "@tanstack/react-table"
78

89
export default (): JSX.Element => {
910
const client = useClient()
@@ -18,17 +19,30 @@ export default (): JSX.Element => {
1819
})()
1920
}, [])
2021

21-
const columns = columnDefs(['date', 'temperatureC', 'temperatureF', 'summary'],
22-
({ temperatureC, temperatureF}) => {
22+
const columns = columnDefs<Forecast>(['date', 'temperatureC', 'temperatureF', 'summary'],
23+
({ temperatureC, temperatureF }) => {
2324
temperatureC.header = "Temp. (C)"
2425
temperatureF.header = "Temp. (F)"
25-
temperatureC.cell = temperatureF.cell = ({ getValue }) => <>{getValue()}&deg;</>
26+
27+
// Properly type the cell renderer function
28+
const tempCellRenderer = ({ getValue }: CellContext<Forecast, number>) => (
29+
<>{getValue()}&deg;</>
30+
)
31+
32+
temperatureC.cell = tempCellRenderer
33+
temperatureF.cell = tempCellRenderer
2634
})
2735

28-
return (<LayoutPage title="Weather">
29-
<DataTable columns={columns} data={forecasts} getCoreRowModel={getCoreRowModel()} />
30-
<div className="mt-8 flex justify-center gap-x-4">
31-
<SrcPage path="weather.tsx" />
32-
</div>
33-
</LayoutPage>)
34-
}
36+
return (
37+
<LayoutPage title="Weather">
38+
<DataTable
39+
columns={columns}
40+
data={forecasts}
41+
getCoreRowModel={getCoreRowModel()}
42+
/>
43+
<div className="mt-8 flex justify-center gap-x-4">
44+
<SrcPage path="weather.tsx" />
45+
</div>
46+
</LayoutPage>
47+
)
48+
}

MyApp.Client/vite.config.ts

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,30 @@ if (!certificateName) {
3535
const certFilePath = path.join(baseFolder, `${certificateName}.pem`);
3636
const keyFilePath = path.join(baseFolder, `${certificateName}.key`);
3737

38+
console.log(`Certificate path: ${certFilePath}`);
39+
3840
if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) {
39-
if (0 !== child_process.spawnSync('dotnet', [
40-
'dev-certs',
41-
'https',
42-
'--export-path',
43-
certFilePath,
44-
'--format',
45-
'Pem',
46-
'--no-password',
47-
], { stdio: 'inherit', }).status) {
41+
42+
// mkdir to fix dotnet dev-certs error 3 https://github.com/dotnet/aspnetcore/issues/58330
43+
if (!fs.existsSync(baseFolder)) {
44+
fs.mkdirSync(baseFolder, { recursive: true });
45+
}
46+
if (
47+
0 !==
48+
child_process.spawnSync(
49+
"dotnet",
50+
[
51+
"dev-certs",
52+
"https",
53+
"--export-path",
54+
certFilePath,
55+
"--format",
56+
"Pem",
57+
"--no-password",
58+
],
59+
{ stdio: "inherit" }
60+
).status
61+
) {
4862
throw new Error("Could not create certificate.");
4963
}
5064
}

0 commit comments

Comments
 (0)