@apollo-annotation/cli 0.1.17 → 0.1.19
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 +120 -58
- package/bin/dev.js +2 -2
- package/bin/run.js +2 -2
- package/dist/ApolloConf.d.ts +22 -0
- package/dist/ApolloConf.js +144 -0
- package/dist/baseCommand.js +7 -17
- package/dist/commands/assembly/add-fasta.js +16 -27
- package/dist/commands/assembly/add-gff.js +11 -24
- package/dist/commands/assembly/check.js +7 -18
- package/dist/commands/assembly/delete.js +1 -1
- package/dist/commands/assembly/get.test.js +3 -3
- package/dist/commands/assembly/sequence.js +7 -21
- package/dist/commands/change/get.test.js +1 -1
- package/dist/commands/config.js +21 -53
- package/dist/commands/feature/add-child.js +21 -29
- package/dist/commands/feature/check.js +5 -5
- package/dist/commands/feature/copy.js +20 -32
- package/dist/commands/feature/delete.js +16 -31
- package/dist/commands/feature/edit-attribute.js +15 -10
- package/dist/commands/feature/edit-coords.js +39 -27
- package/dist/commands/feature/edit-type.js +5 -8
- package/dist/commands/feature/edit.js +3 -16
- package/dist/commands/feature/get-id.js +0 -1
- package/dist/commands/feature/get.js +6 -18
- package/dist/commands/feature/import.js +22 -41
- package/dist/commands/feature/search.js +1 -1
- package/dist/commands/login.js +17 -29
- package/dist/commands/logout.js +5 -14
- package/dist/commands/refseq/add-alias.d.ts +14 -0
- package/dist/commands/refseq/add-alias.js +72 -0
- package/dist/commands/status.js +5 -13
- package/dist/commands/user/get.test.js +1 -1
- package/dist/test/fixtures.js +2 -2
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +50 -25
- package/oclif.manifest.json +163 -102
- package/package.json +11 -3
- 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/dist/Config.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import Joi from 'joi';
|
|
2
|
-
export declare class ConfigError extends Error {
|
|
3
|
-
}
|
|
4
|
-
interface BaseProfile {
|
|
5
|
-
address: string;
|
|
6
|
-
accessType: 'google' | 'microsoft' | 'guest';
|
|
7
|
-
accessToken: string;
|
|
8
|
-
}
|
|
9
|
-
interface RootProfile extends Omit<BaseProfile, 'accessType'> {
|
|
10
|
-
accessType: 'root';
|
|
11
|
-
rootCredentials: {
|
|
12
|
-
username: string;
|
|
13
|
-
password: string;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
export type Profile = BaseProfile | RootProfile;
|
|
17
|
-
export declare enum KEYS {
|
|
18
|
-
address = "address",
|
|
19
|
-
accessType = "accessType",
|
|
20
|
-
accessToken = "accessToken",
|
|
21
|
-
rootCredentials_username = "rootCredentials.username",
|
|
22
|
-
rootCredentials_password = "rootCredentials.password"
|
|
23
|
-
}
|
|
24
|
-
export declare function optionDesc(): string[];
|
|
25
|
-
export declare class Config {
|
|
26
|
-
private configFile;
|
|
27
|
-
private profiles;
|
|
28
|
-
constructor(configFile: string);
|
|
29
|
-
private index;
|
|
30
|
-
private addProps;
|
|
31
|
-
private checkKey;
|
|
32
|
-
get(key: string, profileName: string): string;
|
|
33
|
-
set(key: string, value: string, profileName: string): void;
|
|
34
|
-
writeConfigFile(): void;
|
|
35
|
-
getProfileNames(): string[];
|
|
36
|
-
validate(): Joi.ValidationResult;
|
|
37
|
-
getAccess(profileName: string): Promise<{
|
|
38
|
-
address: string;
|
|
39
|
-
accessToken: string;
|
|
40
|
-
}>;
|
|
41
|
-
toString(): string;
|
|
42
|
-
}
|
|
43
|
-
export {};
|
package/dist/Config.js
DELETED
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3
|
-
/* eslint-disable @typescript-eslint/no-unsafe-enum-comparison */
|
|
4
|
-
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
|
6
|
-
import fs from 'node:fs';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
import Joi from 'joi';
|
|
9
|
-
import YAML, { YAMLParseError } from 'yaml';
|
|
10
|
-
import { checkProfileExists, queryApollo } from './utils.js';
|
|
11
|
-
export class ConfigError extends Error {
|
|
12
|
-
}
|
|
13
|
-
export var KEYS;
|
|
14
|
-
(function (KEYS) {
|
|
15
|
-
KEYS["address"] = "address";
|
|
16
|
-
KEYS["accessType"] = "accessType";
|
|
17
|
-
KEYS["accessToken"] = "accessToken";
|
|
18
|
-
KEYS["rootCredentials_username"] = "rootCredentials.username";
|
|
19
|
-
KEYS["rootCredentials_password"] = "rootCredentials.password";
|
|
20
|
-
})(KEYS || (KEYS = {}));
|
|
21
|
-
function optionDocs() {
|
|
22
|
-
const docs = [];
|
|
23
|
-
for (const v of Object.values(KEYS)) {
|
|
24
|
-
switch (v) {
|
|
25
|
-
case 'address': {
|
|
26
|
-
docs.push({
|
|
27
|
-
key: v,
|
|
28
|
-
description: 'Address and port e.g http://localhost:3999',
|
|
29
|
-
});
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case 'accessType': {
|
|
33
|
-
docs.push({
|
|
34
|
-
key: v,
|
|
35
|
-
description: 'How to access Apollo. accessType is typically one of: google, microsoft, guest, root. Allowed types depend on your Apollo setup',
|
|
36
|
-
});
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
case 'accessToken': {
|
|
40
|
-
docs.push({
|
|
41
|
-
key: v,
|
|
42
|
-
description: 'Access token. Usually inserted by `apollo login`',
|
|
43
|
-
});
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
case 'rootCredentials.username': {
|
|
47
|
-
docs.push({
|
|
48
|
-
key: v,
|
|
49
|
-
description: 'Username of root account. Only set this for "root" access type',
|
|
50
|
-
});
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
case 'rootCredentials.password': {
|
|
54
|
-
docs.push({
|
|
55
|
-
key: v,
|
|
56
|
-
description: 'Password for root account. Only set this for "root" access type',
|
|
57
|
-
});
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
default: {
|
|
61
|
-
throw new ConfigError(`Unexpected key: ${v}`);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return docs;
|
|
66
|
-
}
|
|
67
|
-
export function optionDesc() {
|
|
68
|
-
const docs = [];
|
|
69
|
-
for (const x of optionDocs()) {
|
|
70
|
-
docs.push(`- ${x.key}:\n${x.description}`);
|
|
71
|
-
}
|
|
72
|
-
return docs;
|
|
73
|
-
}
|
|
74
|
-
function isValidAddress(address) {
|
|
75
|
-
// const port: string | undefined = address.split(':').pop()
|
|
76
|
-
// if (port === undefined || /^\d+$/.test(port) === false) {
|
|
77
|
-
// return false
|
|
78
|
-
// }
|
|
79
|
-
let url;
|
|
80
|
-
try {
|
|
81
|
-
url = new URL(address);
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
const profileSchema = Joi.object({
|
|
92
|
-
address: Joi.string()
|
|
93
|
-
.uri({ scheme: /https?/ })
|
|
94
|
-
.required(),
|
|
95
|
-
accessType: Joi.string()
|
|
96
|
-
.valid('google', 'microsoft', 'root', 'guest')
|
|
97
|
-
.required(),
|
|
98
|
-
accessToken: Joi.string(),
|
|
99
|
-
rootCredentials: Joi.object({
|
|
100
|
-
username: Joi.string().required(),
|
|
101
|
-
password: Joi.string().required(),
|
|
102
|
-
}).when('accessType', {
|
|
103
|
-
is: Joi.string().valid('root'),
|
|
104
|
-
// eslint-disable-next-line unicorn/no-thenable
|
|
105
|
-
then: Joi.required(),
|
|
106
|
-
otherwise: Joi.forbidden(),
|
|
107
|
-
}),
|
|
108
|
-
});
|
|
109
|
-
const configSchema = Joi.object().pattern(Joi.string(), profileSchema);
|
|
110
|
-
export class Config {
|
|
111
|
-
configFile;
|
|
112
|
-
profiles = {};
|
|
113
|
-
constructor(configFile) {
|
|
114
|
-
this.configFile = configFile;
|
|
115
|
-
if (fs.existsSync(configFile)) {
|
|
116
|
-
const data = fs.readFileSync(configFile, 'utf8').trim();
|
|
117
|
-
if (data !== '') {
|
|
118
|
-
let config;
|
|
119
|
-
try {
|
|
120
|
-
config = YAML.parse(data);
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
if (error instanceof YAMLParseError) {
|
|
124
|
-
process.stderr.write('Error: Configuration file is probably invalid yaml format:\n');
|
|
125
|
-
process.stderr.write(error.message);
|
|
126
|
-
}
|
|
127
|
-
else if (error instanceof Error) {
|
|
128
|
-
process.stderr.write('Unexpected error:');
|
|
129
|
-
process.stderr.write(error.message);
|
|
130
|
-
}
|
|
131
|
-
// eslint-disable-next-line unicorn/no-process-exit
|
|
132
|
-
process.exit(1);
|
|
133
|
-
}
|
|
134
|
-
this.profiles = config;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
index(obj, arr, value) {
|
|
139
|
-
if (typeof arr == 'string') {
|
|
140
|
-
return this.index(obj, arr.split('.'), value);
|
|
141
|
-
}
|
|
142
|
-
if (arr.length == 1 && value !== undefined) {
|
|
143
|
-
return (obj[arr[0]] = value);
|
|
144
|
-
}
|
|
145
|
-
if (arr.length === 0) {
|
|
146
|
-
return obj;
|
|
147
|
-
}
|
|
148
|
-
return this.index(obj[arr[0]], arr.slice(1), value);
|
|
149
|
-
}
|
|
150
|
-
addProps(obj, arr, value) {
|
|
151
|
-
// credit https://stackoverflow.com/questions/17643965/how-to-automatically-add-properties-to-an-object-that-is-undefined
|
|
152
|
-
if (typeof arr == 'string') {
|
|
153
|
-
arr = arr.split('.');
|
|
154
|
-
}
|
|
155
|
-
obj[arr[0]] = obj[arr[0]] || {};
|
|
156
|
-
const tmpObj = obj[arr[0]];
|
|
157
|
-
if (arr.length > 1) {
|
|
158
|
-
arr.shift();
|
|
159
|
-
this.addProps(tmpObj, arr, value);
|
|
160
|
-
}
|
|
161
|
-
else if (value !== undefined) {
|
|
162
|
-
obj[arr[0]] = value;
|
|
163
|
-
}
|
|
164
|
-
return obj;
|
|
165
|
-
}
|
|
166
|
-
checkKey(key) {
|
|
167
|
-
for (const x of Object.values(KEYS)) {
|
|
168
|
-
if (x === key) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
throw new ConfigError(`Invalid configuration key: "${key}". Valid keys are:\n${Object.values('\n')}`);
|
|
173
|
-
}
|
|
174
|
-
get(key, profileName) {
|
|
175
|
-
this.checkKey(key);
|
|
176
|
-
const profile = this.profiles[profileName];
|
|
177
|
-
if (!profile) {
|
|
178
|
-
// throw new Error(`No profile name "${profileName}" found`)
|
|
179
|
-
return '';
|
|
180
|
-
}
|
|
181
|
-
this.addProps(profile, key);
|
|
182
|
-
const value = this.index(profile, key);
|
|
183
|
-
if (typeof value === 'object' && Object.keys(value).length === 0) {
|
|
184
|
-
// The key is valid but missing from config
|
|
185
|
-
return '';
|
|
186
|
-
}
|
|
187
|
-
return value;
|
|
188
|
-
}
|
|
189
|
-
set(key, value, profileName) {
|
|
190
|
-
this.checkKey(key);
|
|
191
|
-
if (key === KEYS[KEYS.address] && !isValidAddress(value)) {
|
|
192
|
-
throw new ConfigError(`"${value}" is not a valid value for "${key}"`);
|
|
193
|
-
}
|
|
194
|
-
const profile = this.profiles[profileName] ?? {};
|
|
195
|
-
this.profiles[profileName] = profile;
|
|
196
|
-
this.addProps(profile, key, value);
|
|
197
|
-
}
|
|
198
|
-
writeConfigFile() {
|
|
199
|
-
let APOLLO_DISABLE_CONFIG_CREATE = false;
|
|
200
|
-
if (process.env.APOLLO_DISABLE_CONFIG_CREATE !== undefined &&
|
|
201
|
-
process.env.APOLLO_DISABLE_CONFIG_CREATE !== '0') {
|
|
202
|
-
APOLLO_DISABLE_CONFIG_CREATE = true;
|
|
203
|
-
}
|
|
204
|
-
if (APOLLO_DISABLE_CONFIG_CREATE && !fs.existsSync(this.configFile)) {
|
|
205
|
-
throw new ConfigError('Configuration file does not exist yet, please create it as an empty file first.');
|
|
206
|
-
}
|
|
207
|
-
const yml = YAML.stringify(this.profiles);
|
|
208
|
-
fs.mkdirSync(path.dirname(this.configFile), { recursive: true });
|
|
209
|
-
fs.writeFileSync(this.configFile, yml);
|
|
210
|
-
}
|
|
211
|
-
getProfileNames() {
|
|
212
|
-
return Object.keys(this.profiles);
|
|
213
|
-
}
|
|
214
|
-
validate() {
|
|
215
|
-
return configSchema.validate(this.profiles);
|
|
216
|
-
}
|
|
217
|
-
async getAccess(profileName) {
|
|
218
|
-
checkProfileExists(profileName, this);
|
|
219
|
-
const address = this.get('address', profileName);
|
|
220
|
-
if (address === undefined || address.trim() === '') {
|
|
221
|
-
throw new ConfigError(`Profile "${profileName}" has no address. Please run "apollo config" to set it up.`);
|
|
222
|
-
}
|
|
223
|
-
const accessToken = this.get('accessToken', profileName);
|
|
224
|
-
if (accessToken === undefined || accessToken.trim() === '') {
|
|
225
|
-
throw new ConfigError(`Profile "${profileName}" has no access token. Please run "apollo login" to set it up.`);
|
|
226
|
-
}
|
|
227
|
-
await queryApollo(address, accessToken, 'assemblies');
|
|
228
|
-
return { address, accessToken };
|
|
229
|
-
}
|
|
230
|
-
toString() {
|
|
231
|
-
return YAML.stringify(this.profiles);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,188 +0,0 @@
|
|
|
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 config: Query config file', () => {
|
|
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 = ['config', 'rootCredentials.password'];
|
|
18
|
-
test
|
|
19
|
-
.stdout()
|
|
20
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
21
|
-
.it(cmd.join(' '), (ctx) => {
|
|
22
|
-
expect(ctx.stdout.trim()).to.equal('1234');
|
|
23
|
-
});
|
|
24
|
-
cmd = ['config', 'address'];
|
|
25
|
-
test
|
|
26
|
-
.stdout()
|
|
27
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
28
|
-
.it(cmd.join(' '), (ctx) => {
|
|
29
|
-
expect(ctx.stdout.trim()).to.equal('http://localhost:3999');
|
|
30
|
-
});
|
|
31
|
-
cmd = ['config', 'someInvalidKey'];
|
|
32
|
-
test
|
|
33
|
-
.stderr()
|
|
34
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
35
|
-
.exit(1)
|
|
36
|
-
.do((output) => expect(output.stderr).to.contain('someInvalidKey'))
|
|
37
|
-
.it(cmd.join(' '));
|
|
38
|
-
cmd = ['config', '--profile', 'profile1', 'address'];
|
|
39
|
-
test
|
|
40
|
-
.stdout()
|
|
41
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
42
|
-
.it(cmd.join(' '), (ctx) => {
|
|
43
|
-
expect(ctx.stdout.trim()).to.equal('http://localhost:1999');
|
|
44
|
-
});
|
|
45
|
-
cmd = ['config', '--profile', 'profile1', 'rootCredentials.username'];
|
|
46
|
-
test
|
|
47
|
-
.stdout()
|
|
48
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
49
|
-
.it(cmd.join(' '), (ctx) => {
|
|
50
|
-
expect(ctx.stdout.trim()).to.equal('');
|
|
51
|
-
});
|
|
52
|
-
cmd = ['config', '--profile', 'nonExistantProfile', 'address'];
|
|
53
|
-
test
|
|
54
|
-
.stdout()
|
|
55
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
56
|
-
.it(cmd.join(' '), (ctx) => {
|
|
57
|
-
expect(ctx.stdout.trim()).to.equal('');
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
describe('apollo config: Missing config file', () => {
|
|
61
|
-
let cmd = ['config', 'rootCredentials.password'];
|
|
62
|
-
test
|
|
63
|
-
.stdout()
|
|
64
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
65
|
-
.it(cmd.join(' '), (ctx) => {
|
|
66
|
-
expect(ctx.stdout.trim()).to.equal('');
|
|
67
|
-
});
|
|
68
|
-
cmd = ['config', 'address'];
|
|
69
|
-
test
|
|
70
|
-
.stdout()
|
|
71
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
72
|
-
.it(cmd.join(' '), (ctx) => {
|
|
73
|
-
expect(ctx.stdout.trim()).to.equal('');
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
describe('apollo config: Create config directory', () => {
|
|
77
|
-
const outdir = `${TEST_DATA_DIR}/_tmp`;
|
|
78
|
-
before(() => {
|
|
79
|
-
fs.rmSync(outdir, { recursive: true, force: true });
|
|
80
|
-
});
|
|
81
|
-
after(() => {
|
|
82
|
-
fs.rmSync(outdir, { recursive: true, force: true });
|
|
83
|
-
});
|
|
84
|
-
const cmd = [
|
|
85
|
-
'config',
|
|
86
|
-
'--config-file',
|
|
87
|
-
`${outdir}/config.yaml`,
|
|
88
|
-
'address',
|
|
89
|
-
'http://localhost:3999',
|
|
90
|
-
];
|
|
91
|
-
test
|
|
92
|
-
.stdout()
|
|
93
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
94
|
-
.it(cmd.join(' '), () => {
|
|
95
|
-
expect(fs.existsSync(`${outdir}/config.yaml`));
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
describe('apollo config: Read & edit config file', () => {
|
|
99
|
-
before(() => {
|
|
100
|
-
copyFile(`${TEST_DATA_DIR}/complete_config.yaml`, CONFIG_FILE, VERBOSE);
|
|
101
|
-
});
|
|
102
|
-
after(() => {
|
|
103
|
-
fs.rmSync(CONFIG_FILE);
|
|
104
|
-
});
|
|
105
|
-
let cmd = ['config', 'address', 'http://localhost:4321'];
|
|
106
|
-
test
|
|
107
|
-
.stdout()
|
|
108
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
109
|
-
.it(cmd.join(' '), () => {
|
|
110
|
-
const cfg = YAML.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
111
|
-
expect(cfg.default.address).to.equal('http://localhost:4321');
|
|
112
|
-
expect(cfg.default.rootCredentials.username).to.equal('root');
|
|
113
|
-
});
|
|
114
|
-
cmd = ['config', 'rootCredentials.username', 'root2'];
|
|
115
|
-
test
|
|
116
|
-
.stdout()
|
|
117
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
118
|
-
.it(cmd.join(' '), () => {
|
|
119
|
-
const cfg = YAML.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
120
|
-
expect(cfg.default.rootCredentials.username).to.equal('root2');
|
|
121
|
-
});
|
|
122
|
-
cmd = ['config', 'accessType', 'microsoft'];
|
|
123
|
-
test
|
|
124
|
-
.stdout()
|
|
125
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
126
|
-
.it(cmd.join(' '), () => {
|
|
127
|
-
const cfg = YAML.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
128
|
-
expect(cfg.default.accessType).to.equal('microsoft');
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
describe('Do not set invalid address', () => {
|
|
132
|
-
before(() => {
|
|
133
|
-
copyFile(`${TEST_DATA_DIR}/complete_config.yaml`, CONFIG_FILE, VERBOSE);
|
|
134
|
-
});
|
|
135
|
-
after(() => {
|
|
136
|
-
fs.rmSync(CONFIG_FILE);
|
|
137
|
-
});
|
|
138
|
-
const cmd = ['config', 'address', 'http://localhost:3999xxx'];
|
|
139
|
-
test
|
|
140
|
-
.stderr()
|
|
141
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
142
|
-
.exit(1)
|
|
143
|
-
.do((output) => expect(output.stderr).to.contain('http://localhost:3999xxx'))
|
|
144
|
-
.it(cmd.join(' '));
|
|
145
|
-
});
|
|
146
|
-
describe('apollo config: Write config file from scratch', () => {
|
|
147
|
-
after(() => {
|
|
148
|
-
fs.rmSync(CONFIG_FILE);
|
|
149
|
-
});
|
|
150
|
-
let cmd = ['config', 'rootCredentials.username', 'somename'];
|
|
151
|
-
test
|
|
152
|
-
.stdout()
|
|
153
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
154
|
-
.it(cmd.join(' '), () => {
|
|
155
|
-
const cfg = YAML.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
156
|
-
expect(cfg.default.rootCredentials.username).to.equal('somename');
|
|
157
|
-
});
|
|
158
|
-
cmd = [
|
|
159
|
-
'config',
|
|
160
|
-
'--profile',
|
|
161
|
-
'myProfile',
|
|
162
|
-
'rootCredentials.password',
|
|
163
|
-
'somepwd',
|
|
164
|
-
];
|
|
165
|
-
test
|
|
166
|
-
.stdout()
|
|
167
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
168
|
-
.it(cmd.join(' '), () => {
|
|
169
|
-
const cfg = YAML.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
170
|
-
expect(cfg.myProfile.rootCredentials.password).to.equal('somepwd');
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
describe('apollo config: Handle strings as numbers in yaml', () => {
|
|
174
|
-
const cmd = [
|
|
175
|
-
'config',
|
|
176
|
-
'--config-file',
|
|
177
|
-
'test_data/nameAsNumber.yaml',
|
|
178
|
-
'rootCredentials.username',
|
|
179
|
-
];
|
|
180
|
-
test
|
|
181
|
-
.stderr()
|
|
182
|
-
.stdout()
|
|
183
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
184
|
-
.do((output) => expect(output.stderr).contains('must be a string'))
|
|
185
|
-
.it(cmd.join(' '), (ctx) => {
|
|
186
|
-
expect(ctx.stdout.trim()).to.equal('7890');
|
|
187
|
-
});
|
|
188
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,52 +0,0 @@
|
|
|
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 login: Config file does not exist', () => {
|
|
11
|
-
const cmd = ['login', '--config-file', '_tmp.yaml'];
|
|
12
|
-
test
|
|
13
|
-
.stderr()
|
|
14
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
15
|
-
.exit(1)
|
|
16
|
-
.do((output) => expect(output.stderr).to.contain('apollo config'))
|
|
17
|
-
.it(cmd.join(' '));
|
|
18
|
-
});
|
|
19
|
-
describe('apollo login: Profile does not exist', () => {
|
|
20
|
-
const cmd = [
|
|
21
|
-
'login',
|
|
22
|
-
'--config-file',
|
|
23
|
-
'test_data/complete_config.yaml',
|
|
24
|
-
'--profile',
|
|
25
|
-
'notavailable',
|
|
26
|
-
];
|
|
27
|
-
test
|
|
28
|
-
.stderr()
|
|
29
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
30
|
-
.exit(1)
|
|
31
|
-
.do((output) => expect(output.stderr).to.contain('apollo config'))
|
|
32
|
-
.do((output) => expect(output.stderr).to.contain('Profile'))
|
|
33
|
-
.do((output) => expect(output.stderr).to.contain('notavailable'))
|
|
34
|
-
.it(cmd.join(' '));
|
|
35
|
-
});
|
|
36
|
-
// TODO: Mock server
|
|
37
|
-
describe.skip('apollo login: Add token for guest', () => {
|
|
38
|
-
before(() => {
|
|
39
|
-
copyFile(`${TEST_DATA_DIR}/guest.yaml`, CONFIG_FILE, VERBOSE);
|
|
40
|
-
});
|
|
41
|
-
after(() => {
|
|
42
|
-
fs.rmSync(CONFIG_FILE);
|
|
43
|
-
});
|
|
44
|
-
const cmd = ['login'];
|
|
45
|
-
test
|
|
46
|
-
.stdout()
|
|
47
|
-
.command(cmd, { root: dirname(dirname(__dirname)) })
|
|
48
|
-
.it(cmd.join(' '), () => {
|
|
49
|
-
const cfg = YAML.parse(fs.readFileSync(CONFIG_FILE, 'utf8'));
|
|
50
|
-
expect(cfg.default.accessToken).not.empty;
|
|
51
|
-
});
|
|
52
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,67 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
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
|
-
});
|