forked from solid/catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
executable file
·61 lines (51 loc) · 1.96 KB
/
index.ts
File metadata and controls
executable file
·61 lines (51 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env -S node --disable-warning=ExperimentalWarning
import { Command } from 'commander'
import { getPath, loadData, saveData } from './util.ts'
import { validateWebid } from './validations/webid.ts'
import { migrateWebid } from './migrations/webid.ts'
import { aggregateW3C } from './aggregations/w3c.ts'
import { aggregateGithub } from './aggregations/github.ts'
const dataPath = getPath(import.meta.url, '../catalog-data.ttl')
const dataset = await loadData(dataPath)
const program = new Command()
program
.name('solid-catalog')
.description('CLI to manage Solid Catalog')
.version('0.1.0')
program.command('format')
.description('Formats catalog data in a deterministic way')
.action(async () => {
console.info('Formatting data')
await saveData(dataset, dataPath)
})
const validate = program.command('validate')
validate.command('webid')
.description('Checks statements with ex:webid that subject and object are the same')
.action(async () => {
console.info('Validate ex:webid statements')
await validateWebid(dataset)
})
const migrate = program.command('migrate')
migrate.command('webid')
.description('Picks object in statement with ex:webid and makes it a subject, then updates all other statements using the old subject')
.action(async () => {
console.info('migrate ex:webid statements and related data')
const updated = await migrateWebid(dataset)
await saveData(updated, dataPath)
})
const aggregate = program.command('aggregate')
aggregate.command('w3c')
.description('Adds data from W3C API')
.action(async () => {
console.info('Fetching data from W3C API')
const updated = await aggregateW3C(dataset)
await saveData(updated, dataPath)
})
aggregate.command('github')
.description('Adds data from Github API')
.action(async () => {
console.info('Fetching data from Github API')
const updated = await aggregateGithub(dataset)
await saveData(updated, dataPath)
})
program.parse(process.argv)