@mui/internal-code-infra 0.0.3-canary.6 → 0.0.3-canary.61

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 (99) hide show
  1. package/README.md +55 -0
  2. package/build/babel-config.d.mts +40 -0
  3. package/build/brokenLinksChecker/index.d.mts +138 -0
  4. package/build/cli/cmdArgosPush.d.mts +13 -0
  5. package/build/cli/cmdBuild.d.mts +56 -0
  6. package/build/cli/cmdCopyFiles.d.mts +20 -0
  7. package/build/cli/cmdExtractErrorCodes.d.mts +3 -0
  8. package/build/cli/cmdGithubAuth.d.mts +6 -0
  9. package/build/cli/cmdListWorkspaces.d.mts +18 -0
  10. package/build/cli/cmdPublish.d.mts +27 -0
  11. package/build/cli/cmdPublishCanary.d.mts +30 -0
  12. package/build/cli/cmdPublishNewPackage.d.mts +8 -0
  13. package/build/cli/cmdSetVersionOverrides.d.mts +9 -0
  14. package/build/cli/cmdValidateBuiltTypes.d.mts +2 -0
  15. package/build/cli/index.d.mts +1 -0
  16. package/build/eslint/baseConfig.d.mts +10 -0
  17. package/build/eslint/docsConfig.d.mts +4 -0
  18. package/build/eslint/extensions.d.mts +8 -0
  19. package/build/eslint/index.d.mts +4 -0
  20. package/build/eslint/jsonConfig.d.mts +4 -0
  21. package/build/eslint/material-ui/config.d.mts +8 -0
  22. package/build/eslint/material-ui/index.d.mts +2 -0
  23. package/build/eslint/material-ui/rules/disallow-active-element-as-key-event-target.d.mts +5 -0
  24. package/build/eslint/material-ui/rules/disallow-react-api-in-server-components.d.mts +2 -0
  25. package/build/eslint/material-ui/rules/docgen-ignore-before-comment.d.mts +2 -0
  26. package/build/eslint/material-ui/rules/mui-name-matches-component-name.d.mts +5 -0
  27. package/build/eslint/material-ui/rules/no-empty-box.d.mts +5 -0
  28. package/build/eslint/material-ui/rules/no-restricted-resolved-imports.d.mts +12 -0
  29. package/build/eslint/material-ui/rules/no-styled-box.d.mts +5 -0
  30. package/build/eslint/material-ui/rules/rules-of-use-theme-variants.d.mts +9 -0
  31. package/build/eslint/material-ui/rules/straight-quotes.d.mts +5 -0
  32. package/build/eslint/testConfig.d.mts +14 -0
  33. package/build/markdownlint/duplicate-h1.d.mts +27 -0
  34. package/build/markdownlint/git-diff.d.mts +8 -0
  35. package/build/markdownlint/index.d.mts +56 -0
  36. package/build/markdownlint/straight-quotes.d.mts +8 -0
  37. package/build/markdownlint/table-alignment.d.mts +8 -0
  38. package/build/markdownlint/terminal-language.d.mts +8 -0
  39. package/build/prettier.d.mts +20 -0
  40. package/build/stylelint/index.d.mts +32 -0
  41. package/build/utils/babel.d.mts +71 -0
  42. package/build/utils/build.d.mts +50 -0
  43. package/build/utils/changelog.d.mts +64 -0
  44. package/build/utils/credentials.d.mts +17 -0
  45. package/build/utils/extractErrorCodes.d.mts +19 -0
  46. package/build/utils/git.d.mts +26 -0
  47. package/build/utils/github.d.mts +41 -0
  48. package/build/utils/pnpm.d.mts +238 -0
  49. package/build/utils/typescript.d.mts +35 -0
  50. package/package.json +92 -42
  51. package/src/babel-config.mjs +52 -8
  52. package/src/brokenLinksChecker/__fixtures__/static-site/broken-links.html +20 -0
  53. package/src/brokenLinksChecker/__fixtures__/static-site/broken-targets.html +22 -0
  54. package/src/brokenLinksChecker/__fixtures__/static-site/example.md +9 -0
  55. package/src/brokenLinksChecker/__fixtures__/static-site/external-links.html +21 -0
  56. package/src/brokenLinksChecker/__fixtures__/static-site/ignored-page.html +17 -0
  57. package/src/brokenLinksChecker/__fixtures__/static-site/index.html +26 -0
  58. package/src/brokenLinksChecker/__fixtures__/static-site/known-targets.json +5 -0
  59. package/src/brokenLinksChecker/__fixtures__/static-site/nested/page.html +19 -0
  60. package/src/brokenLinksChecker/__fixtures__/static-site/orphaned-page.html +20 -0
  61. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-api-links.html +20 -0
  62. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-custom-targets.html +24 -0
  63. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-ignored-content.html +28 -0
  64. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-known-target-links.html +19 -0
  65. package/src/brokenLinksChecker/__fixtures__/static-site/valid.html +20 -0
  66. package/src/brokenLinksChecker/__fixtures__/static-site/with-anchors.html +31 -0
  67. package/src/brokenLinksChecker/index.mjs +641 -0
  68. package/src/brokenLinksChecker/index.test.ts +178 -0
  69. package/src/cli/cmdArgosPush.mjs +13 -2
  70. package/src/cli/cmdBuild.mjs +228 -31
  71. package/src/cli/cmdGithubAuth.mjs +36 -0
  72. package/src/cli/cmdListWorkspaces.mjs +2 -2
  73. package/src/cli/cmdPublish.mjs +203 -49
  74. package/src/cli/cmdPublishCanary.mjs +404 -46
  75. package/src/cli/cmdPublishNewPackage.mjs +86 -0
  76. package/src/cli/cmdSetVersionOverrides.mjs +17 -1
  77. package/src/cli/cmdValidateBuiltTypes.mjs +49 -0
  78. package/src/cli/index.mjs +6 -2
  79. package/src/cli/packageJson.d.ts +729 -0
  80. package/src/eslint/baseConfig.mjs +96 -78
  81. package/src/eslint/docsConfig.mjs +26 -13
  82. package/src/eslint/extensions.mjs +8 -8
  83. package/src/eslint/jsonConfig.mjs +40 -0
  84. package/src/eslint/material-ui/config.mjs +8 -9
  85. package/src/eslint/material-ui/rules/mui-name-matches-component-name.mjs +4 -2
  86. package/src/eslint/material-ui/rules/rules-of-use-theme-variants.mjs +2 -1
  87. package/src/eslint/testConfig.mjs +72 -66
  88. package/src/stylelint/index.mjs +46 -0
  89. package/src/untyped-plugins.d.ts +13 -0
  90. package/src/{cli → utils}/babel.mjs +10 -3
  91. package/src/utils/build.mjs +27 -1
  92. package/src/utils/changelog.mjs +157 -0
  93. package/src/utils/credentials.mjs +71 -0
  94. package/src/utils/extractErrorCodes.mjs +2 -2
  95. package/src/utils/git.mjs +67 -0
  96. package/src/utils/github.mjs +263 -0
  97. package/src/{cli → utils}/pnpm.mjs +23 -13
  98. package/src/{cli → utils}/typescript.mjs +13 -7
  99. package/src/cli/cmdJsonLint.mjs +0 -69
