@alwaysmeticulous/cli 2.323.0 → 2.324.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/dist/commands/agent/agent-review-writes.command.spec.d.ts +2 -0
- package/dist/commands/agent/agent-review-writes.command.spec.d.ts.map +1 -0
- package/dist/commands/agent/agent-review-writes.command.spec.js +96 -0
- package/dist/commands/agent/agent-review-writes.command.spec.js.map +1 -0
- package/dist/commands/agent/create-diff-comment.command.d.ts +13 -0
- package/dist/commands/agent/create-diff-comment.command.d.ts.map +1 -0
- package/dist/commands/agent/create-diff-comment.command.js +57 -0
- package/dist/commands/agent/create-diff-comment.command.js.map +1 -0
- package/dist/commands/agent/diff-comment-write.utils.d.ts +13 -0
- package/dist/commands/agent/diff-comment-write.utils.d.ts.map +1 -0
- package/dist/commands/agent/diff-comment-write.utils.js +19 -0
- package/dist/commands/agent/diff-comment-write.utils.js.map +1 -0
- package/dist/commands/agent/diff-comments.command.d.ts.map +1 -1
- package/dist/commands/agent/diff-comments.command.js +15 -4
- package/dist/commands/agent/diff-comments.command.js.map +1 -1
- package/dist/commands/agent/diff-comments.command.spec.js +29 -4
- package/dist/commands/agent/diff-comments.command.spec.js.map +1 -1
- package/dist/commands/agent/ignore-diff.command.d.ts +13 -0
- package/dist/commands/agent/ignore-diff.command.d.ts.map +1 -0
- package/dist/commands/agent/ignore-diff.command.js +54 -0
- package/dist/commands/agent/ignore-diff.command.js.map +1 -0
- package/dist/commands/agent/index.d.ts.map +1 -1
- package/dist/commands/agent/index.js +16 -6
- package/dist/commands/agent/index.js.map +1 -1
- package/dist/commands/agent/js-coverage.command.d.ts +2 -2
- package/dist/commands/agent/js-coverage.command.d.ts.map +1 -1
- package/dist/commands/agent/js-coverage.command.js +6 -5
- package/dist/commands/agent/js-coverage.command.js.map +1 -1
- package/dist/commands/agent/js-coverage.command.spec.js +7 -6
- package/dist/commands/agent/js-coverage.command.spec.js.map +1 -1
- package/dist/commands/agent/reject-diff.command.d.ts +13 -0
- package/dist/commands/agent/reject-diff.command.d.ts.map +1 -0
- package/dist/commands/agent/reject-diff.command.js +54 -0
- package/dist/commands/agent/reject-diff.command.js.map +1 -0
- package/dist/commands/agent/reject-diff.command.spec.d.ts +2 -0
- package/dist/commands/agent/reject-diff.command.spec.d.ts.map +1 -0
- package/dist/commands/agent/reject-diff.command.spec.js +61 -0
- package/dist/commands/agent/reject-diff.command.spec.js.map +1 -0
- package/dist/commands/agent/reply-to-diff-comment.command.d.ts +10 -0
- package/dist/commands/agent/reply-to-diff-comment.command.d.ts.map +1 -0
- package/dist/commands/agent/reply-to-diff-comment.command.js +47 -0
- package/dist/commands/agent/reply-to-diff-comment.command.js.map +1 -0
- package/dist/commands/agent/sessions.command.d.ts +3 -0
- package/dist/commands/agent/sessions.command.d.ts.map +1 -1
- package/dist/commands/agent/sessions.command.js +46 -5
- package/dist/commands/agent/sessions.command.js.map +1 -1
- package/dist/commands/agent/sessions.command.spec.js +30 -7
- package/dist/commands/agent/sessions.command.spec.js.map +1 -1
- package/dist/commands/agent/test-run-checks.command.d.ts +15 -0
- package/dist/commands/agent/test-run-checks.command.d.ts.map +1 -0
- package/dist/commands/agent/test-run-checks.command.js +121 -0
- package/dist/commands/agent/test-run-checks.command.js.map +1 -0
- package/dist/commands/agent/test-run-checks.command.spec.d.ts +2 -0
- package/dist/commands/agent/test-run-checks.command.spec.d.ts.map +1 -0
- package/dist/commands/agent/test-run-checks.command.spec.js +132 -0
- package/dist/commands/agent/test-run-checks.command.spec.js.map +1 -0
- package/dist/commands/agent/test-run-diffs.command.d.ts.map +1 -1
- package/dist/commands/agent/test-run-diffs.command.js +19 -24
- package/dist/commands/agent/test-run-diffs.command.js.map +1 -1
- package/dist/commands/agent/test-run-diffs.command.spec.js +59 -37
- package/dist/commands/agent/test-run-diffs.command.spec.js.map +1 -1
- package/dist/commands/agent/test-run-diffs.utils.d.ts +1 -0
- package/dist/commands/agent/test-run-diffs.utils.d.ts.map +1 -1
- package/dist/commands/agent/test-run-diffs.utils.js +5 -3
- package/dist/commands/agent/test-run-diffs.utils.js.map +1 -1
- package/dist/commands/agent/test-run-diffs.utils.spec.js +2 -2
- package/dist/commands/agent/test-run-for-commit.command.d.ts.map +1 -1
- package/dist/commands/agent/test-run-for-commit.command.js +5 -4
- package/dist/commands/agent/test-run-for-commit.command.js.map +1 -1
- package/dist/commands/auth/__tests__/get-project.command.spec.js +48 -42
- package/dist/commands/auth/__tests__/get-project.command.spec.js.map +1 -1
- package/dist/commands/auth/__tests__/list-projects.command.spec.js +11 -10
- package/dist/commands/auth/__tests__/list-projects.command.spec.js.map +1 -1
- package/dist/commands/auth/__tests__/set-project.command.spec.js +6 -7
- package/dist/commands/auth/__tests__/set-project.command.spec.js.map +1 -1
- package/dist/commands/auth/__tests__/whoami.command.spec.js +77 -124
- package/dist/commands/auth/__tests__/whoami.command.spec.js.map +1 -1
- package/dist/commands/auth/get-project.command.d.ts +6 -2
- package/dist/commands/auth/get-project.command.d.ts.map +1 -1
- package/dist/commands/auth/get-project.command.js +25 -24
- package/dist/commands/auth/get-project.command.js.map +1 -1
- package/dist/commands/auth/list-projects.command.d.ts.map +1 -1
- package/dist/commands/auth/list-projects.command.js +4 -8
- package/dist/commands/auth/list-projects.command.js.map +1 -1
- package/dist/commands/auth/set-project.command.d.ts +1 -0
- package/dist/commands/auth/set-project.command.d.ts.map +1 -1
- package/dist/commands/auth/set-project.command.js +22 -9
- package/dist/commands/auth/set-project.command.js.map +1 -1
- package/dist/commands/auth/whoami.command.d.ts.map +1 -1
- package/dist/commands/auth/whoami.command.js +94 -87
- package/dist/commands/auth/whoami.command.js.map +1 -1
- package/dist/utils/__tests__/project-selection-hint.spec.d.ts +2 -0
- package/dist/utils/__tests__/project-selection-hint.spec.d.ts.map +1 -0
- package/dist/utils/__tests__/project-selection-hint.spec.js +73 -0
- package/dist/utils/__tests__/project-selection-hint.spec.js.map +1 -0
- package/dist/utils/__tests__/resolve-project-identifier.spec.js +2 -27
- package/dist/utils/__tests__/resolve-project-identifier.spec.js.map +1 -1
- package/dist/utils/__tests__/select-project.spec.js +23 -22
- package/dist/utils/__tests__/select-project.spec.js.map +1 -1
- package/dist/utils/handle-auth-failure.d.ts +27 -0
- package/dist/utils/handle-auth-failure.d.ts.map +1 -1
- package/dist/utils/handle-auth-failure.js +44 -3
- package/dist/utils/handle-auth-failure.js.map +1 -1
- package/dist/utils/project-selection-hint.d.ts +16 -0
- package/dist/utils/project-selection-hint.d.ts.map +1 -0
- package/dist/utils/project-selection-hint.js +82 -0
- package/dist/utils/project-selection-hint.js.map +1 -0
- package/dist/utils/resolve-project-identifier.d.ts +0 -13
- package/dist/utils/resolve-project-identifier.d.ts.map +1 -1
- package/dist/utils/resolve-project-identifier.js +3 -26
- package/dist/utils/resolve-project-identifier.js.map +1 -1
- package/dist/utils/resolve-test-run-from-commit.d.ts.map +1 -1
- package/dist/utils/resolve-test-run-from-commit.js +4 -3
- package/dist/utils/resolve-test-run-from-commit.js.map +1 -1
- package/dist/utils/select-project.d.ts +20 -4
- package/dist/utils/select-project.d.ts.map +1 -1
- package/dist/utils/select-project.js +39 -13
- package/dist/utils/select-project.js.map +1 -1
- package/package.json +14 -14
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="80bfb6ce-5689-581b-8e23-c500d20fed63")}catch(e){}}();
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.setProjectCommand = void 0;
|
|
6
6
|
const client_1 = require("@alwaysmeticulous/client");
|
|
7
7
|
const common_1 = require("@alwaysmeticulous/common");
|
|
8
|
+
const print_json_1 = require("../../command-utils/print-json");
|
|
8
9
|
const sentry_utils_1 = require("../../command-utils/sentry.utils");
|
|
9
10
|
const cli_user_error_1 = require("../../utils/cli-user-error");
|
|
10
11
|
const select_project_1 = require("../../utils/select-project");
|
|
@@ -18,13 +19,26 @@ exports.setProjectCommand = {
|
|
|
18
19
|
"When provided, skips the interactive picker. Required in non-interactive " +
|
|
19
20
|
"environments (no TTY), where the interactive picker is unavailable.",
|
|
20
21
|
},
|
|
22
|
+
json: {
|
|
23
|
+
boolean: true,
|
|
24
|
+
default: false,
|
|
25
|
+
description: "Output the selected project as JSON ({project, projectId}) on stdout. " +
|
|
26
|
+
"Only stdout is affected — notices still go to stderr.",
|
|
27
|
+
},
|
|
21
28
|
},
|
|
22
|
-
handler: (0, sentry_utils_1.wrapHandler)(async ({ project }) => {
|
|
29
|
+
handler: (0, sentry_utils_1.wrapHandler)(async ({ project, json }) => {
|
|
23
30
|
(0, common_1.initLogger)();
|
|
24
|
-
|
|
31
|
+
// `createClientWithOAuth` already resolves the token (including any
|
|
32
|
+
// interactive login and the legacy `selected-project.json` migration) via
|
|
33
|
+
// `resolveApiTokenWithOAuth` internally — re-run that whole resolution just
|
|
34
|
+
// to check the token kind would repeat the migration and double-print its
|
|
35
|
+
// "no API token found" notice. `getAuthToken` reads back the same (by now
|
|
36
|
+
// already-resolved) state without redoing any of that.
|
|
37
|
+
const client = await (0, client_1.createClientWithOAuth)({
|
|
25
38
|
apiToken: null,
|
|
26
39
|
enableOAuthLogin: true,
|
|
27
40
|
});
|
|
41
|
+
const apiToken = await (0, client_1.getAuthToken)(null);
|
|
28
42
|
// Project-scoped API tokens (env var or legacy config) already pin a
|
|
29
43
|
// project, so `set-project` has nothing to do.
|
|
30
44
|
if (apiToken && !(0, client_1.isOAuthJwt)(apiToken)) {
|
|
@@ -35,16 +49,15 @@ exports.setProjectCommand = {
|
|
|
35
49
|
"logout` and unset `METICULOUS_API_TOKEN`, then re-run this " +
|
|
36
50
|
"command to log in with OAuth.");
|
|
37
51
|
}
|
|
38
|
-
const
|
|
39
|
-
apiToken: null,
|
|
40
|
-
enableOAuthLogin: true,
|
|
41
|
-
});
|
|
42
|
-
await (0, select_project_1.selectAndStoreProject)({
|
|
52
|
+
const selected = await (0, select_project_1.selectAndStoreProject)({
|
|
43
53
|
client,
|
|
44
54
|
project,
|
|
45
55
|
allowInteractivePrompt: (0, client_1.isInteractiveContext)(),
|
|
46
56
|
});
|
|
57
|
+
if (json) {
|
|
58
|
+
(0, print_json_1.printJson)(selected);
|
|
59
|
+
}
|
|
47
60
|
}),
|
|
48
61
|
};
|
|
49
62
|
//# sourceMappingURL=set-project.command.js.map
|
|
50
|
-
//# debugId=
|
|
63
|
+
//# debugId=80bfb6ce-5689-581b-8e23-c500d20fed63
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-project.command.js","sources":["../../../src/commands/auth/set-project.command.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA,qDAKkC;AAClC,qDAAsD;AAEtD,mEAA+D;AAC/D,+DAA0D;AAC1D,+DAAmE;
|
|
1
|
+
{"version":3,"file":"set-project.command.js","sources":["../../../src/commands/auth/set-project.command.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA,qDAKkC;AAClC,qDAAsD;AAEtD,+DAA2D;AAC3D,mEAA+D;AAC/D,+DAA0D;AAC1D,+DAAmE;AAOtD,QAAA,iBAAiB,GAAoC;IAChE,OAAO,EAAE,aAAa;IACtB,QAAQ,EACN,wEAAwE;IAC1E,OAAO,EAAE;QACP,OAAO,EAAE;YACP,MAAM,EAAE,IAAI;YACZ,WAAW,EACT,4EAA4E;gBAC5E,2EAA2E;gBAC3E,qEAAqE;SACxE;QACD,IAAI,EAAE;YACJ,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,KAAK;YACd,WAAW,EACT,wEAAwE;gBACxE,uDAAuD;SAC1D;KACF;IACD,OAAO,EAAE,IAAA,0BAAW,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAW,EAAE,EAAE;QACxD,IAAA,mBAAU,GAAE,CAAC;QAEb,oEAAoE;QACpE,0EAA0E;QAC1E,4EAA4E;QAC5E,0EAA0E;QAC1E,0EAA0E;QAC1E,uDAAuD;QACvD,MAAM,MAAM,GAAG,MAAM,IAAA,8BAAqB,EAAC;YACzC,QAAQ,EAAE,IAAI;YACd,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAY,EAAC,IAAI,CAAC,CAAC;QAE1C,qEAAqE;QACrE,+CAA+C;QAC/C,IAAI,QAAQ,IAAI,CAAC,IAAA,mBAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,6BAAY,CACpB,gEAAgE;gBAC9D,+DAA+D;gBAC/D,UAAU;gBACV,gEAAgE;gBAChE,6DAA6D;gBAC7D,+BAA+B,CAClC,CAAC;QACJ,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAA,sCAAqB,EAAC;YAC3C,MAAM;YACN,OAAO;YACP,sBAAsB,EAAE,IAAA,6BAAoB,GAAE;SAC/C,CAAC,CAAC;QACH,IAAI,IAAI,EAAE,CAAC;YACT,IAAA,sBAAS,EAAC,QAAQ,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;CACH,CAAC","debugId":"80bfb6ce-5689-581b-8e23-c500d20fed63"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.command.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/whoami.command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"whoami.command.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/whoami.command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAS3C,UAAU,OAAO;IACf,IAAI,EAAE,OAAO,CAAC;CACf;AAED,eAAO,MAAM,aAAa,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,CAiFzD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f3f01d5f-e355-5a5b-bca1-711843c24c6d")}catch(e){}}();
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.whoamiCommand = void 0;
|
|
@@ -9,8 +9,6 @@ const print_json_1 = require("../../command-utils/print-json");
|
|
|
9
9
|
const sentry_utils_1 = require("../../command-utils/sentry.utils");
|
|
10
10
|
const cli_user_error_1 = require("../../utils/cli-user-error");
|
|
11
11
|
const handle_auth_failure_1 = require("../../utils/handle-auth-failure");
|
|
12
|
-
const resolve_project_identifier_1 = require("../../utils/resolve-project-identifier");
|
|
13
|
-
const select_project_1 = require("../../utils/select-project");
|
|
14
12
|
exports.whoamiCommand = {
|
|
15
13
|
command: "whoami",
|
|
16
14
|
describe: "Show the currently logged-in user",
|
|
@@ -25,113 +23,122 @@ exports.whoamiCommand = {
|
|
|
25
23
|
},
|
|
26
24
|
handler: (0, sentry_utils_1.wrapHandler)(async ({ json }) => {
|
|
27
25
|
(0, common_1.initLogger)();
|
|
28
|
-
|
|
26
|
+
// `createClientWithOAuth` already resolves the token (including any
|
|
27
|
+
// interactive login and the legacy `selected-project.json` migration) via
|
|
28
|
+
// `resolveApiTokenWithOAuth` internally — re-run that whole resolution just
|
|
29
|
+
// to learn whether a local token exists would repeat the migration and
|
|
30
|
+
// double-print its "no API token found" notice. `getAuthToken` reads back
|
|
31
|
+
// the same (by now already-resolved) state without redoing any of that.
|
|
32
|
+
const client = await (0, client_1.createClientWithOAuth)({
|
|
29
33
|
apiToken: null,
|
|
30
34
|
enableOAuthLogin: true,
|
|
31
35
|
});
|
|
36
|
+
const apiToken = await (0, client_1.getAuthToken)(null);
|
|
32
37
|
// No local token: some environments inject credentials into outbound
|
|
33
|
-
// requests instead
|
|
34
|
-
//
|
|
35
|
-
//
|
|
36
|
-
// failures into `null`) rather than falling through to the OAuth path.
|
|
38
|
+
// requests instead, so the call still doubles as the probe for that — it
|
|
39
|
+
// succeeds when injection is working and 401s when there is simply no
|
|
40
|
+
// credential at all.
|
|
37
41
|
if (!apiToken) {
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
42
|
+
const injected = await (0, client_1.getAgentWhoami)(client).catch(() => null);
|
|
43
|
+
if (!injected) {
|
|
40
44
|
throw new cli_user_error_1.CliUserError("Not logged in. Run `meticulous auth login`, or set " +
|
|
41
45
|
"METICULOUS_API_TOKEN. In terminals without a browser, use " +
|
|
42
46
|
"`meticulous auth login --non-interactive`.");
|
|
43
47
|
}
|
|
48
|
+
const selectedProject = injected.selectedProject;
|
|
44
49
|
if (json) {
|
|
45
50
|
(0, print_json_1.printJson)({
|
|
46
51
|
authenticatedVia: "injected-credentials",
|
|
47
|
-
|
|
52
|
+
selectedProject,
|
|
53
|
+
// Deprecated alias for `selectedProject`, which is the key the OAuth
|
|
54
|
+
// branch below and the MCP `whoami` tool both use for the same thing.
|
|
55
|
+
pinnedProject: selectedProject,
|
|
48
56
|
});
|
|
49
57
|
}
|
|
50
58
|
else {
|
|
51
59
|
console.log("Authenticated via: credentials injected at request time");
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
// A project-scoped API token (env var or legacy config) cannot be used
|
|
57
|
-
// against the OAuth-only `/oauth/whoami` endpoint — it would 403. Report
|
|
58
|
-
// the active credential without a doomed round-trip.
|
|
59
|
-
if (!(0, client_1.isOAuthJwt)(apiToken)) {
|
|
60
|
-
const tokenSource = process.env["METICULOUS_API_TOKEN"]
|
|
61
|
-
? "METICULOUS_API_TOKEN environment variable"
|
|
62
|
-
: "~/.meticulous/config.json";
|
|
63
|
-
const pinnedProject = await (0, resolve_project_identifier_1.resolvePinnedProjectSlug)(apiToken);
|
|
64
|
-
if (json) {
|
|
65
|
-
(0, print_json_1.printJson)({
|
|
66
|
-
authenticatedVia: "project-api-token",
|
|
67
|
-
tokenSource,
|
|
68
|
-
pinnedProject,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
console.log(`Authenticated via: project API token (${tokenSource})`);
|
|
73
|
-
if (pinnedProject) {
|
|
74
|
-
console.log(`Pinned project: ${pinnedProject}`);
|
|
60
|
+
if (selectedProject) {
|
|
61
|
+
console.log(`Pinned project: ${selectedProject}`);
|
|
75
62
|
}
|
|
76
63
|
}
|
|
77
|
-
// Always-on guidance (stderr) — --json only changes stdout, so the hint
|
|
78
|
-
// still surfaces.
|
|
79
|
-
(0, common_1.logNotice)("This token is scoped to a single project. To sign in as a user, " +
|
|
80
|
-
"run `meticulous auth logout`, unset METICULOUS_API_TOKEN, then " +
|
|
81
|
-
"`meticulous auth login`.");
|
|
82
64
|
return;
|
|
83
65
|
}
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
66
|
+
const whoami = await (0, client_1.getAgentWhoami)(client).catch((error) => {
|
|
67
|
+
(0, handle_auth_failure_1.handleAuthFailure)(error);
|
|
68
|
+
throw (0, handle_auth_failure_1.toServerMessageError)(error);
|
|
87
69
|
});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
? (0, select_project_1.formatProjectSlug)(defaultProject)
|
|
93
|
-
: null;
|
|
94
|
-
if (json) {
|
|
95
|
-
(0, print_json_1.printJson)({
|
|
96
|
-
authenticatedVia: "oauth",
|
|
97
|
-
email,
|
|
98
|
-
firstName,
|
|
99
|
-
lastName,
|
|
100
|
-
isAdmin,
|
|
101
|
-
organizations: organizations.map((org) => ({
|
|
102
|
-
name: org.name,
|
|
103
|
-
role: org.role ?? null,
|
|
104
|
-
})),
|
|
105
|
-
selectedProject: selectedProject ?? null,
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
console.log("Authenticated via: OAuth");
|
|
110
|
-
console.log(`Logged in as: ${firstName} ${lastName} (${email})`);
|
|
111
|
-
if (isAdmin) {
|
|
112
|
-
console.log("Role: Admin");
|
|
113
|
-
}
|
|
114
|
-
if (organizations.length > 0) {
|
|
115
|
-
const formatted = organizations
|
|
116
|
-
.map((org) => (org.role ? `${org.name} (${org.role})` : org.name))
|
|
117
|
-
.join(", ");
|
|
118
|
-
console.log(`Organizations: ${formatted}`);
|
|
119
|
-
}
|
|
120
|
-
if (selectedProject) {
|
|
121
|
-
console.log(`Selected project: ${selectedProject}`);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// Always-on guidance (stderr) — --json only changes stdout, so the hint
|
|
125
|
-
// still surfaces.
|
|
126
|
-
if (!selectedProject) {
|
|
127
|
-
(0, common_1.logNotice)("No default project set. Run `meticulous auth set-project` to choose one.");
|
|
128
|
-
}
|
|
70
|
+
if (whoami.authenticatedVia === "project-api-token" ||
|
|
71
|
+
whoami.authenticatedVia === "test-run-token") {
|
|
72
|
+
printPinnedTokenWhoami(whoami, json);
|
|
73
|
+
return;
|
|
129
74
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
75
|
+
printOAuthWhoami(whoami, json);
|
|
76
|
+
// Always-on guidance (stderr) — --json only changes stdout, so the hint
|
|
77
|
+
// still surfaces.
|
|
78
|
+
if (!whoami.selectedProject) {
|
|
79
|
+
(0, common_1.logNotice)("No default project set. Run `meticulous auth set-project` to choose one.");
|
|
133
80
|
}
|
|
134
81
|
}),
|
|
135
82
|
};
|
|
83
|
+
const printPinnedTokenWhoami = (whoami, json) => {
|
|
84
|
+
// Which local file or env var supplied the token is knowable only here — the
|
|
85
|
+
// backend sees a bearer, not where it came from.
|
|
86
|
+
const tokenSource = process.env["METICULOUS_API_TOKEN"]
|
|
87
|
+
? "METICULOUS_API_TOKEN environment variable"
|
|
88
|
+
: "~/.meticulous/config.json";
|
|
89
|
+
const label = whoami.authenticatedVia === "test-run-token"
|
|
90
|
+
? "test-run API token"
|
|
91
|
+
: "project API token";
|
|
92
|
+
if (json) {
|
|
93
|
+
(0, print_json_1.printJson)({
|
|
94
|
+
authenticatedVia: whoami.authenticatedVia,
|
|
95
|
+
tokenSource,
|
|
96
|
+
selectedProject: whoami.selectedProject,
|
|
97
|
+
// Deprecated alias for `selectedProject` — see the injected-credentials
|
|
98
|
+
// branch above.
|
|
99
|
+
pinnedProject: whoami.selectedProject,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
console.log(`Authenticated via: ${label} (${tokenSource})`);
|
|
104
|
+
if (whoami.selectedProject) {
|
|
105
|
+
console.log(`Pinned project: ${whoami.selectedProject}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Always-on guidance (stderr) — --json only changes stdout, so the hint
|
|
109
|
+
// still surfaces.
|
|
110
|
+
(0, common_1.logNotice)("This token is scoped to a single project. To sign in as a user, " +
|
|
111
|
+
"run `meticulous auth logout`, unset METICULOUS_API_TOKEN, then " +
|
|
112
|
+
"`meticulous auth login`.");
|
|
113
|
+
};
|
|
114
|
+
const printOAuthWhoami = (whoami, json) => {
|
|
115
|
+
const organizations = whoami.organizations ?? [];
|
|
116
|
+
if (json) {
|
|
117
|
+
(0, print_json_1.printJson)({
|
|
118
|
+
authenticatedVia: "oauth",
|
|
119
|
+
email: whoami.email,
|
|
120
|
+
firstName: whoami.firstName,
|
|
121
|
+
lastName: whoami.lastName,
|
|
122
|
+
isAdmin: whoami.isAdmin,
|
|
123
|
+
organizations,
|
|
124
|
+
selectedProject: whoami.selectedProject,
|
|
125
|
+
});
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
console.log("Authenticated via: OAuth");
|
|
129
|
+
console.log(`Logged in as: ${whoami.firstName} ${whoami.lastName} (${whoami.email})`);
|
|
130
|
+
if (whoami.isAdmin) {
|
|
131
|
+
console.log("Role: Admin");
|
|
132
|
+
}
|
|
133
|
+
if (organizations.length > 0) {
|
|
134
|
+
const formatted = organizations
|
|
135
|
+
.map((org) => (org.role ? `${org.name} (${org.role})` : org.name))
|
|
136
|
+
.join(", ");
|
|
137
|
+
console.log(`Organizations: ${formatted}`);
|
|
138
|
+
}
|
|
139
|
+
if (whoami.selectedProject) {
|
|
140
|
+
console.log(`Selected project: ${whoami.selectedProject}`);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
136
143
|
//# sourceMappingURL=whoami.command.js.map
|
|
137
|
-
//# debugId=
|
|
144
|
+
//# debugId=f3f01d5f-e355-5a5b-bca1-711843c24c6d
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.command.js","sources":["../../../src/commands/auth/whoami.command.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"whoami.command.js","sources":["../../../src/commands/auth/whoami.command.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA,qDAIkC;AAElC,qDAAiE;AAEjE,+DAA2D;AAC3D,mEAA+D;AAC/D,+DAA0D;AAC1D,yEAGyC;AAM5B,QAAA,aAAa,GAAoC;IAC5D,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,mCAAmC;IAC7C,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,KAAK;YACd,WAAW,EACT,oEAAoE;gBACpE,gEAAgE;gBAChE,0DAA0D;SAC7D;KACF;IACD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AAI,CAAC,IAAI,CAAC,CAAC;QACd,OAAO,CAAC,GAAG,CAAC,kBAAkB,SAAS,EAAE,CAAC,CAAC;IAC7C,CAAC;IACD,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;QAC3B,OAAO,CAAC,GAAG,CAAC,qBAAqB,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC;IAC7D,CAAC;AACH,CAAC,CAAC","debugId":"f3f01d5f-e355-5a5b-bca1-711843c24c6d"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-selection-hint.spec.d.ts","sourceRoot":"","sources":["../../../src/utils/__tests__/project-selection-hint.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="281520e8-cd14-5df1-ac1e-fcd5077dbb3c")}catch(e){}}();
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
const vitest_1 = require("vitest");
|
|
6
|
+
const project_selection_hint_1 = require("../project-selection-hint");
|
|
7
|
+
const mocks = vitest_1.vi.hoisted(() => ({
|
|
8
|
+
getAgentCurrentProject: vitest_1.vi.fn(),
|
|
9
|
+
}));
|
|
10
|
+
vitest_1.vi.mock("@alwaysmeticulous/client", () => ({
|
|
11
|
+
getAgentCurrentProject: mocks.getAgentCurrentProject,
|
|
12
|
+
}));
|
|
13
|
+
const client = {};
|
|
14
|
+
(0, vitest_1.describe)("appendProjectSelectionHint", () => {
|
|
15
|
+
(0, vitest_1.beforeEach)(() => {
|
|
16
|
+
vitest_1.vi.clearAllMocks();
|
|
17
|
+
});
|
|
18
|
+
(0, vitest_1.it)("names an OAuth caller's stored default project and how to change it", async () => {
|
|
19
|
+
mocks.getAgentCurrentProject.mockResolvedValue({
|
|
20
|
+
project: "meticulous/Twenty Demo",
|
|
21
|
+
projectId: "id-1",
|
|
22
|
+
source: "user-default",
|
|
23
|
+
});
|
|
24
|
+
const message = await (0, project_selection_hint_1.appendProjectSelectionHint)("No test run found for commit abc123.", client, undefined);
|
|
25
|
+
(0, vitest_1.expect)(message).toContain("No test run found for commit abc123.");
|
|
26
|
+
(0, vitest_1.expect)(message).toContain("meticulous/Twenty Demo");
|
|
27
|
+
(0, vitest_1.expect)(message).toContain("auth set-project");
|
|
28
|
+
});
|
|
29
|
+
(0, vitest_1.it)("names an auto-picked project distinctly from a stored default", async () => {
|
|
30
|
+
mocks.getAgentCurrentProject.mockResolvedValue({
|
|
31
|
+
project: "meticulous/Only Project",
|
|
32
|
+
projectId: "id-2",
|
|
33
|
+
source: "auto-picked",
|
|
34
|
+
});
|
|
35
|
+
const message = await (0, project_selection_hint_1.appendProjectSelectionHint)("Nothing found.", client, undefined);
|
|
36
|
+
(0, vitest_1.expect)(message).toContain("meticulous/Only Project");
|
|
37
|
+
(0, vitest_1.expect)(message).toContain("automatically selected");
|
|
38
|
+
(0, vitest_1.expect)(message).toContain("auth set-project");
|
|
39
|
+
});
|
|
40
|
+
(0, vitest_1.it)("names the token's pinned project without suggesting set-project as a certainty", async () => {
|
|
41
|
+
mocks.getAgentCurrentProject.mockResolvedValue({
|
|
42
|
+
project: "Acme/Pinned",
|
|
43
|
+
projectId: "id-3",
|
|
44
|
+
source: "api-token",
|
|
45
|
+
});
|
|
46
|
+
const message = await (0, project_selection_hint_1.appendProjectSelectionHint)("No recorded sessions found for this project.", client, undefined);
|
|
47
|
+
(0, vitest_1.expect)(message).toContain("Acme/Pinned");
|
|
48
|
+
(0, vitest_1.expect)(message).toContain("does not apply to any API token");
|
|
49
|
+
(0, vitest_1.expect)(message).toContain("cross-project access");
|
|
50
|
+
});
|
|
51
|
+
(0, vitest_1.it)("leaves the message untouched when --project was passed", async () => {
|
|
52
|
+
(0, vitest_1.expect)(await (0, project_selection_hint_1.appendProjectSelectionHint)("Nothing found.", client, "org/proj")).toBe("Nothing found.");
|
|
53
|
+
(0, vitest_1.expect)(mocks.getAgentCurrentProject).not.toHaveBeenCalled();
|
|
54
|
+
});
|
|
55
|
+
(0, vitest_1.it)("treats an empty or whitespace-only --project as absent, not explicit", async () => {
|
|
56
|
+
mocks.getAgentCurrentProject.mockResolvedValue({
|
|
57
|
+
project: "meticulous/Twenty Demo",
|
|
58
|
+
projectId: "id-1",
|
|
59
|
+
source: "user-default",
|
|
60
|
+
});
|
|
61
|
+
const message = await (0, project_selection_hint_1.appendProjectSelectionHint)("Nothing found.", client, " ");
|
|
62
|
+
(0, vitest_1.expect)(message).toContain("meticulous/Twenty Demo");
|
|
63
|
+
(0, vitest_1.expect)(mocks.getAgentCurrentProject).toHaveBeenCalled();
|
|
64
|
+
});
|
|
65
|
+
(0, vitest_1.it)("still names the commands when the project can't be resolved", async () => {
|
|
66
|
+
mocks.getAgentCurrentProject.mockRejectedValue(new Error("offline"));
|
|
67
|
+
const message = await (0, project_selection_hint_1.appendProjectSelectionHint)("Nothing found.", client, undefined);
|
|
68
|
+
(0, vitest_1.expect)(message).toContain("auth get-project");
|
|
69
|
+
(0, vitest_1.expect)(message).toContain("auth set-project");
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
//# sourceMappingURL=project-selection-hint.spec.js.map
|
|
73
|
+
//# debugId=281520e8-cd14-5df1-ac1e-fcd5077dbb3c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-selection-hint.spec.js","sources":["../../../src/utils/__tests__/project-selection-hint.spec.ts"],"sourceRoot":"","names":[],"mappings":";;;;AACA,mCAA8D;AAC9D,sEAAuE;AAEvE,MAAM,KAAK,GAAG,WAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC9B,sBAAsB,EAAE,WAAE,CAAC,EAAE,EAAE;CAChC,CAAC,CAAC,CAAC;AAEJ,WA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IAAA,mDAA0B,EAC9C,gBAAgB,EAChB,MAAM,EACN,KAAK,CACN,CAAC;QAEF,IAAA,eAAM,EAAC,OAAO,CAAC,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;QACpD,IAAA,eAAM,EAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,KAAK,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QAErE,MAAM,OAAO,GAAG,MAAM,IAAA,mDAA0B,EAC9C,gBAAgB,EAChB,MAAM,EACN,SAAS,CACV,CAAC;QAEF,IAAA,eAAM,EAAC,OAAO,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;QAC9C,IAAA,eAAM,EAAC,OAAO,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","debugId":"281520e8-cd14-5df1-ac1e-fcd5077dbb3c"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bed63ce2-ba7c-583a-ab71-66ca70f784a3")}catch(e){}}();
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
const vitest_1 = require("vitest");
|
|
@@ -8,14 +8,10 @@ const resolve_project_identifier_1 = require("../resolve-project-identifier");
|
|
|
8
8
|
const mocks = vitest_1.vi.hoisted(() => ({
|
|
9
9
|
resolveDefaultProjectId: vitest_1.vi.fn(),
|
|
10
10
|
isOAuthJwt: vitest_1.vi.fn(),
|
|
11
|
-
createClient: vitest_1.vi.fn(),
|
|
12
|
-
getProject: vitest_1.vi.fn(),
|
|
13
11
|
}));
|
|
14
12
|
vitest_1.vi.mock("@alwaysmeticulous/client", () => ({
|
|
15
13
|
resolveDefaultProjectId: mocks.resolveDefaultProjectId,
|
|
16
14
|
isOAuthJwt: mocks.isOAuthJwt,
|
|
17
|
-
createClient: mocks.createClient,
|
|
18
|
-
getProject: mocks.getProject,
|
|
19
15
|
}));
|
|
20
16
|
vitest_1.vi.mock("@alwaysmeticulous/common", () => ({
|
|
21
17
|
initLogger: vitest_1.vi.fn(),
|
|
@@ -45,26 +41,5 @@ vitest_1.vi.mock("@alwaysmeticulous/common", () => ({
|
|
|
45
41
|
(0, vitest_1.expect)(caught.exitCode).toBe(1);
|
|
46
42
|
});
|
|
47
43
|
});
|
|
48
|
-
(0, vitest_1.describe)("resolvePinnedProjectSlug", () => {
|
|
49
|
-
(0, vitest_1.beforeEach)(() => {
|
|
50
|
-
vitest_1.vi.clearAllMocks();
|
|
51
|
-
mocks.createClient.mockReturnValue({});
|
|
52
|
-
});
|
|
53
|
-
(0, vitest_1.it)("returns the organization/name slug for the token's bound project", async () => {
|
|
54
|
-
mocks.getProject.mockResolvedValue({
|
|
55
|
-
name: "My App",
|
|
56
|
-
organization: { name: "Acme" },
|
|
57
|
-
});
|
|
58
|
-
(0, vitest_1.expect)(await (0, resolve_project_identifier_1.resolvePinnedProjectSlug)("prat-abc")).toBe("Acme/My App");
|
|
59
|
-
});
|
|
60
|
-
(0, vitest_1.it)("returns null when the project can't be resolved", async () => {
|
|
61
|
-
mocks.getProject.mockResolvedValue(null);
|
|
62
|
-
(0, vitest_1.expect)(await (0, resolve_project_identifier_1.resolvePinnedProjectSlug)("prat-abc")).toBeNull();
|
|
63
|
-
});
|
|
64
|
-
(0, vitest_1.it)("swallows errors and returns null", async () => {
|
|
65
|
-
mocks.getProject.mockRejectedValue(new Error("network error"));
|
|
66
|
-
(0, vitest_1.expect)(await (0, resolve_project_identifier_1.resolvePinnedProjectSlug)("prat-abc")).toBeNull();
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
44
|
//# sourceMappingURL=resolve-project-identifier.spec.js.map
|
|
70
|
-
//# debugId=
|
|
45
|
+
//# debugId=bed63ce2-ba7c-583a-ab71-66ca70f784a3
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-project-identifier.spec.js","sources":["../../../src/utils/__tests__/resolve-project-identifier.spec.ts"],"sourceRoot":"","names":[],"mappings":";;;;AAAA,mCAA8D;AAC9D,sDAAiD;AACjD,
|
|
1
|
+
{"version":3,"file":"resolve-project-identifier.spec.js","sources":["../../../src/utils/__tests__/resolve-project-identifier.spec.ts"],"sourceRoot":"","names":[],"mappings":";;;;AAAA,mCAA8D;AAC9D,sDAAiD;AACjD,8EAAyE;AAEzE,MAAM,KAAK,GAAG,WAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC9B,uBAAuB,EAAE,WAAE,CAAC,EAAE,EAAE;IAChC,UAAU,EAAE,WAAE,CAAC,EAAE,EAAE;CACpB,CAAC,CAAC,CAAC;AAEJ,WAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,CAAC,CAAC;IACzC,uBAAuB,EAAE,KAAK,CAAC,uBAAuB;IACtD,UAAU,EAAE,KAAK,CAAC,UAAU;CAC7B,CAAC,CAAC,CAAC;AAEJ,WAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,CAAC,CAAC;IACzC,UAAU,EAAE,WAAE,CAAC,EAAE,EAAE;CACpB,CAAC,CAAC,CAAC;AAEJ,IAAA,iBAAQ,EAAC,0BAA0B,EAAE,G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,kBAAkB,CAAC,CAAC;QACvE,IAAA,eAAM,EAAE,MAAuB,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","debugId":"bed63ce2-ba7c-583a-ab71-66ca70f784a3"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="42cf5a0a-a974-5f19-a984-dbab1288a84c")}catch(e){}}();
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
const vitest_1 = require("vitest");
|
|
@@ -7,23 +7,24 @@ const cli_user_error_1 = require("../cli-user-error");
|
|
|
7
7
|
const select_project_1 = require("../select-project");
|
|
8
8
|
const mocks = vitest_1.vi.hoisted(() => ({
|
|
9
9
|
getOAuthProjects: vitest_1.vi.fn(),
|
|
10
|
-
|
|
10
|
+
setAgentCurrentProject: vitest_1.vi.fn(),
|
|
11
|
+
getAgentProjects: vitest_1.vi.fn(),
|
|
11
12
|
getOAuthDefaultProject: vitest_1.vi.fn(),
|
|
12
13
|
isFetchError: vitest_1.vi.fn(() => false),
|
|
13
14
|
prompt: vitest_1.vi.fn(),
|
|
14
15
|
}));
|
|
15
16
|
vitest_1.vi.mock("@alwaysmeticulous/client", () => ({
|
|
16
17
|
getOAuthProjects: mocks.getOAuthProjects,
|
|
17
|
-
|
|
18
|
+
setAgentCurrentProject: mocks.setAgentCurrentProject,
|
|
19
|
+
getAgentProjects: mocks.getAgentProjects,
|
|
18
20
|
getOAuthDefaultProject: mocks.getOAuthDefaultProject,
|
|
19
21
|
isFetchError: mocks.isFetchError,
|
|
20
22
|
}));
|
|
21
23
|
// The backend resolves the identifier and returns the resolved project; model
|
|
22
24
|
// that here.
|
|
23
25
|
const resolved = (org, name, id) => ({
|
|
26
|
+
project: `${org}/${name}`,
|
|
24
27
|
projectId: id,
|
|
25
|
-
name,
|
|
26
|
-
organization: { id: `${org}-id`, name: org },
|
|
27
28
|
});
|
|
28
29
|
vitest_1.vi.mock("@alwaysmeticulous/common", () => ({
|
|
29
30
|
logNotice: vitest_1.vi.fn(),
|
|
@@ -42,27 +43,27 @@ const fakeClient = {};
|
|
|
42
43
|
(0, vitest_1.it)("sends an explicit identifier to the backend verbatim (not matched client-side)", async () => {
|
|
43
44
|
// A bare name, id, or slug all go straight to the backend, which resolves
|
|
44
45
|
// flexibly and returns the resolved project.
|
|
45
|
-
mocks.
|
|
46
|
+
mocks.setAgentCurrentProject.mockResolvedValue(resolved("OrgB", "App2", "id-2"));
|
|
46
47
|
const result = await (0, select_project_1.selectAndStoreProject)({
|
|
47
48
|
client: fakeClient,
|
|
48
49
|
project: "App2",
|
|
49
50
|
});
|
|
50
|
-
(0, vitest_1.expect)(result).
|
|
51
|
-
(0, vitest_1.expect)(mocks.
|
|
51
|
+
(0, vitest_1.expect)(result).toEqual({ project: "OrgB/App2", projectId: "id-2" });
|
|
52
|
+
(0, vitest_1.expect)(mocks.setAgentCurrentProject).toHaveBeenCalledWith(fakeClient, "App2");
|
|
52
53
|
// No client-side project listing for an explicit identifier.
|
|
53
54
|
(0, vitest_1.expect)(mocks.getOAuthProjects).not.toHaveBeenCalled();
|
|
54
55
|
});
|
|
55
56
|
(0, vitest_1.it)("trims surrounding whitespace from the provided identifier", async () => {
|
|
56
|
-
mocks.
|
|
57
|
+
mocks.setAgentCurrentProject.mockResolvedValue(resolved("OrgA", "App1", "id-1"));
|
|
57
58
|
const result = await (0, select_project_1.selectAndStoreProject)({
|
|
58
59
|
client: fakeClient,
|
|
59
60
|
project: " OrgA/App1 ",
|
|
60
61
|
});
|
|
61
|
-
(0, vitest_1.expect)(result).
|
|
62
|
-
(0, vitest_1.expect)(mocks.
|
|
62
|
+
(0, vitest_1.expect)(result).toEqual({ project: "OrgA/App1", projectId: "id-1" });
|
|
63
|
+
(0, vitest_1.expect)(mocks.setAgentCurrentProject).toHaveBeenCalledWith(fakeClient, "OrgA/App1");
|
|
63
64
|
});
|
|
64
65
|
(0, vitest_1.it)("throws with the available list when the backend can't resolve the identifier", async () => {
|
|
65
|
-
mocks.
|
|
66
|
+
mocks.setAgentCurrentProject.mockRejectedValueOnce(new Error("not found"));
|
|
66
67
|
mocks.getOAuthProjects.mockResolvedValue([project("OrgA", "App1", "id-1")]);
|
|
67
68
|
await (0, vitest_1.expect)((0, select_project_1.selectAndStoreProject)({
|
|
68
69
|
client: fakeClient,
|
|
@@ -74,8 +75,8 @@ const fakeClient = {};
|
|
|
74
75
|
const result = await (0, select_project_1.selectAndStoreProject)({
|
|
75
76
|
client: fakeClient,
|
|
76
77
|
});
|
|
77
|
-
(0, vitest_1.expect)(result).
|
|
78
|
-
(0, vitest_1.expect)(mocks.
|
|
78
|
+
(0, vitest_1.expect)(result).toEqual({ project: "OrgA/App1", projectId: "id-1" });
|
|
79
|
+
(0, vitest_1.expect)(mocks.setAgentCurrentProject).toHaveBeenCalledWith(fakeClient, "id-1");
|
|
79
80
|
});
|
|
80
81
|
(0, vitest_1.it)("throws when no projects are accessible", async () => {
|
|
81
82
|
mocks.getOAuthProjects.mockResolvedValue([]);
|
|
@@ -93,7 +94,7 @@ const fakeClient = {};
|
|
|
93
94
|
(0, vitest_1.expect)(caught).toBeInstanceOf(cli_user_error_1.CliUserError);
|
|
94
95
|
(0, vitest_1.expect)(caught.severity).toBe("warn");
|
|
95
96
|
(0, vitest_1.expect)(caught.exitCode).toBe(1);
|
|
96
|
-
(0, vitest_1.expect)(mocks.
|
|
97
|
+
(0, vitest_1.expect)(mocks.setAgentCurrentProject).not.toHaveBeenCalled();
|
|
97
98
|
});
|
|
98
99
|
});
|
|
99
100
|
(0, vitest_1.describe)("selectProjectOnLogin", () => {
|
|
@@ -101,18 +102,18 @@ const fakeClient = {};
|
|
|
101
102
|
vitest_1.vi.clearAllMocks();
|
|
102
103
|
});
|
|
103
104
|
(0, vitest_1.it)("persists an explicit --project (resolved by the backend)", async () => {
|
|
104
|
-
mocks.
|
|
105
|
+
mocks.setAgentCurrentProject.mockResolvedValue(resolved("OrgB", "App2", "id-2"));
|
|
105
106
|
await (0, select_project_1.selectProjectOnLogin)({
|
|
106
107
|
client: fakeClient,
|
|
107
108
|
project: "OrgB/App2",
|
|
108
109
|
interactive: true,
|
|
109
110
|
});
|
|
110
|
-
(0, vitest_1.expect)(mocks.
|
|
111
|
+
(0, vitest_1.expect)(mocks.setAgentCurrentProject).toHaveBeenCalledWith(fakeClient, "OrgB/App2");
|
|
111
112
|
});
|
|
112
113
|
(0, vitest_1.it)("auto-selects and persists the sole project (no stored-default lookup needed)", async () => {
|
|
113
114
|
mocks.getOAuthProjects.mockResolvedValue([project("OrgA", "App1", "id-1")]);
|
|
114
115
|
await (0, select_project_1.selectProjectOnLogin)({ client: fakeClient, interactive: true });
|
|
115
|
-
(0, vitest_1.expect)(mocks.
|
|
116
|
+
(0, vitest_1.expect)(mocks.setAgentCurrentProject).toHaveBeenCalledWith(fakeClient, "id-1");
|
|
116
117
|
// Only >1-project accounts consult the stored default (to respect it);
|
|
117
118
|
// a sole project is selected directly.
|
|
118
119
|
(0, vitest_1.expect)(mocks.getOAuthDefaultProject).not.toHaveBeenCalled();
|
|
@@ -128,7 +129,7 @@ const fakeClient = {};
|
|
|
128
129
|
organization: { id: "OrgB-id", name: "OrgB" },
|
|
129
130
|
});
|
|
130
131
|
await (0, select_project_1.selectProjectOnLogin)({ client: fakeClient, interactive: false });
|
|
131
|
-
(0, vitest_1.expect)(mocks.
|
|
132
|
+
(0, vitest_1.expect)(mocks.setAgentCurrentProject).not.toHaveBeenCalled();
|
|
132
133
|
});
|
|
133
134
|
(0, vitest_1.it)("succeeds non-interactively when a default already exists, even with multiple projects", async () => {
|
|
134
135
|
mocks.getOAuthProjects.mockResolvedValue([
|
|
@@ -153,7 +154,7 @@ const fakeClient = {};
|
|
|
153
154
|
interactive: false,
|
|
154
155
|
}).catch((error) => error);
|
|
155
156
|
(0, vitest_1.expect)(caught).toBeInstanceOf(cli_user_error_1.CliUserError);
|
|
156
|
-
(0, vitest_1.expect)(mocks.
|
|
157
|
+
(0, vitest_1.expect)(mocks.setAgentCurrentProject).not.toHaveBeenCalled();
|
|
157
158
|
});
|
|
158
159
|
(0, vitest_1.it)("prompts and persists when interactive with several projects and no default", async () => {
|
|
159
160
|
mocks.getOAuthProjects.mockResolvedValue([
|
|
@@ -163,7 +164,7 @@ const fakeClient = {};
|
|
|
163
164
|
mocks.getOAuthDefaultProject.mockResolvedValue({ projectId: null });
|
|
164
165
|
mocks.prompt.mockResolvedValue({ projectId: "id-2" });
|
|
165
166
|
await (0, select_project_1.selectProjectOnLogin)({ client: fakeClient, interactive: true });
|
|
166
|
-
(0, vitest_1.expect)(mocks.
|
|
167
|
+
(0, vitest_1.expect)(mocks.setAgentCurrentProject).toHaveBeenCalledWith(fakeClient, "id-2");
|
|
167
168
|
});
|
|
168
169
|
});
|
|
169
170
|
(0, vitest_1.describe)("formatProjectSlug", () => {
|
|
@@ -211,4 +212,4 @@ const fakeClient = {};
|
|
|
211
212
|
});
|
|
212
213
|
});
|
|
213
214
|
//# sourceMappingURL=select-project.spec.js.map
|
|
214
|
-
//# debugId=
|
|
215
|
+
//# debugId=42cf5a0a-a974-5f19-a984-dbab1288a84c
|