# @johnls/git-extra

> Extra git commands for working with GitHub, BitBucket and GitLab

Latest version **3.6.0** (published 2021-02-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @johnls/git-extra
pnpm add @johnls/git-extra
yarn add @johnls/git-extra
bun add @johnls/git-extra
```

Provides the command `git-extra`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.6.0 |
| Published | 2021-02-18 |
| First published | 2019-02-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.0 |
| Dependencies | 11 |
| Unpacked size | 49.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | John Lyon-Smith |
| Maintainers | jlyonsmith |
| Keywords | bitbucket, github, git, cli, tool |

## Links

- npm: https://www.npmjs.com/package/@johnls/git-extra
- Repository: https://github.com/jlyonsmith/git-extra
- Homepage: https://github.com/jlyonsmith/git-extra#readme
- Issues: https://github.com/jlyonsmith/git-extra/issues
- npm.io page: https://npm.io/package/@johnls/git-extra

## Dependencies (11)

- [got](https://npm.io/package/got.md) ^11.8.1
- [open](https://npm.io/package/open.md) ^7.0.3
- [chalk](https://npm.io/package/chalk.md) ^4.0.0
- [prompts](https://npm.io/package/prompts.md) ^2.3.2
- [fs-extra](https://npm.io/package/fs-extra.md) ^9.0.0
- [minimist](https://npm.io/package/minimist.md) ^1.2.5
- [change-case](https://npm.io/package/change-case.md) ^4.1.1
- [@johnls/json5](https://npm.io/package/@johnls/json5.md) ^2.3.0
- [command-exists](https://npm.io/package/command-exists.md) ^1.2.9
- [hosted-git-info](https://npm.io/package/hosted-git-info.md) ^3.0.4
- [promisify-child-process](https://npm.io/package/promisify-child-process.md) ^4.1.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 3.6.0 (latest) — 2021-02-18
- 3.5.1 — 2021-02-17
- 3.5.0 — 2021-02-16
- 3.4.0 — 2020-06-09
- 3.3.2 — 2020-05-30
- 3.3.1 — 2020-05-29
- 3.3.0 — 2020-05-19
- 3.2.0 — 2020-05-08
- 3.1.1 — 2020-04-04
- 3.1.0 — 2019-05-25
- 3.0.1 — 2019-03-11
- 3.0.0 — 2019-02-19

## README

# Extra Git Commands

A tool that creates some commands for working with BitBucket and GitHub that you can add to Git.

- `browse` - Opens a browser for the current repository and branch.
- `pull-request` - Opens a new pull-request.
- `quick-start` - Quickly starts a new project by copying and customizing an existing repository.

To add these commands to Git, do `git config --global --edit` and insert:

```sh
[alias]
  ...
  browse = !git-extra browse
  pull-request = !git-extra pull-request
  quick-start = !git-extra quick-start
```

## Quick Start

By default `quick-start` copies an existing repository by cloning it and then resets the Git history.

The power of `quick-start` is that you can customize the project after the initial clone.  To enable this, create a `git-extra-customize.js` file in the root of the project.  This file contains a Javascript program that is run after the initial clone which can change the contents of the files, changing names, creating files and directories, etc..  The script is run in a VM so it can only do a restricted set of things.  See the [GitExtraTool.js](./src/GitExtraTool.js) for the full list of functions available.

### `git-extra-customize.js`

The following objects and methods are available:

| `async` | Method                               | Description                                                                 |
| ------- | ------------------------------------ | --------------------------------------------------------------------------- |
|         | `args.projectName`                   | The name of the project (the `path.basename()` of the directory)            |
|         | `args.userName`                      | The name of the currently logged in user                                    |
|         | `ui.log(message)`                    | Display a message to stdout                                                 |
| `async` | `fs.readFile(fileName)`              | Read a file from the project                                                |
| `async` | `fs.writeFile(fileName)`             | Write a file to the project                                                 |
| `async` | `fs.remove(pathName)`                | Remove a file or directory from the project                                 |
| `async` | `fs.move(fromPath, toPath)`          | Move a file or directory in the project                                     |
| `async` | `fs.ensureFile(fileName)`            | Ensure a file exists in the project, creating it if not                     |
| `async` | `fs.ensureDir(dirName)`              | Ensure a directory exists in the project, creating it if not                |
| `async` | `fs.inPlaceUpdate(fileName, array)`  | In-place-update a file with an array of search/replace strings. See below.  |
|         | `path.join(...pathNames)`            | Join a bunch of path parts                                                  |
|         | `path.dirname(pathName)`             | Get the directory part of a path                                            |
|         | `path.basename(pathName[, extName])` | Get the base part of path with any extension, remove `extName` if it exists |
|         | `path.extname(pathName)`             | Get the extension of a path                                                 |
| `async` | `git.forceAdd(fileName)`             | Force add a file to the Git repository                                      |
|         | `changeCase.camel(name)`             | Change the name to "camelCase"                                              |
|         | `changeCase.capital(name)`           | Change the name to "Capital Case"                                           |
|         | `changeCase.constant(name)`          | Change the name to "CONSTANT_CASE"                                          |
|         | `changeCase.dot(name)`               | Change the name to "dot.case"                                               |
|         | `changeCase.header(name)`            | Change the name to "Header-Case"                                            |
|         | `changeCase.word(name)`              | Change the name to "word case"                                              |
|         | `changeCase.param(name)`             | Change the name to "param-case"                                             |
|         | `changeCase.pascal(name)`            | Change the name to "PascalCase"                                             |
|         | `changeCase.path(name)`              | Change the name to "path/case"                                              |
|         | `changeCase.sentence(name)`          | Change the name to "Sentence case"                                          |
|         | `changeCase.snake(name)`             | Change the name to "snake_case"                                             |
| `async` | `ui.prompts(promptArray)`            | Display array of prompts. See below.                                        |
|         | `ui.log(message)`                    | Display a message to stdout                                                 |

`ui.prompts(...)` takes an array of:

```js
  [
    {
      name: string,
      initial: string, // Optional
      message: string,
      regex: string, // Optional
      error: string, // Optional
    }
  ]
```

`fs.inPlaceUpdate(...)` takes an array of arrays of search/replace pairs:

```js
 [
   [/something/, "anotherThing"],
 ]
```

---
_Source: https://npm.io/package/@johnls/git-extra · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