@@ -31,6 +31,7 @@ import * as semver from 'semver';
31
31
  * @typedef {Object} PublishOptions
32
32
  * @property {boolean} [dryRun] - Whether to run in dry-run mode
33
33
  * @property {boolean} [noGitChecks] - Whether to skip git checks
34
+ * @property {string} [tag] - NPM dist tag to publish to
34
35
  */
35
36
 
36
37
  /**
@@ -45,6 +46,7 @@ import * as semver from 'semver';
45
46
  * @typedef {Object} GetWorkspacePackagesOptions
46
47
  * @property {string|null} [sinceRef] - Git reference to filter changes since
47
48
  * @property {boolean} [publicOnly=false] - Whether to filter to only public packages
49
+ * @property {boolean} [nonPublishedOnly=false] - Whether to filter to only non-published packages. It by default means public packages yet to be published.
48
50
  */
49
51
 
50
52
  /**
@@ -55,6 +57,10 @@ import * as semver from 'semver';
55
57
  * @returns {Promise<PublicPackage[]>} Array of packages
56
58
  *
57
59
  * @overload
60
+ * @param {{ nonPublishedOnly: true } & GetWorkspacePackagesOptions} [options={}] - Options for filtering packages
61
+ * @returns {Promise<PublicPackage[]>} Array of packages
62
+ *
63
+ * @overload
58
64
  * @param {{ publicOnly?: false | undefined } & GetWorkspacePackagesOptions} [options={}] - Options for filtering packages
59
65
  * @returns {Promise<PrivatePackage[]>} Array of packages
60
66
  *
@@ -66,7 +72,7 @@ import * as semver from 'semver';
66
72
  * @returns {Promise<(PrivatePackage | PublicPackage)[]>} Array of packages
67
73
  */
