module Hace

Extended Modules

Defined in:

completion.cr
hace.cr
makefile.cr

Constant Summary

DEPRECATED_ENV_WARNED = Set(String).new

Environment variable names that already produced a deprecation warning (${NAME} expansion, brace-less $NAME in non-command fields), so each is reported at most once per run.

ENVIRONMENT = {} of String => String
FAIL_FAST_SHELLS = ["sh", "bash", "zsh", "dash", "ash", "ksh", "mksh"] of ::String

Shells that understand POSIX fail-fast (-e). When a task or Hacefile selects one of these shells without explicit arguments, hace runs the commands with "-e -c" so multi-command tasks stop at the first failure, matching the default /bin/sh behavior. Other shells (python, cmd.exe, ...) only get the script passed via -c.

RECIPE_STAMP_DIR = ".hace"

Recipe stamps make the rendered recipe part of the staleness model.

Croupier only considers missing outputs, input file hashes and upstream staleness, so editing a task's commands in the Hacefile would never trigger a rebuild. To fix that, every task gets an extra input: a small file whose content is the SHA1 of its commands, shell and working directory. When the recipe changes, the stamp content changes, and the regular input-hash comparison marks the task stale.

TASKS_WITH_CLI_ARGS = Set(String).new

Track which tasks explicitly use CLI_ARGS (detected before Crinja expansion)

VARIABLES = {} of String => Value
VERSION = {{ (`shards version /srv/crystaldoc.info/github-ralsina-hace-v1.2.3/src`).chomp.stringify }}

Class Method Summary

Class Method Detail

def self.env_namespace : Hash(String, Value) #

Snapshot the merged environment view as template variables, backing the env namespace ({{ env.NAME }}). It matches what task shells see for $NAME: process environment (including dotenv) plus env: overrides.


[View source]
def self.expand_env_in_value(value : Hace::Value) : Hace::Value #

Expand the deprecated ${ENV_VAR} references inside a value and everything nested in it, leaving non-string values untouched. Warns when a brace-less $ENV_VAR reference would have expanded before (only names that resolve in the merged environment, to keep noise down).


[View source]
def self.expand_env_vars(str : String) : String #

Expand the deprecated braced ${ENV_VAR} references from the merged environment view. Actual substitutions log a deprecation warning, once per variable name per run; undefined references stay literal (matching both the old behavior and post-removal shell passthrough).


[View source]
def self.expand_glob(str : String) : Array(String) #

[View source]
def self.expand_string(str : String, variables = Hace::VARIABLES) : String #

[View source]
def self.from_yaml_any(any : YAML::Any) : Hace::Value #

Convert a parsed YAML node into the typed Value representation. This is the single place where YAML::Any is allowed to exist.


[View source]
def self.inject_cli_args(cli_args : Array(String)) #

Inject CLI_ARGS and CLI_ARGS_LIST into VARIABLES for template expansion


[View source]
def self.load_dotenv(dotenv_file = nil) #

[View source]
def self.recipe_stamp_path(task_name : String) : String #

[View source]
def self.reset_state #

Clear the module-level mutable state (VARIABLES, ENVIRONMENT, the CLI_ARGS tracking set and the env-deprecation warning set). Intended for use between test scenarios so that values injected by one run (CLI_ARGS, Hacefile variables, env entries) do not leak into the next. Mirrors Croupier::TaskManager.cleanup.


[View source]
def self.stamp_recipe(task_name : String, signature : String) : String #

Record the current recipe signature for task_name and return the stamp path. Writing is skipped when the content is unchanged so the file's mtime stays stable (mtime-based staleness modes would otherwise see it as modified on every run). Failures degrade gracefully: the returned path then simply does not exist, which scan_inputs skips, giving the old behavior without recipe sensitivity.


[View source]
def self.to_crinja_value(value : Hace::Value) : Crinja::Value #

[View source]
def self.to_crinja_variables(hash : Hash(String, Value)) : Crinja::Variables #

Convert a Hash(String, Value) to Crinja::Variables


[View source]
def self.warn_braceless_env_ref(str : String) #

Warn about brace-less $WORD references in non-command fields: hace no longer expands them, so a value like "$HOME" stays literal. Only names that resolve in the merged environment warn, since only those could have relied on the old expansion.


[View source]