From 7100451b1e38553f60de8e580d1d38a30c25be23 Mon Sep 17 00:00:00 2001 From: Darren Reid Date: Tue, 26 Nov 2024 18:04:37 +1100 Subject: [PATCH] Fix npm build --- MyApp.Client/src/pages/weather.tsx | 36 +++++++++++++++++++++--------- MyApp.Client/vite.config.ts | 32 ++++++++++++++++++-------- 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/MyApp.Client/src/pages/weather.tsx b/MyApp.Client/src/pages/weather.tsx index 4dccc5d..128aba4 100644 --- a/MyApp.Client/src/pages/weather.tsx +++ b/MyApp.Client/src/pages/weather.tsx @@ -3,7 +3,8 @@ import LayoutPage from "@/components/LayoutPage" import SrcPage from "@/components/SrcPage" import { useClient } from "@/gateway" import { GetWeatherForecast, Forecast } from "@/dtos" -import { columnDefs, DataTable, getCoreRowModel } from "@/components/DataTable.tsx" +import { columnDefs, DataTable, getCoreRowModel } from "@/components/DataTable" +import { CellContext } from "@tanstack/react-table" export default (): JSX.Element => { const client = useClient() @@ -18,17 +19,30 @@ export default (): JSX.Element => { })() }, []) - const columns = columnDefs(['date', 'temperatureC', 'temperatureF', 'summary'], - ({ temperatureC, temperatureF}) => { + const columns = columnDefs(['date', 'temperatureC', 'temperatureF', 'summary'], + ({ temperatureC, temperatureF }) => { temperatureC.header = "Temp. (C)" temperatureF.header = "Temp. (F)" - temperatureC.cell = temperatureF.cell = ({ getValue }) => <>{getValue()}° + + // Properly type the cell renderer function + const tempCellRenderer = ({ getValue }: CellContext) => ( + <>{getValue()}° + ) + + temperatureC.cell = tempCellRenderer + temperatureF.cell = tempCellRenderer }) - return ( - -
- -
-
) -} + return ( + + +
+ +
+
+ ) +} \ No newline at end of file diff --git a/MyApp.Client/vite.config.ts b/MyApp.Client/vite.config.ts index e34cb5c..e4b4f95 100644 --- a/MyApp.Client/vite.config.ts +++ b/MyApp.Client/vite.config.ts @@ -35,16 +35,30 @@ if (!certificateName) { const certFilePath = path.join(baseFolder, `${certificateName}.pem`); const keyFilePath = path.join(baseFolder, `${certificateName}.key`); +console.log(`Certificate path: ${certFilePath}`); + if (!fs.existsSync(certFilePath) || !fs.existsSync(keyFilePath)) { - if (0 !== child_process.spawnSync('dotnet', [ - 'dev-certs', - 'https', - '--export-path', - certFilePath, - '--format', - 'Pem', - '--no-password', - ], { stdio: 'inherit', }).status) { + + // mkdir to fix dotnet dev-certs error 3 https://github.com/dotnet/aspnetcore/issues/58330 + if (!fs.existsSync(baseFolder)) { + fs.mkdirSync(baseFolder, { recursive: true }); + } + if ( + 0 !== + child_process.spawnSync( + "dotnet", + [ + "dev-certs", + "https", + "--export-path", + certFilePath, + "--format", + "Pem", + "--no-password", + ], + { stdio: "inherit" } + ).status + ) { throw new Error("Could not create certificate."); } }