Skip to content

Commit

Permalink
[code-infra] Update monorepo (#16112)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot authored Feb 4, 2025
1 parent 6d5be78 commit 0735942
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 48 deletions.
1 change: 0 additions & 1 deletion docs/config.js

This file was deleted.

2 changes: 2 additions & 0 deletions docs/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// eslint-disable-next-line no-restricted-imports
export * from '@mui/monorepo/docs/config';
6 changes: 0 additions & 6 deletions docs/constants.js

This file was deleted.

2 changes: 2 additions & 0 deletions docs/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const SOURCE_CODE_REPO = 'https://github.com/mui/mui-x';
export const SOURCE_GITHUB_BRANCH = 'master'; // #default-branch-switch
29 changes: 10 additions & 19 deletions docs/next.config.mjs → docs/next.config.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
// @ts-check
import * as path from 'path';
import * as url from 'url';
import * as fs from 'fs';
import { createRequire } from 'module';
import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
// const withTM from 'next-transpile-modules')(['@mui/monorepo'];
// @ts-expect-error This expected error should be gone once we update the monorepo
import withDocsInfra from '@mui/monorepo/docs/nextConfigDocsInfra.js';
import { findPages } from './src/modules/utils/find.mjs';
import {
LANGUAGES,
LANGUAGES_SSR,
LANGUAGES_IGNORE_PAGES,
LANGUAGES_IN_PROGRESS,
} from './config.js';
import constants from './constants.js';
// eslint-disable-next-line no-restricted-imports
import withDocsInfra from '@mui/monorepo/docs/nextConfigDocsInfra';
import { findPages } from './src/modules/utils/find';
import { LANGUAGES, LANGUAGES_SSR, LANGUAGES_IGNORE_PAGES, LANGUAGES_IN_PROGRESS } from './config';
import { SOURCE_CODE_REPO, SOURCE_GITHUB_BRANCH } from './constants';

const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url));
const require = createRequire(import.meta.url);
Expand All @@ -23,6 +17,7 @@ const WORKSPACE_ROOT = path.resolve(currentDirectory, '../');
const MONOREPO_PATH = path.resolve(WORKSPACE_ROOT, './node_modules/@mui/monorepo');
const MONOREPO_ALIASES = {
'@mui/docs': path.resolve(MONOREPO_PATH, './packages/mui-docs/src'),
'@mui/internal-markdown': path.resolve(MONOREPO_PATH, './packages/markdown'),
};

