@asteroidai/cli 1.9.27 → 1.9.28
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/dist/asteroid.js +1 -1
- package/package.json +3 -8
- package/src/account.ts +0 -501
- package/src/args.ts +0 -39
- package/src/auth/credentials.ts +0 -179
- package/src/auth/store.ts +0 -253
- package/src/auth/workos.ts +0 -171
- package/src/commands.ts +0 -13
- package/src/config.ts +0 -125
- package/src/core.ts +0 -41
- package/src/generated/commands.ts +0 -4772
- package/src/http.ts +0 -115
- package/src/main.ts +0 -49
- package/src/output.test.ts +0 -71
- package/src/output.ts +0 -176
- package/src/program.test.ts +0 -155
- package/src/program.ts +0 -293
- package/src/reference.ts +0 -195
- package/src/request.test.ts +0 -164
- package/src/request.ts +0 -252
- package/src/run.test.ts +0 -651
- package/src/run.ts +0 -235
- package/src/sync/activities.ts +0 -80
- package/src/sync/commands.ts +0 -63
- package/src/sync/execution-pull.ts +0 -273
- package/src/sync/node-files.ts +0 -47
- package/src/sync/paths.ts +0 -45
- package/src/sync/run.ts +0 -136
- package/src/sync/sync.test.ts +0 -502
- package/src/sync/types.ts +0 -58
- package/src/sync/workflow-pull.ts +0 -185
- package/src/sync/workflow-push.ts +0 -161
- package/src/types.ts +0 -46
- package/src/ui.ts +0 -35
package/src/config.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import envPaths from "env-paths";
|
|
2
|
-
import {
|
|
3
|
-
chmodSync,
|
|
4
|
-
existsSync,
|
|
5
|
-
mkdirSync,
|
|
6
|
-
readFileSync,
|
|
7
|
-
renameSync,
|
|
8
|
-
writeFileSync,
|
|
9
|
-
} from "node:fs";
|
|
10
|
-
import { dirname, join } from "node:path";
|
|
11
|
-
|
|
12
|
-
import { clean } from "./output";
|
|
13
|
-
|
|
14
|
-
export interface Org {
|
|
15
|
-
workosId: string;
|
|
16
|
-
id?: string;
|
|
17
|
-
name?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface Config {
|
|
21
|
-
org?: Org;
|
|
22
|
-
orgs?: Org[];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const DEFAULT_API_URL = "https://odyssey.asteroid.ai";
|
|
26
|
-
export const DEFAULT_WORKOS_CLIENT_ID = "client_01K3NXPE8X6EJZXZSYCNT5M4P0";
|
|
27
|
-
export const DEFAULT_WORKOS_API_URL = "https://api.workos.com";
|
|
28
|
-
|
|
29
|
-
export interface Env {
|
|
30
|
-
apiUrl: string;
|
|
31
|
-
apiKey?: string;
|
|
32
|
-
org?: string;
|
|
33
|
-
workosClientId: string;
|
|
34
|
-
workosApiUrl: string;
|
|
35
|
-
configDir: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function readEnv(env: NodeJS.ProcessEnv = process.env): Env {
|
|
39
|
-
return {
|
|
40
|
-
apiUrl: (env.ASTEROID_API_URL || DEFAULT_API_URL).replace(/\/+$/, ""),
|
|
41
|
-
apiKey: env.ASTEROID_API_KEY || undefined,
|
|
42
|
-
org: env.ASTEROID_ORG || undefined,
|
|
43
|
-
workosClientId: env.ASTEROID_WORKOS_CLIENT_ID || DEFAULT_WORKOS_CLIENT_ID,
|
|
44
|
-
workosApiUrl: (
|
|
45
|
-
env.ASTEROID_WORKOS_API_URL || DEFAULT_WORKOS_API_URL
|
|
46
|
-
).replace(/\/+$/, ""),
|
|
47
|
-
configDir:
|
|
48
|
-
env.ASTEROID_CONFIG_DIR || envPaths("asteroid", { suffix: "" }).config,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function readJson<T>(path: string, fallback: T): T {
|
|
53
|
-
if (!existsSync(path)) return fallback;
|
|
54
|
-
try {
|
|
55
|
-
return JSON.parse(readFileSync(path, "utf8")) as T;
|
|
56
|
-
} catch {
|
|
57
|
-
return fallback;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function writePrivateJson(path: string, value: unknown) {
|
|
62
|
-
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
|
|
63
|
-
const temp = `${path}.${process.pid}.tmp`;
|
|
64
|
-
writeFileSync(temp, `${JSON.stringify(value, null, 2)}\n`, { mode: 0o600 });
|
|
65
|
-
chmodSync(temp, 0o600);
|
|
66
|
-
renameSync(temp, path);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function loadConfig(env: Env): Config {
|
|
70
|
-
return readJson<Config>(join(env.configDir, "config.json"), {});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function saveConfig(env: Env, config: Config) {
|
|
74
|
-
writePrivateJson(join(env.configDir, "config.json"), config);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function repoOrg(cwd: string): string | undefined {
|
|
78
|
-
let dir = cwd;
|
|
79
|
-
for (;;) {
|
|
80
|
-
const file = join(dir, ".asteroid", "org");
|
|
81
|
-
if (existsSync(file)) return readFileSync(file, "utf8").trim() || undefined;
|
|
82
|
-
const parent = dirname(dir);
|
|
83
|
-
if (parent === dir) return undefined;
|
|
84
|
-
dir = parent;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function requestedOrg(
|
|
89
|
-
flag: string | undefined,
|
|
90
|
-
env: Env,
|
|
91
|
-
cwd: string,
|
|
92
|
-
config: Config,
|
|
93
|
-
) {
|
|
94
|
-
return flag ?? env.org ?? repoOrg(cwd) ?? config.org?.workosId;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function findOrg(ref: string, orgs: Org[]): Org | undefined {
|
|
98
|
-
const lower = ref.toLowerCase();
|
|
99
|
-
return (
|
|
100
|
-
orgs.find(
|
|
101
|
-
(org) =>
|
|
102
|
-
org.workosId.toLowerCase() === lower || org.id?.toLowerCase() === lower,
|
|
103
|
-
) ??
|
|
104
|
-
orgs.find((org) => org.name?.toLowerCase() === lower) ??
|
|
105
|
-
(/^org_[0-9a-z]+$/i.test(ref) ? { workosId: ref } : undefined)
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function mergeOrgs(known: Org[] = [], found: Org[] = []): Org[] {
|
|
110
|
-
const byId = new Map(known.map((org) => [org.workosId, org]));
|
|
111
|
-
for (const org of found) {
|
|
112
|
-
const merged = { ...byId.get(org.workosId) };
|
|
113
|
-
for (const [key, value] of Object.entries(org))
|
|
114
|
-
if (value !== undefined) Object.assign(merged, { [key]: value });
|
|
115
|
-
byId.set(org.workosId, merged as Org);
|
|
116
|
-
}
|
|
117
|
-
return [...byId.values()].sort((a, b) =>
|
|
118
|
-
(a.name ?? a.workosId).localeCompare(b.name ?? b.workosId),
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function orgLabel(org: Org): string {
|
|
123
|
-
const id = clean(org.id ?? org.workosId);
|
|
124
|
-
return org.name ? `${clean(org.name)} (${id})` : id;
|
|
125
|
-
}
|
package/src/core.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
export { leadingWords, matchCommand, type Parsed, UsageError } from "./args";
|
|
2
|
-
export { COMMANDS } from "./generated/commands";
|
|
3
|
-
export { render } from "./output";
|
|
4
|
-
export {
|
|
5
|
-
type Invocation,
|
|
6
|
-
parseInvocation,
|
|
7
|
-
type ProgramOptions,
|
|
8
|
-
} from "./program";
|
|
9
|
-
export { type BuiltRequest, buildRequest, type InputReader } from "./request";
|
|
10
|
-
export type { CliCommand, Option } from "./types";
|
|
11
|
-
export { ALL_COMMANDS, withSyncCommands } from "./commands";
|
|
12
|
-
export { type Activity, formatActivitiesMarkdown } from "./sync/activities";
|
|
13
|
-
export {
|
|
14
|
-
type Execution,
|
|
15
|
-
type ExecutionPullOptions,
|
|
16
|
-
type ExecutionPullResult,
|
|
17
|
-
formatExecutionPull,
|
|
18
|
-
pullExecution,
|
|
19
|
-
} from "./sync/execution-pull";
|
|
20
|
-
export { matchesGlob } from "./sync/paths";
|
|
21
|
-
export { runSync, type SyncDeps, SYNC_COMMANDS } from "./sync/run";
|
|
22
|
-
export {
|
|
23
|
-
type FileEntry,
|
|
24
|
-
type FileTree,
|
|
25
|
-
type LocalFiles,
|
|
26
|
-
MANIFEST,
|
|
27
|
-
type Manifest,
|
|
28
|
-
type Remote,
|
|
29
|
-
type Sync,
|
|
30
|
-
} from "./sync/types";
|
|
31
|
-
export {
|
|
32
|
-
formatWorkflowPull,
|
|
33
|
-
pullWorkflow,
|
|
34
|
-
type WorkflowPullOptions,
|
|
35
|
-
type WorkflowPullResult,
|
|
36
|
-
} from "./sync/workflow-pull";
|
|
37
|
-
export {
|
|
38
|
-
formatWorkflowPush,
|
|
39
|
-
pushWorkflow,
|
|
40
|
-
type WorkflowPushResult,
|
|
41
|
-
} from "./sync/workflow-push";
|