ghcreate 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +55 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +38 -0
- data/LICENSE.txt +21 -0
- data/README.md +13 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/ghcreate +99 -0
- data/ghcreate.gemspec +28 -0
- data/init.rb +90 -0
- data/lib/github/create.rb +13 -0
- data/lib/github/create/version.rb +5 -0
- data/lib/helper.rb +15 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a8aec4d865ac15164afec240c7696677076d240cbda5231d23271c237b525347
|
4
|
+
data.tar.gz: 84fcc04399ffc46b9f5d7dd25834ec02b8a4d3a20d5bb8df862da7b68a009f5d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 296f041afd7c0e90a20b89302f00b42907f4c1d91ab00612be48761e4f1bedb16644a50ad273c71b7f8441387e41c59b642c9bd6ecd5677e4955111b507d65cd
|
7
|
+
data.tar.gz: def1141baa490fa6772a9061130cc5218d3c388c56cf1651e9b5b21b99c30dffb88b07f1a3fa2580ffbbdf62ca9bbb806377f0f9aab2a738d9f847905e3da9b1
|
data/.gitignore
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
# Used by dotenv library to load environment variables.
|
14
|
+
# .env
|
15
|
+
|
16
|
+
# Ignore Byebug command history file.
|
17
|
+
.byebug_history
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
# .ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
55
|
+
\.idea/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.6.0)
|
5
|
+
public_suffix (>= 2.0.2, < 4.0)
|
6
|
+
descendants_tracker (0.0.4)
|
7
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
8
|
+
faraday (0.15.4)
|
9
|
+
multipart-post (>= 1.2, < 3)
|
10
|
+
github_api (0.18.2)
|
11
|
+
addressable (~> 2.4)
|
12
|
+
descendants_tracker (~> 0.0.4)
|
13
|
+
faraday (~> 0.8)
|
14
|
+
hashie (~> 3.5, >= 3.5.2)
|
15
|
+
oauth2 (~> 1.0)
|
16
|
+
hashie (3.6.0)
|
17
|
+
jwt (2.1.0)
|
18
|
+
multi_json (1.13.1)
|
19
|
+
multi_xml (0.6.0)
|
20
|
+
multipart-post (2.0.0)
|
21
|
+
oauth2 (1.4.1)
|
22
|
+
faraday (>= 0.8, < 0.16.0)
|
23
|
+
jwt (>= 1.0, < 3.0)
|
24
|
+
multi_json (~> 1.3)
|
25
|
+
multi_xml (~> 0.5)
|
26
|
+
rack (>= 1.2, < 3)
|
27
|
+
public_suffix (3.0.3)
|
28
|
+
rack (2.0.6)
|
29
|
+
thread_safe (0.3.6)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
x64-mingw32
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
github_api
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 wisehackermonkey
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Github repository creator
|
2
|
+
|
3
|
+
```
|
4
|
+
wisemonkey
|
5
|
+
oranbusiness@gmail.com
|
6
|
+
20190206
|
7
|
+
github.com/wisehackermonkey
|
8
|
+
|
9
|
+
Creates a new repository on github.com
|
10
|
+
asks for project name => repository name
|
11
|
+
asks for username and password of github account
|
12
|
+
generates a repository based on the name and description
|
13
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "github/create"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/ghcreate
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Github repository creator
|
4
|
+
|
5
|
+
# Creates a new repository on github.com
|
6
|
+
# asks for project name => repository name
|
7
|
+
# asks for username and password of github account
|
8
|
+
# generates a repository based on the name and description
|
9
|
+
|
10
|
+
# wisemonkey
|
11
|
+
# oranbusiness@gmail.com
|
12
|
+
# 20190206
|
13
|
+
# github.com/wisehackermonkey
|
14
|
+
|
15
|
+
require 'io/console'
|
16
|
+
# hide_password
|
17
|
+
# Hides users password to when typed into shell
|
18
|
+
# Source https://stackoverflow.com/questions/2338889/how-to-hide-password-input-from-terminal-in-ruby-script
|
19
|
+
def hide_password
|
20
|
+
password = STDIN.noecho(&:gets).chomp
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'github_api'
|
26
|
+
|
27
|
+
|
28
|
+
begin
|
29
|
+
puts "Github project creator by Wisemonkey"
|
30
|
+
puts "-" * 44
|
31
|
+
puts
|
32
|
+
|
33
|
+
print "Project Name: "
|
34
|
+
project_name = gets.chomp
|
35
|
+
|
36
|
+
print "Description: "
|
37
|
+
description = gets.chomp
|
38
|
+
|
39
|
+
print "Github Username: "
|
40
|
+
username = gets.chomp
|
41
|
+
|
42
|
+
print "Github Password: "
|
43
|
+
password = hide_password
|
44
|
+
puts
|
45
|
+
|
46
|
+
begin
|
47
|
+
# authenticate github api
|
48
|
+
github = Github.new basic_auth: "#{username}:#{password}"
|
49
|
+
|
50
|
+
# create repo given project name
|
51
|
+
# docs for "create repo"
|
52
|
+
# https://www.rubydoc.info/github/piotrmurach/github/master/Github/Client/Repos:create
|
53
|
+
github.repos.create "name": "#{project_name}",
|
54
|
+
"description": "#{description}"
|
55
|
+
|
56
|
+
# check if repo was created
|
57
|
+
repo_created = github.repos.find "#{username}", "#{project_name}"
|
58
|
+
unless repo_created.success?
|
59
|
+
raise "repo not found or an error occured"
|
60
|
+
end
|
61
|
+
|
62
|
+
puts "Successfully created Repo http://github.com/#{username}/#{project_name}"
|
63
|
+
# puts "https://www.github.com/#{username}/#{project_name}"
|
64
|
+
rescue Github::Error::GithubError => e
|
65
|
+
|
66
|
+
# handle if repo was not found
|
67
|
+
if e.is_a? Github::Error::NotFound
|
68
|
+
puts "-" * 44
|
69
|
+
puts "Error: Created repository not found"
|
70
|
+
puts "-" * 44
|
71
|
+
end
|
72
|
+
|
73
|
+
# Handles incorrect username or password login
|
74
|
+
if e.is_a? Github::Error::Unauthorized
|
75
|
+
puts "-" * 44
|
76
|
+
puts "Error: username or password is incorrect"
|
77
|
+
puts "-" * 44
|
78
|
+
end
|
79
|
+
|
80
|
+
# Handels if repository already exists
|
81
|
+
if e.is_a? Github::Error::UnprocessableEntity
|
82
|
+
puts "-" * 44
|
83
|
+
puts "Error: Repository already exists, try another project name"
|
84
|
+
puts "-" * 44
|
85
|
+
end
|
86
|
+
|
87
|
+
puts
|
88
|
+
puts "Error message"
|
89
|
+
puts e.message
|
90
|
+
puts "-" * 44
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
rescue Interrupt => e
|
95
|
+
puts
|
96
|
+
puts "-" * 44
|
97
|
+
puts "Exiting.... #{e.message}"
|
98
|
+
puts "-" * 44
|
99
|
+
end
|
data/ghcreate.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "github/create/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ghcreate"
|
8
|
+
spec.version = Github::Create::VERSION
|
9
|
+
spec.authors = ["wisemonkey"]
|
10
|
+
spec.email = ["oranbusiness@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Github repository creator.}
|
13
|
+
spec.description = %q{Github repository creator Creates a new repository on github.com asks for project name => repository name asks for username and password of github account generates a repository based on the name and description.}
|
14
|
+
spec.homepage = "https://github.com/wisehackermonkey/github-create"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = ["ghcreate"]
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Github repository creator
|
3
|
+
|
4
|
+
# Creates a new repository on github.com
|
5
|
+
# asks for project name => repository name
|
6
|
+
# asks for username and password of github account
|
7
|
+
# generates a repository based on the name and description
|
8
|
+
|
9
|
+
# wisemonkey
|
10
|
+
# oranbusiness@gmail.com
|
11
|
+
# 20190206
|
12
|
+
# github.com/wisehackermonkey
|
13
|
+
|
14
|
+
require 'github_api'
|
15
|
+
|
16
|
+
# helper module for no echoing password input
|
17
|
+
require_relative 'lib/helper.rb'
|
18
|
+
include Helper
|
19
|
+
begin
|
20
|
+
puts "Github project creator by Wisemonkey"
|
21
|
+
puts "-" * 44
|
22
|
+
puts
|
23
|
+
|
24
|
+
print "Project Name: "
|
25
|
+
project_name = gets.chomp
|
26
|
+
|
27
|
+
print "Description: "
|
28
|
+
description = gets.chomp
|
29
|
+
|
30
|
+
print "Github Username: "
|
31
|
+
username = gets.chomp
|
32
|
+
|
33
|
+
print "Github Password: "
|
34
|
+
password = Helper::hide_password
|
35
|
+
puts
|
36
|
+
|
37
|
+
begin
|
38
|
+
# authenticate github api
|
39
|
+
github = Github.new basic_auth: "#{username}:#{password}"
|
40
|
+
|
41
|
+
# create repo given project name
|
42
|
+
# docs for "create repo"
|
43
|
+
# https://www.rubydoc.info/github/piotrmurach/github/master/Github/Client/Repos:create
|
44
|
+
github.repos.create "name": "#{project_name}",
|
45
|
+
"description": "#{description}"
|
46
|
+
|
47
|
+
# check if repo was created
|
48
|
+
repo_created = github.repos.find "#{username}", "#{project_name}"
|
49
|
+
unless repo_created.success?
|
50
|
+
raise "repo not found or an error occured"
|
51
|
+
end
|
52
|
+
|
53
|
+
puts "Successfully created Repo #{project_name}"
|
54
|
+
# puts "https://www.github.com/#{username}/#{project_name}"
|
55
|
+
rescue Github::Error::GithubError => e
|
56
|
+
|
57
|
+
# handle if repo was not found
|
58
|
+
if e.is_a? Github::Error::NotFound
|
59
|
+
puts "-" * 44
|
60
|
+
puts "Error: Created repository not found"
|
61
|
+
puts "-" * 44
|
62
|
+
end
|
63
|
+
|
64
|
+
# Handles incorrect username or password login
|
65
|
+
if e.is_a? Github::Error::Unauthorized
|
66
|
+
puts "-" * 44
|
67
|
+
puts "Error: username or password is incorrect"
|
68
|
+
puts "-" * 44
|
69
|
+
end
|
70
|
+
|
71
|
+
# Handels if repository already exists
|
72
|
+
if e.is_a? Github::Error::UnprocessableEntity
|
73
|
+
puts "-" * 44
|
74
|
+
puts "Error: Repository already exists, try another project name"
|
75
|
+
puts "-" * 44
|
76
|
+
end
|
77
|
+
|
78
|
+
puts
|
79
|
+
puts "Error message"
|
80
|
+
puts e.message
|
81
|
+
puts "-" * 44
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
rescue Interrupt => e
|
86
|
+
puts
|
87
|
+
puts "-" * 44
|
88
|
+
puts "Exiting.... #{e.message}"
|
89
|
+
puts "-" * 44
|
90
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "github/create/version"
|
2
|
+
require 'io/console'
|
3
|
+
module Github
|
4
|
+
module Create
|
5
|
+
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
# Hides users password to when typed into shell
|
10
|
+
# Source https://stackoverflow.com/questions/2338889/how-to-hide-password-input-from-terminal-in-ruby-script
|
11
|
+
def hide_password
|
12
|
+
password = STDIN.noecho(&:gets).chomp
|
13
|
+
end
|
data/lib/helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Helper functions for init.rb
|
2
|
+
|
3
|
+
# wisemonkey
|
4
|
+
# oranbusiness@gmail.com
|
5
|
+
# 20190206
|
6
|
+
# github.com/wisehackermonkey
|
7
|
+
|
8
|
+
module Helper
|
9
|
+
require 'io/console'
|
10
|
+
# Hides users password to when typed into shell
|
11
|
+
# Source https://stackoverflow.com/questions/2338889/how-to-hide-password-input-from-terminal-in-ruby-script
|
12
|
+
def hide_password
|
13
|
+
password = STDIN.noecho(&:gets).chomp
|
14
|
+
end
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ghcreate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- wisemonkey
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: Github repository creator Creates a new repository on github.com asks
|
42
|
+
for project name => repository name asks for username and password of github account
|
43
|
+
generates a repository based on the name and description.
|
44
|
+
email:
|
45
|
+
- oranbusiness@gmail.com
|
46
|
+
executables:
|
47
|
+
- ghcreate
|
48
|
+
extensions: []
|
49
|
+
extra_rdoc_files: []
|
50
|
+
files:
|
51
|
+
- ".gitignore"
|
52
|
+
- ".idea/encodings.xml"
|
53
|
+
- ".idea/github-create.iml"
|
54
|
+
- ".idea/inspectionProfiles/Project_Default.xml"
|
55
|
+
- ".idea/misc.xml"
|
56
|
+
- ".idea/modules.xml"
|
57
|
+
- ".idea/vcs.xml"
|
58
|
+
- Gemfile
|
59
|
+
- Gemfile.lock
|
60
|
+
- LICENSE.txt
|
61
|
+
- README.md
|
62
|
+
- Rakefile
|
63
|
+
- bin/console
|
64
|
+
- bin/setup
|
65
|
+
- exe/ghcreate
|
66
|
+
- ghcreate.gemspec
|
67
|
+
- init.rb
|
68
|
+
- lib/github/create.rb
|
69
|
+
- lib/github/create/version.rb
|
70
|
+
- lib/helper.rb
|
71
|
+
homepage: https://github.com/wisehackermonkey/github-create
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.7.8
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Github repository creator.
|
95
|
+
test_files: []
|