const WORKSPACE_ALIASES = {
Expand All @@ -43,11 +38,7 @@ const WORKSPACE_ALIASES = {
'@mui/x-license': path.resolve(WORKSPACE_ROOT, './packages/x-license/src'),
};

/**
* @param {string} pkgPath
* @returns {{version: string}}
*/
function loadPkg(pkgPath) {
function loadPkg(pkgPath: string): { version: string } {
const pkgContent = fs.readFileSync(path.resolve(WORKSPACE_ROOT, pkgPath, 'package.json'), 'utf8');
return JSON.parse(pkgContent);
}
Expand All @@ -60,7 +51,7 @@ const treeViewPkg = loadPkg('./packages/x-tree-view');

let localSettings = {};
try {
// eslint-disable-next-line import/no-unresolved
// eslint-disable-next-line import/extensions
localSettings = require('./next.config.local.js');
} catch (_) {
// Ignore
Expand All @@ -77,8 +68,8 @@ export default withDocsInfra({
env: {
// docs-infra
LIB_VERSION: pkg.version,
SOURCE_CODE_REPO: constants.SOURCE_CODE_REPO,
SOURCE_GITHUB_BRANCH: constants.SOURCE_GITHUB_BRANCH,
SOURCE_CODE_REPO,
SOURCE_GITHUB_BRANCH,
GITHUB_TEMPLATE_DOCS_FEEDBACK: '6.docs-feedback.yml',
// MUI X related
DATA_GRID_VERSION: dataGridPkg.version,
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { pathnameToLanguage } from 'docs/src/modules/utils/helpers';
import getProductInfoFromUrl from 'docs/src/modules/utils/getProductInfoFromUrl';
import { DocsProvider } from '@mui/docs/DocsProvider';
import { mapTranslations } from '@mui/docs/i18n';
import config from '../config';
import * as config from '../config';

// Remove the license warning from demonstration purposes
LicenseInfo.setLicenseKey(process.env.NEXT_PUBLIC_MUI_LICENSE);
Expand Down
2 changes: 1 addition & 1 deletion docs/scripts/reportBrokenLinks.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable no-console */
const path = require('path');
const fse = require('fs-extra');
const { parseDocFolder, getAnchor } = require('@mui/monorepo/docs/scripts/reportBrokenLinks');
const { parseDocFolder, getAnchor } = require('@mui/monorepo/docs/scripts/reportBrokenLinksLib');

const docsSpaceRoot = path.join(__dirname, '../');

Expand Down
17 changes: 13 additions & 4 deletions docs/src/modules/utils/find.mjs → docs/src/modules/utils/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ const currentDirectory = url.fileURLToPath(new URL('.', import.meta.url));
const jsRegex = /\.js$/;
const blackList = ['/.eslintrc', '/_document', '/_app'];

interface NextJSPage {
pathname: string;
children?: NextJSPage[];
}

interface FindPagesOptions {
front?: boolean;
}

// Returns the Next.js pages available in a nested format.
// The output is in the next.js format.
// Each pathname is a route you can navigate to.
export function findPages(
options = {},
directory = path.resolve(currentDirectory, '../../../pages'),
pages = [],
options: FindPagesOptions = {},
directory: string = path.resolve(currentDirectory, '../../../pages'),
pages: NextJSPage[] = [],
) {
fs.readdirSync(directory).forEach((item) => {
const itemPath = path.resolve(directory, item);
Expand Down Expand Up @@ -41,7 +50,7 @@ export function findPages(
}

if (fs.statSync(itemPath).isDirectory()) {
const children = [];
const children: NextJSPage[] = [];
pages.push({
pathname,
children,
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"docs:create-playground": "pnpm --filter docs create-playground",
"docs:api": "NODE_OPTIONS=--max-old-space-size=4096 pnpm docs:api:build && pnpm docs:api:buildX",
"docs:api:build": "tsx ./scripts/buildApiDocs/index.ts",
"docs:api:buildX": "cross-env BABEL_ENV=development babel-node -i \"/node_modules/(?!@mui)/\" -x .ts,.tsx,.js ./docs/scripts/api/buildApi.ts",
"docs:link-check": "cross-env BABEL_ENV=development babel-node -i \"/node_modules/(?!@mui)/\" --extensions \".tsx,.ts,.js\" ./docs/scripts/reportBrokenLinks.js",
"docs:api:buildX": "tsx ./docs/scripts/api/buildApi.ts",
"docs:link-check": "tsx ./docs/scripts/reportBrokenLinks.js",
"docs:build": "pnpm --filter docs build",
"docs:typescript:formatted": "pnpm --filter docs typescript:transpile",
"docs:populate:demos": "pnpm --filter docs populate:demos",
Expand Down Expand Up @@ -94,7 +94,7 @@
"@mui/internal-markdown": "^1.0.25",
"@mui/internal-test-utils": "^1.0.26",
"@mui/material": "^5.16.14",
"@mui/monorepo": "github:mui/material-ui#c4f898d3b624b1248245b43dcd1fe035a66b08d5",
"@mui/monorepo": "github:mui/material-ui#40a4e6b3e684fff41c68f2d01d5a0e45aded980e",
"@mui/utils": "^5.16.14",
"@next/eslint-plugin-next": "15.1.6",
"@octokit/plugin-retry": "^7.1.3",
Expand Down
22 changes: 11 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions webpackBaseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
docs: path.resolve(__dirname, './node_modules/@mui/monorepo/docs'),
docsx: path.resolve(__dirname, './docs'),
},
extensions: ['.js', '.ts', '.tsx', '.d.ts'],
extensions: ['.js', '.mjs', '.ts', '.tsx', '.d.ts'],
},
output: {
path: path.join(__dirname, 'build'),
Expand All @@ -39,7 +39,7 @@ module.exports = {
module: {
rules: [
{
test: /\.(js|ts|tsx)$/,
test: /\.(js|mjs|ts|tsx)$/,
exclude: /node_modules\/.*\/node_modules\/(?!@mui)/,
loader: 'babel-loader',
options: {
Expand Down

0 comments on commit 0735942

Please sign in to comment.