Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,17 @@ Lanyards' lexicons are published from the `@lanyards.app` account
value `did=did:plc:ua3d6biqepazbq6mw4ysotfo`. Resolvers never walk up the
hierarchy, so each group needs its own record:

| Name | Covers |
| --------------------------------------- | ----------------------------------------- |
| `_lexicon.lanyards.app` | `app.lanyards.authFull` |
| `_lexicon.actor.lanyards.app` | `app.lanyards.actor.lanyard` |
| `_lexicon.biography.actor.lanyards.app` | `app.lanyards.actor.biography.honorific` |
| `_lexicon.link.lanyards.app` | `app.lanyards.link.web` |
| `_lexicon.media.link.lanyards.app` | `app.lanyards.link.media.audio`, `.video` |
| Name | Covers |
| ---------------------------------- | ----------------------------------------- |
| `_lexicon.lanyards.app` | `app.lanyards.authFull` |
| `_lexicon.actor.lanyards.app` | `app.lanyards.actor.lanyard` |
| `_lexicon.media.lanyards.app` | `app.lanyards.media.item` |
| `_lexicon.media.link.lanyards.app` | `app.lanyards.link.media.audio`, `.video` |

`scripts/lexiconDns.test.ts` keeps this table in step with
`lexicons/lanyards/`. Records for retired lexicons
(`_lexicon.biography.actor.lanyards.app`, `_lexicon.link.lanyards.app`)
can be deleted.

5. From `web/`, publish:
`GOAT_USERNAME=lanyards.app GOAT_PASSWORD=<app password> goat lex publish --lexicons-dir lexicons/lanyards`.
Expand Down
42 changes: 42 additions & 0 deletions web/scripts/lexiconDns.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { readdirSync, readFileSync } from 'node:fs';
import { join, resolve } from 'node:path';

import { describe, expect, it } from 'vitest';

const ROOT = resolve(process.cwd(), 'lexicons/lanyards');

function lexiconIds(dir: string): string[] {
return readdirSync(dir, { withFileTypes: true }).flatMap((entry) =>
entry.isDirectory()
? lexiconIds(join(dir, entry.name))
: entry.name.endsWith('.json')
? [
(
JSON.parse(readFileSync(join(dir, entry.name), 'utf8')) as {
id: string;
}
).id,
]
: []
);
}

/**
* The TXT record an NSID resolves through: its authority (the NSID less
* its name, reversed) under _lexicon. Resolvers never walk up the tree.
*/
const record = (nsid: string) =>
`_lexicon.${nsid.split('.').slice(0, -1).reverse().join('.')}`;

// The README's publishing steps list the records to create in DNS (#165).
describe('the README’s lexicon DNS records', () => {
it('are exactly the ones the lexicons we publish need', () => {
const needed = [...new Set(lexiconIds(ROOT).map(record))].sort();
const readme = readFileSync(resolve(process.cwd(), 'README.md'), 'utf8');
const listed = [
...readme.matchAll(/^\s*\|\s*`(_lexicon\.[a-z.]+)`\s*\|/gm),
].map((match) => match[1]);
expect(listed.sort()).toEqual(needed);
expect(needed).toContain('_lexicon.media.lanyards.app');
});
});
Loading