@mui/internal-code-infra 0.0.4-canary.56 → 0.0.4-canary.58
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.
- package/build/cli/cmdBuild.d.mts +1 -0
- package/build/utils/build.d.mts +58 -22
- package/package.json +4 -4
- package/src/cli/cmdBuild.mjs +39 -16
- package/src/utils/build.mjs +607 -259
- package/src/utils/build.test.mjs +740 -171
- package/src/utils/git.mjs +16 -7
package/src/utils/git.mjs
CHANGED
|
@@ -24,6 +24,10 @@ export async function getRepositoryInfo(cwd = process.cwd()) {
|
|
|
24
24
|
* @type {Set<string>}
|
|
25
25
|
*/
|
|
26
26
|
const repoRemotes = new Set();
|
|
27
|
+
/**
|
|
28
|
+
* @type {Map<string, { owner: string, repo: string }>}
|
|
29
|
+
*/
|
|
30
|
+
const validRemotes = new Map();
|
|
27
31
|
|
|
28
32
|
for (const line of lines) {
|
|
29
33
|
// Match pattern: "remoteName url (fetch|push)"
|
|
@@ -36,20 +40,25 @@ export async function getRepositoryInfo(cwd = process.cwd()) {
|
|
|
36
40
|
cause[remoteName] = `Remote is not a GitHub repository under 'mui' organization: ${url}`;
|
|
37
41
|
continue;
|
|
38
42
|
}
|
|
39
|
-
|
|
40
|
-
owner: parsed.owner,
|
|
41
|
-
|
|
42
|
-
remoteName,
|
|
43
|
-
};
|
|
43
|
+
if (!validRemotes.has(remoteName)) {
|
|
44
|
+
validRemotes.set(remoteName, { owner: parsed.owner, repo: parsed.name });
|
|
45
|
+
}
|
|
44
46
|
} catch (error) {
|
|
45
47
|
cause[remoteName] = `Failed to parse URL for remote ${remoteName}: ${url}`;
|
|
46
48
|
}
|
|
47
|
-
}
|
|
48
|
-
if (type !== '(push)') {
|
|
49
|
+
} else if (type !== '(push)') {
|
|
49
50
|
throw new Error(`Unexpected line format for "git remote -v": "${line}"`);
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
const preferredOrder = ['upstream', 'origin', ...validRemotes.keys()];
|
|
55
|
+
for (const name of preferredOrder) {
|
|
56
|
+
const match = validRemotes.get(name);
|
|
57
|
+
if (match) {
|
|
58
|
+
return { ...match, remoteName: name };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
53
62
|
throw new Error(
|
|
54
63
|
`Failed to find correct remote(s) in : ${Array.from(repoRemotes.keys()).join(', ')}`,
|
|
55
64
|
{ cause },
|