moodle-cli 0.9.0 → 0.9.2

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.
@@ -26452,7 +26452,7 @@ function stringValue(value) {
26452
26452
  }
26453
26453
 
26454
26454
  // src/version.ts
26455
- var VERSION = "0.9.0";
26455
+ var VERSION = "0.9.2";
26456
26456
 
26457
26457
  // src/worker/http.ts
26458
26458
  var HEALTH_PATH = "/healthz";
@@ -27004,7 +27004,12 @@ async function fetchWithSession(input3, init, moodleOrigin, cookie, fetchImpl =
27004
27004
  headers.delete("authorization");
27005
27005
  headers.delete("proxy-authorization");
27006
27006
  }
27007
- const response = await fetchImpl(url2.toString(), { ...init, method, body, headers: Object.fromEntries(headers), signal, redirect: "manual" });
27007
+ let response;
27008
+ try {
27009
+ response = await fetchImpl(url2.toString(), { ...init, method, body, headers: Object.fromEntries(headers), signal, redirect: "manual" });
27010
+ } catch (error62) {
27011
+ throw requestFailure(error62, url2, deadline);
27012
+ }
27008
27013
  if (!REDIRECT_STATUSES.has(response.status)) return response;
27009
27014
  const location = response.headers.get("location");
27010
27015
  if (!location) return response;
@@ -27025,6 +27030,25 @@ async function fetchWithSession(input3, init, moodleOrigin, cookie, fetchImpl =
27025
27030
  url2 = next;
27026
27031
  }
27027
27032
  }
27033
+ var RequestFailed = class extends Error {
27034
+ host;
27035
+ timedOut;
27036
+ constructor(host, timedOut, cause) {
27037
+ super(timedOut ? `${host} did not respond within ${REQUEST_TIMEOUT_MS / 1e3}s.` : `Could not reach ${host}: ${cause}`);
27038
+ this.name = "RequestFailed";
27039
+ this.host = host;
27040
+ this.timedOut = timedOut;
27041
+ }
27042
+ };
27043
+ function requestFailure(error62, url2, deadline) {
27044
+ if (deadline.aborted) {
27045
+ return new RequestFailed(url2.host, true);
27046
+ }
27047
+ if (!(error62 instanceof Error)) {
27048
+ return error62;
27049
+ }
27050
+ return new RequestFailed(url2.host, false, error62.cause instanceof Error ? error62.cause.message : error62.message);
27051
+ }
27028
27052
 
27029
27053
  // src/constants.ts
27030
27054
  var PACKAGE_NAME = "moodle-cli";
@@ -26452,7 +26452,7 @@ function stringValue(value) {
26452
26452
  }
26453
26453
 
26454
26454
  // src/version.ts
26455
- var VERSION = "0.9.0";
26455
+ var VERSION = "0.9.2";
26456
26456
 
26457
26457
  // src/worker/http.ts
26458
26458
  var HEALTH_PATH = "/healthz";
@@ -27004,7 +27004,12 @@ async function fetchWithSession(input3, init, moodleOrigin, cookie, fetchImpl =
27004
27004
  headers.delete("authorization");
27005
27005
  headers.delete("proxy-authorization");
27006
27006
  }
27007
- const response = await fetchImpl(url2.toString(), { ...init, method, body, headers: Object.fromEntries(headers), signal, redirect: "manual" });
27007
+ let response;
27008
+ try {
27009
+ response = await fetchImpl(url2.toString(), { ...init, method, body, headers: Object.fromEntries(headers), signal, redirect: "manual" });
27010
+ } catch (error62) {
27011
+ throw requestFailure(error62, url2, deadline);
27012
+ }
27008
27013
  if (!REDIRECT_STATUSES.has(response.status)) return response;
27009
27014
  const location = response.headers.get("location");
27010
27015
  if (!location) return response;
@@ -27025,6 +27030,25 @@ async function fetchWithSession(input3, init, moodleOrigin, cookie, fetchImpl =
27025
27030
  url2 = next;
27026
27031
  }
27027
27032
  }
27033
+ var RequestFailed = class extends Error {
27034
+ host;
27035
+ timedOut;
27036
+ constructor(host, timedOut, cause) {
27037
+ super(timedOut ? `${host} did not respond within ${REQUEST_TIMEOUT_MS / 1e3}s.` : `Could not reach ${host}: ${cause}`);
27038
+ this.name = "RequestFailed";
27039
+ this.host = host;
27040
+ this.timedOut = timedOut;
27041
+ }
27042
+ };
27043
+ function requestFailure(error62, url2, deadline) {
27044
+ if (deadline.aborted) {
27045
+ return new RequestFailed(url2.host, true);
27046
+ }
27047
+ if (!(error62 instanceof Error)) {
27048
+ return error62;
27049
+ }
27050
+ return new RequestFailed(url2.host, false, error62.cause instanceof Error ? error62.cause.message : error62.message);
27051
+ }
27028
27052
 
27029
27053
  // src/constants.ts
27030
27054
  var PACKAGE_NAME = "moodle-cli";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moodle-cli",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Terminal-first CLI for Moodle LMS",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -20,7 +20,7 @@ asks for confirmation (`--yes` skips it) and prints the receipt Moodle shows aft
20
20
  | moodle auth keepalive install | Install a macOS launch agent that renews the session periodically. | | --interval (value required)<br>--pretty<br>--json<br>--yaml<br>--table<br>--fields (value required) |
21
21
  | moodle auth keepalive status | Show whether the keepalive launch agent is installed. | | --pretty<br>--json<br>--yaml<br>--table<br>--fields (value required) |
22
22
  | moodle auth keepalive uninstall | Remove the keepalive launch agent. | | --pretty<br>--json<br>--yaml<br>--table<br>--fields (value required) |
23
- | moodle auth login | Extract a fresh session, opening the browser when needed. | | --pretty<br>--json<br>--yaml<br>--table<br>--fields (value required) |
23
+ | moodle auth login | Sign in through a browser the CLI controls, then capture the session. | | --paste<br>--pretty<br>--json<br>--yaml<br>--table<br>--fields (value required) |
24
24
  | moodle auth status | Show cached session freshness and keepalive state. | | --pretty<br>--json<br>--yaml<br>--table<br>--fields (value required) |
25
25
  | moodle commands | Describe the complete command tree. | | --pretty<br>--json<br>--yaml<br>--table<br>--fields (value required) |
26
26
  | moodle completion | Print shell completion for zsh, bash or fish. | <shell> | |