tayo 0.1.8 → 0.1.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da1c2b256c1dafba3c750dc5f8fe18487db251584646fc485576bf338544bfe1
4
- data.tar.gz: 61ea6d61163327ef47b1462a290935eec9a899db30703012f12cbdcf0b6bf021
3
+ metadata.gz: 2b925f8aa2d0555113bba7ca0f1ed1e2a4f7b923f4f8cd5f7ebc2ed0abb0a5df
4
+ data.tar.gz: 42fe13a69f4c8b9bca65b2d46f8bfe501e34f2c350658d75e277dc1fb2005268
5
5
  SHA512:
6
- metadata.gz: 6723d0513bb51d2417dee22159d8b10bfd22714bbe99376a289ed0b723f0dc93e2e6a9294662f2272f8f77872752eedf8f40dc16770af03aa559b2e55841d922
7
- data.tar.gz: 68017f8f0f916c510101abd914dd1ac117befd8bcbb726942a79da7f76b51b70401fdafd162753a5d4e402ca012916933bef6d881a4bb0716ee8b59c41b8913f
6
+ metadata.gz: 13ce503cf8c8d0fd7c0ec6588cbf699d0713c01e6b1d9c26fa1b7c0339c4c1747b93b959e5e5071e9213ec28d6e2aa634032511f4ae921f5fbfeb2fd4ab5bac8
7
+ data.tar.gz: d131a5928299a44bf63b2a0e1c65ebcf12113643120fc5d2f5a2084643b7e05de9388e34575ffddc3ad1e1804268051ce4fdd8df5213609b5e0361a6f447b304
data/README.md CHANGED
@@ -23,7 +23,6 @@ tayo init
23
23
  이 명령어는 다음 작업들을 수행합니다:
24
24
 
25
25
  - **OrbStack 설치 확인**: Docker 컨테이너를 실행하기 위한 OrbStack이 설치되어 있는지 확인합니다
26
- - **Gemfile 수정**: development 그룹에 tayo gem을 추가합니다
27
26
  - **Bundle 설치**: 의존성을 설치합니다
28
27
  - **Linux 플랫폼 추가**: `x86_64-linux`와 `aarch64-linux` 플랫폼을 Gemfile.lock에 추가합니다
29
28
  - **Dockerfile 생성**: Rails 7 기본 Dockerfile이 없으면 생성합니다
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "colorize"
4
+ require_relative "../dockerfile_modifier"
4
5
 
5
6
  module Tayo
6
7
  module Commands
@@ -12,15 +13,13 @@ module Tayo
12
13
  puts "❌ Rails 프로젝트가 아닙니다. Rails 프로젝트 루트에서 실행해주세요.".colorize(:red)
13
14
  return
14
15
  end
15
-
16
+ commit_initial_state
16
17
  check_orbstack
17
- add_to_gemfile
18
- bundle_install
19
- add_linux_platform
20
- create_welcome_page
21
- commit_changes
18
+ create_welcome_page
22
19
  clear_docker_cache
23
-
20
+ ensure_dockerfile_exists
21
+ disable_bootsnap_in_dockerfile
22
+ commit_changes
24
23
  puts "✅ Tayo가 성공적으로 설정되었습니다!".colorize(:green)
25
24
  end
26
25
 
@@ -66,74 +65,6 @@ module Tayo
66
65
  end
67
66
  end
68
67
  end
