@mycadet/cli 0.13.0-dev.202610181425.b8556ca → 0.13.0-dev.202610181631.3760abb
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/node_modules/@mycadet/environments/src/__tests__/cloud-assistant-hub-url.test.ts +9 -17
- package/node_modules/@mycadet/environments/src/seeds.ts +6 -13
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/environments/src/__tests__/cloud-assistant-hub-url.test.ts +9 -17
- package/node_modules/@mycadet/local-mode/node_modules/@mycadet/environments/src/seeds.ts +6 -13
- package/package.json +1 -1
- package/src/lib/nginx-ingress.ts +9 -1
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Pins the environment-to-cloud-hub mapping in one place. Both consumers
|
|
3
3
|
* (the Capacitor shell's `server.url` and the CLI remote-web edge's
|
|
4
4
|
* `hubUrl`) read this helper, so this matrix is the single behavioral pin
|
|
5
|
-
* for the served URLs.
|
|
5
|
+
* for the served URLs. (The remote-web edge additionally folds local → dev
|
|
6
|
+
* at its own site: clients served through a tunnel cannot reach the local
|
|
7
|
+
* seed's loopback.)
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
10
|
import { describe, expect, test } from "bun:test";
|
|
@@ -10,29 +12,19 @@ import { describe, expect, test } from "bun:test";
|
|
|
10
12
|
import { cloudAssistantHubUrl, SEEDS } from "../index.js";
|
|
11
13
|
|
|
12
14
|
describe("cloudAssistantHubUrl", () => {
|
|
13
|
-
test("
|
|
14
|
-
|
|
15
|
-
"https://mycadet.ai/assistant",
|
|
16
|
-
);
|
|
17
|
-
expect(cloudAssistantHubUrl("staging")).toBe(
|
|
18
|
-
"https://staging.mycadet.ai/assistant",
|
|
19
|
-
);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test("every other environment falls back to the dev SPA", () => {
|
|
23
|
-
for (const name of ["dev", "test", "local", "unknown-env", undefined]) {
|
|
15
|
+
test("every known environment resolves to its own web origin", () => {
|
|
16
|
+
for (const name of ["production", "staging", "dev", "test", "local"]) {
|
|
24
17
|
expect(cloudAssistantHubUrl(name)).toBe(
|
|
25
|
-
|
|
18
|
+
`${SEEDS[name].webUrl}/assistant`,
|
|
26
19
|
);
|
|
27
20
|
}
|
|
28
21
|
});
|
|
29
22
|
|
|
30
|
-
test("
|
|
31
|
-
for (const name of ["
|
|
23
|
+
test("unknown environments fall back to the dev SPA", () => {
|
|
24
|
+
for (const name of ["unknown-env", undefined]) {
|
|
32
25
|
expect(cloudAssistantHubUrl(name)).toBe(
|
|
33
|
-
|
|
26
|
+
"https://dev.mycadet.ai/assistant",
|
|
34
27
|
);
|
|
35
28
|
}
|
|
36
|
-
expect(cloudAssistantHubUrl("local")).toBe(`${SEEDS.dev.webUrl}/assistant`);
|
|
37
29
|
});
|
|
38
30
|
});
|
|
@@ -26,15 +26,11 @@ function portBlock(base: number): PortMap {
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Base URL of the cloud-hosted assistant SPA (the "hub") for a deployment
|
|
29
|
-
* environment. The Capacitor mobile
|
|
30
|
-
* `server.url`, and the CLI's
|
|
31
|
-
* config as `hubUrl`, so the
|
|
32
|
-
* once.
|
|
33
|
-
*
|
|
34
|
-
* Only the cloud deployments (production, staging) serve the hosted SPA at
|
|
35
|
-
* their own web origin; every other environment (dev, test, local, unknown)
|
|
36
|
-
* falls back to the dev SPA, whose host serves remote clients that cannot
|
|
37
|
-
* reach a local or per-developer web URL.
|
|
29
|
+
* environment: always `${SEEDS[env].webUrl}/assistant`. The Capacitor mobile
|
|
30
|
+
* shell bakes this into native builds as `server.url`, and the CLI's
|
|
31
|
+
* remote-web edge stamps it into the served config as `hubUrl`, so the
|
|
32
|
+
* environment-to-hub mapping lives here exactly once. Unknown environment
|
|
33
|
+
* names fall back to the dev SPA defensively.
|
|
38
34
|
*
|
|
39
35
|
* The `/assistant` suffix is deliberate: booting on the bare host lands on
|
|
40
36
|
* the marketing page, whose CTA redirects to `mycadet.ai/assistant` and
|
|
@@ -46,10 +42,7 @@ function portBlock(base: number): PortMap {
|
|
|
46
42
|
* imports type-only so it stays loadable on its own.
|
|
47
43
|
*/
|
|
48
44
|
export function cloudAssistantHubUrl(envName: string | undefined): string {
|
|
49
|
-
const seed =
|
|
50
|
-
envName === "production" || envName === "staging"
|
|
51
|
-
? SEEDS[envName]
|
|
52
|
-
: SEEDS.dev;
|
|
45
|
+
const seed = (envName && SEEDS[envName]) || SEEDS.dev;
|
|
53
46
|
return `${seed.webUrl}/assistant`;
|
|
54
47
|
}
|
|
55
48
|
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Pins the environment-to-cloud-hub mapping in one place. Both consumers
|
|
3
3
|
* (the Capacitor shell's `server.url` and the CLI remote-web edge's
|
|
4
4
|
* `hubUrl`) read this helper, so this matrix is the single behavioral pin
|
|
5
|
-
* for the served URLs.
|
|
5
|
+
* for the served URLs. (The remote-web edge additionally folds local → dev
|
|
6
|
+
* at its own site: clients served through a tunnel cannot reach the local
|
|
7
|
+
* seed's loopback.)
|
|
6
8
|
*/
|
|
7
9
|
|
|
8
10
|
import { describe, expect, test } from "bun:test";
|
|
@@ -10,29 +12,19 @@ import { describe, expect, test } from "bun:test";
|
|
|
10
12
|
import { cloudAssistantHubUrl, SEEDS } from "../index.js";
|
|
11
13
|
|
|
12
14
|
describe("cloudAssistantHubUrl", () => {
|
|
13
|
-
test("
|
|
14
|
-
|
|
15
|
-
"https://mycadet.ai/assistant",
|
|
16
|
-
);
|
|
17
|
-
expect(cloudAssistantHubUrl("staging")).toBe(
|
|
18
|
-
"https://staging.mycadet.ai/assistant",
|
|
19
|
-
);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test("every other environment falls back to the dev SPA", () => {
|
|
23
|
-
for (const name of ["dev", "test", "local", "unknown-env", undefined]) {
|
|
15
|
+
test("every known environment resolves to its own web origin", () => {
|
|
16
|
+
for (const name of ["production", "staging", "dev", "test", "local"]) {
|
|
24
17
|
expect(cloudAssistantHubUrl(name)).toBe(
|
|
25
|
-
|
|
18
|
+
`${SEEDS[name].webUrl}/assistant`,
|
|
26
19
|
);
|
|
27
20
|
}
|
|
28
21
|
});
|
|
29
22
|
|
|
30
|
-
test("
|
|
31
|
-
for (const name of ["
|
|
23
|
+
test("unknown environments fall back to the dev SPA", () => {
|
|
24
|
+
for (const name of ["unknown-env", undefined]) {
|
|
32
25
|
expect(cloudAssistantHubUrl(name)).toBe(
|
|
33
|
-
|
|
26
|
+
"https://dev.mycadet.ai/assistant",
|
|
34
27
|
);
|
|
35
28
|
}
|
|
36
|
-
expect(cloudAssistantHubUrl("local")).toBe(`${SEEDS.dev.webUrl}/assistant`);
|
|
37
29
|
});
|
|
38
30
|
});
|
|
@@ -26,15 +26,11 @@ function portBlock(base: number): PortMap {
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Base URL of the cloud-hosted assistant SPA (the "hub") for a deployment
|
|
29
|
-
* environment. The Capacitor mobile
|
|
30
|
-
* `server.url`, and the CLI's
|
|
31
|
-
* config as `hubUrl`, so the
|
|
32
|
-
* once.
|
|
33
|
-
*
|
|
34
|
-
* Only the cloud deployments (production, staging) serve the hosted SPA at
|
|
35
|
-
* their own web origin; every other environment (dev, test, local, unknown)
|
|
36
|
-
* falls back to the dev SPA, whose host serves remote clients that cannot
|
|
37
|
-
* reach a local or per-developer web URL.
|
|
29
|
+
* environment: always `${SEEDS[env].webUrl}/assistant`. The Capacitor mobile
|
|
30
|
+
* shell bakes this into native builds as `server.url`, and the CLI's
|
|
31
|
+
* remote-web edge stamps it into the served config as `hubUrl`, so the
|
|
32
|
+
* environment-to-hub mapping lives here exactly once. Unknown environment
|
|
33
|
+
* names fall back to the dev SPA defensively.
|
|
38
34
|
*
|
|
39
35
|
* The `/assistant` suffix is deliberate: booting on the bare host lands on
|
|
40
36
|
* the marketing page, whose CTA redirects to `mycadet.ai/assistant` and
|
|
@@ -46,10 +42,7 @@ function portBlock(base: number): PortMap {
|
|
|
46
42
|
* imports type-only so it stays loadable on its own.
|
|
47
43
|
*/
|
|
48
44
|
export function cloudAssistantHubUrl(envName: string | undefined): string {
|
|
49
|
-
const seed =
|
|
50
|
-
envName === "production" || envName === "staging"
|
|
51
|
-
? SEEDS[envName]
|
|
52
|
-
: SEEDS.dev;
|
|
45
|
+
const seed = (envName && SEEDS[envName]) || SEEDS.dev;
|
|
53
46
|
return `${seed.webUrl}/assistant`;
|
|
54
47
|
}
|
|
55
48
|
|
package/package.json
CHANGED
package/src/lib/nginx-ingress.ts
CHANGED
|
@@ -1269,11 +1269,19 @@ export async function startRemoteWebIngress(opts: {
|
|
|
1269
1269
|
) {
|
|
1270
1270
|
listenPort = recorded.listenPort;
|
|
1271
1271
|
}
|
|
1272
|
+
// The hub mapping is per-environment, but every client served by THIS edge
|
|
1273
|
+
// is remote (they arrived through the tunnel) and cannot reach a
|
|
1274
|
+
// developer's loopback — so a local environment serves the dev hub, whose
|
|
1275
|
+
// host is reachable from anywhere.
|
|
1276
|
+
const currentEnvName = getCurrentEnvironment().name;
|
|
1277
|
+
const hubUrl = cloudAssistantHubUrl(
|
|
1278
|
+
currentEnvName === "local" ? "dev" : currentEnvName,
|
|
1279
|
+
);
|
|
1272
1280
|
// The SPA config the served index must carry, computed up front so the
|
|
1273
1281
|
// reuse decision and the actual spawn share one value and cannot drift.
|
|
1274
1282
|
const spaOptions = includeWebApp
|
|
1275
1283
|
? {
|
|
1276
|
-
hubUrl
|
|
1284
|
+
hubUrl,
|
|
1277
1285
|
...(opts.assistantName ? { assistantName: opts.assistantName } : {}),
|
|
1278
1286
|
...(opts.assistantId ? { assistantId: opts.assistantId } : {}),
|
|
1279
1287
|
}
|