@mui/internal-code-infra 0.0.4-canary.3 → 0.0.4-canary.31

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 (69) hide show
  1. package/README.md +19 -8
  2. package/build/babel-config.d.mts +11 -3
  3. package/build/brokenLinksChecker/crawlWorker.d.mts +1 -0
  4. package/build/brokenLinksChecker/index.d.mts +35 -2
  5. package/build/changelog/types.d.ts +1 -1
  6. package/build/cli/cmdArgosPush.d.mts +2 -2
  7. package/build/cli/cmdBuild.d.mts +2 -2
  8. package/build/cli/cmdCopyFiles.d.mts +2 -2
  9. package/build/cli/cmdExtractErrorCodes.d.mts +2 -2
  10. package/build/cli/cmdGenerateChangelog.d.mts +2 -2
  11. package/build/cli/cmdGithubAuth.d.mts +2 -2
  12. package/build/cli/cmdListWorkspaces.d.mts +4 -2
  13. package/build/cli/cmdNetlifyIgnore.d.mts +2 -2
  14. package/build/cli/cmdPublish.d.mts +4 -2
  15. package/build/cli/cmdPublishCanary.d.mts +3 -2
  16. package/build/cli/cmdPublishNewPackage.d.mts +4 -2
  17. package/build/cli/cmdSetVersionOverrides.d.mts +2 -2
  18. package/build/cli/cmdVale.d.mts +46 -0
  19. package/build/cli/cmdValidateBuiltTypes.d.mts +2 -2
  20. package/build/eslint/mui/rules/disallow-react-api-in-server-components.d.mts +2 -2
  21. package/build/eslint/mui/rules/docgen-ignore-before-comment.d.mts +2 -2
  22. package/build/eslint/mui/rules/no-restricted-resolved-imports.d.mts +2 -2
  23. package/build/markdownlint/duplicate-h1.d.mts +1 -1
  24. package/build/markdownlint/git-diff.d.mts +1 -1
  25. package/build/markdownlint/index.d.mts +1 -1
  26. package/build/markdownlint/straight-quotes.d.mts +1 -1
  27. package/build/markdownlint/table-alignment.d.mts +1 -1
  28. package/build/markdownlint/terminal-language.d.mts +1 -1
  29. package/build/utils/build.d.mts +3 -3
  30. package/build/utils/github.d.mts +1 -1
  31. package/build/utils/pnpm.d.mts +68 -2
  32. package/build/utils/testUtils.d.mts +7 -0
  33. package/package.json +38 -31
  34. package/src/babel-config.mjs +9 -3
  35. package/src/brokenLinksChecker/__fixtures__/static-site/index.html +1 -0
  36. package/src/brokenLinksChecker/__fixtures__/static-site/invalid-html.html +15 -0
  37. package/src/brokenLinksChecker/crawlWorker.mjs +173 -0
  38. package/src/brokenLinksChecker/index.mjs +177 -164
  39. package/src/brokenLinksChecker/index.test.ts +55 -13
  40. package/src/build-env.d.ts +13 -0
  41. package/src/changelog/fetchChangelogs.mjs +6 -2
  42. package/src/changelog/types.ts +1 -1
  43. package/src/cli/cmdListWorkspaces.mjs +9 -2
  44. package/src/cli/cmdNetlifyIgnore.mjs +4 -88
  45. package/src/cli/cmdPublish.mjs +51 -14
  46. package/src/cli/cmdPublishCanary.mjs +139 -107
  47. package/src/cli/cmdPublishNewPackage.mjs +27 -6
  48. package/src/cli/cmdVale.mjs +513 -0
  49. package/src/cli/cmdVale.test.mjs +644 -0
  50. package/src/cli/index.mjs +2 -0
  51. package/src/eslint/baseConfig.mjs +2 -1
  52. package/src/eslint/docsConfig.mjs +2 -1
  53. package/src/eslint/jsonConfig.mjs +2 -1
  54. package/src/eslint/mui/config.mjs +11 -1
  55. package/src/eslint/testConfig.mjs +2 -1
  56. package/src/estree-typescript.d.ts +1 -1
  57. package/src/untyped-plugins.d.ts +11 -11
  58. package/src/utils/build.test.mjs +546 -575
  59. package/src/utils/pnpm.mjs +192 -3
  60. package/src/utils/pnpm.test.mjs +580 -0
  61. package/src/utils/testUtils.mjs +18 -0
  62. package/src/utils/typescript.test.mjs +249 -272
  63. package/vale/.vale.ini +1 -0
  64. package/vale/styles/MUI/CorrectReferenceAllCases.yml +43 -0
  65. package/vale/styles/MUI/CorrectRererenceCased.yml +14 -0
  66. package/vale/styles/MUI/GoogleLatin.yml +11 -0
  67. package/vale/styles/MUI/MuiBrandName.yml +22 -0
  68. package/vale/styles/MUI/NoBritish.yml +112 -0
  69. package/vale/styles/MUI/NoCompanyName.yml +17 -0
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import { findWorkspaceDir } from '@pnpm/find-workspace-dir';
3
4
  import { $ } from 'execa';
