diff --git a/docs/package.json b/docs/package.json index 2a30afbcb10..71b8b03f2c6 100644 --- a/docs/package.json +++ b/docs/package.json @@ -31,7 +31,7 @@ "@mui/lab": "5.0.0-alpha.166", "@mui/material": "5.15.11", "@mui/material-nextjs": "^5.15.11", - "@mui/monorepo": "github:mui/material-ui#7faab118953050eec27e119a53070d2994b70476", + "@mui/monorepo": "github:mui/material-ui#8bdcff4a75e0e77137bc3df44560413f2c4241a7", "@mui/styles": "5.15.11", "@mui/toolpad": "workspace:*", "@mui/utils": "5.15.11", diff --git a/docs/pages/_app.js b/docs/pages/_app.js index a0f88ed8d75..46a66937da9 100644 --- a/docs/pages/_app.js +++ b/docs/pages/_app.js @@ -18,6 +18,7 @@ import findActivePage from 'docs/src/modules/utils/findActivePage'; import getProductInfoFromUrl from 'docs/src/modules/utils/getProductInfoFromUrl'; import toolpadPkgJson from '@mui/toolpad/package.json'; import { DocsProvider } from '@mui/docs/DocsProvider'; +import { mapTranslations } from '@mui/docs/i18n'; import pages from '../data/pages'; import config from '../config'; @@ -175,7 +176,11 @@ function AppWrapper(props) { - + @@ -218,6 +223,9 @@ MyApp.propTypes = { MyApp.getInitialProps = async ({ ctx, Component }) => { let pageProps = {}; + const req = require.context('../translations', false, /translations.*\.json$/); + const translations = mapTranslations(req); + if (Component.getInitialProps) { pageProps = await Component.getInitialProps(ctx); } @@ -225,6 +233,7 @@ MyApp.getInitialProps = async ({ ctx, Component }) => { return { pageProps: { userLanguage: ctx.query.userLanguage || 'en', + translations, ...pageProps, }, }; diff --git a/package.json b/package.json index badf010ef1b..1f894352435 100644 --- a/package.json +++ b/package.json @@ -33,12 +33,14 @@ "toolpad": "node --enable-source-maps packages/toolpad-app/cli.mjs", "jsonSchemas": "tsx ./scripts/docs/generateJsonSchemas.ts", "update-monorepo": "tsx ./scripts/updateMonorepo.ts", + "monorepo:update": "tsx ./scripts/updateMonorepo.ts", + "monorepo:canary": "tsx ./scripts/canaryMonorepo.ts", "check-changes": "git add -A && git diff --exit-code --staged", "test:rest:start": "tsx ./scripts/restTestServer.ts" }, "devDependencies": { "@argos-ci/core": "1.5.4", - "@mui/monorepo": "github:mui/material-ui#7faab118953050eec27e119a53070d2994b70476", + "@mui/monorepo": "github:mui/material-ui#8bdcff4a75e0e77137bc3df44560413f2c4241a7", "@mui/x-charts": "6.19.5", "@next/eslint-plugin-next": "14.1.0", "@playwright/test": "1.41.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e859d58fc8f..4887edb66ba 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -55,8 +55,8 @@ importers: specifier: 1.5.4 version: 1.5.4 '@mui/monorepo': - specifier: github:mui/material-ui#7faab118953050eec27e119a53070d2994b70476 - version: github.com/mui/material-ui/7faab118953050eec27e119a53070d2994b70476 + specifier: github:mui/material-ui#8bdcff4a75e0e77137bc3df44560413f2c4241a7 + version: github.com/mui/material-ui/8bdcff4a75e0e77137bc3df44560413f2c4241a7 '@mui/x-charts': specifier: 6.19.5 version: 6.19.5(@mui/material@5.15.11)(@mui/system@5.15.11)(react-dom@18.2.0)(react@18.2.0) @@ -226,8 +226,8 @@ importers: specifier: ^5.15.11 version: 5.15.11(@emotion/cache@11.11.0)(@emotion/server@11.11.0)(@mui/material@5.15.11)(next@13.5.6)(react@18.2.0) '@mui/monorepo': - specifier: github:mui/material-ui#7faab118953050eec27e119a53070d2994b70476 - version: github.com/mui/material-ui/7faab118953050eec27e119a53070d2994b70476 + specifier: github:mui/material-ui#8bdcff4a75e0e77137bc3df44560413f2c4241a7 + version: github.com/mui/material-ui/8bdcff4a75e0e77137bc3df44560413f2c4241a7 '@mui/styles': specifier: 5.15.11 version: 5.15.11(react@18.2.0) @@ -15384,8 +15384,8 @@ packages: resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} dev: false - github.com/mui/material-ui/7faab118953050eec27e119a53070d2994b70476: - resolution: {tarball: https://codeload.github.com/mui/material-ui/tar.gz/7faab118953050eec27e119a53070d2994b70476} + github.com/mui/material-ui/8bdcff4a75e0e77137bc3df44560413f2c4241a7: + resolution: {tarball: https://codeload.github.com/mui/material-ui/tar.gz/8bdcff4a75e0e77137bc3df44560413f2c4241a7} name: '@mui/monorepo' version: 5.15.11 requiresBuild: true diff --git a/scripts/canaryMonorepo.ts b/scripts/canaryMonorepo.ts new file mode 100644 index 00000000000..3c947be102b --- /dev/null +++ b/scripts/canaryMonorepo.ts @@ -0,0 +1,26 @@ +import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; +import { dedupe, updateToBranch } from './gitUtils'; + +async function main(argv) { + await updateToBranch('@mui/monorepo', 'mui/material-ui', `refs/pull/${argv.pr}/head`); + await dedupe(); +} + +yargs(hideBin(process.argv)) + .command({ + command: '$0', + description: 'transpile TypeScript demos', + builder: (command) => { + return command + .option('pr', { + description: 'PR number', + }) + .demandOption('pr'); + }, + handler: main, + }) + .help() + .strict(true) + .version(false) + .parse(); diff --git a/scripts/gitUtils.ts b/scripts/gitUtils.ts new file mode 100644 index 00000000000..7049a2bafbd --- /dev/null +++ b/scripts/gitUtils.ts @@ -0,0 +1,40 @@ +import * as execa from 'execa'; + +const $ = execa.$({ stdio: 'inherit' }); + +export async function updateToBranch(dependency: string, repo: string, branch: string = 'master') { + // eslint-disable-next-line no-console + console.log(`Updating "${repo}" to branch "${branch}"...`); + + await $`pnpm update -r ${dependency}@github:${repo}#${encodeURIComponent(branch)}`; +} + +export async function dedupe() { + // eslint-disable-next-line no-console + console.log(`Deduping...`); + + await $({ stdio: 'inherit' })`pnpm dedupe`; +} + +export async function updateToLatestCommit( + dependency: string, + repo: string, + branch: string = 'master', +) { + const url = new URL(`https://api.github.com/repos/${repo}/commits`); + url.searchParams.set('sha', branch); + url.searchParams.set('per_page', '1'); + const res = await fetch(url); + if (!res.ok) { + throw new Error(`HTTP ${res.status} while fetching "${url}"`); + } + const commits = await res.json(); + + if (commits.length <= 0) { + throw new Error(`No commits found for "${branch}"`); + } + + const latestCommit: string = commits[0].sha; + + await updateToBranch(dependency, repo, latestCommit); +} diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index 4db00598aa6..0fe01577156 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -10,7 +10,7 @@ "../packages/toolpad-utils/src/*.ts" ] }, - "module": "CommonJS", + "module": "ESNext", "noEmit": true, "esModuleInterop": true, "moduleResolution": "node", diff --git a/scripts/updateMonorepo.ts b/scripts/updateMonorepo.ts index c65ad75daa9..de2194b5941 100644 --- a/scripts/updateMonorepo.ts +++ b/scripts/updateMonorepo.ts @@ -1,32 +1,7 @@ -import * as execa from 'execa'; +import { dedupe, updateToLatestCommit } from './gitUtils'; -const $ = execa.$({ stdio: 'inherit' }); - -async function updateGithubDependency(dependency: string, repo: string, branch: string = 'master') { - const url = new URL(`https://api.github.com/repos/${repo}/commits`); - url.searchParams.set('sha', branch); - url.searchParams.set('per_page', '1'); - const res = await fetch(url); - if (!res.ok) { - throw new Error(`HTTP ${res.status} while fetching "${url}"`); - } - const commits = await res.json(); - - if (commits.length <= 0) { - throw new Error(`No commits found for "${branch}"`); - } - - const latestCommit: string = commits[0].sha; - - // eslint-disable-next-line no-console - console.log(`Updating "${repo}" to latest commit ${latestCommit}...`); - - await $`pnpm update -r ${dependency}@github:${repo}#${latestCommit}`; - - // eslint-disable-next-line no-console - console.log(`Deduping...`); - - await $({ stdio: 'inherit' })`pnpm dedupe`; +async function main() { + await updateToLatestCommit('@mui/monorepo', 'mui/material-ui'); + await dedupe(); } - -updateGithubDependency('@mui/monorepo', 'mui/material-ui'); +main();