@hexclave/cli 1.0.66 → 1.0.68
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/index.js +245 -24
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/commands/init.ts +0 -4
- package/src/commands/project.ts +4 -5
- package/src/commands/team.command.test.ts +124 -0
- package/src/commands/team.test.ts +25 -0
- package/src/commands/team.ts +301 -0
- package/src/index.ts +2 -0
- package/src/lib/create-project.ts +11 -13
- package/src/lib/resolve-team.test.ts +58 -0
- package/src/lib/resolve-team.ts +62 -0
- package/dist/errors-CyPbl0LV.js +0 -21
- package/dist/errors-CyPbl0LV.js.map +0 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { input, select } from "@inquirer/prompts";
|
|
2
|
+
import { CliError } from "./errors.js";
|
|
3
|
+
import { isNonInteractiveEnv } from "./interactive.js";
|
|
4
|
+
|
|
5
|
+
export type ResolveTeamItem = {
|
|
6
|
+
id: string,
|
|
7
|
+
displayName: string,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type ResolveTeamOptions<T extends ResolveTeamItem> = {
|
|
11
|
+
teamId?: string,
|
|
12
|
+
createTeam?: (displayName: string) => Promise<T>,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export async function resolveTeam<T extends ResolveTeamItem>(
|
|
16
|
+
teams: T[],
|
|
17
|
+
options: ResolveTeamOptions<T> = {},
|
|
18
|
+
): Promise<T> {
|
|
19
|
+
const teamId = options.teamId?.trim();
|
|
20
|
+
if (teamId) {
|
|
21
|
+
const team = teams.find((candidate) => candidate.id === teamId);
|
|
22
|
+
if (team == null) {
|
|
23
|
+
throw new CliError(`Team '${teamId}' was not found on your account.`);
|
|
24
|
+
}
|
|
25
|
+
return team;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (teams.length === 0) {
|
|
29
|
+
if (options.createTeam != null) {
|
|
30
|
+
if (isNonInteractiveEnv()) {
|
|
31
|
+
throw new CliError("No teams found. Run `hexclave team create` first, or pass --team-id.");
|
|
32
|
+
}
|
|
33
|
+
const displayName = (await input({
|
|
34
|
+
message: "Team display name:",
|
|
35
|
+
validate: (value) => value.trim().length > 0 || "Display name cannot be empty.",
|
|
36
|
+
})).trim();
|
|
37
|
+
return await options.createTeam(displayName);
|
|
38
|
+
}
|
|
39
|
+
throw new CliError("No teams found. Run `hexclave team create` first.");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (teams.length === 1) {
|
|
43
|
+
return teams[0];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (isNonInteractiveEnv()) {
|
|
47
|
+
throw new CliError("--team-id is required in non-interactive environments (CI).");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const selectedTeamId = await select({
|
|
51
|
+
message: "Choose a team:",
|
|
52
|
+
choices: teams.map((team) => ({
|
|
53
|
+
name: `${team.displayName || "(unnamed)"} (${team.id})`,
|
|
54
|
+
value: team.id,
|
|
55
|
+
})),
|
|
56
|
+
});
|
|
57
|
+
const selectedTeam = teams.find((team) => team.id === selectedTeamId);
|
|
58
|
+
if (selectedTeam == null) {
|
|
59
|
+
throw new CliError("The selected team was not found.");
|
|
60
|
+
}
|
|
61
|
+
return selectedTeam;
|
|
62
|
+
}
|
package/dist/errors-CyPbl0LV.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
//#region src/lib/errors.ts
|
|
3
|
-
var CliError = class extends Error {
|
|
4
|
-
constructor(message) {
|
|
5
|
-
super(message);
|
|
6
|
-
this.name = "CliError";
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
var AuthError = class extends CliError {
|
|
10
|
-
constructor(message) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.name = "AuthError";
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
function errorMessage(error) {
|
|
16
|
-
return error instanceof Error ? error.message : String(error);
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
export { CliError as n, errorMessage as r, AuthError as t };
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=errors-CyPbl0LV.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors-CyPbl0LV.js","names":[],"sources":["../src/lib/errors.ts"],"sourcesContent":["export class CliError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"CliError\";\n }\n}\n\nexport class AuthError extends CliError {\n constructor(message: string) {\n super(message);\n this.name = \"AuthError\";\n }\n}\n\nexport function errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n"],"mappings":";;AAAA,IAAa,WAAb,cAA8B,MAAM;CAClC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;AAEA,IAAa,YAAb,cAA+B,SAAS;CACtC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;AAEA,SAAgB,aAAa,OAAwB;CACnD,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D"}
|