{"id":15062246,"url":"https://github.com/sayjava/phake","last_synced_at":"2026-01-02T17:05:19.490Z","repository":{"id":177540440,"uuid":"654125843","full_name":"sayjava/phake","owner":"sayjava","description":"Effortlessly generate realistic mock data with Ease using Handlebars and fakerjs","archived":false,"fork":false,"pushed_at":"2023-07-22T15:42:25.000Z","size":1148,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-22T02:36:43.219Z","etag":null,"topics":["fake-data","faker-generator","handlebars","mock","mocking-utility","sample-data","sample-data-generator"],"latest_commit_sha":null,"homepage":"https://phake-d4468.web.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sayjava.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-06-15T12:46:02.000Z","updated_at":"2023-07-18T09:31:24.000Z","dependencies_parsed_at":"2024-11-21T08:36:04.402Z","dependency_job_id":null,"html_url":"https://github.com/sayjava/phake","commit_stats":null,"previous_names":["sayjava/phake"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayjava%2Fphake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayjava%2Fphake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayjava%2Fphake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayjava%2Fphake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sayjava","download_url":"https://codeload.github.com/sayjava/phake/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243725635,"owners_count":20337670,"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":["fake-data","faker-generator","handlebars","mock","mocking-utility","sample-data","sample-data-generator"],"created_at":"2024-09-24T23:32:52.655Z","updated_at":"2026-01-02T17:05:19.444Z","avatar_url":"https://github.com/sayjava.png","language":"TypeScript","readme":"\u003ch1 align=\"center\"\u003ePhake\u003c/h1\u003e\n\u003cp align=\"center\"\u003eEffortlessly Generate Realistic Mock Data with Ease using Handlebars and Fakerjs\u003c/p\u003e\n\u003cdiv align=\"center\"\u003e\u003ca href=\"https://phake-d4468.web.app/editor\"\u003eTry it online\u003c/a\u003e\u003c/div\u003e\n\n## Features\n\n- Utilize the power of declarative templates using\n  [Handlebars](https://handlebarsjs.com).\n- Seamlessly integrate with [Faker.js](https://fakerjs.dev) for generating\n  realistic and randomized data.\n- Enjoy the simplicity of a command-line interface for streamlined usage.\n- Incorporate the tool into your development process and easily version your\n  templates.\n- Promote code reuse and maintainability by creating DRY (Don't Repeat Yourself)\n  templates, allowing you to reuse template sections across multiple templates.\n- Leverage custom Handlebars helpers to simplify data creation and manipulation,\n  further enhancing the flexibility and functionality of your templates.\n\n## Quick Start\n\nCreate a template file named `sample.json.hbs` with the following content\n\n```template filename=\"sample.json.hbs\"\n {\n    \"id\": {{faker 'number.int' 10}},\n    \"node_id\": \"{{faker 'string.alpha' 25}}\",\n    \"name\": \"{{faker 'word.noun'}}\",\n    \"language\": \"{{randomize 'javascript' 'ruby' 'golang' 'c++'}}\",\n    \"forks_count\": {{faker 'number.int' max=10000}},\n    \"size\": {{faker 'number.float' max=10000 precision=0.2}},\n    \"default_branch\": \"{{randomize 'main' 'master'}}\",\n    \"open_issues_count\": {{faker 'number.int' max=50}},\n    \"is_template\": {{randomize false true}},\n    \"description\": \"{{faker 'lorem.sentences' max=3}}\",\n    \"topics\": [\n        {{#repeat 5}}\n            \"{{faker 'string.alpha' 5}}\"\n        {{/repeat}}\n    ]\n}\n```\n\nRun the `phake-cli` command to compile the template into user.json\n\n```shell\nnpx @sayjava/phake-cli compile -t sample.json.hbs\n```\n\n```json\n{\n  \"id\": 7,\n  \"node_id\": \"HSUWMxwXsVKxycdaVOiJFnlNe\",\n  \"name\": \"factory\",\n  \"language\": \"javascript\",\n  \"forks_count\": 4558,\n  \"size\": 8800,\n  \"default_branch\": \"master\",\n  \"open_issues_count\": 9,\n  \"is_template\": true,\n  \"description\": \"Aliquam sunt eveniet quam\",\n  \"topics\": [\n    \"UiqiJ\",\n    \"GdyVl\",\n    \"LUiDO\",\n    \"QEHha\",\n    \"Ksvjv\"\n  ]\n}\n```\n\n## Phake Compile\n\nThe Phake CLI uses [Handlebars](https://handlebarsjs.com) and\n[FakerJS](https://fakerjs.dev) to generate sample data for development purposes.\nIt allows you to define data templates using Handlebars syntax and generate\nrealistic sample data based on those templates, incorporating fake data\ngenerated by [FakerJS](https://fakerjs.dev).\n\n### Installation\n\n```shell\nnpm i -g @sayjava/phake-cli\n```\n\n### CLI Options\n\n| Flag           | Default | Description                             |\n| -------------- | ------- | --------------------------------------- |\n| -t, --template | -       | file/directory containing `.hbs` files  |\n| -o, --output   | cwd     | The directory to write the output files |\n\n## File Naming\n\nImprove the functionality of the `phake` CLI with the following enhancements:\n\n- The `phake` CLI now intelligently uses file extensions to name the output\n  files that are written to the output directory.\n- If no file extension is supplied, the output file will still be created but\n  without any file extension.\n- This flexible approach allows you to specify the desired file extension for\n  the output, providing compatibility with various file formats and ensuring\n  clarity in file naming.\n- You can now generate output files with the appropriate extensions, making it\n  easier to identify and work with the generated files.\n- This enhancement adds versatility to the `phake` CLI, catering to a wider\n  range of use cases and preferences.\n\nExamples\n\n| Input           | Output      |\n| --------------- | ----------- |\n| sample.json.hbs | sample.json |\n| sample.yaml.hbs | sample.yaml |\n| sample.hbs      | sample      |\n\n### Usage\n\n```shell\nphake compile -t name-of-template.hbs\n```\n\nCompile a folder containing `.hbs` files\n\n```shell\nphake -t dir/containing-hbs-files -o folder/to/write/output\n```\n\nCompile a single `[name].hbs` file\n\n```shell\nphake -t dir/containing/single.hbs -o folder/to/write/output\n```\n\nCompile a single `[name].json.hbs` file with an explicit file extension. This\nwill create `[name].json`\n\n```shell\nphake -t dir/containing/single.json.hbs -o folder/to/write/output\n```\n\n## DRY Templates with Handlebar's Partials\n\n- Enable easy reuse of template sections by naming them as `[name].partial.hbs`.\n- Partial files are not compiled individually but instead registered as\n  Handlebar partials. This allows them to be referenced and included within\n  other template files seamlessly.\n- By adopting this approach, you can efficiently organize and manage your\n  templates, promoting modular and reusable code.\n- The registration of partials ensures that changes made to a partial file\n  reflect automatically across all templates that reference it.\n- This method of partial registration enhances maintainability and reduces\n  duplication of code within your project.\n\nExample\n\n```hbs\n{\n  \"title\": \"{{ faker \"company.name\" }}\",\n  \"price\": \"{{ faker \"commerce.price\" min=100 max=200 dec=0 symbol='£' }}\"\n}\n```\n\nThe partial can then be referenced from other template files\n\n```hbs\n{\n  \"items\": [\n    {{#repeat 3}}\n        {{\u003e item }}\n    {{/repeat}}\n  ],\n}\n```\n\n## Template Helpers\n\n`phake` ships with some handy helpers that eases data generation. All\n[Handlebar Helpers](https://handlebarsjs.com/guide/builtin-helpers.html) are\nalso supported.\n\n| Helper      | Description                                                       | Example                                                   | options                                                                       |\n| ----------- | ----------------------------------------------------------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------- |\n| repeat      | Generates a comma separated list for creating arrays              | `[{{#repeat 5}} index-{{@index}} {{/repeat}}]`            | `number` Iteration count                                                      |\n| for         | Repeat items for the specified range                              | `{{#for 1 5}} index-{{@index}} {{/for}}`                  | `number` Iteration count                                                      |\n| randomize   | Randomize an array                                                | `{{randomize \"german shepard\" \"golden retriever\" \"pug\"}}` | `values` to be randomized                                                     |\n| var         | Register a variable to be used later                              | `{{#var 'myVar' 5 }}` then accessed later as `{{myVar}}`  | `name` of the variable, `value` of the variable                               |\n| imageURI    | Generate a URI encoded random patterned image using a seed string | `{{imageURI    'seedString'  }}`                          | `string` to use to seed the generated pattern, `color` to use for the pattern |\n| imageURL    | Generate a URL encoded random patterned image using a seed string | `{{imageURL    'seedString' #00FF00 }}`                   | `string` to use to seed the generated pattern, `color` to use for the pattern |\n| imageSVG    | Generate a SVG random patterned image using a seed string         | `{{imageSVG    'seedString'  }}`                          | `string` to use to seed the generated pattern, `color` to use for the pattern |\n| imageBase64 | Generate a base64 encoded random patterned image                  | `{{imageBase64 'seedString' }}`                           | `string` to use to seed the generated pattern, `color` to use for the pattern |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayjava%2Fphake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsayjava%2Fphake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayjava%2Fphake/lists"}