@apollo-annotation/cli 0.3.0 → 0.3.2
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 +73 -39
- package/dist/commands/assembly/add-from-fasta.js +23 -8
- package/dist/commands/export/gff3.d.ts +15 -0
- package/dist/commands/export/gff3.js +74 -0
- package/dist/test/test.d.ts +11 -0
- package/dist/test/test.js +978 -0
- package/dist/test/test_docker.d.ts +1 -0
- package/dist/test/test_docker.js +51 -0
- package/dist/test/utils.d.ts +9 -0
- package/dist/test/utils.js +28 -0
- package/oclif.manifest.json +282 -224
- package/package.json +9 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import assert from 'node:assert';
|
|
2
|
+
import { after, before, describe } from 'node:test';
|
|
3
|
+
import { Shell } from './utils.js';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
const hostTmpDir = path.resolve('tmpTestDocker');
|
|
7
|
+
const hostDataDir = path.resolve('test_data');
|
|
8
|
+
const apollo = `docker run --network host -v ${hostTmpDir}:/root/.config/apollo-cli -v ${hostDataDir}:/data apollo`;
|
|
9
|
+
const configFile = '/root/.config/apollo-cli/config.yml';
|
|
10
|
+
void describe('Test Docker', () => {
|
|
11
|
+
before(() => {
|
|
12
|
+
if (fs.existsSync(hostTmpDir) && fs.lstatSync(hostTmpDir).isDirectory()) {
|
|
13
|
+
fs.rmSync(hostTmpDir, { recursive: true });
|
|
14
|
+
}
|
|
15
|
+
fs.mkdirSync(hostTmpDir);
|
|
16
|
+
fs.writeFileSync(path.join(hostTmpDir, 'config.yml'), '');
|
|
17
|
+
new Shell('docker build --no-cache -t apollo .');
|
|
18
|
+
// See apollo-collaboration-server/.development.env for credentials etc.
|
|
19
|
+
new Shell(`${apollo} config --config-file ${configFile} address http://localhost:3999`);
|
|
20
|
+
new Shell(`${apollo} config --config-file ${configFile} accessType root`);
|
|
21
|
+
new Shell(`${apollo} config --config-file ${configFile} rootPassword pass`);
|
|
22
|
+
new Shell(`${apollo} login --config-file ${configFile}`, true, 60_000);
|
|
23
|
+
});
|
|
24
|
+
after(() => {
|
|
25
|
+
fs.rmSync(hostTmpDir, { recursive: true });
|
|
26
|
+
});
|
|
27
|
+
void globalThis.itName('Print help', () => {
|
|
28
|
+
const p = new Shell(`${apollo} --help`);
|
|
29
|
+
assert.ok(p.stdout.includes('COMMANDS'));
|
|
30
|
+
});
|
|
31
|
+
void globalThis.itName('Add assembly', () => {
|
|
32
|
+
const configFile = '/root/.config/apollo-cli/config.yml';
|
|
33
|
+
new Shell(`${apollo} assembly add-from-gff --config-file ${configFile} data/tiny.fasta.gff3 -a vv1 -f`);
|
|
34
|
+
let p = new Shell(`${apollo} assembly get --config-file ${configFile} -a vv1`);
|
|
35
|
+
assert.ok(p.stdout.includes('vv1'));
|
|
36
|
+
new Shell(`${apollo} assembly delete --config-file ${configFile} -a vv1`);
|
|
37
|
+
p = new Shell(`${apollo} assembly get --config-file ${configFile} -a vv1`);
|
|
38
|
+
assert.deepStrictEqual(p.stdout.trim(), '[]');
|
|
39
|
+
});
|
|
40
|
+
void globalThis.itName('Missing config', () => {
|
|
41
|
+
let p = new Shell(`${apollo} config address --config-file {hostTmpDir}/new.yml http://localhost:3999`, false);
|
|
42
|
+
assert.ok(p.returncode != 0);
|
|
43
|
+
assert.ok(p.stderr.includes('does not exist yet'));
|
|
44
|
+
p = new Shell(`${apollo} config address --config-file /root/.config/apollo-cli/new.yml http://localhost:3999`, false);
|
|
45
|
+
assert.ok(p.returncode != 0);
|
|
46
|
+
assert.ok(p.stderr.includes('does not exist yet'));
|
|
47
|
+
fs.writeFileSync(path.join(hostTmpDir, 'new.yml'), '');
|
|
48
|
+
p = new Shell(`${apollo} config address --config-file /root/.config/apollo-cli/new.yml http://localhost:3999`);
|
|
49
|
+
assert.strictEqual(p.returncode, 0);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { it } from 'node:test';
|
|
2
|
+
import spawn from 'cross-spawn';
|
|
3
|
+
// Workaround to print test name before each test
|
|
4
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
5
|
+
globalThis.itName = (name, fn) => {
|
|
6
|
+
const wrappedFn = () => {
|
|
7
|
+
process.stdout.write(`Running test: ${name}\n`);
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
9
|
+
return fn();
|
|
10
|
+
};
|
|
11
|
+
return it(name, wrappedFn);
|
|
12
|
+
};
|
|
13
|
+
export class Shell {
|
|
14
|
+
returncode;
|
|
15
|
+
stdout;
|
|
16
|
+
stderr;
|
|
17
|
+
constructor(cmd, strict = true, timeout) {
|
|
18
|
+
process.stdout.write(`${cmd}\n`);
|
|
19
|
+
cmd = `set -e; set -u; set -o pipefail\n${cmd}`;
|
|
20
|
+
const p = spawn.sync(cmd, { shell: '/bin/bash', timeout });
|
|
21
|
+
this.returncode = p.status;
|
|
22
|
+
this.stdout = p.stdout.toString();
|
|
23
|
+
this.stderr = p.stderr.toString();
|
|
24
|
+
if (strict && this.returncode != 0) {
|
|
25
|
+
throw new Error(`${p.error}\nCOMMAND:\n${cmd}\nSTDOUT:\n${this.stdout}\nSTDERR:\n${this.stderr}\nEXIT CODE: ${this.returncode}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|