npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

create-git

v1.2.2

Published

Initalize a git repository with some helpful extras

Downloads

945

Readme

Create Git Project

NPM Version NPM Downloads test js-standard-style

A generator to initialize a project with git.

Features

  • Initalize git repo
  • Create .gitignore from templates
  • Setup a remote origin
  • Create first commit
  • Push to repo

Usage

$ npm init git

# or

$ npx create-git

# or

$ npm install -g create-git
$ create-git

CLI Usage

$ create-git --help
create-git

initalize a git repo

Options:
  --help                        Show help                              [boolean]
  --version                     Show version number                    [boolean]
  --cwd, -d                     Directory to run in     [default: process.cwd()]
  --primary-branch, -b          Primary branch for repo [string] [default: main]
  --initial-commit-message, -m  Message for initial commit              [string]
  --remote-origin, -o           Git remote origin                       [string]
  --ignore-templates, -t        Ignore templates from
                                github.com/github/gitignore
                                                       [default: Node.gitignore]
  --additional-rules            comma separated list of ignore lines    [string]
  --ignore-existing             Ignore existing .gitignore and package.json
                                files                           [default: false]
  --commit-all                  Commit all files (not just the new .gitignore
                                                       [boolean] [default: true]
  --push                        Push to remote origin when complete
                                                       [boolean] [default: true]

Programmatic Usage

const createGit = require('create-git')

await createGit({
  primartBranch: 'main',
  ignoreExisting: false,
  initialCommitMessage: '',
  remoteOrigin: '', // Will also load from the package.json repository field
  ignoreTemplates: ['Node.gitignore'],
  additionalRules: [],
  push: true,
  commitAll: true
})

Composition with other create-* packages

This generator is built on top of opta, a helper library for collecting user input from multiple interfaces: CLI via yargs, interactive prompts via inquirer and via a JS interface. To compose with other opta based input collection, you can use .options to access the cli/prompt/js configurations.

const createGit = require('create-git')
const opta = require('opta')

// My wrapper which asks github username and repo to
// generate the `remoteOrigin`
const opts = opta({
  commandDescription: 'Create github repo',
  options: {
    // Spread the options from createGit
    ...createGit.options,

    // Add our additional prompts
    githubOrg: {
      prompt: {
        message: 'GitHub User/Org:'
      }
    },
    githubRepo: {
      prompt: {
        message: 'GitHub repo:'
      }
    },

    // Override createGit.options.remoteOrigin
    remoteOrigin: {
      ...createGit.options.remoteOrigin,
      default: (promptInput, allInput) => {
        return `https://github.com/${allInput.githubOrg}/${allInput.githubRepo}`
      }
    }
  }
})

// Our generator main
module.exports = async function (input) {
  // Add our input as overrides on the opta instance
  options.overrides(input)

  // Prompt the user,
  // by overriding remoteOrigin's default above
  // it will now ask for the org and repo first,
  // then set the default for the remote origin
  // based on that input
  await options.prompt()

  // Get the current values from the opta instance
  let opts = options.values()

  // Call create git
  await createGit(opts)
}

For more information check out the docs for opta.