{"id":16753077,"url":"https://github.com/bsutton/build_it","last_synced_at":"2026-02-14T10:03:53.757Z","repository":{"id":141377881,"uuid":"410684104","full_name":"bsutton/build_it","owner":"bsutton","description":"The `build_it`is a builder that makes publicly available third-party source code generators and runs them during the build process for rapid development.","archived":false,"fork":false,"pushed_at":"2021-03-21T21:22:18.000Z","size":185,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-05T23:54:26.392Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bsutton.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-26T23:18:38.000Z","updated_at":"2022-02-14T19:40:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"8461e4dc-c490-4669-8a36-1a967d5046d4","html_url":"https://github.com/bsutton/build_it","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bsutton/build_it","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsutton%2Fbuild_it","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsutton%2Fbuild_it/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsutton%2Fbuild_it/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsutton%2Fbuild_it/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bsutton","download_url":"https://codeload.github.com/bsutton/build_it/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsutton%2Fbuild_it/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29442334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T07:24:13.446Z","status":"ssl_error","status_checked_at":"2026-02-14T07:23:58.969Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T02:49:06.947Z","updated_at":"2026-02-14T10:03:53.740Z","avatar_url":"https://github.com/bsutton.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# build_it\n\nThe `build_it`is a builder that makes publicly available third-party source code generators and runs them during the build process for rapid development.\n\nVersion 0.2.9 (BETA)\n\nTODO:\n- Add the development `build_it` JSON generator (`build_it:json_dev`) that will generate a file with the `.dart` extension with JSON classes (generated by `json_serializable`) without the `part ` and `part of` directives (and without the files with extensions `.g.dart`). This will be done by combining the parts into one file. This generator allows you to create JSON classes that will not be deleted during build process and will always be available.  \n\n## What are the benefits of using?\n\nThe `build_it` builder simplifies several development steps at once:  \n- Source code generators are given full (and simplified) access to build steps: build and post build  \n- Allows you to easily use your own generator without delving too much into the principles of the build process (generate whatever you want)  \n- You can use your own data description format to configure your generator in YAML format (it is recommended to use JSON models for this purpose)  \n- You can use third-party source code generators for rapid development, you just need to know the configuration description format (and what they end up creating)  \n- Includes built-in `build_it:json` JSON generator maximum compatible with package `json_serializable` and its annotations  \n- A built-in JSON generator is provided to simplify the creation of generators specification models, or it can be used to generate code for JSON classes that are commonly used  \n\n## What are the principles of work?\n\nThe `build_it` builder is a common builder for the Dart build system. It is intended for building Dart projects.  \nIt is configured and for those who use it there is no need to worry about how it works.  \nOn the other hand, it allows you to use third-party (or your own) code generators quite simply without the need to know how it all works.  \nIf you need to generate code based on some configuration, then you simply create a configuration file for a specific generator and `build_it` builder does all the work for you (runs the corresponding generator).\n\n## How do generators become publicly available?\n\nCreate a file named `your_generator_name_build_it.dart`.  \nThat is, add `_build_it.dart` at the end of the generator file name.  \nYour generator will be available to anyone who adds dependencies to your package.  \nThe generator will be available with the name `your_package_name:generator_name`.  \nOr, if your generator has the same name as your package, then its alias (the short name) will be `your_package_name`.  \n\nIf necessary, you can hide it away in your package.  \nEg. `src/foo/bar/baz_build_it.dart`\n\n## File format\n\nInput configuration files must be in the `build_it` format.  \nThis is a non-existent format (don't try to find a description). This format is only intended to be able to identify data in this format.  \nThis format is very simple. The data format is `YAML`.  \nYou just need to specify the correct YAML `metadata section` in a certain way.\n\nThe header format (YAML `metadata section`) is shown below.\n\n```yaml\n---\nformat:\n  name: build_it\n  generator:\n    name: string\n  language:\n    version: string?\n---\n\n# Configuration goes here\n```\n\n## How to use\n\nThe `build_it` builder directly executes third-party (or your own) generators for you.  \nThe builder executes thеse generators that generates ready-to-use source code (or source code for other builders or generators).  \nThe configurations for generators are described in the `YAML` format.  \nConfigurations are based on specifications.  \nThat is, you describe the configuration in the `YAML` format according to the specification. Because the target generator will use this configuration for its work.\n\n## How to implement your own `build_it` generator?\n\nFirst, add a dependency to the `pubspec.yaml` file:\n\n```yaml\ndependencies:\n  json_annotation: ^4.0.0\ndev_dependencies:  \n  build_it: ^0.2.3\n  json_serializable: ^4.0.2 \n```\n\nSuppose you want to create a generator named `example`. \n\nCreate a file named `example_build_it.dart` in the` lib` folder. \n\nAdd the following directive (for data exchange with the builder):\n\n```dart\nimport 'package:build_it/build_it_models.dart';\n```\n\nCreate a `main` method:\n\n```dart\nFuture\u003cvoid\u003e main(List\u003cString\u003e args, [response]) async {\n  //\n}\n```\n\nAnd add some code to it.\n\n```dart\nimport 'package:build_it/build_it_helper.dart';\nimport 'package:json_helpers/json_helpers.dart';\n\nFuture\u003cvoid\u003e main(List\u003cString\u003e args, [message]) async {\n  return await buildIt(args, message, _build);\n}\n\nFuture\u003cBuildResult\u003e _build(BuildConfig config) async {\n  const _template = '''\nvoid main() {\n  stdout.writeln('Hello, {{NAME}}');\n}\n''';\n\n  final data = config.data.json((e) =\u003e Data.fromMap(e));\n  final name = data.name;\n  final code = \u003cString\u003e[];\n  final template = _template.replaceAll('{{NAME}}', name);\n  code.add(template);\n  final directives = \u003cDirective\u003e[];\n  directives.add(Directive(type: 'import', url: 'dart:io'));\n  return BuildResult(code: code.join('\\n'), directives: directives);\n}\n\nclass Data {\n  final String name;\n\n  Data({required this.name});\n\n  factory Data.fromMap(Map\u003cString, dynamic\u003e json) {\n    return Data(name: (json['name'] as String?) ?? '');\n  }\n}\n\n''';\n\n```\n\nThen create your config file:\n\n`example_text.yaml`\n\n```yaml\n---\nformat:\n  name: build_it\n  generator:\n    name: build_it_test:example\n---\n\nname: Jack\n\n```\n\nWe will assume that your package is named `build_it_test`.   \nAccordingly, the public available name of your generator is `build_it_test:example`.  \n\nEverything is ready, you can start the build process:\n\n`dart run build_runner build`\n\nBelow is the build (and generation) result:\n\n`example_text.g.dart`\n\n```dart\n// GENERATED CODE - DO NOT MODIFY BY HAND\n\nimport 'dart:io';\n\n// **************************************************************************\n// build_it: build_it_test:example\n// **************************************************************************\n\nvoid main() {\n  stdout.writeln('Hello, Jack');\n}\n\n```\n\nYes, it’s not impressive, but we didn't put much effort into it.  \nIt is best to use the package [code_builder](https://pub.dev/packages/code_builder).  \nAnother way is to use a template engine (for example, [mustache](https://pub.dev/packages/mustache)).  \n\nA good generator should have a format specification and use JSON models to work with the configuration.  \nPackage `build_it` offers a built-in JSON generator. This generator will be improved soon. You can use it to generate JSON models for your generator.\n\n\n## Built-in JSON generator\n\nFor a generator to work well, a specification is required to describe the configuration and to work with the configuration.  \n`JSON` classes are very well suited for this purpose. They are convenient for modeling and data processing.  \nIt is not very pleasant to write such classes by hand, it is a common routine work.  \nUsing the `json` generator from the` build_it` package can make this work a little easier.\n\nExample of configuration for `JSON` generator:\n\n`example_classes.yaml`\n\n```yaml\n---\nformat:\n  name: build_it\n  generator:\n    name: build_it:json\n---\n\ncheckNullSafety: true\njsonSerializable:\n  anyMap: true\n\nclasses:\n- name: Category\n  fields:\n  - { name: id, type: int? }\n  - { name: name, type: String? }\n  - { name: products, type: List\u003cProduct\u003e, jsonKey: { defaultValue: [] } }\n\n- name: Product\n  fields:\n  - { name: id, type: int? }\n  - { name: name, type: String? }\n  - { name: type, type: ProductType, jsonKey: { defaultValue: ProductType.product } }\n\nenums:\n- name: ProductType\n  values:\n  - { name: product, jsonValue: { value: 0 } }\n  - { name: service, jsonValue: { value: 1 } }\n\ncode: |\n  int _foo(String s) {\n    return 41;\n  }\n  \n```\n\nThe result of work:\n\n`example_classes.g.dart`\n\n```dart\n// GENERATED CODE - DO NOT MODIFY BY HAND\n\nimport 'package:json_annotation/json_annotation.dart';\n\npart 'example_classes.g.g.dart';\n\n// **************************************************************************\n// build_it: build_it:json\n// **************************************************************************\n\n@JsonSerializable(anyMap: true)\nclass Category {\n  Category({this.id, this.name, required this.products});\n\n  /// Creates an instance of 'Category' from a JSON representation\n  factory Category.fromJson(Map json) =\u003e _$CategoryFromJson(json);\n\n  int? id;\n\n  String? name;\n\n  @JsonKey(defaultValue: [])\n  List\u003cProduct\u003e products;\n\n  /// Returns a JSON representation of the 'Category' instance.\n  Map\u003cString, dynamic\u003e toJson() =\u003e _$CategoryToJson(this);\n}\n\n@JsonSerializable(anyMap: true)\nclass Product {\n  Product({this.id, this.name, required this.type});\n\n  /// Creates an instance of 'Product' from a JSON representation\n  factory Product.fromJson(Map json) =\u003e _$ProductFromJson(json);\n\n  int? id;\n\n  String? name;\n\n  @JsonKey(defaultValue: ProductType.product)\n  ProductType type;\n\n  /// Returns a JSON representation of the 'Product' instance.\n  Map\u003cString, dynamic\u003e toJson() =\u003e _$ProductToJson(this);\n}\n\nenum ProductType {\n  @JsonValue(0)\n  product,\n  @JsonValue(1)\n  service\n}\n\nint _foo(String s) {\n  return 41;\n}\n\n```\n\nThis generator is an example of how and what kind of public generators can be written and used with the `build_it` builder.  \nIf you add the following dependencies to your project, then this generator will be available in your project as well.\n\n```yaml\ndependencies:\n  json_annotation: ^4.0.0\ndev_dependencies:\n  build_it: ^0.2.3\n  json_serializable: ^4.0.2\n```\n\nNow everyone who adds dependencies will have access to this generator.  \n\nThis way everyone can easily create useful public generators for everyone.  \nThis applies to all generators intended to use with `build_it` builder.\n\n## How to avoid bulld conflicts?\n\nThe only way to avoid build conflicts is to not create a Dart file with the same name as the configuration file.  \nFor example, if you are using a configuration file named `my_models.yaml`, then do not create a file called `my_models.dart`.  \nThe reason for the possible conflict may be that if the file `my_models.dart` will generate the file` my_models.g.dart`, then there will be a build conflict.\n\n## How to debug generator?\n\nIf you need to debug the process of work 'build_it', then you can read the answer here:  \n\n[https://github.com/dart-lang/build/blob/master/docs/builder_author_faq.md#how-can-i-debug-my-builder](How can I debug my builder?)\n\nBut if you need to debug your code generator, then it is easier to do so:  \nMove the generator functionality into a separate class and debug it in the usual way.  \nThe builder 'build_it' runs the generator in a separate isolate, this debugging is not very convenient.\n\nTo be continued...  ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsutton%2Fbuild_it","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbsutton%2Fbuild_it","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsutton%2Fbuild_it/lists"}