@mui/internal-bundle-size-checker 1.1.1-canary.1 → 1.1.1-canary.3
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/ciReport.d.ts +2 -0
- package/build/uploadSnapshot.d.ts +11 -0
- package/package.json +3 -3
- package/src/ciReport.js +2 -0
- package/src/uploadSnapshot.js +21 -11
package/build/ciReport.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { z } from 'zod/v4';
|
|
|
9
9
|
export declare function ciReportUploadSchema(type: string, version: number, reportSchema: z.ZodType): z.ZodObject<{
|
|
10
10
|
version: z.ZodLiteral<number>;
|
|
11
11
|
timestamp: z.ZodNumber;
|
|
12
|
+
commitTimestamp: z.ZodOptional<z.ZodNumber>;
|
|
12
13
|
commitSha: z.ZodString;
|
|
13
14
|
repo: z.ZodString;
|
|
14
15
|
reportType: z.ZodLiteral<string>;
|
|
@@ -19,6 +20,7 @@ export declare function ciReportUploadSchema(type: string, version: number, repo
|
|
|
19
20
|
export declare const sizeSnapshotUploadSchema: z.ZodObject<{
|
|
20
21
|
version: z.ZodLiteral<number>;
|
|
21
22
|
timestamp: z.ZodNumber;
|
|
23
|
+
commitTimestamp: z.ZodOptional<z.ZodNumber>;
|
|
22
24
|
commitSha: z.ZodString;
|
|
23
25
|
repo: z.ZodString;
|
|
24
26
|
reportType: z.ZodLiteral<string>;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
export type NormalizedUploadConfig = import('./types.js').NormalizedUploadConfig;
|
|
2
|
+
export type Commit = {
|
|
3
|
+
/**
|
|
4
|
+
* - The full commit SHA
|
|
5
|
+
*/
|
|
6
|
+
sha: string;
|
|
7
|
+
/**
|
|
8
|
+
* - The commit's time in milliseconds, which orders it in the
|
|
9
|
+
* dashboard's timeline
|
|
10
|
+
*/
|
|
11
|
+
timestamp: number;
|
|
12
|
+
};
|
|
2
13
|
/**
|
|
3
14
|
* Uploads the size snapshot to S3
|
|
4
15
|
* @param {string} snapshotPath - The path to the size snapshot JSON file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/internal-bundle-size-checker",
|
|
3
|
-
"version": "1.1.1-canary.
|
|
3
|
+
"version": "1.1.1-canary.3",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "Bundle size checker for MUI packages.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"micromatch": "^4.0.8",
|
|
37
37
|
"piscina": "^5.3.2",
|
|
38
38
|
"rollup-plugin-visualizer": "^7.1.1",
|
|
39
|
-
"vite": "^8.3.
|
|
39
|
+
"vite": "^8.3.2",
|
|
40
40
|
"yargs": "^18.2.0",
|
|
41
41
|
"zod": "^4.6.5"
|
|
42
42
|
},
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@types/micromatch": "4.0.10",
|
|
46
46
|
"@types/yargs": "17.0.35"
|
|
47
47
|
},
|
|
48
|
-
"gitSha": "
|
|
48
|
+
"gitSha": "52b7be572a556459d18a7ebfd71ed5f3b8d8d3e7",
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsc -p tsconfig.build.json",
|
|
51
51
|
"test": "pnpm -w test --project @mui/internal-bundle-size-checker",
|
package/src/ciReport.js
CHANGED
|
@@ -11,6 +11,8 @@ export function ciReportUploadSchema(type, version, reportSchema) {
|
|
|
11
11
|
return z.object({
|
|
12
12
|
version: z.literal(version),
|
|
13
13
|
timestamp: z.number(),
|
|
14
|
+
/** When the commit was made, in milliseconds: what orders it in the dashboard's timeline. */
|
|
15
|
+
commitTimestamp: z.number().optional(),
|
|
14
16
|
commitSha: z.string().regex(/^[0-9a-f]{40}$/, 'Must be a 40-character hex string'),
|
|
15
17
|
repo: z.string().includes('/', 'Must be in owner/repo format'),
|
|
16
18
|
reportType: z.literal(type),
|
package/src/uploadSnapshot.js
CHANGED
|
@@ -6,12 +6,21 @@ import { execa } from 'execa';
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
9
|
+
* @typedef {object} Commit
|
|
10
|
+
* @property {string} sha - The full commit SHA
|
|
11
|
+
* @property {number} timestamp - The commit's time in milliseconds, which orders it in the
|
|
12
|
+
* dashboard's timeline
|
|
11
13
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Looks up a commit's SHA and time.
|
|
17
|
+
* @param {string} ref - The commit, by SHA or any other revision
|
|
18
|
+
* @returns {Promise<Commit>}
|
|
19
|
+
*/
|
|
20
|
+
async function getCommit(ref) {
|
|
21
|
+
const { stdout } = await execa('git', ['log', '-1', '--format=%H %ct', ref]);
|
|
22
|
+
const [sha, time] = stdout.trim().split(' ');
|
|
23
|
+
return { sha, timestamp: Number(time) * 1000 };
|
|
15
24
|
}
|
|
16
25
|
|
|
17
26
|
/**
|
|
@@ -19,15 +28,16 @@ async function getCurrentCommitSHA() {
|
|
|
19
28
|
* @param {string} apiUrl - Base URL of the CI report API
|
|
20
29
|
* @param {Buffer} fileContent - The file content to upload
|
|
21
30
|
* @param {NormalizedUploadConfig} uploadConfig - The normalized upload configuration
|
|
22
|
-
* @param {
|
|
31
|
+
* @param {Commit} commit - The commit the snapshot is of
|
|
23
32
|
* @returns {Promise<{key:string}>}
|
|
24
33
|
*/
|
|
25
|
-
async function uploadViaApi(apiUrl, fileContent, uploadConfig,
|
|
34
|
+
async function uploadViaApi(apiUrl, fileContent, uploadConfig, commit) {
|
|
26
35
|
/** @type {import('./ciReport.js').SizeSnapshotUpload} */
|
|
27
36
|
const requestBody = {
|
|
28
37
|
version: 1,
|
|
29
38
|
timestamp: Date.now(),
|
|
30
|
-
|
|
39
|
+
commitTimestamp: commit.timestamp,
|
|
40
|
+
commitSha: commit.sha,
|
|
31
41
|
repo: uploadConfig.repo,
|
|
32
42
|
reportType: 'size-snapshot',
|
|
33
43
|
branch: uploadConfig.branch,
|
|
@@ -71,10 +81,10 @@ async function uploadViaApi(apiUrl, fileContent, uploadConfig, sha) {
|
|
|
71
81
|
*/
|
|
72
82
|
export async function uploadSnapshot(snapshotPath, uploadConfig, commitSha) {
|
|
73
83
|
// Run git operations and file reading in parallel
|
|
74
|
-
const [
|
|
75
|
-
commitSha ||
|
|
84
|
+
const [commit, fileContent] = await Promise.all([
|
|
85
|
+
getCommit(commitSha || 'HEAD'),
|
|
76
86
|
fs.promises.readFile(snapshotPath),
|
|
77
87
|
]);
|
|
78
88
|
|
|
79
|
-
return uploadViaApi(uploadConfig.apiUrl, fileContent, uploadConfig,
|
|
89
|
+
return uploadViaApi(uploadConfig.apiUrl, fileContent, uploadConfig, commit);
|
|
80
90
|
}
|