@opencrs/cli 0.0.0 → 0.1.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/man/opencrs.1 ADDED
@@ -0,0 +1,312 @@
1
+ .ie \n(.g .ds Aq \(aq
2
+ .el .ds Aq '
3
+ .TH OPENCRS 1 OpenCRS "OpenCRS Manual"
4
+ .ie \n(.g .ds Aq \(aq
5
+ .el .ds Aq '
6
+ .SH NAME
7
+ opencrs \- Check digital\-signage creative against the screens it\*(Aqs made for
8
+ .ie \n(.g .ds Aq \(aq
9
+ .el .ds Aq '
10
+ .SH SYNOPSIS
11
+ \fBopencrs\fR <COMMAND>
12
+ .br
13
+ \fBopencrs\fR [\-h|\-\-help] [\-V|\-\-version]
14
+ .ie \n(.g .ds Aq \(aq
15
+ .el .ds Aq '
16
+ .SH DESCRIPTION
17
+ Check digital\-signage creative against the screens it\*(Aqs made for
18
+ .PP
19
+ opencrs reads a publisher\*(Aqs screens.json files, which say what each screen needs, and a creative.json, which lists the files of one piece of creative, and checks the files against the screens they target. It can also find a publisher\*(Aqs files on the web and check which of them to trust, check any OpenCRS document against its schema, and run the conformance suite against a validator.
20
+ .ie \n(.g .ds Aq \(aq
21
+ .el .ds Aq '
22
+ .PP
23
+ Each command takes its own options; see COMMANDS. Every flag may also be written with a single dash and its full name (for example \-spec for \-\-spec), as in earlier versions.
24
+ .ie \n(.g .ds Aq \(aq
25
+ .el .ds Aq '
26
+ .SH OPTIONS
27
+ .TP
28
+ \fB\-h\fR, \fB\-\-help\fR
29
+ Show help (\-\-help shows more)
30
+ .TP
31
+ \fB\-V\fR, \fB\-\-version\fR
32
+ Show the version
33
+ .ie \n(.g .ds Aq \(aq
34
+ .el .ds Aq '
35
+ .SH COMMANDS
36
+ .ie \n(.g .ds Aq \(aq
37
+ .el .ds Aq '
38
+ .SS "opencrs check"
39
+ Check a creative\*(Aqs files against the screens they target.
40
+ .PP
41
+ Reads a creative.json, finds each file it lists, and checks the file\*(Aqs type, size, duration and layout against every screen it targets in the screens.json files you give. Each file\*(Aqs pixel size, byte size and SHA\-256 come from the file itself; the manifest\*(Aqs declared values are used only for a file that is missing or when \-\-no\-files is set.
42
+ .PP
43
+ \fBopencrs check\fR [OPTIONS] \-\-spec <SCREENS> <CREATIVE>
44
+ .ie \n(.g .ds Aq \(aq
45
+ .el .ds Aq '
46
+ .TP
47
+ \fB\-s\fR, \fB\-\-spec\fR \fI<SCREENS>\fR
48
+ A screens.json to check against. Give it more than once to check against several publishers.
49
+ .TP
50
+ \fB\-\-files\fR \fI<DIR>\fR
51
+ Directory holding the creative files. Defaults to the manifest\*(Aqs directory.
52
+ .TP
53
+ \fB\-\-no\-files\fR
54
+ Use the manifest\*(Aqs declared values, don\*(Aqt read the files
55
+ .TP
56
+ \fB\-\-json\fR
57
+ Print the reports as a JSON array of spec reports, in the spec\*(Aqs report format.
58
+ .TP
59
+ \fB\-\-now\fR \fI<TIME>\fR
60
+ Validation time, RFC 3339 (default: now)
61
+ .TP
62
+ \fB\-\-margin\fR \fI<RATIO>\fR [default: 1.25]
63
+ Warn when text is below this multiple of its minimum size. Zero means the default, 1.25.
64
+ .TP
65
+ \fB\-h\fR, \fB\-\-help\fR
66
+ Show help (\-\-help shows more)
67
+ .TP
68
+ <\fICREATIVE\fR>
69
+ The creative.json to check
70
+ .ie \n(.g .ds Aq \(aq
71
+ .el .ds Aq '
72
+ .SS "opencrs schema"
73
+ Check documents against the OpenCRS schemas.
74
+ .PP
75
+ Each file is checked against the JSON Schema for its kind (index, screens, creative, report or rule\-pack), detected from the document unless \-\-kind is given. For a screens.json it also reports references to formats or venues that don\*(Aqt exist and rules that inheritance has made impossible to meet. A JSON array is checked element by element, so the output of check \-\-json works.
76
+ .PP
77
+ \fBopencrs schema\fR [OPTIONS] <FILE>...
78
+ .ie \n(.g .ds Aq \(aq
79
+ .el .ds Aq '
80
+ .TP
81
+ \fB\-\-kind\fR \fI<KIND>\fR
82
+ Document kind: index, screens, creative, report or rule\-pack. Detected from the document when omitted.
83
+ .TP
84
+ \fB\-\-allow\-local\-http\fR
85
+ Accept http://localhost document URLs in an index
86
+ .TP
87
+ \fB\-h\fR, \fB\-\-help\fR
88
+ Show help (\-\-help shows more)
89
+ .TP
90
+ <\fIFILE\fR>
91
+ The documents to check
92
+ .ie \n(.g .ds Aq \(aq
93
+ .el .ds Aq '
94
+ .SS "opencrs resolve"
95
+ Show the requirements for a format or a screen.
96
+ .PP
97
+ Prints the requirements that apply to one format or one screen after inheritance (publisher, network, venue, format, screen) as JSON. A reference is <publisher>/<network>/<format> or <publisher>/<network>/screen/<id>.
98
+ .PP
99
+ \fBopencrs resolve\fR <SCREENS> <REF>
100
+ .ie \n(.g .ds Aq \(aq
101
+ .el .ds Aq '
102
+ .TP
103
+ \fB\-h\fR, \fB\-\-help\fR
104
+ Show help (\-\-help shows more)
105
+ .TP
106
+ <\fISCREENS\fR>
107
+ The screens.json to read
108
+ .TP
109
+ <\fIREF\fR>
110
+ A format or screen reference: <publisher>/<network>/<format> or <publisher>/<network>/screen/<id>.
111
+ .ie \n(.g .ds Aq \(aq
112
+ .el .ds Aq '
113
+ .SS "opencrs fetch"
114
+ Find a publisher\*(Aqs specs and check which to trust.
115
+ .PP
116
+ Given a domain, reads the publisher\*(Aqs index at /.well\-known/opencrs.json, fetches each document it lists, follows delegations, and marks each document trusted, expired, rejected, skipped (a partner document without a token) or failed, with the reason. Given a document URL, checks that its publisher vouches for that exact URL.
117
+ .PP
118
+ Only HTTPS is used, and addresses on private networks are refused. See the NETWORK section of the man page for the limits.
119
+ .PP
120
+ \fBopencrs fetch\fR [OPTIONS] <DOMAIN|URL>
121
+ .ie \n(.g .ds Aq \(aq
122
+ .el .ds Aq '
123
+ .TP
124
+ \fB\-\-token\fR \fI<DOMAIN=TOKEN>\fR
125
+ Bearer token a publisher issued for its partner documents, as DOMAIN=TOKEN. Give it more than once for several publishers. The token is sent only to that domain.
126
+ .TP
127
+ \fB\-o\fR, \fB\-\-output\fR \fI<DIR>\fR
128
+ Save trusted documents, exactly as served, under this directory. The files are ready for check \-\-spec. When partner documents are included, a merged.screens.json is written too.
129
+ .TP
130
+ \fB\-\-json\fR
131
+ Print the result as JSON
132
+ .TP
133
+ \fB\-\-allow\-local\-http\fR
134
+ Local testing: allow http:// and connections to localhost, 127.0.0.1 and [::1]. Other internal addresses stay refused.
135
+ .TP
136
+ \fB\-h\fR, \fB\-\-help\fR
137
+ Show help (\-\-help shows more)
138
+ .TP
139
+ <\fIDOMAIN|URL\fR>
140
+ A publisher\*(Aqs domain, or the URL of one document
141
+ .ie \n(.g .ds Aq \(aq
142
+ .el .ds Aq '
143
+ .SS "opencrs conformance"
144
+ Run the conformance suite against a validator.
145
+ .PP
146
+ Runs the cases in the conformance directory against this tool\*(Aqs own validator, or against another validator given with \-\-cmd. The command is run through the shell with each case directory as its last argument and must print the reports as a JSON array.
147
+ .PP
148
+ \fBopencrs conformance\fR [OPTIONS] [DIR]
149
+ .ie \n(.g .ds Aq \(aq
150
+ .el .ds Aq '
151
+ .TP
152
+ \fB\-\-level\fR \fI<LEVEL>\fR [default: full]
153
+ Level to test: core, layout or full
154
+ .TP
155
+ \fB\-\-cmd\fR \fI<COMMAND>\fR
156
+ External validator to test. It is run with each case directory as its last argument and must print the reports as a JSON array.
157
+ .TP
158
+ \fB\-v\fR, \fB\-\-verbose\fR
159
+ List passing cases too
160
+ .TP
161
+ \fB\-h\fR, \fB\-\-help\fR
162
+ Show help (\-\-help shows more)
163
+ .TP
164
+ [\fIDIR\fR] [default: conformance/0.1]
165
+ The conformance directory
166
+ .ie \n(.g .ds Aq \(aq
167
+ .el .ds Aq '
168
+ .SS "opencrs completion"
169
+ Print shell completions.
170
+ .PP
171
+ Prints a completion script for the shell to standard output. Save it where your shell looks for completions, or load it from your shell\*(Aqs startup file.
172
+ .PP
173
+ \fBopencrs completion\fR <SHELL>
174
+ .ie \n(.g .ds Aq \(aq
175
+ .el .ds Aq '
176
+ .TP
177
+ \fB\-h\fR, \fB\-\-help\fR
178
+ Show help (\-\-help shows more)
179
+ .TP
180
+ <\fISHELL\fR>
181
+ The shell to print completions for
182
+ .br
183
+
184
+ .br
185
+ \fIPossible values:\fR
186
+ .RS 14
187
+ .IP \(bu 2
188
+ bash
189
+ .IP \(bu 2
190
+ zsh
191
+ .IP \(bu 2
192
+ fish
193
+ .IP \(bu 2
194
+ powershell
195
+ .RE
196
+ .ie \n(.g .ds Aq \(aq
197
+ .el .ds Aq '
198
+ .SS "opencrs version"
199
+ Show the tool, spec and rule pack versions.
200
+ .PP
201
+ \fBopencrs version\fR
202
+ .ie \n(.g .ds Aq \(aq
203
+ .el .ds Aq '
204
+ .TP
205
+ \fB\-h\fR, \fB\-\-help\fR
206
+ Show help (\-\-help shows more)
207
+ .ie \n(.g .ds Aq \(aq
208
+ .el .ds Aq '
209
+ .SH EXAMPLES
210
+ .PP
211
+ Check a creative against a publisher\*(Aqs screens:
212
+ .PP
213
+ .RS 4
214
+ .nf
215
+ opencrs check \-\-spec retail.screens.json creative.json
216
+ .fi
217
+ .RE
218
+ .PP
219
+ Check against two publishers and save the reports as JSON:
220
+ .PP
221
+ .RS 4
222
+ .nf
223
+ opencrs check \-s retail.screens.json \-s airports.screens.json \\
224
+ \-\-json creative.json > reports.json
225
+ .fi
226
+ .RE
227
+ .PP
228
+ Check a screens.json and a creative.json against the schemas:
229
+ .PP
230
+ .RS 4
231
+ .nf
232
+ opencrs schema screens.json creative.json
233
+ .fi
234
+ .RE
235
+ .PP
236
+ Show what a screen requires:
237
+ .PP
238
+ .RS 4
239
+ .nf
240
+ opencrs resolve retail.screens.json harbourline.example/retail/screen/HC\-L1\-002
241
+ .fi
242
+ .RE
243
+ .PP
244
+ Find a publisher\*(Aqs specs and save the ones to trust:
245
+ .PP
246
+ .RS 4
247
+ .nf
248
+ opencrs fetch \-\-output specs harbourline.example
249
+ .fi
250
+ .RE
251
+ .PP
252
+ Install the zsh completions:
253
+ .PP
254
+ .RS 4
255
+ .nf
256
+ opencrs completion zsh > ~/.zfunc/_opencrs
257
+ .fi
258
+ .RE
259
+ .SH "EXIT STATUS"
260
+ .PP
261
+ All commands exit 0 on success, 1 when what they checked failed, and 2 for a usage error or a file that could not be read. Asking for help or the version exits 0.
262
+ .TP
263
+ \fBcheck\fR
264
+ 0 passed, 1 a file failed, 2 usage or read error
265
+ .TP
266
+ \fBschema\fR
267
+ 0 all valid, 1 a document failed, 2 usage or read error
268
+ .TP
269
+ \fBresolve\fR
270
+ 0 resolved, 1 reference not found, 2 usage or read error
271
+ .TP
272
+ \fBfetch\fR
273
+ 0 all trusted, 1 a document was not trusted, 2 usage or fetch error
274
+ .TP
275
+ \fBconformance\fR
276
+ 0 conforms, 1 a case failed, 2 usage or read error
277
+ .SH ENVIRONMENT
278
+ .TP
279
+ \fBNO_COLOR\fR
280
+ When set to a non\-empty value, help and error messages are never coloured. They are also plain when output is not a terminal, or when TERM is dumb.
281
+ .TP
282
+ \fBCLICOLOR_FORCE\fR
283
+ When set to a value other than 0, colour is used even when output is not a terminal (NO_COLOR still wins).
284
+ .TP
285
+ \fBHTTP_PROXY, HTTPS_PROXY\fR
286
+ Ignored by fetch. A proxy would resolve host names where the addresses can\*(Aqt be checked, so fetch always connects directly.
287
+ .SH NETWORK
288
+ .PP
289
+ Only fetch uses the network. It is built so that an index cannot point it at a service on the machine or its network.
290
+ .TP
291
+ \fBScheme\fR
292
+ Only https:// URLs are fetched. With \-\-allow\-local\-http, http:// is allowed for localhost, 127.0.0.1 and [::1] only.
293
+ .TP
294
+ \fBAddresses\fR
295
+ Each host, redirects included, is resolved once and refused if any of its addresses is loopback, private, link\-local, shared (CGNAT), multicast, broadcast, unspecified, reserved or for documentation. The connection goes to the addresses that were checked. With \-\-allow\-local\-http, loopback is allowed for localhost, 127.0.0.1 and [::1] only; other internal addresses stay refused.
296
+ .TP
297
+ \fBRedirects\fR
298
+ At most four, and only to https://. A redirect to another host is refused for a document that must stay on its publisher\*(Aqs host and for any request that carries a token.
299
+ .TP
300
+ \fBTime\fR
301
+ Each request, redirects included, must finish within 30 seconds.
302
+ .TP
303
+ \fBSize\fR
304
+ A document larger than 50 MiB (52428800 bytes) is refused. One discovery reads at most 512 MiB in total, indexes and documents together.
305
+ .TP
306
+ \fBIndex entries\fR
307
+ An index may list at most 1000 documents, and at most 1000 delegates.
308
+ .TP
309
+ \fBTokens\fR
310
+ A \-\-token is sent only with requests for that publisher\*(Aqs partner documents.
311
+ .SH "SEE ALSO"
312
+ The OpenCRS specification: https://opencrs.dev/spec/0.1/
@@ -0,0 +1,52 @@
1
+ {
2
+ "lockfileVersion": 3,
3
+ "name": "@opencrs/cli",
4
+ "packages": {
5
+ "": {
6
+ "bin": {
7
+ "opencrs": "run-opencrs.js"
8
+ },
9
+ "dependencies": {
10
+ "detect-libc": "^2.1.2"
11
+ },
12
+ "devDependencies": {
13
+ "prettier": "^3.9.6"
14
+ },
15
+ "engines": {
16
+ "node": ">=14.14",
17
+ "npm": ">=6"
18
+ },
19
+ "hasInstallScript": true,
20
+ "license": "Apache-2.0",
21
+ "name": "@opencrs/cli",
22
+ "version": "0.1.0-rc.3"
23
+ },
24
+ "node_modules/detect-libc": {
25
+ "engines": {
26
+ "node": ">=8"
27
+ },
28
+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
29
+ "license": "Apache-2.0",
30
+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
31
+ "version": "2.1.2"
32
+ },
33
+ "node_modules/prettier": {
34
+ "bin": {
35
+ "prettier": "bin/prettier.cjs"
36
+ },
37
+ "dev": true,
38
+ "engines": {
39
+ "node": ">=14"
40
+ },
41
+ "funding": {
42
+ "url": "https://github.com/prettier/prettier?sponsor=1"
43
+ },
44
+ "integrity": "sha512-OpN0zzVdiaiAhxpuuj5efpIS4sY9j7bY6uR5mnj5yPzGkdkjNKSJeUThPb60Jw29QuAZgA4o+/iB49kFiaBX6g==",
45
+ "license": "MIT",
46
+ "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.9.6.tgz",
47
+ "version": "3.9.6"
48
+ }
49
+ },
50
+ "requires": true,
51
+ "version": "0.1.0-rc.3"
52
+ }
package/package.json CHANGED
@@ -1,7 +1,130 @@
1
1
  {
2
- "name": "@opencrs/cli",
3
- "version": "0.0.0",
4
- "description": "The OpenCRS command-line validator. Placeholder; the first real release follows.",
2
+ "artifactDownloadUrls": [
3
+ "https://github.com/OpenCRS-Org/opencrs/releases/download/v0.1.0-rc.3"
4
+ ],
5
+ "bin": {
6
+ "opencrs": "run-opencrs.js"
7
+ },
8
+ "dependencies": {
9
+ "detect-libc": "^2.1.2"
10
+ },
11
+ "description": "Tooling for OpenCRS, the Open Creative Requirements Specification",
12
+ "devDependencies": {
13
+ "prettier": "^3.9.6"
14
+ },
15
+ "engines": {
16
+ "node": ">=14.14",
17
+ "npm": ">=6"
18
+ },
19
+ "glibcMinimum": {
20
+ "major": 2,
21
+ "series": 35
22
+ },
23
+ "homepage": "https://opencrs.dev",
24
+ "keywords": [
25
+ "opencrs",
26
+ "dooh",
27
+ "creative",
28
+ "specification"
29
+ ],
5
30
  "license": "Apache-2.0",
6
- "homepage": "https://opencrs.dev"
7
- }
31
+ "name": "@opencrs/cli",
32
+ "preferUnplugged": true,
33
+ "repository": "https://github.com/OpenCRS-Org/opencrs",
34
+ "scripts": {
35
+ "fmt": "prettier --write **/*.js",
36
+ "fmt:check": "prettier --check **/*.js",
37
+ "postinstall": "node ./install.js"
38
+ },
39
+ "supportedPlatforms": {
40
+ "aarch64-apple-darwin": {
41
+ "artifactName": "opencrs-cli-aarch64-apple-darwin.tar.xz",
42
+ "bins": {
43
+ "opencrs": "opencrs"
44
+ },
45
+ "zipExt": ".tar.xz"
46
+ },
47
+ "aarch64-pc-windows-gnu": {
48
+ "artifactName": "opencrs-cli-aarch64-pc-windows-msvc.zip",
49
+ "bins": {
50
+ "opencrs": "opencrs.exe"
51
+ },
52
+ "zipExt": ".zip"
53
+ },
54
+ "aarch64-pc-windows-msvc": {
55
+ "artifactName": "opencrs-cli-aarch64-pc-windows-msvc.zip",
56
+ "bins": {
57
+ "opencrs": "opencrs.exe"
58
+ },
59
+ "zipExt": ".zip"
60
+ },
61
+ "aarch64-unknown-linux-gnu": {
62
+ "artifactName": "opencrs-cli-aarch64-unknown-linux-gnu.tar.xz",
63
+ "bins": {
64
+ "opencrs": "opencrs"
65
+ },
66
+ "zipExt": ".tar.xz"
67
+ },
68
+ "aarch64-unknown-linux-musl-dynamic": {
69
+ "artifactName": "opencrs-cli-aarch64-unknown-linux-musl.tar.xz",
70
+ "bins": {
71
+ "opencrs": "opencrs"
72
+ },
73
+ "zipExt": ".tar.xz"
74
+ },
75
+ "aarch64-unknown-linux-musl-static": {
76
+ "artifactName": "opencrs-cli-aarch64-unknown-linux-musl.tar.xz",
77
+ "bins": {
78
+ "opencrs": "opencrs"
79
+ },
80
+ "zipExt": ".tar.xz"
81
+ },
82
+ "x86_64-apple-darwin": {
83
+ "artifactName": "opencrs-cli-x86_64-apple-darwin.tar.xz",
84
+ "bins": {
85
+ "opencrs": "opencrs"
86
+ },
87
+ "zipExt": ".tar.xz"
88
+ },
89
+ "x86_64-pc-windows-gnu": {
90
+ "artifactName": "opencrs-cli-x86_64-pc-windows-msvc.zip",
91
+ "bins": {
92
+ "opencrs": "opencrs.exe"
93
+ },
94
+ "zipExt": ".zip"
95
+ },
96
+ "x86_64-pc-windows-msvc": {
97
+ "artifactName": "opencrs-cli-x86_64-pc-windows-msvc.zip",
98
+ "bins": {
99
+ "opencrs": "opencrs.exe"
100
+ },
101
+ "zipExt": ".zip"
102
+ },
103
+ "x86_64-unknown-linux-gnu": {
104
+ "artifactName": "opencrs-cli-x86_64-unknown-linux-gnu.tar.xz",
105
+ "bins": {
106
+ "opencrs": "opencrs"
107
+ },
108
+ "zipExt": ".tar.xz"
109
+ },
110
+ "x86_64-unknown-linux-musl-dynamic": {
111
+ "artifactName": "opencrs-cli-x86_64-unknown-linux-musl.tar.xz",
112
+ "bins": {
113
+ "opencrs": "opencrs"
114
+ },
115
+ "zipExt": ".tar.xz"
116
+ },
117
+ "x86_64-unknown-linux-musl-static": {
118
+ "artifactName": "opencrs-cli-x86_64-unknown-linux-musl.tar.xz",
119
+ "bins": {
120
+ "opencrs": "opencrs"
121
+ },
122
+ "zipExt": ".tar.xz"
123
+ }
124
+ },
125
+ "version": "0.1.0-rc.3",
126
+ "volta": {
127
+ "node": "18.14.1",
128
+ "npm": "9.5.0"
129
+ }
130
+ }
package/run-opencrs.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { run } = require("./binary");
4
+ run("opencrs");