@antasphere/cli-core 0.3.0 → 0.5.0
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 +210 -103
- package/dist/config.d.ts +61 -31
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +42 -27
- package/dist/config.js.map +1 -1
- package/dist/connect-on-demand.d.ts +85 -32
- package/dist/connect-on-demand.d.ts.map +1 -1
- package/dist/connect-on-demand.js +106 -50
- package/dist/connect-on-demand.js.map +1 -1
- package/dist/connect.d.ts +58 -28
- package/dist/connect.d.ts.map +1 -1
- package/dist/connect.js +31 -9
- package/dist/connect.js.map +1 -1
- package/dist/index.d.ts +15 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -9
- package/dist/index.js.map +1 -1
- package/dist/resolve.d.ts +125 -10
- package/dist/resolve.d.ts.map +1 -1
- package/dist/resolve.js +167 -8
- package/dist/resolve.js.map +1 -1
- package/package.json +2 -2
- package/src/config.ts +91 -45
- package/src/connect-on-demand.ts +192 -78
- package/src/connect.ts +69 -31
- package/src/index.ts +51 -15
- package/src/resolve.ts +234 -13
- package/dist/org.d.ts +0 -42
- package/dist/org.d.ts.map +0 -1
- package/dist/org.js +0 -39
- package/dist/org.js.map +0 -1
- package/src/org.ts +0 -73
package/src/org.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { HUB_TOOL, loadConfig, saveConfig, type CliEnv } from './config.js';
|
|
2
|
-
import { CliUsageError, resolveProfile } from './resolve.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Org context for the cross-tool connect flow (binding patterns §7). Orgs
|
|
6
|
-
* are HUB-level entities and the hub login is the one credential shared
|
|
7
|
-
* across the tool family, so the active org lives on the HUB profile:
|
|
8
|
-
* `antasphere org use` sets it, every tool CLI reads it when picking the
|
|
9
|
-
* org to exchange for.
|
|
10
|
-
*
|
|
11
|
-
* The effective target org for an exchange resolves in this order:
|
|
12
|
-
*
|
|
13
|
-
* explicit per-invocation override (--org)
|
|
14
|
-
* → the hub profile's active org (`org use`)
|
|
15
|
-
* → the hub key's bound workspace (set at login)
|
|
16
|
-
* → undefined — the exchange then omits `workspaceId` and the hub
|
|
17
|
-
* defaults to the key's bound org server-side.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export interface OrgContextOptions {
|
|
21
|
-
/** Hub profile name; default = the hub config's active profile. */
|
|
22
|
-
profile?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The hub profile's effective active org: the `org use` choice when one is
|
|
27
|
-
* set, else the org the hub key was bound to at login. Undefined when not
|
|
28
|
-
* logged in (or an explicitly named profile is missing → CliUsageError).
|
|
29
|
-
*/
|
|
30
|
-
export function getActiveWorkspace(env: CliEnv, opts: OrgContextOptions = {}): string | undefined {
|
|
31
|
-
const { profile } = resolveProfile(loadConfig(env, HUB_TOOL), opts.profile);
|
|
32
|
-
return profile?.activeWorkspaceId ?? profile?.workspaceId;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* What `antasphere org use` calls: persist the org choice on the hub
|
|
37
|
-
* profile (`null` clears it, falling back to the key's bound workspace).
|
|
38
|
-
* Every other profile field is preserved. Returns the file written.
|
|
39
|
-
*/
|
|
40
|
-
export function setActiveWorkspace(
|
|
41
|
-
env: CliEnv,
|
|
42
|
-
workspaceId: string | null,
|
|
43
|
-
opts: OrgContextOptions = {}
|
|
44
|
-
): string {
|
|
45
|
-
const config = loadConfig(env, HUB_TOOL);
|
|
46
|
-
const { name, profile } = resolveProfile(config, opts.profile);
|
|
47
|
-
if (!name || !profile) {
|
|
48
|
-
throw new CliUsageError('No hub profile to set the org on — run `antasphere login` first.');
|
|
49
|
-
}
|
|
50
|
-
if (workspaceId === null) {
|
|
51
|
-
const { activeWorkspaceId: _cleared, ...rest } = profile;
|
|
52
|
-
config.profiles[name] = rest;
|
|
53
|
-
} else {
|
|
54
|
-
config.profiles[name] = { ...profile, activeWorkspaceId: workspaceId };
|
|
55
|
-
}
|
|
56
|
-
return saveConfig(env, HUB_TOOL, config);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface ResolveTargetWorkspaceOptions extends OrgContextOptions {
|
|
60
|
-
/** Per-invocation override (--org). */
|
|
61
|
-
override?: string;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* The org a cross-tool exchange should target: explicit override → active
|
|
66
|
-
* org → the hub key's bound workspace → undefined (hub decides).
|
|
67
|
-
*/
|
|
68
|
-
export function resolveTargetWorkspace(
|
|
69
|
-
env: CliEnv,
|
|
70
|
-
opts: ResolveTargetWorkspaceOptions = {}
|
|
71
|
-
): string | undefined {
|
|
72
|
-
return opts.override ?? getActiveWorkspace(env, opts);
|
|
73
|
-
}
|