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

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/utils/pnpm.mjs +26 -11
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.72",
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": "d5f96b89b5b960ad6272652eb2734ddb305a85ae",
190
190
  "scripts": {
191
191
  "build": "tsgo -p tsconfig.build.json",
192
192
  "typescript": "tsgo -noEmit",
@@ -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) => {