@mui/internal-code-infra 0.0.3-canary.62 → 0.0.3-canary.64

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.
@@ -2,13 +2,13 @@
2
2
  * @typedef {Object} RepoInfo
3
3
  * @property {string} owner - Repository owner
4
4
  * @property {string} repo - Repository name
5
+ * @property {string} remoteName - Remote name
5
6
  */
6
7
  /**
7
8
  * Get current repository info from git remote
8
- * @param {string[]} [remotes=['upstream', 'origin']] - Remote name(s) to check (default: ['upstream', 'origin'])
9
9
  * @returns {Promise<RepoInfo>} Repository owner and name
10
10
  */
11
- export function getRepositoryInfo(remotes?: string[]): Promise<RepoInfo>;
11
+ export function getRepositoryInfo(): Promise<RepoInfo>;
12
12
  /**
13
13
  * Get current git SHA
14
14
  * @returns {Promise<string>} Current git commit SHA
@@ -23,4 +23,8 @@ export type RepoInfo = {
23
23
  * - Repository name
24
24
  */
25
25
  repo: string;
26
+ /**
27
+ * - Remote name
28
+ */
29
+ remoteName: string;
26
30
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-code-infra",
3
- "version": "0.0.3-canary.62",
3
+ "version": "0.0.3-canary.64",
4
4
  "description": "Infra scripts and configs to be used across MUI repos.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -61,14 +61,14 @@
61
61
  "@eslint/compat": "^2.0.0",
62
62
  "@eslint/js": "^9.39.1",
63
63
  "@eslint/json": "^0.14.0",
64
- "@inquirer/confirm": "^5.1.21",
64
+ "@inquirer/confirm": "^6.0.3",
65
65
  "@inquirer/select": "^5.0.2",
66
66
  "@napi-rs/keyring": "^1.2.0",
67
67
  "@octokit/auth-action": "^6.0.2",
68
68
  "@octokit/oauth-methods": "^6.0.2",
69
69
  "@octokit/rest": "^22.0.1",
70
70
  "@pnpm/find-workspace-dir": "^1000.1.3",
71
- "@vitest/eslint-plugin": "^1.5.1",
71
+ "@vitest/eslint-plugin": "^1.6.4",
72
72
  "babel-plugin-optimize-clsx": "^2.6.2",
73
73
  "babel-plugin-react-compiler": "^1.0.0",
74
74
  "babel-plugin-transform-inline-environment-variables": "^0.4.4",
@@ -103,9 +103,9 @@
103
103
  "stylelint-config-standard": "^39.0.1",
104
104
  "typescript-eslint": "^8.49.0",
105
105
  "yargs": "^18.0.0",
106
- "@mui/internal-babel-plugin-minify-errors": "2.0.8-canary.13",
106
+ "@mui/internal-babel-plugin-display-name": "1.0.4-canary.8",
107
107
  "@mui/internal-babel-plugin-resolve-imports": "2.0.7-canary.28",
108
- "@mui/internal-babel-plugin-display-name": "1.0.4-canary.8"
108
+ "@mui/internal-babel-plugin-minify-errors": "2.0.8-canary.13"
109
109
  },
