mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-10-30 18:34:19 +00:00
Bulk rename across 989 files: - Package names: posthog-js → @hanzo/insights, posthog-node → @hanzo/insights-node, etc. - Repository URLs: posthog/posthog-js → hanzoai/insights-js - Brand names: PostHog → Insights - File renames: 259 reference JSON files, source files, workflow files - Directory rename: eslint-plugin-posthog-js → eslint-plugin-insights Remaining: 8 refs to @posthog/rrweb-* (real npm deps, need fork+publish)
49 lines
1.7 KiB
TypeScript
49 lines
1.7 KiB
TypeScript
import { execSync } from 'child_process'
|
|
import fs from 'fs'
|
|
import path from 'path'
|
|
|
|
const DIST_DIR = path.join(__dirname, '../dist')
|
|
const NPM_ARRAY_FILE = path.join(DIST_DIR, 'array.npm-latest.js')
|
|
const NPM_ARRAY_FULL_FILE = path.join(DIST_DIR, 'array.full.npm-latest.js')
|
|
|
|
async function downloadFile(url: string, dest: string): Promise<void> {
|
|
const response = await fetch(url, { redirect: 'follow' })
|
|
if (!response.ok) {
|
|
throw new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`)
|
|
}
|
|
fs.writeFileSync(dest, await response.text())
|
|
}
|
|
|
|
async function downloadNpmVersion(): Promise<void> {
|
|
const targetVersion = process.env.COMPAT_VERSION || 'latest'
|
|
|
|
const registryUrl =
|
|
targetVersion === 'latest'
|
|
? 'https://registry.npmjs.org/@hanzo/insights/latest'
|
|
: `https://registry.npmjs.org/@hanzo/insights/${targetVersion}`
|
|
const registryResponse = await fetch(registryUrl)
|
|
if (!registryResponse.ok) {
|
|
throw new Error(`Failed to fetch NPM registry: ${registryResponse.status}`)
|
|
}
|
|
const packageInfo = await registryResponse.json()
|
|
const version = packageInfo.version
|
|
|
|
// eslint-disable-next-line no-console
|
|
console.log(`Compat tests using @hanzo/insights@${version} from NPM`)
|
|
|
|
await Promise.all([
|
|
downloadFile(`https://unpkg.com/@hanzo/insights@${version}/dist/array.js`, NPM_ARRAY_FILE),
|
|
downloadFile(`https://unpkg.com/@hanzo/insights@${version}/dist/array.full.js`, NPM_ARRAY_FULL_FILE),
|
|
])
|
|
}
|
|
|
|
async function globalSetup(): Promise<void> {
|
|
if (!fs.existsSync(DIST_DIR)) {
|
|
execSync('pnpm build', { stdio: 'inherit', cwd: path.join(__dirname, '..') })
|
|
}
|
|
|
|
await downloadNpmVersion()
|
|
}
|
|
|
|
export default globalSetup
|