module

Carat

Constants

CARAT_SOURCE = "OrelSokolov/carat.cr"

Канонический репозиторий carat — источник для carat self ....

COMMANDS = ["install", "update", "dev", "only", "shards", "exec", "completion", "self"]

Подкоманды для автокомплита; "__complete" скрытая — не показывается.

GIT_SCP_URL = /\A[^\/\s]+@[^\/\s]+:/
GIT_URL = /\A(?:https?|git|ssh|file):\/\//

Прямой git URL: схема https://host/... | ssh://user@host/... | git:// | file:// — либо scp-подобный синтаксис git (user@host:path, до двоеточия нет '/': git@github.com:owner/repo.git). Таким URL carat доверяет как есть — любой git-хост (GitLab, Gitea, sr.ht, ...).

USAGE = " carat #{VERSION} — global binary installer for Crystal shards\n\n Usage:\n carat install <src> Global install: clone -> build -> binaries in ~/.carat/bin\n Resolves like shards: the latest release tag when\n the repo has tags, otherwise the default branch HEAD\n <src>: owner/repo | name | git URL (https://, ssh://,\n git@host:path) | local directory\n Private repos work too: auth is delegated to git\n (ssh keys, credential helper, https token)\n carat install head <src>\n Always the default branch HEAD (fresh master,\n experimental): the install is pinned per commit\n (version+git.commit.<sha>), so `carat update head`\n follows every push, tagged or not\n carat install . Global install of the shard in the current directory\n (local shard development)\n carat install In a project with shard.yml: shards install + build\n binaries into ./.carat/bin\n carat update <src> Update globally installed shard if remote identity\n is newer (tag: semver decides; head: any new commit)\n carat update head <src>\n Re-resolve the default branch HEAD and rebuild\n carat update In a project: delegates to shards update + rebuild\n binaries into ./.carat/bin\n carat dev install Like install, but builds without --release\n (plain crystal build: faster codegen, for iteration)\n carat dev update Same for update\n carat only install Like install, but only installs shards (shards install),\n no binary build\n carat only update Same for update (shards update only)\n (`shards` is a synonym of `only`: carat shards install)\n carat exec <cmd> ... Run <cmd> with ./.carat/bin prepended to PATH\n carat completion install\n Shell autocompletion (bash/fish; zsh hint)\n carat self install Install-or-update carat itself from the canonical\n repository (OrelSokolov/carat.cr)\n carat self update The same thing (alias of carat self install)\n\n Options:\n --with-examples Also build the optional examples: section\n (global: ~/.carat/examples, project: ./.carat/examples)\n --system Install binaries into the system dir instead of\n ~/.carat/bin (Unix: /usr/local/bin, Windows:\n %ProgramFiles%\\carat\\bin + system PATH).\n Needs root/Administrator — fails fast with a\n clear error if not.\n\n Directories:\n ~/.carat/bin/ global binaries (only entry points)\n ~/.carat/examples/ global example binaries (--with-examples)\n ~/.carat/apps/<name>/ GUI apps (app: binaries + icons)\n ~/.carat/shards/<name>/<identity>/ global source store, per installed version\n (tag: 1.2.3; HEAD: 1.2.3+git.commit.a1b2c3d4e5)\n ~/.carat/shards/<name>/current installed identity pointer (see above)\n ~/.carat/logs/carat.log install/overwrite/update audit log\n ./.carat/bin/ project binaries\n ./.carat/examples/ project example binaries (--with-examples)\n\n Desktop apps (GUI):\n A binary with a `launchers:` mapping in shard.yml gets desktop\n integration beyond the PATH entry:\n launchers:\n terminal: true # default, always: binary in ~/.carat/bin\n menu: true # application menu (.desktop / Start Menu /\n # ~/Applications .app bundle on macOS)\n desktop: true # shortcut on the desktop, in addition to menu\n The icon comes from `assets:appicon:` (PNG or SVG, checked by magic\n bytes); no conversion pipeline is needed — .ico/.icns wrap the PNG\n as a container. The app itself knows nothing about carat: its assets\n live next to the binary (portable-app convention)."
VERSION = "0.13.1"

