-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3d20b64
Showing
14 changed files
with
2,035 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# These are supported funding model platforms | ||
|
||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] | ||
patreon: evillt | ||
open_collective: # Replace with a single Open Collective username | ||
ko_fi: evillt | ||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel | ||
custom: https://donate.evila.me |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules/ | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless | ||
|
||
# MacOS | ||
.DS_Store | ||
|
||
# Universal output | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"bracketSpacing": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) evillt <ijoec123@gmail.com> (https://evila.me) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# git-delete-branch | ||
|
||
> 🔌Tooling for delete git branches | ||
Please consider starring the project to show your ❤️ and support. | ||
|
||
[![NPM version](https://badgen.net/npm/v/git-delete-branch?icon=npm)](https://npmjs.com/package/git-delete-branch) | ||
[![NPM download](https://badgen.net/npm/dm/git-delete-branch?icon=npm)](https://npmjs.com/package/git-delete-branch) | ||
[![CircleCI](https://badgen.net/circleci/github/evillt/git-delete-branch?icon=circleci)](https://circleci.com/gh/evillt/git-delete-branch/tree/master) | ||
[![License](https://badgen.net/npm/license/git-delete-branch)](./LICENSE) | ||
[![donate](https://badgen.net/badge/support%20me/donate/f2a)](https://donate.evila.me) | ||
|
||
## Features | ||
|
||
- Support delete matched branches. e.g.`fix/*` | ||
|
||
## Prerequires | ||
|
||
- git | ||
- node.js | ||
|
||
## Install | ||
|
||
```console | ||
yarn global add git-delete-branch | ||
``` | ||
|
||
## Usage | ||
|
||
Basically: | ||
|
||
```console | ||
git-delete-branch [...branches] | ||
``` | ||
|
||
Or using git external commands: | ||
|
||
```console | ||
git delete-branch [...branches] | ||
``` | ||
|
||
## CLI | ||
|
||
`git-delete-branch [...branches] [options]` | ||
|
||
### `branches` | ||
|
||
Delete branches | ||
|
||
### `options` | ||
|
||
#### `-r, --remote` (WIP) | ||
|
||
Delete remote branches | ||
|
||
## Contributing | ||
|
||
1. Fork it! | ||
2. Create your feature branch: `git checkout -b my-new-feature` | ||
3. Commit your changes: `git commit -am 'Add some feature'` | ||
4. Push to the branch: `git push origin my-new-feature` | ||
5. Submit a pull request :D | ||
|
||
## Author | ||
|
||
**git-delete-branch** © [evillt](https://github.com/evillt), Released under the [MIT](./LICENSE) License. | ||
|
||
Authored and maintained by **EVILLT** with help from contributors ([list](https://github.com/evillt/git-delete-branch/contributors)). | ||
|
||
> [evila.me](https://evila.me) · GitHub [@evillt](https://github.com/evillt) · Twitter [@evillt](https://twitter.com/evillt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env node | ||
const GitDeleteBranch = require('..') | ||
|
||
const app = new GitDeleteBranch() | ||
|
||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
version: 2 | ||
jobs: | ||
build: | ||
docker: | ||
- image: circleci/node:latest | ||
branches: | ||
ignore: | ||
- gh-pages | ||
- /release\/.*/ | ||
steps: | ||
- checkout | ||
- restore_cache: | ||
key: dependency-cache-{{ checksum "yarn.lock" }} | ||
- run: | ||
name: Install dependencies | ||
command: yarn | ||
- save_cache: | ||
key: dependency-cache-{{ checksum "yarn.lock" }} | ||
paths: | ||
- ./node_modules | ||
- run: | ||
name: Release | ||
command: npx semantic-release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const cac = require('cac') | ||
const path = require('path') | ||
const fs = require('fs') | ||
const spawn = require('cross-spawn') | ||
const parseArgs = require('../utils/parseArgs') | ||
const logger = require('../utils/logger') | ||
|
||
module.exports = class Core { | ||
constructor() { | ||
this.cwd = process.cwd() | ||
this.rawArgs = process.argv | ||
this.args = parseArgs(this.rawArgs.slice(2)) | ||
|
||
this.isGitProject() | ||
|
||
this.initCli() | ||
} | ||
|
||
initCli() { | ||
const cli = (this.cli = cac()) | ||
this.command = cli | ||
.command('[...branches]') | ||
.usage('[option]') | ||
.action(branches => { | ||
this.deleteBranch(branches) | ||
}) | ||
|
||
cli.version(require('../package.json').version).help() | ||
|
||
this.cli.parse(this.rawArgs, { run: false }) | ||
} | ||
|
||
isGitProject() { | ||
if (!fs.existsSync(path.join(this.cwd, '.git'))) { | ||
logger.error('Current working directory is not a git project!') | ||
process.exit(1) | ||
} | ||
return true | ||
} | ||
|
||
getBranch() { | ||
const { stdout } = spawn.sync('git', ['branch']) | ||
const branch = stdout | ||
.toString() | ||
.trimRight() | ||
.split('\n') | ||
.map(b => { | ||
if (!b.includes('*')) { | ||
return b.trim() | ||
} | ||
}) | ||
.filter(Boolean) | ||
|
||
return branch | ||
} | ||
|
||
deleteBranch(branches) { | ||
const match = require('multimatch') | ||
const matched = match(this.getBranch(), branches) | ||
|
||
matched.forEach(branch => { | ||
const ps = spawn.sync('git', ['branch', branch, '-D']) | ||
if (ps.status === 0) { | ||
logger.success('Deleted branch', `\`${branch}\``) | ||
} | ||
}) | ||
} | ||
|
||
run() { | ||
this.cli.runMatchedCommand() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"name": "git-delete-branch", | ||
"description": "🔌Tooling for delete git branches", | ||
"version": "0.0.1", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "evillt/git-delete-branch" | ||
}, | ||
"bin": "bin/cli.js", | ||
"author": "evillt <ijoec123@gmail.com> (https://evila.me)", | ||
"main": "lib/index.js", | ||
"scripts": {}, | ||
"dependencies": { | ||
"cac": "^6.5.2", | ||
"cross-spawn": "^6.0.5", | ||
"kleur": "^3.0.3", | ||
"mri": "^1.1.4", | ||
"multimatch": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"husky": "^1.0.0-rc.13", | ||
"lint-staged": "^7.2.0", | ||
"prettier": "^1.17.0" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"linters": { | ||
"*.{js,json,md}": [ | ||
"prettier --write", | ||
"git add" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const kleur = require('kleur') | ||
const path = require('path') | ||
|
||
class Logger { | ||
log(...args) { | ||
console.log(...args) | ||
} | ||
|
||
success(...args) { | ||
this.log(kleur.green('success'), ...args) | ||
} | ||
|
||
error(...args) { | ||
this.log(kleur.red('error'), ...args) | ||
} | ||
|
||
warn(...args) { | ||
this.log(kleur.yellow('warning'), ...args) | ||
} | ||
|
||
done(...args) { | ||
this.log(kleur.green(process.platform === 'win32' ? '√' : '✔'), ...args) | ||
} | ||
|
||
tip(...args) { | ||
this.log(kleur.blue('tip'), ...args) | ||
} | ||
|
||
info(...args) { | ||
this.log(kleur.cyan('info'), ...args) | ||
} | ||
} | ||
|
||
module.exports = new Logger() |
Oops, something went wrong.