hiroto_create 0.1.2 → 0.1.3
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 +4 -4
- data/lib/hiroto_create/version.rb +1 -1
- data/lib/hiroto_create.rb +71 -37
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 485427c3cc2f945b3457a26ddb109ae6b7fc1e1a1dd6dce0121ea9bc7c0a095b
|
4
|
+
data.tar.gz: 538b5516505f04c9005a4339c59204971a7880135a8d2d668cacd45dd816c73e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dceaeda46e05c2f95b93fcf7d4241ff56e22315baf9813bba0fb901ed8efc588d1d491695f1fb4baf85bb54b64e57e8c70e8d1cd4c0162309f295306483284f
|
7
|
+
data.tar.gz: ddfc39c7149c8696f051010e309920dec87ea73128c8d98060415aa93880056cd56b9914b31ff858583b44258fe8f0c9e53313c5f0266d359fd0f3a34a6765dc
|
data/lib/hiroto_create.rb
CHANGED
@@ -2,47 +2,81 @@
|
|
2
2
|
|
3
3
|
require_relative "hiroto_create/version"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
unless gh_installed
|
9
|
-
puts "ghコマンドが見つかりません。"
|
10
|
-
|
11
|
-
# インストール確認
|
12
|
-
print "ghコマンドをインストールしますか? (yes/no): "
|
13
|
-
user_input = gets.chomp.strip.downcase
|
14
|
-
|
15
|
-
case user_input
|
16
|
-
when 'yes'
|
17
|
-
# macOSの場合
|
18
|
-
if RUBY_PLATFORM.include?('darwin')
|
19
|
-
puts "GitHub CLI (gh)のインストール中..."
|
20
|
-
system('brew install gh')
|
21
|
-
# インストールの完了を待機する
|
22
|
-
end
|
5
|
+
module HirotoCreate
|
6
|
+
class Error < StandardError; end
|
7
|
+
def self.hiroto_create
|
23
8
|
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
9
|
+
# .gitファイルを作る
|
10
|
+
system("git init")
|
11
|
+
|
12
|
+
# リポジトリ名の入力
|
13
|
+
print 'Enter the repository name: '
|
14
|
+
repo_name = gets.chomp.strip
|
15
|
+
|
16
|
+
# GitHubユーザー名の入力
|
17
|
+
print 'Enter your GitHub username: '
|
18
|
+
username = gets.chomp.strip
|
19
|
+
|
20
|
+
# publicかprivateかを聞く
|
21
|
+
print 'Enter public or private: '
|
22
|
+
flag = gets.chomp.strip
|
23
|
+
|
24
|
+
# ghコマンドがインストールされているか確認
|
25
|
+
gh_installed = system('which gh > /dev/null')
|
26
|
+
|
27
|
+
unless gh_installed
|
28
|
+
puts "ghコマンドが見つかりません。"
|
29
|
+
|
30
|
+
# インストール確認
|
31
|
+
print "ghコマンドをインストールしますか? (yes/no): "
|
32
|
+
user_input = gets.chomp.strip.downcase
|
30
33
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
case user_input
|
35
|
+
when 'yes'
|
36
|
+
# macOSの場合
|
37
|
+
if RUBY_PLATFORM.include?('darwin')
|
38
|
+
puts "GitHub CLI (gh)のインストール中..."
|
39
|
+
system('brew install gh')
|
40
|
+
# インストールの完了を待機する
|
41
|
+
end
|
42
|
+
|
43
|
+
# Linuxの場合 (ここではUbuntu)
|
44
|
+
if RUBY_PLATFORM.include?('linux')
|
45
|
+
puts "GitHub CLI (gh)のインストール中..."
|
46
|
+
system('sudo apt install gh')
|
47
|
+
# インストールの完了を待機する
|
48
|
+
end
|
49
|
+
|
50
|
+
# インストールが成功したか再度確認
|
51
|
+
gh_installed_after_install = system('which gh > /dev/null')
|
52
|
+
if gh_installed_after_install
|
53
|
+
puts "GitHub CLI (gh)のインストールが完了しました。"
|
54
|
+
else
|
55
|
+
puts "GitHub CLI (gh)のインストールに失敗しました。手動でインストールしてください。"
|
56
|
+
exit(1)
|
57
|
+
end
|
58
|
+
|
59
|
+
when 'いいえ', 'no'
|
60
|
+
puts "インストールを中止しました。hiroto_createを使用するには手動でghコマンドをインストールしてください。"
|
61
|
+
exit(1)
|
62
|
+
|
63
|
+
else
|
64
|
+
puts "無効な入力です。yesかnoで答えてください。"
|
65
|
+
exit(1)
|
66
|
+
end
|
38
67
|
end
|
39
68
|
|
40
|
-
when 'いいえ', 'no'
|
41
|
-
puts "インストールを中止しました。hiroto_createを使用するには手動でghコマンドをインストールしてください。"
|
42
|
-
exit(1)
|
43
69
|
|
44
|
-
|
45
|
-
|
46
|
-
|
70
|
+
# リモートリポジトリのSSH
|
71
|
+
remote_repo_url = "git@github.com:#{username}/#{repo_name}.git"
|
72
|
+
|
73
|
+
# リモートリポジトリの作成
|
74
|
+
system("gh repo create #{username}/#{repo_name} --#{flag}")
|
75
|
+
|
76
|
+
# GitHubにログイン
|
77
|
+
system('gh auth login')
|
78
|
+
|
79
|
+
# リモートリポジトリへの接続
|
80
|
+
system("git remote add origin #{remote_repo_url}")
|
47
81
|
end
|
48
82
|
end
|