@alwaysmeticulous/cli 2.323.0 → 2.325.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 +107 -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 +57 -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.handler.spec.js +45 -5
- package/dist/commands/agent/js-coverage.command.handler.spec.js.map +1 -1
- package/dist/commands/agent/js-coverage.command.js +21 -6
- 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 +57 -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 +5 -0
- package/dist/utils/resolve-test-run-from-commit.d.ts.map +1 -1
- package/dist/utils/resolve-test-run-from-commit.js +9 -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,49 +1,50 @@
|
|
|
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]="8f3f1b14-f959-504b-939e-a5b88b923978")}catch(e){}}();
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.getProjectCommand = 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
|
-
const
|
|
10
|
-
const resolve_project_identifier_1 = require("../../utils/resolve-project-identifier");
|
|
11
|
-
const select_project_1 = require("../../utils/select-project");
|
|
10
|
+
const handle_auth_failure_1 = require("../../utils/handle-auth-failure");
|
|
12
11
|
/**
|
|
13
12
|
* Prints the project that project-scoped CLI commands would currently use —
|
|
14
13
|
* the token's own pinned project for a project/test-run API token, or the
|
|
15
14
|
* OAuth caller's default project (`auth set-project`) otherwise. Scriptable:
|
|
16
15
|
* only the resolved `organization/name` slug goes to stdout; exits non-zero
|
|
17
|
-
* with guidance on stderr if nothing is resolved.
|
|
16
|
+
* with the backend's guidance on stderr if nothing is resolved.
|
|
18
17
|
*/
|
|
19
18
|
exports.getProjectCommand = {
|
|
20
19
|
command: "get-project",
|
|
21
20
|
describe: "Print the project that project-scoped commands would currently use",
|
|
22
|
-
builder: {
|
|
23
|
-
|
|
21
|
+
builder: {
|
|
22
|
+
json: {
|
|
23
|
+
boolean: true,
|
|
24
|
+
default: false,
|
|
25
|
+
description: "Output the result as JSON ({project, projectId, source}, where source " +
|
|
26
|
+
"is 'user-default' or 'api-token') instead of the bare " +
|
|
27
|
+
"'organization/project' slug. Only stdout is affected — notices still " +
|
|
28
|
+
"go to stderr.",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
handler: (0, sentry_utils_1.wrapHandler)(async ({ json }) => {
|
|
24
32
|
(0, common_1.initLogger)();
|
|
25
|
-
const apiToken = await (0, client_1.resolveApiTokenWithOAuth)({
|
|
26
|
-
apiToken: null,
|
|
27
|
-
enableOAuthLogin: true,
|
|
28
|
-
});
|
|
29
|
-
if (apiToken && !(0, client_1.isOAuthJwt)(apiToken)) {
|
|
30
|
-
const pinned = await (0, resolve_project_identifier_1.resolvePinnedProjectSlug)(apiToken);
|
|
31
|
-
if (!pinned) {
|
|
32
|
-
throw new cli_user_error_1.CliUserError("Could not resolve the project this API token is bound to.");
|
|
33
|
-
}
|
|
34
|
-
console.log(pinned);
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
33
|
const client = await (0, client_1.createClientWithOAuth)({
|
|
38
34
|
apiToken: null,
|
|
39
35
|
enableOAuthLogin: true,
|
|
40
36
|
});
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
throw
|
|
37
|
+
const current = await (0, client_1.getAgentCurrentProject)(client).catch((error) => {
|
|
38
|
+
(0, handle_auth_failure_1.handleAuthFailure)(error);
|
|
39
|
+
throw (0, handle_auth_failure_1.toServerMessageError)(error);
|
|
40
|
+
});
|
|
41
|
+
if (json) {
|
|
42
|
+
(0, print_json_1.printJson)(current);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
console.log(current.project);
|
|
44
46
|
}
|
|
45
|
-
console.log((0, select_project_1.formatProjectSlug)(defaultProject));
|
|
46
47
|
}),
|
|
47
48
|
};
|
|
48
49
|
//# sourceMappingURL=get-project.command.js.map
|
|
49
|
-
//# debugId=
|
|
50
|
+
//# debugId=8f3f1b14-f959-504b-939e-a5b88b923978
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-project.command.js","sources":["../../../src/commands/auth/get-project.command.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"get-project.command.js","sources":["../../../src/commands/auth/get-project.command.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA,qDAGkC;AAClC,qDAAsD;AAEtD,+DAA2D;AAC3D,mEAA+D;AAC/D,yEAGyC;AAMzC;;;;;;GAMG;AACU,QAAA,iBAAiB,GAAoC;IAChE,OAAO,EAAE,aAAa;IACtB,QAAQ,EACN,oEAAoE;IACtE,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,KAAK;YACd,WAAW,EACT,wEAAwE;gBACxE,wDAAwD;gBACxD,uEAAuE;gBACvE,eAAe;SAClB;KACF;IACD,OAAO,EAAE,IAAA,0BAAW,EAAC,KAAK,EAAE,EAAE,IAAI,EAAW,EAAE,EAAE;QAC/C,IAAA,mBAAU,GAAE,CAAC;QAEb,MAAM,MAAM,GAAG,MAAM,IAAA,8BAAqB,EAAC;YACzC,QAAQ,EAAE,IAAI;YACd,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,IAAA,+BAAsB,EAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACnE,IAAA,uCAAiB,EAAC,KAAK,CAAC,CAAC;YACzB,MAAM,IAAA,0CAAoB,EAAC,KAAK,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,IAAI,IAAI,EAAE,CAAC;YACT,IAAA,sBAAS,EAAC,OAAO,CAAC,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC,CAAC;CACH,CAAC","debugId":"8f3f1b14-f959-504b-939e-a5b88b923978"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-projects.command.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/list-projects.command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAM3C,UAAU,OAAO;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"list-projects.command.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/list-projects.command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAM3C,UAAU,OAAO;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,CAuC/D,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]="abc4eb30-d968-5734-b82a-18a5e28cd6eb")}catch(e){}}();
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.listProjectsCommand = void 0;
|
|
@@ -30,13 +30,9 @@ exports.listProjectsCommand = {
|
|
|
30
30
|
// there isn't a stored one yet (interactive only; CI can't show a browser).
|
|
31
31
|
const apiToken = await resolveOAuthToken();
|
|
32
32
|
const client = (0, client_1.createClient)({ apiToken });
|
|
33
|
-
const projects = await (0, select_project_1.
|
|
33
|
+
const projects = await (0, select_project_1.listProjectsForUser)(client);
|
|
34
34
|
if (json) {
|
|
35
|
-
(0, print_json_1.printJson)(projects
|
|
36
|
-
id: p.id,
|
|
37
|
-
name: p.name,
|
|
38
|
-
organization: { name: p.organization.name },
|
|
39
|
-
})));
|
|
35
|
+
(0, print_json_1.printJson)(projects);
|
|
40
36
|
}
|
|
41
37
|
else {
|
|
42
38
|
for (const p of projects) {
|
|
@@ -66,4 +62,4 @@ const resolveOAuthToken = async () => {
|
|
|
66
62
|
return tokens.accessToken;
|
|
67
63
|
};
|
|
68
64
|
//# sourceMappingURL=list-projects.command.js.map
|
|
69
|
-
//# debugId=
|
|
65
|
+
//# debugId=abc4eb30-d968-5734-b82a-18a5e28cd6eb
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-projects.command.js","sources":["../../../src/commands/auth/list-projects.command.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA,qDAKkC;AAClC,qDAAiE;AAEjE,+DAA2D;AAC3D,mEAA+D;AAC/D,+DAA0D;AAC1D,+
|
|
1
|
+
{"version":3,"file":"list-projects.command.js","sources":["../../../src/commands/auth/list-projects.command.ts"],"sourceRoot":"","names":[],"mappings":";;;;;AAAA,qDAKkC;AAClC,qDAAiE;AAEjE,+DAA2D;AAC3D,mEAA+D;AAC/D,+DAA0D;AAC1D,+DAAiE;AAMpD,QAAA,mBAAmB,GAAoC;IAClE,OAAO,EAAE,eAAe;IACxB,QAAQ,EAAE,mEAAmE;IAC7E,OAAO,EAAE;QACP,IAAI,EAAE;YACJ,OAAO,EAAE,IAAI;YACb,WAAW,EACT,sEAAsE;gBACtE,gEAAgE;gBAChE,mEAAmE;YACrE,OAAO,EAAE,KAAK;SACf;KACF;IACD,OAAO,EAAE,IAAA,0BAAW,EAAC,KAAK,EAAE,EAAE,IAAI,EAAW,EAAE,EAAE;QAC/C,IAAA,mBAAU,GAAE,CAAC;QAEb,gEAAgE;QAChE,2EAA2E;QAC3E,2EAA2E;QAC3E,uEAAuE;QACvE,4EAA4E;QAC5E,MAAM,QAAQ,GAAG,MAAM,iBAAiB,EAAE,CAAC;QAE3C,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1C,MAAM,QAAQ,GAAG,MAAM,IAAA,oCAAmB,EAAC,MAAM,CAAC,CAAC;QAEnD,IAAI,IAAI,EAAE,CAAC;YACT,IAAA,sBAAS,EAAC,QAAQ,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;gBACzB,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;QAED,uEAAuE;QACvE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,IAAA,kBAAS,EAAC,6CAA6C,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC,CAAC;CACH,CAAC;AAEF,MAAM,iBAAiB,GAAG,KAAK,IAAqB,EAAE;IACpD,MAAM,UAAU,GAAG,MAAM,IAAA,4BAAmB,GAAE,CAAC;IAC/C,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,IAAI,CAAC,IAAA,6BAAoB,GAAE,EAAE,CAAC;QAC5B,MAAM,IAAI,6BAAY,CACpB,uEAAuE;YACrE,4DAA4D;YAC5D,+DAA+D;YAC/D,+DAA+D;YAC/D,iEAAiE;YACjE,sBAAsB,CACzB,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAiB,GAAE,CAAC;IACzC,OAAO,MAAM,CAAC,WAAW,CAAC;AAC5B,CAAC,CAAC","debugId":"abc4eb30-d968-5734-b82a-18a5e28cd6eb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-project.command.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/set-project.command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"set-project.command.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/set-project.command.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAM3C,UAAU,OAAO;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,eAAO,MAAM,iBAAiB,EAAE,aAAa,CAAC,OAAO,EAAE,OAAO,CAyD7D,CAAC"}
|
|
@@ -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,OAAO,EAAE,IAAA,0BAAW,EAAC,KAAK,EAAE,EAAE,IAAI,EAAW,EAAE,EAAE;QAC/C,IAAA,mBAAU,GAAE,CAAC;QAEb,oEAAoE;QACpE,0EAA0E;QAC1E,4EAA4E;QAC5E,uEAAuE;QACvE,0EAA0E;QAC1E,wEAAwE;QACxE,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,yEAAyE;QACzE,sEAAsE;QACtE,qBAAqB;QACrB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,QAAQ,GAAG,MAAM,IAAA,uBAAc,EAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,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C,OAAO;YACvB,aAAa;YACb,eAAe,EAAE,MAAM,CAAC,eAAe;SACxC,CAAC,CAAC;QACH,OAAO;IACT,CAAC;IACD,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CACT,iBAAiB,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,KAAK,GAAG,CACzE,CAAC;IACF,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC7B,MAAM,SAAS,GAAG,aAAa;aAC5B,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;aACjE,IAAI,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,WAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE,GAAG,EAAE,CAAC,CAAC;IACzC,sBAAsB,EAAE,KAAK,CAAC,sBAAsB;CACrD,CAAC,CAAC,CAAC;AAEJ,MAAM,MAAM,GAAG,EAAsB,CAAC;AAEtC,IAAA,iBAAQ,EAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,IAAA,mBAAU,EAAC,GAAG,EAAE;QACd,WAAE,CAAC,aAAa,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,qEAAqE,EAAE,KAAK,IAAI,EAAE;QACnF,KAAK,CAAC,sBAAsB,CAAC,iBAAiB,CAAC;YAC7C,OAAO,EAAE,wBAAwB;YACjC,SAAS,EAAE,MAAM;YACjB,MAAM,EAAE,cAAc;SACvB,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAM,IAAA,mDAA0B,EAC9C,sCAAsC,EACtC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AC,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
|