{"id":13448640,"url":"https://github.com/fabiospampinato/template","last_synced_at":"2025-06-22T15:36:51.289Z","repository":{"id":66053428,"uuid":"102024301","full_name":"fabiospampinato/template","owner":"fabiospampinato","description":"A super-simple way to create new projects based on templates.","archived":false,"fork":false,"pushed_at":"2023-09-24T16:28:50.000Z","size":2398,"stargazers_count":150,"open_issues_count":0,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-16T09:38:00.855Z","etag":null,"topics":["cli","handlebars","picolate","scaffold","simple","template"],"latest_commit_sha":null,"homepage":"","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/fabiospampinato.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,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":"fabiospampinato","custom":"https://www.paypal.me/fabiospampinato"}},"created_at":"2017-08-31T17:00:59.000Z","updated_at":"2024-07-25T01:03:58.000Z","dependencies_parsed_at":"2024-04-06T04:31:32.396Z","dependency_job_id":"5c8a9410-e5cc-44c7-ba6c-19ee429c03b3","html_url":"https://github.com/fabiospampinato/template","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":"0.030303030303030276","last_synced_commit":"b2ffde0cc90147bcb13dfe46079660feaec4a35c"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/fabiospampinato/template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiospampinato%2Ftemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiospampinato%2Ftemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiospampinato%2Ftemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiospampinato%2Ftemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabiospampinato","download_url":"https://codeload.github.com/fabiospampinato/template/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabiospampinato%2Ftemplate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261315779,"owners_count":23140338,"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","handlebars","picolate","scaffold","simple","template"],"created_at":"2024-07-31T05:01:51.406Z","updated_at":"2025-06-22T15:36:46.280Z","avatar_url":"https://github.com/fabiospampinato.png","language":"TypeScript","funding_links":["https://github.com/sponsors/fabiospampinato","https://www.paypal.me/fabiospampinato"],"categories":["TypeScript","Templates","cli"],"sub_categories":[],"readme":"\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"resources/logo.png\" width=500 alt=\"Logo\"\u003e\n\u003c/p\u003e\n\nA super-simple way to create new projects based on templates.\n\nA list of known active templates for this program can be found [here](https://github.com/fabiospampinato/awesome-template).\n\n## Install\n\n```sh\nnpm install -g @fabiospampinato/template\n```\n\n## Usage\n\nhttps://github.com/fabiospampinato/template/assets/1812093/4c53bf75-eb08-49c2-8b7f-8dae6dfa04eb\n\n\u003cdetails\u003e\n\u003csummary\u003eOverview\u003c/summary\u003e\n\nAt a high level a template looks like this:\n\n1. A template is just a folder installed locally simply by `git clone`-ing it into `~/.templates`, or you can copy it manually there.\n2. Each template has a folder named \"template\" inside it, which is what will be used for creating projects.\n3. Each template has a \"template.json\" file inside it, which lists all variables used by files inside the \"template\" folder.\n4. Each template may optionally have a folder named \"hooks\" inside it, containing files that will be executed at the appropriate times.\n\nWhen creating a project from a template this happens:\n\n1. The user is asked to provide a value for each variable listed by the template inside its \"template.json\" file.\n2. The entire \"template\" folder inside the template is duplicated.\n3. Each non-binary file inside this folder is rendered with [`picolate`](https://github.com/fabiospampinato/picolate) using the provided variables.\n4. All rendered and binary files are copied in a newly created folder that has the name of the project you want to create.\n5. The postinstall hook, if present, is executed.\n6. That's it.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eCommand Line Interface\u003c/summary\u003e\n\nThe following commands are available:\n\n```sh\n# Show help for the entire program\ntemplate --help\n\n# Show help for a specific command\ntemplate install --help\n\n# List all installed templates\ntemplate ls\n\n# CD into an installed template\ntemplate cd my-template\n\n# Install a template using a custom git endpoint\ntemplate install https://gitlab.com/some-user/some-repo.git my-template\n\n# Install a template using a GitHub url\ntemplate install https://github.com/fabiospampinato/template-typescript-package typescript-package\n\n# Install a template using a GitHub shorthand\ntemplate install fabiospampinato/template-typescript-package typescript-package\n\n# Install a template from a local path\ntemplate install ./work-in-progress-template wip-template\n\n# Automatically update all templates backed by git\ntemplate update\n\n# Automatically update a specific template\ntemplate update my-template\n\n# Uninstall a template\ntemplate uninstall my-template\n\n# Create a new project from a template\ntemplate new typescript-package my-package\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eTemplate Folder\u003c/summary\u003e\n\nAs mentioned in the \"Overview\" section a template must have this structure on disk:\n\n```\n.\n├── hooks (optional)\n│   └── postinstall.js (optional)\n├── template\n│   └── \u003canything\u003e\n└── template.json\n```\n\n- You can put any files and folders you want under the \"template\" folder.\n- Everything inside it will be copied when creating a new project from it, and non-binary files will be rendered with [`picolate`](https://github.com/fabiospampinato/picolate) before saving them to disk.\n- Syntax highlighting for those files in your editor will probably be broken, but if you change the language to \"Handlebars\" it should look nice again.\n- Hooks are optional, each of them must export a function, that this program will call at the right times. Inside hooks `process.cwd ()` will return the path of the new project.\n- The following hooks are supported:\n  - `postinstall.js`: it will be called right after a new project has been created. It will receive the object of variables used to render the project.\n\nThe \"template.json\" file should look somewhat like this:\n\n```jsonc\n{\n  \"delimiters\": [ // This is optional\n    \"start\": \"[[\",\n    \"end\": \"]]\"\n  ],\n  \"variables\": {\n    \"name\": {\n      \"type\": \"string\"\n    },\n    \"description\": {\n      \"type\": \"string\"\n    },\n    \"version\": {\n      \"type\": \"string\",\n      \"default\": \"1.0.0\"\n    },\n    \"author\": {\n      \"type\": \"string\"\n    },\n    \"owner\": {\n      \"type\": \"string\"\n    },\n    \"scoped\": {\n      \"type\": \"boolean\"\n    },\n    \"tested\": {\n      \"type\": \"boolean\"\n    }\n  }\n}\n```\n\n- Custom template delimiters that [`picolate`](https://github.com/fabiospampinato/picolate) will use can be provided, if you need them.\n- The user will be prompted to provide a value for each variable you list here.\n- You should list every single variable referenced by any of your template files.\n- A variable can either be of type \"string\" or of type \"boolean\".\n- A variable can also provide a default value, to allow the user to use that value quickly just by pressing enter.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eTemplate Overrides\u003c/summary\u003e\n\nAs we saw in the \"Templates Folder\" section each template must provide a metadata \"template.json\" file, listing all the variables it uses, and optionally providing some default values for them.\n\nThere's also a way to override this metadata, by having a file at `~/.templates/templates.json` that looks like this:\n\n```json\n{\n  \"typescript-package\": {\n    \"variables\": {\n      \"author\": {\n        \"default\": \"Fabio Spampinato\"\n      },\n      \"owner\": {\n        \"default\": \"fabiospampinato\"\n      }\n    }\n  },\n  \"some-other-template\": {\n    \"variables\": {\n      \"someOtherVariable\": {\n        \"default\": \"Some default value\"\n      }\n    }\n  }\n}\n```\n\nThis is very useful because:\n\n- In order for a template to be usable by a wide range of people it makes no sense to specify for example a default value for the \"author\" variable.\n- Still, once you install a template you probably know who the author is going to be, and you don't want to type out that informattion a million times, so this way you can override defaults for a template.\n\n\u003c/details\u003e\n\n## License\n\nMIT © Fabio Spampinato\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiospampinato%2Ftemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabiospampinato%2Ftemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabiospampinato%2Ftemplate/lists"}