@mui/internal-code-infra 0.1.1-canary.24 → 0.1.1-canary.25

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.
@@ -35,6 +35,10 @@ export type Args = {
35
35
  * - Whether to skip checking for main field in package.json.
36
36
  */
37
37
  skipMainCheck: boolean;
38
+ /**
39
+ * - Whether to skip validating the output directory with publint.
40
+ */
41
+ skipPublint: boolean;
38
42
  /**
39
43
  * - Globs to be ignored by Babel.
40
44
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-code-infra",
3
- "version": "0.1.1-canary.24",
3
+ "version": "0.1.1-canary.25",
4
4
  "author": "MUI Team",
5
5
  "description": "Infra scripts and configs to be used across MUI repos.",
6
6
  "license": "MIT",
@@ -116,6 +116,7 @@
116
116
  "node-html-parser": "^9.0.5",
117
117
  "open": "^11.0.4",
118
118
  "postcss-styled-syntax": "^0.7.4",
119
+ "publint": "^0.3.25",
119
120
  "regexp.escape": "^2.0.1",
120
121
  "rehype-slug": "^6.0.0",
121
122
  "rehype-stringify": "^10.0.1",
@@ -191,7 +192,7 @@
191
192
  "publishConfig": {
192
193
  "access": "public"
193
194
  },
194
- "gitSha": "d14c1ec7e620c0bf10d09090e718ff376a8a190d",
195
+ "gitSha": "80d3ec0d49901ddda4af788aeb3b1b51e21c07cc",
195
196
  "scripts": {
196
197
  "build": "tsc -p tsconfig.build.json",
197
198
  "typescript": "tsc -noEmit",
@@ -28,6 +28,7 @@ import { readPnpmConfig } from '../utils/pnpm.mjs';
28
28
  * @property {boolean} skipBabelRuntimeCheck - Whether to skip checking for Babel runtime dependencies in the package.
29
29
  * @property {boolean} skipPackageJson - Whether to skip generating the package.json file in the bundle output.
30
30
  * @property {boolean} skipMainCheck - Whether to skip checking for main field in package.json.
31
+ * @property {boolean} skipPublint - Whether to skip validating the output directory with publint.
31
32
  * @property {string[]} ignore - Globs to be ignored by Babel.
32
33
  * @property {string[]} [copy] - Files/Directories to be copied. Can be a glob pattern.
33
34
  * @property {boolean} [enableReactCompiler] - Whether to use the React compiler.
@@ -216,6 +217,11 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
216
217
  default: false,
217
218
  description: 'Skip checking for main field in package.json.',
218
219
  })
220
+ .option('skipPublint', {
221
+ type: 'boolean',
222
+ default: false,
223
+ description: 'Skip validating the output directory with publint.',
224
+ })
219
225
  .option('copy', {
220
226
  type: 'string',
221
227
  array: true,
@@ -392,9 +398,48 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
392
398
  buildDir,
393
399
  verbose: args.verbose,
394
400
  });
401
+
402
+ if (!args.skipPublint) {
403
+ await validateWithPublint(buildDir);
404
+ }
395
405
  },
396
406
  });
397
407
 
408
+ /**
409
+ * Lints the output directory with publint. Errors fail the build, warnings are only reported.
410
+ * @param {string} buildDir - The build directory to validate.
411
+ * @returns {Promise<void>}
412
+ */
413
+ async function validateWithPublint(buildDir) {
414
+ const [{ publint }, { formatMessage }] = await Promise.all([
415
+ import('publint'),
416
+ import('publint/utils'),
417
+ ]);
418
+ // Everything in the output directory is published, so there is nothing to pack.
419
+ const result = await publint({ pkgDir: buildDir, pack: false, level: 'warning' });
420
+ const { pkg } = result;
421
+ // TODO: remove this filter and bump publint to >=0.3.25, which ships the fix from
422
+ // https://github.com/publint/publint/pull/265 (publint checks `browser` values
423
+ // that point at another package as local files).
424
+ const messages = result.messages.filter((message) => {
425
+ if (message.code !== 'FILE_DOES_NOT_EXIST' || message.path[0] !== 'browser') {
426
+ return true;
427
+ }
428
+ const value = message.path.length === 2 ? pkg.browser?.[message.path[1]] : undefined;
429
+ return typeof value !== 'string' || value.startsWith('.');
430
+ });
431
+
432
+ for (const message of messages) {
433
+ const log = message.type === 'error' ? console.error : console.warn;
434
+ log(`publint ${message.type}: ${formatMessage(message, pkg)}`);
435
+ }
436
+
437
+ const errorCount = messages.filter((message) => message.type === 'error').length;
438
+ if (errorCount > 0) {
439
+ throw new Error(`publint found ${errorCount} error(s) in "${buildDir}".`);
440
+ }
441
+ }
442
+
398
443
  /**
399
444
  * @param {Object} param0
400
445
  * @param {string} param0.cwd - The current working directory.