{"id":15022253,"url":"https://github.com/rusith/gimbli","last_synced_at":"2025-04-12T06:18:05.794Z","repository":{"id":36831692,"uuid":"230185346","full_name":"rusith/gimbli","owner":"rusith","description":"File Generator to Generate Multiple Files From Single Template","archived":false,"fork":false,"pushed_at":"2023-01-05T03:41:02.000Z","size":244,"stargazers_count":5,"open_issues_count":10,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T06:17:53.911Z","etag":null,"topics":["file","generator","node"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/gimbli","language":"TypeScript","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/rusith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-26T03:03:35.000Z","updated_at":"2023-08-23T10:54:45.000Z","dependencies_parsed_at":"2023-01-17T05:26:57.289Z","dependency_job_id":null,"html_url":"https://github.com/rusith/gimbli","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusith%2Fgimbli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusith%2Fgimbli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusith%2Fgimbli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusith%2Fgimbli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rusith","download_url":"https://codeload.github.com/rusith/gimbli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248525141,"owners_count":21118620,"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":["file","generator","node"],"created_at":"2024-09-24T19:57:42.208Z","updated_at":"2025-04-12T06:18:05.740Z","avatar_url":"https://github.com/rusith.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Gimbli \n\nIt is a command-line utility that can generate multiple files using a single template file.\n\n[![codecov](https://codecov.io/gh/rusith/gimbli/branch/master/graph/badge.svg)](https://codecov.io/gh/rusith/gimbli)\n![](https://github.com/rusith/gimbli/workflows/Test/badge.svg)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/50acc66394c747e7b4cd642fb731cf5a)](https://www.codacy.com/manual/rusith/gimbli?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=rusith/gimbli\u0026amp;utm_campaign=Badge_Grade)\n[![npm](https://img.shields.io/npm/v/gimbli?color=red\u0026label=NPM)](https://www.npmjs.com/package/gimbli)\n\n## Installation\n\n#### You will need NodeJS installed to run Gimbli.\n\nyou can install Gimbly by running \n\n```\nnpm i -g gimbli\n```\n\nThis will register the command `gimbli` globally.\n\nOr you can use NPX to run Gimbli (`npx gimbli`)\n\n## Reporting Issues\n\nThis tool is still young and needs feedback to improve. if you find anything wrong, just add an issue in [Github](https://github.com/rusith/gimbli/issues)\n\n\n## Why This?\n\nWhen writing software, sometimes we have to repeat the task of creating the same set of files again and again. this is especially apparent when working with front-end frameworks like React, Angular, Vue and so on. This repetitive task is certainly a pain and is time-consuming. If we could take the repeated boilerplate code and create a command that will do the file generation for us, that will save many minutes of the developer's time. this is what this tool tries to achieve.\n\n## How Gimbli Solves the Problem?\n\nGimbli allows the user to create templates that can contain content for multiple files in them. and the developer can run the template using one command. Gimbli supports Handlebars inside the template so the developer can create dynamic content easily.\n\n## An Example\n\nIf we take a react app as an example, we most of the time create 3 files for one component. which are `Component.jsx`, `Component.module.css`, `index.js`.\n\nInstead of creating these three files manually, we can use Gimbli.\n\nfor that, we have to create a `templates` folder inside the project folder. and put a file named `component.gimbli`. the name will be the name of the command but the `.gimbli`  extension is required.\n\nThe template can be something like below.\n\n```\n@#args\nprops\ninitialContent\n#@\n\n\n@#file($path/$name.jsx)\nimport React from \"react\"\nimport styles from \"./$name.module.css\";\n\nconst $name = ({{props}}) =\u003e {\n  return (\n    \u003c\u003e{{initialContent}}\u003c/\u003e\n  );\n};\n\nexport default $name;\n#@\n\n@#file($path/index.js)\nimport $name from \"./$name\";\nexport default $name;\n#@\n\n\n@#file($path/$name.module.css)\n.root {\n\n}\n#@\n```\n\nWhat are all these?\n`@#args` declare the arguments that can be used in this template. args can be passed through the command. and you can use these values inside the files. or even inside file paths.\n\n`@#file` declares a file. in this template, there are three files. and inside the parentheses of the declaration, you can provide where the individual file should go.\n\neach section must end with `#@`.\n\nSo now the template is ready, we can run Gimbli to execute the template. \n\nThe command should look like below.\n\n```sh\ngimbli component myapp/components/button/Button -props \"text, onClick\" -initialContent \"Button\"\n```\nRunning this will generate the three files (`Button.jsx`, `Button.module.css` and `index.js`) inside `myapp/components/button` folder.\n\n\n## Template Syntax\n\nA template file (.gimbli) file can have two types of sections. `args` and `file`.\n\n### Args\n\nThe `args` section lists the arguments used in the template. each argument should be in a new line.\n\nexample:\n\n```\n@#args\nname\nisAbstract\n#@\n```\n\n### Files\n\nA file section declares the content of a file and its location.\n\nexample:\n\n```\n@#file($path/$name.ts)\ncontent\n#@\n```\n\nInside the parenthesis, you provide the path (relative to the current directory) that the file will be created. You can use `$path` and `$name` placeholders inside the parenthesis. and you can use arguments inside the parenthesis. eg: `$path/{{className}}.cs`\n\nWithin the section, you can provide the dynamic content of the file. in here the Handlebars syntax is fully supported. you can also use `$path` and `$name` placeholders here.\n\n**Files can have a condition which tells the file should only be created if the condition evaluates to true.**\n\neg:\n\n```\n@#if(name.startsWith(\"App\"))\n@#file($path/$name.ts)\ncontent\n#@\n```\n\nInside the parenthesis is a Javascript expression that will be evaluated safely on the argument values. you can use any argument including `name` and `path` inside this condition.\n\n\n## Arguments\n\n*Only the arguments that are defined in the template are taken into consideration*. for example, if you pass `-name SomeName` into the command and if `name` is not declared in the template, it will be ignored.\n\nThe default value of arguments is `true`. so if you pass `-isAbstract` without a value it will be true by default.\n\nThere are two types of arguments you can provide with a command. \n\n### Value Arguments\n\nThese are passed into the template and must be defined in the template's args section. value arguments should start with one hyphen (`-argName`)\n\n\nYou can pass anything to the value. the value should be the next immediate argument in the command. eg: `-componentName TestComponent`.\n\nYou can wrap the value in quotes if the value contains spaces.\n\n**Passing compound values** such as arrays and objects can be done by adding `#j` at the beginning of the value. this will tell Gimbli to parse the value as a JavaScript value and pass it to the template. (this will be evaluated safely)\n\neg: `gimbli class Main/TestClass -props \"#j[\"name\", \"id\"]\"`\n\neg: `gimbli class Main/TestClass -props \"#j{ name: \"TestClass\", isAbstract: true }\"`\n\n### Special Arguments\n\nThese are the arguments that are passed for changing Gimbli behavior. Special arguments must start with two hyphens. (`--argName`). \n\nAll special arguments can be in the configuration file also and **passing the argument will override the configuration file values**\n\nThese arguments won't be passed into the template.\n\nSupported arguments:\n\n* `templateDir` - passing a relative folder path to this will tell Gimbli to search template files inside the given folder instead of the `./templates` folder.\n\n\n## Configuration File\n\nYou can add a `gimbli.json` file in the project root to specify config values instead of passing them to the command every time. currently, there is only one configuration value that is `templateDir`\n\neg:\n```json\n{\n  \"templateDir\": \"./gimbli-templates\"\n}\n```\n\n## Contributing\n\nFeel free to send pull requests at any time. And any type of contribution is greatly appreciated.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusith%2Fgimbli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frusith%2Fgimbli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusith%2Fgimbli/lists"}