@mui/internal-code-infra 0.0.3-canary.49 → 0.0.3-canary.50
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/utils/git.d.mts +26 -0
- package/build/utils/pnpm.d.mts +0 -5
- package/package.json +4 -4
- package/src/cli/cmdPublish.mjs +2 -62
- package/src/cli/cmdPublishCanary.mjs +1 -25
- package/src/utils/git.mjs +67 -0
- package/src/utils/pnpm.mjs +0 -9
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {Object} RepoInfo
|
|
3
|
+
* @property {string} owner - Repository owner
|
|
4
|
+
* @property {string} repo - Repository name
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Get current repository info from git remote
|
|
8
|
+
* @param {string[]} [remotes=['upstream', 'origin']] - Remote name(s) to check (default: ['upstream', 'origin'])
|
|
9
|
+
* @returns {Promise<RepoInfo>} Repository owner and name
|
|
10
|
+
*/
|
|
11
|
+
export function getRepositoryInfo(remotes?: string[]): Promise<RepoInfo>;
|
|
12
|
+
/**
|
|
13
|
+
* Get current git SHA
|
|
14
|
+
* @returns {Promise<string>} Current git commit SHA
|
|
15
|
+
*/
|
|
16
|
+
export function getCurrentGitSha(): Promise<string>;
|
|
17
|
+
export type RepoInfo = {
|
|
18
|
+
/**
|
|
19
|
+
* - Repository owner
|
|
20
|
+
*/
|
|
21
|
+
owner: string;
|
|
22
|
+
/**
|
|
23
|
+
* - Repository name
|
|
24
|
+
*/
|
|
25
|
+
repo: string;
|
|
26
|
+
};
|
package/build/utils/pnpm.d.mts
CHANGED
|
@@ -124,11 +124,6 @@ export function readPackageJson(packagePath: string): Promise<import("../cli/pac
|
|
|
124
124
|
* @returns {Promise<void>}
|
|
125
125
|
*/
|
|
126
126
|
export function writePackageJson(packagePath: string, packageJson: Object): Promise<void>;
|
|
127
|
-
/**
|
|
128
|
-
* Get current git SHA
|
|
129
|
-
* @returns {Promise<string>} Current git commit SHA
|
|
130
|
-
*/
|
|
131
|
-
export function getCurrentGitSha(): Promise<string>;
|
|
132
127
|
/**
|
|
133
128
|
* Resolve a package@version specifier to an exact version
|
|
134
129
|
* @param {string} packageSpec - Package specifier in format "package@version"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-code-infra",
|
|
3
|
-
"version": "0.0.3-canary.
|
|
3
|
+
"version": "0.0.3-canary.50",
|
|
4
4
|
"description": "Infra scripts and configs to be used across MUI repos.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -101,9 +101,9 @@
|
|
|
101
101
|
"stylelint-config-standard": "^39.0.1",
|
|
102
102
|
"typescript-eslint": "^8.46.3",
|
|
103
103
|
"yargs": "^18.0.0",
|
|
104
|
-
"@mui/internal-babel-plugin-
|
|
104
|
+
"@mui/internal-babel-plugin-resolve-imports": "2.0.7-canary.28",
|
|
105
105
|
"@mui/internal-babel-plugin-minify-errors": "2.0.8-canary.11",
|
|
106
|
-
"@mui/internal-babel-plugin-
|
|
106
|
+
"@mui/internal-babel-plugin-display-name": "1.0.4-canary.8"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
109
|
"@next/eslint-plugin-next": "*",
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"publishConfig": {
|
|
141
141
|
"access": "public"
|
|
142
142
|
},
|
|
143
|
-
"gitSha": "
|
|
143
|
+
"gitSha": "c98d146c72fd9e4db92810432a550a4b2c530de9",
|
|
144
144
|
"scripts": {
|
|
145
145
|
"build": "tsc -p tsconfig.build.json",
|
|
146
146
|
"typescript": "tsc -p tsconfig.json",
|
package/src/cli/cmdPublish.mjs
CHANGED
|
@@ -13,12 +13,12 @@ import { Octokit } from '@octokit/rest';
|
|
|
13
13
|
import chalk from 'chalk';
|
|
14
14
|
import envCI from 'env-ci';
|
|
15
15
|
import { $ } from 'execa';
|
|
16
|
-
import gitUrlParse from 'git-url-parse';
|
|
17
16
|
import * as fs from 'node:fs/promises';
|
|
18
17
|
import * as semver from 'semver';
|
|
19
18
|
|
|
20
19
|
import { persistentAuthStrategy } from '../utils/github.mjs';
|
|
21
20
|
import { getWorkspacePackages, publishPackages } from '../utils/pnpm.mjs';
|
|
21
|
+
import { getCurrentGitSha, getRepositoryInfo } from '../utils/git.mjs';
|
|
22
22
|
|
|
23
23
|
const isCI = envCI().isCi;
|
|
24
24
|
|
|
@@ -126,66 +126,6 @@ async function checkGitHubReleaseExists(owner, repo, version) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
/**
|
|
130
|
-
* Get current repository info from git remote
|
|
131
|
-
* @param {string[]} [remotes=['origin']] - Remote name(s) to check (default: 'origin')
|
|
132
|
-
* @returns {Promise<{owner: string, repo: string}>} Repository owner and name
|
|
133
|
-
*/
|
|
134
|
-
async function getRepositoryInfo(remotes = ['origin']) {
|
|
135
|
-
/**
|
|
136
|
-
* @type {{owner: string, repo: string} | undefined}
|
|
137
|
-
*/
|
|
138
|
-
let result;
|
|
139
|
-
/**
|
|
140
|
-
* @type {Record<string, any>}
|
|
141
|
-
*/
|
|
142
|
-
const cause = {};
|
|
143
|
-
|
|
144
|
-
for (let i = 0; i < remotes.length; i += 1) {
|
|
145
|
-
const remote = remotes[i];
|
|
146
|
-
try {
|
|
147
|
-
// eslint-disable-next-line no-await-in-loop
|
|
148
|
-
const cliResult = await $`git remote get-url ${remote}`;
|
|
149
|
-
const url = cliResult.stdout.trim();
|
|
150
|
-
|
|
151
|
-
const parsed = gitUrlParse(url);
|
|
152
|
-
if (parsed.source !== 'github.com' && parsed.owner !== 'mui') {
|
|
153
|
-
cause[remote] = { message: `Unsupported git remote URL: ${url}` };
|
|
154
|
-
continue;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
result = {
|
|
158
|
-
owner: parsed.owner,
|
|
159
|
-
repo: parsed.name,
|
|
160
|
-
};
|
|
161
|
-
break; // break as soon as we have a valid result
|
|
162
|
-
} catch (/** @type {any} */ error) {
|
|
163
|
-
const execaError = /** @type {import('execa').ExecaError} */ (error);
|
|
164
|
-
if (
|
|
165
|
-
i < remotes.length - 1 &&
|
|
166
|
-
typeof execaError.stderr === 'string' &&
|
|
167
|
-
execaError.stderr.includes('No such remote')
|
|
168
|
-
) {
|
|
169
|
-
continue; // Try next remote
|
|
170
|
-
}
|
|
171
|
-
cause[remote] = error;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (!result) {
|
|
175
|
-
throw new Error(`Failed to find remote`, { cause });
|
|
176
|
-
}
|
|
177
|
-
return result;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* Get current git SHA
|
|
182
|
-
* @returns {Promise<string>} Current git commit SHA
|
|
183
|
-
*/
|
|
184
|
-
async function getCurrentGitSha() {
|
|
185
|
-
const result = await $`git rev-parse HEAD`;
|
|
186
|
-
return result.stdout.trim();
|
|
187
|
-
}
|
|
188
|
-
|
|
189
129
|
/**
|
|
190
130
|
* Create and push a git tag
|
|
191
131
|
* @param {string} version - Version to tag
|
|
@@ -423,7 +363,7 @@ Please run the command "${chalk.bold('pnpm code-infra publish-new-package')}" fi
|
|
|
423
363
|
return;
|
|
424
364
|
}
|
|
425
365
|
console.log('✅ No new packages found, proceeding...');
|
|
426
|
-
const repoInfo = await getRepositoryInfo(
|
|
366
|
+
const repoInfo = await getRepositoryInfo();
|
|
427
367
|
console.log(`📂 Repository: ${repoInfo.owner}/${repoInfo.repo}`);
|
|
428
368
|
const params = {
|
|
429
369
|
owner: repoInfo.owner,
|
|
@@ -12,11 +12,9 @@ import path from 'node:path';
|
|
|
12
12
|
import { createActionAuth } from '@octokit/auth-action';
|
|
13
13
|
import { Octokit } from '@octokit/rest';
|
|
14
14
|
import { $ } from 'execa';
|
|
15
|
-
import gitUrlParse from 'git-url-parse';
|
|
16
15
|
import * as semver from 'semver';
|
|
17
16
|
|
|
18
17
|
import {
|
|
19
|
-
getCurrentGitSha,
|
|
20
18
|
getPackageVersionInfo,
|
|
21
19
|
getWorkspacePackages,
|
|
22
20
|
publishPackages,
|
|
@@ -24,6 +22,7 @@ import {
|
|
|
24
22
|
semverMax,
|
|
25
23
|
writePackageJson,
|
|
26
24
|
} from '../utils/pnpm.mjs';
|
|
25
|
+
import { getCurrentGitSha, getRepositoryInfo } from '../utils/git.mjs';
|
|
27
26
|
|
|
28
27
|
/**
|
|
29
28
|
* @typedef {Object} Args
|
|
@@ -41,29 +40,6 @@ function getOctokit() {
|
|
|
41
40
|
return new Octokit({ authStrategy: createActionAuth });
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
/**
|
|
45
|
-
* Get current repository info from git remote
|
|
46
|
-
* @returns {Promise<{owner: string, repo: string}>} Repository owner and name
|
|
47
|
-
*/
|
|
48
|
-
async function getRepositoryInfo() {
|
|
49
|
-
try {
|
|
50
|
-
const result = await $`git remote get-url origin`;
|
|
51
|
-
const url = result.stdout.trim();
|
|
52
|
-
|
|
53
|
-
const parsed = gitUrlParse(url);
|
|
54
|
-
if (parsed.source !== 'github.com') {
|
|
55
|
-
throw new Error('Repository is not hosted on GitHub');
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
owner: parsed.owner,
|
|
60
|
-
repo: parsed.name,
|
|
61
|
-
};
|
|
62
|
-
} catch (/** @type {any} */ error) {
|
|
63
|
-
throw new Error(`Failed to get repository info: ${error.message}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
43
|
/**
|
|
68
44
|
* @typedef {Object} Commit
|
|
69
45
|
* @property {string} sha - Commit SHA
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { $ } from 'execa';
|
|
2
|
+
import gitUrlParse from 'git-url-parse';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} RepoInfo
|
|
6
|
+
* @property {string} owner - Repository owner
|
|
7
|
+
* @property {string} repo - Repository name
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Get current repository info from git remote
|
|
12
|
+
* @param {string[]} [remotes=['upstream', 'origin']] - Remote name(s) to check (default: ['upstream', 'origin'])
|
|
13
|
+
* @returns {Promise<RepoInfo>} Repository owner and name
|
|
14
|
+
*/
|
|
15
|
+
export async function getRepositoryInfo(remotes = ['upstream', 'origin']) {
|
|
16
|
+
/**
|
|
17
|
+
* @type {Record<string, string>}
|
|
18
|
+
*/
|
|
19
|
+
const cause = {};
|
|
20
|
+
const cliResult = $`git remote -v`;
|
|
21
|
+
/**
|
|
22
|
+
* @type {Map<string, string>}
|
|
23
|
+
*/
|
|
24
|
+
const repoRemotes = new Map();
|
|
25
|
+
|
|
26
|
+
for await (const line of cliResult) {
|
|
27
|
+
// Match pattern: "remoteName url (fetch|push)"
|
|
28
|
+
const [remoteName, url, type] = line.trim().split(/\s+/, 3);
|
|
29
|
+
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;
|
|
47
|
+
}
|
|
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}`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
throw new Error(`Failed to find remote(s): ${remotes.join(', ')}`, { cause });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get current git SHA
|
|
62
|
+
* @returns {Promise<string>} Current git commit SHA
|
|
63
|
+
*/
|
|
64
|
+
export async function getCurrentGitSha() {
|
|
65
|
+
const result = await $`git rev-parse HEAD`;
|
|
66
|
+
return result.stdout.trim();
|
|
67
|
+
}
|
package/src/utils/pnpm.mjs
CHANGED
|
@@ -193,15 +193,6 @@ export async function writePackageJson(packagePath, packageJson) {
|
|
|
193
193
|
await fs.writeFile(path.join(packagePath, 'package.json'), content);
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
/**
|
|
197
|
-
* Get current git SHA
|
|
198
|
-
* @returns {Promise<string>} Current git commit SHA
|
|
199
|
-
*/
|
|
200
|
-
export async function getCurrentGitSha() {
|
|
201
|
-
const result = await $`git rev-parse HEAD`;
|
|
202
|
-
return result.stdout.trim();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
196
|
/**
|
|
206
197
|
* Resolve a package@version specifier to an exact version
|
|
207
198
|
* @param {string} packageSpec - Package specifier in format "package@version"
|