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

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 (53) hide show
  1. package/build/utils/git.d.mts +7 -0
  2. package/package.json +5 -3
  3. package/src/cli/cmdPublish.mjs +40 -5
  4. package/src/utils/git.mjs +11 -0
  5. package/src/brokenLinksChecker/__fixtures__/static-site/broken-links.html +0 -20
  6. package/src/brokenLinksChecker/__fixtures__/static-site/broken-targets.html +0 -22
  7. package/src/brokenLinksChecker/__fixtures__/static-site/example.md +0 -20
  8. package/src/brokenLinksChecker/__fixtures__/static-site/external-links.html +0 -21
  9. package/src/brokenLinksChecker/__fixtures__/static-site/ignored-page.html +0 -17
  10. package/src/brokenLinksChecker/__fixtures__/static-site/index.html +0 -29
  11. package/src/brokenLinksChecker/__fixtures__/static-site/invalid-html.html +0 -15
  12. package/src/brokenLinksChecker/__fixtures__/static-site/known-targets.json +0 -5
  13. package/src/brokenLinksChecker/__fixtures__/static-site/nested/page.html +0 -21
  14. package/src/brokenLinksChecker/__fixtures__/static-site/orphaned-page.html +0 -20
  15. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-api-links.html +0 -20
  16. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-custom-targets.html +0 -24
  17. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-ignored-content.html +0 -28
  18. package/src/brokenLinksChecker/__fixtures__/static-site/page-with-known-target-links.html +0 -19
  19. package/src/brokenLinksChecker/__fixtures__/static-site/unclosed-tags.html +0 -1
  20. package/src/brokenLinksChecker/__fixtures__/static-site/valid.html +0 -20
  21. package/src/brokenLinksChecker/__fixtures__/static-site/with-anchors.html +0 -31
  22. package/src/brokenLinksChecker/index.test.ts +0 -301
  23. package/src/changelog/categorizeCommits.test.ts +0 -319
  24. package/src/changelog/filterCommits.test.ts +0 -363
  25. package/src/changelog/parseCommitLabels.test.ts +0 -509
  26. package/src/changelog/renderChangelog.test.ts +0 -378
  27. package/src/changelog/sortSections.test.ts +0 -199
  28. package/src/cli/cmdVale.test.mjs +0 -644
  29. package/src/eslint/mui/rules/add-undef-to-optional.test.mjs +0 -361
  30. package/src/eslint/mui/rules/consistent-production-guard.test.mjs +0 -162
  31. package/src/eslint/mui/rules/disallow-active-elements-as-key-event-target.test.mjs +0 -66
  32. package/src/eslint/mui/rules/disallow-react-api-in-server-components.test.mjs +0 -305
  33. package/src/eslint/mui/rules/docgen-ignore-before-comment.test.mjs +0 -52
  34. package/src/eslint/mui/rules/flatten-parentheses.test.mjs +0 -245
  35. package/src/eslint/mui/rules/mui-name-matches-component-name.test.mjs +0 -247
  36. package/src/eslint/mui/rules/no-empty-box.test.mjs +0 -40
  37. package/src/eslint/mui/rules/no-floating-cleanup.test.mjs +0 -141
  38. package/src/eslint/mui/rules/no-guarded-throw.test.mjs +0 -206
  39. package/src/eslint/mui/rules/no-presentation-role.test.mjs +0 -33
  40. package/src/eslint/mui/rules/no-styled-box.test.mjs +0 -73
  41. package/src/eslint/mui/rules/require-dev-wrapper.test.mjs +0 -265
  42. package/src/eslint/mui/rules/rules-of-use-theme-variants.test.mjs +0 -149
  43. package/src/eslint/mui/rules/straight-quotes.test.mjs +0 -67
  44. package/src/remark/firstBlockHeading.test.mjs +0 -107
  45. package/src/remark/gitDiff.test.mjs +0 -45
  46. package/src/remark/noSpaceInLinks.test.mjs +0 -22
  47. package/src/remark/straightQuotes.test.mjs +0 -25
  48. package/src/remark/tableAlignment.test.mjs +0 -28
  49. package/src/remark/terminalLanguage.test.mjs +0 -17
  50. package/src/utils/build.test.mjs +0 -1263
  51. package/src/utils/pnpm.test.mjs +0 -731
  52. package/src/utils/template.test.mjs +0 -133
  53. package/src/utils/typescript.test.mjs +0 -341
