Class: Pindo::Command::Unity::Packinit
- Inherits:
-
Pindo::Command::Unity
- Object
- CLAide::Command
- Pindo::Command
- Pindo::Command::Unity
- Pindo::Command::Unity::Packinit
- Defined in:
- lib/pindo/command/unity/packinit.rb
Constant Summary
Constants inherited from Pindo::Command
DEFAULT_OPTIONS, DEFAULT_ROOT_OPTIONS
Instance Attribute Summary
Attributes inherited from Pindo::Command
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Packinit
constructor
A new instance of Packinit.
- #run ⇒ Object
Methods inherited from Pindo::Command
Methods included from Funlog::Mixin
Methods included from Pindoconfig::Mixin
Methods included from Githelper
#add_branch, #add_tag, #add_tag_with_check, #clone_clang_repo, #clone_devclang_repo, #clone_pindo_common_config_repo, #clone_pindo_env_config_repo, #clong_buildconfig_repo, #get_repo_base_name, #getcode_to_dir, #git_addpush_repo, #git_latest_commit_id, #git_root_directory, #is_git_directory?, #local_branch_exists?, #local_tag_exists?, #prepare_gitenv, #process_need_add_files, #remote_branch_exists?, #remote_tag_exists?, #remove_branch, #remove_tag
Methods included from Executable
capture_command, #executable, execute_command, which, which!
Constructor Details
#initialize(argv) ⇒ Packinit
Returns a new instance of Packinit.
38 39 40 |
# File 'lib/pindo/command/unity/packinit.rb', line 38 def initialize(argv) super end |
Class Method Details
.arguments ⇒ Object
30 31 32 |
# File 'lib/pindo/command/unity/packinit.rb', line 30 def self.arguments [] end |
.options ⇒ Object
34 35 36 |
# File 'lib/pindo/command/unity/packinit.rb', line 34 def self. [].concat(super) end |
Instance Method Details
#run ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/pindo/command/unity/packinit.rb', line 42 def run package_dir = Dir.pwd puts "=" * 60 puts "🔧 Unity Package 初始化" puts "=" * 60 puts # 检测文件存在情况 status = Pindo::Unity::NugetHelper.detect_files(package_dir) puts "文件检测:" puts " package.json: #{status[:has_package_json] ? '✅' : '❌'}" puts " .nuspec: #{status[:has_nuspec] ? '✅' : '❌'}" if status[:nuspec_file] puts " 路径: #{File.basename(status[:nuspec_file])}" end puts # 根据4种情况处理 case [status[:has_package_json], status[:has_nuspec]] when [true, false] puts "📝 情况A:只有 package.json" puts " → 创建 .nuspec(ID 使用驼峰格式)" puts Pindo::Unity::NugetHelper.handle_case_a(package_dir) when [false, true] puts "📝 情况B:只有 .nuspec" puts " → 创建 package.json(name 使用全小写)" puts Pindo::Unity::NugetHelper.handle_case_b(package_dir, status[:nuspec_file]) when [true, true] puts "📝 情况C:同时存在两个文件" puts " → 以 .nuspec 为准同步到 package.json" puts Pindo::Unity::NugetHelper.handle_case_c(package_dir, status[:nuspec_file]) when [false, false] puts "❌ 情况D:都不存在" Pindo::Unity::NugetHelper.handle_case_d(package_dir) end puts puts "=" * 60 puts "✅ 初始化完成!" puts "=" * 60 puts puts "下一步:" puts " 运行 pindo unity pack 进行打包" end |