πŸ““ Language: English | δΈ­ζ–‡
πŸ’‘ See the Migration Guide to learn how to migrate between breaking changes.



YAML Variable Scanner

stable package dev package pub points top language

YAML Variable Scanner, used to scan multiple files for text that can use YAML variables.


example-video.gif

[example]


Table of contents πŸͺ„

Features ✨

Important

Currently, only the following variables support checking:

  • {{ x.xx.xxx }}
  • πŸ“‚ Multiple files can be specified (Glob syntax)
  • πŸ—‘οΈ Ignore checks can be specified
    • Ignore files (Glob syntax)
    • Ignore YAML variables, text paragraphs (RegExp syntax)
  • πŸ” Support for checking existing YAML variables in text
  • πŸ”¦ Detailed console printout (with statistics)

Example πŸ’‘

Use the following command to run the check in the example:

$ dart run example --help

$ dart run example check

Install 🎯

Versions compatibility 🐦

Flutter / Dart 3.19.0+ / 3.3.0+
yaml_variable_scanner 0.0.1+ βœ…

Add package πŸ“¦

Run this command with Flutter,

$ dart pub add yaml_variable_scanner

or add yaml_variable_scanner to pubspec.yaml dependencies manually.

dependencies:
  yaml_variable_scanner: ^latest_version

Simple usage πŸ“–

Run checks (config file)

import 'dart:io';
import 'package:yaml_variable_scanner/yaml_variable_scanner.dart';

YamlVariableScanner.run(
  /// yaml_variable_scanner config file
  './yaml_variable_scanner.yaml',
  stdout,
);

yaml_variable_scanner config file

  1. Create the yaml_variable_scanner.yaml file.
  2. Complete the yaml_variable_scanner.yaml configuration.
yaml_variable_scanner:

  # File path for YAML variables
  yamlFilePath:
    - path: "test/siteA.yaml" # YAML path (Glob syntax)
      variablePrefix: "a." # Variable prefix. e.g. `a.` -> `a.x.xx`
    - path: "test/siteB.yaml"
      variablePrefix: "b."

  # Ignore YAML file path
  #
  # (Glob Syntax)
  ignoreYamlFilePath:
    - "test/test.yaml"

  # Ignore YAML Key
  #
  # e.g. "^a\.bb$"
  #
  # (RegExp Syntax)
  ignoreYamlKey:
    - ^description$
  
  # File path for check file contents
  #
  # (Glob Syntax)
  checkFilePath:
    - "test/**/*.md"

  # Ignore file paths to check
  #
  # (Glob Syntax)
  ignoreCheckFilePath:
    - "test/content/**.md"

  # Ignore text that doesn't need to match
  #
  # e.g. 
  # - `r"^\s*---([\s\S]*?)---$"`
  # - `r"^\s*{%-?\s*comment\s*-?%}([\s\S]*?){%-?\s*endcomment\s*-?%}$"`
  # - `r"^\s*<!---?\s*([\s\S]*?)\s*-?-->$"`
  #
  # (RegExp Syntax)
  ignoreCheckText:
    # --- xxx ---
    - ^\s*---([\s\S]*?)---$

    # {%- comment %} xxx {% endcomment -%}
    - ^\s*{%-?\s*comment\s*-?%}([\s\S]*?){%-?\s*endcomment\s*-?%}$

    # <!-- xxx -->
    - ^\s*<!---?\s*([\s\S]*?)\s*-?-->$

Usage πŸ“–

YamlVariableScanner.run() parameters πŸ€–

Parameter Type Default Description
configPath required String - yaml_variable_scanner.yaml config file path.
stdout required Stdout - stdout from dart:io
printMode PrintMode PrintMode.detail Console Print Mode.

License πŸ“„

MIT License
Open sourced under the MIT license.

Β© AmosHuKe

Libraries

yaml_variable_scanner
YAML Variable Scanner