@jbrowse/cli 5.0.0-beta.3 → 5.0.0-beta.7
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/README.md +7 -0
- package/dist/commands/add-track-utils/track-config.js +3 -3
- package/dist/commands/make-pif/index.js +6 -1
- package/dist/commands/make-pif/pif-generator.js +34 -40
- package/dist/commands/validate/configManifest.generated.js +685 -75
- package/dist/commands/validate/configSchema.generated.js +17706 -0
- package/dist/commands/validate/index.js +8 -1
- package/dist/commands/validate/schemaValidate.js +300 -0
- package/dist/commands/validate/validateConfig.js +76 -278
- package/dist/version.js +1 -1
- package/package.json +5 -4
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
// Checks a JBrowse config (or a saved session file)
|
|
2
|
-
//
|
|
1
|
+
// Checks a JBrowse config (or a saved session file): the generated JSON Schema
|
|
2
|
+
// first, which reports every key or value the schema can judge, then the
|
|
3
|
+
// cross-references a schema cannot express and the warnings for stale
|
|
4
|
+
// spellings a migration still rewrites.
|
|
3
5
|
//
|
|
4
|
-
// Why
|
|
5
|
-
// ignore snapshot keys they do not declare
|
|
6
|
-
//
|
|
7
|
-
// it — the track loads, appears, and the setting silently does nothing. That is
|
|
8
|
-
// the check no other layer performs, and it is the mistake config authors
|
|
9
|
-
// (human or agent) make most.
|
|
6
|
+
// Why a validator at all, given MST type-checks a config on load: MST models
|
|
7
|
+
// ignore snapshot keys they do not declare, so a misspelt slot leaves the track
|
|
8
|
+
// loading normally with the setting doing nothing.
|
|
10
9
|
//
|
|
11
10
|
// Pure: no filesystem, no process exit. The command wrapper owns both.
|
|
12
11
|
import { configManifest } from './configManifest.generated.js';
|
|
13
|
-
import {
|
|
12
|
+
import { schemaProblems } from './schemaValidate.js';
|
|
14
13
|
import { didYouMean } from './suggest.js';
|
|
15
|
-
// ------------------------------------------------------------------ reporting
|
|
16
14
|
class Report {
|
|
17
15
|
problems = [];
|
|
18
16
|
notes = [];
|
|
@@ -34,100 +32,58 @@ class Report {
|
|
|
34
32
|
};
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
|
-
// ------------------------------------------------------------------- checking
|
|
38
35
|
function isRecord(value) {
|
|
39
36
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
40
37
|
}
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
return [...entry.slots.map(s => s.name), ...(entry.shorthandKeys ?? [])];
|
|
46
|
-
}
|
|
47
|
-
// A key JBrowse fills in for itself, so writing one by hand is an anti-pattern
|
|
48
|
-
// whether or not the schema happens to declare a slot for it. Both halves get a
|
|
49
|
-
// message that says so, because the generic ones send the author looking for a
|
|
50
|
-
// typo in a key that is spelled correctly.
|
|
51
|
-
//
|
|
52
|
-
// `sequenceAdapter` is the standing case, and it is now uniform:
|
|
53
|
-
// `getFeatureAdapter` and `CoreGetRefNames` prime every feature adapter's
|
|
54
|
-
// `sequenceAdapterConfig` from the assembly the track is displayed against, and
|
|
55
|
-
// `getSequenceSubAdapter` is what every adapter that reads a sequence resolves
|
|
56
|
-
// through. So no track has to carry one — three grape/peach/volvox configs were
|
|
57
|
-
// copying their own assembly's FASTA urls into a GC track, and two hg002 tracks
|
|
58
|
-
// carried one on a `CramAdapter`, which declares no such slot at all.
|
|
59
|
-
//
|
|
60
|
-
// Two levels, and the split is this validator's own rule: an undeclared key does
|
|
61
|
-
// nothing where it is written (error), a declared one works and is simply the
|
|
62
|
-
// wrong way round (warning).
|
|
38
|
+
// A declared `sequenceAdapter` works and is simply the wrong way round: every
|
|
39
|
+
// feature adapter takes its sequence from the assembly the track is displayed
|
|
40
|
+
// against, so a hand-written one pins the track to that source. An undeclared
|
|
41
|
+
// one is the schema's unknown-key error, with its own message there.
|
|
63
42
|
const SELF_SUPPLIED = {
|
|
64
|
-
sequenceAdapter:
|
|
65
|
-
undeclared: 'JBrowse takes the sequence from the assembly the track is displayed against, and this adapter declares no `sequenceAdapter` slot, so the one written here is never read — delete it',
|
|
66
|
-
declared: '`sequenceAdapter` is set by hand. JBrowse takes the sequence from the assembly the track is displayed against, so this is only needed to read some OTHER sequence — and it pins the track to that source even when the assembly changes. Delete it unless that is what you meant',
|
|
67
|
-
},
|
|
43
|
+
sequenceAdapter: '`sequenceAdapter` is set by hand. JBrowse takes the sequence from the assembly the track is displayed against, so this is only needed to read some OTHER sequence — and it pins the track to that source even when the assembly changes. Delete it unless that is what you meant',
|
|
68
44
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
report.warn(`${where}.${key}`, selfSupplied.declared);
|
|
77
|
-
}
|
|
78
|
-
continue;
|
|
45
|
+
// The warnings a slot table carries: a legacy key or value a migration
|
|
46
|
+
// rewrites, and a declared key JBrowse fills in for itself.
|
|
47
|
+
function warnSlots(obj, entry, where, report) {
|
|
48
|
+
const declared = new Set(entry.slots.map(s => s.name));
|
|
49
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
50
|
+
if (declared.has(key) && SELF_SUPPLIED[key]) {
|
|
51
|
+
report.warn(`${where}.${key}`, SELF_SUPPLIED[key]);
|
|
79
52
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// that "silently does nothing" is true and useless, and a validator that
|
|
83
|
-
// cries wolf on a deliberate annotation is one an author learns to ignore.
|
|
84
|
-
if (/^_+comment/i.test(key)) {
|
|
85
|
-
continue;
|
|
53
|
+
else if (entry.legacyValues?.[key]?.includes(value)) {
|
|
54
|
+
report.warn(`${where}.${key}`, `${JSON.stringify(value)} is a legacy value of "${key}" that a migration rewrites — the config loads, but the current spelling is one of the enum's members`);
|
|
86
55
|
}
|
|
87
|
-
|
|
88
|
-
// lifted into current slots, so the config does load — but it is stale, and
|
|
89
|
-
// whether every setting inside it survived the lift is worth a look.
|
|
90
|
-
if (legacyKeys.includes(key)) {
|
|
56
|
+
else if (!declared.has(key) && entry.legacyKeys?.includes(key)) {
|
|
91
57
|
report.warn(`${where}.${key}`, `"${key}" is a legacy key that a migration rewrites into current slots — the config loads, but check the settings inside it landed`);
|
|
92
|
-
continue;
|
|
93
58
|
}
|
|
94
|
-
report.error(`${where}.${key}`, SELF_SUPPLIED[key]?.undeclared ??
|
|
95
|
-
`unknown slot "${key}"${didYouMean(key, accepted)} — JBrowse ignores keys it does not declare, so this setting silently does nothing`);
|
|
96
59
|
}
|
|
97
|
-
// Recurse into sub-schemas the config actually filled in. One it omits is
|
|
98
|
-
// fine: the sub-schema supplies its own defaults.
|
|
99
60
|
for (const slot of entry.slots) {
|
|
100
61
|
const value = obj[slot.name];
|
|
101
|
-
if (slot.subSlots
|
|
102
|
-
|
|
62
|
+
if (!slot.subSlots) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
for (const [item, suffix] of isRecord(value)
|
|
66
|
+
? [[value, '']]
|
|
67
|
+
: Array.isArray(value)
|
|
68
|
+
? value.map((v, i) => [v, `[${i}]`])
|
|
69
|
+
: []) {
|
|
70
|
+
if (isRecord(item)) {
|
|
71
|
+
warnSlots(item, { slots: slot.subSlots }, `${where}.${slot.name}${suffix}`, report);
|
|
72
|
+
}
|
|
103
73
|
}
|
|
104
74
|
}
|
|
105
75
|
}
|
|
106
|
-
// Resolves a `type` against one of the manifest's groups.
|
|
107
|
-
//
|
|
108
|
-
//
|
|
109
|
-
// there deliberately:
|
|
110
|
-
//
|
|
111
|
-
// error = JBrowse accepts the config and silently does the wrong thing
|
|
112
|
-
// warning = JBrowse will complain by itself when the config loads
|
|
113
|
-
//
|
|
114
|
-
// An unknown type is loud — MST throws "Unknown track type" on load, so the
|
|
115
|
-
// author finds out either way. It is also frequently not wrong: a plugin
|
|
116
|
-
// registers types this manifest never saw. An unknown *slot* has neither
|
|
117
|
-
// property, which is why that one is the error.
|
|
76
|
+
// Resolves a `type` against one of the manifest's groups. An unregistered type
|
|
77
|
+
// is a warning: MST is loud about it on load, and a plugin registers types the
|
|
78
|
+
// manifest never saw.
|
|
118
79
|
function resolveType(obj, group, groupLabel, where, report) {
|
|
119
80
|
const typeName = obj.type;
|
|
120
81
|
if (typeof typeName !== 'string') {
|
|
121
|
-
report.error(where, `missing "type" — expected one of the ${groupLabel} types`);
|
|
122
82
|
return undefined;
|
|
123
83
|
}
|
|
124
84
|
const canonical = typeName in group
|
|
125
85
|
? typeName
|
|
126
|
-
:
|
|
127
|
-
// canonicalizes it before validation and sessionMigrations restores the
|
|
128
|
-
// settings that made the old type distinct, so this is supported config
|
|
129
|
-
// — check it against the type that absorbed it.
|
|
130
|
-
Object.keys(group).find(name => group[name].aliases?.includes(typeName));
|
|
86
|
+
: Object.keys(group).find(name => group[name].aliases?.includes(typeName));
|
|
131
87
|
const entry = canonical === undefined ? undefined : group[canonical];
|
|
132
88
|
if (entry && canonical !== undefined) {
|
|
133
89
|
return { ...entry, canonicalName: canonical };
|
|
@@ -135,65 +91,26 @@ function resolveType(obj, group, groupLabel, where, report) {
|
|
|
135
91
|
report.warn(where, `${groupLabel} type "${typeName}" is not registered by the core plugins${didYouMean(typeName, Object.keys(group))} — it may come from a plugin`);
|
|
136
92
|
return undefined;
|
|
137
93
|
}
|
|
138
|
-
function checkAdapter(adapter, manifest, where, report) {
|
|
139
|
-
if (!isRecord(adapter)) {
|
|
140
|
-
report.error(where, 'missing "adapter"');
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
const entry = resolveType(adapter, manifest.adapters, 'adapter', `${where}.type`, report);
|
|
144
|
-
if (entry) {
|
|
145
|
-
checkSlots(adapter, entry, where, report);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
// A pluggable sub-object written inline: resolve its type against `group`, then
|
|
149
|
-
// check its own slots. `connections`, `aggregateTextSearchAdapters` and a
|
|
150
|
-
// track's `textSearching.textSearchAdapter` are all this shape, and none of
|
|
151
|
-
// them was opened at all — a Trix path typo is a search that returns nothing,
|
|
152
|
-
// which is the class of mistake this command exists to catch.
|
|
153
94
|
function checkPluggable(obj, group, groupLabel, where, report) {
|
|
154
95
|
if (!isRecord(obj)) {
|
|
155
|
-
report.error(where, `${groupLabel} must be an object`);
|
|
156
96
|
return;
|
|
157
97
|
}
|
|
158
98
|
const entry = resolveType(obj, group, groupLabel, `${where}.type`, report);
|
|
159
99
|
if (entry) {
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
function checkDisplayDefaults(defaults, trackEntry, manifest, where, report) {
|
|
164
|
-
if (!isRecord(defaults)) {
|
|
165
|
-
report.error(where, 'displayDefaults must be an object of display settings');
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const accepted = displayDefaultKeys(trackEntry, manifest);
|
|
169
|
-
if (accepted.length === 0) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
for (const key of Object.keys(defaults)) {
|
|
173
|
-
if (!accepted.includes(key)) {
|
|
174
|
-
report.error(`${where}.${key}`, `no display of this track declares "${key}"${didYouMean(key, accepted)}`);
|
|
175
|
-
}
|
|
100
|
+
warnSlots(obj, entry, where, report);
|
|
176
101
|
}
|
|
177
102
|
}
|
|
178
103
|
function checkTrack(track, index, manifest, report, ctx) {
|
|
179
104
|
const where = `tracks[${index}]`;
|
|
180
|
-
// The loose form: a data file and no adapter. JBrowse infers the track type
|
|
181
|
-
// and adapter from the file's extension at load, so neither is required
|
|
182
|
-
// here, and neither can be checked against the manifest without the format
|
|
183
|
-
// plugins' guessers — the keys written beside `uri` still are.
|
|
184
105
|
const loose = typeof track.uri === 'string' && !('adapter' in track);
|
|
185
|
-
const entry = loose && track.type === undefined
|
|
186
|
-
? undefined
|
|
187
|
-
: resolveType(track, manifest.tracks, 'track', `${where}.type`, report);
|
|
188
106
|
const trackId = track.trackId;
|
|
189
|
-
if (typeof trackId
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
ctx.seenTrackIds.add(trackId);
|
|
107
|
+
if (typeof trackId === 'string' && trackId) {
|
|
108
|
+
if (ctx.seenTrackIds.has(trackId)) {
|
|
109
|
+
report.error(`${where}.trackId`, `duplicate trackId "${trackId}" — a later track with the same id shadows the earlier one`);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
ctx.seenTrackIds.add(trackId);
|
|
113
|
+
}
|
|
197
114
|
}
|
|
198
115
|
const names = track.assemblyNames;
|
|
199
116
|
if (!Array.isArray(names) || names.length === 0) {
|
|
@@ -204,120 +121,49 @@ function checkTrack(track, index, manifest, report, ctx) {
|
|
|
204
121
|
else {
|
|
205
122
|
for (const name of names) {
|
|
206
123
|
if (typeof name === 'string' && !ctx.assemblyNames.has(name)) {
|
|
207
|
-
// The connection caveat leads and the spelling guess trails
|
|
208
|
-
// connection
|
|
209
|
-
//
|
|
210
|
-
// and `did you mean "volvox_del"?` called a working config a typo.
|
|
124
|
+
// The connection caveat leads and the spelling guess trails: a
|
|
125
|
+
// connection added at runtime can supply the assembly, and a guess
|
|
126
|
+
// called a working config a typo.
|
|
211
127
|
report.error(`${where}.assemblyNames`, `assembly "${name}" is not defined in this config, and no connection here supplies one — though a connection added at runtime can${didYouMean(name, [...ctx.assemblyNames])}`);
|
|
212
128
|
}
|
|
213
129
|
}
|
|
214
130
|
}
|
|
215
|
-
|
|
216
|
-
// displayDefaults is a shorthand no track schema declares, so it is
|
|
217
|
-
// exempted from the track's own slot check and validated on its own terms.
|
|
218
|
-
checkSlots(track, {
|
|
219
|
-
...entry,
|
|
220
|
-
shorthandKeys: [
|
|
221
|
-
...(entry.shorthandKeys ?? []),
|
|
222
|
-
'displayDefaults',
|
|
223
|
-
...(loose ? ['uri', 'index'] : []),
|
|
224
|
-
],
|
|
225
|
-
}, where, report);
|
|
226
|
-
if (track.displayDefaults !== undefined) {
|
|
227
|
-
checkDisplayDefaults(track.displayDefaults, entry, manifest, `${where}.displayDefaults`, report);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
131
|
+
checkPluggable(track, manifest.tracks, 'track', where, report);
|
|
230
132
|
if (!loose) {
|
|
231
|
-
|
|
133
|
+
checkPluggable(track.adapter, manifest.adapters, 'adapter', `${where}.adapter`, report);
|
|
232
134
|
}
|
|
233
135
|
const textSearching = track.textSearching;
|
|
234
|
-
if (isRecord(textSearching)
|
|
235
|
-
textSearching.textSearchAdapter !== undefined) {
|
|
136
|
+
if (isRecord(textSearching)) {
|
|
236
137
|
checkPluggable(textSearching.textSearchAdapter, manifest.textSearchAdapters, 'text search adapter', `${where}.textSearching.textSearchAdapter`, report);
|
|
237
138
|
}
|
|
238
139
|
if (Array.isArray(track.displays)) {
|
|
239
140
|
for (const [i, display] of track.displays.entries()) {
|
|
240
|
-
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
const displayWhere = `${where}.displays[${i}]`;
|
|
244
|
-
const displayEntry = resolveType(display, manifest.displays, 'display', `${displayWhere}.type`, report);
|
|
245
|
-
if (displayEntry) {
|
|
246
|
-
checkSlots(display, displayEntry, displayWhere, report);
|
|
247
|
-
}
|
|
141
|
+
checkPluggable(display, manifest.displays, 'display', `${where}.displays[${i}]`, report);
|
|
248
142
|
}
|
|
249
143
|
}
|
|
250
144
|
}
|
|
251
145
|
function checkAssembly(assembly, index, manifest, report) {
|
|
252
|
-
const
|
|
253
|
-
if (
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
// An assembly has three levels of shorthand, all filled in by
|
|
257
|
-
// assemblyConfigSchema's preProcessSnapshot, and this used to reject every one
|
|
258
|
-
// of them — including `{ name, uri }`, which the cookbook calls the smallest
|
|
259
|
-
// possible config:
|
|
260
|
-
//
|
|
261
|
-
// 1. `{ name, uri }` -> sequence: { adapter: { uri } }
|
|
262
|
-
// 2. `sequence: { adapter: { uri } }` -> adapter type from the extension
|
|
263
|
-
// 3. sequence with no type/trackId -> ReferenceSequenceTrack, derived id
|
|
264
|
-
//
|
|
265
|
-
// Only (2) can't be checked here, and deliberately: the type is guessed
|
|
266
|
-
// through the `Core-guessAdapterForLocation` extension point, and this command
|
|
267
|
-
// loads no plugins on purpose. A `uri` is therefore taken as enough — saying
|
|
268
|
-
// nothing about an adapter we can't name beats calling a working config broken.
|
|
269
|
-
const sequence = assembly.sequence ??
|
|
270
|
-
(typeof assembly.uri === 'string'
|
|
271
|
-
? { adapter: { uri: assembly.uri } }
|
|
272
|
-
: undefined);
|
|
273
|
-
if (!isRecord(sequence)) {
|
|
274
|
-
report.error(`${where}.sequence`, 'missing "sequence" track (or a `uri` naming the sequence file)');
|
|
275
|
-
return;
|
|
146
|
+
const sequence = assembly.sequence;
|
|
147
|
+
if (isRecord(sequence) && isRecord(sequence.adapter)) {
|
|
148
|
+
checkPluggable(sequence.adapter, manifest.adapters, 'adapter', `assemblies[${index}].sequence.adapter`, report);
|
|
276
149
|
}
|
|
277
|
-
if (isRecord(sequence.adapter) && !('type' in sequence.adapter)) {
|
|
278
|
-
if (typeof sequence.adapter.uri !== 'string') {
|
|
279
|
-
report.error(`${where}.sequence.adapter`, 'adapter has neither a "type" nor a "uri" to infer one from');
|
|
280
|
-
}
|
|
281
|
-
return;
|
|
282
|
-
}
|
|
283
|
-
checkAdapter(sequence.adapter, manifest, `${where}.sequence.adapter`, report);
|
|
284
150
|
}
|
|
285
|
-
// A display node
|
|
286
|
-
//
|
|
287
|
-
//
|
|
288
|
-
// exactly like a misspelling: the session loads, the track appears, the setting
|
|
289
|
-
// does nothing. That is the same silent failure the slot checks above exist for,
|
|
290
|
-
// on the surface people hand-write most, and it is why a whole class of these
|
|
291
|
-
// sat unnoticed in this repo's own fixtures.
|
|
292
|
-
//
|
|
293
|
-
// The advice differs from the unknown-slot case, so the messages do too — a slot
|
|
294
|
-
// is real, it is just in the wrong place, and there are two right places for it.
|
|
151
|
+
// A display node inside a session is instantiated by the display's state
|
|
152
|
+
// model; the schema reports a key it does not declare. What remains here is
|
|
153
|
+
// the legacy display-instance key a session migration still lifts.
|
|
295
154
|
function checkSessionDisplay(display, manifest, where, report) {
|
|
296
155
|
const entry = resolveType(display, manifest.displays, 'display', `${where}.type`, report);
|
|
297
|
-
// A display type the manifest doesn't know (a plugin's) has already been
|
|
298
|
-
// reported as a warning by resolveType; its props are unknowable here.
|
|
299
156
|
if (!entry?.stateModelProps) {
|
|
300
157
|
return;
|
|
301
158
|
}
|
|
302
|
-
const props = entry.stateModelProps;
|
|
303
|
-
const slots = entry.slots.map(slot => slot.name);
|
|
304
159
|
const migrated = new Set([
|
|
305
160
|
...(manifest.migratedDisplayKeys['*'] ?? []),
|
|
306
161
|
...(manifest.migratedDisplayKeys[entry.canonicalName] ?? []),
|
|
307
162
|
]);
|
|
308
163
|
for (const key of Object.keys(display)) {
|
|
309
|
-
if (
|
|
310
|
-
continue;
|
|
311
|
-
}
|
|
312
|
-
if (migrated.has(key)) {
|
|
164
|
+
if (!entry.stateModelProps.includes(key) && migrated.has(key)) {
|
|
313
165
|
report.warn(`${where}.${key}`, `"${key}" is a legacy display-instance key that a session migration lifts onto the config slot replacing it — it still works, but writing the current slot is clearer`);
|
|
314
166
|
}
|
|
315
|
-
else if (slots.includes(key)) {
|
|
316
|
-
report.error(`${where}.${key}`, `"${key}" is a config slot, not a display property, so a session snapshot drops it and the setting silently does nothing — put it on the track's "displays" entry under "tracks", or in a "trackConfigDeltas" entry, instead`);
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
report.error(`${where}.${key}`, `unknown display property "${key}"${didYouMean(key, [...props, ...slots])} — a session snapshot drops keys the display does not declare, so this setting silently does nothing`);
|
|
320
|
-
}
|
|
321
167
|
}
|
|
322
168
|
}
|
|
323
169
|
// Walks the tracks of a view and its sub-views (a synteny view holds a row of
|
|
@@ -344,40 +190,6 @@ function checkSessionViewTracks(view, manifest, where, report) {
|
|
|
344
190
|
}
|
|
345
191
|
}
|
|
346
192
|
}
|
|
347
|
-
// A view node in a session — `defaultSession.views[]` — is instantiated by the
|
|
348
|
-
// view's STATE MODEL, and a view has no config schema at all, so every setting
|
|
349
|
-
// an author writes lands on that node: the properties MST restores, plus the
|
|
350
|
-
// launch keys a launcher resolves (`assembly`, `loc`, `tracks`). Those two
|
|
351
|
-
// together are the whole accepted set, which is what makes this check
|
|
352
|
-
// exhaustive rather than a guess — anything else is dropped exactly like a
|
|
353
|
-
// misspelling, and the view opens on its defaults with nothing said.
|
|
354
|
-
//
|
|
355
|
-
// The same trap checkSessionDisplay catches one level down, and the same three
|
|
356
|
-
// diagnoses: a real key in the wrong place, a stale spelling that still works,
|
|
357
|
-
// and a key nothing anywhere reads.
|
|
358
|
-
function checkSessionViewKeys(view, entry, manifest, where, report) {
|
|
359
|
-
const accepted = [
|
|
360
|
-
...entry.stateModelProps,
|
|
361
|
-
...entry.launchKeys,
|
|
362
|
-
...(entry.passThrough ?? []),
|
|
363
|
-
];
|
|
364
|
-
for (const key of Object.keys(view)) {
|
|
365
|
-
// `init` gets its own message from checkSessionView below
|
|
366
|
-
if (accepted.includes(key) || key === 'init') {
|
|
367
|
-
continue;
|
|
368
|
-
}
|
|
369
|
-
// Whichever other view types do read the key. `assembly` on a DotplotView is
|
|
370
|
-
// not a misspelling and no suggestion reaches it, so naming the views that
|
|
371
|
-
// take it is the only thing that tells the author what they wrote.
|
|
372
|
-
const elsewhere = Object.entries(manifest.views)
|
|
373
|
-
.filter(([name, other]) => name !== entry.canonicalName &&
|
|
374
|
-
[...other.stateModelProps, ...other.launchKeys].includes(key))
|
|
375
|
-
.map(([name]) => name);
|
|
376
|
-
report.error(`${where}.${key}`, elsewhere.length
|
|
377
|
-
? `"${key}" is a setting of ${elsewhere.join(', ')}, not of ${entry.canonicalName}${didYouMean(key, accepted)} — a session snapshot drops keys the view does not declare, so this setting silently does nothing`
|
|
378
|
-
: `unknown view key "${key}"${didYouMean(key, accepted)} — a session snapshot drops keys the view does not declare, so this setting silently does nothing`);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
193
|
// The ids a view names, which nothing validates at load: a trackId that does not
|
|
382
194
|
// exist simply fails to open, which reads as a rendering bug rather than a typo.
|
|
383
195
|
function checkViewReferences(view, where, report, ctx) {
|
|
@@ -388,10 +200,8 @@ function checkViewReferences(view, where, report, ctx) {
|
|
|
388
200
|
if (!Array.isArray(view.tracks)) {
|
|
389
201
|
return;
|
|
390
202
|
}
|
|
391
|
-
// A LinearSyntenyView's `tracks` is one array
|
|
392
|
-
//
|
|
393
|
-
// inner arrays as track entries reported every genome row of every synteny
|
|
394
|
-
// demo as a track with no trackId.
|
|
203
|
+
// A LinearSyntenyView's `tracks` is one array per level, so flatten one level
|
|
204
|
+
// before reading entries.
|
|
395
205
|
const entries = view.tracks.flatMap((t) => Array.isArray(t) ? t : [t]);
|
|
396
206
|
for (const [j, entry] of entries.entries()) {
|
|
397
207
|
// A built track snapshot names its config through `configuration` rather
|
|
@@ -400,10 +210,8 @@ function checkViewReferences(view, where, report, ctx) {
|
|
|
400
210
|
continue;
|
|
401
211
|
}
|
|
402
212
|
const trackId = isRecord(entry) ? entry.trackId : entry;
|
|
403
|
-
if (typeof trackId
|
|
404
|
-
|
|
405
|
-
}
|
|
406
|
-
else if (!ctx.seenTrackIds.has(trackId) &&
|
|
213
|
+
if (typeof trackId === 'string' &&
|
|
214
|
+
!ctx.seenTrackIds.has(trackId) &&
|
|
407
215
|
!ctx.sequenceTrackIds.has(trackId)) {
|
|
408
216
|
report.error(`${where}.tracks[${j}]`, `trackId "${trackId}" is not defined in this config${didYouMean(trackId, [...ctx.seenTrackIds, ...ctx.sequenceTrackIds])}`);
|
|
409
217
|
}
|
|
@@ -411,26 +219,21 @@ function checkViewReferences(view, where, report, ctx) {
|
|
|
411
219
|
}
|
|
412
220
|
function checkSessionView(view, manifest, where, report, ctx) {
|
|
413
221
|
const entry = resolveType(view, manifest.views, 'view', `${where}.type`, report);
|
|
414
|
-
// A view type the manifest doesn't know (a plugin's) is already a warning from
|
|
415
|
-
// resolveType, and its keys are unknowable here.
|
|
416
222
|
if (!entry) {
|
|
417
223
|
return;
|
|
418
224
|
}
|
|
419
|
-
checkSessionViewKeys(view, entry, manifest, where, report);
|
|
420
225
|
checkViewReferences(view, where, report, ctx);
|
|
421
226
|
// A warning, not an error: v5 unwraps the nesting on the way in, so the
|
|
422
|
-
// settings do arrive.
|
|
423
|
-
// since that is where they land.
|
|
227
|
+
// settings do arrive.
|
|
424
228
|
if (view.init !== undefined) {
|
|
425
229
|
report.warn(`${where}.init`, 'settings nested under "init", which is deprecated: write every setting directly on the view object');
|
|
426
230
|
if (isRecord(view.init)) {
|
|
427
|
-
checkSessionViewKeys(view.init, entry, manifest, `${where}.init`, report);
|
|
428
231
|
checkViewReferences(view.init, `${where}.init`, report, ctx);
|
|
429
232
|
}
|
|
430
233
|
}
|
|
431
|
-
// A synteny or breakpoint row is a whole view snapshot of its own.
|
|
432
|
-
//
|
|
433
|
-
//
|
|
234
|
+
// A synteny or breakpoint row is a whole view snapshot of its own. A row
|
|
235
|
+
// written as a recipe names no view type, and which one it becomes is the
|
|
236
|
+
// parent launcher's business.
|
|
434
237
|
if (Array.isArray(view.views)) {
|
|
435
238
|
for (const [i, row] of view.views.entries()) {
|
|
436
239
|
if (isRecord(row) && typeof row.type === 'string') {
|
|
@@ -459,8 +262,9 @@ export function validateConfig(config, manifest = configManifest) {
|
|
|
459
262
|
return report.result();
|
|
460
263
|
}
|
|
461
264
|
if (Array.isArray(config.plugins) && config.plugins.length > 0) {
|
|
462
|
-
report.note(`config declares ${config.plugins.length} plugin(s); the types and slots they register are not in the
|
|
265
|
+
report.note(`config declares ${config.plugins.length} plugin(s); the types and slots they register are not in the schema and cannot be checked`);
|
|
463
266
|
}
|
|
267
|
+
report.problems.push(...schemaProblems(config));
|
|
464
268
|
const assemblies = (Array.isArray(config.assemblies)
|
|
465
269
|
? config.assemblies
|
|
466
270
|
: isRecord(config.assembly)
|
|
@@ -469,24 +273,15 @@ export function validateConfig(config, manifest = configManifest) {
|
|
|
469
273
|
if (assemblies.length === 0) {
|
|
470
274
|
report.error('assemblies', 'no assemblies — a config needs at least one');
|
|
471
275
|
}
|
|
472
|
-
const connections = Array.isArray(config.connections)
|
|
473
|
-
? config.connections
|
|
474
|
-
: [];
|
|
475
276
|
const ctx = {
|
|
476
|
-
// An assembly's `aliases` are usable wherever its name is
|
|
477
|
-
// `assemblyNames: ['vvx']` against an assembly named volvox that lists vvx
|
|
478
|
-
// as an alias. Leaving them out reports working configs as broken.
|
|
277
|
+
// An assembly's `aliases` are usable wherever its name is.
|
|
479
278
|
assemblyNames: new Set(assemblies
|
|
480
279
|
.flatMap(a => [a.name, ...(Array.isArray(a.aliases) ? a.aliases : [])])
|
|
481
280
|
.filter((n) => typeof n === 'string')),
|
|
482
281
|
assemblyCount: assemblies.length,
|
|
483
282
|
seenTrackIds: new Set(),
|
|
484
|
-
//
|
|
485
|
-
//
|
|
486
|
-
// the assembly rather than in `tracks`, and collecting only `tracks`
|
|
487
|
-
// reported every such reference as undefined. Both the written trackId and
|
|
488
|
-
// the one the `{name, uri}` shorthand derives, since a config using the
|
|
489
|
-
// shorthand still gets the derived id at runtime.
|
|
283
|
+
// Both the written trackId and the one the `{name, uri}` shorthand derives,
|
|
284
|
+
// since a config using the shorthand still gets the derived id at runtime.
|
|
490
285
|
sequenceTrackIds: new Set(assemblies.flatMap(a => {
|
|
491
286
|
const declared = isRecord(a.sequence) ? a.sequence.trackId : undefined;
|
|
492
287
|
return [
|
|
@@ -506,6 +301,9 @@ export function validateConfig(config, manifest = configManifest) {
|
|
|
506
301
|
for (const [i, track] of tracks.entries()) {
|
|
507
302
|
checkTrack(track, i, manifest, report, ctx);
|
|
508
303
|
}
|
|
304
|
+
const connections = Array.isArray(config.connections)
|
|
305
|
+
? config.connections
|
|
306
|
+
: [];
|
|
509
307
|
for (const [i, connection] of connections.entries()) {
|
|
510
308
|
checkPluggable(connection, manifest.connections, 'connection', `connections[${i}]`, report);
|
|
511
309
|
}
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '5.0.0-beta.
|
|
1
|
+
export const version = '5.0.0-beta.7';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/cli",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A command line tool for working with JBrowse 2",
|
|
6
6
|
"keywords": [
|
|
@@ -27,13 +27,14 @@
|
|
|
27
27
|
"node": ">=18.3.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
+
"ajv": "^8.20.0",
|
|
30
31
|
"cli-progress": "^3.12.0",
|
|
31
32
|
"ixixx": "^3.0.13",
|
|
32
33
|
"serve-handler": "^6.1.7",
|
|
33
34
|
"tmp": "^0.2.7",
|
|
34
|
-
"@jbrowse/
|
|
35
|
-
"@jbrowse/
|
|
36
|
-
"@jbrowse/text-indexing-core": "^5.0.0-beta.
|
|
35
|
+
"@jbrowse/cigar-utils": "^5.0.0-beta.7",
|
|
36
|
+
"@jbrowse/add-track-core": "^5.0.0-beta.7",
|
|
37
|
+
"@jbrowse/text-indexing-core": "^5.0.0-beta.7"
|
|
37
38
|
},
|
|
38
39
|
"publishConfig": {
|
|
39
40
|
"access": "public"
|