Class methods

build_binaries(meta : ShardMeta, dir : String, bin_dir : String, release : Bool = true, warn_overwrite : Bool = true) : Array(String)

release=true → --release (= -O3 --single-module); release=false — dev-режим: обычный crystal build без оптимизаций (быстрый кодоген). warn_overwrite=false для проектной установки: перезапись ./.carat/bin — нормальный цикл пересборки, WARNING только для глобальных каталогов, где он защищает PATH от тихой подмены. Общий prebuild секции — all: prebuild: в binaries:/examples: (см. ShardMeta::Section): один раз, а не по разу на каждый бинарник.

Source
build_examples(meta : ShardMeta, dir : String, examples_dir : String, release : Bool = true, warn_overwrite : Bool = true) : Array(String)

The optional examples: section — same build pipeline as binaries:, but only built with --with-examples (never on a plain carat install).

Source
check_writable_dir(dir : String) : Nil

Проверка записываемости каталога ДО клонирования и release-сборки: probe-файл создаётся и удаляется. На Unix прикладная ошибка — EACCES от mkdir или File.write; обе проходят как File::Error/Errno.

Source
collect_dep_flags(dir : String, os : String) : Tuple(Array(String), Array(String))

Рекурсивный сбор флагов сборки из зависимостей: библиотека (например, C-привязка) может объявить top-level flags:/link_flags: в своём shard.yml — carat подхватывает их при сборке бинарников любого шарда, который от неё зависит. Источник — lib/**/shard.yml (после shards install; у глобальной установки lib/ появляется через prebuild). Glob не следует симлинкам — циклов в раскладке shards не будет.

Source
colors?

Цвета только для интерактивного вывода: NO_COLOR и редирект в пайп отключают escape-коды (иначе они засоряют логи и вывод в файлах).

Source
copy_tree(src : String, dst : String) : Nil

Рекурсивное копирование дерева без следования симлинкам: симлинки пересоздаются (FileUtils.cp_r следует за симлинками на каталоги — layout lib/<shard>/lib -> .., который делает shards для flat-резолва зависимостей, уводит его в бесконечную рекурсию).

Source
exec_command(command : String, args : Array(String)) : Nil
Source
executable_file?(path : String) : Bool
Source
git(args : Array(String), cwd : String | Nil = nil) : String | Nil

Захваченный stdout git-команды (в отличие от Shell#run, который всё наследует) — для резолва тегов/коммитов. stderr наследуется, чтобы причину ошибки (auth, сеть) пользователь видел сразу.

Source
install_dependencies(meta : ShardMeta, dir : String) : Nil

A globally installed shard builds with crystal build directly, and the compiler resolves bare requires from the project's lib/ — so the dependency resolution the project mode delegates to shards install must run here too: once, in the stored copy, before the first binary is built. Dep-free shards skip it (nothing to resolve).

Source
logger
Source
os_family

OS family for the binaries: selectors; "macos" is an alias of "darwin".

Source
paint(line : String, color : Colorize::Color) : String
Source
resolve_source(src : String) : Source
Source
run(argv : Array(String)) : Nil
Source
select_flag_list(node : YAML::Any | Nil, os : String = os_family) : Array(String)

A flags:/link_flags: value: a plain list applies to every OS; a mapping selects by OS family — exact match, then alias (macos for darwin), then "*"; first hit wins.

Source
self_command(with_examples : Bool = false, system : Bool = false) : Nil

carat self install / carat self update — install-or-update самого carat из канонического репозитория. Если указатель версии уже есть (~/.carat/shards/carat/current) — путь update, иначе — полная установка. Репозиторий carat не тегируется под каждый релиз — self всегда идёт по HEAD master'а (head-режим): identity version+git.commit.<sha> меняется с каждым пушем, update видит движение и без bump'а version.

Source
shell
Source
warning(line : String) : Nil
Source

Nested types