@mui/internal-code-infra 0.0.4-canary.71 → 0.0.4-canary.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,3 +20,10 @@ export declare function getRepositoryInfo(cwd?: string): Promise<RepoInfo>;
20
20
  * @returns {Promise<string>} Current git commit SHA
21
21
  */
22
22
  export declare function getCurrentGitSha(): Promise<string>;
23
+ /**
24
+ * Check whether a tag already exists on the origin remote
25
+ * @param {string} tagName - Tag name to check (e.g. `v1.2.3`)
26
+ * @param {string} [cwd=process.cwd()]
27
+ * @returns {Promise<boolean>} True if the tag exists on origin
28
+ */
29
+ export declare function remoteGitTagExists(tagName: string, cwd?: string): Promise<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-code-infra",
3
- "version": "0.0.4-canary.71",
3
+ "version": "0.0.4-canary.73",
4
4
  "author": "MUI Team",
5
5
  "description": "Infra scripts and configs to be used across MUI repos.",
6
6
  "license": "MIT",
@@ -136,8 +136,8 @@
136
136
  "yaml": "^2.9.0",
137
137
  "yargs": "^18.0.0",
138
138
  "@mui/internal-babel-plugin-display-name": "1.0.4-canary.21",
139
- "@mui/internal-babel-plugin-minify-errors": "2.0.8-canary.28",
140
- "@mui/internal-babel-plugin-resolve-imports": "2.0.7-canary.38"
139
+ "@mui/internal-babel-plugin-resolve-imports": "2.0.7-canary.38",
140
+ "@mui/internal-babel-plugin-minify-errors": "2.0.8-canary.28"
141
141
  },
142
142
  "peerDependencies": {
143
143
  "@next/eslint-plugin-next": "*",
@@ -186,7 +186,7 @@
186
186
  "publishConfig": {
187
187
  "access": "public"
188
188
  },
189
- "gitSha": "cb672accc6b61d455e18ce874f99ea841831a734",
189
+ "gitSha": "a646322dc5697683ef464c5a05a0de6240de9f05",
190
190
  "scripts": {
191
191
  "build": "tsgo -p tsconfig.build.json",
192
192
  "typescript": "tsgo -noEmit",
@@ -23,7 +23,7 @@ import {
23
23
  publishPackages,
24
24
  validatePublishDependencies,
25
25
  } from '../utils/pnpm.mjs';
26
- import { getCurrentGitSha, getRepositoryInfo } from '../utils/git.mjs';
26
+ import { getCurrentGitSha, getRepositoryInfo, remoteGitTagExists } from '../utils/git.mjs';
27
27
 
28
28
  const isCI = envCI().isCi;
29
29
 
@@ -365,7 +365,13 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
365
365
  console.log(`✅ Published ${pkg.name}@${pkg.version}`);
366
366
  });
367
367
 
368
- await createGitTag(version, dryRun);
368
+ // Tag the root version when it's new. Arbitrary package publishes that don't
369
+ // bump the root version don't create a new tag, so skip in that case.
370
+ if (await remoteGitTagExists(`v${version}`)) {
371
+ console.log(`ℹ️ Git tag v${version} already exists, skipping tag creation.`);
372
+ } else {
373
+ await createGitTag(version, dryRun);
374
+ }
369
375
 
370
376
  // Create GitHub release or git tag after successful npm publishing
371
377
  if (githubRelease && githubReleaseData) {
package/src/utils/git.mjs CHANGED
@@ -73,3 +73,14 @@ export async function getCurrentGitSha() {
73
73
  const result = await $`git rev-parse HEAD`;
74
74
  return result.stdout.trim();
75
75
  }
76
+
77
+ /**
78
+ * Check whether a tag already exists on the origin remote
79
+ * @param {string} tagName - Tag name to check (e.g. `v1.2.3`)
80
+ * @param {string} [cwd=process.cwd()]
81
+ * @returns {Promise<boolean>} True if the tag exists on origin
82
+ */
83
+ export async function remoteGitTagExists(tagName, cwd = process.cwd()) {
84
+ const { stdout } = await $({ cwd })`git ls-remote --tags origin refs/tags/${tagName}`;
85
+ return stdout.trim().length > 0;
86
+ }
@@ -78,18 +78,33 @@ import { parseDocument, isMap } from 'yaml';
78
78
  export async function getWorkspacePackages(options = {}) {
79
79
  const { sinceRef = null, publicOnly = false, nonPublishedOnly = false, filter = [] } = options;
80
80
 
81
- // Build command with conditional filter
82
- const filterArg = sinceRef ? ['--filter', `...[${sinceRef}]`] : [];
83
- if (filter.length > 0) {
84
- filter.forEach((f) => {
85
- filterArg.push('--filter', f);
86
- });
81
+ /**
82
+ * Run `pnpm ls` with the given --filter args and return the parsed list.
83
+ * @param {string[]} filterArg
84
+ * @returns {Promise<PnpmListResultItem[]>}
85
+ */
86
+ const listPackages = async (filterArg) => {
87
+ const result = await $({ cwd: options.cwd })`pnpm ls -r --json --depth -1 ${filterArg}`;
88
+ return JSON.parse(result.stdout);
89
+ };
90
+
91
+ // pnpm ORs --filter args, so intersect "matches filter" with "changed since ref"
92
+ // in JS. The `[ref]` selector (no `...`) excludes dependents of changed packages.
93
+ const patternFilterArg = filter.flatMap((f) => ['--filter', f]);
94
+ const [candidatePackages, changedPackages] = await Promise.all([
95
+ listPackages(patternFilterArg),
96
+ // null when no sinceRef (skip the constraint); [] when nothing changed.
97
+ sinceRef ? listPackages(['--filter', `[${sinceRef}]`]) : Promise.resolve(null),
98
+ ]);
99
+ let packageData = candidatePackages;
100
+ if (changedPackages) {
101
+ // sinceRef given but nothing changed → no packages, regardless of filter.
102
+ if (changedPackages.length === 0) {
103
+ return [];
104
+ }
105
+ const changedPaths = new Set(changedPackages.map((pkg) => pkg.path));
106
+ packageData = packageData.filter((pkg) => changedPaths.has(pkg.path));
87
107
  }
88
- const result = options.cwd
89
- ? await $({ cwd: options.cwd })`pnpm ls -r --json --depth -1 ${filterArg}`
90
- : await $`pnpm ls -r --json --depth -1 ${filterArg}`;
91
- /** @type {PnpmListResultItem[]} */
92
- const packageData = JSON.parse(result.stdout);
93
108
 
94
109
  // Filter packages based on options
95
110
  const filteredPackages = packageData.flatMap((pkg) => {