{"id":14971522,"url":"https://github.com/birjuvachhani/spider","last_synced_at":"2025-05-16T14:02:35.680Z","repository":{"id":37871440,"uuid":"237763599","full_name":"BirjuVachhani/spider","owner":"BirjuVachhani","description":"A small dart library to generate Assets dart code from assets folder.","archived":false,"fork":false,"pushed_at":"2024-11-29T05:11:05.000Z","size":5901,"stargazers_count":191,"open_issues_count":10,"forks_count":23,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-03T09:11:09.546Z","etag":null,"topics":["cli","cli-app","code-generation","dart","dart-library","dart-package","dart2","dartlang","flutter","flutter-package","hacktoberfest","hacktoberfest-accepted","hacktoberfest2023","library","metaprogramming","open-source"],"latest_commit_sha":null,"homepage":"https://spider.birju.dev/","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BirjuVachhani.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2020-02-02T11:52:55.000Z","updated_at":"2025-03-07T19:24:13.000Z","dependencies_parsed_at":"2024-10-11T05:41:05.751Z","dependency_job_id":"7050fedf-64a6-4aee-b631-7c255cc13cca","html_url":"https://github.com/BirjuVachhani/spider","commit_stats":{"total_commits":360,"total_committers":10,"mean_commits":36.0,"dds":"0.13611111111111107","last_synced_commit":"9e9e4585a8fc6f25f395cd97d3341260a526abee"},"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirjuVachhani%2Fspider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirjuVachhani%2Fspider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirjuVachhani%2Fspider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BirjuVachhani%2Fspider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BirjuVachhani","download_url":"https://codeload.github.com/BirjuVachhani/spider/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248545125,"owners_count":21122081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["cli","cli-app","code-generation","dart","dart-library","dart-package","dart2","dartlang","flutter","flutter-package","hacktoberfest","hacktoberfest-accepted","hacktoberfest2023","library","metaprogramming","open-source"],"created_at":"2024-09-24T13:45:19.406Z","updated_at":"2025-04-12T09:25:09.702Z","avatar_url":"https://github.com/BirjuVachhani.png","language":"Dart","funding_links":["https://github.com/sponsors/BirjuVachhani","https://www.buymeacoffee.com/birjuvachhani"],"categories":[],"sub_categories":[],"readme":"![Banner](https://raw.githubusercontent.com/BirjuVachhani/spider/main/.github/banner.png?raw=true)\n\n# Spider\n\nA small dart library to generate Assets dart code from assets folder. It generates dart class with static const\nvariables in it which can be used to reference the assets safely anywhere in the flutter app.\n\n[![Build](https://github.com/BirjuVachhani/spider/workflows/Build/badge.svg?branch=main)](https://github.com/BirjuVachhani/spider/actions) [![Tests](https://github.com/BirjuVachhani/spider/workflows/Tests/badge.svg?branch=main)](https://github.com/BirjuVachhani/spider/actions) [![codecov](https://codecov.io/gh/birjuvachhani/spider/branch/main/graph/badge.svg?token=ZTYF9UQJID)](https://codecov.io/gh/birjuvachhani/spider) [![Pub Version](https://img.shields.io/pub/v/spider?label=Pub)](https://pub.dev/packages/spider)\n\n### User Guide: [Spider Docs](https://birjuvachhani.github.io/spider/)\n\n## Breaking Changes since v4.0.0:\n\n- `--info` flag command is now `--about` command.\n- `--check-updates` flag command is now `--check-for-updates`.\n\n### Example\n\n#### Before\n\n```dart\nWidget build(BuildContext context) {\n  return Image(image: AssetImage('assets/background.png'));\n}\n```\n\n#### After\n\n```dart\nWidget build(BuildContext context) {\n  return Image(image: AssetImage(Assets.background));\n}\n```\n\n#### Generated Assets Class\n\n```dart\nclass Assets {\n  static const String background = 'assets/background.png';\n}\n```\n\nThis method allows no error scope for string typos. Also, it provides auto-complete in the IDE which comes very handy\nwhen you have large amount of assets.\n\n## Installation\n\n### Install using pub\n\nThis is package is an independent library that is not linked to your project. So there's no need to add it to your\nflutter project as it works as a global command line tool for all of your projects.\n\n```shell\ndart pub global activate spider\n```\n\n### Install using Homebrew\n\n```shell\nbrew tap birjuvachhani/spider\nbrew install spider\n```\n\nRun following command to see help:\n\n```shell\nspider --help\n```\n\n## Usage\n\n#### Create Configuration File\n\nSpider provides a very easy and straight forward way to create a configuration file. Execute following command, and it\nwill create a configuration file with default configurations in it.\n\n```shell\nspider create\n```\n\nTo append configs in `pubspec.yaml` file, execute following command.\n\n```shell\nspider create --add-in-pubspec\n```\n\nTo use a custom directory path for configuration file, execute following command.\n\n```shell\nspider create -p ./directory/path/for/config\n```\n\nNow you can modify available configurations and Spider will use those configs when generating dart code.\n\n#### Use JSON config file\n\nThough above command creates `YAML` format for config file, spider also supports `JSON` format for config file. Use this\ncommand to create `JSON` config file instead of `YAML`.\n\n```shell\n# Create in root directory\nspider create --json\n\n# or\n\n# custom directory path\nspider create -p ./directory/path/for/config --json\n```\n\nNo matter which config format you use, `JSON` or `YAML`, spider automatically detects it and uses it for code\ngeneration.\n\nHere's the default configuration that will be in the config file:\n\n```yaml\n# Generated by Spider\n\n# Generates unit tests to verify that the assets exists in assets directory\ngenerate_tests: true\n\n# Use this to remove vcs noise created by the `generated` comments in dart code\nno_comments: true\n\n# Exports all the generated file as the one library\nexport: true\n\n# This allows you to import all the generated references with 1 single import!\nuse_part_of: true\n\n# Location where all the generated references will be stored\npackage: resources\n\ngroups:\n  - path: assets/images\n    class_name: Images\n    types: [ .png, .jpg, .jpeg, .webp, .webm, .bmp ]\n```\n\n### Generate Code\n\nRun following command to generate dart code:\n\n```shell\nspider build\n```\n\nIf you're using custom directory path for the configuration file, then you can specify the config file path like this:\n\n```shell\nspider -p ./path/to/config/file/spider.yaml build\n```\n\n### Manual\n\n![Manual](https://raw.githubusercontent.com/BirjuVachhani/spider/main/table.png)\n\n\u003c!-- \n| KEY                | TYPE            | DEFAULT VALUE    | SCOPE    | DESCRIPTION                                                                                            |\n|-----------------\t|--------------\t|----------------\t|--------\t|-------------------------------------------------------------------------------------------------------\t|\n| `path/paths`*    | String        | None            | GROUP    | Where to locate assets?                                                                                |\n| `class_name`*    | String        | None            | GROUP    | What will be the name of generated dart class?                                                            |\n| `package`        | String        | resources        | GLOBAL    | Where to generate dart code in the lib folder?                                                            |\n| `file_name`        | String        | {class_name}    | GROUP    | What will be the name of the generated dart file?                                                        |\n| `prefix`            | String        | None            | GROUP    | What will be the prefix of generated dart references?                                                    |\n| `use_underscores`            | bool        | false            | GROUP    | Use underscore instead of camelcase for dart references?                                                    |\n| `types`            | List\u003cString\u003e    | All                | GROUP    | Which types of assets should be included?                                                                |\n| `generate_test`    | bool            | false            | GLOBAL    | Generate test cases to make sure that assets are still present in the project?                            |\n| `no_comments`    | bool            | false            | GLOBAL    | Removes all the `generated` comments from top of all generated dart code.Use this to avoid vcs noise.    |\n| `export`            | bool            | true            | GLOBAL    | Generates a dart file exporting all the generated classes. Can be used to avoid multiple exports.        |\n| `export_file`    | String        | resources.dart    | GLOBAL    | What will be the name of generated export file?                                                        |\n| `use_part_of`    | bool            | false            | GLOBAL    | Allows to opt in for using `part of` instead of exporting generated dart files.                            |\n| `use_references_list`    | bool            | false            | GLOBAL    | Generates value list just like enums which contains all the asset references of that class.                            |\n --\u003e\n\n### Watch Directory\n\nSpider can also watch given directory for changes in files and rebuild dart code automatically. Use following command to\nwatch for changes:\n\n```shell\nspider build --watch\n```\n\nsee help for more information:\n\n```shell\nspider build --help\n```\n\n### Smart Watch (Experimental)\n\nThe normal `--watch` option watches for any kind of changes that happens in the directory. However, this can be improved\nmy smartly watching the directory. It includes ignoring events that doesn't affect anything like file content changes.\nAlso, it only watches allowed file types and rebuilds upon changes for those files only.\n\nRun following command to watch directories smartly.\n\n```shell\nspider build --smart-watch\n```\n\n### Categorizing by File Extension\n\nBy default, Spider allows any file to be referenced in the dart code. but you can change that behavior. You can specify\nwhich files you want to be referenced.\n\n```yaml\npath: assets\nclass_name: Assets\npackage: res\ntypes: [ jpg, png, jpeg, webp, bmp, gif ]\n```\n\n### Use Prefix\n\nYou can use prefixes for names of the generated dart references. Prefixes will be attached to the formatted reference\nnames.\n\n```yaml\npath: assets\nclass_name: Assets\npackage: res\nprefix: ic\n```\n\n##### Output\n\n```dart\nclass Assets {\n  static const String icCamera = 'assets/camera.png';\n  static const String icLocation = 'assets/location.png';\n}\n```\n\n## Advanced Configuration\n\nSpider provides supports for multiple configurations and classifications. If you want to group your assets by module, type\nor anything, you can do that using `groups` in spider.\n\n### Example\n\nSuppose you have both vector(SVGs) and raster images in your project, and you want to me classified separately so that\nyou can use them with separate classes. You can use groups here. Keep your vector and raster images in separate folder\nand specify them in the config file.\n\n`spider.yaml`\n\n```yaml\ngroups:\n  - path: assets/images\n    class_name: Images\n    package: res\n  - path: assets/vectors\n    class_name: Svgs\n    package: res\n```\n\nHere, first item in the list indicates to group assets of `assets/images` folder under class named `Images` and the\nsecond one indicates to group assets of `assets/vectors` directory under class named `Svgs`.\n\nSo when you refer to `Images` class, auto-complete suggests raster images only, and you know that you can use them\nwith `AssetImage` and other one with vector rendering library.\n\n## Multi-path configuration\n\nFrom Spider `v0.4.0`, multiple paths can be specified for a single group to collect references from multiple directories\nand generate all the references under single dart class.\n\n#### Example\n\n```yaml\ngroups:\n  - paths:\n      - assets/images\n      - assets/more_images/\n    class_name: Images\n    package: res\n    types: [ .png, .jpg, .jpeg, .webp, .webm, .bmp ]\n```\n\nBy using `paths`, multiple source directories can be specified. Above example will generate references\nfrom `assets/images` and `assets/more_images/` under a single dart class named `Images`.\n\n## Generating Tests\n\nSpider `v0.4.0` adds support for generating test cases for generated dart references to make sure that the asset file is\npresent in the project. These tests can also be run on CI servers. To enable tests generation, specify `generate_tests`\nflag in `spider.yaml` or `spider.json` configuration file as shown below.\n\n```yaml\ngenerate_tests: true\n```\n\nThis flag will indicate spider to generate tests for all the generated dart references.\n\n## Generate `values` list\n\nFamiliar with `Enum.values` list which contains all the enum values? Spider also provides support for generating `values`\nlist for all the asset references in given dart class. \nUse `use_references_list` global config to enable `values` list generation. This is disabled by default as it can be\noverwhelming to have this code-gen if you don't need it.\n\n```yaml\n# global config\nuse_references_list: true\n```\n\n\n## Enable Verbose Logging\n\nSpider prefers not to overwhelm terminal with verbose logs that are redundant for most of the cases. However, those\nverbose logs come quite handy when it comes to debug anything. You can enable verbose logging by using `--verbose`\noption on build command.\n\n```shell\nspider build --verbose\n\n# watching directories with verbose logs\nspider build --watch --verbose\n```\n\n## Liked spider?\n\nShow some love and support by starring the repository. ⭐\n\nWant to support my work?\n\n\u003ca href=\"https://github.com/sponsors/BirjuVachhani\" target=\"_blank\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/BirjuVachhani/spider/main/.github/sponsor.png?raw=true\" alt=\"Sponsor Author\" style=\"!important;width: 600px !important;\" \u003e\u003c/a\u003e\n\nOr You can\n\n\u003ca href=\"https://www.buymeacoffee.com/birjuvachhani\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/default-blue.png\" alt=\"Buy Me A Coffee\" style=\"height: 51px !important;width: 217px !important;\" \u003e\u003c/a\u003e\n\n## License\n\n```\nCopyright © 2020 Birju Vachhani\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirjuvachhani%2Fspider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbirjuvachhani%2Fspider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbirjuvachhani%2Fspider/lists"}