Skip to content

Commit 24aca6b

Browse files
committed
fix(cli): accept bare remote urls
1 parent 4474bdd commit 24aca6b

19 files changed

Lines changed: 180 additions & 38 deletions

packages/interfacectl-cli/dist/commands/analyze.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/interfacectl-cli/dist/commands/analyze.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { mkdir, writeFile } from "node:fs/promises";
33
import path from "node:path";
44
import { inspectAuthProfile } from "../utils/auth-profiles.js";
55
import { analyzeSurface, stringifyStableArtifact, } from "../utils/first-run-analysis.js";
6-
import { suggestSurfaceIdFromPath, suggestSurfaceIdFromUrl, suggestSurfaceName } from "../utils/onboarding.js";
6+
import { normalizeRemoteUrlInput, suggestSurfaceIdFromPath, suggestSurfaceIdFromUrl, suggestSurfaceName, } from "../utils/onboarding.js";
77
import { redactSensitiveText } from "../utils/redaction.js";
88
const DEFAULT_OUT_DIR = "contracts/generated";
99
function normalizeSurfaceId(raw) {
@@ -39,6 +39,9 @@ export async function runAnalyzeCommand(options) {
3939
const rootDir = process.cwd();
4040
try {
4141
const sourceMode = inferSourceMode(options);
42+
const normalizedUrl = sourceMode === "remote-url" && options.url
43+
? normalizeRemoteUrlInput(options.url)
44+
: undefined;
4245
if (sourceMode === "remote-url" && !options.url) {
4346
throw new Error("Missing required --url for remote-url analysis.");
4447
}
@@ -52,16 +55,16 @@ export async function runAnalyzeCommand(options) {
5255
}
5356
}
5457
const surfaceSuggestion = options.surface ??
55-
(sourceMode === "remote-url" && options.url
56-
? suggestSurfaceIdFromUrl(options.url)
58+
(sourceMode === "remote-url" && normalizedUrl
59+
? suggestSurfaceIdFromUrl(normalizedUrl)
5760
: suggestSurfaceIdFromPath(options.appRoot ?? "surface"));
5861
const surfaceId = normalizeSurfaceId(surfaceSuggestion);
5962
const surfaceName = options.surfaceName ?? suggestSurfaceName(surfaceId);
6063
let authMode = "none";
6164
let authProfileName;
6265
let authStorageState;
63-
if (sourceMode === "remote-url" && options.authProfile && options.url) {
64-
const url = new URL(options.url);
66+
if (sourceMode === "remote-url" && options.authProfile && normalizedUrl) {
67+
const url = new URL(normalizedUrl);
6568
const inspection = await inspectAuthProfile(options.authProfile, url.hostname);
6669
if (inspection.status !== "ready" || !inspection.profile || !inspection.storageState) {
6770
const reason = inspection.status === "missing"
@@ -83,7 +86,7 @@ export async function runAnalyzeCommand(options) {
8386
surfaceName,
8487
sourceMode,
8588
appRoot: options.appRoot,
86-
url: options.url,
89+
url: normalizedUrl,
8790
surfaceKindOverride: options.surfaceKind,
8891
authMode,
8992
authProfileName,
@@ -95,7 +98,7 @@ export async function runAnalyzeCommand(options) {
9598
console.log(`Wrote analysis: ${outputPath}`);
9699
console.log(`Inferred surface kind: ${result.analysis.classification.inferredKind} (${result.analysis.classification.confidence.toFixed(2)})`);
97100
if (result.analysis.sourceHealth.status !== "ok") {
98-
console.log(`Source access: ${result.analysis.sourceHealth.status} (${result.analysis.sourceHealth.confidence}) at ${result.analysis.sourceHealth.finalUrl ?? options.url}`);
101+
console.log(`Source access: ${result.analysis.sourceHealth.status} (${result.analysis.sourceHealth.confidence}) at ${result.analysis.sourceHealth.finalUrl ?? normalizedUrl}`);
99102
}
100103
if (result.analysis.classification.requiresConfirmation && !options.surfaceKind) {
101104
console.log("Note: classification is low confidence; pass --surface-kind to confirm seeding intent.");

packages/interfacectl-cli/dist/commands/auth.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/interfacectl-cli/dist/commands/auth.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { captureBrowserStorageState, observeRemotePage } from "../utils/browser-session.js";
22
import { clearAuthProfiles, getAuthStorageMode, inspectAuthProfile, isLegacyAuthProfile, isProfileExpired, isProfileReplayReady, listAuthProfiles, saveReplayAuthProfile, } from "../utils/auth-profiles.js";
3+
import { normalizeRemoteUrlInput } from "../utils/onboarding.js";
34
function buildProfileStatus(profile) {
45
if (!profile) {
56
return "missing";
@@ -54,7 +55,7 @@ export async function runAuthCaptureCommand(options) {
5455
return 1;
5556
}
5657
try {
57-
const requestedUrl = new URL(options.url);
58+
const requestedUrl = new URL(normalizeRemoteUrlInput(options.url));
5859
const captured = await captureBrowserStorageState({
5960
url: requestedUrl.toString(),
6061
});
@@ -105,7 +106,8 @@ export async function runAuthTestCommand(options) {
105106
console.error("Missing --profile for auth test.");
106107
return 1;
107108
}
108-
const domain = options.url ? new URL(options.url).hostname : options.domain;
109+
const normalizedUrl = options.url ? normalizeRemoteUrlInput(options.url) : undefined;
110+
const domain = normalizedUrl ? new URL(normalizedUrl).hostname : options.domain;
109111
if (!domain) {
110112
if (options.format === "json") {
111113
console.log(JSON.stringify({ ok: false, error: "Provide --domain or --url for auth test." }, null, 2));
@@ -158,8 +160,9 @@ export async function runAuthTestCommand(options) {
158160
return 0;
159161
}
160162
try {
163+
const targetUrl = normalizedUrl ?? normalizeRemoteUrlInput(options.url);
161164
const observation = await observeRemotePage({
162-
url: options.url,
165+
url: targetUrl,
163166
storageState: inspection.storageState,
164167
});
165168
const ok = new URL(observation.finalUrl).hostname === inspection.profile.domain &&

packages/interfacectl-cli/dist/commands/init.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/interfacectl-cli/dist/commands/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { runValidateExtractedCommand } from "./validate-extracted.js";
88
import { getAuthStorageMode, inspectAuthProfile, saveReplayAuthProfile, } from "../utils/auth-profiles.js";
99
import { captureBrowserStorageState, observeRemotePage } from "../utils/browser-session.js";
1010
import { analyzeSurface, stringifyStableArtifact, } from "../utils/first-run-analysis.js";
11-
import { emitOnboardingRunArtifact, suggestSurfaceIdFromPath, suggestSurfaceIdFromUrl, suggestSurfaceName, } from "../utils/onboarding.js";
11+
import { emitOnboardingRunArtifact, normalizeRemoteUrlInput, suggestSurfaceIdFromPath, suggestSurfaceIdFromUrl, suggestSurfaceName, } from "../utils/onboarding.js";
1212
import { inferSourceMode, normalizeSurfaceId, promptGateResolution, promptInteractiveInitInputs, promptSurfaceKindConfirmation, promptWriteConfirmation, } from "../utils/init-interactive.js";
1313
import { redactSensitiveText } from "../utils/redaction.js";
1414
const DEFAULT_OUT_DIR = "contracts/generated";
@@ -74,7 +74,7 @@ async function resolveInputs(options) {
7474
const surfaceName = options.surfaceName ?? suggestSurfaceName(surfaceId);
7575
return {
7676
sourceMode,
77-
url: options.url ? new URL(options.url).toString() : undefined,
77+
url: options.url ? normalizeRemoteUrlInput(options.url) : undefined,
7878
appRoot: options.appRoot,
7979
surfaceId,
8080
surfaceName,

packages/interfacectl-cli/dist/utils/init-interactive.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/interfacectl-cli/dist/utils/init-interactive.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import readline from "node:readline/promises";
22
import { stdin as input, stdout as output } from "node:process";
3-
import { suggestSurfaceIdFromPath, suggestSurfaceIdFromUrl, suggestSurfaceName, } from "./onboarding.js";
3+
import { normalizeRemoteUrlInput, suggestSurfaceIdFromPath, suggestSurfaceIdFromUrl, suggestSurfaceName, } from "./onboarding.js";
44
const VALID_SURFACE_KINDS = new Set(["marketing", "application", "unknown"]);
55
export function normalizeSurfaceId(raw) {
66
return raw
@@ -31,7 +31,7 @@ export async function promptInteractiveInitInputs(options) {
3131
inferredMode).toLowerCase();
3232
const sourceMode = rawMode === "remote-url" ? "remote-url" : "local-root";
3333
const url = sourceMode === "remote-url"
34-
? new URL(options.url ?? (await rl.question("Surface URL: ")).trim()).toString()
34+
? normalizeRemoteUrlInput(options.url ?? (await rl.question("Surface URL: ")).trim())
3535
: options.url?.trim() || undefined;
3636
const appRoot = sourceMode === "local-root"
3737
? (options.appRoot ?? (await rl.question("Local app root: "))).trim()

packages/interfacectl-cli/dist/utils/onboarding.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface BootstrapExtractionReport {
2828
};
2929
};
3030
}
31+
export declare function normalizeRemoteUrlInput(rawInput: string): string;
3132
export declare function suggestSurfaceIdFromUrl(rawUrl: string): string;
3233
export declare function suggestSurfaceName(surfaceId: string): string;
3334
export declare function suggestSurfaceIdFromPath(rawPath: string): string;

packages/interfacectl-cli/dist/utils/onboarding.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)