{"id":13941298,"url":"https://github.com/efidiles/folder-template","last_synced_at":"2025-04-12T23:55:31.781Z","repository":{"id":57239675,"uuid":"71734023","full_name":"efidiles/folder-template","owner":"efidiles","description":"A directory / files generator based on templates","archived":false,"fork":false,"pushed_at":"2017-12-05T14:37:31.000Z","size":4269,"stargazers_count":13,"open_issues_count":4,"forks_count":7,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2025-04-12T23:55:26.531Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/efidiles.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":"2016-10-23T22:43:22.000Z","updated_at":"2024-08-12T10:51:21.000Z","dependencies_parsed_at":"2022-08-30T00:11:29.321Z","dependency_job_id":null,"html_url":"https://github.com/efidiles/folder-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efidiles%2Ffolder-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efidiles%2Ffolder-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efidiles%2Ffolder-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efidiles%2Ffolder-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/efidiles","download_url":"https://codeload.github.com/efidiles/folder-template/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248647232,"owners_count":21139083,"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":[],"created_at":"2024-08-08T02:01:15.950Z","updated_at":"2025-04-12T23:55:31.757Z","avatar_url":"https://github.com/efidiles.png","language":"JavaScript","readme":"## Jump to\n\n* [What is folder-template?](#overview)\n* [TL;DR and experienced devs](#tldr)\n* [Features](#features)\n* [Screenshots](#screenshots)\n* [Sample project](#sample-project)\n\n## Table of contents\n\n- [Overview](#overview)\n- [TL;DR](#tldr)\n- [Features](#features)\n- [Getting started](#getting-started)\n  * [Installing folder-template](#installing-folder-template)\n  * [Expose folder-template through npm scripts](#expose-folder-template-through-npm-scripts)\n  * [Define some templates](#define-some-templates)\n  * [Setup the .config file](#setup-the-config-file)\n  * [Generate files / folders](#generate-files-folders)\n- [Screenshots](#screenshots)\n- [Notes](#notes)\n- [Sample project](#sample-project)\n- [License](#license)\n\n## Overview \n[[jump to TOC](#jump-to)]\n\nfolder-template is an easy to use directory / files generator.  \n\nIts main purpose is to help with generation of components, modules and other folder / files structures from predefined and easy to configure templates.\n\nIt's a simpler and more focused alternative to `angular-cli` and similar tools.  \n\nCheck the [screenshots](#screenshots) to quickly get a better idea.\n\n## TL;DR \n[[jump to TOC](#jump-to)]\n\n1. Install the package:  \n```sh\n$ npm install folder-template --save-dev\n```\n\n2. Expose the CLI through your `package.json`'s `scripts`:  \n```js\n{\n    ...\n    \"scripts\": {\n        ...\n        \"generate\": \"ft\"\n    }\n    ...\n}\n```\n\n3. Define templates inside a `/templates` directory located in your project's root:  \nSamples [here](https://github.com/efidiles/folder-template/tree/master/examples/sample-templates)\n\n4. Define questions and variable names inside a `.config` located in each template folder (Eg: `/templates/component/.config`) \n\n5. Run the npm command to generate files / folders:  \n  \n```sh\n$ npm run generate component ./\n```\n`component` being a folder name from your `/templates` directory and `./` is the destination path.\n## Features \n[[jump to TOC](#jump-to)]\n\n- Simple configuration\n- Ability to query the user for data\n- Compilation is done using [handlebars](https://www.npmjs.com/package/engine-handlebars)\n- Access to all [handlebars helpers](https://www.npmjs.com/package/handlebars-helpers)\n- Supports nested structures\n\n## Getting started \n\nnpm: [https://www.npmjs.com/package/folder-template](https://www.npmjs.com/package/folder-template)  \ngithub: [https://github.com/efidiles/folder-template](https://github.com/efidiles/folder-template)\n\n### Installing folder-template \n[[jump to TOC](#jump-to)]\n\n```sh\n$ npm install folder-template --save-dev\n```\n\nThis adds the `ft` CLI command locally to your project and can now be used in your project's npm scripts.\n\n### Expose folder-template through npm scripts \n[[jump to TOC](#jump-to)]\n\nAdd the following to your project's `package.json`'s `scripts` section:\n\n```js\n{\n    ...\n    \"scripts\": {\n        ...\n        \"generate\": \"ft\"\n    }\n    ...\n}\n```\nThis will basically create a npm task in your project which basically exposes the CLI of the `folder-template` package. \n\n### Define some templates \n[[jump to TOC](#jump-to)]\n\nNow we need some templates inside a `/templates` directory in the root of your project.  \nThere are a few available in the [/examples/sample-templates](https://github.com/efidiles/folder-template/tree/master/examples/sample-templates) directory of `folder-template`'s github repository.  \nThe sample templates are for Angular 2 but similarily they can be generated for any framework.\n\nBasically every folder inside the `/templates` directory is a template.  \nWhatever is inside each of these folders (except `.config` file) will be compiled with handlebars and copied in the specified destination.\n```\n|-- project-root\n|   |-- templates\n|   |   |-- component\n|   |   |   |-- {{hyphenate name}}\n|   |   |   |   |-- {{hyphenate name}}.component.css.tpl\n|   |   |   |   |-- {{hyphenate name}}.component.html.tpl\n|   |   |   |   |-- {{hyphenate name}}.component.ts.tpl\n|   |   |   |-- .config\n|   |   |-- service\n|   |   |   |-- {{hyphenate name}}.service.ts.tpl\n|   |   |   |-- .config\n|   |-- package.json\n|   |-- Gruntfile.js\n|   |-- LICENSE.md\n|   |-- README.md\n```\n### Setup the .config file \n[[jump to TOC](#jump-to)]\n\nWhen you run folder-template, the CLI will ask some questions to collect data to populate the templates.  \n\nThe questions and the variable names to store the answers are defined inside a `.config` folder inside each of the templates folders.  \nFor example the [.config](https://github.com/efidiles/folder-template/blob/master/examples/sample-templates/component/.config) \nfile inside the [/templates/component](https://github.com/efidiles/folder-template/blob/master/examples/sample-templates/component)\ndirectory contains the following code:\n\n```\n{\n  \"meta\": {\n    \"description\": \"This is some optional description. Eg. Please enter all the input in 'hyphen-case':\"\n  },\n  \"name\": \"Enter name for the new component:\",\n  \"selector\": \"Enter the name of the selector:\"\n}\n```\nThe key names (`name`, `selector`) become handlebars variables to be used inside the templates and the filenames.  \nThey will be replaced with the answers given to the questions.  \nThe `meta.description` property is optional and holds some optional instructions to display to the user before collecting the data.\n\n### Generate files / folders \n[[jump to TOC](#jump-to)]\n\nAssuming that the steps above were followed, you can\nstart generating files and folders using commands like the following (in your project's root directory):\n\n```sh\n$ npm run generate component ./\n```\n\nWhere:\n- `generate` is the alias to `folder-template` CLI (`ft`) defined in `scripts` property of `package.json`\n- `component` is the name of one of the direct folders inside `/templates` directory from your project's root (specifically [these](https://github.com/efidiles/folder-template/tree/master/examples/sample-templates))\n- and `./` is the path where you want the generated files to appear (relative to your project's root)\n\nYou should now be asked some questions about the new component (based on the `.config` file) and\nthen you should find a new folder with the name you specified in the root of your project. \n\n## Screenshots \n[[jump to TOC](#jump-to)]\n\n**1. Define a `templates` directory in your project's root directory:**  \n\u003ca href=\"https://github.com/efidiles/folder-template\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/efidiles/folder-template/master/docs/templates-folder.png\"\u003e  \n\u003c/a\u003e\n\n**2. Setup your templates and specify variables and questions in a `.config` file sitting in each template folder:**  \n\u003ca href=\"https://github.com/efidiles/folder-template\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/efidiles/folder-template/master/docs/config-file.png\"\u003e  \n\u003c/a\u003e\n\n**3. Generate a template and you'll be queried for data based on the `.config` file:**  \n\u003ca href=\"https://github.com/efidiles/folder-template\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/efidiles/folder-template/master/docs/questions.png\"\u003e  \n\u003c/a\u003e\n\n**Completion screen:**  \n\u003ca href=\"https://github.com/efidiles/folder-template\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/efidiles/folder-template/master/docs/completion-screen.png\"\u003e  \n\u003c/a\u003e\n\n**Example of template contents:**  \n\u003ca href=\"https://github.com/efidiles/folder-template\"\u003e\n    \u003cimg src=\"https://raw.githubusercontent.com/efidiles/folder-template/master/docs/template-file-contents.png\"\u003e  \n\u003c/a\u003e\n\n## Notes \n[[jump to TOC](#jump-to)]  \nYou can use handlebars to parametrise both the contents of files and also the names of the directories and files. Examples [here](https://github.com/efidiles/folder-template/tree/master/examples/sample-templates).  \nYou can also use all the [handlebars helpers](https://www.npmjs.com/package/handlebars-helpers) as can be seen in the examples and in [screenshots](#screenshots).\n\n## Sample project \n[[jump to TOC](#jump-to)]\n\nThere is a sample project in the [github repo](https://github.com/efidiles/folder-template/tree/master/examples/sample-project) inside [/examples/sample-project](https://github.com/efidiles/folder-template/tree/master/examples/sample-project)\n\nTo use it, clone the repo:  \n```\ngit clone git@github.com:efidiles/folder-template.git  \n```\nnavigate to `/examples/sample-project`:  \n```\ncd folder-template/examples/sample-project\n```\nrun:  \n```\nnpm run generate component ./\n```\n(no need for `npm install` as it will be done automatically) \n\n## Authors \n[[jump to TOC](#jump-to)]\n\n**Eduard Fidiles**\n\n* [github/efidiles](https://github.com/efidiles)\n* [twitter/efidiles](http://twitter.com/efidiles)\n\n**John Kilpatrick**\n\n* [github/jjkilpatrick](https://github.com/jjkilpatrick)\n* [twitter/jjkilpatrick](http://twitter.com/jjkilpatrick)\n\n## License \n[[jump to TOC](#jump-to)]\n\nCopyright © 2016, [Eduard Fidiles](https://github.com/efidiles).\nReleased under the [MIT license](https://github.com/folder-template/folder-template/blob/master/LICENSE).\n\nBased on [assemble](https://www.npmjs.com/package/assemble)","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefidiles%2Ffolder-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fefidiles%2Ffolder-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefidiles%2Ffolder-template/lists"}