clay_core 0.0.1-dev.2 copy "clay_core: ^0.0.1-dev.2" to clipboard
clay_core: ^0.0.1-dev.2 copied to clipboard

Core library for Clay — config loading, reference transforms, template generation, and annotation validation.

example/main.dart

import 'dart:io';

import 'package:clay_core/clay.dart';

Future<void> main() async {
  final exampleRoot = File(Platform.script.toFilePath()).parent.path;

  final discovered = discoverClayConfig(cwd: exampleRoot);
  final config = await loadClayConfig(configPath: discovered.configPath);

  final referencePath = resolveReferencePath(
    projectRoot: discovered.projectRoot,
    config: config,
  );
  final targetPath = resolveTargetPath(
    projectRoot: discovered.projectRoot,
    config: config,
  );

  stdout
    ..writeln('Generating template...')
    ..writeln('  reference: $referencePath')
    ..writeln('  target:    $targetPath');

  await generateTemplate(
    config: config,
    referencePath: referencePath,
    targetPath: targetPath,
  );

  final issues = validateAnnotations(
    referenceDir: Directory(referencePath),
  );
  if (issues.isEmpty) {
    stdout.writeln('Validation: no annotation issues.');
  } else {
    stdout.writeln('Validation issues:');
    for (final issue in issues) {
      stdout.writeln('  $issue');
    }
  }

  const previewFile = 'lib/ref_pkg/greeting.dart.ref';
  final preview = await previewReferenceFile(
    filePath: previewFile,
    referencePath: referencePath,
    config: config,
    templateOnly: true,
  );

  stdout
    ..writeln('Preview ($previewFile, template-only):')
    ..writeln(preview);
}
0
likes
160
points
275
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Core library for Clay — config loading, reference transforms, template generation, and annotation validation.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#mason #template #codegen #yaml #annotations

License

MIT (license)

Dependencies

dart_mappable, glob, mason, meta, path, pub_semver, yaml

More

Packages that depend on clay_core