UNPKG

@controlplane/cli

Version:

Control Plane Corporation CLI

138 lines 6.83 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CONNECT_TIMEOUT_MS = exports.SUPPORTED_GIT_HOSTS = exports.SUPPORT_EMAIL = exports.CONNECT_POLL_MS = exports.BASELINE_EXCLUDES = exports.MAX_WILDCARD_RUNS_PER_SEGMENT = exports.MAX_LINK_DEPTH = exports.SCAN_BUDGET_MS = exports.MAX_SCAN_DEPTH = exports.MAX_CONTEXT_DIRS = exports.MAX_CONTEXT_FILES = exports.MAX_CONTEXT_BYTES = exports.UPLOAD_PRINT_EVERY_MS = exports.UPLOAD_TIMEOUT_MS = exports.UPLOAD_ATTEMPTS = exports.UPLOAD_CONCURRENCY = exports.BUILD_LOG_TAIL_LINES = exports.LOG_DRAIN_BUDGET_MS = exports.LOG_DRAIN_WAIT_MS = exports.LOG_DRAIN_ROUNDS = exports.LOG_MISSING_TOLERANCE = exports.LOG_FETCHES_PER_POLL = exports.POLL_MISSING_TOLERANCE = exports.POLL_BACKOFF_MAX_MS = exports.POLL_MAX_FAILURES = exports.POLL_INTERVAL_MS = exports.BUILD_TIMEOUT_MS = exports.BUILD_TIMEOUT_GRACE_MS = exports.IDEMPOTENT_POST_RETRIES = exports.REQUEST_TIMEOUT_MS = void 0; exports.resolveRemoteBuildEndpoint = resolveRemoteBuildEndpoint; exports.resolveRemoteBuildHeaders = resolveRemoteBuildHeaders; // ANCHOR - Constants // Build Service const DEFAULT_ENDPOINT = 'https://builder.cpln.io'; // The test environment runs its own build service, which the default endpoint does not reach. const TEST_ENDPOINT = 'https://cpln-archive-store-nkar3g1rhr512.gapbkxk1vnj3c.t.cpln.app'; // The API host a profile targets when it points at the test environment. const TEST_API_HOST = 'api.test.cpln.io'; // Routes the request to one build service environment; absent, the service picks its own. const ENVIRONMENT_HEADER = 'environment'; // A stalled connection must fail the call instead of hanging the command. exports.REQUEST_TIMEOUT_MS = 60 * 1000; // Four attempts cover transient blips in ~15s; a hard-down service must fail in seconds. exports.IDEMPOTENT_POST_RETRIES = 4; // Build Watch // The service enforces the real 20-minute build ceiling and fails the build with a // reason. The client waits past that so the service's message wins the race; this // deadline is only a backstop for a service that stops answering entirely. exports.BUILD_TIMEOUT_GRACE_MS = 2 * 60 * 1000; exports.BUILD_TIMEOUT_MS = 20 * 60 * 1000 + exports.BUILD_TIMEOUT_GRACE_MS; exports.POLL_INTERVAL_MS = 2000; exports.POLL_MAX_FAILURES = 8; exports.POLL_BACKOFF_MAX_MS = 15000; // The record store lags a fresh submission, so a build reads as missing before it appears. exports.POLL_MISSING_TOLERANCE = 3; // Bounds one poll's log-fetch loop so a misbehaving cursor cannot spin forever. exports.LOG_FETCHES_PER_POLL = 50; // The log store lags too; only a persistent miss means the service has no log endpoint. exports.LOG_MISSING_TOLERANCE = 3; // Enough rounds to outlast a lagging log store without delaying the result indefinitely. exports.LOG_DRAIN_ROUNDS = 6; exports.LOG_DRAIN_WAIT_MS = 500; // Wall-clock ceiling on the post-terminal drain, so slow log reads cannot defer the result. exports.LOG_DRAIN_BUDGET_MS = 30 * 1000; // How much of a failed build's log is folded into the error when it never streamed. exports.BUILD_LOG_TAIL_LINES = 25; // Context Upload exports.UPLOAD_CONCURRENCY = 24; exports.UPLOAD_ATTEMPTS = 3; // Whole-request ceiling per presigned PUT. Covers a full MAX_CONTEXT_BYTES seed on a // ~1 Mbps uplink, since a retry restarts the transfer from the first byte. exports.UPLOAD_TIMEOUT_MS = 60 * 60 * 1000; // How often append-only output reprints upload progress. exports.UPLOAD_PRINT_EVERY_MS = 2000; // Build Context exports.MAX_CONTEXT_BYTES = 500 * 1024 * 1024; // Mirrors the build service's per-context cap. exports.MAX_CONTEXT_FILES = 20000; // Directories carry no content but ship as entries, so they need their own ceiling. exports.MAX_CONTEXT_DIRS = 20000; // Deeper than any real source tree, and shallow enough to keep the walk off the stack limit. exports.MAX_SCAN_DEPTH = 512; // Ignore matching runs per entry, so only a wall-clock ceiling bounds rules times entries. exports.SCAN_BUDGET_MS = 2 * 60 * 1000; // Kernel symlink-chain limit (ELOOP); bounds cyclic links so resolution terminates. exports.MAX_LINK_DEPTH = 40; // At the 255-char filename cap, 3 runs per segment cost ~40 ms, 4 cost ~3 s, and 5 hang. exports.MAX_WILDCARD_RUNS_PER_SEGMENT = 3; /** * Junk excluded from every build context, overridable with a `!` rule. Framework build * outputs (.next, dist, ...) are deliberately absent: Dockerfiles legitimately COPY them. */ exports.BASELINE_EXCLUDES = [ '.git', 'node_modules', '__pycache__', '.venv', 'venv', '.mypy_cache', '.pytest_cache', '.ruff_cache', '.DS_Store', 'Thumbs.db', 'desktop.ini', ]; // Git Provider Connection exports.CONNECT_POLL_MS = 2000; exports.SUPPORT_EMAIL = 'support@controlplane.com'; exports.SUPPORTED_GIT_HOSTS = ['github.com', 'gitlab.com']; // Matches the connector's signed-state TTL — the link dies when we do. exports.CONNECT_TIMEOUT_MS = 15 * 60 * 1000; // ANCHOR - Exported Functions /** * Returns the build service endpoint: the CPLN_IMAGE_BUILD_ENDPOINT override when set, * the test environment's build service when the profile targets the test API, otherwise * the default. * * @param {string | undefined} apiEndpoint - (Optional) The API endpoint the profile targets. * @returns {string} The build service base URL. */ function resolveRemoteBuildEndpoint(apiEndpoint) { const override = process.env.CPLN_IMAGE_BUILD_ENDPOINT || ''; if (override !== '') { return override; } if (isTestApiEndpoint(apiEndpoint)) { return TEST_ENDPOINT; } return DEFAULT_ENDPOINT; } /** * Returns the headers every build service request carries: the environment header when * CPLN_IMAGE_BUILD_ENV names an environment, and no headers of our own otherwise. * * @returns {RawAxiosRequestHeaders | undefined} The headers, or undefined when no environment is named. */ function resolveRemoteBuildHeaders() { var _a; const environment = ((_a = process.env.CPLN_IMAGE_BUILD_ENV) !== null && _a !== void 0 ? _a : '').trim(); if (environment === '') { return undefined; } return { [ENVIRONMENT_HEADER]: environment }; } // ANCHOR - Functions /** * Reports whether the given API endpoint targets the test environment. * * @param {string | undefined} apiEndpoint - (Optional) The API endpoint the profile targets. * @returns {boolean} True when the endpoint names the test environment's API host. */ function isTestApiEndpoint(apiEndpoint) { const endpoint = (apiEndpoint !== null && apiEndpoint !== void 0 ? apiEndpoint : '').trim(); if (endpoint === '') { return false; } try { return new URL(endpoint).hostname.toLowerCase() === TEST_API_HOST; } catch (_a) { return false; } } //# sourceMappingURL=config.js.map