4
5
  import * as fs from 'node:fs/promises';
5
6
  import * as path from 'node:path';
@@ -48,6 +49,7 @@ import * as semver from 'semver';
48
49
  * @property {boolean} [publicOnly=false] - Whether to filter to only public packages
49
50
  * @property {boolean} [nonPublishedOnly=false] - Whether to filter to only non-published packages. It by default means public packages yet to be published.
50
51
  * @property {string} [cwd] - Current working directory to run pnpm command in
52
+ * @property {string[]} [filter] - Same as filtering packages with --filter in pnpm. Only include packages matching the filter. See https://pnpm.io/filtering.
51
53
  */
52
54
 
53
55
  /**
@@ -73,10 +75,15 @@ import * as semver from 'semver';
73
75
  * @returns {Promise<(PrivatePackage | PublicPackage)[]>} Array of packages
74
76
  */
75
77
  export async function getWorkspacePackages(options = {}) {
76
- const { sinceRef = null, publicOnly = false, nonPublishedOnly = false } = options;
78
+ const { sinceRef = null, publicOnly = false, nonPublishedOnly = false, filter = [] } = options;
77
79
 
78
80
  // Build command with conditional filter
79
81
  const filterArg = sinceRef ? ['--filter', `...[${sinceRef}]`] : [];
82
+ if (filter.length > 0) {
83
+ filter.forEach((f) => {
84
+ filterArg.push('--filter', f);
85
+ });
86
+ }
80
87
  const result = options.cwd
81
88
  ? await $({ cwd: options.cwd })`pnpm ls -r --json --depth -1 ${filterArg}`
82
89
  : await $`pnpm ls -r --json --depth -1 ${filterArg}`;
@@ -148,11 +155,17 @@ export async function getPackageVersionInfo(packageName, baseVersion) {
148
155
  }
149
156
  }
150
157
 
158
+ /**
159
+ * @typedef {Object} PublishSummaryEntry
160
+ * @property {string} name
161
+ * @property {string} version
162
+ */
163
+
151
164
  /**
152
165
  * Publish packages with the given options
153
166
  * @param {PublicPackage[]} packages - Packages to publish
154
167
  * @param {PublishOptions} [options={}] - Publishing options
155
- * @returns {Promise<void>}
168
+ * @returns {Promise<PublishSummaryEntry[]>}
156
169
  */
