@apollo-annotation/cli 0.1.17 → 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
|
@@ -66,8 +66,7 @@ export default class ApolloCmd extends BaseCommand {
|
|
|
66
66
|
const { flags } = await this.parse(ApolloCmd);
|
|
67
67
|
const endCoord = flags.end ?? Number.MAX_SAFE_INTEGER;
|
|
68
68
|
if (flags.start <= 0 || endCoord <= 0) {
|
|
69
|
-
this.
|
|
70
|
-
this.exit(1);
|
|
69
|
+
this.error('Start and end coordinates must be greater than 0.');
|
|
71
70
|
}
|
|
72
71
|
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
73
72
|
let assembly = undefined;
|
|
@@ -76,16 +75,9 @@ export default class ApolloCmd extends BaseCommand {
|
|
|
76
75
|
[assembly] = idReader([flags.assembly]);
|
|
77
76
|
}
|
|
78
77
|
let refseqIds = [];
|
|
79
|
-
|
|
80
|
-
refseqIds = await getRefseqId(access.address, access.accessToken, flags.refseq, assembly);
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
this.logToStderr(error.message);
|
|
84
|
-
this.exit(1);
|
|
85
|
-
}
|
|
78
|
+
refseqIds = await getRefseqId(access.address, access.accessToken, flags.refseq, assembly);
|
|
86
79
|
if (refseqIds.length === 0) {
|
|
87
|
-
this.
|
|
88
|
-
this.exit(1);
|
|
80
|
+
this.error('No reference sequence found');
|
|
89
81
|
}
|
|
90
82
|
const refs = await queryApollo(access.address, access.accessToken, 'refSeqs');
|
|
91
83
|
const refSeqs = (await refs.json());
|
package/dist/commands/config.js
CHANGED
|
@@ -5,8 +5,8 @@ import password from '@inquirer/password';
|
|
|
5
5
|
import select from '@inquirer/select';
|
|
6
6
|
import { Args, Flags } from '@oclif/core';
|
|
7
7
|
import { fetch } from 'undici';
|
|
8
|
+
import { ApolloConf, KEYS, optionDesc } from '../ApolloConf.js';
|
|
8
9
|
import { BaseCommand } from '../baseCommand.js';
|
|
9
|
-
import { Config, ConfigError, KEYS, optionDesc } from '../Config.js';
|
|
10
10
|
import { createFetchErrorMessage, localhostToAddress, wrapLines, } from '../utils.js';
|
|
11
11
|
export default class ApolloConfig extends BaseCommand {
|
|
12
12
|
static summary = 'Get or set apollo configuration options';
|
|
@@ -57,9 +57,9 @@ export default class ApolloConfig extends BaseCommand {
|
|
|
57
57
|
: path.resolve(configFile);
|
|
58
58
|
if (flags['get-config-file']) {
|
|
59
59
|
this.log(configFile);
|
|
60
|
-
|
|
60
|
+
return;
|
|
61
61
|
}
|
|
62
|
-
const config = new
|
|
62
|
+
const config = new ApolloConf(configFile);
|
|
63
63
|
if (args.key === undefined) {
|
|
64
64
|
await this.interactiveSetup(config, flags.profile);
|
|
65
65
|
}
|
|
@@ -71,33 +71,16 @@ export default class ApolloConfig extends BaseCommand {
|
|
|
71
71
|
if (flags.profile !== undefined) {
|
|
72
72
|
profileName = flags.profile;
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
config.set(args.key, args.value, profileName);
|
|
81
|
-
}
|
|
74
|
+
if (args.value === undefined) {
|
|
75
|
+
const currentValue = config.get(`${profileName}.${args.key}`);
|
|
76
|
+
this.log(currentValue);
|
|
77
|
+
return;
|
|
82
78
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.logToStderr(error.message);
|
|
86
|
-
}
|
|
87
|
-
this.exit(1);
|
|
79
|
+
if (args.key === 'accessType') {
|
|
80
|
+
config.setAccessType(profileName, args.value);
|
|
88
81
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (v) {
|
|
92
|
-
this.logToStderr(v);
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
config.writeConfigFile();
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
if (error instanceof ConfigError) {
|
|
99
|
-
this.logToStderr(error.message);
|
|
100
|
-
this.exit(1);
|
|
82
|
+
else {
|
|
83
|
+
config.set(`${profileName}.${args.key}`, args.value);
|
|
101
84
|
}
|
|
102
85
|
}
|
|
103
86
|
}
|
|
@@ -107,34 +90,19 @@ export default class ApolloConfig extends BaseCommand {
|
|
|
107
90
|
}
|
|
108
91
|
let setMe = true;
|
|
109
92
|
while (setMe) {
|
|
110
|
-
const address = await this.askAddress(config.get(KEYS[KEYS.address]
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
setMe = false;
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
if (error instanceof ConfigError) {
|
|
117
|
-
this.logToStderr(error.message);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
93
|
+
const address = await this.askAddress(config.get(`${profileName}.${KEYS[KEYS.address]}`));
|
|
94
|
+
config.set(`${profileName}.${KEYS[KEYS.address]}`, address);
|
|
95
|
+
setMe = false;
|
|
120
96
|
}
|
|
121
|
-
const address = config.get(KEYS[KEYS.address]
|
|
97
|
+
const address = config.get(`${profileName}.${KEYS[KEYS.address]}`);
|
|
122
98
|
let accessType = '';
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
if (error instanceof ConfigError) {
|
|
128
|
-
this.logToStderr(error.message);
|
|
129
|
-
this.exit(1);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
config.set(KEYS[KEYS.accessType], accessType, profileName);
|
|
99
|
+
accessType = await this.selectAccessType(address);
|
|
100
|
+
config.setAccessType(profileName, accessType);
|
|
133
101
|
if (accessType === 'root') {
|
|
134
|
-
const username = await this.askUsername(config.get(KEYS.rootCredentials_username
|
|
135
|
-
config.set(
|
|
102
|
+
const username = await this.askUsername(config.get(`${profileName}.${KEYS.rootCredentials_username}`));
|
|
103
|
+
config.set(`${profileName}.rootCredentials.username`, username);
|
|
136
104
|
const password = await this.askPassword();
|
|
137
|
-
config.set(
|
|
105
|
+
config.set(`${profileName}.rootCredentials.password`, password);
|
|
138
106
|
}
|
|
139
107
|
}
|
|
140
108
|
async askProfileName(currentProfiles) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
2
2
|
/* eslint-disable @typescript-eslint/restrict-plus-operands */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
4
3
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
5
4
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
6
5
|
import { Flags } from '@oclif/core';
|
|
@@ -42,31 +41,27 @@ export default class Get extends BaseCommand {
|
|
|
42
41
|
async run() {
|
|
43
42
|
const { flags } = await this.parse(Get);
|
|
44
43
|
if (flags.end < flags.start) {
|
|
45
|
-
this.
|
|
46
|
-
this.exit(1);
|
|
44
|
+
this.error('Error: End coordinate is lower than the start coordinate');
|
|
47
45
|
}
|
|
48
46
|
if (flags.start <= 0) {
|
|
49
|
-
this.
|
|
50
|
-
this.exit(1);
|
|
47
|
+
this.error('Coordinates must be greater than 0');
|
|
51
48
|
}
|
|
52
49
|
const ff = idReader([flags['feature-id']]);
|
|
53
50
|
if (ff.length !== 1) {
|
|
54
|
-
this.
|
|
51
|
+
this.error(`Expected only one feature identifier. Got ${ff.length}`);
|
|
55
52
|
}
|
|
56
53
|
const [featureId] = ff;
|
|
57
54
|
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
58
|
-
const
|
|
59
|
-
if (!
|
|
60
|
-
const errorMessage = await createFetchErrorMessage(
|
|
55
|
+
const res = await getFeatureById(access.address, access.accessToken, featureId);
|
|
56
|
+
if (!res.ok) {
|
|
57
|
+
const errorMessage = await createFetchErrorMessage(res, 'getFeatureById failed');
|
|
61
58
|
throw new Error(errorMessage);
|
|
62
59
|
}
|
|
63
|
-
const feature = JSON.parse(await
|
|
60
|
+
const feature = JSON.parse(await res.text());
|
|
64
61
|
const childRes = await this.addChild(access.address, access.accessToken, feature, flags.start - 1, flags.end, flags.type);
|
|
65
62
|
if (!childRes.ok) {
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
this.logToStderr(message);
|
|
69
|
-
this.exit(1);
|
|
63
|
+
const errorMessage = await createFetchErrorMessage(childRes, 'Add child failed');
|
|
64
|
+
throw new Error(errorMessage);
|
|
70
65
|
}
|
|
71
66
|
this.exit(0);
|
|
72
67
|
}
|
|
@@ -74,8 +69,7 @@ export default class Get extends BaseCommand {
|
|
|
74
69
|
const pStart = parentFeature['start'];
|
|
75
70
|
const pEnd = parentFeature['end'];
|
|
76
71
|
if (start < pStart || end > pEnd) {
|
|
77
|
-
this.
|
|
78
|
-
this.exit(1);
|
|
72
|
+
this.error(`Error: Child feature coordinates (${start + 1}-${end}) cannot extend beyond parent coordinates (${pStart + 1}-${pEnd})`);
|
|
79
73
|
}
|
|
80
74
|
const res = await queryApollo(address, accessToken, 'refSeqs');
|
|
81
75
|
const refSeqs = (await res.json());
|
|
@@ -38,36 +38,27 @@ export default class Copy extends BaseCommand {
|
|
|
38
38
|
async run() {
|
|
39
39
|
const { flags } = await this.parse(Copy);
|
|
40
40
|
if (flags.start <= 0) {
|
|
41
|
-
this.
|
|
42
|
-
this.exit(1);
|
|
41
|
+
this.error('Start coordinate must be greater than 0');
|
|
43
42
|
}
|
|
44
43
|
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
45
|
-
const
|
|
46
|
-
if (!
|
|
47
|
-
const errorMessage = await createFetchErrorMessage(
|
|
44
|
+
const res = await getFeatureById(access.address, access.accessToken, flags['feature-id']);
|
|
45
|
+
if (!res.ok) {
|
|
46
|
+
const errorMessage = await createFetchErrorMessage(res, 'getFeatureById failed');
|
|
48
47
|
throw new Error(errorMessage);
|
|
49
48
|
}
|
|
50
|
-
const feature = (await
|
|
49
|
+
const feature = (await res.json());
|
|
51
50
|
let refseqIds = [];
|
|
52
|
-
|
|
53
|
-
refseqIds = await getRefseqId(access.address, access.accessToken, flags.refseq, flags.assembly);
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
this.logToStderr(error.message);
|
|
57
|
-
this.exit(1);
|
|
58
|
-
}
|
|
51
|
+
refseqIds = await getRefseqId(access.address, access.accessToken, flags.refseq, flags.assembly);
|
|
59
52
|
if (refseqIds.length === 0) {
|
|
60
|
-
this.
|
|
61
|
-
this.exit(1);
|
|
53
|
+
this.error('No reference sequence found');
|
|
62
54
|
}
|
|
63
55
|
const [refseq] = refseqIds;
|
|
64
56
|
const assembly = await getAssemblyFromRefseq(access.address, access.accessToken, refseq);
|
|
65
57
|
const newId = new ObjectId().toHexString();
|
|
66
58
|
const rescopy = await this.copyFeature(access.address, access.accessToken, feature, refseq, flags.start, assembly, newId);
|
|
67
59
|
if (!rescopy.ok) {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
this.exit(1);
|
|
60
|
+
const errorMessage = await createFetchErrorMessage(rescopy, 'Copy feature failed');
|
|
61
|
+
throw new Error(errorMessage);
|
|
71
62
|
}
|
|
72
63
|
this.exit(0);
|
|
73
64
|
}
|
|
@@ -100,11 +91,11 @@ export default class Copy extends BaseCommand {
|
|
|
100
91
|
'Content-Type': 'application/json',
|
|
101
92
|
},
|
|
102
93
|
};
|
|
103
|
-
const
|
|
104
|
-
if (!
|
|
105
|
-
const errorMessage = await createFetchErrorMessage(
|
|
94
|
+
const res = await fetch(url, auth);
|
|
95
|
+
if (!res.ok) {
|
|
96
|
+
const errorMessage = await createFetchErrorMessage(res, 'copyFeature failed');
|
|
106
97
|
throw new Error(errorMessage);
|
|
107
98
|
}
|
|
108
|
-
return
|
|
99
|
+
return res;
|
|
109
100
|
}
|
|
110
101
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
4
2
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
5
3
|
import { Flags } from '@oclif/core';
|
|
6
4
|
import { fetch } from 'undici';
|
|
@@ -67,30 +65,23 @@ export default class Delete extends BaseCommand {
|
|
|
67
65
|
}
|
|
68
66
|
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
69
67
|
for (const featureId of featureIds) {
|
|
70
|
-
const
|
|
71
|
-
if (
|
|
68
|
+
const res = await getFeatureById(access.address, access.accessToken, featureId);
|
|
69
|
+
if (res.status === 404 && flags.force) {
|
|
72
70
|
continue;
|
|
73
71
|
}
|
|
74
|
-
if (!
|
|
75
|
-
const errorMessage = await createFetchErrorMessage(
|
|
72
|
+
if (!res.ok) {
|
|
73
|
+
const errorMessage = await createFetchErrorMessage(res, 'getFeatureById failed');
|
|
76
74
|
throw new Error(errorMessage);
|
|
77
75
|
}
|
|
78
|
-
const feature = JSON.parse(await
|
|
79
|
-
if (!response.ok) {
|
|
80
|
-
const message = feature['message'];
|
|
81
|
-
this.logToStderr(message);
|
|
82
|
-
this.exit(1);
|
|
83
|
-
}
|
|
76
|
+
const feature = JSON.parse(await res.text());
|
|
84
77
|
if (flags['dry-run']) {
|
|
85
78
|
this.log(feature);
|
|
86
79
|
}
|
|
87
80
|
else {
|
|
88
81
|
const delFet = await deleteFeature(access.address, access.accessToken, feature);
|
|
89
82
|
if (!delFet.ok) {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
this.logToStderr(message);
|
|
93
|
-
this.exit(1);
|
|
83
|
+
const errorMessage = await createFetchErrorMessage(delFet, 'Delete feature failed');
|
|
84
|
+
throw new Error(errorMessage);
|
|
94
85
|
}
|
|
95
86
|
}
|
|
96
87
|
}
|
|
@@ -47,12 +47,11 @@ export default class EditAttibute extends BaseCommand {
|
|
|
47
47
|
async run() {
|
|
48
48
|
const { flags } = await this.parse(EditAttibute);
|
|
49
49
|
if (flags.delete && flags.value) {
|
|
50
|
-
this.
|
|
51
|
-
this.exit(1);
|
|
50
|
+
this.error('Error: Options --delete and --value are mutually exclusive');
|
|
52
51
|
}
|
|
53
52
|
const ff = idReader([flags['feature-id']]);
|
|
54
53
|
if (ff.length !== 1) {
|
|
55
|
-
this.
|
|
54
|
+
this.error(`Expected only one feature identifier. Got ${ff.length}`);
|
|
56
55
|
}
|
|
57
56
|
const [featureId] = ff;
|
|
58
57
|
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
@@ -64,7 +63,7 @@ export default class EditAttibute extends BaseCommand {
|
|
|
64
63
|
const featureJson = JSON.parse(await response.text());
|
|
65
64
|
if (flags.value === undefined && !flags.delete) {
|
|
66
65
|
this.log(JSON.stringify(featureJson.attributes[flags.attribute]));
|
|
67
|
-
|
|
66
|
+
return;
|
|
68
67
|
}
|
|
69
68
|
if (flags.delete) {
|
|
70
69
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
@@ -37,34 +37,31 @@ export default class Get extends BaseCommand {
|
|
|
37
37
|
async run() {
|
|
38
38
|
const { flags } = await this.parse(Get);
|
|
39
39
|
if (flags.start === undefined && flags.end === undefined) {
|
|
40
|
-
this.
|
|
41
|
-
this.exit(1);
|
|
40
|
+
this.error('Please provide new start and/or end coordinates to edit');
|
|
42
41
|
}
|
|
43
42
|
if (flags.start !== undefined && flags.start <= 0) {
|
|
44
|
-
this.
|
|
45
|
-
this.exit(1);
|
|
43
|
+
this.error('Coordinates must be greater than 0');
|
|
46
44
|
}
|
|
47
45
|
if (flags.start !== undefined &&
|
|
48
46
|
flags.end !== undefined &&
|
|
49
47
|
flags.end < flags.start) {
|
|
50
|
-
this.
|
|
51
|
-
this.exit(1);
|
|
48
|
+
this.error('Error: The new end coordinate is lower than the new start coordinate');
|
|
52
49
|
}
|
|
53
50
|
if (flags.start !== undefined) {
|
|
54
51
|
flags.start -= 1;
|
|
55
52
|
}
|
|
56
53
|
const ff = idReader([flags['feature-id']]);
|
|
57
54
|
if (ff.length !== 1) {
|
|
58
|
-
this.
|
|
55
|
+
this.error(`Expected only one feature identifier. Got ${ff.length}`);
|
|
59
56
|
}
|
|
60
57
|
const [featureId] = ff;
|
|
61
58
|
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
62
|
-
const
|
|
63
|
-
if (!
|
|
64
|
-
const errorMessage = await createFetchErrorMessage(
|
|
59
|
+
const res = await getFeatureById(access.address, access.accessToken, featureId);
|
|
60
|
+
if (!res.ok) {
|
|
61
|
+
const errorMessage = await createFetchErrorMessage(res, 'getFeatureById failed');
|
|
65
62
|
throw new Error(errorMessage);
|
|
66
63
|
}
|
|
67
|
-
const featureJson = JSON.parse(await
|
|
64
|
+
const featureJson = JSON.parse(await res.text());
|
|
68
65
|
const assembly = await getAssemblyFromRefseq(access.address, access.accessToken, featureJson['refSeq']);
|
|
69
66
|
const currentEnd = featureJson['end'];
|
|
70
67
|
let edit = ['Start', 'End'];
|
|
@@ -24,7 +24,7 @@ export default class Get extends BaseCommand {
|
|
|
24
24
|
const { flags } = await this.parse(Get);
|
|
25
25
|
const ff = idReader([flags['feature-id']]);
|
|
26
26
|
if (ff.length !== 1) {
|
|
27
|
-
this.
|
|
27
|
+
this.error(`Expected only one feature identifier. Got ${ff.length}`);
|
|
28
28
|
}
|
|
29
29
|
const [featureId] = ff;
|
|
30
30
|
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
@@ -37,11 +37,11 @@ export default class Get extends BaseCommand {
|
|
|
37
37
|
const currentType = featureJson['type'];
|
|
38
38
|
if (flags.type === undefined) {
|
|
39
39
|
this.log(currentType);
|
|
40
|
-
|
|
40
|
+
return;
|
|
41
41
|
}
|
|
42
42
|
if (flags.type === currentType) {
|
|
43
43
|
this.logToStderr(`NOTE: Feature ${featureId} is already of type "${flags.type}"`);
|
|
44
|
-
|
|
44
|
+
return;
|
|
45
45
|
}
|
|
46
46
|
const assembly = await getAssemblyFromRefseq(access.address, access.accessToken, featureJson['refSeq']);
|
|
47
47
|
const changeJson = {
|
|
@@ -66,5 +66,6 @@ export default class Get extends BaseCommand {
|
|
|
66
66
|
const errorMessage = await createFetchErrorMessage(res, 'edit-type failed');
|
|
67
67
|
throw new Error(errorMessage);
|
|
68
68
|
}
|
|
69
|
+
this.exit(0);
|
|
69
70
|
}
|
|
70
71
|
}
|
|
@@ -42,21 +42,9 @@ export default class Get extends BaseCommand {
|
|
|
42
42
|
else if (fs.existsSync(flags['json-input'])) {
|
|
43
43
|
jsonStr = fs.readFileSync(flags['json-input']).toString();
|
|
44
44
|
}
|
|
45
|
-
let json;
|
|
46
|
-
|
|
47
|
-
json =
|
|
48
|
-
if (!Array.isArray(json)) {
|
|
49
|
-
json = [json];
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
if (error instanceof Error) {
|
|
54
|
-
this.logToStderr(`Error parsing json input:\n${error.message}`);
|
|
55
|
-
this.exit(1);
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
throw error;
|
|
59
|
-
}
|
|
45
|
+
let json = JSON.parse(jsonStr);
|
|
46
|
+
if (!Array.isArray(json)) {
|
|
47
|
+
json = [json];
|
|
60
48
|
}
|
|
61
49
|
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
62
50
|
for (const change of json) {
|
|
@@ -37,21 +37,10 @@ export default class Get extends BaseCommand {
|
|
|
37
37
|
const { flags } = await this.parse(Get);
|
|
38
38
|
const endCoord = flags.end ?? Number.MAX_SAFE_INTEGER;
|
|
39
39
|
if (flags.start <= 0 || endCoord <= 0) {
|
|
40
|
-
this.
|
|
41
|
-
this.exit(1);
|
|
40
|
+
this.error('Start and end coordinates must be greater than 0.');
|
|
42
41
|
}
|
|
43
42
|
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
refseqIds = await getRefseqId(access.address, access.accessToken, flags.refseq, flags.assembly);
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
this.logToStderr(error.message);
|
|
50
|
-
this.exit(1);
|
|
51
|
-
}
|
|
52
|
-
if (refseqIds.length === 0) {
|
|
53
|
-
this.logToStderr('No reference sequence found');
|
|
54
|
-
}
|
|
43
|
+
const refseqIds = await getRefseqId(access.address, access.accessToken, flags.refseq, flags.assembly);
|
|
55
44
|
const results = [];
|
|
56
45
|
for (const refseq of refseqIds) {
|
|
57
46
|
const features = await this.getFeatures(access.address, access.accessToken, refseq, flags.start, endCoord);
|
|
@@ -77,11 +66,11 @@ export default class Get extends BaseCommand {
|
|
|
77
66
|
'Content-Type': 'application/json',
|
|
78
67
|
},
|
|
79
68
|
};
|
|
80
|
-
const
|
|
81
|
-
if (!
|
|
82
|
-
const errorMessage = await createFetchErrorMessage(
|
|
69
|
+
const res = await fetch(url, auth);
|
|
70
|
+
if (!res.ok) {
|
|
71
|
+
const errorMessage = await createFetchErrorMessage(res, 'Failed to access Apollo with the current address and/or access token\nThe server returned:\n');
|
|
83
72
|
throw new Error(errorMessage);
|
|
84
73
|
}
|
|
85
|
-
return
|
|
74
|
+
return res;
|
|
86
75
|
}
|
|
87
76
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
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 { Flags } from '@oclif/core';
|
|
5
3
|
import { fetch } from 'undici';
|
|
@@ -33,22 +31,18 @@ export default class Import extends BaseCommand {
|
|
|
33
31
|
async run() {
|
|
34
32
|
const { flags } = await this.parse(Import);
|
|
35
33
|
if (!fs.existsSync(flags['input-file'])) {
|
|
36
|
-
this.
|
|
37
|
-
this.exit(1);
|
|
34
|
+
this.error(`File "${flags['input-file']}" does not exist`);
|
|
38
35
|
}
|
|
39
36
|
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
40
37
|
const assembly = await convertAssemblyNameToId(access.address, access.accessToken, [flags.assembly]);
|
|
41
38
|
if (assembly.length === 0) {
|
|
42
|
-
this.
|
|
43
|
-
this.exit(1);
|
|
39
|
+
this.error(`Assembly "${flags.assembly}" does not exist. Perhaps you want to create this assembly first`);
|
|
44
40
|
}
|
|
45
41
|
const uploadId = await uploadFile(access.address, access.accessToken, flags['input-file'], 'text/x-gff3');
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
this.logToStderr(message);
|
|
51
|
-
this.exit(1);
|
|
42
|
+
const res = await importFeatures(access.address, access.accessToken, assembly[0], uploadId, flags['delete-existing']);
|
|
43
|
+
if (!res.ok) {
|
|
44
|
+
const errorMessage = await createFetchErrorMessage(res, 'Import features failed');
|
|
45
|
+
throw new Error(errorMessage);
|
|
52
46
|
}
|
|
53
47
|
this.exit(0);
|
|
54
48
|
}
|
package/dist/commands/login.js
CHANGED
|
@@ -8,8 +8,8 @@ import * as querystring from 'node:querystring';
|
|
|
8
8
|
import { Errors, Flags, ux } from '@oclif/core';
|
|
9
9
|
import open from 'open';
|
|
10
10
|
import { fetch } from 'undici';
|
|
11
|
+
import { ApolloConf } from '../ApolloConf.js';
|
|
11
12
|
import { BaseCommand } from '../baseCommand.js';
|
|
12
|
-
import { Config, ConfigError } from '../Config.js';
|
|
13
13
|
import { basicCheckConfig, createFetchErrorMessage, getUserCredentials, localhostToAddress, waitFor, wrapLines, } from '../utils.js';
|
|
14
14
|
export default class Login extends BaseCommand {
|
|
15
15
|
static summary = 'Login to Apollo';
|
|
@@ -61,21 +61,12 @@ export default class Login extends BaseCommand {
|
|
|
61
61
|
if (profileName === undefined) {
|
|
62
62
|
profileName = process.env.APOLLO_PROFILE ?? 'default';
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (error instanceof ConfigError) {
|
|
69
|
-
this.logToStderr(error.message);
|
|
70
|
-
this.exit(1);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
const config = new Config(configFile);
|
|
74
|
-
const accessType = config.get('accessType', profileName);
|
|
75
|
-
const address = flags.address ?? config.get('address', profileName);
|
|
64
|
+
basicCheckConfig(configFile, profileName);
|
|
65
|
+
const config = new ApolloConf(configFile);
|
|
66
|
+
const accessType = config.get(`${profileName}.accessType`);
|
|
67
|
+
const address = flags.address ?? config.get(`${profileName}.address`);
|
|
76
68
|
if (address === undefined) {
|
|
77
|
-
this.
|
|
78
|
-
this.exit(1);
|
|
69
|
+
this.error('Address to apollo must be set');
|
|
79
70
|
}
|
|
80
71
|
let userCredentials = { accessToken: '' };
|
|
81
72
|
try {
|
|
@@ -83,11 +74,12 @@ export default class Login extends BaseCommand {
|
|
|
83
74
|
await this.checkUserAlreadyLoggedIn();
|
|
84
75
|
}
|
|
85
76
|
if (accessType === 'root' || flags.username !== undefined) {
|
|
86
|
-
const username = flags.username ??
|
|
87
|
-
|
|
77
|
+
const username = flags.username ??
|
|
78
|
+
config.get(`${profileName}.rootCredentials.username`);
|
|
79
|
+
const password = flags.password ??
|
|
80
|
+
config.get(`${profileName}.rootCredentials.password`);
|
|
88
81
|
if (username === undefined || password === undefined) {
|
|
89
|
-
this.
|
|
90
|
-
this.exit(1);
|
|
82
|
+
this.error('Username and password must be set');
|
|
91
83
|
}
|
|
92
84
|
userCredentials = await this.startRootLogin(address, username, password);
|
|
93
85
|
}
|
|
@@ -95,8 +87,7 @@ export default class Login extends BaseCommand {
|
|
|
95
87
|
userCredentials = await this.startGuestLogin(address);
|
|
96
88
|
}
|
|
97
89
|
else if (accessType === undefined) {
|
|
98
|
-
this.
|
|
99
|
-
this.exit(1);
|
|
90
|
+
this.error('Undefined access type');
|
|
100
91
|
}
|
|
101
92
|
else {
|
|
102
93
|
userCredentials = await this.startAuthorizationCodeFlow(address, accessType, flags.port);
|
|
@@ -105,16 +96,13 @@ export default class Login extends BaseCommand {
|
|
|
105
96
|
catch (error) {
|
|
106
97
|
if ((error instanceof Errors.CLIError && error.message === 'ctrl-c') ||
|
|
107
98
|
error instanceof Errors.ExitError) {
|
|
108
|
-
|
|
99
|
+
return;
|
|
109
100
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
ux.action.stop(error.message);
|
|
113
|
-
this.exit(1);
|
|
101
|
+
if (error instanceof Error) {
|
|
102
|
+
throw error;
|
|
114
103
|
}
|
|
115
104
|
}
|
|
116
|
-
config.set(
|
|
117
|
-
config.writeConfigFile();
|
|
105
|
+
config.set(`${profileName}.accessToken`, userCredentials.accessToken);
|
|
118
106
|
}
|
|
119
107
|
async checkUserAlreadyLoggedIn() {
|
|
120
108
|
const userCredentials = getUserCredentials();
|
package/dist/commands/logout.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import { ApolloConf, KEYS } from '../ApolloConf.js';
|
|
2
3
|
import { BaseCommand } from '../baseCommand.js';
|
|
3
|
-
import { Config, ConfigError, KEYS } from '../Config.js';
|
|
4
4
|
import { basicCheckConfig, wrapLines } from '../utils.js';
|
|
5
5
|
export default class Logout extends BaseCommand {
|
|
6
6
|
static summary = 'Logout of Apollo';
|
|
@@ -25,17 +25,8 @@ export default class Logout extends BaseCommand {
|
|
|
25
25
|
if (configFile === undefined) {
|
|
26
26
|
configFile = path.join(this.config.configDir, 'config.yaml');
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
if (error instanceof ConfigError) {
|
|
33
|
-
this.logToStderr(error.message);
|
|
34
|
-
this.exit(1);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
const config = new Config(configFile);
|
|
38
|
-
config.set(KEYS.accessToken, '', profileName);
|
|
39
|
-
config.writeConfigFile();
|
|
28
|
+
basicCheckConfig(configFile, profileName);
|
|
29
|
+
const config = new ApolloConf(configFile);
|
|
30
|
+
config.delete(`${profileName}.${KEYS.accessToken}`);
|
|
40
31
|
}
|
|
41
32
|
}
|
package/dist/commands/status.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import { ApolloConf, KEYS } from '../ApolloConf.js';
|
|
3
4
|
import { BaseCommand } from '../baseCommand.js';
|
|
4
|
-
import { Config, ConfigError, KEYS } from '../Config.js';
|
|
5
5
|
import { basicCheckConfig, wrapLines } from '../utils.js';
|
|
6
6
|
export default class Status extends BaseCommand {
|
|
7
7
|
static summary = 'View authentication status';
|
|
@@ -17,17 +17,9 @@ export default class Status extends BaseCommand {
|
|
|
17
17
|
if (configFile === undefined) {
|
|
18
18
|
configFile = path.join(this.config.configDir, 'config.yaml');
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
if (error instanceof ConfigError) {
|
|
25
|
-
this.logToStderr(error.message);
|
|
26
|
-
this.exit(1);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
const config = new Config(configFile);
|
|
30
|
-
const accessToken = config.get(KEYS.accessToken, profileName);
|
|
20
|
+
basicCheckConfig(configFile, profileName);
|
|
21
|
+
const config = new ApolloConf(configFile);
|
|
22
|
+
const accessToken = config.get(`${profileName}.${KEYS.accessToken}`);
|
|
31
23
|
if (accessToken === undefined || accessToken.trim() === '') {
|
|
32
24
|
this.log(`${profileName}: Logged out`);
|
|
33
25
|
}
|