OverviewFilesCommitsIssuesDocsReleasesPeers

favela-peer / test / boundary.test.js

33 lines · javascript ref:
// The acceptance criterion from hyper-social #61 §10, enforced rather than asserted in prose.
//
// It is not a style rule. atproto is a projection of this stack, and the moment the daemon imports
// the projection the dependency has been inverted and the recentring has failed. MVP.md §1 states
// this and is violated today by the atproto-store substrate; this test exists so favela-peer cannot
// repeat it silently.

import test from 'brittle'
import fs from '#node:fs'
import { join } from '#node:path'

const ROOT = new URL('..', import.meta.url).pathname
const FORBIDDEN = /(atproto-|ap-bridge|@ipld\/dag-cbor|dagCbor|did:plc|app\.bsky|activitystreams)/

const walk = (dir) => fs.readdirSync(dir, { withFileTypes: true }).flatMap((e) =>
  e.name === 'node_modules' || e.name === '.git' ? []
    : e.isDirectory() ? walk(join(dir, e.name))
      : e.name.endsWith('.js') ? [join(dir, e.name)] : [])

test('no source file names atproto or ActivityPub', (t) => {
  for (const f of walk(join(ROOT, 'lib'))) {
    const src = fs.readFileSync(f, 'utf8')
    t.absent(FORBIDDEN.test(src), f.slice(ROOT.length) + ' is free of projection vocabulary')
  }
})

test('no dependency is an atproto or ap package', (t) => {
  const pkg = JSON.parse(fs.readFileSync(join(ROOT, 'package.json'), 'utf8'))
  const deps = Object.keys({ ...pkg.dependencies, ...pkg.devDependencies })
  t.ok(deps.length > 0, 'there are dependencies to check')
  for (const d of deps) t.absent(FORBIDDEN.test(d), d + ' is not a projection package')
})