From c8dd44a01b9e655e703ce66250aa254d3ad75881 Mon Sep 17 00:00:00 2001
From: Olivier Tassinari <olivier.tassinari@gmail.com>
Date: Mon, 30 Dec 2024 01:30:30 +0100
Subject: [PATCH 1/2] [core] Improve release

---
 docs/package.json           |  2 +-
 packages/react/package.json |  4 ++--
 scripts/README.md           | 40 ++++++++++++++++++-------------------
 scripts/copyFiles.mjs       | 12 +++++++++--
 4 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/docs/package.json b/docs/package.json
index 62910c3523..1e573eddaa 100644
--- a/docs/package.json
+++ b/docs/package.json
@@ -8,7 +8,7 @@
     "build": "rimraf ./export && cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=8192 next build --profile",
     "build:clean": "rimraf .next && pnpm build",
     "dev": "next dev --port 3005",
-    "deploy": "git push -f material-ui-docs master:latest",
+    "deploy": "git push -f upstream master:docs-v1",
     "serve": "serve ./export -l 3010",
     "typescript": "tsc -b tsconfig.json",
     "link-check": "tsx ./scripts/reportBrokenLinks.mts"
diff --git a/packages/react/package.json b/packages/react/package.json
index a8fb06db16..c1a3e43c02 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -63,14 +63,14 @@
   },
   "type": "commonjs",
   "scripts": {
+    "prebuild": "rimraf --glob build build-tests \"*.tsbuildinfo\"",
     "build": "pnpm build:node && pnpm build:stable && pnpm build:types && pnpm build:copy-files && pnpm build:manifest",
     "build:node": "node ../../scripts/build.mjs node",
     "build:stable": "node ../../scripts/build.mjs stable",
+    "build:types": "tsx ../../scripts/buildTypes.mts --project tsconfig.build.json --copy build/cjs",
     "build:copy-files": "node ../../scripts/copyFiles.mjs",
-    "build:types": "tsx ../../scripts/buildTypes.mjs --project tsconfig.build.json --copy build/cjs",
     "build:manifest": "tsx ./scripts/createPackageManifest.mts",
     "test:package": "publint ./build && attw --pack ./build",
-    "prebuild": "rimraf --glob build build-tests \"*.tsbuildinfo\"",
     "release": "pnpm build && pnpm publish",
     "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/react/**/*.test.{js,ts,tsx}'",
     "typescript": "tsc -b tsconfig.json"
diff --git a/scripts/README.md b/scripts/README.md
index 5dd3b0eb3b..7259f2b6f3 100644
--- a/scripts/README.md
+++ b/scripts/README.md
@@ -6,19 +6,15 @@ A typical release goes like this:
 
 ### Prerequisites
 
-1. You must be a member of the `@mui` org in npm to publish the release
-2. Set up your npm authToken by logging into npm (`npm login`) . This will save a token to `~/.npmrc` as a line that looks
+1. You must be a member of the `@base-ui-components` org in npm to publish the release.
+2. Set up your npm authToken by logging into npm (`npm login`). This will save a token to `~/.npmrc` as a line that looks
    like this:
    ```text
    //registry.npmjs.org/:_authToken=npm_000000000000000000000000000000000000
    ```
-3. Make sure you have added the `material-ui-docs` remote to deploy the documentation:
-   ```bash
-   git remote add material-ui-docs https://github.com/mui/material-ui-docs.git
-   ```
-4. Generate a GitHub Token at https://github.com/settings/personal-access-tokens/new and add it to your shell rc script (either `.bashrc` or `.zshrc`) as `GITHUB_TOKEN`.
+3. Generate a GitHub Token at https://github.com/settings/personal-access-tokens/new and add it to your shell rc script (either `.bashrc` or `.zshrc`) as `GITHUB_TOKEN`.
 
-### Prepare
+### Prepare the release of the packages
 
 The following steps must be proposed as a pull request.
 
@@ -28,33 +24,35 @@ The following steps must be proposed as a pull request.
 
 2. Clean the generated changelog:
    1. Match the format of https://github.com/mui/material-ui/releases.
-   2. Change the packages names casing to be lowercase if applicable, for example change `Material` to `material`
-3. Update the root `/package.json`'s version
+   2. Change the packages names casing to be lowercase if applicable
+3. Update the root `/package.json`'s version.
 4. Run `pnpm release:version`. Keep the package versions of stable public packages the same as the root `package.json` version.
-5. Open PR with changes and wait for review and green CI
-6. Merge PR once CI is green and it has been approved
+5. Open PR with changes and wait for review and green CI.
+6. Merge PR once CI is green and it has been approved.
+
+### Release the packages
 
-### Release
+1. Checkout the last version of the release branch.
+2. `pnpm install && pnpm release:build` (make sure you have the latest dependencies installed, and build the packages).
+3. `pnpm release:publish` (release the versions on npm, you need your 2FA device).
+4. `pnpm release:tag` (push the newly created tag).
 
-1. Checkout the last version of the release branch
-2. `pnpm install && pnpm release:build` (make sure you have the latest dependencies installed, and build the packages)
-3. `pnpm release:publish` (release the versions on npm, you need your 2FA device)
-4. `pnpm release:tag` (push the newly created tag)
+> Tip: You can use `release:publish:dry-run` to test the release process without actually publishing the packages.
+> Be sure install [verdaccio](https://verdaccio.org/) (local npm registry) before doing it.
 
 ### Publish the documentation
 
 The documentation must be updated on the `docs-vX` branch (`docs-v1` for `v1.X` releases, `docs-v2` for `v2.X` releases, etc.)
 
-Push the working branch to the documentation release branch to deploy the documentation with the latest changes.
+Push the working branch to the documentation release branch to deploy the documentation with the latest changes:
 
 <!-- #default-branch-switch -->
 
 ```bash
-git push -f upstream master:docs-v1
+pnpm docs:deploy
 ```
 
-You can follow the deployment process [on the Netlify Dashboard](https://app.netlify.com/sites/material-ui-x/deploys?filter=docs-next)
-Once deployed, it will be accessible at https://material-ui-x.netlify.app/ for the `docs-next` deployment.
+You can follow the deployment process [on the Netlify Dashboard](https://app.netlify.com/sites/base-ui/deploys).
 
 ### Announce
 
diff --git a/scripts/copyFiles.mjs b/scripts/copyFiles.mjs
index 8e5577d07e..d09e5b0a40 100644
--- a/scripts/copyFiles.mjs
+++ b/scripts/copyFiles.mjs
@@ -1,8 +1,11 @@
 /* eslint-disable no-console */
 import path from 'path';
-import fse from 'fs-extra';
+import fs from 'fs/promises';
+import { $ } from 'execa';
 import { includeFileInBuild, prepend, typescriptCopy } from './copyFilesUtils.mjs';
 
+const $$ = $({ stdio: 'inherit' });
+
 const packagePath = process.cwd();
 const buildPath = path.join(packagePath, './build');
 const srcPath = path.join(packagePath, './src');
@@ -31,6 +34,10 @@ async function addLicense(packageData) {
   );
 }
 
+async function removeBuildArtefacts() {
+  await $$`rimraf --glob ${buildPath}/*.tsbuildinfo`;
+}
+
 async function run() {
   const extraFiles = process.argv.slice(2);
   try {
@@ -44,9 +51,10 @@ async function run() {
       }),
     );
 
-    const packageFile = await fse.readFile(path.resolve(packagePath, './package.json'), 'utf8');
+    const packageFile = await fs.readFile(path.resolve(packagePath, './package.json'), { encoding: 'utf-8' });
     const packageData = JSON.parse(packageFile);
     await addLicense(packageData);
+    await removeBuildArtefacts();
   } catch (err) {
     console.error(err);
     process.exit(1);

From 17a5636e3afad493cfeae47b3a92da538ea8bcf7 Mon Sep 17 00:00:00 2001
From: Olivier Tassinari <olivier.tassinari@gmail.com>
Date: Mon, 30 Dec 2024 01:38:33 +0100
Subject: [PATCH 2/2] prettier

---
 scripts/copyFiles.mjs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scripts/copyFiles.mjs b/scripts/copyFiles.mjs
index d09e5b0a40..c9251cafab 100644
--- a/scripts/copyFiles.mjs
+++ b/scripts/copyFiles.mjs
@@ -51,7 +51,9 @@ async function run() {
       }),
     );
 
-    const packageFile = await fs.readFile(path.resolve(packagePath, './package.json'), { encoding: 'utf-8' });
+    const packageFile = await fs.readFile(path.resolve(packagePath, './package.json'), {
+      encoding: 'utf-8',
+    });
     const packageData = JSON.parse(packageFile);
     await addLicense(packageData);
     await removeBuildArtefacts();