Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[code-infra] Prepare publishing @mui-internal/typescript-to-proptypes to npm #40842

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"packages/mui-styles",
"packages/mui-system",
"packages/mui-types",
"packages/mui-utils"
"packages/mui-utils",
"packages/docs-utils",
"packages/typescript-to-proptypes"
],
"publishDirectory": {
"@mui/base": "packages/mui-base/build",
Expand All @@ -36,7 +38,9 @@
"@mui/styles": "packages/mui-styles/build",
"@mui/system": "packages/mui-system/build",
"@mui/types": "packages/mui-types/build",
"@mui/utils": "packages/mui-utils/build"
"@mui/utils": "packages/mui-utils/build",
"@mui-internal/docs-utils": "packages/docs-utils",
"@mui-internal/typescript-to-proptypes": "packages/typescript-to-proptypes"
},
"sandboxes": [
"material-ui-issue-latest-s2dsx",
Expand Down
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = function getBabelConfig(api) {
'@mui/material-next': resolveAliasPath('./packages/mui-material-next/src'),
'@mui/joy': resolveAliasPath('./packages/mui-joy/src'),
'@mui/zero-runtime': resolveAliasPath('./packages/zero-runtime/src'),
'@mui-internal/docs-utils': resolveAliasPath('./packages/docs-utils/src'),
docs: resolveAliasPath('./docs'),
test: resolveAliasPath('./test'),
};
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@
"devDependencies": {
"@babel/plugin-transform-react-constant-elements": "^7.23.3",
"@babel/preset-typescript": "^7.23.3",
"@mui-internal/docs-utilities": "workspace:^",
"@mui-internal/docs-utils": "workspace:^",
"@mui-internal/test-utils": "workspace:^",
"@mui-internal/typescript-to-proptypes": "workspace:^",
"@types/autosuggest-highlight": "^3.2.3",
"@types/chai": "^4.3.11",
"@types/css-mediaquery": "^0.1.4",
Expand All @@ -139,7 +140,6 @@
"playwright": "^1.41.1",
"prettier": "^2.8.8",
"tailwindcss": "^3.4.1",
"typescript-to-proptypes": "workspace:^",
"yargs": "^17.7.2"
}
}
7 changes: 5 additions & 2 deletions docs/scripts/formattedTSDemos.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ const path = require('path');
const fse = require('fs-extra');
const babel = require('@babel/core');
const prettier = require('prettier');
const { getPropTypesFromFile, injectPropTypesInFile } = require('typescript-to-proptypes');
const {
getPropTypesFromFile,
injectPropTypesInFile,
} = require('@mui-internal/typescript-to-proptypes');
const {
createTypeScriptProjectBuilder,
} = require('@mui-internal/api-docs-builder/utils/createTypeScriptProject');
const yargs = require('yargs');
const { fixBabelGeneratorIssues, fixLineEndings } = require('@mui-internal/docs-utilities');
const { fixBabelGeneratorIssues, fixLineEndings } = require('@mui-internal/docs-utils');
const { default: CORE_TYPESCRIPT_PROJECTS } = require('../../scripts/coreTypeScriptProjects');

