UNPKG

alepha

Version:

Easy-to-use modern TypeScript framework for building many kind of applications.

246 lines 8.36 kB
import { Static } from "alepha"; import { PackageManagerUtils } from "alepha/cli"; import { ConsoleColorProvider } from "alepha/logger"; import { FileSystemProvider, ShellProvider } from "alepha/system"; //#region ../../src/cli/vendor/atoms/vendorOptions.d.ts /** * Vendor configuration atom. * * Filled from the `vendor` section of `alepha.config.ts`. * Read by `VendorCommand` to resolve remote, branch, and packages. */ declare const vendorOptions: import("alepha").Atom<import("zod").ZodOptional<import("zod").ZodObject<{ remote: import("zod").ZodOptional<import("zod").ZodString>; branch: import("zod").ZodOptional<import("zod").ZodString>; dir: import("zod").ZodOptional<import("zod").ZodString>; packages: import("zod").ZodArray<import("zod").ZodString>; }, import("zod/v4/core").$strip>>, "alepha.cli.vendor.options">; /** * Type for vendor options. */ type VendorOptions = Static<typeof vendorOptions.schema>; //#endregion //#region ../../src/cli/vendor/services/VendorService.d.ts /** * Options for syncing vendored packages from a remote repository. */ interface VendorSyncOptions { root: string; remote: string; branch: string; dir: string; packages: string[]; force?: boolean; } /** * Result of a vendor sync operation. */ interface VendorSyncResult { synced: string[]; errors: string[]; aborted?: VendorDiffResult; } /** * Options for diffing vendored packages against a remote repository. */ interface VendorDiffOptions { root: string; remote: string; branch: string; dir: string; packages: string[]; } /** * A single line change within a modified file. */ interface VendorLineDiff { line: number; type: "added" | "removed"; text: string; } /** * A modified file with its line-level changes. */ interface VendorFileDiff { file: string; changes: VendorLineDiff[]; } /** * Diff result for a single vendored package. */ interface VendorPackageDiff { name: string; added: string[]; modified: VendorFileDiff[]; removed: string[]; } /** * Result of a vendor diff operation. */ interface VendorDiffResult { packages: VendorPackageDiff[]; totalChanges: number; } /** * Shape of the `<dir>/vendor.json` lock file (where `<dir>` is the * configured vendor directory, defaulting to `.vendor`). */ interface VendorLock { /** * Git remote URL the vendored sources were synced from. Recorded so any * downstream tool (AI agent, CI script) can re-fetch without needing the * project's `alepha.config.ts`. */ remote: string; /** * Commit hash of the synced sources. */ commit: string; } /** * Handles syncing and diffing vendored packages from a remote git repository. */ declare class VendorService { protected readonly log: import("alepha/logger").Logger; protected readonly shell: ShellProvider; protected readonly fs: FileSystemProvider; /** * Sync vendored packages from a remote repository. * * Without `force`: checks for local modifications by comparing the local * copy against the last-synced commit (stored in `<dir>/vendor.json`). * If modifications are found, aborts without touching local files. * * With `force` (or first sync): replaces local copies unconditionally. */ sync(options: VendorSyncOptions): Promise<VendorSyncResult>; /** * Diff vendored packages against the last-synced commit. * * Reads the commit hash from `<dir>/vendor.json`, clones at that commit, * and compares local files to detect modifications since last sync. */ diff(options: VendorDiffOptions): Promise<VendorDiffResult>; /** * Diff local packages against an already-cloned remote. */ protected diffFromClone(root: string, tmpDir: string, dir: string, packages: string[]): Promise<VendorDiffResult>; /** * Remove test files and ignored directories from a synced package. */ protected removeIgnoredFiles(pkgDir: string): Promise<void>; /** * Clone a remote repository into a temporary directory. */ protected cloneRemote(remote: string, branch: string): Promise<string>; /** * Clone a remote repository at a specific commit hash. */ protected cloneAtCommit(remote: string, commit: string): Promise<string>; /** * Get the HEAD commit hash from a cloned repository. */ protected getCommitHash(repoDir: string): Promise<string>; /** * Read the vendor lock file at `<root>/<dir>/vendor.json`. */ protected readLock(root: string, dir: string): Promise<VendorLock | undefined>; /** * Write the vendor lock file to `<root>/<dir>/vendor.json`. */ protected writeLock(root: string, dir: string, lock: VendorLock): Promise<void>; /** * Directories to ignore during diff comparisons. */ protected readonly ignoredPaths: string[]; /** * Check if a file path should be ignored during diff. */ protected isIgnored(filePath: string): boolean; /** * Recursively compare two directories and return the differences. */ protected diffDirectories(localDir: string, remoteDir: string): Promise<{ added: string[]; modified: VendorFileDiff[]; removed: string[]; }>; /** * Compute line-level differences between two file contents. * * Uses a longest-common-subsequence algorithm to produce minimal * added/removed line changes with accurate line numbers. */ protected computeLineDiff(baseline: string, local: string): VendorLineDiff[]; /** * Compute the longest common subsequence of two string arrays. */ protected longestCommonSubsequence(a: string[], b: string[]): string[]; } //#endregion //#region ../../src/cli/vendor/commands/VendorCommand.d.ts declare class VendorCommand { protected readonly log: import("alepha/logger").Logger; protected readonly options: Readonly<{ remote?: string | undefined; branch?: string | undefined; dir?: string | undefined; packages: string[]; } | undefined>; protected readonly vendorService: VendorService; protected readonly color: ConsoleColorProvider; protected readonly pm: PackageManagerUtils; /** * Ensure vendor config is present and return resolved options. */ protected resolveOptions(): { remote: string; branch: string; dir: string; packages: string[]; }; protected readonly syncFlags: import("zod").ZodObject<{ force: import("zod").ZodOptional<import("zod").ZodBoolean>; remote: import("zod").ZodOptional<import("zod").ZodString>; }, import("zod/v4/core").$strip>; protected readonly sync: import("alepha/command").CommandPrimitive<import("zod").ZodObject<{ force: import("zod").ZodOptional<import("zod").ZodBoolean>; remote: import("zod").ZodOptional<import("zod").ZodString>; }, import("zod/v4/core").$strip>, import("alepha").ZType, import("alepha").TObject>; protected readonly diff: import("alepha/command").CommandPrimitive<import("alepha").TObject, import("alepha").ZType, import("alepha").TObject>; protected printPackageDiff(pkg: VendorPackageDiff): void; readonly vendor: import("alepha/command").CommandPrimitive<import("alepha").TObject, import("alepha").ZType, import("alepha").TObject>; } //#endregion //#region ../../src/cli/vendor/index.d.ts /** * CLI plugin for vendoring Alepha packages into external projects. * * Copies package source code from a git remote into the current project's * `packages/` directory. Useful for corporate projects that need a local * copy of Alepha for AI tooling, audits, documentation, or quick fixes. * * Commands: * - `alepha vendor sync` — replace local packages with remote source * - `alepha vendor diff` — compare local packages against remote HEAD * * Configuration in `alepha.config.ts`: * * ```typescript * import { vendor } from "alepha/cli/vendor"; * * export default defineConfig({ * plugins: [ * vendor({ * branch: "main", * packages: ["alepha", "@alepha/payments-stripe"], * }), * ], * }); * ``` */ declare const AlephaCliVendorPlugin: import("alepha").Service<import("alepha").Module>; declare const vendor: (options: VendorOptions) => () => void; //#endregion export { AlephaCliVendorPlugin, VendorCommand, VendorDiffOptions, VendorDiffResult, VendorFileDiff, VendorLineDiff, VendorLock, VendorOptions, VendorPackageDiff, VendorService, VendorSyncOptions, VendorSyncResult, vendor, vendorOptions }; //# sourceMappingURL=index.d.ts.map