Giter VIP home page Giter VIP logo

backpack's Introduction





๐ŸŽ’ Backpack

Use template and starter projects easily.

$ bp new user/repo

โœ… A supercharged scaffolding machine
โœ… Grab subfolders, branches, tags from template projects
โœ… Personalize shortlinks and projects for individuals and teams
โœ… Fast clone
โœ… Apply files into current project
โœ… No history or .git folder
โœ… Local cache support

๐Ÿš€ Quick Start

For macOS:

brew tap rusty-ferris-club/tap && brew install backpack

Otherwise, grab a release from releases and run bp --help:

$ bp --help
backpack 1.0.0
Create projects from existing repos

USAGE:
    backpack <SUBCOMMAND>

OPTIONS:
    -h, --help       Print help information
    -V, --version    Print version information

SUBCOMMANDS:
    apply     apply remote files into a folder [projects: a]
    cache     cache handling
    config    create custom configuration
    help      Print this message or the help of the given subcommand(s)
    new       initialize a new project [projects: n]

๐Ÿ”จ Using Backpack

bp scaffolds projects for you, or copies parts of a project using shortlinks, which is a quick and easy way to describe repos and files to copy from them.

You can also save a list of your favorite projects to use as shortcuts.

๐Ÿ”— What's a shortlink?

A shortlink is a pointer to a Git repo which looks like this:

shortlink

Any one of these is a legal shortlink:

user/repo -> resolves to https://github.com/user/repo
gl:user/repo -> resolves to https://gitlab.org/user/repo
user/repo/-/subfolder -> takes only 'subfolder'
user/repo#wip -> takes the 'wip' branch

โœ… Bare minimum is user/repo which defaults to Github.
โœ… You can set up a custom prefix if you want.

๐Ÿšค Scaffolding interactively

$ bp new
or
$ bp apply

And follow the interactive menu, which will let you:

  • Pick a project, if you have any configured
  • Input a shortlink
  • Input a destination or pick an auto generated one

๐Ÿ—๏ธ Scaffolding new projects

$ bp new kriasoft/react-starter-kit my-react-project

โœ… Use new to create a new project into my-react-project
โœ… Resolves to https://github.com/kriasoft/react-starter-kit
โœ… Finds the default branch, downloads it and caches locally. Next time you run, it'll be much faster.

You can start with your new project:

$ cd my-react-project
$ git init .
$ yarn

โ†ช๏ธ Applying templates to existing projects

Let's say you really like how react-starter-kit configured its Github Action, and you'd like to copy that to your existing project. You can do this:

$ bp apply kriasoft/react-starter-kit/-/.github

โœ… Use /-/ to access a subfolder
โœ… Use apply to overlay files onto your current working directory

๐ŸŒฒ Using branches

Branches or tags can be used with the #branch specifier.

$ bp new kriasoft/react-starter-kit#feature/redux my-starter

๐Ÿ‘ฉโ€๐Ÿ’ป Using git for private repos

For private repos, you might want to download over Git SSH protocol, add --git to your commands:

$ bp new kriasoft/react-starter-kit --git

๐Ÿ•น๏ธ Configuration

backpack is built for teams. This means you can configure your own shortcuts (called projects) to Git hosting vendors, organizations, and repos.

๐Ÿ™‹โ€โ™€๏ธ Configuring user projects

If you have a template project you always use, you can give it a shortcut name, or a "project".

Start by generating a global user configuration file:

$ bp config --init --global

And edit the file:

$ code ~/.backpack/backpack.yaml

To add projects you can use the projects section:

projects:
  rust-starter: 
    shortlink: rusty-ferris-club/rust-starter

For projects that are either new scaffolds or those which want to take components from, you can specify the mode to show the correct list in the interactive wizard:

projects:
  rust-starter: 
    shortlink: rusty-ferris-club/rust-starter
    mode: apply # or new, or remove property.

And now you can use:

$ bp new rust-starter

Which will resolve to the correct location. Note: projects will automatically resolve custom Git vendors (see below for what these are).

๐Ÿ”— Using remote project sources

You can create a configuration of favorite projects and put it online, to share with your team or save for yourself. Then:

$ bp new -r https://<url to YAML>
# file content:
projects:
  rust:
    shortlink: rusty-ferris-club/rust-starter

Running with this remote will show you through the available projects and also offer to save the source in your configuration.

Here's a an example from our own backpack-tap repo.

๐Ÿท๏ธ Configuring custom Git vendors

Start by generating a project-local configuration file:

$ bp config --init
wrote: .backpack.yaml.

Example: configure a Github Enterprise instance:

vendors:
  custom:
    ghe: # <--- this prefix is yours
      kind: github
      base: enterprise-github.acme.org
             # `---- it will point here now

And now, you can use the ghe: prefix for your shortlinks:

$ bp new ghe:user/repo

You can check in the .backpack.yaml to your project to share it with your team. When backpack runs it will pick it up automatically.

You can also generate a global user config by specifying:

$ bp config --init --global

FAQ

Is it possible to use backpack only on parts of source repos?

Yes, use the folder notation /-/:

$ bp new user/repo/-/path/to/folder dest-folder

How do I update projects or remove cache?

Use bp cache to manage cached versions. Remove your cache to force updates:

$ bp cache --rm

To show your cache, use:

$ bp cache --path

Can I use backpack on empty or populated directories?

Yes. Use apply to grab content and apply it to an existing empty or populated directories:

$ cd your-directory
$ bp apply user/repo .

Can backpack work on self hosted Git servers?

If it's one of the supported vendors, you can create a custom prefix configuration:

vendors:
  custom:
    gh:
      kind: github
      base: github.acme.com/my-org

Note that in addition to the custom hosted github.acme.com server, we also specified a default org my-org above, so it saves a bit of typing. Then you can run:

$ bp new gh:my-repo my-repo

Can backpack infer the name of the destination folder and save me some more typing?

Where it's non ambiguous, yes. For example, when you specify a subfolder:

$ bp new user/repo/-/my-folder

Will grab just my-folder from user/repo and create in a destinaton folder called my-folder.

If there's a inference strategy you think will work, open an issue or submit a PR.

How to install backpack globally?

With Homebrew it happens automatically. Otherwise, download a binary and add its containing folder to your PATH in the way that's supported by your OS.

We're accepting PRs for other OS specific installers.

Any requirements or dependencies for backpack?

Just git to exist (and we will eventually remove that dependency). Other than that the bp binary is self contained and has no dependencies.

Can I get a single file?

Yes. backpack will act differently when the source is a file, it will do what you're expecting it to.

For example, this will give you a .gitignore file from another project:

$ cd my-project
$ bp apply rusty-ferris-club/backpack/-/.gitignore
$ tree
.gitignore

This will copy just a single workflow file, but also the entire hierarchy of folders:

$ cd my-project
$ bp apply rusty-ferris-club/backpack/-/.github/workflows/build.yml
$ tree
.github/
  workflows/
    build.yml

Or in other words:

  1. When you specify a target file verbatim, it will use that
  2. If you're not specifying a target file, the destination file and folder path will be copied from the source.

Thanks

To all Contributors - you make this happen, thanks!

Copyright

Copyright (c) 2021 @jondot. See LICENSE for further details.

backpack's People

Contributors

jondot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.