Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/src/commands/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function createCheckCommand(): Command {
const validated = validate(CheckOptionsSchema, options, 'command options');
const progress = validated.format === 'json' ? undefined : new ConsoleProgress();
// ── Resolve repository URL ───────────────────────────────────────
let repoUrl = validated.repo;
let repoUrl = validated.repo ? normalizeToHttps(validated.repo) : undefined;
if (!repoUrl) {
let remote: string;
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function createConnectionsCommand(): Command {
.description('Display component relationships from the architecture model')
.argument('[model-path]', 'Directory containing architecture model files')
.option('--model-format <format>', 'Format of the architecture model', 'likec4')
.requiredOption('--repo <url>', 'GitHub or GitLab repository URL')
.requiredOption('--repo <url>', 'Repository URL')
.option('--output <format>', 'Result format (console, json)', 'console')
.action(async (modelPath: string | undefined, options: unknown) => {
try {
Expand Down
22 changes: 17 additions & 5 deletions packages/cli/src/utils/command-schemas.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
import { z } from 'zod';
import { stripUrlUserinfo } from '@erode-app/core';
import { isRepositoryHostUrl, parseRepoLocator, stripUrlUserinfo } from '@erode-app/core';

const RepositoryUrlSchema = z
.string()
.transform(stripUrlUserinfo)
.pipe(
z
.string()
.regex(
/^https?:\/\/(github\.com\/[^/]+\/[^/]+|gitlab\.com\/.+\/[^/]+)\/?$/,
'Provide a valid GitHub or GitLab repository URL'
.refine(
isRepositoryHostUrl,
'Provide a repository URL on GitHub, GitLab, Bitbucket, Azure DevOps, or a configured self-hosted host'
)
);

const RepositoryLocationSchema = z
.string()
.transform(stripUrlUserinfo)
.pipe(
z
.string()
.refine(
(value) => parseRepoLocator(value) !== null,
'Provide a repository URL or git remote (https://host/owner/repo or git@host:owner/repo.git)'
)
);

Expand Down Expand Up @@ -60,7 +72,7 @@ export const ConnectionsOptionsSchema = z.object({
});

export const CheckOptionsSchema = z.object({
repo: z.url().transform(stripUrlUserinfo).optional(),
repo: RepositoryLocationSchema.optional(),
modelFormat: z.string().default('likec4'),
staged: z.boolean().optional().default(false),
branch: z
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/adapters/likec4/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { resolve } from 'path';
import { fileURLToPath } from 'url';
import { CONFIG } from '../../utils/config.js';
import { validate } from '../../utils/validation.js';
import { isRepositoryHostUrl, normalizeRepositoryUrl } from '../url-utils.js';
import { isRepositoryHostUrl, normalizeRepositoryUrl } from '../../utils/repo-locator.js';
import { ErodeError, AdapterError, ConfigurationError, ErrorCode } from '../../errors.js';
import type {
ArchitectureModelAdapter,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/adapters/structurizr/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { readFile } from 'fs/promises';
import { existsSync, statSync } from 'fs';
import { join, resolve } from 'path';
import { validate, validatePath } from '../../utils/validation.js';
import { isRepositoryHostUrl, normalizeRepositoryUrl } from '../url-utils.js';
import { isRepositoryHostUrl, normalizeRepositoryUrl } from '../../utils/repo-locator.js';
import { AdapterError, ErrorCode } from '../../errors.js';
import { STRUCTURIZR_METADATA } from './metadata.js';
import { exportDslToJson } from './structurizr-cli.js';
Expand Down
101 changes: 0 additions & 101 deletions packages/core/src/adapters/url-utils.ts

This file was deleted.

4 changes: 4 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ export type { ModelPatcher, PatchResult, DslValidationResult } from './adapters/
export { resolveModelSource } from './utils/model-source.js';
export type { ResolvedModelSource } from './utils/model-source.js';

// Repository identity
export { parseRepoLocator, isRepositoryHostUrl } from './utils/repo-locator.js';
export type { RepoLocator, RepoPlatform } from './utils/repo-locator.js';

// Git diff (local check)
export {
generateGitDiff,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/pipelines/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ProgressReporter } from './progress.js';
import { SilentProgress } from './progress.js';
import { createAdapter } from '../adapters/adapter-factory.js';
import { validatePath } from '../utils/validation.js';
import { isRepositoryHostUrl } from '../adapters/url-utils.js';
import { isRepositoryHostUrl } from '../utils/repo-locator.js';

export interface ValidateOptions {
modelPath: string;
Expand Down
Loading
Loading