69
-
70
- def add_to_gemfile
71
- gemfile_content = File.read("Gemfile")
72
-
73
- if gemfile_content.include?("tayo")
74
- puts "ℹ️ Tayo가 이미 Gemfile에 있습니다.".colorize(:yellow)
75
- return
76
- end
77
-
78
- development_group = gemfile_content.match(/group :development do\n(.*?)\nend/m)
79
-
80
- if development_group
81
- updated_content = gemfile_content.sub(
82
- /group :development do\n/,
83
- "group :development do\n gem 'tayo'\n"
84
- )
85
- else
86
- updated_content = gemfile_content + "\n\ngroup :development do\n gem 'tayo'\nend\n"
87
- end
88
-
89
- File.write("Gemfile", updated_content)
90
- puts "✅ Gemfile에 Tayo를 추가했습니다.".colorize(:green)
91
- end
92
-
93
- def bundle_install
94
- puts "📦 bundle install을 실행합니다...".colorize(:yellow)
95
- system("bundle install")
96
- end
97
-
98
- def add_linux_platform
99
- puts "🐧 Linux 플랫폼을 확인하고 추가합니다...".colorize(:yellow)
100
-
101
- # Gemfile.lock 파일 확인
102
- unless File.exist?("Gemfile.lock")
103
- puts "⚠️ Gemfile.lock 파일이 없습니다. bundle install을 먼저 실행해주세요.".colorize(:yellow)
104
- return
105
- end
106
-
107
- gemfile_lock_content = File.read("Gemfile.lock")
108
- platforms_needed = []
109
-
110
- # 필요한 플랫폼 확인
111
- unless gemfile_lock_content.include?("x86_64-linux")
112
- platforms_needed << "x86_64-linux"
113
- end
114
-
115
- unless gemfile_lock_content.include?("aarch64-linux")
116
- platforms_needed << "aarch64-linux"
117
- end
118
-
119
- if platforms_needed.empty?
120
- puts "✅ 필요한 Linux 플랫폼이 이미 추가되어 있습니다.".colorize(:green)
121
- return
122
- end
123
-
124
- # 플랫폼 추가
125
- platforms_needed.each do |platform|
126
- puts "📦 #{platform} 플랫폼을 추가합니다...".colorize(:yellow)
127
- if system("bundle lock --add-platform #{platform}")
128
- puts "✅ #{platform} 플랫폼이 추가되었습니다.".colorize(:green)
129
- else
130
- puts "❌ #{platform} 플랫폼 추가에 실패했습니다.".colorize(:red)
131
- end
132
- end
133
-
134
- # Dockerfile 확인 및 생성
135
- ensure_dockerfile_exists
136
- end
137
68
 
138
69
  def ensure_dockerfile_exists
139
70
  unless File.exist?("Dockerfile")
@@ -150,67 +81,16 @@ module Tayo
150
81
  end
151
82
  else
152
83
  puts "✅ Dockerfile이 이미 존재합니다.".colorize(:green)
153
- end
154
-
155
- # Dockerfile에서 bootsnap precompile 부분 제거 (빌드 문제 해결)
156
- fix_dockerfile_bootsnap_issue
84
+ end
157
85
  end
158
86
 
159
- def fix_dockerfile_bootsnap_issue
160
- dockerfile_path = "Dockerfile"
161
- return unless File.exist?(dockerfile_path)
162
-
163
- original_content = File.read(dockerfile_path)
164
- lines = original_content.split("\n")
165
-
166
- # 삭제할 패턴들을 정의합니다.
167
- comment_pattern = /^\s*# Precompile bootsnap code for faster boot times/i
168
- run_command_pattern = /^\s*RUN bundle exec bootsnap precompile app\/ lib\//i
169
-
170
- # 디버깅: 매칭되는 라인 확인
171
- debug_matches = false
172
- if ENV['TAYO_DEBUG'] == 'true'
173
- debug_matches = true
174
- puts "🔍 Dockerfile 디버깅 모드".colorize(:yellow)
175
- puts " 전체 라인 수: #{lines.length}"
176
- lines.each_with_index do |line, index|
177
- if line.match?(comment_pattern)
178
- puts " 주석 매치 (라인 #{index + 1}): #{line.strip}"
179
- elsif line.match?(run_command_pattern)
180
- puts " RUN 매치 (라인 #{index + 1}): #{line.strip}"
181
- elsif line.include?("bootsnap")
182
- puts " 기타 bootsnap (라인 #{index + 1}): #{line.strip}"
183
- end
184
- end
185
- end
186
-
187
- # `reject`를 사용해 패턴과 일치하는 줄들을 한번에 제거합니다.
188
- filtered_lines = lines.reject do |line|
189
- line.match?(comment_pattern) || line.match?(run_command_pattern)
190
- end
191
-
192
- new_content = filtered_lines.join("\n")
193
- # 원본 파일이 개행으로 끝났다면 새 파일도 개행으로 끝나도록
194
- new_content += "\n" if original_content.end_with?("\n") && !new_content.end_with?("\n")
195
-
196
- # 변경된 내용이 있을 경우에만 파일을 다시 씁니다.
197
- if new_content != original_content
198
- removed_lines = lines.length - filtered_lines.length
199
- File.write(dockerfile_path, new_content)
200
- puts "✅ Dockerfile에서 bootsnap precompile 부분을 제거했습니다. (빌드 문제 해결)".colorize(:green)
201
- puts " - 제거된 라인 수: #{removed_lines}".colorize(:gray)
202
- puts " - 이는 알려진 빌드 문제를 방지하기 위함입니다.".colorize(:gray)
203
-
204
- if debug_matches
205
- puts " 남은 bootsnap 라인:".colorize(:yellow)
206
- filtered_lines.each_with_index do |line, index|
207
- if line.include?("bootsnap")
208
- puts " 라인 #{index + 1}: #{line.strip}"
209
- end
210
- end
211
- end
212
- elsif debug_matches
213
- puts "ℹ️ 제거할 bootsnap 라인이 없습니다.".colorize(:yellow)
87
+ def disable_bootsnap_in_dockerfile
88
+ puts "🔧 Dockerfile에서 bootsnap을 비활성화합니다...".colorize(:yellow)
89
+ begin
90
+ modifier = DockerfileModifier.new
91
+ modifier.init
92
+ rescue => e
93
+ puts "⚠️ Dockerfile 수정 중 오류가 발생했습니다: #{e.message}".colorize(:yellow)
214
94
  end