110
110
  "peerDependencies": {
111
111
  "@next/eslint-plugin-next": "*",
@@ -142,7 +142,7 @@
142
142
  "publishConfig": {
143
143
  "access": "public"
144
144
  },
145
- "gitSha": "d9cf3df228aa4a3e7a7b1663bad0d7167f40d22c",
145
+ "gitSha": "dbef881bae7f3202ea876354b83af83f8970559a",
146
146
  "scripts": {
147
147
  "build": "tsc -p tsconfig.build.json",
148
148
  "typescript": "tsc -p tsconfig.json",
@@ -2,6 +2,7 @@ import { Octokit } from '@octokit/rest';
2
2
  import { $ } from 'execa';
3
3
 
4
4
  import { persistentAuthStrategy } from './github.mjs';
5
+ import { getRepositoryInfo } from './git.mjs';
5
6
 
6
7
  /**
7
8
  * @typedef {import('@octokit/rest').Octokit} OctokitType
@@ -39,8 +40,10 @@ export async function findLatestTaggedVersion(opts) {
39
40
  const $$ = $({ cwd: opts.cwd });
40
41
  const fetchAll = opts.fetchAll ?? true;
41
42
  if (fetchAll) {
42
- // Fetch all tags from all remotes to ensure we have the latest tags.
43
- await $$`git fetch --tags --all`;
43
+ const { remoteName } = await getRepositoryInfo();
44
+ // Fetch all tags from the mui remote to ensure we have the latest tags.
45
+ // --force to update any existing tags that may have changed to avoid the clobering error.
46
+ await $$`git fetch --tags --force ${remoteName}`;
44
47
  }
45
48
  const { stdout } = await $$`git describe --tags --abbrev=0 --match ${'v*'}`; // only include "version-tags"
46
49
  return stdout.trim();
package/src/utils/git.mjs CHANGED
@@ -5,56 +5,54 @@ import gitUrlParse from 'git-url-parse';
5
5
  * @typedef {Object} RepoInfo
6
6
  * @property {string} owner - Repository owner
7
7
  * @property {string} repo - Repository name
8
+ * @property {string} remoteName - Remote name
8
9
  */
9
10
 
10
11
  /**
11
12
  * Get current repository info from git remote
12
- * @param {string[]} [remotes=['upstream', 'origin']] - Remote name(s) to check (default: ['upstream', 'origin'])
13
13
  * @returns {Promise<RepoInfo>} Repository owner and name
14
14
  */
15
- export async function getRepositoryInfo(remotes = ['upstream', 'origin']) {
15
+ export async function getRepositoryInfo() {
16
16
  /**
17
17
  * @type {Record<string, string>}
18
18
  */
19
19
  const cause = {};
20
- const cliResult = $`git remote -v`;
20
+ const { stdout } = await $`git remote -v`;
21
+ const lines = stdout.trim().split('\n');
21
22
  /**
22
- * @type {Map<string, string>}
23
+ * @type {Set<string>}
23
24
  */
24
- const repoRemotes = new Map();
25
+ const repoRemotes = new Set();
25
26
 
26
- for await (const line of cliResult) {
27
+ for (const line of lines) {
27
28
  // Match pattern: "remoteName url (fetch|push)"
28
29
  const [remoteName, url, type] = line.trim().split(/\s+/, 3);
30
+ repoRemotes.add(remoteName);
29
31
  if (type === '(fetch)') {
30
- repoRemotes.set(remoteName, url);
31
- } else if (type !== '(push)') {
32
- throw new Error(`Unexpected line format for "git remote -v": "${line}"`);
33
- }
34
- }
35
-
36
- for (const remote of remotes) {
37
- if (!repoRemotes.has(remote)) {
38
- cause[remote] = 'Remote not found';
39
- continue;
40
- }
41
- const url = /** @type {string} */ (repoRemotes.get(remote));
42
- try {
43
- const parsed = gitUrlParse(url);
44
- if (parsed.source !== 'github.com' || parsed.owner !== 'mui') {
45
- cause[remote] = `Remote is not a GitHub repository under 'mui' organization: ${url}`;
46
- continue;
32
+ try {
33
+ const parsed = gitUrlParse(url);
34
+ if (parsed.source !== 'github.com' || parsed.owner !== 'mui') {
35
+ cause[remoteName] = `Remote is not a GitHub repository under 'mui' organization: ${url}`;
36
+ continue;
37
+ }
38
+ return {
39
+ owner: parsed.owner,
40
+ repo: parsed.name,
41
+ remoteName,
42
+ };
43
+ } catch (error) {
44
+ cause[remoteName] = `Failed to parse URL for remote ${remoteName}: ${url}`;
47
45
  }
48
- return {
49
- owner: parsed.owner,
50
- repo: parsed.name,
51
- };
52
- } catch (error) {
53
- cause[remote] = `Failed to parse URL for remote ${remote}: ${url}`;
46
+ }
47
+ if (type !== '(push)') {
48
+ throw new Error(`Unexpected line format for "git remote -v": "${line}"`);
54
49
  }
55
50
  }
56
51
 
57
- throw new Error(`Failed to find remote(s): ${remotes.join(', ')}`, { cause });
52
+ throw new Error(
53
+ `Failed to find correct remote(s) in : ${Array.from(repoRemotes.keys()).join(', ')}`,
54
+ { cause },
55
+ );
58
56
  }
59
57
 
60
58
  /**