UNPKG

alepha

Version:

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

1,801 lines 90.4 kB
import { Alepha, Static } from "alepha"; import { CliProvider, EnvUtils, RunnerMethod } from "alepha/command"; import { ConsoleColorProvider } from "alepha/logger"; import { FileSystemProvider, ShellProvider } from "alepha/system"; import { BrotliOptions, ZlibOptions, brotliCompress, gzip } from "node:zlib"; import { spawn } from "node:child_process"; import * as vite from "vite"; import { Logger, Plugin, ViteDevServer } from "vite"; import { DatabaseProvider } from "alepha/orm"; //#region ../../src/cli/core/alephaPackageJson.d.ts declare const alephaPackageJson: { name: string; description: string; author: string; version: string; type: string; engines: { node: string; bun: string; }; license: string; bin: string; main: string; types: string; files: string[]; dependencies: { "@biomejs/biome": string; "@redis/client": string; "@vitejs/plugin-react": string; dayjs: string; "drizzle-kit": string; "drizzle-orm": string; postgres: string; s3mini: string; tsx: string; typescript: string; vite: string; "vite-bundle-analyzer": string; vitest: string; zod: string; }; devDependencies: { "@cloudflare/workers-types": string; "@electric-sql/pglite": string; "@faker-js/faker": string; "@tailwindcss/vite": string; "@testing-library/dom": string; "@testing-library/react": string; "@types/bun": string; "@types/node": string; "@types/nodemailer": string; "@types/react": string; "@types/react-dom": string; "cron-schedule": string; jose: string; jsdom: string; nodemailer: string; "openid-client": string; "prom-client": string; react: string; "react-dom": string; "swagger-ui-dist": string; tailwindcss: string; tsdown: string; }; peerDependencies: { react: string; "react-dom": string; }; peerDependenciesMeta: { react: { optional: boolean; }; "react-dom": { optional: boolean; }; }; scarfSettings: { enabled: boolean; }; scripts: { lint: string; typecheck: string; test: string; build: string; "build:check": string; copy: string; }; homepage: string; repository: { type: string; url: string; }; keywords: string[]; exports: { "./api/audits": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/files": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/jobs": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/keys": { types: string; import: string; default: string; }; "./api/notifications": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/oauth": { types: string; import: string; default: string; }; "./api/organizations": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/parameters": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/payments": { types: string; import: string; default: string; }; "./api/subscriptions": { types: string; import: string; default: string; }; "./api/users": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/verifications": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./background": { types: string; workerd: string; import: string; default: string; }; "./batch": { types: string; import: string; default: string; }; "./bin": { types: string; import: string; default: string; }; "./bucket": { types: string; workerd: string; import: string; default: string; }; "./cache": { types: string; workerd: string; import: string; default: string; }; "./cache/database": { types: string; import: string; default: string; }; "./cache/redis": { types: string; import: string; default: string; }; "./captcha": { types: string; import: string; default: string; }; "./cli/config": { types: string; import: string; default: string; }; "./cli": { types: string; import: string; default: string; }; "./cli/devtools": { types: string; import: string; default: string; }; "./cli/i18n": { types: string; import: string; default: string; }; "./cli/platform": { types: string; import: string; default: string; }; "./cli/platform-lib": { types: string; import: string; default: string; }; "./cli/vendor": { types: string; import: string; default: string; }; "./command": { types: string; import: string; default: string; }; ".": { types: string; "react-native": string; workerd: string; browser: string; import: string; default: string; }; "./crypto": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./datetime": { types: string; import: string; default: string; }; "./email/brevo": { types: string; import: string; default: string; }; "./email/cloudflare": { types: string; import: string; default: string; }; "./email": { types: string; workerd: string; import: string; default: string; }; "./email/smtp": { types: string; import: string; default: string; }; "./fake": { types: string; import: string; default: string; }; "./lock": { types: string; import: string; default: string; }; "./lock/redis": { types: string; import: string; default: string; }; "./logger": { types: string; import: string; default: string; }; "./mcp": { types: string; import: string; default: string; }; "./orm": { types: string; "react-native": string; browser: string; bun: string; import: string; default: string; }; "./orm/postgres": { types: string; bun: string; import: string; default: string; }; "./queue": { types: string; workerd: string; import: string; default: string; }; "./queue/redis": { types: string; import: string; default: string; }; "./react/auth": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./react": { types: string; import: string; default: string; }; "./react/form": { types: string; import: string; default: string; }; "./react/head": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./react/i18n": { types: string; import: string; default: string; }; "./react/intro": { types: string; import: string; default: string; }; "./react/router": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./react/sitemap": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./react/testing": { types: string; import: string; default: string; }; "./react/ui": { types: string; import: string; default: string; }; "./redis": { types: string; bun: string; import: string; default: string; }; "./retry": { types: string; import: string; default: string; }; "./router": { types: string; import: string; default: string; }; "./scheduler": { types: string; workerd: string; import: string; default: string; }; "./security": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./server/auth": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./server/cookies": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./server": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./server/cors": { types: string; import: string; default: string; }; "./server/etag": { types: string; import: string; default: string; }; "./server/health": { types: string; import: string; default: string; }; "./server/links": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./server/metrics": { types: string; import: string; default: string; }; "./server/proxy": { types: string; import: string; default: string; }; "./server/rate-limit": { types: string; import: string; default: string; }; "./server/static": { types: string; import: string; default: string; }; "./server/swagger": { types: string; import: string; default: string; }; "./sms": { types: string; import: string; default: string; }; "./system": { types: string; "react-native": string; workerd: string; browser: string; import: string; default: string; }; "./topic": { types: string; import: string; default: string; }; "./topic/redis": { types: string; import: string; default: string; }; "./tsconfig.base": string; "./package.json": string; }; publishConfig: { main: string; types: string; bin: string; exports: { "./api/audits": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/files": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/jobs": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/keys": { types: string; import: string; default: string; }; "./api/notifications": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/oauth": { types: string; import: string; default: string; }; "./api/organizations": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/parameters": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/payments": { types: string; import: string; default: string; }; "./api/subscriptions": { types: string; import: string; default: string; }; "./api/users": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./api/verifications": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./background": { types: string; workerd: string; import: string; default: string; }; "./batch": { types: string; import: string; default: string; }; "./bin": { types: string; import: string; default: string; }; "./bucket": { types: string; workerd: string; import: string; default: string; }; "./cache": { types: string; workerd: string; import: string; default: string; }; "./cache/database": { types: string; import: string; default: string; }; "./cache/redis": { types: string; import: string; default: string; }; "./captcha": { types: string; import: string; default: string; }; "./cli/config": { types: string; import: string; default: string; }; "./cli": { types: string; import: string; default: string; }; "./cli/devtools": { types: string; import: string; default: string; }; "./cli/i18n": { types: string; import: string; default: string; }; "./cli/platform": { types: string; import: string; default: string; }; "./cli/platform-lib": { types: string; import: string; default: string; }; "./cli/vendor": { types: string; import: string; default: string; }; "./command": { types: string; import: string; default: string; }; ".": { types: string; "react-native": string; workerd: string; browser: string; import: string; default: string; }; "./crypto": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./datetime": { types: string; import: string; default: string; }; "./email/brevo": { types: string; import: string; default: string; }; "./email/cloudflare": { types: string; import: string; default: string; }; "./email": { types: string; workerd: string; import: string; default: string; }; "./email/smtp": { types: string; import: string; default: string; }; "./fake": { types: string; import: string; default: string; }; "./lock": { types: string; import: string; default: string; }; "./lock/redis": { types: string; import: string; default: string; }; "./logger": { types: string; import: string; default: string; }; "./mcp": { types: string; import: string; default: string; }; "./orm": { types: string; "react-native": string; browser: string; bun: string; import: string; default: string; }; "./orm/postgres": { types: string; bun: string; import: string; default: string; }; "./queue": { types: string; workerd: string; import: string; default: string; }; "./queue/redis": { types: string; import: string; default: string; }; "./react/auth": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./react": { types: string; import: string; default: string; }; "./react/form": { types: string; import: string; default: string; }; "./react/head": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./react/i18n": { types: string; import: string; default: string; }; "./react/intro": { types: string; import: string; default: string; }; "./react/router": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./react/sitemap": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./react/testing": { types: string; import: string; default: string; }; "./react/ui": { types: string; import: string; default: string; }; "./redis": { types: string; bun: string; import: string; default: string; }; "./retry": { types: string; import: string; default: string; }; "./router": { types: string; import: string; default: string; }; "./scheduler": { types: string; workerd: string; import: string; default: string; }; "./security": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./server/auth": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./server/cookies": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./server": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./server/cors": { types: string; import: string; default: string; }; "./server/etag": { types: string; import: string; default: string; }; "./server/health": { types: string; import: string; default: string; }; "./server/links": { types: string; "react-native": string; browser: string; import: string; default: string; }; "./server/metrics": { types: string; import: string; default: string; }; "./server/proxy": { types: string; import: string; default: string; }; "./server/rate-limit": { types: string; import: string; default: string; }; "./server/static": { types: string; import: string; default: string; }; "./server/swagger": { types: string; import: string; default: string; }; "./sms": { types: string; import: string; default: string; }; "./system": { types: string; "react-native": string; workerd: string; browser: string; import: string; default: string; }; "./topic": { types: string; import: string; default: string; }; "./topic/redis": { types: string; import: string; default: string; }; "./tsconfig.base": string; "./package.json": string; }; }; }; declare const version: string; //#endregion //#region ../../src/cli/core/atoms/appEntryOptions.d.ts declare const appEntryOptions: import("alepha").Atom<import("zod").ZodObject<{ server: import("zod").ZodOptional<import("zod").ZodString>; browser: import("zod").ZodOptional<import("zod").ZodString>; style: import("zod").ZodOptional<import("zod").ZodString>; }, import("zod/v4/core").$strip>, "alepha.cli.appEntry.options">; type AppEntryOptions = Static<typeof appEntryOptions.schema>; //#endregion //#region ../../src/cli/core/atoms/buildOptions.d.ts /** * Deployment target for the build output. * * - `docker` - Generate Dockerfile for containerized deployment * - `vercel` - Generate Vercel deployment configuration (forces node runtime) * - `cloudflare` - Generate Cloudflare Workers configuration (forces workerd runtime) */ type BuildTarget = "bare" | "docker" | "vercel" | "cloudflare" | "static"; /** * JavaScript runtime for the build output. * * - `node` - Node.js runtime (default) * - `bun` - Bun runtime (uses bun export conditions) * - `workerd` - Cloudflare Workers runtime (auto-set with cloudflare target) */ type BuildRuntime = "node" | "bun" | "workerd"; /** * Build options atom for CLI build command. * * Defines the available build configuration options with their defaults. * Options can be overridden via alepha.config.ts or CLI flags. */ declare const buildOptions: import("alepha").Atom<import("zod").ZodObject<{ stats: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodBoolean, import("zod").ZodEnum<{ json: "json"; }>]>>; target: import("zod").ZodOptional<import("zod").ZodEnum<{ bare: "bare"; cloudflare: "cloudflare"; docker: "docker"; static: "static"; vercel: "vercel"; }>>; runtime: import("zod").ZodOptional<import("zod").ZodEnum<{ bun: "bun"; node: "node"; workerd: "workerd"; }>>; output: import("zod").ZodOptional<import("zod").ZodObject<{ dist: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodString>>; public: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodString>>; }, import("zod/v4/core").$strip>>; vercel: import("zod").ZodOptional<import("zod").ZodObject<{ projectName: import("zod").ZodOptional<import("zod").ZodString>; orgId: import("zod").ZodOptional<import("zod").ZodString>; projectId: import("zod").ZodOptional<import("zod").ZodString>; config: import("zod").ZodOptional<import("zod").ZodObject<{ crons: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{ path: import("zod").ZodString; schedule: import("zod").ZodString; }, import("zod/v4/core").$strip>>>; }, import("zod/v4/core").$strip>>; }, import("zod/v4/core").$strip>>; cloudflare: import("zod").ZodOptional<import("zod").ZodObject<{ config: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodAny>>; }, import("zod/v4/core").$strip>>; docker: import("zod").ZodOptional<import("zod").ZodObject<{ from: import("zod").ZodOptional<import("zod").ZodString>; command: import("zod").ZodOptional<import("zod").ZodString>; install: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>; image: import("zod").ZodOptional<import("zod").ZodObject<{ tag: import("zod").ZodString; args: import("zod").ZodOptional<import("zod").ZodString>; oci: import("zod").ZodOptional<import("zod").ZodBoolean>; }, import("zod/v4/core").$strip>>; compile: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodBoolean, import("zod").ZodObject<{ target: import("zod").ZodOptional<import("zod").ZodString>; base: import("zod").ZodOptional<import("zod").ZodString>; minify: import("zod").ZodOptional<import("zod").ZodBoolean>; }, import("zod/v4/core").$strip>]>>; }, import("zod/v4/core").$strip>>; static: import("zod").ZodOptional<import("zod").ZodObject<{ domain: import("zod").ZodOptional<import("zod").ZodString>; }, import("zod/v4/core").$strip>>; pwa: import("zod").ZodOptional<import("zod").ZodObject<{ name: import("zod").ZodString; shortName: import("zod").ZodOptional<import("zod").ZodString>; themeColor: import("zod").ZodOptional<import("zod").ZodString>; backgroundColor: import("zod").ZodOptional<import("zod").ZodString>; display: import("zod").ZodOptional<import("zod").ZodEnum<{ browser: "browser"; fullscreen: "fullscreen"; "minimal-ui": "minimal-ui"; standalone: "standalone"; }>>; offline: import("zod").ZodOptional<import("zod").ZodBoolean>; }, import("zod/v4/core").$strip>>; }, import("zod/v4/core").$strip>, "alepha.cli.build.options">; /** * Type for build options. */ type BuildOptions = Static<typeof buildOptions.schema>; //#endregion //#region ../../src/cli/core/atoms/changelogOptions.d.ts /** * Default scopes to ignore in changelog generation. * Commits with these scopes won't appear in release notes. */ declare const DEFAULT_IGNORE: string[]; /** * Changelog configuration atom. * * Configure in `alepha.config.ts`: * ```ts * import { changelogOptions } from "alepha/cli"; * * alepha.set(changelogOptions, { * ignore: ["project", "release", "chore", "docs"], * }); * ``` */ declare const changelogOptions: import("alepha").Atom<import("zod").ZodObject<{ ignore: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>; }, import("zod/v4/core").$strip>, "alepha.cli.changelog.options">; type ChangelogOptions = Static<typeof changelogOptions.schema>; //#endregion //#region ../../src/cli/core/atoms/devOptions.d.ts /** * Dev options atom for CLI dev command. * * Defines the available dev configuration options with their defaults. * Options can be overridden via alepha.config.ts or CLI flags. */ declare const devOptions: import("alepha").Atom<import("zod").ZodObject<{ noViteReactPlugin: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodBoolean>>; }, import("zod/v4/core").$strip>, "alepha.cli.dev.options">; /** * Type for dev options. */ type DevOptions = Static<typeof devOptions.schema>; //#endregion //#region ../../src/cli/core/providers/AppEntryProvider.d.ts /** * Service for locating entry files in Alepha projects. * * Resolves application entry points for the CLI build pipeline. */ declare class AppEntryProvider { protected readonly fs: FileSystemProvider; protected readonly options: Readonly<{ server?: string | undefined; browser?: string | undefined; style?: string | undefined; }>; protected readonly serverEntries: readonly ["main.server.ts", "main.server.tsx", "main.ts", "main.tsx"]; protected readonly browserEntries: readonly ["main.browser.ts", "main.browser.tsx", "main.ts", "main.tsx"]; protected readonly styleEntries: readonly ["main.css", "styles.css", "style.css"]; /** * Get application entry points. * * Server entry is required, an error is thrown if not found. * Browser entry is optional. * * It will first check for custom entries in options, see appEntryOptions. */ getAppEntry(root: string): Promise<AppEntry>; } interface AppEntry { root: string; server: string; browser?: string; style?: string; } //#endregion //#region ../../src/cli/core/services/ViteUtils.d.ts interface BufferedLogEntry { level: "info" | "warn" | "error"; msg: string; timestamp: Date; } interface BufferedLogger extends Logger { /** * Flush all buffered log messages to console. * Call this on build failure to show what happened. */ flush(): void; /** * Get all buffered log entries. */ getEntries(): BufferedLogEntry[]; /** * Clear all buffered entries without printing. */ clear(): void; } /** * Preload manifest mapping short keys to source paths. * Generated at build time, consumed by SSRManifestProvider at runtime. */ interface PreloadManifest { [key: string]: string; } /** * Vite integration utilities for the Alepha CLI. * * Centralizes all Vite-specific code: lazy loading, plugin creation, * buffered logger, dev server management. * When Vite is replaced, only this file needs to change. */ declare class ViteUtils { protected readonly fs: FileSystemProvider; protected viteDevServer?: ViteDevServer; /** * Lazy-load Vite (with rolldown-vite fallback). */ importVite(): Promise<typeof import("vite")>; /** * Lazy-load @vitejs/plugin-react (optional). */ importViteReact(): Promise<any>; /** * Create a Vite logger that buffers all messages instead of printing them. * Useful for silent builds that only show output on failure. */ createBufferedLogger(): BufferedLogger; /** * Vite plugin that reads tsconfig.json `compilerOptions.paths` and converts * them to Vite `resolve.alias` entries. Enables `@/*` → `src/*` style imports * with zero config beyond tsconfig.json. */ createTsconfigPathsPlugin(): Plugin; /** * Vite plugin that generates a preload manifest for SSR module preloading. * * Collects lazy import paths from $page definitions during transform, * generates a manifest mapping short keys to resolved source paths, * and injects only the short key into $page definitions. */ createSsrPreloadPlugin(): Plugin; generateIndexHtml(entry: AppEntry, opts?: { pwa?: boolean; }): string; /** * We need to close the Vite dev server after build is done. */ protected onReady: import("alepha").HookPrimitive<"ready">; protected onStop: import("alepha").HookPrimitive<"stop">; runAlepha(opts: { entry: AppEntry; mode: "production" | "development"; }): Promise<Alepha>; } //#endregion //#region ../../src/cli/core/providers/ViteBuildProvider.d.ts declare class ViteBuildProvider { protected alepha?: Alepha; protected appEntry?: AppEntry; protected readonly viteUtils: ViteUtils; init(opts: { entry: AppEntry; }): Promise<Alepha>; hasClient(): boolean; } //#endregion //#region ../../src/cli/core/services/AlephaCliUtils.d.ts /** * Core utility service for CLI commands. * * Provides: * - Command execution * - File editing helpers * - Drizzle/ORM utilities * - Environment loading */ declare class AlephaCliUtils { protected readonly log: import("alepha/logger").Logger; protected readonly fs: FileSystemProvider; protected readonly envUtils: EnvUtils; protected readonly boot: AppEntryProvider; protected readonly shell: ShellProvider; protected readonly viteUtils: ViteUtils; protected readonly alepha: Alepha; /** * Execute a command with inherited stdio. */ exec(command: string, options?: { root?: string; env?: Record<string, string>; global?: boolean; capture?: boolean; }): Promise<void>; /** * Resolve the absolute path to a toolchain binary that ships embedded in * `alepha`'s own `dependencies` (typescript, vite, vitest, @biomejs/biome, * drizzle-kit). * * The CLI runs the result via `node <path>` so the toolchain works under * every package manager — including pnpm with a strict node-linker, where * a transitive dependency's bin is NOT hoisted into the project's * `node_modules/.bin`. Resolution starts from `alepha`'s own location, so * the version is whatever `alepha` shipped — the project never pins it. * * @param pkg - npm package name (e.g. `"typescript"`) * @param binName - which `bin` entry to use (e.g. `"tsc"`); defaults to the * package's only/first bin */ resolveBin(pkg: string, binName?: string): string; /** * Write a configuration file to node_modules/.alepha directory. */ writeConfigFile(name: string, content: string, root?: string): Promise<string>; loadAlephaFromServerEntryFile(opts: { mode: "production" | "development"; } & ({ entry: AppEntry; } | { root: string; })): Promise<Alepha>; /** * Load environment variables from a .env file. */ loadEnv(root: string, files?: string[]): Promise<void>; exists(root: string, path: string): Promise<boolean>; /** * Check if a command is installed and available in the system PATH. */ isInstalledAsync(cmd: string): Promise<boolean>; /** * Get the current git revision (commit SHA). * * @returns The short commit SHA or "unknown" if not in a git repo */ getGitRevision(): Promise<string>; /** * Get the user's email from git config. * * @returns The git user email or undefined if not configured */ getGitEmail(): Promise<string | undefined>; } //#endregion //#region ../../src/cli/core/services/PackageManagerUtils.d.ts /** * Context information about a workspace root. * Used when initializing a package inside a monorepo. */ interface WorkspaceContext { /** * Whether we're inside a workspace package. */ isPackage: boolean; /** * The workspace root directory (e.g., ../.. from packages/my-pkg). */ workspaceRoot: string | null; /** * Package manager detected at workspace root. */ packageManager: "yarn" | "pnpm" | "npm" | "bun" | null; /** * Config files present at workspace root. */ config: { biomeJson: boolean; editorconfig: boolean; tsconfigJson: boolean; }; } /** * Utility service for package manager operations. * * Handles detection, installation, and cleanup for: * - Yarn * - npm * - pnpm * - Bun */ declare class PackageManagerUtils { protected readonly log: import("alepha/logger").Logger; protected readonly fs: FileSystemProvider; protected readonly alepha: Alepha; /** * Detect the package manager used in the project. * Checks current directory first, then workspace root if in a monorepo. */ getPackageManager(root: string, pm?: "yarn" | "pnpm" | "npm" | "bun"): Promise<"yarn" | "pnpm" | "npm" | "bun">; /** * Detect workspace context when inside a monorepo package. * * Checks if we're inside a workspace package by walking up to 3 levels * for workspace indicators like lockfiles and config files. * This covers both standard layouts (packages/my-pkg) and deeper nesting * (packages/scope/my-pkg). * * @param root - The current package directory * @returns Workspace context with root path, PM, and config presence */ getWorkspaceContext(root: string): Promise<WorkspaceContext>; protected checkWorkspaceRoot(candidate: string): Promise<WorkspaceContext | null>; /** * Get the install command for a package. */ getInstallCommand(root: string, packageName: string, dev?: boolean): Promise<string>; /** * Check if a dependency is installed in the project. */ hasDependency(root: string, packageName: string): Promise<boolean>; /** * Check if Expo is present in the project. */ hasExpo(root: string): Promise<boolean>; /** * Check if React is present in the project. */ hasReact(root: string): Promise<boolean>; /** * Install a dependency if it's missing from the project. * Optionally checks workspace root for the dependency in monorepo setups. */ ensureDependency(root: string, packageName: string, options?: { dev?: boolean; /** * Also check workspace root for the dependency (for monorepo setups). */ checkWorkspace?: boolean; run?: RunnerMethod; exec?: (cmd: string, opts?: { global?: boolean; root?: string; }) => Promise<void>; }): Promise<void>; ensureYarn(root: string): Promise<void>; ensureBun(root: string): Promise<void>; ensurePnpm(root: string): Promise<void>; ensureNpm(root: string): Promise<void>; removeAllPmFilesExcept(root: string, except: string): Promise<void>; removeYarn(root: string): Promise<void>; removePnpm(root: string): Promise<void>; removeNpm(root: string): Promise<void>; removeBun(root: string): Promise<void>; readPackageJson(root: string): Promise<Record<string, any>>; writePackageJson(root: string, content: Record<string, any>): Promise<void>; editPackageJson(root: string, editFn: (pkg: Record<string, any>) => Record<string, any>): Promise<void>; ensurePackageJson(root: string, modes: DependencyModes): Promise<Record<string, any>>; generatePackageJsonContent(modes: DependencyModes): { dependencies: Record<string, string>; devDependencies: Record<string, string>; scripts: Record<string, string>; type: "module"; }; protected removeFiles(root: string, files: string[]): Promise<void>; } interface DependencyModes { react?: boolean; expo?: boolean; tailwind?: boolean; /** * Whether the project is a workspace package inside a monorepo. */ isPackage?: boolean; } //#endregion //#region ../../src/cli/core/services/ProjectScaffolder.d.ts /** * Service for scaffolding new Alepha projects. * * Handles creation of: * - Project structure (src/api, src/web) * - Configuration files (tsconfig, biome, editorconfig) * - Entry points (main.server.ts, main.browser.ts) * - Example code (HelloController, Home component) */ declare class ProjectScaffolder { protected readonly log: import("alepha/logger").Logger; protected readonly colors: ConsoleColorProvider; protected readonly fs: FileSystemProvider; protected readonly pm: PackageManagerUtils; protected readonly utils: AlephaCliUtils; /** * Get the app name from the directory name. * * Converts the directory name to a valid module name: * - Converts to lowercase * - Replaces spaces, dashes, underscores with nothing * - Falls back to "app" if empty */ getAppName(root: string): string; /** * Ensure all configuration files exist. */ ensureConfig(root: string, opts: { force?: boolean; /** * Check workspace root for existing config files. */ checkWorkspace?: boolean; packageJson?: boolean | DependencyModes; tsconfigJson?: boolean; biomeJson?: boolean; editorconfig?: boolean; agentMd?: boolean; /** * Write `.vscode/settings.json` pointing the editor's TypeScript * server at the `typescript` copy embedded in `alepha`. */ vscodeSettings?: boolean; }): Promise<void>; ensureTsConfig(root: string, opts?: { force?: boolean; }): Promise<void>; ensureBiomeConfig(root: string, opts?: { force?: boolean; checkWorkspace?: boolean; }): Promise<void>; ensureEditorConfig(root: string, opts?: { force?: boolean; checkWorkspace?: boolean; }): Promise<void>; /** * Ensure `.vscode/settings.json` exists, pointing the editor's TypeScript * language server at the `typescript` copy embedded in `alepha`. Keeps the * IDE on the same compiler version as `alepha typecheck` — see * `vscodeSettingsJson`. */ ensureVscodeSettings(root: string, opts?: { force?: boolean; checkWorkspace?: boolean; }): Promise<void>; /** * Ensure git repository is initialized with .gitignore. * * @returns true if git was initialized, false if already exists or git unavailable */ ensureGitRepo(root: string, opts?: { force?: boolean; }): Promise<boolean>; /** * Ensure AGENTS.md (cross-tool standard, canonical source) exists, with a * CLAUDE.md stub that imports it via Claude Code's `@` syntax. Single * source of truth, cross-platform, no symlink needed. */ ensureAgentMd(root: string, options?: { force?: boolean; }): Promise<void>; /** * Ensure alepha.config.ts exists with documented options. */ ensureAlephaConfig(root: string, opts?: { force?: boolean; }): Promise<void>; /** * Ensure src/main.server.ts exists with correct module imports. */ ensureMainServerTs(root: string, opts?: { api?: boolean; react?: boolean; force?: boolean; }): Promise<void>; /** * Ensure API module structure exists. * * Creates: * - src/api/index.ts (API module) * - src/api/controllers/HelloController.ts (example controller) */ ensureApiProject(root: string, opts?: { force?: boolean; }): Promise<void>; /** * Ensure web/React project structure exists. * * Creates: * - src/main.browser.ts * - src/main.css * - src/web/index.ts, src/web/AppRouter.ts, src/web/components/Home.tsx */ ensureWebProject(root: string, opts?: { api?: boolean; tailwind?: boolean; force?: boolean; }): Promise<void>; /** * Ensure test directory exists with a dummy test file + a self-contained * `vitest.config.ts`. Pinning `test.root` prevents Vitest from walking up * to a parent monorepo config (e.g. one that boots a Postgres container). */ ensureTestDir(root: string): Promise<void>; /** * Full project init — scaffolds files, installs deps, sets up PM and git. */ init({ run, root, flags, args }: { run: RunnerMethod; root: string; flags: { pm?: "yarn" | "npm" | "pnpm" | "bun"; api?: boolean; react?: boolean; tailwind?: boolean; force?: boolean; }; args?: string; }): Promise<void>; /** * Write a file, optionally overriding if it exists. */ protected ensureFile(root: string, relativePath: string, content: string, force?: boolean): Promise<void>; /** * Check if a file exists in the given directory or any parent directory. */ protected existsInParents(root: string, filename: string): Promise<boolean>; } //#endregion //#region ../../src/cli/core/tasks/BuildCloudflareTask.d.ts interface WranglerConfig { [key: string]: any; } /** * Build-time snapshot describing what the workspace needs at deploy * time. Written to `dist/manifest.json` alongside `wrangler.jsonc`. * * Lets `alepha platform up --prebuilt` skip the Vite-based * introspection step on the deploy side — and lets Alepha Rocket skip * the workspace's runtime `npm install` because no app source is * booted at deploy time. The manifest captures the bits of primitive * data that the deploy steps (provision, secrets, hooks) need to * know. */ interface BuildManifest { version: 1; project: string; /** * Default environment when `--env` is omitted at deploy time. * Captured from `platformOptions.default` (defaults to `"production"`). */ defaultEnv: string; /** * Multi-tenancy mode (`none` | `optional` | `required`). Captured from * `platformOptions.tenancy` so the prebuilt deploy side (Rocket) can * validate `--tenant` without re-evaluating `alepha.config.ts`. */ tenancy?: "none" | "optional" | "required"; /** * Resolved `platform({ environments: ... })` map. Captured at build * time from the workspace's `alepha.config.ts` so the deploy side * doesn't need to re-evaluate the config. Each value is the same * `EnvironmentConfig` shape consumed by the orchestrator (adapter, * domain, zone, jurisdiction, accountId). */ environments: Record<string, { adapter: "cloudflare" | "vercel"; domain?: string; zone?: string; jurisdiction?: "eu" | "fedramp"; accountId?: string; }>; resources: { hasDatabase: boolean; hasBucket: boolean; hasKV: boolean; hasQueue: boolean; hasCron: boolean; }; /** * All distinct cron expressions registered by `$scheduler` * primitives. Empty when `hasCron` is false. */ crons: string[]; /** * Cloudflare email binding, captured when the app registers * `CloudflareEmailProvider` at artifact-build time. The prebuilt/manifest * deploy path (Alepha Rocket `--prebuilt`) has no Vite introspection, so it * reads this to re-emit the `send_email` wrangler binding. Absent when the * app doesn't use Cloudflare email. */ email?: { binding: string; }; /** * Every env var the app declares via `$env`, captured from * `alepha.dump().env` at build time. The deploy `secrets` step uses this * as the worker-secret allowlist (minus build/binding vars) so CI can * deliver secrets straight from `process.env` without a `.env` file — * `platform.secrets.keys` overrides it when set. Empty when introspection * was unavailable (older artifacts / prebuilt mode). */ env: string[]; } /** * Generate Cloudflare Workers deployment configuration. * * Creates: * - wrangler.jsonc with worker configuration * - main.cloudflare.js entry point for Cloudflare Workers */ declare class BuildCloudflareTask extends BuildTask { protected readonly fs: FileSystemProvider; protected readonly viteUtils: ViteUtils; protected readonly warningComment: string; run(ctx: BuildTaskContext): Promise<void>; protected generateCloudflare(ctx: BuildTaskContext, distDir: string): Promise<void>; /** * Write `dist/manifest.json` — a build-time snapshot of everything * downstream tooling needs to know about the app without re-booting * it. Used by `alepha platform up --prebuilt` (and Alepha Rocket) so * the deploy path can skip the Vite-based introspection step and the * workspace's runtime npm install. */ protected writeManifest(ctx: BuildTaskContext, root: string, distDir: string, name: string): Promise<void>; /** Worker-to-worker service bindings, from CLOUDFLARE_SERVICES (JSON). */ protected enhanceServices(wrangler: WranglerConfig): void; protected enhanceDomain(wrangler: WranglerConfig): void; protected enhanceCron(ctx: BuildTaskContext, wrangler: WranglerConfig): void; protected discoverCrons(ctx: BuildTaskContext): string[]; protected enhanceDatabase(wrangler: WranglerConfig): void; protected static readonly D1_BINDING = "DB"; protected enhanceD1(wrangler: WranglerConfig): void; protected enhanceHyperdrive(wrangler: WranglerConfig): void; protected enhanceR2(wrangler: WranglerConfig): void; protected enhanceKV(wrangler: WranglerConfig): void; protected enhanceQueue(wrangler: WranglerConfig): void; protected enhanceEmail(ctx: BuildTaskContext, wrangler: WranglerConfig): void; protected writeWorkerEntryPoint(root: string, distDir: string): Promise<void>; } //#endregion //#region ../../src/cli/core/tasks/BuildTask.d.ts interface BuildTaskContext { /** * The user's app Alepha container (NOT the CLI container). * Used for metadata extraction (pages, primitives, store, etc.). */ alepha: Alepha; /** * Resolved build options (flags merged with atom defaults). * BuildCommand mutates the atom before creating the context, * so stats, target, runtime are all resolved values. */ options: BuildOptions; /** * CLI runner for progress logging. * Tasks call this when they have work to show. * Tasks decide IF and WHEN to call run — e.g. skip entirely if nothing to do. */ run: RunnerMethod; /** * Project root directory. */ root: string; /** * Application entry points resolved by AppEntryProvider. */ entry: AppEntry; /** * Whether the app has a client-side bundle (React). */ hasClient: boolean; /** * Raw CLI flags passed through from the command. * Tasks can read flags relevant to their domain. */ /** * Build-time snapshot of primitive data, read from * `dist/manifest.json`. Populated only in `--prebuilt` mode when a * previous build's manifest is present — lets BuildCloudflareTask * regenerate `wrangler.jsonc` without re-booting the workspace. * `null` when introspection (`ctx.alepha`) is the source of truth. */ manifest: BuildManifest | null; /** * Resolved `platform({ default, environments, ... })` options from * the workspace's `alepha.config.ts`. Populated by `BuildCommand` * from the CLI's Alepha instance (where alepha.config.ts ran) — * BuildCloudflareTask uses these to write the corresponding fields * into `dist/manifest.json` so the deploy side doesn't need to * re-load `alepha.config.ts`. `null` when no platform options were * declared. */ platformOptions: { default?: string; tenancy?: "none" | "optional" | "required"; environments?: Record<string, { adapter: "cloudflare" | "vercel"; domain?: string; zone?: string; jurisdiction?: "eu" | "fedramp"; accountId?: string; }>; } | null; flags?: { image?: boolean | string; /** * Skip the slow build steps (Vite client + Vite server + asset * compression). Only runs the deploy-config generation * (wrangler.jsonc, etc.) — useful when the caller already has a * built `dist/` and just needs the wrangler config refreshed for * per-tenant overrides. */ prebuilt?: boolean; }; } /** * Abstract base class for build pipeline tasks. * * Each task encapsulates a step in the build pipeline. * Tasks control their own progress reporting via ctx.run. */ declare abstract class BuildTask { abstract run(ctx: BuildTaskContext): Promise<void>; } //#endregion //#region ../../src/cli/core/tasks/BuildAssetsTask.d.ts /** * Copy assets from Alepha packages to the build output directory. * * Reads `alepha.build.assets` state to find packages with assets, * and copies their `/assets` directories to the build output. * Used by modules like AlephaServerSwagger to distribute UI files. */ declare class BuildAssetsTask extends BuildTask { protected readonly fs: FileSystemProvider; run(ctx: BuildTaskContext): Promise<void>; } //#endregion //#region ../../src/cli/core/tasks/BuildClientTask.d.ts /** * Build client-side bundle with Vite. * * Compiles the browser/client code for production, * including code splitting and minification. * Analyze step stays in BuildCommand (ViteBuildProvider). * This task wraps only the actual Vite client build call. */ declare class BuildClientTask extends BuildTask { protected readonly alepha: Alepha; protected readonly fs: FileSystemProvider; protected readonly viteUtils: ViteUtils; run