mirror of
https://github.com/hanzoai/insights.git
synced 2026-10-30 16:15:31 +00:00
frontend/utils.mjs went upstream into @hanzo/esbuilder (#28441). The convergence took that deletion but two importers stayed behind, so a FRESH CLONE died at @hanzo/elements#build with ERR_MODULE_NOT_FOUND — which is why no insights image has published since the merge landed. Both now import the package, and elements declares the dependency it uses rather than reaching up the tree for it. The Python import gate could not see this: it reads .py only.
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
import fse from 'fs-extra'
|
|
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
import { isDev } from '@hanzo/esbuilder'
|
|
|
|
export const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
|
|
export function writeSourceCodeEditorTypes() {
|
|
const readFile = (p) => {
|
|
try {
|
|
return fse.readFileSync(path.resolve(__dirname, p), { encoding: 'utf-8' })
|
|
} catch (e) {
|
|
if (isDev) {
|
|
console.warn(`🙈 Didn't find "${p}" for the app source editor. Build it with: pnpm packages:build`)
|
|
} else {
|
|
throw e
|
|
}
|
|
}
|
|
}
|
|
const types = {
|
|
'@types/react/index.d.ts': readFile('../node_modules/@types/react/index.d.ts'),
|
|
'@types/react/global.d.ts': readFile('../node_modules/@types/react/global.d.ts'),
|
|
'@types/kea/index.d.ts': readFile('../node_modules/kea/lib/index.d.ts'),
|
|
'@hanzo/elements/index.d.ts': readFile('./@hanzo/elements/dist/index.d.ts'),
|
|
}
|
|
const packagesJsonFile = path.resolve(__dirname, './src/scenes/plugins/source/types/packages.json')
|
|
fse.mkdirpSync(path.dirname(packagesJsonFile))
|
|
fse.writeFileSync(packagesJsonFile, JSON.stringify(types, null, 4) + '\n')
|
|
}
|
|
|
|
writeSourceCodeEditorTypes()
|