mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
The tree was a debranded snapshot of upstream taken around 2026-02-20, and upstream has moved about five months since. This replaces it with upstream master, mechanically re-derived: bin/debrand does the rename, and the pipeline and squashed migrations are restored from the shipped tree. Not a merge. The previous import replaced the tree wholesale in a single commit, so there is no shared content history to merge against. Reproducing the rename on the new tree is what actually converges. What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints, compose files, LLM.md, and insights/migrations. The squashed initial migration is load-bearing — the live database records it by name, so upstream's ~918 individual migrations cannot come back. Nine products are dropped as unreferenced. Twenty-one more that we do not run are kept anyway because the core app still imports them; unpicking those is a refactor and does not belong in a rebase. This base does not build yet, and the reasons are not in the rename: upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against our 4.2, and the dependency manifests still name upstream packages that we republish under our own names. Those are decisions, not renames.
68 lines
2.7 KiB
JavaScript
68 lines
2.7 KiB
JavaScript
#!/usr/bin/env node
|
|
import { execSync } from 'node:child_process'
|
|
import fs from 'node:fs'
|
|
import path from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
const frontendDir = path.resolve(__dirname, '..')
|
|
const reportDir = path.join(frontendDir, 'dist-report')
|
|
|
|
// Mirrors the compressed-size-action config this replaces (ci-frontend.yml):
|
|
// pattern: frontend/dist-report/**/*.js exclude: {**/_chunks/chunk*.js}
|
|
// compression: none strip-hash: -[A-Za-z0-9]{8}\.js$
|
|
// dist-report/ (built by build-bundle-report.mjs) carries the source bundle and source
|
|
// path in each filename, so a stripped hash yields a stable identity across builds.
|
|
const HASH_SUFFIX = /-[A-Za-z0-9]{8}(\.js)$/
|
|
const CHUNK_EXCLUDE = /(^|\/)_chunks\/chunk[^/]*\.js$/
|
|
|
|
function walk(dir) {
|
|
const out = []
|
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
const full = path.join(dir, entry.name)
|
|
if (entry.isDirectory()) {
|
|
out.push(...walk(full))
|
|
} else if (entry.isFile() && entry.name.endsWith('.js')) {
|
|
out.push(full)
|
|
}
|
|
}
|
|
return out
|
|
}
|
|
|
|
if (!fs.existsSync(reportDir)) {
|
|
console.error(
|
|
`Bundle size report: ${reportDir} not found — run build-bundle-report.mjs first (build:with-report does).`
|
|
)
|
|
process.exit(1)
|
|
}
|
|
|
|
const files = []
|
|
for (const full of walk(reportDir)) {
|
|
const identity = path.relative(reportDir, full).split(path.sep).join('/').replace(HASH_SUFFIX, '$1')
|
|
if (CHUNK_EXCLUDE.test(identity)) {
|
|
continue
|
|
}
|
|
files.push({ file: identity, bytes: fs.statSync(full).size })
|
|
}
|
|
files.sort((a, b) => a.file.localeCompare(b.file))
|
|
|
|
const report = { files, total: files.reduce((sum, f) => sum + f.bytes, 0) }
|
|
|
|
// The sha convention matches eager-graph-report: compressed-size-action's replacement
|
|
// builds the PR branch AND the base branch in the same workspace, so the plain filename
|
|
// holds the LAST build's numbers (the base's) and doubles as the vs-base baseline, while
|
|
// the sha-suffixed file identifies the PR build's own report.
|
|
try {
|
|
report.sha = execSync('git rev-parse HEAD', { cwd: frontendDir, encoding: 'utf-8' }).trim()
|
|
} catch (err) {
|
|
console.error(`Could not resolve HEAD sha for the bundle size report: ${err.message}`)
|
|
}
|
|
|
|
const serialized = JSON.stringify(report, null, 2)
|
|
fs.writeFileSync(path.join(frontendDir, 'bundle-size-report.json'), serialized)
|
|
if (report.sha) {
|
|
fs.writeFileSync(path.join(frontendDir, `bundle-size-report-${report.sha}.json`), serialized)
|
|
}
|
|
|
|
console.info(`Bundle size report: ${files.length} files, ${(report.total / 1024 / 1024).toFixed(2)} MiB total`)
|