mirror of
https://github.com/hanzoai/insights.git
synced 2026-11-03 00:52:32 +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.
122 lines
4.2 KiB
TypeScript
122 lines
4.2 KiB
TypeScript
import type { StorybookConfig } from '@storybook/react-vite'
|
|
import { spawn } from 'node:child_process'
|
|
import { fileURLToPath } from 'node:url'
|
|
import chokidar from 'chokidar'
|
|
import path from 'path'
|
|
import type { Plugin, ViteDevServer } from 'vite'
|
|
|
|
// Storybook 10 loads the config as a native ES module, where `__dirname` is
|
|
// not defined — derive it from the module URL instead.
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
|
|
/**
|
|
* Regenerates @hanzo/quill-tokens dist CSS whenever the tokens source
|
|
* (colors.ts, spacing.ts, typography.ts, …) changes, then triggers a
|
|
* full page reload. Without this plugin the tokens package only rebuilds
|
|
* on explicit `pnpm build`, so runtime CSS custom properties stay stale
|
|
* until the dev server is restarted.
|
|
*
|
|
* Uses a dedicated chokidar watcher instead of `server.watcher.add()`:
|
|
* Vite's default watcher is scoped to the storybook project root and
|
|
* doesn't reliably pick up changes in sibling workspace packages added
|
|
* via globs after server start.
|
|
*/
|
|
function quillTokensWatcher(): Plugin {
|
|
const tokensRoot = path.resolve(__dirname, '../../../packages/tokens')
|
|
const tokensSrc = path.join(tokensRoot, 'src')
|
|
let rebuildTimer: NodeJS.Timeout | null = null
|
|
let rebuilding = false
|
|
let rebuildPending = false
|
|
let watcher: chokidar.FSWatcher | null = null
|
|
|
|
const rebuild = (server: ViteDevServer): void => {
|
|
if (rebuilding) {
|
|
rebuildPending = true
|
|
return
|
|
}
|
|
rebuildPending = false
|
|
rebuilding = true
|
|
console.info('[quill-tokens-watcher] rebuilding tokens…')
|
|
const proc = spawn('pnpm', ['exec', 'tsx', 'src/build.ts'], {
|
|
cwd: tokensRoot,
|
|
stdio: 'inherit',
|
|
shell: true,
|
|
})
|
|
proc.on('error', (err) => {
|
|
console.error('[quill-tokens-watcher] spawn error:', err)
|
|
})
|
|
proc.on('exit', (code) => {
|
|
rebuilding = false
|
|
if (code === 0) {
|
|
console.info('[quill-tokens-watcher] rebuild ok → reloading')
|
|
server.ws.send({ type: 'full-reload' })
|
|
} else {
|
|
console.error('[quill-tokens-watcher] rebuild failed, exit', code)
|
|
}
|
|
if (rebuildPending) {
|
|
rebuild(server)
|
|
}
|
|
})
|
|
}
|
|
|
|
return {
|
|
name: 'quill-tokens-watcher',
|
|
configureServer(server) {
|
|
watcher = chokidar.watch(tokensSrc, {
|
|
ignored: /node_modules/,
|
|
ignoreInitial: true,
|
|
awaitWriteFinish: { stabilityThreshold: 50, pollInterval: 20 },
|
|
})
|
|
watcher.on('all', (event, file) => {
|
|
if (event !== 'change' && event !== 'add') {
|
|
return
|
|
}
|
|
if (!file.endsWith('.ts')) {
|
|
return
|
|
}
|
|
if (rebuildTimer) {
|
|
clearTimeout(rebuildTimer)
|
|
}
|
|
rebuildTimer = setTimeout(() => rebuild(server), 100)
|
|
})
|
|
watcher.on('ready', () => {
|
|
console.info('[quill-tokens-watcher] watching', tokensSrc)
|
|
})
|
|
},
|
|
closeBundle() {
|
|
watcher?.close()
|
|
},
|
|
}
|
|
}
|
|
|
|
const config: StorybookConfig = {
|
|
stories: [
|
|
'../stories/**/*.mdx',
|
|
'../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)',
|
|
// Also pick up stories co-located in packages
|
|
'../../../packages/*/src/**/*.stories.@(js|jsx|mjs|ts|tsx)',
|
|
],
|
|
addons: ['@storybook/addon-docs', 'storybook-addon-pseudo-states', 'storybook-dark-mode'],
|
|
framework: {
|
|
name: '@storybook/react-vite',
|
|
options: {},
|
|
},
|
|
viteFinal: async (config) => {
|
|
const { default: tailwindcss } = await import('@tailwindcss/vite')
|
|
|
|
config.plugins = [...(config.plugins || []), tailwindcss(), quillTokensWatcher()]
|
|
config.resolve = {
|
|
...config.resolve,
|
|
alias: {
|
|
...config.resolve?.alias,
|
|
// Points to primitives/src so @/ imports in primitive components resolve
|
|
'@': path.resolve(__dirname, '../../../packages/primitives/src'),
|
|
},
|
|
}
|
|
|
|
return config
|
|
},
|
|
}
|
|
|
|
export default config
|