Skip to content

Repository files navigation

Social Card of this repo

npm versionGitHub ActionsCommitizen friendly

) -->

gitit

A powerful template and project scaffolding tool to help kick-start development of your next project.

Features

Gitit comes with the following features:

  • 🚀 Fast Template CloningClone templates from GitHub, GitLab, Bitbucket, and more
  • 💪 Fully Typed APIsWritten in TypeScript for a great developer experience
  • 📦 Zero ConfigurationWorks out of the box with sensible defaults
  • 🔄 Offline SupportUse cached templates when offline
  • 🛠️ CustomizableConfigure templates with various options
  • 🧩 Post-Installation CommandsRun custom commands after cloning
  • 🔑 Private Repository SupportAuthentication for private templates
  • 🖥️ Interactive ShellOpen a shell in your newly created project

Get Started

# Install globally
bun install -g @stacksjs/gitit
# or use directly with bunx
bunx @stacksjs/gitit github:user/repo my-project

Usage

# Basic usage
gitit github:user/repo my-project
# With options
gitit github:user/repo my-project --install --shell
# Clone with custom command
gitit github:user/repo my-project --command "npm run dev"# Use offline cached template
gitit github:user/repo my-project --offline
# Clone to a specific directory
gitit github:user/repo ./path/to/project

Available Options

OptionDescription
--forceClone to existing directory even if it exists
--force-cleanRemove any existing directory or file recursively before cloning
--shellOpen a new shell with current working directory
--installInstall dependencies after cloning
--verboseShow verbose debugging info
--commandCustom command to run after template is cloned
--authCustom Authorization token for private repositories
--cwdSet current working directory to resolve dirs relative to it
--offlineDo not attempt to download and use cached version
--prefer-offlineUse cache if exists otherwise try to download

Library Usage

Gitit can also be used programmatically in your Node.js or Bun applications:

import{downloadTemplate}from'@stacksjs/gitit'// Basic usageawaitdownloadTemplate('github:user/repo')// With optionsconstresult=awaitdownloadTemplate('github:user/repo',{dir: './my-project',force: true,install: true,offline: false,preferOffline: true})console.log(`Downloaded to ${result.dir}`)

API Reference

downloadTemplate(source, options)

The main function for downloading templates.

  • source: string - Template source (e.g., "github:user/repo")
  • options: DownloadTemplateOptions - Configuration options
interfaceDownloadTemplateOptions{provider?: string// Specify provider (github, gitlab, etc.)force?: boolean// Force clone even if directory existsforceClean?: boolean// Remove existing directory before cloningoffline?: boolean// Use cached version onlypreferOffline?: boolean// Prefer cache if existsdir?: string// Target directoryregistry?: false|string// Registry URL or false to disablecwd?: string// Current working directoryauth?: string// Auth token for private repositoriesinstall?: boolean// Install dependencies after downloadsilent?: boolean// Hide installation outputhooks?: Hooks// Custom lifecycle hooks}

Return value

interfaceDownloadTemplateResult{dir: string// The directory where template was extractedsource: string// Original source stringname: string// Template nametar: string// Tarball URLversion?: string// Template versionurl?: string// Repository URL// ... additional properties}

Advanced: Custom Plugins

You can extend gitit's functionality using plugins:

import{downloadTemplate}from'@stacksjs/gitit'constmyPlugin={name: 'my-plugin',version: '1.0.0',hooks: {afterExtract: (result)=>{console.log(`Template extracted to ${result.dir}`)returnresult}},providers: {myCustomSource: (input,options)=>{// Custom template provider logicreturn{name: 'my-template',tar: 'https://example.com/template.tar.gz'}}}}awaitdownloadTemplate('mycustom:template',{plugins: [myPlugin]})

Changelog

Please see our releases page for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discussions on GitHub

For casual chit-chat with others using this package:

Join the Stacks Discord Server

Postcardware

"Software that is free, but hopes for a postcard." We love receiving postcards from around the world showing where Stacks is being used! We showcase them on our website too.

Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094, United States 🌎

Sponsors

We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.

License

The MIT License (MIT). Please see LICENSE for more information.

Made with 💙

About

A simple way to download templates stored using git.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

3 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Used by

Contributors

Languages