215
95
  end
216
96
 
@@ -375,20 +255,44 @@ module Tayo
375
255
  @welcome_page_created = true
376
256
  end
377
257
 
378
- def commit_changes
258
+ def commit_initial_state
379
259
  # Git 저장소인지 확인
380
260
  unless Dir.exist?(".git")
381
261
  puts "⚠️ Git 저장소가 아닙니다. 커밋을 건너뜁니다.".colorize(:yellow)
382
262
  return
383
263
  end
384
264
 
385
- # Welcome 페이지가 새로 생성된 경우에만 커밋
386
- unless @welcome_page_created
387
- puts "ℹ️ 새로운 변경사항이 없어 커밋을 건너뜁니다.".colorize(:yellow)
265
+ puts "📝 초기 상태를 Git에 커밋합니다...".colorize(:yellow)
266
+
267
+ # Git 상태 확인
268
+ git_status = `git status --porcelain`
269
+
270
+ if git_status.strip.empty?
271
+ puts "ℹ️ 커밋할 변경사항이 없습니다.".colorize(:yellow)
272
+ return
273
+ end
274
+
275
+ # 변경사항 스테이징
276
+ system("git add .")
277
+
278
+ # 커밋
279
+ commit_message = "Save current state before Tayo initialization"
280
+ if system("git commit -m '#{commit_message}'")
281
+ puts "✅ 초기 상태가 커밋되었습니다.".colorize(:green)
282
+ puts " 커밋 메시지: #{commit_message}".colorize(:gray)
283
+ else
284
+ puts "⚠️ 커밋에 실패했습니다.".colorize(:yellow)
285
+ end
286
+ end
287
+
288
+ def commit_changes
289
+ # Git 저장소인지 확인
290
+ unless Dir.exist?(".git")
291
+ puts "⚠️ Git 저장소가 아닙니다. 커밋을 건너뜁니다.".colorize(:yellow)
388
292
  return
389
293
  end
390
294
 
391
- puts "📝 변경사항을 Git에 커밋합니다...".colorize(:yellow)
295
+ puts "📝 Tayo 설정 완료 상태를 Git에 커밋합니다...".colorize(:yellow)
392
296
 
393
297
  # Git 상태 확인
394
298
  git_status = `git status --porcelain`
@@ -402,9 +306,9 @@ module Tayo
402
306
  system("git add .")
403
307
 
404
308
  # 커밋
405
- commit_message = "Add Tayo configuration and Welcome page"
309
+ commit_message = "Complete Tayo initialization with Welcome page and Docker setup"
406
310
  if system("git commit -m '#{commit_message}'")
407
- puts "✅ 변경사항이 커밋되었습니다.".colorize(:green)
311
+ puts "✅ Tayo 설정이 완료되어 커밋되었습니다.".colorize(:green)
408
312
  puts " 커밋 메시지: #{commit_message}".colorize(:gray)
409
313
  else
