@apollo-annotation/cli 0.1.10
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 +899 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +9 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +8 -0
- package/dist/Config.d.ts +43 -0
- package/dist/Config.js +233 -0
- package/dist/baseCommand.d.ts +21 -0
- package/dist/baseCommand.js +62 -0
- package/dist/commands/assembly/add-fasta.d.ts +15 -0
- package/dist/commands/assembly/add-fasta.js +98 -0
- package/dist/commands/assembly/add-gff.d.ts +16 -0
- package/dist/commands/assembly/add-gff.js +76 -0
- package/dist/commands/assembly/check.d.ts +15 -0
- package/dist/commands/assembly/check.js +148 -0
- package/dist/commands/assembly/delete.d.ts +14 -0
- package/dist/commands/assembly/delete.js +43 -0
- package/dist/commands/assembly/get.d.ts +9 -0
- package/dist/commands/assembly/get.js +33 -0
- package/dist/commands/assembly/get.test.d.ts +1 -0
- package/dist/commands/assembly/get.test.js +50 -0
- package/dist/commands/assembly/sequence.d.ts +16 -0
- package/dist/commands/assembly/sequence.js +117 -0
- package/dist/commands/change/get.d.ts +9 -0
- package/dist/commands/change/get.js +35 -0
- package/dist/commands/change/get.test.d.ts +1 -0
- package/dist/commands/change/get.test.js +22 -0
- package/dist/commands/config.d.ts +25 -0
- package/dist/commands/config.js +217 -0
- package/dist/commands/config.test.d.ts +1 -0
- package/dist/commands/config.test.js +188 -0
- package/dist/commands/feature/add-child.d.ts +17 -0
- package/dist/commands/feature/add-child.js +120 -0
- package/dist/commands/feature/check.d.ts +14 -0
- package/dist/commands/feature/check.js +97 -0
- package/dist/commands/feature/copy.d.ts +17 -0
- package/dist/commands/feature/copy.js +110 -0
- package/dist/commands/feature/delete.d.ts +11 -0
- package/dist/commands/feature/delete.js +99 -0
- package/dist/commands/feature/edit-attribute.d.ts +16 -0
- package/dist/commands/feature/edit-attribute.js +100 -0
- package/dist/commands/feature/edit-coords.d.ts +15 -0
- package/dist/commands/feature/edit-coords.js +109 -0
- package/dist/commands/feature/edit-type.d.ts +10 -0
- package/dist/commands/feature/edit-type.js +70 -0
- package/dist/commands/feature/edit.d.ts +13 -0
- package/dist/commands/feature/edit.js +81 -0
- package/dist/commands/feature/get-id.d.ts +14 -0
- package/dist/commands/feature/get-id.js +56 -0
- package/dist/commands/feature/get.d.ts +16 -0
- package/dist/commands/feature/get.js +87 -0
- package/dist/commands/feature/import.d.ts +15 -0
- package/dist/commands/feature/import.js +83 -0
- package/dist/commands/feature/search.d.ts +14 -0
- package/dist/commands/feature/search.js +91 -0
- package/dist/commands/login.d.ts +21 -0
- package/dist/commands/login.js +206 -0
- package/dist/commands/login.test.d.ts +1 -0
- package/dist/commands/login.test.js +52 -0
- package/dist/commands/logout.d.ts +10 -0
- package/dist/commands/logout.js +41 -0
- package/dist/commands/logout.test.d.ts +1 -0
- package/dist/commands/logout.test.js +67 -0
- package/dist/commands/refseq/get.d.ts +13 -0
- package/dist/commands/refseq/get.js +44 -0
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.js +38 -0
- package/dist/commands/status.test.d.ts +1 -0
- package/dist/commands/status.test.js +54 -0
- package/dist/commands/user/get.d.ts +14 -0
- package/dist/commands/user/get.js +46 -0
- package/dist/commands/user/get.test.d.ts +1 -0
- package/dist/commands/user/get.test.js +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/test/fixtures.d.ts +7 -0
- package/dist/test/fixtures.js +40 -0
- package/dist/utils.d.ts +54 -0
- package/dist/utils.js +373 -0
- package/oclif.manifest.json +1632 -0
- package/package.json +100 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { BaseCommand } from '../baseCommand.js';
|
|
3
|
+
import { Config, ConfigError, KEYS } from '../Config.js';
|
|
4
|
+
import { basicCheckConfig, wrapLines } from '../utils.js';
|
|
5
|
+
export default class Logout extends BaseCommand {
|
|
6
|
+
static summary = 'Logout of Apollo';
|
|
7
|
+
static description = wrapLines('Logout by removing the access token from the selected profile');
|
|
8
|
+
static examples = [
|
|
9
|
+
{
|
|
10
|
+
description: 'Logout default profile:',
|
|
11
|
+
command: '<%= config.bin %> <%= command.id %>',
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
description: 'Logout selected profile',
|
|
15
|
+
command: '<%= config.bin %> <%= command.id %> --profile my-profile',
|
|
16
|
+
},
|
|
17
|
+
];
|
|
18
|
+
async run() {
|
|
19
|
+
const { flags } = await this.parse(Logout);
|
|
20
|
+
let profileName = flags.profile;
|
|
21
|
+
if (profileName === undefined) {
|
|
22
|
+
profileName = process.env.APOLLO_PROFILE ?? 'default';
|
|
23
|
+
}
|
|
24
|
+
let configFile = flags['config-file'];
|
|
25
|
+
if (configFile === undefined) {
|
|
26
|
+
configFile = path.join(this.config.configDir, 'config.yaml');
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
basicCheckConfig(configFile, profileName);
|
|
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();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { dirname } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { expect, test } from '@oclif/test';
|
|
7
|
+
import YAML from 'yaml';
|
|
8
|
+
import { CONFIG_FILE, TEST_DATA_DIR, VERBOSE, copyFile, } from '../test/fixtures.js';
|
|
9
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
10
|
+
describe('apollo logout: Set token to empty string', () => {
|
|
11
|
+
before(() => {
|
|
12
|
+
copyFile(`${TEST_DATA_DIR}/complete_config.yaml`, CONFIG_FILE, VERBOSE);
|
|
13
|
+
});
|
|
14
|
+
after(() => {
|
|
15
|
+
fs.rmSync(CONFIG_FILE);
|
|
16
|
+
});
|
|
17
|
+
let cmd = ['logout', '--profile', 'default'];
|
|
18
|
+
test
|
|
19
|
+
.stdout()
|
|
20
|
+
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
21
|
+
.it(cmd.join(' '), () => {
|
|
22
|
+
const cfg = YAML.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
23
|
+
expect(cfg.default.accessToken).to.equal('');
|
|
24
|
+
});
|
|
25
|
+
cmd = ['logout', '--profile', 'profile1'];
|
|
26
|
+
test
|
|
27
|
+
.stdout()
|
|
28
|
+
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
29
|
+
.it(cmd.join(' '), () => {
|
|
30
|
+
const cfg = YAML.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
31
|
+
expect(cfg.profile1.accessToken).to.equal('');
|
|
32
|
+
});
|
|
33
|
+
cmd = ['logout', '--profile', 'noAccessToken'];
|
|
34
|
+
test
|
|
35
|
+
.stdout()
|
|
36
|
+
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
37
|
+
.it(cmd.join(' '), () => {
|
|
38
|
+
const cfg = YAML.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
39
|
+
expect(cfg.profile1.accessToken).to.equal('');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe('apollo logout: Config file does not exist', () => {
|
|
43
|
+
const cmd = ['logout', '--config-file', '_tmp.yaml'];
|
|
44
|
+
test
|
|
45
|
+
.stderr()
|
|
46
|
+
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
47
|
+
.exit(1)
|
|
48
|
+
.do((output) => expect(output.stderr).to.contain('apollo config'))
|
|
49
|
+
.it(cmd.join(' '));
|
|
50
|
+
});
|
|
51
|
+
describe('apollo logout: Profile does not exist', () => {
|
|
52
|
+
const cmd = [
|
|
53
|
+
'logout',
|
|
54
|
+
'--config-file',
|
|
55
|
+
'test_data/complete_config.yaml',
|
|
56
|
+
'--profile',
|
|
57
|
+
'notavailable',
|
|
58
|
+
];
|
|
59
|
+
test
|
|
60
|
+
.stderr()
|
|
61
|
+
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
62
|
+
.exit(1)
|
|
63
|
+
.do((output) => expect(output.stderr).to.contain('apollo config'))
|
|
64
|
+
.do((output) => expect(output.stderr).to.contain('Profile'))
|
|
65
|
+
.do((output) => expect(output.stderr).to.contain('notavailable'))
|
|
66
|
+
.it(cmd.join(' '));
|
|
67
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BaseCommand } from '../../baseCommand.js';
|
|
2
|
+
export default class Get extends BaseCommand<typeof Get> {
|
|
3
|
+
static summary: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: {
|
|
6
|
+
description: string;
|
|
7
|
+
command: string;
|
|
8
|
+
}[];
|
|
9
|
+
static flags: {
|
|
10
|
+
assembly: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string[] | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
};
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../baseCommand.js';
|
|
3
|
+
import { convertAssemblyNameToId, idReader, queryApollo, wrapLines, } from '../../utils.js';
|
|
4
|
+
export default class Get extends BaseCommand {
|
|
5
|
+
static summary = 'Get reference sequences';
|
|
6
|
+
static description = wrapLines('Output the reference sequences in one or more assemblies in json format. \
|
|
7
|
+
This command returns the sequence characteristics (e.g., name, ID, etc), not the DNA sequences. \
|
|
8
|
+
Use `assembly sequence` for that.');
|
|
9
|
+
static examples = [
|
|
10
|
+
{
|
|
11
|
+
description: wrapLines('All sequences in the database:'),
|
|
12
|
+
command: '<%= config.bin %> <%= command.id %>',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
description: wrapLines('Only sequences for these assemblies:'),
|
|
16
|
+
command: '<%= config.bin %> <%= command.id %> -a mm9 mm10',
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
static flags = {
|
|
20
|
+
assembly: Flags.string({
|
|
21
|
+
char: 'a',
|
|
22
|
+
multiple: true,
|
|
23
|
+
description: 'Get reference sequences for these assembly names or IDs; use - to read it from stdin',
|
|
24
|
+
}),
|
|
25
|
+
};
|
|
26
|
+
async run() {
|
|
27
|
+
const { flags } = await this.parse(Get);
|
|
28
|
+
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
29
|
+
const refSeqs = await queryApollo(access.address, access.accessToken, 'refSeqs');
|
|
30
|
+
const json = (await refSeqs.json());
|
|
31
|
+
let keep = json;
|
|
32
|
+
if (flags.assembly !== undefined) {
|
|
33
|
+
keep = [];
|
|
34
|
+
const assembly = idReader(flags.assembly);
|
|
35
|
+
const assemblyIds = await convertAssemblyNameToId(access.address, access.accessToken, assembly);
|
|
36
|
+
for (const x of json) {
|
|
37
|
+
if (assemblyIds.includes(x['assembly'])) {
|
|
38
|
+
keep.push(x);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
this.log(JSON.stringify(keep, null, 2));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { BaseCommand } from '../baseCommand.js';
|
|
4
|
+
import { Config, ConfigError, KEYS } from '../Config.js';
|
|
5
|
+
import { basicCheckConfig, wrapLines } from '../utils.js';
|
|
6
|
+
export default class Status extends BaseCommand {
|
|
7
|
+
static summary = 'View authentication status';
|
|
8
|
+
static description = wrapLines('This command returns "<profile>: Logged in" if the selected profile has an access token and "<profile>: Logged out" otherwise.\
|
|
9
|
+
Note that this command does not check the validity of the access token.');
|
|
10
|
+
async run() {
|
|
11
|
+
const { flags } = await this.parse(Status);
|
|
12
|
+
let profileName = flags.profile;
|
|
13
|
+
if (profileName === undefined) {
|
|
14
|
+
profileName = process.env.APOLLO_PROFILE ?? 'default';
|
|
15
|
+
}
|
|
16
|
+
let configFile = flags['config-file'];
|
|
17
|
+
if (configFile === undefined) {
|
|
18
|
+
configFile = path.join(this.config.configDir, 'config.yaml');
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
basicCheckConfig(configFile, profileName);
|
|
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);
|
|
31
|
+
if (accessToken === undefined || accessToken.trim() === '') {
|
|
32
|
+
this.log(`${profileName}: Logged out`);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.log(`${profileName}: Logged in`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { expect, test } from '@oclif/test';
|
|
5
|
+
import { CONFIG_FILE, TEST_DATA_DIR, VERBOSE, copyFile, } from '../test/fixtures.js';
|
|
6
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
7
|
+
describe('apollo status: Check logged in', () => {
|
|
8
|
+
before(() => {
|
|
9
|
+
copyFile(`${TEST_DATA_DIR}/complete_config.yaml`, CONFIG_FILE, VERBOSE);
|
|
10
|
+
});
|
|
11
|
+
after(() => {
|
|
12
|
+
fs.rmSync(CONFIG_FILE);
|
|
13
|
+
});
|
|
14
|
+
let cmd = ['status', '--profile', 'default'];
|
|
15
|
+
test
|
|
16
|
+
.stdout()
|
|
17
|
+
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
18
|
+
.it(cmd.join(' '), (ctx) => {
|
|
19
|
+
expect(ctx.stdout).contain('Logged in');
|
|
20
|
+
});
|
|
21
|
+
cmd = ['status', '--profile', 'noAccessToken'];
|
|
22
|
+
test
|
|
23
|
+
.stdout()
|
|
24
|
+
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
25
|
+
.it(cmd.join(' '), (ctx) => {
|
|
26
|
+
expect(ctx.stdout).contain('Logged out');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
describe('apollo status: Config file does not exist', () => {
|
|
30
|
+
const cmd = ['status', '--config-file', '_tmp.yaml'];
|
|
31
|
+
test
|
|
32
|
+
.stderr()
|
|
33
|
+
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
34
|
+
.exit(1)
|
|
35
|
+
.do((output) => expect(output.stderr).to.contain('apollo config'))
|
|
36
|
+
.it(cmd.join(' '));
|
|
37
|
+
});
|
|
38
|
+
describe('apollo status: Profile does not exist', () => {
|
|
39
|
+
const cmd = [
|
|
40
|
+
'status',
|
|
41
|
+
'--config-file',
|
|
42
|
+
'test_data/complete_config.yaml',
|
|
43
|
+
'--profile',
|
|
44
|
+
'notavailable',
|
|
45
|
+
];
|
|
46
|
+
test
|
|
47
|
+
.stderr()
|
|
48
|
+
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
49
|
+
.exit(1)
|
|
50
|
+
.do((output) => expect(output.stderr).to.contain('apollo config'))
|
|
51
|
+
.do((output) => expect(output.stderr).to.contain('Profile'))
|
|
52
|
+
.do((output) => expect(output.stderr).to.contain('notavailable'))
|
|
53
|
+
.it(cmd.join(' '));
|
|
54
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BaseCommand } from '../../baseCommand.js';
|
|
2
|
+
export default class Get extends BaseCommand<typeof Get> {
|
|
3
|
+
static summary: string;
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: {
|
|
6
|
+
description: string;
|
|
7
|
+
command: string;
|
|
8
|
+
}[];
|
|
9
|
+
static flags: {
|
|
10
|
+
username: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
+
role: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { BaseCommand } from '../../baseCommand.js';
|
|
3
|
+
import { queryApollo, wrapLines } from '../../utils.js';
|
|
4
|
+
export default class Get extends BaseCommand {
|
|
5
|
+
static summary = 'Get list of users';
|
|
6
|
+
static description = wrapLines('If set, filters username and role must be both satisfied to return an entry');
|
|
7
|
+
static examples = [
|
|
8
|
+
{
|
|
9
|
+
description: 'By username:',
|
|
10
|
+
command: '<%= config.bin %> <%= command.id %> -u Guest',
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
description: 'By role:',
|
|
14
|
+
command: '<%= config.bin %> <%= command.id %> -r admin',
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
description: 'Use jq for more control:',
|
|
18
|
+
command: '<%= config.bin %> <%= command.id %> | jq \'.[] | select(.createdAt > "2024-03-18")\'',
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
static flags = {
|
|
22
|
+
username: Flags.string({
|
|
23
|
+
char: 'u',
|
|
24
|
+
description: 'Find this username',
|
|
25
|
+
}),
|
|
26
|
+
role: Flags.string({
|
|
27
|
+
char: 'r',
|
|
28
|
+
description: 'Get users with this role',
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
async run() {
|
|
32
|
+
const { flags } = await this.parse(Get);
|
|
33
|
+
const access = await this.getAccess(flags['config-file'], flags.profile);
|
|
34
|
+
const users = await queryApollo(access.address, access.accessToken, 'users');
|
|
35
|
+
const json = (await users.json());
|
|
36
|
+
const out = [];
|
|
37
|
+
for (const x of json) {
|
|
38
|
+
if ((flags.username === undefined ||
|
|
39
|
+
x['username'] === flags.username) &&
|
|
40
|
+
(flags.role === undefined || x['role'] === flags.role)) {
|
|
41
|
+
out.push(x);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
this.log(JSON.stringify(out, null, 2));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { expect, test } from '@oclif/test';
|
|
5
|
+
import { CONFIG_FILE, TEST_DATA_DIR, VERBOSE, copyFile, } from '../../test/fixtures.js';
|
|
6
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url));
|
|
7
|
+
// TODO: Need valid token
|
|
8
|
+
describe.skip('apollo user get: Get users as YAML string', () => {
|
|
9
|
+
before(() => {
|
|
10
|
+
copyFile(`${TEST_DATA_DIR}/complete_config.yaml`, CONFIG_FILE, VERBOSE);
|
|
11
|
+
});
|
|
12
|
+
after(() => {
|
|
13
|
+
fs.rmSync(CONFIG_FILE);
|
|
14
|
+
});
|
|
15
|
+
const cmd = ['user:get'];
|
|
16
|
+
test
|
|
17
|
+
.stdout()
|
|
18
|
+
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
19
|
+
.it(cmd.join(' '), (output) => {
|
|
20
|
+
const str = JSON.stringify(JSON.parse(output.stdout));
|
|
21
|
+
expect(str).contain('username');
|
|
22
|
+
});
|
|
23
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from '@oclif/core';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { run } from '@oclif/core';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const TEST_DATA_DIR: string;
|
|
2
|
+
export declare const VERBOSE = false;
|
|
3
|
+
export declare const CONFIG_DIR: string;
|
|
4
|
+
export declare const CONFIG_FILE: string;
|
|
5
|
+
export declare function copyFile(src: string, dest: string, verbose: boolean): void;
|
|
6
|
+
export declare function mochaGlobalSetup(): void;
|
|
7
|
+
export declare function mochaGlobalTeardown(): void;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
export const TEST_DATA_DIR = path.resolve('test_data');
|
|
5
|
+
export const VERBOSE = false;
|
|
6
|
+
export const CONFIG_DIR = path.join(os.homedir(), '.config', 'apollo-cli');
|
|
7
|
+
export const CONFIG_FILE = path.join(CONFIG_DIR, 'config.yaml');
|
|
8
|
+
const CONFIG_BAK = path.join(TEST_DATA_DIR, 'original.config.yaml.bak');
|
|
9
|
+
function renameFile(src, dest, verbose = true) {
|
|
10
|
+
if (fs.existsSync(dest)) {
|
|
11
|
+
throw new Error(`File ${dest} already exists`);
|
|
12
|
+
}
|
|
13
|
+
let msg = '';
|
|
14
|
+
if (fs.existsSync(src)) {
|
|
15
|
+
fs.renameSync(src, dest);
|
|
16
|
+
msg = `mv ${src} ${dest}`;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
msg = `${src} does not exist`;
|
|
20
|
+
}
|
|
21
|
+
if (verbose) {
|
|
22
|
+
process.stdout.write(`${msg}\n`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function copyFile(src, dest, verbose) {
|
|
26
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
27
|
+
fs.copyFileSync(src, dest);
|
|
28
|
+
if (verbose) {
|
|
29
|
+
const msg = `cp ${src} ${dest}`;
|
|
30
|
+
process.stdout.write(`${msg} # Copied: ${fs.existsSync(dest)}\n`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export function mochaGlobalSetup() {
|
|
34
|
+
process.stdout.write(`Temporarily remove config file ${CONFIG_FILE} if any`);
|
|
35
|
+
renameFile(CONFIG_FILE, CONFIG_BAK, VERBOSE);
|
|
36
|
+
}
|
|
37
|
+
export function mochaGlobalTeardown() {
|
|
38
|
+
process.stdout.write(`Putting back config file ${CONFIG_FILE} if any\n`);
|
|
39
|
+
renameFile(CONFIG_BAK, CONFIG_FILE, VERBOSE);
|
|
40
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import EventEmitter from 'node:events';
|
|
2
|
+
import { Response } from 'undici';
|
|
3
|
+
import { Config } from './Config.js';
|
|
4
|
+
export declare const CLI_SERVER_ADDRESS = "http://127.0.0.1:5657";
|
|
5
|
+
export declare const CLI_SERVER_ADDRESS_CALLBACK = "http://127.0.0.1:5657/auth/callback";
|
|
6
|
+
export declare class CheckError extends Error {
|
|
7
|
+
}
|
|
8
|
+
export interface UserCredentials {
|
|
9
|
+
accessToken: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function createFetchErrorMessage(response: Response, additionalText?: string): Promise<string>;
|
|
12
|
+
export declare function checkConfigfileExists(configFile: string): void;
|
|
13
|
+
export declare function checkProfileExists(profileName: string, config: Config): void;
|
|
14
|
+
export declare function basicCheckConfig(configFile: string, profileName: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use this function while we wait to resolve the TypeError when using localhost in fetch.
|
|
17
|
+
*/
|
|
18
|
+
export declare function localhostToAddress(url: string): string;
|
|
19
|
+
export declare function deleteAssembly(address: string, accessToken: string, assemblyId: string): Promise<void>;
|
|
20
|
+
export declare function getAssembly(address: string, accessToken: string, assemblyNameOrId: string): Promise<object>;
|
|
21
|
+
export declare function getRefseqId(address: string, accessToken: string, refseqNameOrId?: string, inAssemblyNameOrId?: string): Promise<string[]>;
|
|
22
|
+
export declare function convertCheckNameToId(address: string, accessToken: string, namesOrIds: string[]): Promise<string[]>;
|
|
23
|
+
export declare function assemblyNameToIdDict(address: string, accessToken: string): Promise<Record<string, string>>;
|
|
24
|
+
/** In input array namesOrIds, substitute common names with internal IDs */
|
|
25
|
+
export declare function convertAssemblyNameToId(address: string, accessToken: string, namesOrIds: string[], verbose?: boolean, removeDuplicates?: boolean): Promise<string[]>;
|
|
26
|
+
export declare function getFeatureById(address: string, accessToken: string, id: string): Promise<Response>;
|
|
27
|
+
export declare function getAssemblyFromRefseq(address: string, accessToken: string, refSeq: string): Promise<string>;
|
|
28
|
+
export declare function queryApollo(address: string, accessToken: string, endpoint: string): Promise<Response>;
|
|
29
|
+
export declare function filterJsonList(json: object[], keep: string[], key: string): object[];
|
|
30
|
+
export declare const getUserCredentials: () => UserCredentials | null;
|
|
31
|
+
export declare const generatePkceChallenge: () => {
|
|
32
|
+
state: string;
|
|
33
|
+
codeVerifier: string;
|
|
34
|
+
codeChallenge: string;
|
|
35
|
+
};
|
|
36
|
+
export declare const waitFor: <T>(eventName: string, emitter: EventEmitter) => Promise<T>;
|
|
37
|
+
interface bodyLocalFile {
|
|
38
|
+
assemblyName: string;
|
|
39
|
+
typeName: string;
|
|
40
|
+
fileId: string;
|
|
41
|
+
}
|
|
42
|
+
interface bodyExternalFile {
|
|
43
|
+
assemblyName: string;
|
|
44
|
+
typeName: string;
|
|
45
|
+
externalLocation: {
|
|
46
|
+
fa: string;
|
|
47
|
+
fai: string;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export declare function submitAssembly(address: string, accessToken: string, body: bodyLocalFile | bodyExternalFile, force: boolean): Promise<Response>;
|
|
51
|
+
export declare function uploadFile(address: string, accessToken: string, file: string, type: string): Promise<string>;
|
|
52
|
+
export declare function wrapLines(s: string, length?: number): string;
|
|
53
|
+
export declare function idReader(input: string[], removeDuplicates?: boolean): string[];
|
|
54
|
+
export {};
|