const babelConfig = {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/ApiPage/list/ClassesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as React from 'react';
import { styled } from '@mui/material/styles';
import kebabCase from 'lodash/kebabCase';
import { ComponentClassDefinition } from '@mui-internal/docs-utilities';
import { ComponentClassDefinition } from '@mui-internal/docs-utils';
import { useTranslate } from 'docs/src/modules/utils/i18n';
import ExpandableApiItem, {
ApiItemContaier,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/no-danger */
import * as React from 'react';
import { useTranslate } from 'docs/src/modules/utils/i18n';
import { ComponentClassDefinition } from '@mui-internal/docs-utilities';
import { ComponentClassDefinition } from '@mui-internal/docs-utils';
import Box from '@mui/material/Box';
import ToggleDisplayOption, {
API_LAYOUT_STORAGE_KEYS,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/ApiPage/table/ClassesTable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable react/no-danger */
import * as React from 'react';
import { ComponentClassDefinition } from '@mui-internal/docs-utilities';
import { ComponentClassDefinition } from '@mui-internal/docs-utils';
import { styled, alpha } from '@mui/material/styles';
import {
brandingDarkTheme as darkTheme,
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
"proptypes": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./scripts/generateProptypes.ts",
"proptypes": "tsx ./scripts/generateProptypes.ts",
"deduplicate": "pnpm dedupe",
"benchmark:browser": "pnpm --filter benchmark browser",
"build": "lerna run --scope \"@mui/*\" build",
"build:zero": "lerna run --scope \"@mui/zero-*\" build",
"clean:zero": "pnpm --filter \"@mui/zero-*\" clean",
"build:codesandbox": "NODE_OPTIONS=\"max_old_space_size=4096\" lerna run --concurrency 8 --scope \"@mui/*\" build",
"build:codesandbox": "NODE_OPTIONS=\"--max_old_space_size=4096\" lerna run --concurrency 8 --scope \"@mui/*\" --scope \"@mui-internal/*\" --no-private build",
"release:version": "lerna version --no-changelog --no-push --no-git-tag-version --no-private --force-publish=@mui/core-downloads-tracker",
"release:build": "lerna run --concurrency 8 --scope \"@mui/*\" build --skip-nx-cache",
"release:changelog": "node scripts/releaseChangelog.mjs",
Expand All @@ -33,7 +33,7 @@
"docs:link-check": "pnpm --filter docs link-check",
"docs:typescript": "pnpm docs:typescript:formatted --watch",
"docs:typescript:check": "pnpm --filter docs typescript",
"docs:typescript:formatted": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/formattedTSDemos",
"docs:typescript:formatted": "tsx ./docs/scripts/formattedTSDemos",
"docs:mdicons:synonyms": "cross-env BABEL_ENV=development babel-node --extensions \".tsx,.ts,.js,.mjs\" ./docs/scripts/updateIconSynonyms && pnpm prettier",
"extract-error-codes": "cross-env MUI_EXTRACT_ERROR_CODES=true lerna run --concurrency 8 build:modern",
"rsc:build": "tsx ./packages/rsc-builder/buildRsc.ts",
Expand Down Expand Up @@ -102,8 +102,9 @@
"@mnajdova/enzyme-adapter-react-18": "^0.2.0",
"@mui-internal/api-docs-builder": "workspace:^",
"@mui-internal/api-docs-builder-core": "workspace:^",
"@mui-internal/docs-utilities": "workspace:^",
"@mui-internal/docs-utils": "workspace:^",
"@mui-internal/test-utils": "workspace:^",
"@mui-internal/typescript-to-proptypes": "workspace:^",
"@mui/joy": "workspace:*",
"@mui/material": "workspace:^",
"@mui/utils": "workspace:^",
Expand Down Expand Up @@ -180,7 +181,6 @@
"tsx": "^4.7.0",
"tsup": "^8.0.1",
"typescript": "^5.3.3",
"typescript-to-proptypes": "workspace:^",
"webpack": "^5.90.0",
"webpack-bundle-analyzer": "^4.10.1",
"webpack-cli": "^5.1.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import remarkVisit from 'unist-util-visit';
import type { Link } from 'mdast';
import { defaultHandlers, parse as docgenParse, ReactDocgenApi } from 'react-docgen';
import { renderMarkdown } from '@mui/markdown';
import { ComponentClassDefinition } from '@mui-internal/docs-utilities';
import { ComponentClassDefinition } from '@mui-internal/docs-utils';
import { ProjectSettings, SortingStrategiesType } from '../ProjectSettings';
import { ComponentInfo, toGitHubPath, writePrettifiedFile } from '../buildApiUtils';
import muiDefaultPropsHandler from '../utils/defaultPropsHandler';
Expand Down
2 changes: 1 addition & 1 deletion packages/api-docs-builder/ProjectSettings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentClassDefinition } from '@mui-internal/docs-utilities/ComponentClassDefinition';
import { ComponentClassDefinition } from '@mui-internal/docs-utils';
import { ComponentInfo, HookInfo } from './buildApiUtils';
import { CreateTypeScriptProjectOptions } from './utils/createTypeScriptProject';
import { CreateDescribeablePropSettings } from './utils/createDescribeableProp';
Expand Down
2 changes: 1 addition & 1 deletion packages/api-docs-builder/buildApiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';
import * as ts from 'typescript';
import * as prettier from 'prettier';
import kebabCase from 'lodash/kebabCase';
import { getLineFeed } from '@mui-internal/docs-utilities';
import { getLineFeed } from '@mui-internal/docs-utils';
import { replaceComponentLinks } from './utils/replaceUrl';
import { TypeScriptProject } from './utils/createTypeScriptProject';

Expand Down
2 changes: 1 addition & 1 deletion packages/api-docs-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@babel/core": "^7.23.9",
"@babel/preset-typescript": "^7.23.3",
"@babel/traverse": "^7.23.9",
"@mui-internal/docs-utilities": "workspace:^",
"@mui-internal/docs-utils": "workspace:^",
"@mui/markdown": "workspace:^",
"ast-types": "^0.14.2",
"doctrine": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-docs-builder/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"strict": true,
"baseUrl": "./",
"paths": {
"@mui/utils": ["../mui-utils/src"]
"@mui-internal/docs-utils": ["../docs-utils/src"]
}
},
"include": ["./**/*.ts", "./**/*.js"],
Expand Down
2 changes: 1 addition & 1 deletion packages/api-docs-builder/utils/parseSlotsAndClasses.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ts from 'typescript';
import { ComponentClassDefinition } from '@mui-internal/docs-utilities';
import { ComponentClassDefinition } from '@mui-internal/docs-utils';
import { renderMarkdown } from '@mui/markdown';
import { getSymbolDescription, getSymbolJSDocTags } from '../buildApiUtils';
import { TypeScriptProject } from './createTypeScriptProject';
Expand Down
5 changes: 0 additions & 5 deletions packages/docs-utilities/README.md

This file was deleted.

9 changes: 0 additions & 9 deletions packages/docs-utilities/index.d.ts

This file was deleted.

6 changes: 0 additions & 6 deletions packages/docs-utilities/package.json

This file was deleted.

19 changes: 0 additions & 19 deletions packages/docs-utilities/tsconfig.json

This file was deleted.

1 change: 1 addition & 0 deletions packages/docs-utils/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.tsbuildinfo
5 changes: 5 additions & 0 deletions packages/docs-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 1.0.0

Initial release as an npm package.
9 changes: 9 additions & 0 deletions packages/docs-utils/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @mui-internal/docs-utils

This package contains utilities shared between MUI docs generation scripts.
This is an internal package not meant for general use.

## Release

1. Build the project: `pnpm build`
2. Publish the build artifacts to npm: `pnpm release:publish`
30 changes: 30 additions & 0 deletions packages/docs-utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@mui-internal/docs-utils",
Copy link
Member

@oliviertassinari oliviertassinari Feb 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package was released 3 days ago https://www.npmjs.com/package/@mui-internal/docs-utils.

@michaldudak Could we:

  1. Remove all the members in https://www.npmjs.com/settings/mui-internal/members. I don't have admin permissions to do it. This should be enough to not silently fail.
  2. Rename all of these to @mui/internal-*
  3. npm deprecate the @mui-internal/* packages
  4. Isolate the @mui/internal-* packages to the Material UI, Joy UI, Base UI, MUI System npm packages. We need to publish the former for each commit, and the latter once a week. So it seems to me that two should be released with two different scripts. It's also relevant to isolate npm permissions.

Copy link
Member Author

@michaldudak michaldudak Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, yes, that's the plan.

Isolate the @mui/internal-* packages to the Material UI, Joy UI, Base UI, MUI System npm packages.

As far as I know, lerna version does not support filtering, so having these packages in the same repo may force us to release on the same schedule as the public Core packages. We could write a custom script that resets their version after lerna version finishes, but it may be confusing for the person releasing the packages.
One solution I can think of would be moving these packages to a separate infra repository and setting up different release rules there. If we used conventional commits, we could automate the most (if not whole) part of the release process, including the changelog generation. What do you think?

cc @Janpot

It's also relevant to isolate npm permissions.

Do you think about restricting who can publish the infra packages?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the goal is to develop the docs package in conjunction with the core libraries then I think following the core packages release schedule is the only option. The docs package has a dependency on the core packages, if they live in the same monorepo, it will depend on an unreleased version of the core packages in the monorepo. Any release of the docs package that is separate from a release of the core packages will potentially depend on unreleased changes in core packages and be broken. This is not a new problem, we already run into this with the current setup. Just last month alone monorepo update in X was blocked at least twice for several days just because it had to wait for core packages to be released. We can develop infra in a separate repo, but it takes away the ability to develop core and docs together.

And so here's where the submodules approach potentially could benefit us, bringing core modules + docs module together in the X monorepo and you act as if X+core is one big pnpm workspaces.

Copy link
Member

@oliviertassinari oliviertassinari Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just last month alone monorepo update in X was blocked at least twice for several days just because it had to wait for core packages to be released

Oh, I didn't know this, but it makes sense, we are dogfooding new MUI System and Material UI APIs on the docs infra.

submodules approach

I was going to raise this, it's a new argument in the "pros" side.

But it feels like we could with some hacks release the infra packages more frequently than the product ones, and that the reliance on the release of the product packages is temporary, or that we could solve it with canary versions (under a different npm name to not clutter the npm version view).

It feels like it will be harder for MUI System team to dogfooding if we move the infra to the mui-public repository.


For context,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, this could be an issue with docs infra packages as they rely heavily on Core projects. The code infra packages, however, don't (or they are about to be decoupled), and could be released any time.

Copy link
Member

@Janpot Janpot Feb 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it feels like we could with some hacks release the infra packages more frequently than the product ones, and that the reliance on the release of the product packages is temporary, or that we could solve it with canary versions (under a different npm name to not clutter the npm version view).

This will be very tricky for X (and Toolpad), because the X packages rely on published releases of core packages. If the docs rely on docs infra which relies on canary releases, then we end up with two versions of core packages in the docs.

edit: I assumed docs package being an infra package, but rereading your comment, that's probably not what you meant

"version": "1.0.0",
"author": "MUI Team",
"description": "Utilities for MUI docs. This is an internal package not meant for general use.",
"main": "./build/index.js",
"exports": {
".": "./build/index.js"
},
"types": "./build/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/mui/material-ui.git",
"directory": "packages/docs-utils"
},
"scripts": {
"prebuild": "rimraf ./build",
"build": "tsc -b tsconfig.build.json",
"typescript": "tsc -b tsconfig.json",
"release:publish": "pnpm publish --tag latest",
"release:publish:dry-run": "pnpm publish --tag latest --registry=\"http://localhost:4873/\""
},
"dependencies": {
"rimraf": "^5.0.5",
"typescript": "^5.1.6"
},
"publishConfig": {
"access": "public"
}
}
Loading
Loading