{"id":15659001,"url":"https://github.com/ksxgithub/build-fs-tree","last_synced_at":"2025-04-07T11:07:30.735Z","repository":{"id":40416707,"uuid":"355797896","full_name":"KSXGitHub/build-fs-tree","owner":"KSXGitHub","description":"Generate a filesystem tree from a macro or a YAML tree","archived":false,"fork":false,"pushed_at":"2025-03-25T02:21:36.000Z","size":352,"stargazers_count":25,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T10:03:36.635Z","etag":null,"topics":["binary","crate","filesystem","json","library","rust","serde","tree"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/build-fs-tree","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KSXGitHub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"github":null,"patreon":"khai96_","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2021-04-08T07:02:31.000Z","updated_at":"2025-03-25T02:21:34.000Z","dependencies_parsed_at":"2023-12-19T06:29:15.145Z","dependency_job_id":"54ae61bb-215b-448c-947d-98bb4fceb2b4","html_url":"https://github.com/KSXGitHub/build-fs-tree","commit_stats":{"total_commits":275,"total_committers":3,"mean_commits":91.66666666666667,"dds":0.3418181818181818,"last_synced_commit":"196a28e54ebfc4c3a6e51c79cc3ab39dcdc7c7a5"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KSXGitHub%2Fbuild-fs-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KSXGitHub%2Fbuild-fs-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KSXGitHub%2Fbuild-fs-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KSXGitHub%2Fbuild-fs-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KSXGitHub","download_url":"https://codeload.github.com/KSXGitHub/build-fs-tree/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247640462,"owners_count":20971557,"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":["binary","crate","filesystem","json","library","rust","serde","tree"],"created_at":"2024-10-03T13:14:37.714Z","updated_at":"2025-04-07T11:07:30.717Z","avatar_url":"https://github.com/KSXGitHub.png","language":"Rust","funding_links":["https://patreon.com/khai96_"],"categories":[],"sub_categories":[],"readme":"# build-fs-tree\n\n[![Test](https://github.com/KSXGitHub/build-fs-tree/workflows/Test/badge.svg)](https://github.com/KSXGitHub/build-fs-tree/actions?query=workflow%3ATest)\n[![Crates.io Version](https://img.shields.io/crates/v/build-fs-tree?logo=rust)](https://crates.io/crates/build-fs-tree)\n\nGenerate a filesystem tree from a macro or a YAML tree.\n\n## Description\n\nWhen I write integration tests, I often find myself needing to create temporary files and directories. Therefore, I created this crate which provides both a library to use in a Rust code and a CLI program that generates a filesystem tree according to a YAML structure.\n\n## Usage Examples\n\n### The Library\n\nGo to [docs.rs](https://docs.rs/build-fs-tree/) for the full API reference.\n\n#### `FileSystemTree`\n\n`FileSystemTree::build` is faster than `MergeableFileSystemTree::build` but it does not write over an existing directory and it does not create parent directories when they don't exist.\n\n```rust\nuse build_fs_tree::{FileSystemTree, Build, dir, file};\nlet tree: FileSystemTree\u003c\u0026str, \u0026str\u003e = dir! {\n    \"index.html\" =\u003e file!(r#\"\n        \u003c!DOCTYPE html\u003e\n        \u003clink rel=\"stylesheet\" href=\"styles/style.css\" /\u003e\n        \u003cscript src=\"scripts/main.js\"\u003e\u003c/script\u003e\n    \"#)\n    \"scripts\" =\u003e dir! {\n        \"main.js\" =\u003e file!(r#\"document.write('Hello World')\"#)\n    }\n    \"styles\" =\u003e dir! {\n        \"style.css\" =\u003e file!(r#\":root { color: red; }\"#)\n    }\n};\ntree.build(\"public\").unwrap();\n```\n\n#### `MergeableFileSystemTree`\n\nUnlike `FileSystemTree::build`, `MergeableFileSystemTree::build` can write over an existing directory and create parent directories that were not exist before at the cost of performance.\n\nYou can convert a `FileSystemTree` into a `MergeableFileSystemTree` via `From::from`/`Into::into` and vice versa.\n\n```rust\nuse build_fs_tree::{MergeableFileSystemTree, Build, dir, file};\nlet tree = MergeableFileSystemTree::\u003c\u0026str, \u0026str\u003e::from(dir! {\n    \"public\" =\u003e dir! {\n        \"index.html\" =\u003e file!(r#\"\n            \u003c!DOCTYPE html\u003e\n            \u003clink rel=\"stylesheet\" href=\"styles/style.css\" /\u003e\n            \u003cscript src=\"scripts/main.js\"\u003e\u003c/script\u003e\n        \"#)\n        \"scripts/main.js\" =\u003e file!(r#\"document.write('Hello World')\"#)\n        \"scripts/style.css\" =\u003e file!(r#\":root { color: red; }\"#)\n    }\n});\ntree.build(\".\").unwrap();\n```\n\n#### Serialization and Deserialization\n\nBoth `FileSystemTree` and `MergeableFileSystemTree` implement `serde::Deserialize` and `serde::Serialize`.\n\n### The Program\n\nThe name of the command is `build-fs-tree`. It has 2 subcommands: [`create`](#create) and [`populate`](#populate).\n\n#### `create`\n\nThis command reads YAML from stdin and creates a new filesystem tree. It is the CLI equivalent of [`FileSystemTree`](#filesystemtree).\n\n_Create two text files in a new directory:_\n\n```sh\necho '{ foo.txt: HELLO, bar.txt: WORLD }' | build-fs-tree create foo-and-bar\n```\n\n_Create a text file and its parent directories:_\n\n```sh\necho '{ text-files: { foo.txt: HELLO } }' | build-fs-tree create files\n```\n\n_Create a new filesystem tree from a YAML file:_\n\n```sh\nbuild-fs-tree create root \u003c fs-tree.yaml\n```\n\n#### `populate`\n\nThis command reads YAML from stdin and either creates a new filesystem tree or add files and directories to an already existing directories. It is the CLI equivalent of [`MergeableFileSystemTree`](#mergeablefilesystemtree).\n\n_Create two text files in the current directory:_\n\n```sh\necho '{ foo.txt: HELLO, bar.txt: WORLD }' | build-fs-tree populate .\n```\n\n_Create a text file and its parent directories:_\n\n```sh\necho '{ files/text-files/foo.txt: HELLO }' | build-fs-tree populate .\n```\n\n_Populate the current directory with filesystem tree as described in a YAML file:_\n\n```sh\nbuild-fs-tree populate . \u003c fs-tree.yaml\n```\n\n## Packaging Status\n\n[![Packaging Status](https://repology.org/badge/vertical-allrepos/build-fs-tree.svg)](https://repology.org/project/build-fs-tree/versions)\n\n## Frequently Asked Questions\n\n### Why YAML?\n\nIt has the features I desired: Easy to read and write, multiline strings done right.\n\n### What about this cool configuration format?\n\nAccording to the UNIX philosophy, you may pipe your cool configuration format to a program that converts it to JSON (YAML is a superset of JSON) and then pipe the JSON output to `build-fs-tree`.\n\n## License\n\n[MIT](https://git.io/JOkew) © [Hoàng Văn Khải](https://ksxgithub.github.io/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksxgithub%2Fbuild-fs-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fksxgithub%2Fbuild-fs-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fksxgithub%2Fbuild-fs-tree/lists"}