From 6cc38f98d7168f82913f199c36c8b1bba57bf341 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Thu, 3 Dec 2020 10:44:40 +0100 Subject: [PATCH] [core] Use Lerna to publish (#23793) --- .circleci/config.yml | 2 +- lerna.json | 1 - package.json | 5 ++- packages/material-ui-codemod/README.md | 20 ++++++------ packages/material-ui-codemod/package.json | 4 +-- packages/material-ui-lab/package.json | 4 +-- packages/material-ui-styles/package.json | 2 +- packages/material-ui-system/package.json | 2 +- packages/material-ui-unstyled/package.json | 2 +- packages/material-ui/package.json | 12 +++---- scripts/README.md | 38 ++++++++++++++++++++++ 11 files changed, 66 insertions(+), 26 deletions(-) create mode 100644 scripts/README.md diff --git a/.circleci/config.yml b/.circleci/config.yml index af632f410ae9af..34f39986fb7331 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -238,7 +238,7 @@ jobs: command: xvfb-run yarn test:regressions - run: name: Upload screenshots to Argos CI - command: yarn argos + command: yarn test:argos workflows: version: 2 pipeline: diff --git a/lerna.json b/lerna.json index 6cd5c8e18d5433..06cff9cd698d98 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,4 @@ { - "packages": ["packages/*", "docs", "framer"], "npmClient": "yarn", "useWorkspaces": true, "version": "independent" diff --git a/package.json b/package.json index 3003e3c28285f5..5389b95c2fbdd2 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,11 @@ "scripts": { "proptypes": "cross-env BABEL_ENV=test babel-node --extensions \".tsx,.ts,.js\" ./scripts/generateProptypes.ts", "deduplicate": "node scripts/deduplicate.js", - "argos": "node ./scripts/pushArgos.js", "benchmark:browser": "yarn workspace benchmark browser", + "build:release": "lerna run --parallel --scope \"@material-ui/*\" build", "build:codesandbox": "lerna run --parallel --scope \"@material-ui/*\" build", + "release": "yarn build:release && lerna publish --no-changelog --dist-tag next --contents build", + "publish:dry-run": "lerna publish --no-changelog --dist-tag next --contents build --no-git-tag-version --no-push --registry=\"http://localhost:4873/\"", "docs:api": "rimraf ./docs/pages/api-docs && yarn docs:api:build", "docs:api:build": "cross-env BABEL_ENV=test __NEXT_EXPORT_TRAILING_SLASH=true babel-node --extensions \".tsx,.ts,.js\" ./docs/scripts/buildApi.ts ./docs/pages/api-docs ./packages/material-ui-unstyled/src ./packages/material-ui/src ./packages/material-ui-lab/src", "docs:build": "yarn workspace docs build", @@ -49,6 +51,7 @@ "test:umd": "node packages/material-ui/test/umd/run.js", "test:unit": "cross-env NODE_ENV=test mocha 'packages/**/*.test.{js,ts,tsx}' 'docs/**/*.test.{js,ts,tsx}' 'scripts/**/*.test.{js,ts,tsx}' 'test/utils/**/*.test.{js,ts,tsx}'", "test:watch": "yarn test:unit --watch", + "test:argos": "node ./scripts/pushArgos.js", "typescript": "lerna run --no-bail --parallel typescript" }, "devDependencies": { diff --git a/packages/material-ui-codemod/README.md b/packages/material-ui-codemod/README.md index e6c2c02bb6f0fe..6185fa264c8904 100644 --- a/packages/material-ui-codemod/README.md +++ b/packages/material-ui-codemod/README.md @@ -32,7 +32,7 @@ The diff should look like this: ``` ```sh -find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v5.0.0/box-sx-prop.js +find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/v5.0.0/box-sx-prop.js ``` #### `moved-lab-modules` @@ -52,7 +52,7 @@ or ``` ```sh -find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v5.0.0/moved-lab-modules.js +find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/v5.0.0/moved-lab-modules.js ``` #### `textfield-variant-prop` @@ -70,7 +70,7 @@ The diff should look like this: This codemod is non-idempotent (`variant="standard"` would be added on a subsequent run, where `variant="outlined"` was removed), so should only be run once against any particular codebase. ```sh -find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v5.0.0/textfield-variant-prop.js +find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/v5.0.0/textfield-variant-prop.js ``` ### v4.0.0 @@ -86,7 +86,7 @@ The diff should look like this: ``` ```sh -find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v4.0.0/theme-spacing-api.js +find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/v4.0.0/theme-spacing-api.js ``` This codemod tries to perform a basic expression simplification which can be improved for expressions that use more than one operation. @@ -111,7 +111,7 @@ Converts all `@material-ui/core` imports more than 1 level deep to the optimal f ``` ```sh -find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v4.0.0/optimal-imports.js +find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/v4.0.0/optimal-imports.js ``` Head to https://material-ui.com/guides/minimizing-bundle-size/ to understand when it's useful. @@ -127,7 +127,7 @@ Converts all `@material-ui/core` submodule imports to the root module: ``` ```sh -find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v4.0.0/top-level-imports.js +find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/v4.0.0/top-level-imports.js ``` Head to https://material-ui.com/guides/minimizing-bundle-size/ to understand when it's useful. @@ -146,7 +146,7 @@ The diff should look like this: ``` ```sh -find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v1.0.0/import-path.js +find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/v1.0.0/import-path.js ``` **Notice**: if you are migrating from pre-v1.0, and your imports use `material-ui`, you will need to manually find and replace all references to `material-ui` in your code to `@material-ui/core`. E.g.: @@ -171,7 +171,7 @@ The diff should look like this: ``` ```sh -find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v1.0.0/color-imports.js +find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/v1.0.0/color-imports.js ``` **additional options** @@ -193,7 +193,7 @@ The diff should look like this: ``` ```sh -find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v1.0.0/svg-icon-imports.js +find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/v1.0.0/svg-icon-imports.js ``` ### v0.15.0 @@ -215,7 +215,7 @@ The diff should look like this: ``` ```sh -find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/lib/v0.15.0/import-path.js +find src -name '*.js' -print | xargs npx jscodeshift -t node_modules/@material-ui/codemod/v0.15.0/import-path.js ``` ### Recast Options diff --git a/packages/material-ui-codemod/package.json b/packages/material-ui-codemod/package.json index 67f903f63d94a5..508305755788d6 100644 --- a/packages/material-ui-codemod/package.json +++ b/packages/material-ui-codemod/package.json @@ -13,8 +13,8 @@ ], "scripts": { "test": "cd ../../ && cross-env NODE_ENV=test mocha 'packages/material-ui-codemod/**/*.test.js'", - "prebuild": "rimraf lib", - "build": "node ../../scripts/build node --out-dir ./lib", + "prebuild": "rimraf build", + "build": "node ../../scripts/build node --out-dir ./build && cp README.md build && cp package.json build", "release": "yarn build && npm publish --tag next" }, "repository": { diff --git a/packages/material-ui-lab/package.json b/packages/material-ui-lab/package.json index bfa7d8073f16d9..e65e5ffb97babd 100644 --- a/packages/material-ui-lab/package.json +++ b/packages/material-ui-lab/package.json @@ -64,8 +64,8 @@ }, "dependencies": { "@babel/runtime": "^7.4.4", - "@material-ui/system": "^5.0.0-alpha.18", - "@material-ui/utils": "^5.0.0-alpha.18", + "@material-ui/system": "5.0.0-alpha.18", + "@material-ui/utils": "5.0.0-alpha.18", "clsx": "^1.0.4", "prop-types": "^15.7.2", "react-is": "^16.8.0 || ^17.0.0", diff --git a/packages/material-ui-styles/package.json b/packages/material-ui-styles/package.json index 1ace1c067769b0..91996ff89f9296 100644 --- a/packages/material-ui-styles/package.json +++ b/packages/material-ui-styles/package.json @@ -51,7 +51,7 @@ "@babel/runtime": "^7.4.4", "@emotion/hash": "^0.8.0", "@material-ui/types": "^5.1.0", - "@material-ui/utils": "^5.0.0-alpha.18", + "@material-ui/utils": "5.0.0-alpha.18", "clsx": "^1.0.4", "csstype": "^3.0.2", "hoist-non-react-statics": "^3.3.2", diff --git a/packages/material-ui-system/package.json b/packages/material-ui-system/package.json index ef59c4486d78a7..648d6d89e53ef3 100644 --- a/packages/material-ui-system/package.json +++ b/packages/material-ui-system/package.json @@ -49,7 +49,7 @@ }, "dependencies": { "@babel/runtime": "^7.4.4", - "@material-ui/utils": "^5.0.0-alpha.18", + "@material-ui/utils": "5.0.0-alpha.18", "prop-types": "^15.7.2", "csstype": "^3.0.2" }, diff --git a/packages/material-ui-unstyled/package.json b/packages/material-ui-unstyled/package.json index 85ece0b8507a20..d49470f5819062 100644 --- a/packages/material-ui-unstyled/package.json +++ b/packages/material-ui-unstyled/package.json @@ -45,7 +45,7 @@ }, "dependencies": { "@babel/runtime": "^7.4.4", - "@material-ui/utils": "^5.0.0-alpha.18", + "@material-ui/utils": "5.0.0-alpha.18", "clsx": "^1.0.4", "prop-types": "^15.7.2", "react-is": "^16.8.0 || ^17.0.0" diff --git a/packages/material-ui/package.json b/packages/material-ui/package.json index ca1eccaf1f06ad..4e53d2649228d0 100644 --- a/packages/material-ui/package.json +++ b/packages/material-ui/package.json @@ -60,12 +60,12 @@ }, "dependencies": { "@babel/runtime": "^7.4.4", - "@material-ui/styled-engine": "^5.0.0-alpha.18", - "@material-ui/styles": "^5.0.0-alpha.18", - "@material-ui/system": "^5.0.0-alpha.18", - "@material-ui/types": "^5.1.0", - "@material-ui/unstyled": "^5.0.0-alpha.18", - "@material-ui/utils": "^5.0.0-alpha.18", + "@material-ui/styled-engine": "5.0.0-alpha.18", + "@material-ui/styles": "5.0.0-alpha.18", + "@material-ui/system": "5.0.0-alpha.18", + "@material-ui/types": "5.1.0", + "@material-ui/unstyled": "5.0.0-alpha.18", + "@material-ui/utils": "5.0.0-alpha.18", "@popperjs/core": "^2.4.4", "@types/react-transition-group": "^4.2.0", "clsx": "^1.0.4", diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 00000000000000..49dc23d5e5d92a --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,38 @@ +# Material-UI Scripts + +## Release + +A typical release goes like this: + +1. **Changelog**. Generate the changelog: + +- Compare the last version with `next`. For instance: https://github.com/mui-org/material-ui/compare/v5.0.0-alpha.17...next +- Generate the changelog with this script: https://trello.com/c/uspnIWkh/1566-release-note +- Clean the generated changelog, to match the format of https://github.com/mui-org/material-ui/releases. +- Open a pull request with the generated change on `next`. + +1. **npm**. Release the packages to npm. You need your 2FA device: + +``` +git checkout next +git pull +yarn +yarn release +``` + +1. **git**. Push the release git commit and git tag to master (e.g. "v5.0.0-alpha.17"): + +``` +git push +git push --tag +``` + +1. **Docs**. Push the next branch on the material-ui-docs repository to deploy the documentation with the latest changes. It lives at https://material-ui.netlify.app/. Force push if necessary. + +``` +yarn docs:deploy +``` + +1. **GitHub**. Make a new release on GitHub (for people subscribing to updates). https://github.com/mui-org/material-ui/releases + +2. **Twitter**. Make sure Material-UI X was released too: https://trello.com/c/kYF9OLLi/105-release-steps. Send a tweet with the main Twitter account to summarize what happened.