68
74
  export async function getWorkspacePackages(options = {}) {
69
- const { sinceRef = null, publicOnly = false } = options;
75
+ const { sinceRef = null, publicOnly = false, nonPublishedOnly = false } = options;
70
76
 
71
77
  // Build command with conditional filter
72
78
  const filterArg = sinceRef ? ['--filter', `...[${sinceRef}]`] : [];
@@ -90,6 +96,19 @@ export async function getWorkspacePackages(options = {}) {
90
96
  ];
91
97
  });
92
98
 
99
+ if (nonPublishedOnly) {
100
+ // Check if any of the packages are new/need manual publishing first.
101
+ const filteredPublicPackages = filteredPackages.filter((pkg) => !pkg.isPrivate);
102
+
103
+ const results = await Promise.all(
104
+ filteredPublicPackages.map(async (pkg) => {
105
+ const url = `${process.env.npm_config_registry || 'https://registry.npmjs.org'}/${pkg.name}`;
106
+ return fetch(url).then((res) => res.status === 404);
107
+ }),
108
+ );
109
+ return filteredPublicPackages.filter((_pkg, index) => !!results[index]);
110
+ }
111
+
93
112
  return filteredPackages;
94
113
  }
95
114
 
@@ -129,12 +148,12 @@ export async function getPackageVersionInfo(packageName, baseVersion) {
129
148
  /**
130
149
  * Publish packages with the given options
131
150
  * @param {PublicPackage[]} packages - Packages to publish
132
- * @param {string} tag - npm tag to publish with
133
151
  * @param {PublishOptions} [options={}] - Publishing options
134
152
  * @returns {Promise<void>}
135
153
  */
136
- export async function publishPackages(packages, tag, options = {}) {
154
+ export async function publishPackages(packages, options = {}) {
137
155
  const args = [];
156
+ const tag = options.tag ?? 'latest';
138
157
 
139
158
  // Add package filters
140
159
  packages.forEach((pkg) => {
@@ -156,7 +175,7 @@ export async function publishPackages(packages, tag, options = {}) {
156
175
  /**
157
176
  * Read package.json from a directory
158
177
  * @param {string} packagePath - Path to package directory
159
- * @returns {Promise<Object>} Parsed package.json content
178
+ * @returns {Promise<import('../cli/packageJson').PackageJson>} Parsed package.json content
160
179
  */
161
180
  export async function readPackageJson(packagePath) {
162
181
  const content = await fs.readFile(path.join(packagePath, 'package.json'), 'utf8');
@@ -174,15 +193,6 @@ export async function writePackageJson(packagePath, packageJson) {
174
193
  await fs.writeFile(path.join(packagePath, 'package.json'), content);
175
194
  }
176
195
 
177
- /**
178
- * Get current git SHA
179
- * @returns {Promise<string>} Current git commit SHA
180
- */
181
- export async function getCurrentGitSha() {
182
- const result = await $`git rev-parse HEAD`;
183
- return result.stdout.trim();
184
- }
185
-
186
196
  /**
187
197
  * Resolve a package@version specifier to an exact version
188
198
  * @param {string} packageSpec - Package specifier in format "package@version"
@@ -8,6 +8,7 @@ import { globby } from 'globby';
8
8
  import * as fs from 'node:fs/promises';
9
9
  import * as os from 'node:os';
10
10
  import * as path from 'node:path';
11
+ import { mapConcurrently } from '../utils/build.mjs';
11
12
 
12
13
  const $$ = $({ stdio: 'inherit' });
13
14
 
@@ -27,7 +28,8 @@ export async function emitDeclarations(tsconfig, outDir) {
27
28
  --emitDeclarationOnly
28
29
  --noEmit false
29
30
  --composite false
30
- --incremental false`;
31
+ --incremental false
32
+ --declarationMap false`;
31
33
  }
32
34
 
33
35
  /**
@@ -80,8 +82,9 @@ async function postProcessDeclarations({ directory }) {
80
82
  [pluginRemoveImports, { test: /\.css$/ }],
81
83
  ];
82
84
 
83
- await Promise.all(
84
- dtsFiles.map(async (dtsFile) => {
85
+ await mapConcurrently(
86
+ dtsFiles,
87
+ async (dtsFile) => {
85
88
  const result = await babel.transformFileAsync(dtsFile, {
86
89
  configFile: false,
87
90
  plugins: babelPlugins,
@@ -92,7 +95,8 @@ async function postProcessDeclarations({ directory }) {
92
95
  } else {
93
96
  console.error('failed to transform', dtsFile);
94
97
  }
95
- }),
98
+ },
99
+ 20,
96
100
  );
97
101
  }
98
102
 
@@ -107,11 +111,13 @@ async function renameDeclarations({ directory }) {
107
111
  return;
108
112
  }
109
113
  console.log(`Renaming d.ts files to d.mts in ${directory}`);
110
- await Promise.all(
111
- dtsFiles.map(async (dtsFile) => {
114
+ await mapConcurrently(
115
+ dtsFiles,
116
+ async (dtsFile) => {
112
117
  const newFileName = dtsFile.replace(/\.d\.ts$/, '.d.mts');
113
118
  await fs.rename(dtsFile, newFileName);
114
- }),
119
+ },
120
+ 20,
115
121
  );
116
122
  }
117
123
 
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import chalk from 'chalk';
4
- import fs from 'node:fs/promises';
5
- import { globby } from 'globby';
6
- import path from 'node:path';
7
- import { mapConcurrently } from '../utils/build.mjs';
8
-
9
- /**
10
- * @typedef {Object} Args
11
- * @property {boolean} [silent] Run in silent mode without logging
12
- */
13
-
14
- /**
15
- * @param {string} message
16
- * @returns {string}
17
- */
18
- const passMessage = (message) => `✓ ${chalk.gray(message)}`;
19
- /**
20
- * @param {string} message
21
- * @returns {string}
22
- */
23
- const failMessage = (message) => `❌ ${chalk.whiteBright(message)}`;
24
-
25
- export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
26
- command: 'jsonlint',
27
- describe: 'Lint JSON files',
28
- builder: (yargs) => {
29
- return yargs.option('silent', {
30
- type: 'boolean',
31
- default: false,
32
- description: "Don't log file names.",
33
- });
34
- },
35
- handler: async (args) => {
36
- const cwd = process.cwd();
37
-
38
- const filenames = await globby('**/*.json', {
39
- cwd,
40
- gitignore: true,
41
- ignoreFiles: ['.lintignore'],
42
- ignore: ['**/tsconfig*.json'],
43
- followSymbolicLinks: false,
44
- });
45
-
46
- let passed = true;
47
-
48
- await mapConcurrently(
49
- filenames,
50
- async (filename) => {
51
- const content = await fs.readFile(path.join(cwd, filename), { encoding: 'utf8' });
52
- try {
53
- JSON.parse(content);
54
- if (!args.silent) {
55
- // eslint-disable-next-line no-console
56
- console.log(passMessage(filename));
57
- }
58
- } catch (error) {
59
- passed = false;
60
- console.error(failMessage(`Error parsing ${filename}:\n\n${String(error)}`));
61
- }
62
- },
63
- 20,
64
- );
65
- if (!passed) {
66
- throw new Error('❌ At least one file did not pass. Check the console output');
67
- }
68
- },
69
- });