@eve-horizon/cli 0.0.1

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.
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveContext = resolveContext;
4
+ exports.parseHarnessSpec = parseHarnessSpec;
5
+ const args_1 = require("./args");
6
+ const DEFAULT_API_URL = 'http://localhost:4747';
7
+ function resolveContext(flags, config, credentials) {
8
+ const profileName = (0, args_1.getStringFlag)(flags, ['profile']) ||
9
+ process.env.EVE_PROFILE ||
10
+ config.active_profile ||
11
+ 'default';
12
+ const profile = config.profiles[profileName] ?? {};
13
+ const apiUrl = (0, args_1.getStringFlag)(flags, ['api', 'api-url']) ||
14
+ process.env.EVE_API_URL ||
15
+ profile.api_url ||
16
+ DEFAULT_API_URL;
17
+ const orgId = (0, args_1.getStringFlag)(flags, ['org']) ||
18
+ process.env.EVE_ORG_ID ||
19
+ profile.org_id;
20
+ const projectId = (0, args_1.getStringFlag)(flags, ['project']) ||
21
+ process.env.EVE_PROJECT_ID ||
22
+ profile.project_id;
23
+ const tokenEntry = credentials.profiles[profileName];
24
+ return {
25
+ apiUrl,
26
+ orgId,
27
+ projectId,
28
+ profileName,
29
+ profile,
30
+ token: tokenEntry?.access_token,
31
+ refreshToken: tokenEntry?.refresh_token,
32
+ expiresAt: tokenEntry?.expires_at,
33
+ };
34
+ }
35
+ /**
36
+ * Parse a harness spec like "mclaude" or "mclaude:fast" into [harness, variant]
37
+ */
38
+ function parseHarnessSpec(spec) {
39
+ if (!spec)
40
+ return [undefined, undefined];
41
+ const colonIdx = spec.indexOf(':');
42
+ if (colonIdx === -1)
43
+ return [spec, undefined];
44
+ return [spec.slice(0, colonIdx), spec.slice(colonIdx + 1) || undefined];
45
+ }