@knpkv/atlassian-common 1.7.0 → 1.9.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/CHANGELOG.md +17 -0
- package/dist/bin.js +3 -2
- package/dist/bin.js.map +1 -1
- package/dist/cli/index.d.ts +40 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +115 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli-auth/authCommand.d.ts +10 -1
- package/dist/cli-auth/authCommand.d.ts.map +1 -1
- package/dist/cli-auth/authCommand.js +10 -2
- package/dist/cli-auth/authCommand.js.map +1 -1
- package/dist/cli-auth/index.d.ts +1 -1
- package/dist/cli-auth/index.d.ts.map +1 -1
- package/dist/cli-auth/index.js +1 -1
- package/dist/cli-auth/index.js.map +1 -1
- package/package.json +5 -1
- package/src/bin.ts +3 -3
- package/src/cli/index.ts +136 -0
- package/src/cli-auth/authCommand.ts +12 -2
- package/src/cli-auth/index.ts +7 -1
- package/test/cli.errorHandling.test.ts +145 -0
- package/test/cliAuth.authCommand.test.ts +11 -3
- package/test/cliAuth.guardrails.test.ts +6 -4
- package/test/cliAuth.login.test.ts +15 -10
- package/vitest.config.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @knpkv/atlassian-common
|
|
2
2
|
|
|
3
|
+
## 1.9.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#479](https://github.com/knpkv/npm/pull/479) [`1ef1847`](https://github.com/knpkv/npm/commit/1ef1847c867f83de237dec1c454b6bb5e40183ef) Thanks [@konopkov](https://github.com/konopkov)! - One error report for every Atlassian CLI (`jira`, `confluence`, `atlassian`), from the new `@knpkv/atlassian-common/cli` subpath (`handleCliError`, `withCliErrorHandling`, `Verbose`, `commandArgs`, `verboseRequested`).
|
|
8
|
+
|
|
9
|
+
- A failed command prints the error's message; a defect prints `Error: <message>`. The full cause, with stack traces, prints only with the new global `--verbose` flag or `DEBUG=1`.
|
|
10
|
+
- jira: stderr no longer prints the pretty-printed cause and stack trace by default.
|
|
11
|
+
- atlassian: tagged errors print their message instead of `String(error)`, and defects are reported too.
|
|
12
|
+
- Help and usage errors that the CLI already rendered are not printed a second time. Exit codes are unchanged.
|
|
13
|
+
|
|
14
|
+
## 1.8.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [#475](https://github.com/knpkv/npm/pull/475) [`08c62b7`](https://github.com/knpkv/npm/commit/08c62b787c649d8f78753515be6faf317791d62b) Thanks [@konopkov](https://github.com/konopkov)! - `auth use <profile>` and `auth remove <profile>` now fail with a typed `ProfileNotFoundError` (exported from `@knpkv/atlassian-common/cli-auth`) and exit non-zero when no stored profile matches. The failure names the profile (`Profile not found: <profile>`, on stderr through each CLI's error handler); previously the line went to stdout and the command exited 0, so a script could not tell a typo from a switch.
|
|
19
|
+
|
|
3
20
|
## 1.7.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
package/dist/bin.js
CHANGED
|
@@ -6,6 +6,7 @@ import * as Effect from "effect/Effect";
|
|
|
6
6
|
import * as Layer from "effect/Layer";
|
|
7
7
|
import * as Stdio from "effect/Stdio";
|
|
8
8
|
import pkg from "../package.json" with { type: "json" };
|
|
9
|
+
import { Verbose, withCliErrorHandling } from "./cli/index.js";
|
|
9
10
|
import { HomeDirectoryLive, inspectAllToolProfiles, migrateLegacyProfiles, refreshActiveProfiles, useProfileForAllTools } from "./config/index.js";
|
|
10
11
|
const profileArg = Args.String("profile").pipe(Args.withDescription("Profile ID, name, site URL, cloud ID, or account ID"));
|
|
11
12
|
const printStatuses = (statuses) => Effect.gen(function* () {
|
|
@@ -47,12 +48,12 @@ const profiles = Command.make("profiles").pipe(Command.withDescription("Manage s
|
|
|
47
48
|
const authRefresh = Command.make("refresh", {}, () => refreshActiveProfiles().pipe(Effect.flatMap(printStatuses)))
|
|
48
49
|
.pipe(Command.withDescription("Refresh expired active OAuth tokens"));
|
|
49
50
|
const auth = Command.make("auth").pipe(Command.withDescription("Manage Atlassian authentication"), Command.withSubcommands([authRefresh]));
|
|
50
|
-
const atlassian = Command.make("atlassian", {}, () => Console.log("Usage: atlassian profiles|auth")).pipe(Command.withDescription("Unified Atlassian profile manager"), Command.withSubcommands([profiles, auth]));
|
|
51
|
+
const atlassian = Command.make("atlassian", {}, () => Console.log("Usage: atlassian profiles|auth")).pipe(Command.withDescription("Unified Atlassian profile manager"), Command.withGlobalFlags([Verbose]), Command.withSubcommands([profiles, auth]));
|
|
51
52
|
const cli = Command.runWith(atlassian, { version: pkg.version });
|
|
52
53
|
const program = Effect.gen(function* () {
|
|
53
54
|
const stdio = yield* Stdio.Stdio;
|
|
54
55
|
const args = yield* stdio.args;
|
|
55
56
|
return yield* cli(args);
|
|
56
|
-
}).pipe(Effect.provide(Layer.mergeAll(NodeServices.layer, NodeHttpClient.layerFetch, HomeDirectoryLive))
|
|
57
|
+
}).pipe(withCliErrorHandling, Effect.provide(Layer.mergeAll(NodeServices.layer, NodeHttpClient.layerFetch, HomeDirectoryLive)));
|
|
57
58
|
NodeRuntime.runMain(program, { disableErrorReporting: true });
|
|
58
59
|
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACjF,OAAO,EAAE,QAAQ,IAAI,IAAI,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,GAAG,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AAM,KAAK,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAA;IAChC,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAA;IAC9B,OAAO,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC,CAAC,CAAC,IAAI,CACL,oBAAoB,EACpB,MAAM,CAAC,OAAO,CACZ,KAAK,CAAC,QAAQ,CACZ,YAAY,CAAC,KAAK,EAClB,cAAc,CAAC,UAAU,EACzB,iBAAiB,CAClB,CACF,CACF,CAAA;AAED,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How an Atlassian command-line tool reports a failed run.
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - **The message is the report.** A failure prints its message; a defect prints `Error: <message>`;
|
|
7
|
+
* an interruption prints `Interrupted`. The full cause, with stack traces, is for whoever asked for
|
|
8
|
+
* it: `--verbose`, or `DEBUG=1` in the environment.
|
|
9
|
+
* - **What the CLI already showed is not repeated.** `Command.runWith` renders help and usage errors
|
|
10
|
+
* itself and then fails with them, so those reasons are skipped unless verbose.
|
|
11
|
+
* - **The exit code is untouched.** The cause is reported and re-failed as it was, so a help request
|
|
12
|
+
* still exits 0 and every failure still exits non-zero.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import * as Cause from "effect/Cause";
|
|
17
|
+
import { GlobalFlag } from "effect/cli";
|
|
18
|
+
import * as Effect from "effect/Effect";
|
|
19
|
+
import * as Stdio from "effect/Stdio";
|
|
20
|
+
/** `--verbose`: print the full cause, with stack traces, when a command fails. Register on the root command. */
|
|
21
|
+
export declare const Verbose: GlobalFlag.Setting<"verbose", boolean>;
|
|
22
|
+
/** Whether `args` turn {@link Verbose} on, as the flag parser would read them. */
|
|
23
|
+
export declare const verboseFlagIn: (args: ReadonlyArray<string>) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* `args` without the {@link Verbose} flag and the value it consumed, for code that routes on the
|
|
26
|
+
* command words before the CLI parses them, such as choosing which service layer to build.
|
|
27
|
+
*/
|
|
28
|
+
export declare const commandArgs: (args: ReadonlyArray<string>) => ReadonlyArray<string>;
|
|
29
|
+
/** `--verbose` in `args`, or `DEBUG=1`. Only `1`: `DEBUG` is also the debug package's namespace list. */
|
|
30
|
+
export declare const verboseRequested: (args: ReadonlyArray<string>) => Effect.Effect<boolean>;
|
|
31
|
+
/** Print a failed run's cause to stderr: each failure's message, or the full cause when verbose. */
|
|
32
|
+
export declare const handleCliError: <E>(cause: Cause.Cause<E>, options: {
|
|
33
|
+
readonly verbose: boolean;
|
|
34
|
+
}) => Effect.Effect<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Report a CLI program's failure with {@link handleCliError} and fail with the same cause. Apply it
|
|
37
|
+
* before providing `Stdio`, which it reads the arguments from.
|
|
38
|
+
*/
|
|
39
|
+
export declare const withCliErrorHandling: <A, E, R>(program: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R | Stdio.Stdio>;
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,EAAkB,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,gHAAgH;AAChH,eAAO,MAAM,OAAO,wCAKlB,CAAA;AAiDF,kFAAkF;AAClF,eAAO,MAAM,aAAa,SAAU,aAAa,CAAC,MAAM,CAAC,KAAG,OAA6C,CAAA;AAEzG;;;GAGG;AACH,eAAO,MAAM,WAAW,SAAU,aAAa,CAAC,MAAM,CAAC,KAAG,aAAa,CAAC,MAAM,CAA2B,CAAA;AAEzG,yGAAyG;AACzG,eAAO,MAAM,gBAAgB,SAAU,aAAa,CAAC,MAAM,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAMtC,CAAA;AAc9C,oGAAoG;AACpG,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAS3F,CAAA;AASzB;;;GAGG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,EAAE,CAAC,EAAE,CAAC,WACjC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC9B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,KAAK,CAC0E,CAAA"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How an Atlassian command-line tool reports a failed run.
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - **The message is the report.** A failure prints its message; a defect prints `Error: <message>`;
|
|
7
|
+
* an interruption prints `Interrupted`. The full cause, with stack traces, is for whoever asked for
|
|
8
|
+
* it: `--verbose`, or `DEBUG=1` in the environment.
|
|
9
|
+
* - **What the CLI already showed is not repeated.** `Command.runWith` renders help and usage errors
|
|
10
|
+
* itself and then fails with them, so those reasons are skipped unless verbose.
|
|
11
|
+
* - **The exit code is untouched.** The cause is reported and re-failed as it was, so a help request
|
|
12
|
+
* still exits 0 and every failure still exits non-zero.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import * as Cause from "effect/Cause";
|
|
17
|
+
import { CliError, Flag, GlobalFlag } from "effect/cli";
|
|
18
|
+
import * as Config from "effect/Config";
|
|
19
|
+
import * as Console from "effect/Console";
|
|
20
|
+
import * as Effect from "effect/Effect";
|
|
21
|
+
import * as Option from "effect/Option";
|
|
22
|
+
import * as Predicate from "effect/Predicate";
|
|
23
|
+
import * as Stdio from "effect/Stdio";
|
|
24
|
+
/** `--verbose`: print the full cause, with stack traces, when a command fails. Register on the root command. */
|
|
25
|
+
export const Verbose = GlobalFlag.Setting("verbose")({
|
|
26
|
+
flag: Flag.Boolean("verbose").pipe(Flag.withDefault(false), Flag.withDescription("Print the full cause, with stack traces, when a command fails"))
|
|
27
|
+
});
|
|
28
|
+
const truthy = new Set(["true", "1", "y", "yes", "on"]);
|
|
29
|
+
const falsy = new Set(["false", "0", "n", "no", "off"]);
|
|
30
|
+
/** Exactly the literals `effect/cli` accepts for a boolean: lowercase only, so `FALSE` is not one. */
|
|
31
|
+
const booleanLiteral = (token) => token === undefined ? undefined : truthy.has(token) ? true : falsy.has(token) ? false : undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Read {@link Verbose} out of `args` the way `effect/cli` parses a boolean flag: only before `--`;
|
|
34
|
+
* `--verbose` may take a following boolean literal (`--verbose false`), `--verbose=<boolean>` and
|
|
35
|
+
* `--no-verbose` are the other spellings, and the first occurrence decides the value.
|
|
36
|
+
*/
|
|
37
|
+
const scanVerbose = (args) => {
|
|
38
|
+
const end = args.indexOf("--");
|
|
39
|
+
const head = end === -1 ? args : args.slice(0, end);
|
|
40
|
+
const tail = end === -1 ? [] : args.slice(end);
|
|
41
|
+
const rest = [];
|
|
42
|
+
let verbose;
|
|
43
|
+
const settle = (value) => {
|
|
44
|
+
if (verbose === undefined)
|
|
45
|
+
verbose = value;
|
|
46
|
+
};
|
|
47
|
+
for (let index = 0; index < head.length; index++) {
|
|
48
|
+
const token = head[index];
|
|
49
|
+
if (token === "--verbose") {
|
|
50
|
+
const literal = booleanLiteral(head[index + 1]);
|
|
51
|
+
if (literal !== undefined)
|
|
52
|
+
index++;
|
|
53
|
+
settle(literal ?? true);
|
|
54
|
+
}
|
|
55
|
+
else if (token === "--no-verbose") {
|
|
56
|
+
settle(false);
|
|
57
|
+
}
|
|
58
|
+
else if (token.startsWith("--verbose=")) {
|
|
59
|
+
// A value that is not a boolean makes the parser fail; it never turns verbose on.
|
|
60
|
+
const literal = booleanLiteral(token.slice("--verbose=".length));
|
|
61
|
+
if (literal !== undefined)
|
|
62
|
+
settle(literal);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
rest.push(token);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { rest: [...rest, ...tail], verbose };
|
|
69
|
+
};
|
|
70
|
+
/** Whether `args` turn {@link Verbose} on, as the flag parser would read them. */
|
|
71
|
+
export const verboseFlagIn = (args) => scanVerbose(args).verbose === true;
|
|
72
|
+
/**
|
|
73
|
+
* `args` without the {@link Verbose} flag and the value it consumed, for code that routes on the
|
|
74
|
+
* command words before the CLI parses them, such as choosing which service layer to build.
|
|
75
|
+
*/
|
|
76
|
+
export const commandArgs = (args) => scanVerbose(args).rest;
|
|
77
|
+
/** `--verbose` in `args`, or `DEBUG=1`. Only `1`: `DEBUG` is also the debug package's namespace list. */
|
|
78
|
+
export const verboseRequested = (args) => verboseFlagIn(args)
|
|
79
|
+
? Effect.succeed(true)
|
|
80
|
+
: Effect.gen(function* () {
|
|
81
|
+
const debug = yield* Config.option(Config.String("DEBUG"));
|
|
82
|
+
return Option.getOrUndefined(debug) === "1";
|
|
83
|
+
}).pipe(Effect.orElseSucceed(() => false));
|
|
84
|
+
const describe = (error) => {
|
|
85
|
+
if (Predicate.hasProperty(error, "message") && Predicate.isString(error.message) && error.message !== "") {
|
|
86
|
+
return error.message;
|
|
87
|
+
}
|
|
88
|
+
if (Predicate.hasProperty(error, "_tag") && Predicate.isString(error._tag))
|
|
89
|
+
return error._tag;
|
|
90
|
+
return String(error);
|
|
91
|
+
};
|
|
92
|
+
/** `Command.runWith` prints help and user errors itself before failing with them; nothing else. */
|
|
93
|
+
const renderedByRunner = (error) => CliError.isCliError(error) && (error._tag === "ShowHelp" || error._tag === "UserError");
|
|
94
|
+
/** Print a failed run's cause to stderr: each failure's message, or the full cause when verbose. */
|
|
95
|
+
export const handleCliError = (cause, options) => options.verbose
|
|
96
|
+
? Console.error(Cause.pretty(cause))
|
|
97
|
+
: Effect.forEach(cause.reasons, (reason) => {
|
|
98
|
+
if (Cause.isFailReason(reason)) {
|
|
99
|
+
return renderedByRunner(reason.error) ? Effect.void : Console.error(describe(reason.error));
|
|
100
|
+
}
|
|
101
|
+
if (Cause.isDieReason(reason))
|
|
102
|
+
return Console.error(`Error: ${describe(reason.defect)}`);
|
|
103
|
+
return Console.error("Interrupted");
|
|
104
|
+
}, { discard: true });
|
|
105
|
+
const reportFailure = (cause) => Effect.gen(function* () {
|
|
106
|
+
const stdio = yield* Stdio.Stdio;
|
|
107
|
+
const verbose = yield* stdio.args.pipe(Effect.flatMap(verboseRequested), Effect.orElseSucceed(() => false));
|
|
108
|
+
yield* handleCliError(cause, { verbose });
|
|
109
|
+
});
|
|
110
|
+
/**
|
|
111
|
+
* Report a CLI program's failure with {@link handleCliError} and fail with the same cause. Apply it
|
|
112
|
+
* before providing `Stdio`, which it reads the arguments from.
|
|
113
|
+
*/
|
|
114
|
+
export const withCliErrorHandling = (program) => program.pipe(Effect.catchCause((cause) => reportFailure(cause).pipe(Effect.andThen(Effect.failCause(cause)))));
|
|
115
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,KAAK,MAAM,MAAM,eAAe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AAG,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAA;IAChC,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IAC3G,KAAK,CAAC,CAAC,cAAc,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;AAC3C,CAAC,CAAC,CAAA;AAEJ;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,OAA+B,EACO,EAAE,CACxC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
*/
|
|
17
17
|
import { Command, Prompt } from "effect/cli";
|
|
18
18
|
import type * as Context from "effect/Context";
|
|
19
|
+
import * as Schema from "effect/Schema";
|
|
19
20
|
import type { AtlassianCliAuth, AtlassianCliDescriptor } from "./AtlassianCliAuth.js";
|
|
20
21
|
/** The part of an Atlassian CLI's auth the `auth` commands drive. */
|
|
21
22
|
export type AuthCommandService = Pick<AtlassianCliAuth<never>, "configure" | "login" | "logout" | "getActiveProfile" | "listProfiles" | "switchProfile" | "removeProfile">;
|
|
@@ -29,6 +30,14 @@ export interface AuthCommandOptions {
|
|
|
29
30
|
* `offline_access` is requested at authorize time but is not an app permission, so it is omitted.
|
|
30
31
|
*/
|
|
31
32
|
export declare const scopeInstructions: (descriptor: AtlassianCliDescriptor, apiSection: string) => string;
|
|
33
|
+
declare const ProfileNotFoundError_base: Schema.Class<ProfileNotFoundError, Schema.TaggedStruct<"ProfileNotFoundError", {
|
|
34
|
+
readonly selector: Schema.String;
|
|
35
|
+
readonly message: Schema.String;
|
|
36
|
+
}>, import("effect/Cause").YieldableError>;
|
|
37
|
+
/** `auth use` or `auth remove` named no stored profile. The CLI prints the message and exits non-zero. */
|
|
38
|
+
export declare class ProfileNotFoundError extends ProfileNotFoundError_base {
|
|
39
|
+
}
|
|
32
40
|
/** Build `<cli> auth` with create, manage, configure, login, logout, status, profiles, use, remove. */
|
|
33
|
-
export declare const makeAuthCommand: <I, S extends AuthCommandService>(service: Context.Key<I, S>, descriptor: AtlassianCliDescriptor, options: AuthCommandOptions) => Command.Command<"auth", {}, {}, import("./openBrowser.js").BrowserOpenError | import("../index.ts").OAuthError | import("effect/Terminal").QuitError | (import("../index.ts").FileSystemError | import("../index.ts").HomeDirectoryError | import("effect/PlatformError").PlatformError), import("effect/process/ChildProcessSpawner").ChildProcessSpawner | Exclude<Exclude<I, "effect/cli/GlobalFlag/log-level">, Command.CommandContext<"auth">> | Prompt.Environment>;
|
|
41
|
+
export declare const makeAuthCommand: <I, S extends AuthCommandService>(service: Context.Key<I, S>, descriptor: AtlassianCliDescriptor, options: AuthCommandOptions) => Command.Command<"auth", {}, {}, import("./openBrowser.js").BrowserOpenError | import("../index.ts").OAuthError | ProfileNotFoundError | import("effect/Terminal").QuitError | (import("../index.ts").FileSystemError | import("../index.ts").HomeDirectoryError | import("effect/PlatformError").PlatformError), import("effect/process/ChildProcessSpawner").ChildProcessSpawner | Exclude<Exclude<I, "effect/cli/GlobalFlag/log-level">, Command.CommandContext<"auth">> | Prompt.Environment>;
|
|
42
|
+
export {};
|
|
34
43
|
//# sourceMappingURL=authCommand.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authCommand.d.ts","sourceRoot":"","sources":["../../src/cli-auth/authCommand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAY,OAAO,EAAQ,MAAM,EAAE,MAAM,YAAY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,0GAA0G;AAC1G,qBAAa,oBAAqB,SAAQ,yBAGxC;CAAG;AAQL,uGAAuG;AACvG,eAAO,MAAM,eAAe,GAAI,CAAC,EAAE,CAAC,SAAS,kBAAkB,WACpD,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,cACd,sBAAsB,WACzB,kBAAkB,qeA+J5B,CAAA"}
|
|
@@ -18,6 +18,7 @@ import { Argument, Command, Flag, Prompt } from "effect/cli";
|
|
|
18
18
|
import * as Console from "effect/Console";
|
|
19
19
|
import * as Effect from "effect/Effect";
|
|
20
20
|
import * as Option from "effect/Option";
|
|
21
|
+
import * as Schema from "effect/Schema";
|
|
21
22
|
import { openBrowser } from "./openBrowser.js";
|
|
22
23
|
const CREATE_APP_URL = "https://developer.atlassian.com/console/myapps/create-3lo-app/";
|
|
23
24
|
const CONSOLE_APPS_URL = "https://developer.atlassian.com/console/myapps/";
|
|
@@ -34,6 +35,13 @@ export const scopeInstructions = (descriptor, apiSection) => {
|
|
|
34
35
|
...section("User Identity API", permissions.filter((scope) => scope === "read:me"))
|
|
35
36
|
].join("\n");
|
|
36
37
|
};
|
|
38
|
+
/** `auth use` or `auth remove` named no stored profile. The CLI prints the message and exits non-zero. */
|
|
39
|
+
export class ProfileNotFoundError extends Schema.TaggedError()("ProfileNotFoundError", {
|
|
40
|
+
selector: Schema.String,
|
|
41
|
+
message: Schema.String
|
|
42
|
+
}) {
|
|
43
|
+
}
|
|
44
|
+
const profileNotFound = (selector) => new ProfileNotFoundError({ selector, message: `Profile not found: ${selector}` });
|
|
37
45
|
/** Print the URL, then try to open it; a browser that never opened fails the command. */
|
|
38
46
|
const visit = (url) => Console.log(`Opening ${url}`).pipe(Effect.andThen(openBrowser(url)));
|
|
39
47
|
/** Build `<cli> auth` with create, manage, configure, login, logout, status, profiles, use, remove. */
|
|
@@ -120,8 +128,8 @@ After adding scopes, run: ${loginHint}
|
|
|
120
128
|
}
|
|
121
129
|
}))).pipe(Command.withDescription("List stored auth profiles"));
|
|
122
130
|
const profile = Argument.String("profile").pipe(Argument.withDescription("Profile ID, name, site URL, cloud ID, or account ID"));
|
|
123
|
-
const use = Command.make("use", { profile }, ({ profile }) => withAuth((auth) => Effect.flatMap(auth.switchProfile(profile), (selected) =>
|
|
124
|
-
const remove = Command.make("remove", { profile }, ({ profile }) => withAuth((auth) => Effect.flatMap(auth.removeProfile(profile), (removed) =>
|
|
131
|
+
const use = Command.make("use", { profile }, ({ profile }) => withAuth((auth) => Effect.flatMap(auth.switchProfile(profile), (selected) => selected === null ? Effect.fail(profileNotFound(profile)) : Console.log(`Active profile: ${selected.name}`)))).pipe(Command.withDescription("Switch active auth profile"));
|
|
132
|
+
const remove = Command.make("remove", { profile }, ({ profile }) => withAuth((auth) => Effect.flatMap(auth.removeProfile(profile), (removed) => removed === null ? Effect.fail(profileNotFound(profile)) : Console.log(`Removed profile: ${removed.name}`)))).pipe(Command.withDescription("Remove stored auth profile"));
|
|
125
133
|
return Command.make("auth").pipe(Command.withDescription("Manage OAuth authentication"), Command.withSubcommands([create, manage, configure, login, logout, status, profiles, use, remove]));
|
|
126
134
|
};
|
|
127
135
|
//# sourceMappingURL=authCommand.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authCommand.js","sourceRoot":"","sources":["../../src/cli-auth/authCommand.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAEzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,MAAM,cAAc,GAAG,gEAAgE,CAAA;AACvF,MAAM,gBAAgB,GAAG,iDAAiD,CAAA;AAC1E,MAAM,YAA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MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CACnG,CAAA;AACH,CAAC,CAAA"}
|
package/dist/cli-auth/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
export { type AccessibleSite, type AtlassianCliAuth, type AtlassianCliAuthOptions, type AtlassianCliDescriptor, type LoginOptions, makeAtlassianCliAuth } from "./AtlassianCliAuth.js";
|
|
10
|
-
export { type AuthCommandOptions, type AuthCommandService, makeAuthCommand, scopeInstructions } from "./authCommand.js";
|
|
10
|
+
export { type AuthCommandOptions, type AuthCommandService, makeAuthCommand, ProfileNotFoundError, scopeInstructions } from "./authCommand.js";
|
|
11
11
|
export { HttpServerFactoryLive, NodeCliAuthLive } from "./internal/NodeLayers.js";
|
|
12
12
|
export { type HttpServerFactory, HttpServerFactoryTag, makeHttpServerFactory } from "./internal/oauthServer.js";
|
|
13
13
|
export { BrowserOpenError, openBrowser } from "./openBrowser.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli-auth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,oBAAoB,EACrB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli-auth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,oBAAoB,EACrB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,EAAE,KAAK,iBAAiB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAC/G,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA"}
|
package/dist/cli-auth/index.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @module
|
|
8
8
|
*/
|
|
9
9
|
export { makeAtlassianCliAuth } from "./AtlassianCliAuth.js";
|
|
10
|
-
export { makeAuthCommand, scopeInstructions } from "./authCommand.js";
|
|
10
|
+
export { makeAuthCommand, ProfileNotFoundError, scopeInstructions } from "./authCommand.js";
|
|
11
11
|
export { HttpServerFactoryLive, NodeCliAuthLive } from "./internal/NodeLayers.js";
|
|
12
12
|
export { HttpServerFactoryTag, makeHttpServerFactory } from "./internal/oauthServer.js";
|
|
13
13
|
export { BrowserOpenError, openBrowser } from "./openBrowser.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli-auth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAML,oBAAoB,EACrB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli-auth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAML,oBAAoB,EACrB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAGL,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,EAA0B,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAC/G,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knpkv/atlassian-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Shared utilities for Atlassian tools (AST, serializers, auth, config)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "knpkv",
|
|
@@ -42,6 +42,10 @@
|
|
|
42
42
|
"import": "./dist/auth/index.js",
|
|
43
43
|
"types": "./dist/auth/index.d.ts"
|
|
44
44
|
},
|
|
45
|
+
"./cli": {
|
|
46
|
+
"import": "./dist/cli/index.js",
|
|
47
|
+
"types": "./dist/cli/index.d.ts"
|
|
48
|
+
},
|
|
45
49
|
"./cli-auth": {
|
|
46
50
|
"import": "./dist/cli-auth/index.js",
|
|
47
51
|
"types": "./dist/cli-auth/index.d.ts"
|
package/src/bin.ts
CHANGED
|
@@ -6,6 +6,7 @@ import * as Effect from "effect/Effect"
|
|
|
6
6
|
import * as Layer from "effect/Layer"
|
|
7
7
|
import * as Stdio from "effect/Stdio"
|
|
8
8
|
import pkg from "../package.json" with { type: "json" }
|
|
9
|
+
import { Verbose, withCliErrorHandling } from "./cli/index.js"
|
|
9
10
|
import {
|
|
10
11
|
HomeDirectoryLive,
|
|
11
12
|
inspectAllToolProfiles,
|
|
@@ -90,6 +91,7 @@ const auth = Command.make("auth").pipe(
|
|
|
90
91
|
|
|
91
92
|
const atlassian = Command.make("atlassian", {}, () => Console.log("Usage: atlassian profiles|auth")).pipe(
|
|
92
93
|
Command.withDescription("Unified Atlassian profile manager"),
|
|
94
|
+
Command.withGlobalFlags([Verbose]),
|
|
93
95
|
Command.withSubcommands([profiles, auth])
|
|
94
96
|
)
|
|
95
97
|
|
|
@@ -99,15 +101,13 @@ const program = Effect.gen(function*() {
|
|
|
99
101
|
const args = yield* stdio.args
|
|
100
102
|
return yield* cli(args)
|
|
101
103
|
}).pipe(
|
|
104
|
+
withCliErrorHandling,
|
|
102
105
|
Effect.provide(
|
|
103
106
|
Layer.mergeAll(
|
|
104
107
|
NodeServices.layer,
|
|
105
108
|
NodeHttpClient.layerFetch,
|
|
106
109
|
HomeDirectoryLive
|
|
107
110
|
)
|
|
108
|
-
),
|
|
109
|
-
Effect.catch(<UnparsedInput>(error: UnparsedInput) =>
|
|
110
|
-
Console.error(String(error)).pipe(Effect.andThen(Effect.fail(error)))
|
|
111
111
|
)
|
|
112
112
|
)
|
|
113
113
|
|
package/src/cli/index.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How an Atlassian command-line tool reports a failed run.
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - **The message is the report.** A failure prints its message; a defect prints `Error: <message>`;
|
|
7
|
+
* an interruption prints `Interrupted`. The full cause, with stack traces, is for whoever asked for
|
|
8
|
+
* it: `--verbose`, or `DEBUG=1` in the environment.
|
|
9
|
+
* - **What the CLI already showed is not repeated.** `Command.runWith` renders help and usage errors
|
|
10
|
+
* itself and then fails with them, so those reasons are skipped unless verbose.
|
|
11
|
+
* - **The exit code is untouched.** The cause is reported and re-failed as it was, so a help request
|
|
12
|
+
* still exits 0 and every failure still exits non-zero.
|
|
13
|
+
*
|
|
14
|
+
* @module
|
|
15
|
+
*/
|
|
16
|
+
import * as Cause from "effect/Cause"
|
|
17
|
+
import { CliError, Flag, GlobalFlag } from "effect/cli"
|
|
18
|
+
import * as Config from "effect/Config"
|
|
19
|
+
import * as Console from "effect/Console"
|
|
20
|
+
import * as Effect from "effect/Effect"
|
|
21
|
+
import * as Option from "effect/Option"
|
|
22
|
+
import * as Predicate from "effect/Predicate"
|
|
23
|
+
import * as Stdio from "effect/Stdio"
|
|
24
|
+
|
|
25
|
+
/** `--verbose`: print the full cause, with stack traces, when a command fails. Register on the root command. */
|
|
26
|
+
export const Verbose = GlobalFlag.Setting("verbose")({
|
|
27
|
+
flag: Flag.Boolean("verbose").pipe(
|
|
28
|
+
Flag.withDefault(false),
|
|
29
|
+
Flag.withDescription("Print the full cause, with stack traces, when a command fails")
|
|
30
|
+
)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const truthy = new Set(["true", "1", "y", "yes", "on"])
|
|
34
|
+
const falsy = new Set(["false", "0", "n", "no", "off"])
|
|
35
|
+
|
|
36
|
+
/** Exactly the literals `effect/cli` accepts for a boolean: lowercase only, so `FALSE` is not one. */
|
|
37
|
+
const booleanLiteral = (token: string | undefined): boolean | undefined =>
|
|
38
|
+
token === undefined ? undefined : truthy.has(token) ? true : falsy.has(token) ? false : undefined
|
|
39
|
+
|
|
40
|
+
interface VerboseScan {
|
|
41
|
+
/** The value the flag parser settles on, or undefined when the flag is absent. */
|
|
42
|
+
readonly verbose: boolean | undefined
|
|
43
|
+
/** `args` with every token the flag consumed removed. */
|
|
44
|
+
readonly rest: ReadonlyArray<string>
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Read {@link Verbose} out of `args` the way `effect/cli` parses a boolean flag: only before `--`;
|
|
49
|
+
* `--verbose` may take a following boolean literal (`--verbose false`), `--verbose=<boolean>` and
|
|
50
|
+
* `--no-verbose` are the other spellings, and the first occurrence decides the value.
|
|
51
|
+
*/
|
|
52
|
+
const scanVerbose = (args: ReadonlyArray<string>): VerboseScan => {
|
|
53
|
+
const end = args.indexOf("--")
|
|
54
|
+
const head = end === -1 ? args : args.slice(0, end)
|
|
55
|
+
const tail = end === -1 ? [] : args.slice(end)
|
|
56
|
+
const rest: Array<string> = []
|
|
57
|
+
let verbose: boolean | undefined
|
|
58
|
+
const settle = (value: boolean) => {
|
|
59
|
+
if (verbose === undefined) verbose = value
|
|
60
|
+
}
|
|
61
|
+
for (let index = 0; index < head.length; index++) {
|
|
62
|
+
const token = head[index]!
|
|
63
|
+
if (token === "--verbose") {
|
|
64
|
+
const literal = booleanLiteral(head[index + 1])
|
|
65
|
+
if (literal !== undefined) index++
|
|
66
|
+
settle(literal ?? true)
|
|
67
|
+
} else if (token === "--no-verbose") {
|
|
68
|
+
settle(false)
|
|
69
|
+
} else if (token.startsWith("--verbose=")) {
|
|
70
|
+
// A value that is not a boolean makes the parser fail; it never turns verbose on.
|
|
71
|
+
const literal = booleanLiteral(token.slice("--verbose=".length))
|
|
72
|
+
if (literal !== undefined) settle(literal)
|
|
73
|
+
} else {
|
|
74
|
+
rest.push(token)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return { rest: [...rest, ...tail], verbose }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** Whether `args` turn {@link Verbose} on, as the flag parser would read them. */
|
|
81
|
+
export const verboseFlagIn = (args: ReadonlyArray<string>): boolean => scanVerbose(args).verbose === true
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* `args` without the {@link Verbose} flag and the value it consumed, for code that routes on the
|
|
85
|
+
* command words before the CLI parses them, such as choosing which service layer to build.
|
|
86
|
+
*/
|
|
87
|
+
export const commandArgs = (args: ReadonlyArray<string>): ReadonlyArray<string> => scanVerbose(args).rest
|
|
88
|
+
|
|
89
|
+
/** `--verbose` in `args`, or `DEBUG=1`. Only `1`: `DEBUG` is also the debug package's namespace list. */
|
|
90
|
+
export const verboseRequested = (args: ReadonlyArray<string>): Effect.Effect<boolean> =>
|
|
91
|
+
verboseFlagIn(args)
|
|
92
|
+
? Effect.succeed(true)
|
|
93
|
+
: Effect.gen(function*() {
|
|
94
|
+
const debug = yield* Config.option(Config.String("DEBUG"))
|
|
95
|
+
return Option.getOrUndefined(debug) === "1"
|
|
96
|
+
}).pipe(Effect.orElseSucceed(() => false))
|
|
97
|
+
|
|
98
|
+
const describe = <E>(error: E): string => {
|
|
99
|
+
if (Predicate.hasProperty(error, "message") && Predicate.isString(error.message) && error.message !== "") {
|
|
100
|
+
return error.message
|
|
101
|
+
}
|
|
102
|
+
if (Predicate.hasProperty(error, "_tag") && Predicate.isString(error._tag)) return error._tag
|
|
103
|
+
return String(error)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** `Command.runWith` prints help and user errors itself before failing with them; nothing else. */
|
|
107
|
+
const renderedByRunner = <E>(error: E): boolean =>
|
|
108
|
+
CliError.isCliError(error) && (error._tag === "ShowHelp" || error._tag === "UserError")
|
|
109
|
+
|
|
110
|
+
/** Print a failed run's cause to stderr: each failure's message, or the full cause when verbose. */
|
|
111
|
+
export const handleCliError = <E>(cause: Cause.Cause<E>, options: { readonly verbose: boolean }): Effect.Effect<void> =>
|
|
112
|
+
options.verbose
|
|
113
|
+
? Console.error(Cause.pretty(cause))
|
|
114
|
+
: Effect.forEach(cause.reasons, (reason) => {
|
|
115
|
+
if (Cause.isFailReason(reason)) {
|
|
116
|
+
return renderedByRunner(reason.error) ? Effect.void : Console.error(describe(reason.error))
|
|
117
|
+
}
|
|
118
|
+
if (Cause.isDieReason(reason)) return Console.error(`Error: ${describe(reason.defect)}`)
|
|
119
|
+
return Console.error("Interrupted")
|
|
120
|
+
}, { discard: true })
|
|
121
|
+
|
|
122
|
+
const reportFailure = <E>(cause: Cause.Cause<E>): Effect.Effect<void, never, Stdio.Stdio> =>
|
|
123
|
+
Effect.gen(function*() {
|
|
124
|
+
const stdio = yield* Stdio.Stdio
|
|
125
|
+
const verbose = yield* stdio.args.pipe(Effect.flatMap(verboseRequested), Effect.orElseSucceed(() => false))
|
|
126
|
+
yield* handleCliError(cause, { verbose })
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Report a CLI program's failure with {@link handleCliError} and fail with the same cause. Apply it
|
|
131
|
+
* before providing `Stdio`, which it reads the arguments from.
|
|
132
|
+
*/
|
|
133
|
+
export const withCliErrorHandling = <A, E, R>(
|
|
134
|
+
program: Effect.Effect<A, E, R>
|
|
135
|
+
): Effect.Effect<A, E, R | Stdio.Stdio> =>
|
|
136
|
+
program.pipe(Effect.catchCause((cause) => reportFailure(cause).pipe(Effect.andThen(Effect.failCause(cause)))))
|
|
@@ -19,6 +19,7 @@ import * as Console from "effect/Console"
|
|
|
19
19
|
import type * as Context from "effect/Context"
|
|
20
20
|
import * as Effect from "effect/Effect"
|
|
21
21
|
import * as Option from "effect/Option"
|
|
22
|
+
import * as Schema from "effect/Schema"
|
|
22
23
|
import type { AtlassianCliAuth, AtlassianCliDescriptor } from "./AtlassianCliAuth.js"
|
|
23
24
|
import { openBrowser } from "./openBrowser.js"
|
|
24
25
|
|
|
@@ -58,6 +59,15 @@ export const scopeInstructions = (descriptor: AtlassianCliDescriptor, apiSection
|
|
|
58
59
|
].join("\n")
|
|
59
60
|
}
|
|
60
61
|
|
|
62
|
+
/** `auth use` or `auth remove` named no stored profile. The CLI prints the message and exits non-zero. */
|
|
63
|
+
export class ProfileNotFoundError extends Schema.TaggedError<ProfileNotFoundError>()("ProfileNotFoundError", {
|
|
64
|
+
selector: Schema.String,
|
|
65
|
+
message: Schema.String
|
|
66
|
+
}) {}
|
|
67
|
+
|
|
68
|
+
const profileNotFound = (selector: string) =>
|
|
69
|
+
new ProfileNotFoundError({ selector, message: `Profile not found: ${selector}` })
|
|
70
|
+
|
|
61
71
|
/** Print the URL, then try to open it; a browser that never opened fails the command. */
|
|
62
72
|
const visit = (url: string) => Console.log(`Opening ${url}`).pipe(Effect.andThen(openBrowser(url)))
|
|
63
73
|
|
|
@@ -202,7 +212,7 @@ After adding scopes, run: ${loginHint}
|
|
|
202
212
|
Effect.flatMap(
|
|
203
213
|
auth.switchProfile(profile),
|
|
204
214
|
(selected) =>
|
|
205
|
-
|
|
215
|
+
selected === null ? Effect.fail(profileNotFound(profile)) : Console.log(`Active profile: ${selected.name}`)
|
|
206
216
|
)
|
|
207
217
|
)
|
|
208
218
|
).pipe(Command.withDescription("Switch active auth profile"))
|
|
@@ -215,7 +225,7 @@ After adding scopes, run: ${loginHint}
|
|
|
215
225
|
Effect.flatMap(
|
|
216
226
|
auth.removeProfile(profile),
|
|
217
227
|
(removed) =>
|
|
218
|
-
|
|
228
|
+
removed === null ? Effect.fail(profileNotFound(profile)) : Console.log(`Removed profile: ${removed.name}`)
|
|
219
229
|
)
|
|
220
230
|
)
|
|
221
231
|
).pipe(Command.withDescription("Remove stored auth profile"))
|
package/src/cli-auth/index.ts
CHANGED
|
@@ -14,7 +14,13 @@ export {
|
|
|
14
14
|
type LoginOptions,
|
|
15
15
|
makeAtlassianCliAuth
|
|
16
16
|
} from "./AtlassianCliAuth.js"
|
|
17
|
-
export {
|
|
17
|
+
export {
|
|
18
|
+
type AuthCommandOptions,
|
|
19
|
+
type AuthCommandService,
|
|
20
|
+
makeAuthCommand,
|
|
21
|
+
ProfileNotFoundError,
|
|
22
|
+
scopeInstructions
|
|
23
|
+
} from "./authCommand.js"
|
|
18
24
|
export { HttpServerFactoryLive, NodeCliAuthLive } from "./internal/NodeLayers.js"
|
|
19
25
|
export { type HttpServerFactory, HttpServerFactoryTag, makeHttpServerFactory } from "./internal/oauthServer.js"
|
|
20
26
|
export { BrowserOpenError, openBrowser } from "./openBrowser.js"
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/** @effect-diagnostics strictEffectProvide:skip-file */
|
|
2
|
+
/**
|
|
3
|
+
* How every Atlassian CLI reports a failed run: the message by default, the full cause when asked,
|
|
4
|
+
* nothing for what `Command.runWith` already rendered, and the exit unchanged.
|
|
5
|
+
*/
|
|
6
|
+
import { NodeServices } from "@effect/platform-node"
|
|
7
|
+
import { describe, expect, it } from "@effect/vitest"
|
|
8
|
+
import { ConfigProvider } from "effect"
|
|
9
|
+
import * as Cause from "effect/Cause"
|
|
10
|
+
import { Argument, CliError, Command } from "effect/cli"
|
|
11
|
+
import * as Console from "effect/Console"
|
|
12
|
+
import * as Effect from "effect/Effect"
|
|
13
|
+
import * as Exit from "effect/Exit"
|
|
14
|
+
import * as Schema from "effect/Schema"
|
|
15
|
+
import * as Stdio from "effect/Stdio"
|
|
16
|
+
import {
|
|
17
|
+
commandArgs,
|
|
18
|
+
handleCliError,
|
|
19
|
+
Verbose,
|
|
20
|
+
verboseFlagIn,
|
|
21
|
+
verboseRequested,
|
|
22
|
+
withCliErrorHandling
|
|
23
|
+
} from "../src/cli/index.js"
|
|
24
|
+
|
|
25
|
+
class ProfileGone extends Schema.TaggedError<ProfileGone>()("ProfileGone", { message: Schema.String }) {}
|
|
26
|
+
class Bare extends Schema.TaggedError<Bare>()("Bare", {}) {}
|
|
27
|
+
|
|
28
|
+
const stderrOf = <E>(cause: Cause.Cause<E>, verbose: boolean) =>
|
|
29
|
+
Effect.gen(function*() {
|
|
30
|
+
const lines: Array<string> = []
|
|
31
|
+
const capture: Console.Console = Object.assign(Object.create(console), {
|
|
32
|
+
error: (...parts: ReadonlyArray<unknown>) => lines.push(parts.join(" "))
|
|
33
|
+
})
|
|
34
|
+
yield* handleCliError(cause, { verbose }).pipe(Effect.provideService(Console.Console, capture))
|
|
35
|
+
return lines
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
describe("handleCliError", () => {
|
|
39
|
+
it.effect("prints a failure's message, a bare tagged error's tag, a defect and an interruption", () =>
|
|
40
|
+
Effect.gen(function*() {
|
|
41
|
+
expect(yield* stderrOf(Cause.fail(new ProfileGone({ message: "Profile not found: x" })), false)).toEqual([
|
|
42
|
+
"Profile not found: x"
|
|
43
|
+
])
|
|
44
|
+
expect(yield* stderrOf(Cause.fail(new Bare()), false)).toEqual(["Bare"])
|
|
45
|
+
expect(yield* stderrOf(Cause.die(new Error("boom")), false)).toEqual(["Error: boom"])
|
|
46
|
+
expect(yield* stderrOf(Cause.interrupt(), false)).toEqual(["Interrupted"])
|
|
47
|
+
}))
|
|
48
|
+
|
|
49
|
+
it.effect("skips what Command.runWith already rendered", () =>
|
|
50
|
+
Effect.gen(function*() {
|
|
51
|
+
const help = new CliError.ShowHelp({ commandPath: ["jira"], errors: [] })
|
|
52
|
+
expect(yield* stderrOf(Cause.fail(help), false)).toEqual([])
|
|
53
|
+
}))
|
|
54
|
+
|
|
55
|
+
it.effect("prints the full cause, stack included, when verbose", () =>
|
|
56
|
+
Effect.gen(function*() {
|
|
57
|
+
const lines = yield* stderrOf(Cause.die(new Error("boom")), true)
|
|
58
|
+
expect(lines.join("\n")).toContain("boom")
|
|
59
|
+
expect(lines.join("\n")).toContain("at ")
|
|
60
|
+
}))
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
describe("verbose", () => {
|
|
64
|
+
// The scanner runs before the CLI parses, so it must agree with the parser it stands in for.
|
|
65
|
+
const parsed = (args: ReadonlyArray<string>) =>
|
|
66
|
+
Effect.gen(function*() {
|
|
67
|
+
const seen: Array<boolean> = []
|
|
68
|
+
const probe = Command.make("probe", { words: Argument.String("word").pipe(Argument.variadic()) }, () =>
|
|
69
|
+
Effect.gen(function*() {
|
|
70
|
+
seen.push(yield* Verbose)
|
|
71
|
+
}))
|
|
72
|
+
const root = Command.make("tool").pipe(Command.withSubcommands([probe]), Command.withGlobalFlags([Verbose]))
|
|
73
|
+
const exit = yield* Command.runWith(root, { version: "0" })(args).pipe(
|
|
74
|
+
Effect.provide(NodeServices.layer),
|
|
75
|
+
Effect.exit
|
|
76
|
+
)
|
|
77
|
+
return { exit, verbose: seen[0] }
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
it.effect("reads --verbose and routes the command words exactly as the parser does", () =>
|
|
81
|
+
Effect.gen(function*() {
|
|
82
|
+
const cases: ReadonlyArray<ReadonlyArray<string>> = [
|
|
83
|
+
["probe", "x"],
|
|
84
|
+
["--verbose", "probe", "x"],
|
|
85
|
+
["--verbose", "false", "probe", "x"],
|
|
86
|
+
["--verbose", "true", "probe", "x"],
|
|
87
|
+
["--verbose=false", "probe", "x"],
|
|
88
|
+
["--verbose=yes", "probe", "x"],
|
|
89
|
+
["probe", "x", "--verbose"],
|
|
90
|
+
["--verbose", "--no-verbose", "probe", "x"],
|
|
91
|
+
["--no-verbose", "--verbose", "probe", "x"],
|
|
92
|
+
["probe", "--", "--verbose"],
|
|
93
|
+
["probe", "x", "--verbose", "FALSE"],
|
|
94
|
+
["probe", "x", "--verbose", "True"]
|
|
95
|
+
]
|
|
96
|
+
for (const args of cases) {
|
|
97
|
+
const { exit, verbose } = yield* parsed(args)
|
|
98
|
+
expect(Exit.isSuccess(exit), JSON.stringify(args)).toBe(true)
|
|
99
|
+
expect(verboseFlagIn(args), JSON.stringify(args)).toBe(verbose)
|
|
100
|
+
expect(commandArgs(args)[0], JSON.stringify(args)).toBe("probe")
|
|
101
|
+
// A literal the parser does not consume stays a positional word.
|
|
102
|
+
for (const word of ["FALSE", "True"]) {
|
|
103
|
+
if (args.includes(word)) expect(commandArgs(args), JSON.stringify(args)).toContain(word)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}))
|
|
107
|
+
|
|
108
|
+
it.effect("does not report verbose for a value the parser rejects, and the rejection is printed", () =>
|
|
109
|
+
Effect.gen(function*() {
|
|
110
|
+
expect(verboseFlagIn(["--verbose=bogus", "probe"])).toBe(false)
|
|
111
|
+
expect(verboseFlagIn(["--verbose=FALSE", "probe"])).toBe(false)
|
|
112
|
+
const { exit } = yield* parsed(["--verbose=bogus", "probe", "x"])
|
|
113
|
+
expect(Exit.isFailure(exit)).toBe(true)
|
|
114
|
+
if (Exit.isFailure(exit)) {
|
|
115
|
+
const lines = yield* stderrOf(exit.cause, false)
|
|
116
|
+
expect(lines).toHaveLength(1)
|
|
117
|
+
expect(lines[0]).toContain("bogus")
|
|
118
|
+
}
|
|
119
|
+
}))
|
|
120
|
+
|
|
121
|
+
it.effect("turns on for DEBUG=1 only", () =>
|
|
122
|
+
Effect.gen(function*() {
|
|
123
|
+
const withEnv = (env: Record<string, string>) =>
|
|
124
|
+
verboseRequested([]).pipe(Effect.provide(ConfigProvider.layer(ConfigProvider.fromEnv({ env }))))
|
|
125
|
+
expect(yield* withEnv({ DEBUG: "1" })).toBe(true)
|
|
126
|
+
expect(yield* withEnv({ DEBUG: "express:*" })).toBe(false)
|
|
127
|
+
expect(yield* withEnv({})).toBe(false)
|
|
128
|
+
}))
|
|
129
|
+
|
|
130
|
+
it.effect("reports with --verbose from the arguments, and fails with the same cause", () =>
|
|
131
|
+
Effect.gen(function*() {
|
|
132
|
+
const lines: Array<string> = []
|
|
133
|
+
const capture: Console.Console = Object.assign(Object.create(console), {
|
|
134
|
+
error: (...parts: ReadonlyArray<unknown>) => lines.push(parts.join(" "))
|
|
135
|
+
})
|
|
136
|
+
const failure = new ProfileGone({ message: "Profile not found: x" })
|
|
137
|
+
const exit = yield* withCliErrorHandling(Effect.fail(failure)).pipe(
|
|
138
|
+
Effect.provideService(Console.Console, capture),
|
|
139
|
+
Effect.provide(Stdio.layerTest({ args: Effect.succeed(["auth", "use", "x", "--verbose"]) })),
|
|
140
|
+
Effect.exit
|
|
141
|
+
)
|
|
142
|
+
expect(Exit.isFailure(exit) && Cause.squash(exit.cause)).toBe(failure)
|
|
143
|
+
expect(lines.join("\n")).toContain("ProfileGone")
|
|
144
|
+
}))
|
|
145
|
+
})
|
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { NodeServices } from "@effect/platform-node"
|
|
8
8
|
import { describe, expect, it } from "@effect/vitest"
|
|
9
|
+
import * as Cause from "effect/Cause"
|
|
9
10
|
import { Command } from "effect/cli"
|
|
10
11
|
import * as Console from "effect/Console"
|
|
11
12
|
import * as Context from "effect/Context"
|
|
12
13
|
import * as Effect from "effect/Effect"
|
|
14
|
+
import * as Exit from "effect/Exit"
|
|
13
15
|
import * as Layer from "effect/Layer"
|
|
14
16
|
import * as PlatformError from "effect/PlatformError"
|
|
15
17
|
import { ChildProcessSpawner } from "effect/process"
|
|
@@ -144,10 +146,16 @@ describe("makeAuthCommand", () => {
|
|
|
144
146
|
expect((yield* run(["status"], {})).output).toContain("Not logged in. Use 'jira auth login' to authenticate.")
|
|
145
147
|
}))
|
|
146
148
|
|
|
147
|
-
it.effect("profiles marks the active one; use and remove
|
|
149
|
+
it.effect("profiles marks the active one; use and remove fail typed on an unknown selector", () =>
|
|
148
150
|
Effect.gen(function*() {
|
|
149
151
|
expect((yield* run(["profiles"], { active: profile })).output).toContain("* cloud-1:account-1")
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
for (const subcommand of ["use", "remove"]) {
|
|
153
|
+
const { exit } = yield* run([subcommand, "nope"], {})
|
|
154
|
+
expect(Exit.isFailure(exit) && Cause.squash(exit.cause), subcommand).toMatchObject({
|
|
155
|
+
_tag: "ProfileNotFoundError",
|
|
156
|
+
message: "Profile not found: nope",
|
|
157
|
+
selector: "nope"
|
|
158
|
+
})
|
|
159
|
+
}
|
|
152
160
|
}))
|
|
153
161
|
})
|
|
@@ -4,6 +4,7 @@ import { describe, expect, it } from "@effect/vitest"
|
|
|
4
4
|
import * as Effect from "effect/Effect"
|
|
5
5
|
import * as FileSystem from "effect/FileSystem"
|
|
6
6
|
import * as Path from "effect/Path"
|
|
7
|
+
import * as Predicate from "effect/Predicate"
|
|
7
8
|
import { ChildProcess, ChildProcessSpawner } from "effect/process"
|
|
8
9
|
import * as Schema from "effect/Schema"
|
|
9
10
|
import * as Stream from "effect/Stream"
|
|
@@ -19,10 +20,11 @@ const Findings = Schema.fromJsonString(Schema.Array(Schema.Struct({ file: Schema
|
|
|
19
20
|
describe("CLI auth guardrails", () => {
|
|
20
21
|
for (const [name, config] of Object.entries(configs)) {
|
|
21
22
|
it(`${name} resolves CLI auth from source rather than stale build output`, () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
)
|
|
23
|
+
const aliases = config.resolve?.alias
|
|
24
|
+
const entries = Array.isArray(aliases) ? aliases : []
|
|
25
|
+
const specifier = "@knpkv/atlassian-common/cli-auth"
|
|
26
|
+
const cliAuth = entries.find(({ find }) => Predicate.isString(find) ? find === specifier : find.test(specifier))
|
|
27
|
+
expect(cliAuth?.replacement).toBe(new URL("../src/cli-auth/index.ts", import.meta.url).pathname)
|
|
26
28
|
})
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -137,9 +137,17 @@ const observedServerFactory = (stopped: Ref.Ref<boolean>) =>
|
|
|
137
137
|
)
|
|
138
138
|
)
|
|
139
139
|
|
|
140
|
-
const captureConsole = (lines: Array<string>): Console.Console =>
|
|
140
|
+
const captureConsole = (lines: Array<string>, waiting?: Deferred.Deferred<void>): Console.Console =>
|
|
141
141
|
Object.assign(Object.create(console), {
|
|
142
|
-
log: (...args: ReadonlyArray<unknown>) =>
|
|
142
|
+
log: (...args: ReadonlyArray<unknown>) => {
|
|
143
|
+
const line = args.join(" ")
|
|
144
|
+
lines.push(line)
|
|
145
|
+
// Login prints this right before it starts its authorization deadline,
|
|
146
|
+
// without suspending in between.
|
|
147
|
+
if (waiting !== undefined && line.startsWith("Waiting for authorization")) {
|
|
148
|
+
Deferred.doneUnsafe(waiting, Effect.void)
|
|
149
|
+
}
|
|
150
|
+
},
|
|
143
151
|
error: (...args: ReadonlyArray<unknown>) => lines.push(`stderr: ${args.join(" ")}`)
|
|
144
152
|
})
|
|
145
153
|
|
|
@@ -235,6 +243,7 @@ describe("Atlassian CLI login", () => {
|
|
|
235
243
|
const attempts = yield* Ref.make<ReadonlyArray<string>>([])
|
|
236
244
|
const lines: Array<string> = []
|
|
237
245
|
const stopped = yield* Ref.make(false)
|
|
246
|
+
const waiting = yield* Deferred.make<void>()
|
|
238
247
|
|
|
239
248
|
const login = yield* makeAtlassianCliAuth(authOptions).pipe(
|
|
240
249
|
Effect.flatMap((auth) => auth.login()),
|
|
@@ -245,18 +254,14 @@ describe("Atlassian CLI login", () => {
|
|
|
245
254
|
failingLaunchers(launched, attempts),
|
|
246
255
|
observedServerFactory(stopped)
|
|
247
256
|
)),
|
|
248
|
-
Effect.provideService(Console.Console, captureConsole(lines)),
|
|
257
|
+
Effect.provideService(Console.Console, captureConsole(lines, waiting)),
|
|
249
258
|
Effect.flip,
|
|
250
259
|
Effect.forkChild({ startImmediately: true })
|
|
251
260
|
)
|
|
252
261
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
for (let minute = 0; minute < 10; minute++) {
|
|
257
|
-
yield* TestClock.adjust("1 minute")
|
|
258
|
-
yield* Effect.yieldNow
|
|
259
|
-
}
|
|
262
|
+
// The login fiber has started its five-minute deadline by the time this resumes.
|
|
263
|
+
yield* Deferred.await(waiting)
|
|
264
|
+
yield* TestClock.adjust("5 minutes")
|
|
260
265
|
const error = yield* Fiber.join(login)
|
|
261
266
|
|
|
262
267
|
expect(error._tag).toBe("OAuthError")
|
package/vitest.config.ts
CHANGED