@apollo-annotation/cli 0.1.16 → 0.1.18
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 +28 -28
- package/dist/ApolloConf.d.ts +22 -0
- package/dist/ApolloConf.js +143 -0
- package/dist/baseCommand.js +3 -14
- package/dist/commands/assembly/add-fasta.js +16 -26
- package/dist/commands/assembly/add-gff.js +11 -23
- package/dist/commands/assembly/check.js +7 -18
- package/dist/commands/assembly/delete.js +1 -1
- package/dist/commands/assembly/sequence.js +3 -11
- package/dist/commands/config.js +20 -52
- package/dist/commands/feature/add-child.js +10 -16
- package/dist/commands/feature/copy.js +13 -22
- package/dist/commands/feature/delete.js +7 -16
- package/dist/commands/feature/edit-attribute.js +3 -4
- package/dist/commands/feature/edit-coords.js +8 -11
- package/dist/commands/feature/edit-type.js +4 -3
- package/dist/commands/feature/edit.js +3 -15
- package/dist/commands/feature/get.js +6 -17
- package/dist/commands/feature/import.js +6 -12
- package/dist/commands/login.js +16 -28
- package/dist/commands/logout.js +4 -13
- package/dist/commands/status.js +4 -12
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +8 -14
- package/oclif.manifest.json +57 -57
- package/package.json +2 -1
- package/dist/Config.d.ts +0 -43
- package/dist/Config.js +0 -233
- package/dist/commands/config.test.d.ts +0 -1
- package/dist/commands/config.test.js +0 -188
- package/dist/commands/login.test.d.ts +0 -1
- package/dist/commands/login.test.js +0 -52
- package/dist/commands/logout.test.d.ts +0 -1
- package/dist/commands/logout.test.js +0 -67
- package/dist/commands/status.test.d.ts +0 -1
- package/dist/commands/status.test.js +0 -54
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ $ npm install -g @apollo-annotation/cli
|
|
|
14
14
|
$ apollo COMMAND
|
|
15
15
|
running command...
|
|
16
16
|
$ apollo (--version)
|
|
17
|
-
@apollo-annotation/cli/0.1.
|
|
17
|
+
@apollo-annotation/cli/0.1.18 linux-x64 node-v18.20.3
|
|
18
18
|
$ apollo --help [COMMAND]
|
|
19
19
|
USAGE
|
|
20
20
|
$ apollo COMMAND
|
|
@@ -82,7 +82,7 @@ EXAMPLES
|
|
|
82
82
|
$ apollo assembly add-fasta -i https://.../genome.fa -x https://.../genome.fa.fai -a myAssembly
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
_See code: [src/commands/assembly/add-fasta.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
85
|
+
_See code: [src/commands/assembly/add-fasta.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/assembly/add-fasta.ts)_
|
|
86
86
|
|
|
87
87
|
## `apollo assembly add-gff`
|
|
88
88
|
|
|
@@ -116,7 +116,7 @@ EXAMPLES
|
|
|
116
116
|
$ apollo assembly add-gff -i genome.gff -a myAssembly -o
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
_See code: [src/commands/assembly/add-gff.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
119
|
+
_See code: [src/commands/assembly/add-gff.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/assembly/add-gff.ts)_
|
|
120
120
|
|
|
121
121
|
## `apollo assembly check`
|
|
122
122
|
|
|
@@ -137,8 +137,8 @@ DESCRIPTION
|
|
|
137
137
|
Add, view, or delete checks to assembly
|
|
138
138
|
|
|
139
139
|
Manage checks, i.e. the rules ensuring features in an assembly are plausible.
|
|
140
|
-
This command only sets the
|
|
141
|
-
checks use `apollo feature check`.
|
|
140
|
+
This command only sets the checks to apply, to retrieve features flagged by
|
|
141
|
+
these checks use `apollo feature check`.
|
|
142
142
|
|
|
143
143
|
EXAMPLES
|
|
144
144
|
View available check types:
|
|
@@ -158,7 +158,7 @@ EXAMPLES
|
|
|
158
158
|
$ apollo assembly check -a hg19 -c CDSCheck --delete
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
_See code: [src/commands/assembly/check.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
161
|
+
_See code: [src/commands/assembly/check.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/assembly/check.ts)_
|
|
162
162
|
|
|
163
163
|
## `apollo assembly delete`
|
|
164
164
|
|
|
@@ -185,7 +185,7 @@ EXAMPLES
|
|
|
185
185
|
$ apollo assembly delete -a mouse 6605826fbd0eee691f83e73f
|
|
186
186
|
```
|
|
187
187
|
|
|
188
|
-
_See code: [src/commands/assembly/delete.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
188
|
+
_See code: [src/commands/assembly/delete.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/assembly/delete.ts)_
|
|
189
189
|
|
|
190
190
|
## `apollo assembly get`
|
|
191
191
|
|
|
@@ -206,7 +206,7 @@ DESCRIPTION
|
|
|
206
206
|
Print to stdout the list of assemblies in json format
|
|
207
207
|
```
|
|
208
208
|
|
|
209
|
-
_See code: [src/commands/assembly/get.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
209
|
+
_See code: [src/commands/assembly/get.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/assembly/get.ts)_
|
|
210
210
|
|
|
211
211
|
## `apollo assembly sequence`
|
|
212
212
|
|
|
@@ -240,7 +240,7 @@ EXAMPLES
|
|
|
240
240
|
$ apollo assembly sequence -a myAssembly -r chr1 -s 1 -e 1000
|
|
241
241
|
```
|
|
242
242
|
|
|
243
|
-
_See code: [src/commands/assembly/sequence.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
243
|
+
_See code: [src/commands/assembly/sequence.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/assembly/sequence.ts)_
|
|
244
244
|
|
|
245
245
|
## `apollo change get`
|
|
246
246
|
|
|
@@ -264,7 +264,7 @@ DESCRIPTION
|
|
|
264
264
|
need to use the assembly ID.
|
|
265
265
|
```
|
|
266
266
|
|
|
267
|
-
_See code: [src/commands/change/get.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
267
|
+
_See code: [src/commands/change/get.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/change/get.ts)_
|
|
268
268
|
|
|
269
269
|
## `apollo config [KEY] [VALUE]`
|
|
270
270
|
|
|
@@ -319,7 +319,7 @@ EXAMPLES
|
|
|
319
319
|
$ apollo config address
|
|
320
320
|
```
|
|
321
321
|
|
|
322
|
-
_See code: [src/commands/config.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
322
|
+
_See code: [src/commands/config.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/config.ts)_
|
|
323
323
|
|
|
324
324
|
## `apollo feature add-child`
|
|
325
325
|
|
|
@@ -349,7 +349,7 @@ EXAMPLES
|
|
|
349
349
|
$ apollo feature add-child -i 6605826fbd0eee691f83e73f -t exon -s 10 -e 20
|
|
350
350
|
```
|
|
351
351
|
|
|
352
|
-
_See code: [src/commands/feature/add-child.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
352
|
+
_See code: [src/commands/feature/add-child.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/feature/add-child.ts)_
|
|
353
353
|
|
|
354
354
|
## `apollo feature check`
|
|
355
355
|
|
|
@@ -382,7 +382,7 @@ EXAMPLES
|
|
|
382
382
|
$ apollo feature check -a hg19
|
|
383
383
|
```
|
|
384
384
|
|
|
385
|
-
_See code: [src/commands/feature/check.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
385
|
+
_See code: [src/commands/feature/check.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/feature/check.ts)_
|
|
386
386
|
|
|
387
387
|
## `apollo feature copy`
|
|
388
388
|
|
|
@@ -413,7 +413,7 @@ EXAMPLES
|
|
|
413
413
|
$ apollo feature copy -i 6605826fbd0eee691f83e73f -r chr1 -s 100 -a hg38
|
|
414
414
|
```
|
|
415
415
|
|
|
416
|
-
_See code: [src/commands/feature/copy.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
416
|
+
_See code: [src/commands/feature/copy.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/feature/copy.ts)_
|
|
417
417
|
|
|
418
418
|
## `apollo feature delete`
|
|
419
419
|
|
|
@@ -437,7 +437,7 @@ DESCRIPTION
|
|
|
437
437
|
error unless you set -f/--force.
|
|
438
438
|
```
|
|
439
439
|
|
|
440
|
-
_See code: [src/commands/feature/delete.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
440
|
+
_See code: [src/commands/feature/delete.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/feature/delete.ts)_
|
|
441
441
|
|
|
442
442
|
## `apollo feature edit`
|
|
443
443
|
|
|
@@ -479,7 +479,7 @@ EXAMPLES
|
|
|
479
479
|
echo '{"typeName": ... "newType": "G_quartet"}' | apollo feature edit -j -
|
|
480
480
|
```
|
|
481
481
|
|
|
482
|
-
_See code: [src/commands/feature/edit.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
482
|
+
_See code: [src/commands/feature/edit.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/feature/edit.ts)_
|
|
483
483
|
|
|
484
484
|
## `apollo feature edit-attribute`
|
|
485
485
|
|
|
@@ -519,7 +519,7 @@ EXAMPLES
|
|
|
519
519
|
$ apollo feature edit-attribute -i 66...3f -a domains -d
|
|
520
520
|
```
|
|
521
521
|
|
|
522
|
-
_See code: [src/commands/feature/edit-attribute.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
522
|
+
_See code: [src/commands/feature/edit-attribute.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/feature/edit-attribute.ts)_
|
|
523
523
|
|
|
524
524
|
## `apollo feature edit-coords`
|
|
525
525
|
|
|
@@ -553,7 +553,7 @@ EXAMPLES
|
|
|
553
553
|
$ apollo feature edit-coords -i abc...xyz -e 2000
|
|
554
554
|
```
|
|
555
555
|
|
|
556
|
-
_See code: [src/commands/feature/edit-coords.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
556
|
+
_See code: [src/commands/feature/edit-coords.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/feature/edit-coords.ts)_
|
|
557
557
|
|
|
558
558
|
## `apollo feature edit-type`
|
|
559
559
|
|
|
@@ -576,7 +576,7 @@ DESCRIPTION
|
|
|
576
576
|
term although but the valifdity of the new term is not checked.
|
|
577
577
|
```
|
|
578
578
|
|
|
579
|
-
_See code: [src/commands/feature/edit-type.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
579
|
+
_See code: [src/commands/feature/edit-type.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/feature/edit-type.ts)_
|
|
580
580
|
|
|
581
581
|
## `apollo feature get`
|
|
582
582
|
|
|
@@ -609,7 +609,7 @@ EXAMPLES
|
|
|
609
609
|
$ apollo feature get -a myAssembly -r chr1 -s 1 -e 1000
|
|
610
610
|
```
|
|
611
611
|
|
|
612
|
-
_See code: [src/commands/feature/get.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
612
|
+
_See code: [src/commands/feature/get.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/feature/get.ts)_
|
|
613
613
|
|
|
614
614
|
## `apollo feature get-id`
|
|
615
615
|
|
|
@@ -638,7 +638,7 @@ EXAMPLES
|
|
|
638
638
|
$ apollo feature get-id -i abc...zyz def...foo
|
|
639
639
|
```
|
|
640
640
|
|
|
641
|
-
_See code: [src/commands/feature/get-id.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
641
|
+
_See code: [src/commands/feature/get-id.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/feature/get-id.ts)_
|
|
642
642
|
|
|
643
643
|
## `apollo feature import`
|
|
644
644
|
|
|
@@ -666,7 +666,7 @@ EXAMPLES
|
|
|
666
666
|
$ apollo feature import -d -i features.gff3 -a myAssembly
|
|
667
667
|
```
|
|
668
668
|
|
|
669
|
-
_See code: [src/commands/feature/import.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
669
|
+
_See code: [src/commands/feature/import.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/feature/import.ts)_
|
|
670
670
|
|
|
671
671
|
## `apollo feature search`
|
|
672
672
|
|
|
@@ -717,7 +717,7 @@ EXAMPLES
|
|
|
717
717
|
$ apollo feature search -a mm9 mm10 -t bac
|
|
718
718
|
```
|
|
719
719
|
|
|
720
|
-
_See code: [src/commands/feature/search.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
720
|
+
_See code: [src/commands/feature/search.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/feature/search.ts)_
|
|
721
721
|
|
|
722
722
|
## `apollo help [COMMANDS]`
|
|
723
723
|
|
|
@@ -777,7 +777,7 @@ EXAMPLES
|
|
|
777
777
|
$ apollo login --profile my-profile
|
|
778
778
|
```
|
|
779
779
|
|
|
780
|
-
_See code: [src/commands/login.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
780
|
+
_See code: [src/commands/login.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/login.ts)_
|
|
781
781
|
|
|
782
782
|
## `apollo logout`
|
|
783
783
|
|
|
@@ -806,7 +806,7 @@ EXAMPLES
|
|
|
806
806
|
$ apollo logout --profile my-profile
|
|
807
807
|
```
|
|
808
808
|
|
|
809
|
-
_See code: [src/commands/logout.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
809
|
+
_See code: [src/commands/logout.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/logout.ts)_
|
|
810
810
|
|
|
811
811
|
## `apollo refseq get`
|
|
812
812
|
|
|
@@ -838,7 +838,7 @@ EXAMPLES
|
|
|
838
838
|
$ apollo refseq get -a mm9 mm10
|
|
839
839
|
```
|
|
840
840
|
|
|
841
|
-
_See code: [src/commands/refseq/get.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
841
|
+
_See code: [src/commands/refseq/get.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/refseq/get.ts)_
|
|
842
842
|
|
|
843
843
|
## `apollo status`
|
|
844
844
|
|
|
@@ -860,7 +860,7 @@ DESCRIPTION
|
|
|
860
860
|
not check the validity of the access token.
|
|
861
861
|
```
|
|
862
862
|
|
|
863
|
-
_See code: [src/commands/status.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
863
|
+
_See code: [src/commands/status.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/status.ts)_
|
|
864
864
|
|
|
865
865
|
## `apollo user get`
|
|
866
866
|
|
|
@@ -895,5 +895,5 @@ EXAMPLES
|
|
|
895
895
|
$ apollo user get | jq '.[] | select(.createdAt > "2024-03-18")'
|
|
896
896
|
```
|
|
897
897
|
|
|
898
|
-
_See code: [src/commands/user/get.ts](https://github.com/GMOD/Apollo3/blob/v0.1.
|
|
898
|
+
_See code: [src/commands/user/get.ts](https://github.com/GMOD/Apollo3/blob/v0.1.18/packages/apollo-cli/src/commands/user/get.ts)_
|
|
899
899
|
<!-- commandsstop -->
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Conf from 'conf';
|
|
2
|
+
export declare class ConfigError extends Error {
|
|
3
|
+
}
|
|
4
|
+
export declare enum KEYS {
|
|
5
|
+
address = "address",
|
|
6
|
+
accessType = "accessType",
|
|
7
|
+
accessToken = "accessToken",
|
|
8
|
+
rootCredentials_username = "rootCredentials.username",
|
|
9
|
+
rootCredentials_password = "rootCredentials.password"
|
|
10
|
+
}
|
|
11
|
+
export declare function optionDesc(): string[];
|
|
12
|
+
export declare class ApolloConf extends Conf {
|
|
13
|
+
constructor(configFile: string);
|
|
14
|
+
get store(): Record<string, unknown>;
|
|
15
|
+
set store(newStore: Record<string, unknown>);
|
|
16
|
+
getProfileNames(): string[];
|
|
17
|
+
setAccessType(profileName: string, accessType: string): void;
|
|
18
|
+
getAccess(profileName: string): Promise<{
|
|
19
|
+
address: string;
|
|
20
|
+
accessToken: string;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import Conf from 'conf';
|
|
4
|
+
import Joi from 'joi';
|
|
5
|
+
import YAML from 'yaml';
|
|
6
|
+
import { checkProfileExists, queryApollo } from './utils.js';
|
|
7
|
+
export class ConfigError extends Error {
|
|
8
|
+
}
|
|
9
|
+
export var KEYS;
|
|
10
|
+
(function (KEYS) {
|
|
11
|
+
KEYS["address"] = "address";
|
|
12
|
+
KEYS["accessType"] = "accessType";
|
|
13
|
+
KEYS["accessToken"] = "accessToken";
|
|
14
|
+
KEYS["rootCredentials_username"] = "rootCredentials.username";
|
|
15
|
+
KEYS["rootCredentials_password"] = "rootCredentials.password";
|
|
16
|
+
})(KEYS || (KEYS = {}));
|
|
17
|
+
function optionDocs() {
|
|
18
|
+
const docs = [];
|
|
19
|
+
for (const v of Object.values(KEYS)) {
|
|
20
|
+
switch (v) {
|
|
21
|
+
case 'address': {
|
|
22
|
+
docs.push({
|
|
23
|
+
key: v,
|
|
24
|
+
description: 'Address and port e.g http://localhost:3999',
|
|
25
|
+
});
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
case 'accessType': {
|
|
29
|
+
docs.push({
|
|
30
|
+
key: v,
|
|
31
|
+
description: 'How to access Apollo. accessType is typically one of: google, microsoft, guest, root. Allowed types depend on your Apollo setup',
|
|
32
|
+
});
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
case 'accessToken': {
|
|
36
|
+
docs.push({
|
|
37
|
+
key: v,
|
|
38
|
+
description: 'Access token. Usually inserted by `apollo login`',
|
|
39
|
+
});
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case 'rootCredentials.username': {
|
|
43
|
+
docs.push({
|
|
44
|
+
key: v,
|
|
45
|
+
description: 'Username of root account. Only set this for "root" access type',
|
|
46
|
+
});
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case 'rootCredentials.password': {
|
|
50
|
+
docs.push({
|
|
51
|
+
key: v,
|
|
52
|
+
description: 'Password for root account. Only set this for "root" access type',
|
|
53
|
+
});
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
default: {
|
|
57
|
+
throw new ConfigError(`Unexpected key: ${v}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return docs;
|
|
62
|
+
}
|
|
63
|
+
export function optionDesc() {
|
|
64
|
+
const docs = [];
|
|
65
|
+
for (const x of optionDocs()) {
|
|
66
|
+
docs.push(`- ${x.key}:\n${x.description}`);
|
|
67
|
+
}
|
|
68
|
+
return docs;
|
|
69
|
+
}
|
|
70
|
+
export class ApolloConf extends Conf {
|
|
71
|
+
constructor(configFile) {
|
|
72
|
+
let APOLLO_DISABLE_CONFIG_CREATE = false;
|
|
73
|
+
if (process.env.APOLLO_DISABLE_CONFIG_CREATE !== undefined &&
|
|
74
|
+
process.env.APOLLO_DISABLE_CONFIG_CREATE !== '0') {
|
|
75
|
+
APOLLO_DISABLE_CONFIG_CREATE = true;
|
|
76
|
+
}
|
|
77
|
+
if (APOLLO_DISABLE_CONFIG_CREATE && !fs.existsSync(configFile)) {
|
|
78
|
+
throw new ConfigError('Configuration file does not exist yet, please create it as an empty file first.');
|
|
79
|
+
}
|
|
80
|
+
super({
|
|
81
|
+
projectName: 'apollo-cli',
|
|
82
|
+
fileExtension: path.parse(configFile).ext.replace(/^\./, ''),
|
|
83
|
+
configName: path.parse(configFile).name,
|
|
84
|
+
cwd: path.dirname(configFile),
|
|
85
|
+
serialize: YAML.stringify,
|
|
86
|
+
deserialize: YAML.parse,
|
|
87
|
+
});
|
|
88
|
+
const v = configSchema.validate(this.store);
|
|
89
|
+
if (v.error?.message !== undefined) {
|
|
90
|
+
throw new Error(`Invalid setting: ${v.error.message}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
get store() {
|
|
94
|
+
const superStore = super.store;
|
|
95
|
+
const v = configSchema.validate(superStore);
|
|
96
|
+
if (v.error?.message !== undefined) {
|
|
97
|
+
throw new ConfigError(`Invalid key: ${v.error.message}`);
|
|
98
|
+
}
|
|
99
|
+
return superStore;
|
|
100
|
+
}
|
|
101
|
+
set store(newStore) {
|
|
102
|
+
const v = configSchema.validate(newStore);
|
|
103
|
+
if (v.error?.message !== undefined) {
|
|
104
|
+
throw new ConfigError(`Invalid setting: ${v.error.message}`);
|
|
105
|
+
}
|
|
106
|
+
super.store = newStore;
|
|
107
|
+
}
|
|
108
|
+
getProfileNames() {
|
|
109
|
+
return Object.keys(this.store);
|
|
110
|
+
}
|
|
111
|
+
setAccessType(profileName, accessType) {
|
|
112
|
+
if (accessType != 'root') {
|
|
113
|
+
this.delete(`${profileName}.rootCredentials`);
|
|
114
|
+
}
|
|
115
|
+
this.set(`${profileName}.accessType`, accessType);
|
|
116
|
+
}
|
|
117
|
+
async getAccess(profileName) {
|
|
118
|
+
checkProfileExists(profileName, this);
|
|
119
|
+
const address = this.get(`${profileName}.address`);
|
|
120
|
+
if (address.trim() === '') {
|
|
121
|
+
throw new ConfigError(`Profile "${profileName}" has no address. Please run "apollo config" to set it up.`);
|
|
122
|
+
}
|
|
123
|
+
const accessToken = this.get(`${profileName}.accessToken`);
|
|
124
|
+
if (accessToken.trim() === '') {
|
|
125
|
+
throw new ConfigError(`Profile "${profileName}" has no access token. Please run "apollo login" to set it up.`);
|
|
126
|
+
}
|
|
127
|
+
await queryApollo(address, accessToken, 'assemblies');
|
|
128
|
+
return { address, accessToken };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
const profileSchema = Joi.object({
|
|
132
|
+
address: Joi.string().uri({ scheme: /https?/ }),
|
|
133
|
+
accessType: Joi.string().valid('google', 'microsoft', 'root', 'guest'),
|
|
134
|
+
accessToken: Joi.string(),
|
|
135
|
+
rootCredentials: Joi.object({
|
|
136
|
+
username: Joi.string(),
|
|
137
|
+
password: Joi.string(),
|
|
138
|
+
}).when('accessType', {
|
|
139
|
+
is: Joi.string().valid('root'),
|
|
140
|
+
otherwise: Joi.forbidden(),
|
|
141
|
+
}),
|
|
142
|
+
});
|
|
143
|
+
const configSchema = Joi.object().pattern(Joi.string(), profileSchema);
|
package/dist/baseCommand.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { Command, Flags } from '@oclif/core';
|
|
3
|
-
import {
|
|
3
|
+
import { ApolloConf } from './ApolloConf.js';
|
|
4
4
|
import { checkConfigfileExists } from './utils.js';
|
|
5
5
|
export class BaseCommand extends Command {
|
|
6
6
|
static baseFlags = {
|
|
@@ -29,7 +29,7 @@ export class BaseCommand extends Command {
|
|
|
29
29
|
configFile = path.join(this.config.configDir, 'config.yaml');
|
|
30
30
|
}
|
|
31
31
|
checkConfigfileExists(configFile);
|
|
32
|
-
const config = new
|
|
32
|
+
const config = new ApolloConf(configFile);
|
|
33
33
|
return config;
|
|
34
34
|
}
|
|
35
35
|
async getAccess(configFile, profileName) {
|
|
@@ -37,18 +37,7 @@ export class BaseCommand extends Command {
|
|
|
37
37
|
if (profileName === undefined) {
|
|
38
38
|
profileName = process.env.APOLLO_PROFILE ?? 'default';
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
return await config.getAccess(profileName);
|
|
42
|
-
}
|
|
43
|
-
catch (error) {
|
|
44
|
-
if (error instanceof ConfigError) {
|
|
45
|
-
this.logToStderr(error.message);
|
|
46
|
-
this.exit(1);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
throw error;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
40
|
+
return config.getAccess(profileName);
|
|
52
41
|
}
|
|
53
42
|
async catch(err) {
|
|
54
43
|
// add any custom logic to handle errors from the command
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
3
2
|
import * as fs from 'node:fs';
|
|
4
3
|
import * as path from 'node:path';
|
|
5
4
|
import { Flags } from '@oclif/core';
|
|
6
5
|
import { ObjectId } from 'bson';
|
|
7
6
|
import { BaseCommand } from '../../baseCommand.js';
|
|
8
|
-
import { submitAssembly, uploadFile, wrapLines } from '../../utils.js';
|
|
7
|
+
import { createFetchErrorMessage, submitAssembly, uploadFile, wrapLines, } from '../../utils.js';
|
|
9
8
|
export default class Get extends BaseCommand {
|
|
10
9
|
static description = 'Add new assembly from local or external fasta file';
|
|
11
10
|
static examples = [
|
|
@@ -42,11 +41,10 @@ export default class Get extends BaseCommand {
|
|
|
42
41
|
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
43
42
|
const assemblyName = flags.assembly ?? path.basename(flags['input-file']);
|
|
44
43
|
const isExternal = isValidHttpUrl(flags['input-file']);
|
|
45
|
-
let
|
|
44
|
+
let res;
|
|
46
45
|
if (isExternal) {
|
|
47
46
|
if (flags.index === undefined) {
|
|
48
|
-
this.
|
|
49
|
-
this.exit(1);
|
|
47
|
+
this.error('Please provide the URL to the index of the external fasta file');
|
|
50
48
|
}
|
|
51
49
|
const body = {
|
|
52
50
|
assemblyName,
|
|
@@ -56,32 +54,24 @@ export default class Get extends BaseCommand {
|
|
|
56
54
|
fai: flags.index,
|
|
57
55
|
},
|
|
58
56
|
};
|
|
59
|
-
|
|
57
|
+
res = (await submitAssembly(access.address, access.accessToken, body, flags.force));
|
|
60
58
|
}
|
|
61
59
|
else {
|
|
62
60
|
if (!isExternal && !fs.existsSync(flags['input-file'])) {
|
|
63
|
-
this.
|
|
64
|
-
this.exit(1);
|
|
65
|
-
}
|
|
66
|
-
try {
|
|
67
|
-
const fileId = await uploadFile(access.address, access.accessToken, flags['input-file'], 'text/x-fasta');
|
|
68
|
-
const body = {
|
|
69
|
-
assemblyName,
|
|
70
|
-
fileId,
|
|
71
|
-
typeName: 'AddAssemblyFromFileChange',
|
|
72
|
-
assembly: new ObjectId().toHexString(),
|
|
73
|
-
};
|
|
74
|
-
response = (await submitAssembly(access.address, access.accessToken, body, flags.force));
|
|
75
|
-
}
|
|
76
|
-
catch (error) {
|
|
77
|
-
this.logToStderr(error.message);
|
|
78
|
-
this.exit(1);
|
|
61
|
+
this.error(`File ${flags['input-file']} does not exist`);
|
|
79
62
|
}
|
|
63
|
+
const fileId = await uploadFile(access.address, access.accessToken, flags['input-file'], 'text/x-fasta');
|
|
64
|
+
const body = {
|
|
65
|
+
assemblyName,
|
|
66
|
+
fileId,
|
|
67
|
+
typeName: 'AddAssemblyFromFileChange',
|
|
68
|
+
assembly: new ObjectId().toHexString(),
|
|
69
|
+
};
|
|
70
|
+
res = (await submitAssembly(access.address, access.accessToken, body, flags.force));
|
|
80
71
|
}
|
|
81
|
-
if (!
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
this.exit(1);
|
|
72
|
+
if (!res.ok) {
|
|
73
|
+
const errorMessage = await createFetchErrorMessage(res, 'Submit assembly failed');
|
|
74
|
+
throw new Error(errorMessage);
|
|
85
75
|
}
|
|
86
76
|
this.exit(0);
|
|
87
77
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3
1
|
import * as fs from 'node:fs';
|
|
4
2
|
import * as path from 'node:path';
|
|
5
3
|
import { Flags } from '@oclif/core';
|
|
6
4
|
import { ObjectId } from 'bson';
|
|
7
5
|
import { BaseCommand } from '../../baseCommand.js';
|
|
8
|
-
import { submitAssembly, uploadFile, wrapLines } from '../../utils.js';
|
|
6
|
+
import { createFetchErrorMessage, submitAssembly, uploadFile, wrapLines, } from '../../utils.js';
|
|
9
7
|
export default class AddGff extends BaseCommand {
|
|
10
8
|
static summary = 'Add new assembly from gff or gft file';
|
|
11
9
|
static description = wrapLines('The gff file is expected to contain sequences as per gff specifications. Features are also imported by default.');
|
|
@@ -41,8 +39,7 @@ export default class AddGff extends BaseCommand {
|
|
|
41
39
|
async run() {
|
|
42
40
|
const { flags } = await this.parse(AddGff);
|
|
43
41
|
if (!fs.existsSync(flags['input-file'])) {
|
|
44
|
-
this.
|
|
45
|
-
this.exit(1);
|
|
42
|
+
this.error(`File ${flags['input-file']} does not exist`);
|
|
46
43
|
}
|
|
47
44
|
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
48
45
|
const fileId = await uploadFile(access.address, access.accessToken, flags['input-file'], 'text/x-gff3');
|
|
@@ -51,25 +48,16 @@ export default class AddGff extends BaseCommand {
|
|
|
51
48
|
typeName = 'AddAssemblyFromFileChange';
|
|
52
49
|
}
|
|
53
50
|
const assemblyName = flags.assembly ?? path.basename(flags['input-file']);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
res = await submitAssembly(access.address, access.accessToken, body, flags.force);
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
this.logToStderr(error.message);
|
|
66
|
-
this.exit(1);
|
|
67
|
-
}
|
|
51
|
+
const body = {
|
|
52
|
+
assemblyName,
|
|
53
|
+
fileId,
|
|
54
|
+
typeName,
|
|
55
|
+
assembly: new ObjectId().toHexString(),
|
|
56
|
+
};
|
|
57
|
+
const res = await submitAssembly(access.address, access.accessToken, body, flags.force);
|
|
68
58
|
if (!res.ok) {
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
this.logToStderr(message);
|
|
72
|
-
this.exit(1);
|
|
59
|
+
const errorMessage = await createFetchErrorMessage(res, 'getFeatureById failed');
|
|
60
|
+
throw new Error(errorMessage);
|
|
73
61
|
}
|
|
74
62
|
this.exit(0);
|
|
75
63
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import { fetch } from 'undici';
|
|
3
3
|
import { BaseCommand } from '../../baseCommand.js';
|
|
4
|
-
import {
|
|
4
|
+
import { convertCheckNameToId, createFetchErrorMessage, getAssembly, idReader, localhostToAddress, wrapLines, } from '../../utils.js';
|
|
5
5
|
async function setChecks(address, accessToken, assembly, checkId) {
|
|
6
6
|
const check = {
|
|
7
7
|
_id: assembly,
|
|
@@ -55,7 +55,7 @@ function getCheckTypesForAssembly(checkTypes, assembly) {
|
|
|
55
55
|
export default class Check extends BaseCommand {
|
|
56
56
|
static summary = 'Add, view, or delete checks to assembly';
|
|
57
57
|
static description = wrapLines('Manage checks, i.e. the rules ensuring features in an assembly are plausible. \
|
|
58
|
-
This command only sets the
|
|
58
|
+
This command only sets the checks to apply, to retrieve features flagged by these checks use `apollo feature check`.');
|
|
59
59
|
static examples = [
|
|
60
60
|
{
|
|
61
61
|
description: 'View available check types:',
|
|
@@ -95,33 +95,23 @@ export default class Check extends BaseCommand {
|
|
|
95
95
|
const checkTypes = await getCheckTypes(access.address, access.accessToken);
|
|
96
96
|
if (flags.check === undefined && flags.assembly === undefined) {
|
|
97
97
|
this.log(JSON.stringify(checkTypes, null, 2));
|
|
98
|
-
|
|
98
|
+
return;
|
|
99
99
|
}
|
|
100
100
|
if (flags.assembly === undefined) {
|
|
101
|
-
this.
|
|
102
|
-
this.exit(1);
|
|
101
|
+
this.error('Please specify the assembly to manage for checks');
|
|
103
102
|
}
|
|
104
103
|
const asm = idReader([flags.assembly]);
|
|
105
104
|
const assembly = await getAssembly(access.address, access.accessToken, asm[0]);
|
|
106
105
|
if (Object.keys(assembly).length === 0) {
|
|
107
|
-
this.
|
|
108
|
-
this.exit(1);
|
|
106
|
+
this.error(`Assembly ${flags.assembly} not found`);
|
|
109
107
|
}
|
|
110
108
|
const currentChecks = getCheckTypesForAssembly(checkTypes, assembly);
|
|
111
109
|
if (flags.check === undefined) {
|
|
112
110
|
this.log(JSON.stringify(currentChecks, null, 2));
|
|
113
|
-
|
|
111
|
+
return;
|
|
114
112
|
}
|
|
115
113
|
let inputCheckIds = [];
|
|
116
|
-
|
|
117
|
-
inputCheckIds = await convertCheckNameToId(access.address, access.accessToken, flags.check);
|
|
118
|
-
}
|
|
119
|
-
catch (error) {
|
|
120
|
-
if (error instanceof CheckError) {
|
|
121
|
-
this.logToStderr(error.message);
|
|
122
|
-
this.exit(1);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
114
|
+
inputCheckIds = await convertCheckNameToId(access.address, access.accessToken, flags.check);
|
|
125
115
|
const newChecks = new Set();
|
|
126
116
|
if (flags.delete) {
|
|
127
117
|
const currentCheckIds = new Set();
|
|
@@ -143,6 +133,5 @@ export default class Check extends BaseCommand {
|
|
|
143
133
|
}
|
|
144
134
|
}
|
|
145
135
|
await setChecks(access.address, access.accessToken, assembly['_id'], [...newChecks.values()]);
|
|
146
|
-
this.exit(0);
|
|
147
136
|
}
|
|
148
137
|
}
|