157
170
  export async function publishPackages(packages, options = {}) {
158
171
  const args = [];
@@ -172,7 +185,183 @@ export async function publishPackages(packages, options = {}) {
172
185
  args.push('--no-git-checks');
173
186
  }
174
187
 
175
- await $({ stdio: 'inherit' })`pnpm -r publish --access public --tag=${tag} ${args}`;
188
+ const workspaceDir = await findWorkspaceDir(process.cwd());
189
+ if (!workspaceDir) {
190
+ throw new Error('Could not find pnpm workspace root');
191
+ }
192
+ const summaryPath = path.join(workspaceDir, 'pnpm-publish-summary.json');
193
+
194
+ // Clean up any leftover summary file from a previous run
195
+ await fs.rm(summaryPath, { force: true });
196
+
197
+ await $({
198
+ stdio: 'inherit',
199
+ env: { npm_config_loglevel: 'warn' },
200
+ })`pnpm -r publish --access public --tag=${tag} --report-summary ${args}`;
201
+
202
+ const summary = JSON.parse(await fs.readFile(summaryPath, 'utf-8'));
203
+ await fs.rm(summaryPath, { force: true });
204
+ return /** @type {PublishSummaryEntry[]} */ (summary.publishedPackages);
205
+ }
206
+
207
+ /**
208
+ * @typedef {Object} GetTransitiveDependenciesOptions
209
+ * @property {Map<string, string>} [workspacePathByName] - Map of workspace package name to directory path
210
+ * @property {boolean} [includeDev=true] - Whether to include devDependencies in the traversal
211
+ */
212
+
213
+ /**
214
+ * Get all transitive workspace dependencies for a set of packages.
215
+ *
216
+ * Only follows deps whose version spec starts with `workspace:` (e.g. `workspace:*`
217
+ * or `workspace:^`), meaning they are sourced directly from the monorepo. Pinned
218
+ * external versions (e.g. `^1.0.0`) are ignored even when the package name exists
219
+ * in the workspace. Traverses `dependencies` and optionally `devDependencies`.
220
+ * Results are cached per package so each package is read from disk at most once
221
+ * regardless of how many roots depend on it.
222
+ *
223
+ * @param {string[]} packageNames - Package names to start the traversal from
224
+ * @param {GetTransitiveDependenciesOptions} [options]
225
+ * @returns {Promise<Set<string>>} All reachable workspace package names, including the input packages themselves
226
+ */
227
+ export async function getTransitiveDependencies(packageNames, options = {}) {
228
+ const { includeDev = true, workspacePathByName = new Map() } = options;
229
+
230
+ /** @type {Map<string, Promise<Set<string>>>} */
231
+ const cache = new Map();
232
+
233
+ /**
234
+ * @param {string} packageName
235
+ * @returns {Promise<Set<string>>}
236
+ */
237
+ function collectDeps(packageName) {
238
+ const cached = cache.get(packageName);
239
+ if (cached) {
240
+ return cached;
241
+ }
242
+
243
+ const promise = (async () => {
244
+ const packagePath = workspacePathByName.get(packageName);
245
+ if (!packagePath) {
246
+ throw new Error(`Workspace "${packageName}" not found`);
247
+ }
248
+
249
+ const pkgJson = await readPackageJson(packagePath);
250
+ const allDepEntries = [
251
+ ...Object.entries(pkgJson.dependencies ?? {}),
252
+ ...(includeDev ? Object.entries(pkgJson.devDependencies ?? {}) : []),
253
+ ];
254
+ const workspaceDeps = allDepEntries
255
+ .filter(
256
+ ([dep, spec]) =>
257
+ workspacePathByName.has(dep) &&
258
+ typeof spec === 'string' &&
259
+ spec.startsWith('workspace:'),
260
+ )
261
+ .map(([dep]) => dep);
262
+
263
+ const recursiveResults = await Promise.all(workspaceDeps.map(collectDeps));
264
+ return new Set([...workspaceDeps, ...recursiveResults.flatMap((s) => [...s])]);
265
+ })();
266
+
267
+ cache.set(packageName, promise);
268
+ return promise;
269
+ }
270
+
271
+ for (const name of packageNames) {
272
+ if (!workspacePathByName.has(name)) {
273
+ throw new Error(`Workspace "${name}" not found`);
274
+ }
275
+ }
276
+
277
+ const results = await Promise.all(packageNames.map(collectDeps));
278
+ return new Set([...packageNames, ...results.flatMap((s) => [...s])]);
279
+ }
280
+
281
+ /**
282
+ * Pure validation logic: given a publish set and workspace maps, checks that all
283
+ * transitive hard workspace dependencies are covered and none are private.
284
+ *
285
+ * A hard dependency is one listed in `dependencies` (not `peerDependencies` or
286
+ * `devDependencies`) using a `workspace:` version specifier (e.g. `workspace:*` or
287
+ * `workspace:^`). Peer dependencies are never bundled and dev dependencies are not installed
288
+ * on consumer devices - both are excluded regardless of version specifier. Pinned-version
289
+ * references in `dependencies` are also excluded - they resolve from the registry and do
290
+ * not need to be co-published.
291
+ *
292
+ * @param {PublicPackage[]} packages - The packages intended for publishing
293
+ * @param {Map<string, PublicPackage | PrivatePackage>} workspacePackageByName - All workspace packages by name
294
+ * @param {Map<string, string>} workspacePathByName - Map of workspace package name to directory path
295
+ * @returns {Promise<{issues: string[]}>}
296
+ * List of human-readable issue strings. Empty when the dependency set is valid.
297
+ * @internal
298
+ */
299
+ export async function checkPublishDependencies(
300
+ packages,
301
+ workspacePackageByName,
302
+ workspacePathByName,
303
+ ) {
304
+ const publishedNames = new Set(packages.map((pkg) => pkg.name));
305
+
306
+ const transitiveDeps = await getTransitiveDependencies(
307
+ packages.map((pkg) => pkg.name),
308
+ { includeDev: false, workspacePathByName },
309
+ );
310
+
311
+ /** @type {Set<string>} */
312
+ const privateButRequired = new Set();
313
+ /** @type {Set<string>} */
314
+ const missingFromPublish = new Set();
315
+
316
+ for (const depName of transitiveDeps) {
317
+ if (publishedNames.has(depName)) {
318
+ continue;
319
+ }
320
+ const workspacePkg = workspacePackageByName.get(depName);
321
+ if (workspacePkg?.isPrivate) {
322
+ privateButRequired.add(depName);
323
+ } else {
324
+ missingFromPublish.add(depName);
325
+ }
326
+ }
327
+
328
+ /** @type {string[]} */
329
+ const issues = [];
330
+
331
+ if (privateButRequired.size > 0) {
332
+ issues.push(
333
+ `The following private workspace packages are required as dependencies but cannot be published: ${[...privateButRequired].join(', ')}`,
334
+ );
335
+ }
336
+
337
+ if (missingFromPublish.size > 0) {
338
+ issues.push(
339
+ `The following workspace packages are required as dependencies but are not included in the publish set: ${[...missingFromPublish].join(', ')}. Add them to the --filter list.`,
340
+ );
341
+ }
342
+
343
+ return { issues };
344
+ }
345
+
346
+ /**
347
+ * Validate that a set of packages covers all of their transitive hard workspace dependencies,
348
+ * and that none of those dependencies are private (which would make them unpublishable).
349
+ *
350
+ * @param {PublicPackage[]} packages - The packages intended for publishing
351
+ * @returns {Promise<{issues: string[]}>}
352
+ * List of human-readable issue strings. Empty when the dependency set is valid.
353
+ */
354
+ export async function validatePublishDependencies(packages) {
355
+ const allWorkspacePackages = await getWorkspacePackages();
356
+
357
+ const workspacePackageByName = /** @type {Map<string, PublicPackage | PrivatePackage>} */ (
358
+ new Map(allWorkspacePackages.flatMap((pkg) => (pkg.name ? [[pkg.name, pkg]] : [])))
359
+ );
360
+ const workspacePathByName = new Map(
361
+ allWorkspacePackages.flatMap((pkg) => (pkg.name ? [[pkg.name, pkg.path]] : [])),
362
+ );
363
+
364
+ return checkPublishDependencies(packages, workspacePackageByName, workspacePathByName);
176
365
  }
177
366
 
178
367
  /**