@@ -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.72",
3
+ "version": "0.0.4-canary.74",
4
4
  "author": "MUI Team",
5
5
  "description": "Infra scripts and configs to be used across MUI repos.",
6
6
  "license": "MIT",
@@ -181,12 +181,14 @@
181
181
  "src",
182
182
  "vale",
183
183
  "README.md",
184
- "LICENSE"
184
+ "LICENSE",
185
+ "!src/**/__fixtures__/**",
186
+ "!src/**/*.test.*"
185
187
  ],
186
188
  "publishConfig": {
187
189
  "access": "public"
188
190
  },
189
- "gitSha": "d5f96b89b5b960ad6272652eb2734ddb305a85ae",
191
+ "gitSha": "76639fa2eabf73261070fa2a6a964209de10688d",
190
192
  "scripts": {
191
193
  "build": "tsgo -p tsconfig.build.json",
192
194
  "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
 
@@ -143,8 +143,19 @@ async function checkGitHubReleaseExists(owner, repo, version) {
143
143
  */
144
144
  async function createGitTag(version, dryRun = false) {
145
145
  const tagName = `v${version}`;
146
+ // The CI smoke-test runs with a read-only token that can't push. It sets this
147
+ // so we tolerate the push failure explicitly, instead of assuming any dry-run
148
+ // permission error is expected.
149
+ const isPublishTest = process.env.IS_PUBLISH_TEST === 'true';
146
150
 
147
151
  try {
152
+ // Skip if the tag already exists locally. Tag creation is local and fails if it exists.
153
+ const { stdout: existingTag } = await $`git tag -l ${tagName}`;
154
+ if (existingTag.trim()) {
155
+ console.log(`🏷️ Git tag ${tagName} already exists, skipping`);
156
+ return;
157
+ }
158
+
148
159
  await $({
149
160
  env: {
150
161
  ...process.env,
@@ -152,10 +163,28 @@ async function createGitTag(version, dryRun = false) {
152
163
  GIT_COMMITTER_EMAIL: 'code-infra@mui.com',
153
164
  },
154
165
  })`git tag -a ${tagName} -m ${`Version ${version}`}`;
155
- const pushArgs = dryRun ? ['--dry-run'] : [];
156
- await $({ stdio: 'inherit' })`git push origin ${tagName} ${pushArgs}`;
157
166
 
158
- console.log(`🏷️ Created and pushed git tag ${tagName}${dryRun ? ' (dry-run)' : ''}`);
167
+ if (dryRun) {
168
+ // `git push --dry-run` still authenticates and needs push access. When the token
169
+ // can push, validate it for real; when it can't, only tolerate the failure if this
170
+ // is an explicit publish smoke-test and the error is a genuine permission denial.
171
+ try {
172
+ // Don't inherit stdio so stderr is captured and matchable below.
173
+ await $`git push origin ${tagName} --dry-run`;
174
+ console.log(`🏷️ Created git tag ${tagName} (dry-run)`);
175
+ } catch (/** @type {any} */ pushError) {
176
+ const message = pushError.stderr || pushError.message || '';
177
+ if (isPublishTest && /permission|403|denied/i.test(message)) {
178
+ console.log(`🏷️ Created git tag ${tagName} (dry-run, no push permission, skipped push)`);
179
+ return;
180
+ }
181
+ throw pushError;
182
+ }
183
+ return;
184
+ }
185
+ await $({ stdio: 'inherit' })`git push origin ${tagName}`;
186
+
187
+ console.log(`🏷️ Created and pushed git tag ${tagName}`);
159
188
  } catch (/** @type {any} */ error) {
160
189
  throw new Error(`Failed to create git tag: ${error.message}`);
161
190
  }
@@ -365,7 +394,13 @@ export default /** @type {import('yargs').CommandModule<{}, Args>} */ ({
365
394
  console.log(`✅ Published ${pkg.name}@${pkg.version}`);
366
395
  });
367
396
 
368
- await createGitTag(version, dryRun);
397
+ // Tag the root version when it's new. Arbitrary package publishes that don't
398
+ // bump the root version don't create a new tag, so skip in that case.
399
+ if (await remoteGitTagExists(`v${version}`)) {
400
+ console.log(`ℹ️ Git tag v${version} already exists, skipping tag creation.`);
401
+ } else {
402
+ await createGitTag(version, dryRun);
403
+ }
369
404
 
370
405
  // Create GitHub release or git tag after successful npm publishing
371
406
  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
+ }
@@ -1,20 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Page with Broken Links</title>
7
- </head>
8
- <body>
9
- <h1>Page with Broken Links</h1>
10
- <p>This page contains links to non-existent pages.</p>
11
- <nav>
12
- <ul>
13
- <li><a href="/">Home (valid)</a></li>
14
- <li><a href="/does-not-exist.html">This page does not exist</a></li>
15
- <li><a href="/another-missing-page.html">Another missing page</a></li>
16
- <li><a href="/valid.html">Valid link</a></li>
17
- </ul>
18
- </nav>
19
- </body>
20
- </html>
@@ -1,22 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Page with Broken Targets</title>
7
- </head>
8
- <body>
9
- <h1>Page with Broken Targets</h1>
10
- <p>This page contains links to valid pages but with invalid hash targets.</p>
11
- <nav>
12
- <ul>
13
- <li><a href="/">Home (valid)</a></li>
14
- <li><a href="/with-anchors.html#section1">Valid anchor</a></li>
15
- <li><a href="/with-anchors.html#nonexistent">Non-existent anchor</a></li>
16
- <li><a href="/valid.html#missing-target">Valid page, missing target</a></li>
17
- <li><a href="/with-anchors.html#section2">Another valid anchor</a></li>
18
- <li><a href="/with-anchors.html#also-missing">Also missing</a></li>
19
- </ul>
20
- </nav>
21
- </body>
22
- </html>
@@ -1,20 +0,0 @@
1
- # Example Markdown File
2
-
3
- This is a markdown file with links:
4
-
5
- - [Link to valid page](/valid.html)
6
- - [Link to page with anchors](/with-anchors.html#section1)
7
- - [Broken markdown link](/broken-from-markdown.html)
8
- - [Relative link to valid page](valid.html)
9
- - [Relative link with dot-slash](./with-anchors.html)
10
- - [Relative broken link](broken-relative.html)
11
-
12
- ## Markdown Section
13
-
14
- This section has an anchor target (`#markdown-section`) generated by rehype-slug.
15
-
16
- This is a code block with a link that should NOT be extracted:
17
-
18
- ```html
19
- <a href="/this-should-not-be-checked.html">Link in code block</a>
20
- ```
@@ -1,21 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Page with External Links</title>
7
- </head>
8
- <body>
9
- <h1>Page with External Links</h1>
10
- <p>This page contains external links that should be ignored.</p>
11
- <nav>
12
- <ul>
13
- <li><a href="/">Home (valid internal)</a></li>
14
- <li><a href="https://example.com">External link 1</a></li>
15
- <li><a href="https://github.com/mui">External link 2</a></li>
16
- <li><a href="http://localhost:9999/fake">External localhost</a></li>
17
- <li><a href="/valid.html">Valid internal link</a></li>
18
- </ul>
19
- </nav>
20
- </body>
21
- </html>
@@ -1,17 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Ignored Page</title>
7
- </head>
8
- <body>
9
- <h1>Ignored Page</h1>
10
- <p>This page should be ignored by the crawler.</p>
11
- <nav>
12
- <ul>
13
- <li><a href="/this-link-should-not-be-checked.html">Should not be checked</a></li>
14
- </ul>
15
- </nav>
16
- </body>
17
- </html>
@@ -1,29 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Test Site Home</title>
7
- </head>
8
- <body>
9
- <h1>Test Site Home</h1>
10
- <nav>
11
- <ul>
12
- <li><a href="/valid.html">Valid Page</a></li>
13
- <li><a href="/with-anchors.html">Page with Anchors</a></li>
14
- <li><a href="/broken-links.html">Page with Broken Links</a></li>
15
- <li><a href="/broken-targets.html">Page with Broken Targets</a></li>
16
- <li><a href="/external-links.html">Page with External Links</a></li>
17
- <li><a href="/nested/page.html">Nested Page</a></li>
18
- <li><a href="/ignored-page.html">Ignored Page</a></li>
19
- <li><a href="/page-with-ignored-content.html">Page with Ignored Content</a></li>
20
- <li><a href="/page-with-custom-targets.html">Page with Custom Targets</a></li>
21
- <li><a href="/page-with-known-target-links.html">Page with Known Target Links</a></li>
22
- <li><a href="/page-with-api-links.html">Page with API Links</a></li>
23
- <li><a href="/example.md">Example Markdown</a></li>
24
- <li><a href="/unclosed-tags.html">Page with Unclosed Tags</a></li>
25
- <li><a href="/invalid-html.html">Invalid HTML Page</a></li>
26
- </ul>
27
- </nav>
28
- </body>
29
- </html>
@@ -1,15 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <title>Invalid HTML Page</title>
6
- </head>
7
- <body>
8
- <h1>Invalid HTML</h1>
9
- <!-- Duplicate ID (violates no-duplicate-id rule) -->
10
- <div id="dup">First</div>
11
- <div id="dup">Second</div>
12
- <!-- Raw ampersand (violates no-raw-characters rule) -->
13
- <p>Tom & Jerry</p>
14
- </body>
15
- </html>
@@ -1,5 +0,0 @@
1
- {
2
- "targets": {
3
- "/api-page.html": ["#method1", "#method2", "#method3"]
4
- }
5
- }
@@ -1,21 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Nested Page</title>
7
- </head>
8
- <body>
9
- <h1>Nested Page</h1>
10
- <p>This is a page in a nested directory.</p>
11
- <nav>
12
- <ul>
13
- <li><a href="/">Home</a></li>
14
- <li><a href="/valid.html">Valid page</a></li>
15
- <li><a href="/with-anchors.html#section1">Link to anchor</a></li>
16
- <li><a href="../valid.html">Relative link to valid page</a></li>
17
- <li><a href="../broken-relative-html.html">Relative broken link from HTML</a></li>
18
- </ul>
19
- </nav>
20
- </body>
21
- </html>
@@ -1,20 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Orphaned Page</title>
7
- </head>
8
- <body>
9
- <h1>Orphaned Page</h1>
10
- <p>This page is not linked from anywhere and can only be discovered via seedUrls.</p>
11
- <nav>
12
- <ul>
13
- <li><a href="/valid.html">Valid Page</a></li>
14
- <li><a href="/valid.html/">Valid Page with trailing slash</a></li>
15
- <li><a href="/orphaned-broken-link.html">Broken link from orphaned page</a></li>
16
- <li><a href="/example.md">Markdown file with HTML snippet</a></li>
17
- </ul>
18
- </nav>
19
- </body>
20
- </html>
@@ -1,20 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Page with API Links</title>
7
- </head>
8
- <body>
9
- <h1>Page with API Links</h1>
10
- <p>This page links to API documentation with known targets.</p>
11
- <nav>
12
- <ul>
13
- <li><a href="/">Home</a></li>
14
- <li><a href="/api-page.html#method1">API Method 1 (known)</a></li>
15
- <li><a href="/api-page.html#method2">API Method 2 (known)</a></li>
16
- <li><a href="/api-page.html#unknown-method">Unknown API method</a></li>
17
- </ul>
18
- </nav>
19
- </body>
20
- </html>
@@ -1,24 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Page with Custom Targets</title>
7
- </head>
8
- <body>
9
- <h1>Page with Custom Targets</h1>
10
- <nav>
11
- <ul>
12
- <li><a href="/">Home</a></li>
13
- <li><a href="#custom-id">Link to custom ID</a></li>
14
- <li><a href="#__should-be-ignored">Link to ignored ID</a></li>
15
- </ul>
16
- </nav>
17
- <section id="custom-id">
18
- <h2>Custom ID Section</h2>
19
- </section>
20
- <section id="__should-be-ignored">
21
- <h2>This target should be ignored</h2>
22
- </section>
23
- </body>
24
- </html>
@@ -1,28 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Page with Ignored Content</title>
7
- </head>
8
- <body>
9
- <h1>Page with Ignored Content</h1>
10
- <nav>
11
- <ul>
12
- <li><a href="/">Home</a></li>
13
- </ul>
14
- </nav>
15
- <aside class="sidebar">
16
- <h2>Sidebar (should be ignored)</h2>
17
- <ul>
18
- <li><a href="/sidebar-broken-link.html">Broken link in sidebar</a></li>
19
- </ul>
20
- </aside>
21
- <main>
22
- <p>Main content</p>
23
- <p>
24
- <a href="/broken-link-with-sidebar-class.html" class="sidebar">Link with sidebar class directly</a>
25
- </p>
26
- </main>
27
- </body>
28
- </html>
@@ -1,19 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Page with Known Target Links</title>
7
- </head>
8
- <body>
9
- <h1>Page with Known Target Links</h1>
10
- <p>This page links to external pages with known targets.</p>
11
- <nav>
12
- <ul>
13
- <li><a href="/">Home</a></li>
14
- <li><a href="/external-page.html#valid-target">Valid external target</a></li>
15
- <li><a href="/external-page.html#invalid-target">Invalid external target</a></li>
16
- </ul>
17
- </nav>
18
- </body>
19
- </html>
@@ -1 +0,0 @@
1
- <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Unclosed Tags</title></head><body><div class="wrapper"><main class="content"><a href="/broken-inside-unclosed-main.html">Broken link inside unclosed main</a><a href="/valid.html">Valid link inside unclosed main</a></main></div></body></html>
@@ -1,20 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Valid Page</title>
7
- </head>
8
- <body>
9
- <h1>Valid Page</h1>
10
- <p>This page has only valid internal links.</p>
11
- <nav>
12
- <ul>
13
- <li><a href="/">Home</a></li>
14
- <li><a href="/with-anchors.html#section1">Link to section 1</a></li>
15
- <li><a href="/with-anchors.html#section2">Link to section 2</a></li>
16
- <li><a href="/nested/page.html">Nested page</a></li>
17
- </ul>
18
- </nav>
19
- </body>
20
- </html>
@@ -1,31 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Page with Anchors</title>
7
- </head>
8
- <body>
9
- <h1>Page with Anchors</h1>
10
- <nav>
11
- <ul>
12
- <li><a href="/">Home</a></li>
13
- <li><a href="#section1">Jump to section 1</a></li>
14
- <li><a href="#section2">Jump to section 2</a></li>
15
- <li><a href="#section3">Jump to section 3</a></li>
16
- </ul>
17
- </nav>
18
- <section id="section1">
19
- <h2>Section 1</h2>
20
- <p>Content for section 1</p>
21
- </section>
22
- <section id="section2">
23
- <h2>Section 2</h2>
24
- <p>Content for section 2</p>
25
- </section>
26
- <section id="section3">
27
- <h2>Section 3</h2>
28
- <p>Content for section 3</p>
29
- </section>
30
- </body>
31
- </html>