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.
110 lines
2.9 KiB
JavaScript
110 lines
2.9 KiB
JavaScript
#!/usr/bin/env node
|
|
import { spawnSync } from 'child_process'
|
|
import fs from 'fs'
|
|
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
const scriptPath = fileURLToPath(import.meta.url)
|
|
const frontendDir = path.resolve(path.dirname(scriptPath), '..')
|
|
const repoRoot = path.resolve(frontendDir, '..')
|
|
const localKeaTypegenBin = path.resolve(
|
|
frontendDir,
|
|
'node_modules',
|
|
'.bin',
|
|
process.platform === 'win32' ? 'kea-typegen.cmd' : 'kea-typegen'
|
|
)
|
|
|
|
const { fileArg, passthroughArgs } = parseArgs(process.argv.slice(2))
|
|
|
|
if (!fileArg) {
|
|
console.error('Usage: pnpm --filter=@hanzo/frontend typegen:file <logic-file> [kea-typegen options]')
|
|
process.exit(1)
|
|
}
|
|
|
|
const resolvedFile = resolveFile(fileArg)
|
|
|
|
if (!resolvedFile) {
|
|
console.error(`Could not find logic file: ${fileArg}`)
|
|
console.error('Checked paths relative to the current directory, pnpm INIT_CWD, frontend/, and the repo root.')
|
|
process.exit(1)
|
|
}
|
|
|
|
const nodeOptions = process.env.NODE_OPTIONS?.includes('--max-old-space-size')
|
|
? process.env.NODE_OPTIONS
|
|
: [process.env.NODE_OPTIONS, '--max-old-space-size=4096'].filter(Boolean).join(' ')
|
|
|
|
const result = spawnSync(
|
|
fs.existsSync(localKeaTypegenBin) ? localKeaTypegenBin : 'kea-typegen',
|
|
['write', '--show-ts-errors', '--file', resolvedFile, ...passthroughArgs],
|
|
{
|
|
cwd: repoRoot,
|
|
env: {
|
|
...process.env,
|
|
NODE_OPTIONS: nodeOptions,
|
|
},
|
|
stdio: 'inherit',
|
|
}
|
|
)
|
|
|
|
if (result.error) {
|
|
console.error(`Failed to run kea-typegen: ${result.error.message}`)
|
|
process.exit(1)
|
|
}
|
|
|
|
process.exit(result.status ?? 1)
|
|
|
|
function parseArgs(args) {
|
|
let fileArg
|
|
const passthroughArgs = []
|
|
|
|
for (let index = 0; index < args.length; index++) {
|
|
const arg = args[index]
|
|
|
|
if (arg === '--file' || arg === '-f') {
|
|
fileArg = args[index + 1]
|
|
index += 1
|
|
continue
|
|
}
|
|
|
|
if (arg.startsWith('--file=')) {
|
|
fileArg = arg.slice('--file='.length)
|
|
continue
|
|
}
|
|
|
|
if (arg.startsWith('-f=')) {
|
|
fileArg = arg.slice('-f='.length)
|
|
continue
|
|
}
|
|
|
|
if (!fileArg && !arg.startsWith('-')) {
|
|
fileArg = arg
|
|
continue
|
|
}
|
|
|
|
passthroughArgs.push(arg)
|
|
}
|
|
|
|
return { fileArg, passthroughArgs }
|
|
}
|
|
|
|
function resolveFile(filePath) {
|
|
const candidates = (
|
|
path.isAbsolute(filePath)
|
|
? [filePath]
|
|
: [
|
|
path.resolve(process.cwd(), filePath),
|
|
process.env.INIT_CWD && path.resolve(process.env.INIT_CWD, filePath),
|
|
path.resolve(frontendDir, filePath),
|
|
path.resolve(repoRoot, filePath),
|
|
]
|
|
).filter(Boolean)
|
|
|
|
for (const candidate of candidates) {
|
|
if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) {
|
|
return candidate
|
|
}
|
|
}
|
|
|
|
return undefined
|
|
}
|