defuss
Project Creator
create-defuss
is a simple, lightweight CLI tool that enables Git sparse checkouts for subdirectories of GitHub repositories. Originally created to help jump-start projects using defuss templates, it can be used for any Git repository.
💡 Did you know? With just one command, you can checkout a specific subdirectory from a GitHub repository without cloning the entire project.
🚀 Getting Started
You're just one step away from checking out specific subdirectories:
Use the create-defuss
CLI:
To checkout a subdirectory from a repository, run the following command:
npx create-defuss <repository-url> [destination-folder]
Replace <repository-url>
with the URL to the GitHub subdirectory you want to checkout (e.g., https://github.com/user/repo/tree/branch/path
).
Optionally, specify a [destination-folder]
to customize where the files will be checked out.
Example
npx create-defuss https://github.com/kyr0/defuss/tree/main/examples/with-astro-ts ./my-new-project
This will download only the code from the with-astro-ts
subdirectory into the (new) folder my-new-project
.
⚙️ API usage
You can also use create-defuss
as library. It's super simple:
import { performSparseCheckout } from "create-defuss"
performSparseCheckout("git_url", "dest_folder")
🚀 How does defuss-vite
work?
create-defuss
is an NPM package with a bin
entry in package.json
. This, combined with a "shebang" line (#!/someshell
) makes it executable using npx
as a CLI (command line interface). It uses Git sparse checkout to efficiently download files from a specific subdirectory of a GitHub repository. It avoids downloading the entire repository, saving bandwidth and time. Also, monorepo maintainers can spare on creating extra "template" repositories for their example code.
Inside the project, you'll find the following relevant files:
/
├── src/cli.ts
├── src/git.ts
├── package.json
🧞 Commands
All commands are run from the root of the project, from a terminal:
npm build | Build a new version of the plugin. |
npm publish | Publish a new version of the defuss-vite integration package. |
Come visit us on defuss island!