forked from mirrors/misskey
chore(dev): refactor frontend bundle report
This commit is contained in:
parent
e12f97b1d8
commit
1173550784
2 changed files with 2 additions and 11 deletions
10
.github/scripts/frontend-js-size.mjs
vendored
10
.github/scripts/frontend-js-size.mjs
vendored
|
|
@ -530,19 +530,13 @@ function renderFrontendBundleReport(before, after) {
|
|||
return lines.join('\n');
|
||||
}
|
||||
|
||||
function renderVisualizerArtifactLink() {
|
||||
const artifactUrl = process.env.FRONTEND_BUNDLE_REPORT_ARTIFACT_URL;
|
||||
const artifactName = process.env.FRONTEND_BUNDLE_REPORT_ARTIFACT_NAME || 'frontend-bundle-report';
|
||||
const htmlFile = process.env.FRONTEND_BUNDLE_REPORT_HTML_FILE || 'frontend-bundle-visualizer.html';
|
||||
return `> [Bundle visualizer HTML](${artifactUrl}) is included in the ${code(artifactName)} artifact as ${code(htmlFile)}.`;
|
||||
}
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const [beforeDir, afterDir, beforeStatsFile, afterStatsFile, outFile] = args;
|
||||
const before = await collectReport(beforeDir);
|
||||
const after = await collectReport(afterDir);
|
||||
const beforeStats = JSON.parse(await fs.readFile(beforeStatsFile, 'utf8'));
|
||||
const afterStats = JSON.parse(await fs.readFile(afterStatsFile, 'utf8'));
|
||||
const visualizerArtifactLink = `> [Bundle visualizer HTML](${process.env.FRONTEND_BUNDLE_REPORT_ARTIFACT_URL}) is included in the ${code('frontend-bundle-visualizer')} artifact as ${code('frontend-bundle-visualizer.html')}.`;
|
||||
|
||||
const body = [
|
||||
marker,
|
||||
|
|
@ -555,7 +549,7 @@ const body = [
|
|||
'',
|
||||
renderFrontendBundleReport(collectVisualizerReport(beforeStats), collectVisualizerReport(afterStats)),
|
||||
'',
|
||||
renderVisualizerArtifactLink(),
|
||||
visualizerArtifactLink,
|
||||
].join('\n');
|
||||
|
||||
await fs.writeFile(outFile, body);
|
||||
|
|
|
|||
3
.github/workflows/frontend-bundle-report.yml
vendored
3
.github/workflows/frontend-bundle-report.yml
vendored
|
|
@ -141,8 +141,6 @@ jobs:
|
|||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
FRONTEND_BUNDLE_REPORT_ARTIFACT_URL: ${{ steps.upload-bundle-visualizer.outputs.artifact-url }}
|
||||
FRONTEND_BUNDLE_REPORT_ARTIFACT_NAME: frontend-bundle-visualizer
|
||||
FRONTEND_BUNDLE_REPORT_HTML_FILE: frontend-bundle-visualizer.html
|
||||
run: |
|
||||
REPORT_DIR="$RUNNER_TEMP/frontend-bundle-report"
|
||||
node after/.github/scripts/frontend-js-size.mjs before after "$REPORT_DIR/before-stats.json" "$REPORT_DIR/after-stats.json" "$REPORT_DIR/frontend-js-size-report.md"
|
||||
|
|
@ -157,7 +155,6 @@ jobs:
|
|||
REPORT_DIR="$RUNNER_TEMP/frontend-bundle-report"
|
||||
test -s "$REPORT_DIR/before-stats.json"
|
||||
test -s "$REPORT_DIR/after-stats.json"
|
||||
test -s "$REPORT_DIR/frontend-bundle-visualizer.html"
|
||||
test -s "$REPORT_DIR/frontend-js-size-report.md"
|
||||
cat "$REPORT_DIR/frontend-js-size-report.md" >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue