-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathceramic.ts
More file actions
143 lines (122 loc) · 5.52 KB
/
ceramic.ts
File metadata and controls
143 lines (122 loc) · 5.52 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import program from 'commander'
import { CeramicCliUtils, DEFAULT_PINNING_STORE_PATH } from "../ceramic-cli-utils"
program
.command('daemon')
.option('--ipfs-api <url>', 'The ipfs http api to use')
.option('--ethereum-rpc <url>', 'The Ethereum RPC URL used for communicating with Ethereum blockchain')
.option('--anchor-service-api <url>', 'The anchor service URL to use')
.option('--validate-docs', 'Validate documents according to their schemas. It is enabled by default')
.option('--pinning <url...>', 'Pinning endpoints')
.option('--pinning-store-path <url>', `The directory path used for pinning service. Defaults to WORKING_DIR/${DEFAULT_PINNING_STORE_PATH}`)
.option('--gateway', 'Makes read only endpoints available. It is disabled by default')
.option('--port <int>', 'Port daemon is availabe. Default is 7007')
.option('--debug', 'Enable debug logging level. Default is false')
.option('--log-to-files', 'If debug is true, write logs to files. Default is false')
.option('--log-path <dir>', 'Store logs in this directory. Defaults to "/usr/local/var/log/ceramic"')
.description('Start the daemon')
.action(async ({ ipfsApi, ethereumRpc, anchorServiceApi, validateDocs, pinning, pinningStorePath, gateway, port, debug, logToFiles, logPath }) => {
await CeramicCliUtils.createDaemon(ipfsApi, ethereumRpc, anchorServiceApi, validateDocs, pinning, pinningStorePath, gateway, port, debug, logToFiles, logPath)
})
program
.command('create <doctype>')
.option('--content <content>', 'New document content')
.option('--only-genesis', 'Only create the genesis object. No anchor will be created')
.option('--controllers <controllers>', 'Specify a comma-separated list of the controllers of the document. Controllers are the users that are allowed to publish updates to this document. Defaults to current user')
.option('--unique', 'Ensure document is unique regardless of content')
.option('--schema <schema>', 'Schema document ID')
.description('Create a new document')
.action(async (doctype, { content, onlyGenesis, controllers, unique, schema }) => {
await CeramicCliUtils.createDoc(doctype, content, controllers, onlyGenesis, unique, schema)
})
program
.command('change <docId>')
.option('--content <content>', 'Change document content')
.option('--controllers <controllers>', 'Change controllers of this document (only 3ID)')
.option('--schema <schema>', 'Change the schema document ID')
.description('Update the content of a document')
.action(async (docId, { content, controllers, schema }) => {
await CeramicCliUtils.change(docId, content, controllers, schema)
})
program
.command('show <docId> [<anchor>]')
.description('Show the content of a document')
.action(async (docId) => {
await CeramicCliUtils.show(docId)
})
program
.command('state <docId> [<anchor>]')
.description('Show the state of a document')
.action(async (docId) => {
await CeramicCliUtils.state(docId)
})
program
.command('watch <docId>')
.description('Watch for updates in a document')
.action(async (docId) => {
await CeramicCliUtils.watch(docId)
})
program
.command('versions <docId>')
.description('List document versions')
.action(async (docId) => {
await CeramicCliUtils.versions(docId)
})
const schemas = program.command('schema')
schemas.description('Ceramic schemas')
schemas
.command('create <new-content>')
.option('--only-genesis', 'Only create the genesis object. No anchor will be created')
.option('--controllers <controllers>', 'Specify a comma-separated list of the controllers of the schema document. Defaults to' + ' current user')
.option('--unique', 'Ensure schema document is unique regardless of content')
.description('Create a new schema')
.action(async (content, { onlyGenesis, controllers, unique }) => {
await CeramicCliUtils.schemaCreateDoc(content, controllers, onlyGenesis, unique)
})
schemas
.command('change <docId> <new-content>')
.option('--controllers <controllers>', 'Change controllers of this document (only 3ID)')
.description('Update the content of a schema')
.action(async (docId, content, { controllers }) => {
await CeramicCliUtils.schemaChangeDoc(docId, content, controllers)
})
const pin = program.command('pin')
pin.description('Ceramic local pinning API')
pin
.command('add <docId>')
.description('Pin document')
.action(async (docId) => {
await CeramicCliUtils.pinAdd(docId)
});
pin
.command('rm <docId>')
.description('Unpin document')
.action(async (docId) => {
await CeramicCliUtils.pinRm(docId)
});
pin
.command('ls [<docId>]')
.description('List pinned documents')
.action(async (docId) => {
await CeramicCliUtils.pinLs(docId)
})
const config = program.command('config')
config.description('CLI Ceramic configuration. Configurable parameters: seed, ceramicHost ')
config
.command('show')
.description('Show CLI Ceramic configuration')
.action(async () => {
await CeramicCliUtils.showConfig()
});
config
.command('set <variable> <value>')
.description('Set variable value')
.action(async (variable, value) => {
await CeramicCliUtils.setConfig(variable, value)
})
config
.command('unset <variable>')
.description('Unset configuration variable')
.action(async (variable) => {
await CeramicCliUtils.unsetConfig(variable)
})
program.parse(process.argv)