diff --git a/docs/package.json b/docs/package.json index 67a9120e45f..09a2313c5b4 100644 --- a/docs/package.json +++ b/docs/package.json @@ -32,7 +32,7 @@ "@mui/joy": "5.0.0-beta.32", "@mui/lab": "5.0.0-alpha.170", "@mui/material": "5.15.15", - "@mui/material-nextjs": "^5.15.11", + "@mui/material-nextjs": "5.15.11", "@mui/styles": "5.15.15", "@mui/utils": "5.15.14", "@mui/x-license": "7.2.0", diff --git a/packages/toolpad-studio/package.json b/packages/toolpad-studio/package.json index aa512f48510..f9c7316e5f5 100644 --- a/packages/toolpad-studio/package.json +++ b/packages/toolpad-studio/package.json @@ -12,10 +12,7 @@ "lint": "prettier --check .", "fix": "prettier --write .", "build:cli": "tsup", - "build:typings": "tsx ./scripts/typings.mts", "dev:cli": "tsup --watch", - "dev:typings": "pnpm build:typings", - "waitForApp": "tsx ./scripts/waitForApp.mts", "check-types": "tsup && tsc --noEmit", "test": "vitest run" }, @@ -71,7 +68,6 @@ "@vitejs/plugin-react": "4.2.1", "@webcontainer/env": "1.1.1", "abort-controller": "3.0.0", - "arg": "5.0.2", "basic-auth": "2.0.1", "chalk": "5.3.0", "chokidar": "3.6.0", diff --git a/packages/toolpad-studio/scripts/tsconfig.json b/packages/toolpad-studio/scripts/tsconfig.json deleted file mode 100644 index 6a37db8c636..00000000000 --- a/packages/toolpad-studio/scripts/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "module": "ES2022", - "esModuleInterop": true - } -} diff --git a/packages/toolpad-studio/scripts/typings.mts b/packages/toolpad-studio/scripts/typings.mts deleted file mode 100644 index e54054d8b22..00000000000 --- a/packages/toolpad-studio/scripts/typings.mts +++ /dev/null @@ -1,111 +0,0 @@ -import * as fs from 'fs/promises'; -import * as path from 'path'; -import * as url from 'node:url'; -import { createRequire } from 'module'; -import { glob } from 'glob'; - -const require = createRequire(import.meta.url); - -const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url)); - -const LIBS = [ - { name: 'react' }, - { name: 'react-dom' }, - { name: '@mui/material' }, - { name: '@toolpad/studio-runtime' }, - { name: '@mui/x-date-pickers' }, - { name: '@mui/x-date-pickers-pro' }, - { name: '@mui/x-data-grid' }, - { name: '@mui/x-data-grid-premium' }, - { name: 'dayjs' }, - // TODO: we need to analyze imports of the definition files and include those libs automatically - { name: 'csstype' }, - { name: 'react-transition-group' }, - { name: '@mui/base' }, - { name: '@mui/types' }, - { name: '@mui/system' }, - { name: '@mui/utils' }, -]; - -function getModuleId(fileName: string, pkgDir: string, pkgName: string) { - return path.join(`node_modules/${pkgName}/`, path.relative(pkgDir, fileName)); -} - -async function main() { - const allFiles: { filename: string; moduleId: string }[] = ( - await Promise.all( - LIBS.map(async ({ name }) => { - const files: { filename: string; moduleId: string }[] = []; - const resolvedPkg = require.resolve(`${name}/package.json`); - const pkgJson = JSON.parse(await fs.readFile(resolvedPkg, { encoding: 'utf-8' })); - const pkgDir = path.dirname(resolvedPkg); - - const dtsFiles = await glob('**/*.d.ts', { - cwd: pkgDir, - absolute: true, - }); - - if (dtsFiles.length > 0) { - files.push( - { filename: resolvedPkg, moduleId: getModuleId(resolvedPkg, pkgDir, pkgJson.name) }, - ...dtsFiles.map((fileName) => ({ - filename: fileName, - // hack around monorepo packages - moduleId: getModuleId(fileName, pkgDir, pkgJson.name), - })), - ); - } - - try { - let typesLib = name; - if (name.startsWith('@')) { - const [part1, part2] = name.slice(1).split('/'); - typesLib = `${part1}__${part2}`; - } - const resolvedTypesPkg = require.resolve(`@types/${typesLib}/package.json`); - const typesDtsFiles = await glob('**/*.d.ts', { - cwd: path.dirname(resolvedTypesPkg), - absolute: true, - }); - if (typesDtsFiles.length > 0) { - files.push( - { - filename: resolvedPkg, - moduleId: getModuleId(resolvedTypesPkg, pkgDir, pkgJson.name), - }, - ...typesDtsFiles.map((fileName) => ({ - filename: fileName, - // hack around monorepo packages - moduleId: getModuleId(fileName, pkgDir, pkgJson.name), - })), - ); - } - // eslint-disable-next-line no-empty - } catch (err) {} - - return files; - }), - ) - ).flat(); - - const results = await Promise.all( - allFiles.map(async ({ filename, moduleId }) => { - return { [moduleId]: await fs.readFile(filename, { encoding: 'utf-8' }) }; - }), - ); - - const result: Record = Object.assign({}, ...results); - - await fs.writeFile( - path.resolve(currentDirectory, '../public/typings.json'), - JSON.stringify(result), - { - encoding: 'utf-8', - }, - ); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/packages/toolpad-studio/scripts/waitForApp.mts b/packages/toolpad-studio/scripts/waitForApp.mts deleted file mode 100644 index f9c636d1ea5..00000000000 --- a/packages/toolpad-studio/scripts/waitForApp.mts +++ /dev/null @@ -1,44 +0,0 @@ -import arg from 'arg'; - -const DEFAULT_URL = 'http://localhost:3000/'; - -const args = arg({ - '--url': String, -}); - -const INTERVAL = 1000; -const MAX_RETRIES = 30; - -const HEALTH_CHECK_URL = `/health-check`; - -async function main() { - const checkedUrl = new URL(HEALTH_CHECK_URL, args['--url'] || DEFAULT_URL); - for (let i = 1; i <= MAX_RETRIES; i += 1) { - try { - // eslint-disable-next-line no-console - console.log(`(${i}/${MAX_RETRIES}) trying reach "${checkedUrl.href}"...`); - // eslint-disable-next-line no-await-in-loop - const res = await fetch(checkedUrl.href); - - if (!res.ok) { - throw new Error(`HTTP ${res.status}`); - } - - // eslint-disable-next-line no-console - console.log(`connected!`); - return; - } catch (err: any) { - console.error(` > ${err.message}`); - // eslint-disable-next-line no-await-in-loop - await new Promise((resolve) => { - setTimeout(resolve, INTERVAL); - }); - } - } - throw new Error(`Failed to connect`); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/packages/toolpad-studio/scripts/waitForDb.mts b/packages/toolpad-studio/scripts/waitForDb.mts deleted file mode 100644 index 6bd45739ffb..00000000000 --- a/packages/toolpad-studio/scripts/waitForDb.mts +++ /dev/null @@ -1,45 +0,0 @@ -import { createRequire } from 'module'; - -const require = createRequire(import.meta.url); - -const { PrismaClient } = require('../prisma/generated/client'); - -const INTERVAL = 1000; -const MAX_RETRIES = 30; - -if (!process.env.TOOLPAD_DATABASE_URL) { - throw new Error(`App started without config env variable TOOLPAD_DATABASE_URL`); -} - -const prisma = new PrismaClient(); - -async function main() { - for (let i = 1; i <= MAX_RETRIES; i += 1) { - try { - // eslint-disable-next-line no-console - console.log( - `(${i}/${MAX_RETRIES}) trying to connect db "${process.env.TOOLPAD_DATABASE_URL}"...`, - ); - // eslint-disable-next-line no-await-in-loop - await prisma.$connect(); - // eslint-disable-next-line no-console - console.log(`connected!`); - return; - } catch (err: any) { - if (err.errorCode === 'P1001') { - // eslint-disable-next-line no-await-in-loop - await new Promise((resolve) => { - setTimeout(resolve, INTERVAL); - }); - } else { - throw err; - } - } - } - throw new Error(`Failed to connect`); -} - -main().catch((err) => { - console.error(err); - process.exit(1); -}); diff --git a/packages/toolpad-studio/src/toolpadDataSources/local/client.tsx b/packages/toolpad-studio/src/toolpadDataSources/local/client.tsx index 49d37b03f22..9f729ba946e 100644 --- a/packages/toolpad-studio/src/toolpadDataSources/local/client.tsx +++ b/packages/toolpad-studio/src/toolpadDataSources/local/client.tsx @@ -6,9 +6,8 @@ import PlayArrowIcon from '@mui/icons-material/PlayArrow'; import { TabContext, TabList } from '@mui/lab'; import { useBrowserJsRuntime } from '@toolpad/studio-runtime/jsBrowserRuntime'; import { errorFrom } from '@toolpad/utils/errors'; - import { useQuery } from '@tanstack/react-query'; -import Grid2 from '@mui/material/Unstable_Grid2/Grid2'; +import Grid2 from '@mui/material/Unstable_Grid2'; import TabPanel from '../../components/TabPanel'; import { ClientDataSource, QueryEditorProps } from '../../types'; import { LocalPrivateApi, LocalQuery, LocalConnectionParams } from './types'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 12122328aec..879cd8cb44b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -232,7 +232,7 @@ importers: specifier: 5.15.15 version: 5.15.15(@emotion/react@11.11.4)(@emotion/styled@11.11.5)(react-dom@18.2.0)(react@18.2.0) '@mui/material-nextjs': - specifier: ^5.15.11 + specifier: 5.15.11 version: 5.15.11(@emotion/cache@11.11.0)(@emotion/server@11.11.0)(@mui/material@5.15.15)(next@14.2.1)(react@18.2.0) '@mui/styles': specifier: 5.15.15 @@ -619,9 +619,6 @@ importers: abort-controller: specifier: 3.0.0 version: 3.0.0 - arg: - specifier: 5.0.2 - version: 5.0.2 basic-auth: specifier: 2.0.1 version: 2.0.1 @@ -5281,10 +5278,6 @@ packages: resolution: {integrity: sha512-Wk7TEzl1KqvTGs/uyhmHO/3XLd3t1UeU4IstvPXVzGPM522cTjqjNZ99esCkcL52sjqjo8e8CTBcWhkxvGzoAw==} dev: false - /arg@5.0.2: - resolution: {integrity: sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==} - dev: false - /argparse@1.0.10: resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} dependencies: