foundry_core 0.0.1-dev.1
foundry_core: ^0.0.1-dev.1 copied to clipboard
Core library for Foundry — mold parsing, variable resolution, template rendering, and cast orchestration.
foundry_core #
Core Dart library for Foundry — mold manifests, variable resolution, template rendering, and cast orchestration.
Preview release. APIs may change before
1.0.0.
What it does #
Foundry molds are Dart packages with a variables.dart manifest, a template/
tree, and optional lifecycle hooks. This library provides:
- Mold loading — parse root
pubspec.yaml, resolve dependencies, and loadmoldVariablesfromvariables.dart - Inspection — validate mold layout (
template/, conventional hook paths) - Variable resolution — evaluate
visibleWhen,defaultValue, and validators against a read-onlySnapshotFoundryContext - Template rendering — render Liquid templates to an output directory
- Hook execution — spawn prepare/shape/finish hooks with a mutable
FoundryContext - Cast orchestration — end-to-end
castMoldpipeline and.foundry/last_cast.jsonpersistence - Import — copy molds from a local path or shallow git clone
For day-to-day use, install the foundry_cli
package (foundry mold init, foundry cast, and related commands). Use this
library when embedding Foundry in tools or automation.
Installation #
Add foundry_core to your pubspec.yaml:
dependencies:
foundry_core: ^0.0.1-dev.1
Requires Dart SDK >=3.5.0 <4.0.0.
Usage #
Load a mold, inspect it, and cast with pre-gathered variable values:
import 'dart:io';
import 'package:foundry_core/foundry_core.dart';
Future<void> main() async {
final moldPath = 'path/to/my_mold';
final outputPath = 'path/to/output';
final report = await inspectMold(moldPath);
if (!report.isValid) {
for (final issue in report.issues) {
stderr.writeln(issue);
}
exitCode = 1;
return;
}
final mold = report.mold!;
final outcome = await castMold(
mold: mold,
outputPath: outputPath,
values: {'project_name': 'my_app'},
force: true,
noHooks: true,
);
stdout.writeln(
'Cast completed: ${outcome.artifactCount} file(s) written.',
);
}
See the example/ directory for a runnable program against a
bundled fixture mold.
Public API #
Import package:foundry_core/foundry_core.dart.
| Area | Key symbols |
|---|---|
| Mold | loadMold, parseMoldPubspec, inspectMold, Mold, FoundryVariableGroup |
| Context | SnapshotFoundryContext, FoundryContext, FoundryContextException |
| Cast | castMold, CastOutcome, readCastState, writeCastState |
| Render | renderTemplate |
| Hooks | runMoldHook, FoundryHookException |
| Import | importMoldFromLocal, importMoldFromGit |
Resources #
License #
MIT — see LICENSE.