410
314
  puts "⚠️ 커밋에 실패했습니다.".colorize(:yellow)
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+ require "colorize"
5
+
6
+ module Tayo
7
+ class DockerfileModifier
8
+ attr_reader :project_path, :dockerfile_path
9
+
10
+ def initialize(project_path = Dir.pwd)
11
+ @project_path = project_path
12
+ @dockerfile_path = File.join(project_path, 'Dockerfile')
13
+ end
14
+
15
+ def init
16
+ unless File.exist?(dockerfile_path)
17
+ raise "Dockerfile not found in #{project_path}"
18
+ end
19
+
20
+ backup_dockerfile
21
+ modify_dockerfile
22
+ end
23
+
24
+ private
25
+
26
+ def backup_dockerfile
27
+ backup_path = File.join(project_path, 'Dockerfile.origin')
28
+ FileUtils.cp(dockerfile_path, backup_path)
29
+ puts "✅ Dockerfile 백업이 생성되었습니다: #{backup_path}".colorize(:green) if defined?(String.colorize)
30
+ end
31
+
32
+ # =================================================================
33
+ # === 수정된 핵심 로직 ===
34
+ # =================================================================
35
+ def modify_dockerfile
36
+ content = File.read(dockerfile_path)
37
+
38
+ # 1. `bundle install` 라인의 마지막에 붙어있는 bootsnap 부분을 제거합니다.
39
+ # - `&& \` 와 함께 `bootsnap precompile --gemfile` 부분을 찾아서 빈 문자열로 만듭니다.
40
+ modified_content = content.gsub(/\s*&& \\\s*bundle exec bootsnap precompile --gemfile/, '')
41
+
42
+ # 2. 단독으로 존재하는 `bootsnap precompile app/ lib/` 라인을 주석 처리합니다.
43
+ # - 라인 시작(`^`)부터 확인하여 정확히 해당 라인만 대상으로 삼습니다.
44
+ # - 원래의 들여쓰기를 보존하기 위해 앞부분의 공백(`\s*`)을 캡처(`()`)했다가 다시 사용(`\1`)합니다.
45
+ modified_content.gsub!(/^(\s*)RUN bundle exec bootsnap precompile app\/ lib\//, '\1# RUN bundle exec bootsnap precompile app/ lib/')
46
+
47
+ File.write(dockerfile_path, modified_content)
48
+ puts "✅ Dockerfile에서 bootsnap 부분이 비활성화되었습니다.".colorize(:green) if defined?(String.colorize)
49
+ end
50
+ end
51
+ end
data/lib/tayo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tayo
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.11"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tayo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - 이원섭wonsup Lee/Alfonso
@@ -75,7 +75,6 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - ".DS_Store"
78
- - DEBUG_GUIDE.md
79
78
  - README.md
80
79
  - Rakefile
81
80
  - exe/tayo
@@ -84,6 +83,7 @@ files:
84
83
  - lib/tayo/commands/cf.rb
85
84
  - lib/tayo/commands/gh.rb
86
85
  - lib/tayo/commands/init.rb
86
+ - lib/tayo/dockerfile_modifier.rb
87
87
  - lib/tayo/version.rb
88
88
  - pkg/homebody-0.1.0.gem
89
89
  - repomix-output.xml
data/DEBUG_GUIDE.md DELETED
@@ -1,155 +0,0 @@
1
- # Tayo 실행 환경 문제 해결 가이드
2
-
3
- ## 1. 현재 설치된 gem 버전 확인
4
-
5
- ```bash
6
- # 시스템에 설치된 tayo gem 버전 확인
7
- gem list tayo
8
-
9
- # 프로젝트에서 사용 중인 버전 확인 (Bundler 사용 시)
10
- bundle show tayo
11
-
12
- # 어느 위치의 gem이 실행되는지 확인
13
- which tayo
14
- gem which tayo
15
- ```
16
-
17
- ## 2. 버전 업데이트
18
-
19
- ### 시스템 전체 gem 업데이트
20
- ```bash
21
- # 최신 버전으로 업데이트
22
- gem update tayo
23
-
24
- # 특정 버전 설치
25
- gem install tayo -v 0.1.7
26
-
27
- # 기존 버전 모두 제거 후 재설치
28
- gem uninstall tayo --all
29
- gem install tayo
30
- ```
31
-
32
- ### Bundler 사용 시
33
- ```bash
34
- # Gemfile에서 버전 확인
35
- cat Gemfile | grep tayo
36
-
37
- # bundle update
38
- bundle update tayo
39
-
40
- # 또는 Gemfile에 버전 명시
41
- # gem 'tayo', '~> 0.1.7'
42
-
43
- # bundle install
44
- bundle install
45
- ```
46
-
47
- ## 3. 실행 방법별 확인
48
-
49
- ### 직접 실행
50
- ```bash
51
- tayo init
52
- ```
53
-
54
- ### Bundle exec 사용
55
- ```bash
56
- bundle exec tayo init
57
- ```
58
-
59
- ### 프로젝트 내 개발 버전 사용
60
- ```bash
61
- # Gemfile에 로컬 경로 지정
62
- # gem 'tayo', path: '/path/to/tayo'
63
- ```
64
-
65
- ## 4. 디버깅 정보 수집
66
-
67
- 다음 스크립트를 실행하여 환경 정보를 수집하세요:
68
-
69
- ```ruby
70
- # debug_tayo.rb
71
- puts "=== Tayo 디버깅 정보 ==="
72
- puts "Ruby 버전: #{RUBY_VERSION}"
73
- puts "Bundler 사용: #{defined?(Bundler) ? 'Yes' : 'No'}"
74
-
75
- require 'tayo/version'
76
- puts "Tayo 버전: #{Tayo::VERSION}"
77
-
78
- require 'tayo/commands/init'
79
- init = Tayo::Commands::Init.new
80
-
81
- # gem 위치 확인
82
- spec = Gem::Specification.find_by_name('tayo')
83
- puts "Gem 위치: #{spec.gem_dir}"
84
- puts "Gem 버전: #{spec.version}"
85
-
86
- # 메서드 존재 확인
87
- puts "fix_dockerfile_bootsnap_issue 메서드 존재: #{init.respond_to?(:fix_dockerfile_bootsnap_issue, true)}"
88
-
89
- # 메서드 위치 확인
90
- if init.respond_to?(:fix_dockerfile_bootsnap_issue, true)
91
- method = init.method(:fix_dockerfile_bootsnap_issue)
92
- puts "메서드 정의 위치: #{method.source_location}"
93
- end
94
- ```
95
-
96
- ## 5. 캐시 문제 해결
97
-
98
- ### RubyGems 캐시 정리
99
- ```bash
100
- gem cleanup tayo
101
- ```
102
-
103
- ### Bundler 캐시 정리
104
- ```bash
105
- bundle clean --force
106
- rm -rf .bundle
107
- bundle install
108
- ```
109
-
110
- ## 6. 수동 테스트
111
-
112
- 프로젝트 디렉토리에서 직접 테스트:
113
-
114
- ```ruby
115
- # irb 또는 rails console에서
116
- require 'tayo'
117
- init = Tayo::Commands::Init.new
118
- init.send(:fix_dockerfile_bootsnap_issue)
119
- ```
120
-
121
- ## 7. 일반적인 문제와 해결법
122
-
123
- ### 문제: "undefined method" 에러
124
- - 원인: 오래된 버전 사용
125
- - 해결: `gem update tayo`
126
-
127
- ### 문제: Bundler가 다른 버전 사용
128
- - 원인: Gemfile.lock에 고정된 버전
129
- - 해결: `bundle update tayo`
130
-
131
- ### 문제: 여러 버전 설치로 인한 충돌
132
- - 원인: 시스템과 프로젝트 버전 충돌
133
- - 해결:
134
- ```bash
135
- gem uninstall tayo --all
136
- bundle install
137
- ```
138
-
139
- ### 문제: 권한 문제
140
- - 원인: 시스템 gem 디렉토리 권한
141
- - 해결:
142
- ```bash
143
- # rbenv/rvm 사용 권장
144
- # 또는
145
- gem install tayo --user-install
146
- ```
147
-
148
- ## 8. 버전별 기능 확인
149
-
150
- - v0.1.4: bootsnap 제거 기능 첫 추가
151
- - v0.1.5: 라인별 처리 방식
152
- - v0.1.6: reject 방식으로 개선
153
- - v0.1.7: 테스트 추가 및 개행 문자 처리 수정
154
-
155
- 필요한 최소 버전: **0.1.6 이상**