@mx-space/cli 0.6.6 → 0.6.8

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/bin/mxs.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { t as run } from "../mxs-DUkVdHhE.mjs";
2
+ import { t as run } from "../mxs-CCNd5SIa.mjs";
3
3
  export { run };
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as defaultMessageFor, c as tagToCode, i as codeForTag, l as toErrorEnvelope, n as defaultGlobalFlags, o as exitCodeForError, r as parseGlobalFlags, s as exitCodeForTag, t as run } from "./mxs-DUkVdHhE.mjs";
1
+ import { a as defaultMessageFor, c as tagToCode, i as codeForTag, l as toErrorEnvelope, n as defaultGlobalFlags, o as exitCodeForError, r as parseGlobalFlags, s as exitCodeForTag, t as run } from "./mxs-CCNd5SIa.mjs";
2
2
  export { codeForTag, defaultGlobalFlags, defaultMessageFor, exitCodeForError, exitCodeForTag, parseGlobalFlags, run, tagToCode, toErrorEnvelope };
@@ -9821,6 +9821,8 @@ const parseApiUrl = (input) => gen(function* () {
9821
9821
  baseUrl: match[1],
9822
9822
  apiVersion: Number(match[2])
9823
9823
  };
9824
+ const apiSuffix = url.match(/^(.*)\/api$/);
9825
+ if (apiSuffix) return { baseUrl: apiSuffix[1] };
9824
9826
  return { baseUrl: url };
9825
9827
  });
9826
9828
  const PROFILES_SUBDIR = "profiles";
@@ -10042,7 +10044,7 @@ var Config = class Config extends Tag$2("Config")() {
10042
10044
  };
10043
10045
  //#endregion
10044
10046
  //#region src/services/Auth.ts
10045
- const SUPPORTED_API_VERSIONS = [2];
10047
+ const SUPPORTED_API_VERSIONS = [3, 2];
10046
10048
  var Auth = class Auth extends Tag$2("Auth")() {
10047
10049
  /** Build the Auth Layer; depends on `Config` and `HttpClient`. */
10048
10050
  static Default = effect(Auth, gen(function* () {
@@ -10112,13 +10114,19 @@ function makeAuthService(http, config) {
10112
10114
  version: null
10113
10115
  }];
10114
10116
  let lastTransport = null;
10117
+ const attempted = [];
10115
10118
  for (const cand of candidates) {
10116
- const result = yield* sendJson(`${apiUrl}${cand.prefix}/ok`, "GET", void 0, { accept: "application/json" }).pipe(either);
10119
+ const probeUrl = `${apiUrl}${cand.prefix}/ok`;
10120
+ const result = yield* sendJson(probeUrl, "GET", void 0, { accept: "application/json" }).pipe(either);
10117
10121
  if (result._tag === "Left") {
10118
10122
  lastTransport = result.left;
10119
10123
  continue;
10120
10124
  }
10121
10125
  const res = result.right;
10126
+ attempted.push({
10127
+ url: probeUrl,
10128
+ status: res.status
10129
+ });
10122
10130
  if (res.status >= 200 && res.status < 300) {
10123
10131
  const apiVersion = cand.version ?? SUPPORTED_API_VERSIONS[0];
10124
10132
  return {
@@ -10132,7 +10140,7 @@ function makeAuthService(http, config) {
10132
10140
  if (lastTransport && lastTransport._tag !== "Generic") return yield* fail$2(lastTransport);
10133
10141
  return yield* fail$2(new AuthProbe({
10134
10142
  message: "cannot detect auth endpoint",
10135
- hint: "verify the URL points at a running mx-core server"
10143
+ hint: `tried: ${attempted.length > 0 ? attempted.map((a) => `${a.url} → ${a.status}`).join(", ") : "no responses"}. supply the site root (e.g. https://blog.example.com), not the API path. verify the server is reachable and runs a supported API version (${SUPPORTED_API_VERSIONS.join(", ")}).`
10136
10144
  }));
10137
10145
  });
10138
10146
  const requestDeviceCode = (authBase, clientId, scope = "openid profile email") => gen(function* () {
@@ -27517,10 +27525,20 @@ const login = make$13("login", { production: production$1 }, ({ production }) =>
27517
27525
  targetProfile = flagProfile?.trim() || (yield* config.readCurrent);
27518
27526
  }
27519
27527
  yield* renderer.emitInfoBlock(({ color }) => `${arrow(`probing ${apiUrl}…`, color)}`);
27520
- const probeResult = yield* auth.probe(apiUrl).pipe(mapError((e) => new Generic({
27521
- message: e.message ?? "auth probe failed",
27522
- cause: e
27523
- })));
27528
+ const probeResult = yield* auth.probe(apiUrl).pipe(catchTags({
27529
+ NetworkTimeout: (e) => fail$2(new Generic({
27530
+ message: e.message ?? "auth probe failed",
27531
+ cause: e
27532
+ })),
27533
+ NetworkDns: (e) => fail$2(new Generic({
27534
+ message: e.message ?? "auth probe failed",
27535
+ cause: e
27536
+ })),
27537
+ NetworkRefused: (e) => fail$2(new Generic({
27538
+ message: e.message ?? "auth probe failed",
27539
+ cause: e
27540
+ }))
27541
+ }));
27524
27542
  const code = yield* auth.requestDeviceCode(probeResult.authBase, DEFAULT_CLIENT_ID);
27525
27543
  yield* renderer.emitInfoBlock(({ color }) => {
27526
27544
  const ttl = humanDuration(code.expires_in);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mx-space/cli",
3
- "version": "0.6.6",
3
+ "version": "0.6.8",
4
4
  "description": "Command line interface for mx-space (mx-core) — auth, content, configuration",
5
5
  "keywords": [
6
6
  "mx-space",