|
| 1 | +import { readFileSync } from 'node:fs' |
| 2 | +import { join } from 'node:path' |
| 3 | +import { describe, expect, it } from 'vitest' |
| 4 | + |
| 5 | +/** |
| 6 | + * `apps/tracker` is MIT while everything around it is AGPL-3.0 (README, "License |
| 7 | + * and trademark"). The |
| 8 | + * split lives in three files that nothing else reads — a LICENSE, a manifest |
| 9 | + * field and the banner the build script prepends — so this is the one place |
| 10 | + * that notices when one of them drifts from the other two. |
| 11 | + */ |
| 12 | + |
| 13 | +const ROOT = join(import.meta.dirname, '..', '..') |
| 14 | +const read = (...parts: string[]) => readFileSync(join(ROOT, ...parts), 'utf8') |
| 15 | + |
| 16 | +describe('the tracker licence', () => { |
| 17 | + it('ships an MIT LICENSE naming the copyright holder', () => { |
| 18 | + const licence = read('apps', 'tracker', 'LICENSE') |
| 19 | + expect(licence.startsWith('MIT License\n')).toBe(true) |
| 20 | + expect(licence).toContain('Copyright (c) 2026 OpenLabs LLC') |
| 21 | + expect(licence).toContain('Permission is hereby granted, free of charge') |
| 22 | + }) |
| 23 | + |
| 24 | + it('declares MIT in its manifest while the workspace root stays AGPL', () => { |
| 25 | + const tracker = JSON.parse(read('apps', 'tracker', 'package.json')) as { license?: string } |
| 26 | + const root = JSON.parse(read('package.json')) as { license?: string } |
| 27 | + expect(tracker.license).toBe('MIT') |
| 28 | + expect(root.license).toBe('AGPL-3.0-only') |
| 29 | + }) |
| 30 | + |
| 31 | + it('opens the served bundle with a licence line that survives minifiers', () => { |
| 32 | + // The build script is not importable (it builds on import), so its banner |
| 33 | + // is read as text. `/*!` is the marker minifiers keep. |
| 34 | + const script = read('scripts', 'build-tracker.mjs') |
| 35 | + const banner = /export const TRACKER_BANNER =\s*'([^']+)'/.exec(script)?.[1] |
| 36 | + expect(banner).toBeDefined() |
| 37 | + expect(banner?.startsWith('/*!')).toBe(true) |
| 38 | + expect(banner).toContain('MIT') |
| 39 | + expect(banner).toContain('apps/tracker/LICENSE') |
| 40 | + expect(script).toContain('banner: { js: TRACKER_BANNER }') |
| 41 | + }) |
| 42 | +}) |
0 commit comments