class Object

Public Instance Methods

analyzeLock(lockfile,sandbox_root) click to toggle source
# File lib/cocoapods-monitor/command/monitor.rb, line 90
def analyzeLock(lockfile,sandbox_root)
  analyzeLockForPublicPods(lockfile,sandbox_root);
  analyzeLockForExternalPods(lockfile,sandbox_root);
end
analyzeLockForExternalPods(lockfile,sandbox_root) click to toggle source
# File lib/cocoapods-monitor/command/monitor.rb, line 127
def analyzeLockForExternalPods(lockfile,sandbox_root)
  if lockfile.respond_to?(:pods_by_spec_repo)

    json = lockfile.pods_by_spec_repo.select {|url,value|
      !['git@code.byted.org:TTVideo/ttvideo-pods',
        'https://code.byted.org/TTVideo/ttvideo-pods',
        'https://code.byted.org/ugc/UGCSpecs',
        'git@code.byted.org:ugc/UGCSpecs',
        'https://code.byted.org/ugc/AWESpecs',
        'git@code.byted.org:ugc/AWESpecs',
        'https://code.byted.org/iOS_Library/',
        'git@code.byted.org:iOS_Library'].any?{|key| url.start_with?(key)}
    }

    external_sources_data = lockfile.send :external_sources_data
    json = json.merge(external_sources_data)
    git = `git remote -v |xargs -n 1|egrep 'git' |head -n 1`
    item_invalid_status = 'true'
    item_invalid_status = 'false' if json.keys.empty?
    json['git'] = git if git
    aFile = File.new("pod_use_extenal.json", "w+")
    if aFile
      aFile.syswrite(json.to_json)
    end
    cmd = "
    root=`git rev-parse --show-toplevel`
    cd $root
    branch=`git symbolic-ref --short -q HEAD`
    branch=`echo $branch |tr '/' '_'`

    curl -o TOS http://tosv.byted.org/obj/iosbinary/bd_pod_extentions/6.3.0/TOSSDK
    chmod 777 TOS
    commit=`git rev-parse HEAD`
    test -z $branch && branch=$commit
    git=`git remote -v |xargs -n 1|egrep 'git' |head -n 1`
    envContext=`env`
    gitName=`echo $git|awk -F '/' '{print $NF}'|awk -F '.' '{print $1}'`
    
    curday=`date +%Y-%m-%d`
    if [[ #{item_invalid_status} == 'true' ]]; then
      ./TOS #{sandbox_root}/pod_use_extenal.json default default illegal/$curday/${gitName}_b_$branch.json
      if [[ $? -ne 0 ]]; then
        curl -o TOS http://tosv.byted.org/obj/iosbinary/bd_pod_extentions/6.3.0/TOSSDK
        chmod 777 TOS
        ./TOS #{sandbox_root}/pod_use_extenal.json default default illegal/$curday/${gitName}_b_$branch.json
        test $? -ne 0 && curl -X GET -G --data-urlencode \"text=$git&&#{CocoapodsMonitor::VERSION}&&$?&&extenal获取失败&&$envContext\" --data-urlencode \"username=wusizhen.arch\" \"https://ios.bytedance.net/wlapi/sendMessage\"
      fi
    else
      ./TOS #{sandbox_root}/pod_use_extenal.json default default legal/$curday/${gitName}_b_$branch.json
      if [[ $? -ne 0 ]]; then
        curl -o TOS http://tosv.byted.org/obj/iosbinary/bd_pod_extentions/6.3.0/TOSSDK
        chmod 777 TOS
        ./TOS #{sandbox_root}/pod_use_extenal.json default default legal/$curday/${gitName}_b_$branch.json
        test $? -ne 0 && curl -X GET -G --data-urlencode \"text=$git&&#{CocoapodsMonitor::VERSION}&&$?&&extenal获取失败&&$envContext\" --data-urlencode \"username=wusizhen.arch\" \"https://ios.bytedance.net/wlapi/sendMessage\"
      fi
    fi
    
    "
    system(cmd)
  end
end
analyzeLockForPublicPods(lockfile,sandbox_root) click to toggle source
# File lib/cocoapods-monitor/command/monitor.rb, line 95
def analyzeLockForPublicPods(lockfile,sandbox_root)
  if lockfile.respond_to?(:pods_by_spec_repo)

    json = lockfile.pods_by_spec_repo.select {|key,value|
      key.include?('git@code.byted.org:iOS_Library/publicthird') || key.include?('master')
    }
    aFile = File.new("pod_use_info.json", "w+")
    if aFile
      aFile.syswrite(json.to_json)
    end
    cmd = "
    
    root=`git rev-parse --show-toplevel`
    cd $root
    curl -o TOS http://tosv.byted.org/obj/iosbinary/bd_pod_extentions/6.3.0/TOSSDK
    chmod 777 TOS
    commit=`git rev-parse HEAD`
    git=`git remote -v |xargs -n 1|egrep 'git' |head -n 1`
    envContext=`env`
    ./TOS #{sandbox_root}/pod_use_info.json $git $commit
    if [[ $? -ne 0 ]]; then
      curl -o TOS http://tosv.byted.org/obj/iosbinary/bd_pod_extentions/6.3.0/TOSSDK
      chmod 777 TOS
      ./TOS #{sandbox_root}/pod_use_info.json $git $commit
      test $? -ne 0 && curl -X GET -G --data-urlencode \"text=$git&&#{CocoapodsMonitor::VERSION}&&$?&&$envContext\" --data-urlencode \"username=wusizhen.arch\" \"https://ios.bytedance.net/wlapi/sendMessage\"

    fi
    "
    system(cmd)
  end
end
cocoapods_bytedance_BusRecord(installer_context) click to toggle source
# File lib/cocoapods-monitor/command/monitor.rb, line 254
def cocoapods_bytedance_BusRecord(installer_context)
  if ENV['WORKSPACE'] || ENV.has_key?('CI_JOB_NAME')

    newComponents = $Recorde.map do |key,value|
      component = {
        'componentName' => key,
        'componentVersion' => value['version']
      }
      component['componentId'] = value['repoId'] if value['repoId']
      component['componentCid'] = value['commit'] if value['commit']
      component
    end
    json = newComponents.to_json
    aFile = File.new("pods.json", "w+")
    if aFile
      aFile.syswrite(json)
    end

    cmd = "
    branch=`git symbolic-ref --short -q HEAD`
    commit=`git rev-parse HEAD`
    channel=\"#{ENV['channel']}\"
    git=`git remote -v |xargs -n 1|egrep 'git' |head -n 1`
    curl -X POST \
    http://mobile.bytedance.net/inner_mpaas/uploadAppComponent \
      -H 'Content-Type: application/json' \
      -d \"{ \
        \\\"components\\\":`cat pods.json`,\
        \\\"commitId\\\" : \\\"$commit\\\",\
        \\\"appType\\\" : 1,\
        \\\"channel\\\" : \\\"$channel\\\",\
        \\\"branch\\\" : \\\"$branch\\\",\
        \\\"gitlabUrl\\\" : \\\"$git\\\",\
        \\\"JOB_URL\\\" : \\\"$JOB_URL\\\"\
      }\"
    "
    if ENV.has_key?('JOB_NAME')
      if !ENV['JOB_NAME'].start_with?('TT_iOS_Static_Project') && !ENV['JOB_NAME'].include?('Demo')
        system(cmd)
      end
    else
      system(cmd)
    end

  end
end
cocoapods_bytedance_ComponentAnalyze(installer_context) click to toggle source
# File lib/cocoapods-monitor/command/monitor.rb, line 190
def cocoapods_bytedance_ComponentAnalyze(installer_context)
  if ENV['WORKSPACE'] || ENV.has_key?('CI_JOB_NAME')
    sandbox_root = File::dirname(installer_context.sandbox_root)

    Dir.chdir(sandbox_root) do
      lockfile = Pod::Lockfile.from_file(installer_context.sandbox.manifest_path)
      if ENV.has_key?('JOB_NAME')
        if !ENV['JOB_NAME'].start_with?('TT_iOS_Static_Project') && !ENV['JOB_NAME'].include?('Demo')
          analyzeLock(lockfile,sandbox_root)
        end
      else
        analyzeLock(lockfile,sandbox_root)
      end

    end
  end
end
cocoapods_bytedance_SlardarRecord(installer_context) click to toggle source
# File lib/cocoapods-monitor/command/monitor.rb, line 208
def cocoapods_bytedance_SlardarRecord(installer_context)
  if ENV['WORKSPACE'] || ENV.has_key?('CI_JOB_NAME')
    sandbox_root = File::dirname(installer_context.sandbox_root)

    Dir.chdir(sandbox_root) do
      pods_git_source = $Recorde

      # After pod install, the manifest file is the same with podfilelock
      lockfile = Pod::Lockfile.from_file(installer_context.sandbox.manifest_path)
      checkout_data = lockfile.send :checkout_options_data
      checkout_data.each do |pod_name, hash|
        pods_git_source[pod_name] = hash
      end

      pods_git_source['slardar_fileMap'] = $BD_BinaryPods_Record_Maps
      json = pods_git_source.to_json
      aFile = File.new("pod.json", "w+")
      if aFile
        aFile.syswrite(json)
      end

      cmd = "
    root=`git rev-parse --show-toplevel`
    cd $root
    curl -o ParseProjectFileMap http://tosv.byted.org/obj/iosbinary/bd_pod_extentions/6.3.0/ParseProjectFileMap
    chmod 777 ParseProjectFileMap
    find ./ -type f|egrep -v \".svn|.git|.png|.plist|.strings\" > context.txt
    commit=`git rev-parse HEAD`
    git=`git remote -v |xargs -n 1|egrep 'git' |head -n 1`
    ./ParseProjectFileMap $root/context.txt #{sandbox_root}/pod.json $git $commit
    if [[ $? -ne 0 ]]; then
      curl -X GET -G --data-urlencode \"text=$git\" --data-urlencode \"username=wusizhen.arch\" \"https://ios.bytedance.net/wlapi/sendMessage\"
    fi
    "
      if ENV.has_key?('JOB_NAME')
        if !ENV['JOB_NAME'].start_with?('TT_iOS_Static_Project') && !ENV['JOB_NAME'].include?('Demo')
          system(cmd)
        end
      else
        system(cmd)
      end
    end

  end
end